diff options
author | Andrew Morgan <morgan@kernel.org> | 2007-07-10 22:38:22 -0700 |
---|---|---|
committer | Jorge Lucangeli Obes <jorgelo@google.com> | 2015-09-03 14:13:03 -0700 |
commit | ec25bd9b420ab62bcc3ec709f467eb43d434b66d (patch) | |
tree | 99f84e363efe6a246a9b1ab798c82e7d0cc383c5 /libcap | |
parent | f9c44c45c23630bcf24135d7972a298aad5949ea (diff) | |
download | libcap-ec25bd9b420ab62bcc3ec709f467eb43d434b66d.tar.gz |
Prepare for 1.95 release.
Diffstat (limited to 'libcap')
-rw-r--r-- | libcap/Makefile | 28 | ||||
-rw-r--r-- | libcap/_makenames.c | 29 | ||||
-rw-r--r-- | libcap/cap_alloc.c | 30 | ||||
-rw-r--r-- | libcap/cap_extint.c | 24 | ||||
-rw-r--r-- | libcap/cap_file.c | 33 | ||||
-rw-r--r-- | libcap/cap_flag.c | 24 | ||||
-rw-r--r-- | libcap/cap_proc.c | 35 | ||||
-rw-r--r-- | libcap/cap_sys.c | 25 | ||||
-rw-r--r-- | libcap/cap_text.c | 51 | ||||
-rw-r--r-- | libcap/include/sys/capability.h | 2 | ||||
-rw-r--r-- | libcap/libcap.h | 40 |
11 files changed, 38 insertions, 283 deletions
diff --git a/libcap/Makefile b/libcap/Makefile index 4572673..4af306b 100644 --- a/libcap/Makefile +++ b/libcap/Makefile @@ -1,26 +1,3 @@ -## -## $Log: Makefile,v $ -## Revision 1.1.1.1 1999/04/17 22:16:31 morgan -## release 1.0 of libcap -## -## Revision 1.5 1998/05/24 22:54:09 morgan -## updated for 2.1.104 -## -## Revision 1.4 1997/05/14 05:17:13 morgan -## autoconf rearrangement from Zefram -## -## Revision 1.3 1997/05/04 05:34:59 morgan -## cleaner -## -## Revision 1.2 1997/04/28 00:57:11 morgan -## fixes and zefram's patches -## -## Revision 1.1 1997/04/21 04:33:29 morgan -## Initial revision -## -## -## - # # defines # @@ -56,13 +33,16 @@ cap_names.sed: Makefile /usr/include/linux/capability.h # @sed -ne '/^#define[ \t]CAP[_A-Z]\+[ \t]\+[0-9]\+/{s/^#define CAP_\([^ \t]*\)[ \t]*\([^ \t]*\)/ \{ \2, \"\1\" \},/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;p;}' < /usr/include/linux/capability.h | fgrep -v 0x > cap_names.sed $(MINLIBNAME): $(OBJS) - $(LD) -soname $(MAJLIBNAME) -x -shared -o $@ $(OBJS) + $(CC) -Wl,-soname -Wl,$(MAJLIBNAME) -Wl,-x -shared -o $@ $(OBJS) ln -sf $(MINLIBNAME) $(MAJLIBNAME) ln -sf $(MAJLIBNAME) $(LIBNAME) %.o: %.c $(INCLS) $(CC) $(CFLAGS) -c $< -o $@ +cap_sys.o: cap_sys.c $(INCLS) + $(CC) -fPIC -Wall -O2 -c $< -o $@ + install: all mkdir -p -m 0755 $(INCDIR)/sys install -m 0644 include/sys/capability.h $(INCDIR)/sys diff --git a/libcap/_makenames.c b/libcap/_makenames.c index ebb17f6..61a7c47 100644 --- a/libcap/_makenames.c +++ b/libcap/_makenames.c @@ -1,7 +1,5 @@ /* - * $Id: _makenames.c,v 1.3 1999/05/14 04:46:15 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G. Morgan <morgan@linux.kernel.org> + * Copyright (c) 1997-8 Andrew G. Morgan <morgan@kernel.org> * * This is a file to make the capability <-> string mappings for * libcap. @@ -61,28 +59,3 @@ int main(void) exit(0); } - -/* - * $Log: _makenames.c,v $ - * Revision 1.3 1999/05/14 04:46:15 morgan - * another attempt to fix the bug Chris Evans found - * - * Revision 1.2 1999/05/14 04:38:06 morgan - * Fix from Chris Evans: off by one error when computing the name array - * - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.4 1998/06/07 15:50:12 morgan - * updated to accommodate kernel's real header file :*) - * - * Revision 1.3 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.2 1997/05/04 05:35:46 morgan - * cleaned up to #include sed output. also generates whole cap_names.c file - * - * Revision 1.1 1997/04/28 00:57:11 morgan - * Initial revision - * - */ diff --git a/libcap/cap_alloc.c b/libcap/cap_alloc.c index 3d3168e..a3b22a7 100644 --- a/libcap/cap_alloc.c +++ b/libcap/cap_alloc.c @@ -1,9 +1,5 @@ /* - * $Id: cap_alloc.c,v 1.3 1999/11/18 07:23:24 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G Morgan <morgan@linux.kernel.org> - * - * See end of file for Log. + * Copyright (c) 1997-8 Andrew G Morgan <morgan@kernel.org> * * This file deals with allocation and deallocation of internal * capability sets as specified by POSIX.1e (formerlly, POSIX 6). @@ -97,6 +93,8 @@ cap_t cap_dup(cap_t cap_d) int cap_free(void *data_p) { + if ( !data_p ) + return 0; if ( good_cap_t(data_p) ) { data_p = -1 + (__u32 *) data_p; @@ -119,25 +117,3 @@ int cap_free(void *data_p) errno = EINVAL; return -1; } - -/* - * $Log: cap_alloc.c,v $ - * Revision 1.3 1999/11/18 07:23:24 morgan - * final fixes tested on a RH6.0 system for release-1.10 - * - * Revision 1.2 1999/11/18 06:03:26 morgan - * fixed cap_free to work as indicated in manuals - * - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.3 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * fixes and zefram's patches - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/cap_extint.c b/libcap/cap_extint.c index 3b0536b..1d858a1 100644 --- a/libcap/cap_extint.c +++ b/libcap/cap_extint.c @@ -1,9 +1,5 @@ /* - * $Id: cap_extint.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G Morgan <morgan@linux.kernel.org> - * - * See end of file for Log. + * Copyright (c) 1997-8 Andrew G Morgan <morgan@kernel.org> * * This file deals with exchanging internal and external * representations of capability sets. @@ -91,7 +87,7 @@ cap_t cap_copy_int(const void *cap_ext) (const struct cap_ext_struct *) cap_ext; cap_t cap_d; int set, blen; - __u32 * to = (__u32 *) &cap_d->set; + __u32 * to; /* Does the external representation make sense? */ if (export == NULL || !memcmp(export->magic, external_magic @@ -104,6 +100,7 @@ cap_t cap_copy_int(const void *cap_ext) if (!(cap_d = cap_init())) return NULL; + to = (__u32 *) &cap_d->set; blen = export->length_of_capset; for (set=0; set<=NUMBER_OF_CAP_SETS; ++set) { int blk; @@ -128,18 +125,3 @@ cap_t cap_copy_int(const void *cap_ext) return cap_d; } -/* - * $Log: cap_extint.c,v $ - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.3 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * fixes and zefram's patches - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/cap_file.c b/libcap/cap_file.c index ba51f15..85d72cb 100644 --- a/libcap/cap_file.c +++ b/libcap/cap_file.c @@ -1,9 +1,5 @@ /* - * $Id: cap_file.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ - * - * Copyright (c) 1997 Andrew G Morgan <morgan@linux.kernel.org> - * - * See end of file for Log. + * Copyright (c) 1997 Andrew G Morgan <morgan@kernel.org> * * This file deals with setting capabilities on files. */ @@ -29,7 +25,8 @@ cap_t cap_get_fd(int fildes) &result->set[CAP_INHERITABLE], &result->set[CAP_PERMITTED], &result->set[CAP_EFFECTIVE] )) { - cap_free(&result); + cap_free(result); + result = NULL; } } @@ -54,7 +51,8 @@ cap_t cap_get_file(const char *filename) &result->set[CAP_INHERITABLE], &result->set[CAP_PERMITTED], &result->set[CAP_EFFECTIVE] )) - cap_free(&result); + cap_free(result); + result = NULL; } return result; @@ -97,24 +95,3 @@ int cap_set_file(const char *filename, cap_t cap_d) &cap_d->set[CAP_EFFECTIVE] ); } -/* - * $Log: cap_file.c,v $ - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.5 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.4 1997/05/14 05:17:13 morgan - * bug-fix from zefram (errno no set on success) - * - * Revision 1.3 1997/05/04 05:35:46 morgan - * fixed errno setting. syscalls do this part - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * fixes and zefram's patches - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/cap_flag.c b/libcap/cap_flag.c index 2181ade..a8567c0 100644 --- a/libcap/cap_flag.c +++ b/libcap/cap_flag.c @@ -1,9 +1,5 @@ /* - * $Id: cap_flag.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G. Morgan <morgan@linux.kernel.org> - * - * See end of file for Log. + * Copyright (c) 1997-8 Andrew G. Morgan <morgan@kernel.org> * * This file deals with flipping of capabilities on internal * capability sets as specified by POSIX.1e (formerlly, POSIX 6). @@ -105,21 +101,3 @@ int cap_clear(cap_t cap_d) } } -/* - * $Log: cap_flag.c,v $ - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.4 1998/09/20 23:07:59 morgan - * fixed lower bound check on 'set'. - * - * Revision 1.3 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * fixes and zefram's patches - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/cap_proc.c b/libcap/cap_proc.c index a7a6b73..5c2ac48 100644 --- a/libcap/cap_proc.c +++ b/libcap/cap_proc.c @@ -1,9 +1,5 @@ /* - * $Id: cap_proc.c,v 1.2 1999/04/18 20:50:01 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G Morgan <morgan@linux.kernel.org> - * - * See end of file for Log. + * Copyright (c) 1997-8 Andrew G Morgan <morgan@kernel.org> * * This file deals with setting capabilities on processes. */ @@ -21,7 +17,8 @@ cap_t cap_get_proc(void) /* fill the capability sets via a system call */ if (capget(&result->head, &result->set)) { - cap_free(&result); + cap_free(result); + result = NULL; } } @@ -87,29 +84,3 @@ int capsetp(pid_t pid, cap_t cap_d) return error; } -/* - * $Log: cap_proc.c,v $ - * Revision 1.2 1999/04/18 20:50:01 morgan - * reliable behavior when trying to talk with a kernel that has a more - * modern capability implementation than the one the library was compiled - * with. - * - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.5 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.4 1997/05/14 05:17:13 morgan - * bug-fix from zefram (errno no set on success) - * - * Revision 1.3 1997/05/04 05:35:46 morgan - * fixed errno setting. syscalls do this part - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * fixes and zefram's patches - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/cap_sys.c b/libcap/cap_sys.c index f28e8a3..27c137d 100644 --- a/libcap/cap_sys.c +++ b/libcap/cap_sys.c @@ -1,15 +1,12 @@ /* - * $Id: cap_sys.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G. Morgan <morgan@linux.kernel.org> + * Copyright (c) 1997-8 Andrew G. Morgan <morgan@kernel.org> * * This file contains the system calls for getting and setting * capabilities */ -#include "libcap.h" -#define __LIBRARY__ #include <linux/unistd.h> +#include <linux/capability.h> _syscall2(int, capget, cap_user_header_t, header, @@ -19,21 +16,3 @@ _syscall2(int, capset, cap_user_header_t, header, const cap_user_data_t, data) -/* - * $Log: cap_sys.c,v $ - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.4 1998/06/08 00:14:01 morgan - * change to accommodate alpha (glibc?) - * - * Revision 1.3 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * fixes and zefram's patches - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/cap_text.c b/libcap/cap_text.c index c69e89b..5814093 100644 --- a/libcap/cap_text.c +++ b/libcap/cap_text.c @@ -1,11 +1,7 @@ /* - * $Id: cap_text.c,v 1.3 1999/11/18 06:03:26 morgan Exp $ - * - * Copyright (c) 1997-8 Andrew G Morgan <morgan@linux.kernel.org> + * Copyright (c) 1997-8 Andrew G Morgan <morgan@kernel.org> * Copyright (c) 1997 Andrew Main <zefram@dcs.warwick.ac.uk> * - * See end of file for Log. - * * This file deals with exchanging internal and textual * representations of capability sets. */ @@ -57,18 +53,23 @@ static char const *namcmp(char const *str, char const *nam) static int lookupname(char const **strp) { - char const *str = *strp; - if (isdigit(*str)) { - unsigned long n = strtoul(str, (char **)&str, 0); + union { + char const *constp; + char *p; + } str; + + str.constp = *strp; + if (isdigit(*str.constp)) { + unsigned long n = strtoul(str.constp, &str.p, 0); if (n >= __CAP_BITS) return -1; - *strp = str; + *strp = str.constp; return n; } else { char const *s; int n; for (n = __CAP_BITS; n--; ) - if (_cap_names[n] && (s = namcmp(str, _cap_names[n]))) { + if (_cap_names[n] && (s = namcmp(str.constp, _cap_names[n]))) { *strp = s; return n; } @@ -209,9 +210,10 @@ cap_t cap_from_text(const char *str) } bad: - cap_free(&res); + cap_free(res); + res = NULL; errno = EINVAL; - return NULL; + return res; } /* @@ -306,28 +308,3 @@ char *cap_to_text(cap_t caps, ssize_t *length_p) return (_libcap_strdup(buf)); } - -/* - * $Log: cap_text.c,v $ - * Revision 1.3 1999/11/18 06:03:26 morgan - * fixed cap_free to work as indicated in manuals - * - * Revision 1.2 1999/04/17 23:25:09 morgan - * fixes from peeterj - * - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.4 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.3 1997/05/04 05:37:00 morgan - * case sensitvity to capability flags - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * zefram's replacement file with a number of bug fixes from AGM - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ diff --git a/libcap/include/sys/capability.h b/libcap/include/sys/capability.h index 5afd3b0..f38f81d 100644 --- a/libcap/include/sys/capability.h +++ b/libcap/include/sys/capability.h @@ -3,7 +3,7 @@ * * * Copyright (C) 1997 Aleph One - * Copyright (C) 1997-8 Andrew G. Morgan <morgan@linux.kernel.org> + * Copyright (C) 1997-8 Andrew G. Morgan <morgan@kernel.org> * * defunct POSIX.1e Standard: 25.2 Capabilities <sys/capability.h> */ diff --git a/libcap/libcap.h b/libcap/libcap.h index eff5f8b..20acb6b 100644 --- a/libcap/libcap.h +++ b/libcap/libcap.h @@ -1,9 +1,5 @@ /* - * $Id: libcap.h,v 1.5 1999/11/18 07:23:24 morgan Exp $ - * - * Copyright (c) 1997 Andrew G Morgan <morgan@linux.kernel.org> - * - * See end of file for Log. + * Copyright (c) 1997 Andrew G Morgan <morgan@kernel.org> * * This file contains internal definitions for the various functions in * this small capability library. @@ -117,37 +113,3 @@ extern int capgetp(pid_t pid, cap_t cap_d); extern int capsetp(pid_t pid, cap_t cap_d); #endif /* LIBCAP_H */ - -/* - * $Log: libcap.h,v $ - * Revision 1.5 1999/11/18 07:23:24 morgan - * final fixes tested on a RH6.0 system for release-1.10 - * - * Revision 1.4 1999/11/18 06:25:02 morgan - * added prototype for _libcap_strdup - * - * Revision 1.3 1999/11/18 06:03:26 morgan - * fixed cap_free to work as indicated in manuals - * - * Revision 1.2 1999/04/17 23:25:10 morgan - * fixes from peeterj - * - * Revision 1.1.1.1 1999/04/17 22:16:31 morgan - * release 1.0 of libcap - * - * Revision 1.5 1998/06/08 00:15:28 morgan - * accommodate alpha (glibc?) - * - * Revision 1.4 1998/06/07 15:58:23 morgan - * accommodate real kernel header files :*) - * - * Revision 1.3 1998/05/24 22:54:09 morgan - * updated for 2.1.104 - * - * Revision 1.2 1997/04/28 00:57:11 morgan - * zefram's replacement file with a number of bug fixes from AGM - * - * Revision 1.1 1997/04/21 04:32:52 morgan - * Initial revision - * - */ |