diff options
Diffstat (limited to 'progs')
-rw-r--r-- | progs/Makefile | 3 | ||||
-rw-r--r-- | progs/RCS/Makefile,v | 187 | ||||
-rw-r--r-- | progs/RCS/execcap.c,v | 119 | ||||
-rw-r--r-- | progs/RCS/getpcaps.c,v | 166 | ||||
-rw-r--r-- | progs/RCS/setpcaps.c,v | 207 | ||||
-rw-r--r-- | progs/RCS/sucap.c,v | 266 | ||||
-rw-r--r-- | progs/getpcaps.c | 5 | ||||
-rw-r--r-- | progs/old/RCS/README,v | 25 | ||||
-rw-r--r-- | progs/old/RCS/getcap.c,v | 151 | ||||
-rw-r--r-- | progs/old/RCS/setcap.c,v | 168 | ||||
-rw-r--r-- | progs/old/getcap.c | 5 | ||||
-rw-r--r-- | progs/old/setcap.c | 5 | ||||
-rw-r--r-- | progs/setpcaps.c | 5 | ||||
-rw-r--r-- | progs/sucap.c | 2 |
14 files changed, 20 insertions, 1294 deletions
diff --git a/progs/Makefile b/progs/Makefile index 49cf246..1f78a5e 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -1,5 +1,8 @@ ## ## $Log: Makefile,v $ +## Revision 1.1.1.1 1999/04/17 22:16:31 morgan +## release 1.0 of libcap +## ## Revision 1.6 1998/09/20 23:17:32 morgan ## added sucap.c ## diff --git a/progs/RCS/Makefile,v b/progs/RCS/Makefile,v deleted file mode 100644 index c3e41ab..0000000 --- a/progs/RCS/Makefile,v +++ /dev/null @@ -1,187 +0,0 @@ -head 1.6; -access; -symbols; -locks; strict; -comment @# @; - - -1.6 -date 98.09.20.23.17.32; author morgan; state Exp; -branches; -next 1.5; - -1.5 -date 98.06.07.01.54.43; author morgan; state Exp; -branches; -next 1.4; - -1.4 -date 97.05.14.05.18.23; author morgan; state Exp; -branches; -next 1.3; - -1.3 -date 97.05.04.05.34.03; author morgan; state Exp; -branches; -next 1.2; - -1.2 -date 97.04.28.01.01.20; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 97.04.21.04.34.04; author morgan; state Exp; -branches; -next ; - - -desc -@first take -@ - - -1.6 -log -@added sucap.c -@ -text -@## -## $Log: Makefile,v $ -## Revision 1.5 1998/06/07 01:54:43 morgan -## updated for 0.104. Added execcap. -## -## Revision 1.4 1997/05/14 05:18:23 morgan -## autoconf rearrangement from Zefram -## -## Revision 1.3 1997/05/04 05:34:03 morgan -## took care of case that install cannot handle more than one file -## -## Revision 1.2 1997/04/28 01:01:20 morgan -## update with zefram's patches -## -## Revision 1.1 1997/04/21 04:34:04 morgan -## Initial revision -## -## - -topdir=$(shell pwd)/.. -include $(topdir)/Make.Rules -# -# Programs: all of the examples that we will compile -# -PROGS=getpcaps setpcaps execcap sucap - -# when we have filecaps... -#PROGS+=getcap setcap - -all: $(PROGS) - -$(PROGS): %: %.o - $(CC) $(LDFLAGS) -o $@@ $< $(LIBS) - -%.o: %.c $(INCS) - $(CC) $(CFLAGS) -c $< -o $@@ - -install: all - mkdir -p -m 0755 $(SBINDIR) - for p in $(PROGS) ; do \ - install -s -m 0755 $$p $(SBINDIR) ; \ - done - -clean: - $(LOCALCLEAN) - rm -f *.o $(PROGS) -@ - - -1.5 -log -@updated for 0.104. Added execcap. -@ -text -@d3 3 -d23 1 -a23 1 -# Programs: getcap, setcap and execcap -d25 1 -a25 1 -PROGS=getpcaps setpcaps execcap -@ - - -1.4 -log -@autoconf rearrangement from Zefram -@ -text -@d3 3 -a18 1 - -d20 1 -a20 1 -# Programs: getcap and setcap -d22 4 -a25 1 -PROGS=getcap setcap -@ - - -1.3 -log -@took care of case that install cannot handle more than one file -@ -text -@d3 3 -d14 1 -a14 1 -topdir=.. -d25 1 -a25 1 - $(CC) $(LDFLAGS) -o $@@ $< $(LPATH) -d31 1 -a31 1 - mkdir -p $(BINDIR) -d33 1 -a33 1 - install -s -g root -o root -m 0111 $$p $(BINDIR) ; \ -d37 2 -a38 1 - rm -f *~ core *.o $(PROGS) -@ - - -1.2 -log -@update with zefram's patches -@ -text -@d3 3 -d28 4 -a31 2 - mkdir -p $(FAKEROOT)/bin - install -s -g root -o root -m 0111 $(PROGS) $(BINDIR) -@ - - -1.1 -log -@Initial revision -@ -text -@d3 2 -d6 4 -d14 1 -a14 3 -PROGS=getcap # setcap - -export CFLAGS =-Dlinux $(WARNINGS) $(DEBUG) $(COPTFLAG) $(IPATH) -d18 2 -a19 2 -getcap: getcap.o - $(CC) -o $@@ $< $(LPATH) -d26 1 -a26 2 - strip $(PROGS) - install -g root -o root -m 0111 $(PROGS) $(FAKEROOT)/bin -@ diff --git a/progs/RCS/execcap.c,v b/progs/RCS/execcap.c,v deleted file mode 100644 index 9d1c20a..0000000 --- a/progs/RCS/execcap.c,v +++ /dev/null @@ -1,119 +0,0 @@ -head 1.3; -access; -symbols; -locks; strict; -comment @ * @; - - -1.3 -date 99.01.30.03.41.43; author morgan; state Exp; -branches; -next 1.2; - -1.2 -date 98.06.08.00.16.20; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 98.06.07.01.46.51; author morgan; state Exp; -branches; -next ; - - -desc -@example program to set capabilities of other processes -intended for use in limiting capabilities of programs later -in a chain of execution. -@ - - -1.3 -log -@compiles on a redhat 5.2 system (glibc) -@ -text -@/* - * This was written by Andrew G. Morgan <morgan@@linux.kernel.org> - * - * This is a program that is intended to exec a subsequent program. - * The purpose of this 'execcap' wrapper is to limit the inheritable - * capabilities of the exec()'d program. All environment variables - * are inherited. - */ - -#include <sys/types.h> -#include <errno.h> -#include <stdio.h> -#include <sys/capability.h> -#include <unistd.h> -#include <string.h> - -static void usage(void) -{ - fprintf(stderr, -"usage: execcap <caps> <command-path> [command-args...]\n\n" -" This program is a wrapper that can be used to limit the Inheritable\n" -" capabilities of a program to be executed. Note, this wrapper is\n" -" intended to assist in overcoming a lack of support for filesystem\n" -" capability attributes and should be used to launch other files.\n" -" This program should _NOT_ be made setuid-0.\n\n" -"[Copyright (c) 1998 Andrew G. Morgan <morgan@@linux.kernel.org>]\n"); - - exit(1); -} - -void main(int argc, char **argv) -{ - cap_t new_caps; - - /* this program should not be made setuid-0 */ - if (getuid() && !geteuid()) { - usage(); - } - - /* check that we have at least 2 arguments */ - if (argc < 3) { - usage(); - } - - /* parse the first argument to obtain a set of capabilities */ - new_caps = cap_from_text(argv[1]); - if (new_caps == NULL) { - fprintf(stderr, "requested capabilities were not recognized\n"); - usage(); - } - - /* set these capabilities for the current process */ - if (cap_set_proc(new_caps) != 0) { - fprintf(stderr, "unable to set capabilities: %s\n", strerror(errno)); - usage(); - } - - /* exec the program indicated by args 2 ... */ - execvp(argv[2], argv+2); - - /* if we fall through to here, our exec failed -- announce the fact */ - fprintf(stderr, "Unable to execute command: %s\n", strerror(errno)); - - usage(); -} -@ - - -1.2 -log -@change to accommodate alpha (glibc?) -@ -text -@d15 1 -@ - - -1.1 -log -@Initial revision -@ -text -@d10 1 -@ diff --git a/progs/RCS/getpcaps.c,v b/progs/RCS/getpcaps.c,v deleted file mode 100644 index a5e1e46..0000000 --- a/progs/RCS/getpcaps.c,v +++ /dev/null @@ -1,166 +0,0 @@ -head 1.4; -access; -symbols; -locks; strict; -comment @ * @; - - -1.4 -date 98.09.20.23.07.08; author morgan; state Exp; -branches; -next 1.3; - -1.3 -date 98.06.08.00.16.58; author morgan; state Exp; -branches; -next 1.2; - -1.2 -date 98.06.07.01.49.39; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 98.04.30.02.53.00; author morgan; state Exp; -branches; -next ; - - -desc -@@ - - -1.4 -log -@fixed comment at top -@ -text -@/* - * $Id: getpcaps.c,v 1.3 1998/06/08 00:16:58 morgan Exp morgan $ - * - * Copyright (c) 1997 Andrew G. Morgan <morgan@@linux.kernel.org> - * - * This displays the capabilities of a given process. - */ - -#include <sys/types.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#undef _POSIX_SOURCE -#include <sys/capability.h> - -static void usage(void) -{ - fprintf(stderr, -"usage: getcaps <pid> [<pid> ...]\n\n" -" This program displays the capabilities on the queried process(es).\n" -" The capabilities are displayed in the cap_from_text(3) format.\n\n" -"[Copyright (c) 1997-8 Andrew G. Morgan <morgan@@linux.kernel.org>]\n" - ); - exit(1); -} - -int main(int argc, char **argv) -{ - cap_t cap_d; - - if (argc < 2) { - usage(); - } - - cap_d = cap_init(); - for ( ++argv; --argc > 0; ++argv ) { - ssize_t length; - int pid; - - if (cap_d == NULL) { - fprintf(stderr, "Failed to make a blank capability set\n" - " (%s)\n", strerror(errno)); - exit(1); - } - - pid = atoi(argv[0]); - /* this is a non-POSIX function */ - if (capgetp(pid, cap_d)) { - fprintf(stderr, "Failed to get cap's for proccess %d:" - " (%s)\n", pid, strerror(errno)); - continue; - } else { - char *result = cap_to_text(cap_d, &length); - fprintf(stderr, "Capabilities for `%s': %s\n", *argv, result); - free(result); - result = NULL; - } - } - - return 0; -} - -/* - * $Log: getpcaps.c,v $ - * Revision 1.3 1998/06/08 00:16:58 morgan - * change to accommodate alpha (glibc?) - * - * Revision 1.2 1998/06/07 01:49:39 morgan - * added copyright info and some usage info. Small tidy up. - * - * Revision 1.1 1998/04/30 02:53:00 morgan - * Initial revision - * - */ -@ - - -1.3 -log -@change to accommodate alpha (glibc?) -@ -text -@d2 1 -a2 1 - * $Id: getpcaps.c,v 1.2 1998/06/07 01:49:39 morgan Exp morgan $ -d6 1 -a6 1 - * This displays the capabilities of a given file. -d66 3 -@ - - -1.2 -log -@added copyright info and some usage info. Small tidy up. -@ -text -@d2 1 -a2 1 - * $Id: getpcaps.c,v 1.1 1998/04/30 02:53:00 morgan Exp morgan $ -d9 1 -d66 3 -@ - - -1.1 -log -@Initial revision -@ -text -@d2 1 -a2 1 - * $Id: getcap.c,v 1.3 1997/05/04 05:34:32 morgan Exp $ -d19 4 -a22 3 - "usage: whatcaps <pid> [<pid> ...]\n" - "\n" - "\tdisplays the capabilities on the queried process(es).\n" -a29 1 - char *result=NULL; -d53 1 -a53 1 - result = cap_to_text(cap_d, &length); -d55 2 -d64 4 -a67 1 - * $Log: getcap.c,v $ -@ diff --git a/progs/RCS/setpcaps.c,v b/progs/RCS/setpcaps.c,v deleted file mode 100644 index 621331e..0000000 --- a/progs/RCS/setpcaps.c,v +++ /dev/null @@ -1,207 +0,0 @@ -head 1.3; -access; -symbols; -locks; strict; -comment @ * @; - - -1.3 -date 98.09.20.23.07.08; author morgan; state Exp; -branches; -next 1.2; - -1.2 -date 98.06.08.00.17.38; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 98.06.07.01.46.51; author morgan; state Exp; -branches; -next ; - - -desc -@example program to set capabilities of other processes -intended for use on non-capabilitiy supporting filesystems. -@ - - -1.3 -log -@fixed comment at top -@ -text -@/* - * $Id: setpcaps.c,v 1.2 1998/06/08 00:17:38 morgan Exp morgan $ - * - * Copyright (c) 1997-8 Andrew G. Morgan <morgan@@linux.kernel.org> - * - * This sets the capabilities of a given process. - */ - -#include <sys/types.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#undef _POSIX_SOURCE -#include <sys/capability.h> -#include <unistd.h> - -static void usage(void) -{ - fprintf(stderr, -"usage: setcap [-q] (-|<caps>) <pid> [ ... (-|<capsN>) <pid> ]\n\n" -" This program can be used to set the process capabilities of running\n" -" processes. In order to work, it needs to be executing with CAP_SETPCAP\n" -" raised, and the only capabilities that this program can bestow on others\n" -" are a subset of its effective set. This program is mostly intended as an\n" -" example -- a safe use of CAP_SETPCAP has yet to be demonstrated!\n\n" -"[Copyright (c) 1997-8 Andrew G. Morgan <morgan@@linux.kernel.org>]\n" - ); - exit(1); -} - -#define MAXCAP 2048 - -static int read_caps(int quiet, const char *filename, char *buffer) -{ - int i=MAXCAP; - - if (!quiet) { - fprintf(stderr, "Please enter caps for file [empty line to end]:\n"); - } - while (i > 0) { - int j = read(STDIN_FILENO, buffer, i); - - if (j < 0) { - fprintf(stderr, "\n[Error - aborting]\n"); - exit(1); - } - - if (j==0 || buffer[0] == '\n') { - /* we're done */ - break; - } - - /* move on... */ - - i -= j; - buffer += j; - } - - /* <NUL> terminate */ - buffer[0] = '\0'; - - return (i < MAXCAP ? 0:-1); -} - -int main(int argc, char **argv) -{ - char buffer[MAXCAP+1]; - int retval, quiet=0; - cap_t cap_d; - - if (argc < 3) { - usage(); - } - - while (--argc > 0) { - const char *text; - pid_t pid; - - if (!strcmp(*++argv,"-q")) { - quiet = 1; - continue; - } - if (!strcmp(*argv,"-")) { - retval = read_caps(quiet, *argv, buffer); - if (retval) - usage(); - text = buffer; - } else - text = *argv; - - cap_d = cap_from_text(text); - if (cap_d == NULL) { - perror("fatal error"); - usage(); - } -#ifndef DEBUG - { - ssize_t length; - char *result; - - result = cap_to_text(cap_d, &length); - fprintf(stderr, "[caps set to:\n%s\n]\n", result); - free(result); - result = NULL; - } -#endif - - if (--argc <= 0) - usage(); - - pid = atoi(*++argv); - retval = capsetp(pid, cap_d); - - if (retval != 0) { - fprintf(stderr, "Failed to set cap's on process `%d': (%s)\n", - pid, strerror(errno)); - usage(); - } -#ifndef DEBUG - fprintf(stderr, "[caps set on %d]\n", pid); -#endif - } - - return 0; -} - -/* - * $Log: setpcaps.c,v $ - * Revision 1.2 1998/06/08 00:17:38 morgan - * change to accommodate alpha (glibc?) - * - * Revision 1.1 1998/06/07 01:46:51 morgan - * Initial revision - * - * Revision 1.2 1997/05/04 05:34:32 morgan - * non void main - * - * Revision 1.1 1997/04/28 01:01:20 morgan - * Initial revision - * - */ -@ - - -1.2 -log -@change to accommodate alpha (glibc?) -@ -text -@d2 1 -a2 1 - * $Id: setpcaps.c,v 1.1 1998/06/07 01:46:51 morgan Exp morgan $ -d6 1 -a6 1 - * This sets the capabilities of a given file. -d130 3 -@ - - -1.1 -log -@Initial revision -@ -text -@d2 1 -a2 1 - * $Id: setcap.c,v 1.2 1997/05/04 05:34:32 morgan Exp $ -d9 1 -d129 4 -a132 1 - * $Log: setcap.c,v $ -@ diff --git a/progs/RCS/sucap.c,v b/progs/RCS/sucap.c,v deleted file mode 100644 index dbcf69f..0000000 --- a/progs/RCS/sucap.c,v +++ /dev/null @@ -1,266 +0,0 @@ -head 1.3; -access; -symbols; -locks; strict; -comment @ * @; - - -1.3 -date 99.01.30.03.40.39; author morgan; state Exp; -branches; -next 1.2; - -1.2 -date 98.09.20.23.15.30; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 98.09.20.23.06.06; author morgan; state Exp; -branches; -next ; - - -desc -@example program contributed by Finn Arne Gangstad <finnag@@guardian.no> -@ - - -1.3 -log -@compiles on a redhat 5.2 system (glibc) -@ -text -@/* - * $Id: sucap.c,v 1.2 1998/09/20 23:15:30 morgan Exp morgan $ - * - * This was written by Finn Arne Gangstad <finnag@@guardian.no> - * - * This is a program that is intended to exec a subsequent program. - * The purpose of this 'sucap' wrapper is to change uid but keep all - * privileges. All environment variables are inherited. - */ - -#include <sys/types.h> -#include <errno.h> -#include <stdio.h> -#undef _POSIX_SOURCE -#include <sys/capability.h> -#include <pwd.h> -#define __USE_BSD -#include <grp.h> -#include <unistd.h> -#include <sys/wait.h> -#include <errno.h> -#include <string.h> - -static void usage(void) -{ - fprintf(stderr, -"usage: sucap <user> <group> <command-path> [command-args...]\n\n" -" This program is a wrapper that change UID but not privileges of a\n" -" program to be executed.\n" -" Note, this wrapper is intended to assist in overcoming a lack of support\n" -" for filesystem capability attributes and should be used to launch other\n" -" files. This program should _NOT_ be made setuid-0.\n\n" -"[Copyright (c) 1998 Finn Arne Gangstad <finnag@@guardian.no>]\n"); - - exit(1); -} - - -static void -wait_on_fd(int fd) -{ - /* Wait until some data is available on a file descriptor, or until - * end of file or an error is detected */ - char buf[1]; - while (read(fd, buf, sizeof(buf)) == -1 && errno == EINTR) { - /* empty loop */ - } -} - - -void main(int argc, char **argv) -{ - cap_t old_caps; - uid_t uid; - pid_t pid, parent_pid; - gid_t gid; - int pipe_fds[2]; - - /* this program should not be made setuid-0 */ - if (getuid() && !geteuid()) { - usage(); - } - - /* check that we have at least 3 arguments */ - if (argc < 4) { - usage(); - } - - /* Convert username to uid */ - { - struct passwd *pw = getpwnam(argv[1]); - if (!pw) { - fprintf(stderr, "sucap: No such user: %s\n", argv[1]); - exit(1); - } - uid = pw->pw_uid; - } - - /* Convert groupname to gid */ - { - struct group *gr = getgrnam(argv[2]); - if (!gr) { - fprintf(stderr, "sucap: No such group: %s\n", argv[2]); - exit(1); - } - gid = gr->gr_gid; - } - - /* set process group to current pid */ - if (setpgid(0, getpid())) { - perror("sucap: Failed to set process group"); - exit(1); - } - - if (pipe(pipe_fds)) { - perror("sucap: pipe() failed"); - exit(1); - } - - parent_pid = getpid(); - - old_caps = cap_init(); - if (capgetp(0, old_caps)) { - perror("sucap: capgetp"); - exit(1); - } - - { - ssize_t x; - printf("Caps: %s\n", cap_to_text(old_caps, &x)); - } - - - /* fork off a child to do the hard work */ - fflush(NULL); - pid = fork(); - if (pid == -1) { - perror("sucap: fork failed"); - exit(1); - } - - /* 1. mother process sets gid and uid - * 2. child process sets capabilities of mother process - * 3. mother process execs whatever is to be executed - */ - - if (pid) { - /* Mother process. */ - close(pipe_fds[0]); - - /* Get rid of any supplemental groups */ - if (!getuid() && setgroups(0, 0)) { - perror("sucap: setgroups failed"); - exit(1); - } - - /* Set gid and uid (this probably clears capabilities) */ - setregid(gid, gid); - setreuid(uid, uid); - - { - ssize_t x; - cap_t cap = cap_init(); - capgetp(0, cap); - printf("Caps: %s\n", cap_to_text(cap, &x)); - } - - printf("[debug] uid:%d, real uid:%d\n", geteuid(), getuid()); - - /* Signal child that we want our privileges updated */ - close(pipe_fds[1]); /* Child hangs in blocking read */ - - /* Wait for child process to set our privileges */ - { - int status = 0; - if (wait(&status) == -1) { - perror("sucap: wait failed"); - } - if (!WIFEXITED(status) || WEXITSTATUS(status)) { - fprintf(stderr, "sucap: child did not exit cleanly.\n"); - exit(1); - } - } - - { - ssize_t x; - cap_t cap = cap_init(); - capgetp(0, cap); - printf("Caps: %s\n", cap_to_text(cap, &x)); - } - -/* printf("[debug] uid:%d, real uid:%d\n", geteuid(), getuid()); */ - /* exec the program indicated by args 2 ... */ - execvp(argv[3], argv+3); - - /* if we fall through to here, our exec failed -- announce the fact */ - fprintf(stderr, "Unable to execute command: %s\n", strerror(errno)); - - usage(); - } else { - /* Child process */ - close(pipe_fds[1]); - - /* Wait for mother process to setuid */ - wait_on_fd(pipe_fds[0]); - - /* Set privileges on mother process */ - if (capsetp(parent_pid, old_caps)) { - perror("sucaps: capsetp"); - _exit(1); - } - - /* exit to signal mother process that we are ready */ - _exit(0); - } -} -@ - - -1.2 -log -@a few changes to make it compile for me without any warnings. -@ -text -@d2 1 -a2 1 - * $Id: sucap.c,v 1.1 1998/09/20 23:06:06 morgan Exp morgan $ -d22 1 -@ - - -1.1 -log -@Initial revision -@ -text -@d2 1 -a2 1 - * $Id$ -d14 1 -a15 1 -#include <unistd.h> -d17 1 -d108 1 -a108 1 - size_t x; -d141 1 -a141 1 - size_t x; -d165 1 -a165 1 - size_t x; -@ diff --git a/progs/getpcaps.c b/progs/getpcaps.c index 46a3500..a831547 100644 --- a/progs/getpcaps.c +++ b/progs/getpcaps.c @@ -1,5 +1,5 @@ /* - * $Id: getpcaps.c,v 1.4 1998/09/20 23:07:08 morgan Exp $ + * $Id: getpcaps.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ * * Copyright (c) 1997 Andrew G. Morgan <morgan@linux.kernel.org> * @@ -63,6 +63,9 @@ int main(int argc, char **argv) /* * $Log: getpcaps.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:08 morgan * fixed comment at top * diff --git a/progs/old/RCS/README,v b/progs/old/RCS/README,v deleted file mode 100644 index 304661d..0000000 --- a/progs/old/RCS/README,v +++ /dev/null @@ -1,25 +0,0 @@ -head 1.1; -access; -symbols; -locks; strict; -comment @# @; - - -1.1 -date 98.05.24.23.47.43; author morgan; state Exp; -branches; -next ; - - -desc -@description -@ - - -1.1 -log -@Initial revision -@ -text -@these files are not relevant to this release -@ diff --git a/progs/old/RCS/getcap.c,v b/progs/old/RCS/getcap.c,v deleted file mode 100644 index 04d3a1a..0000000 --- a/progs/old/RCS/getcap.c,v +++ /dev/null @@ -1,151 +0,0 @@ -head 1.3; -access; -symbols; -locks; strict; -comment @ * @; - - -1.3 -date 97.05.04.05.34.32; author morgan; state Exp; -branches; -next 1.2; - -1.2 -date 97.04.28.01.01.20; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 97.04.21.04.34.04; author morgan; state Exp; -branches; -next ; - - -desc -@first take -@ - - -1.3 -log -@non void main -@ -text -@/* - * $Id: getcap.c,v 1.2 1997/04/28 01:01:20 morgan Exp morgan $ - * - * Copyright (c) 1997 Andrew G. Morgan <morgan@@parc.power.net> - * - * This displays the capabilities of a given file. - */ - -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <sys/capability.h> - -static void usage(void) -{ - fprintf(stderr, - "usage: getcap <filename> [<filename> ...]\n" - "\n" - "\tdisplays the capabilities on the queried file(s).\n" - ); - exit(1); -} - -int main(int argc, char **argv) -{ - char *result=NULL; - - if (argc < 2) { - usage(); - } - - for ( ++argv; --argc > 0; ++argv ) { - ssize_t length; - cap_t cap_d; - - cap_d = cap_get_file(argv[0]); - - if (cap_d == NULL) { - fprintf(stderr, - "Failed to get capabilities for file `%s'\n" - " (%s)\n", argv[0], strerror(errno)); - continue; - } - - result = cap_to_text(cap_d, &length); - - fprintf(stderr, "Capabilities for `%s':\n%s\n", *argv, result); - } - - return 0; -} - -/* - * $Log: getcap.c,v $ - * Revision 1.2 1997/04/28 01:01:20 morgan - * update to allow more than one argument file - * - * Revision 1.1 1997/04/21 04:34:04 morgan - * Initial revision - * - */ -@ - - -1.2 -log -@update to allow more than one argument file -@ -text -@d2 1 -a2 1 - * $Id: getcap.c,v 1.1 1997/04/21 04:34:04 morgan Exp morgan $ -d24 1 -a24 1 -void main(int argc, char **argv) -d50 1 -a50 1 - exit(0); -d55 3 -@ - - -1.1 -log -@Initial revision -@ -text -@d2 1 -a2 1 - * $Id$ -d17 1 -a17 1 - "usage: getcap <filename>\n" -d19 1 -a19 1 - "\tdisplays the capabilities on the queried file\n" -a26 2 - ssize_t length; - cap_t cap_d; -d28 1 -a28 1 - if (argc != 2) { -d32 16 -a47 6 - cap_d = cap_get_file(argv[1]); - if (cap_d == NULL) { - fprintf(stderr, - "Failed to get capabilities for file %s\n" - " (%s)\n", argv[1], strerror(errno)); - exit(1); -a49 3 - result = cap_to_text(cap_d, &length); - - fprintf(stderr, "%s", result); -d54 4 -a57 1 - * $Log$ -@ diff --git a/progs/old/RCS/setcap.c,v b/progs/old/RCS/setcap.c,v deleted file mode 100644 index 9b09195..0000000 --- a/progs/old/RCS/setcap.c,v +++ /dev/null @@ -1,168 +0,0 @@ -head 1.2; -access; -symbols; -locks; strict; -comment @ * @; - - -1.2 -date 97.05.04.05.34.32; author morgan; state Exp; -branches; -next 1.1; - -1.1 -date 97.04.28.01.01.20; author morgan; state Exp; -branches; -next ; - - -desc -@update: merged code from me and zefram -@ - - -1.2 -log -@non void main -@ -text -@/* - * $Id: setcap.c,v 1.1 1997/04/28 01:01:20 morgan Exp morgan $ - * - * Copyright (c) 1997 Andrew G. Morgan <morgan@@parc.power.net> - * - * This sets the capabilities of a given file. - */ - -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <sys/capability.h> -#include <unistd.h> - -static void usage(void) -{ - fprintf(stderr, - "usage: setcap [-q] (-|<caps>) <filename> " - "[ ... (-|<capsN>) <filenameN> ]\n" - ); - exit(1); -} - -#define MAXCAP 2048 - -static int read_caps(int quiet, const char *filename, char *buffer) -{ - int i=MAXCAP; - - if (!quiet) { - fprintf(stderr, "Please enter caps for file [empty line to end]:\n"); - } - while (i > 0) { - int j = read(STDIN_FILENO, buffer, i); - - if (j < 0) { - fprintf(stderr, "\n[Error - aborting]\n"); - exit(1); - } - - if (j==0 || buffer[0] == '\n') { - /* we're done */ - break; - } - - /* move on... */ - - i -= j; - buffer += j; - } - - /* <NUL> terminate */ - buffer[0] = '\0'; - - return (i < MAXCAP ? 0:-1); -} - -int main(int argc, char **argv) -{ - char buffer[MAXCAP+1]; - int retval, quiet=0; - cap_t cap_d; - - if (argc < 3) { - usage(); - } - - while (--argc > 0) { - const char *text; - - if (!strcmp(*++argv,"-q")) { - quiet = 1; - continue; - } - if (!strcmp(*argv,"-")) { - retval = read_caps(quiet, *argv, buffer); - if (retval) - usage(); - text = buffer; - } else - text = *argv; - - cap_d = cap_from_text(text); - if (cap_d == NULL) { - perror("fatal error"); - usage(); - } -#ifdef DEBUG - { - ssize_t length; - const char *result; - - result = cap_to_text(cap_d, &length); - fprintf(stderr, "[caps set to:\n%s\n]\n", result); - } -#endif - - if (--argc <= 0) - usage(); - - retval = cap_set_file(*++argv, cap_d); - - if (retval != 0) { - fprintf(stderr, - "Failed to set capabilities on file `%s'\n" - " (%s)\n", argv[0], strerror(errno)); - usage(); - } - } - - return 0; -} - -/* - * $Log: setcap.c,v $ - * Revision 1.1 1997/04/28 01:01:20 morgan - * Initial revision - * - */ -@ - - -1.1 -log -@Initial revision -@ -text -@d2 1 -a2 1 - * $Id: getcap.c,v 1.1 1997/04/21 04:34:04 morgan Exp morgan $ -d58 1 -a58 1 -void main(int argc, char **argv) -d111 1 -a111 1 - exit(0); -d115 4 -a118 1 - * $Log: getcap.c,v $ -@ diff --git a/progs/old/getcap.c b/progs/old/getcap.c index 67d904b..8a7102d 100644 --- a/progs/old/getcap.c +++ b/progs/old/getcap.c @@ -1,5 +1,5 @@ /* - * $Id: getcap.c,v 1.3 1997/05/04 05:34:32 morgan Exp $ + * $Id: getcap.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ * * Copyright (c) 1997 Andrew G. Morgan <morgan@parc.power.net> * @@ -52,6 +52,9 @@ int main(int argc, char **argv) /* * $Log: getcap.c,v $ + * Revision 1.1.1.1 1999/04/17 22:16:31 morgan + * release 1.0 of libcap + * * Revision 1.3 1997/05/04 05:34:32 morgan * non void main * diff --git a/progs/old/setcap.c b/progs/old/setcap.c index 7d959eb..15418da 100644 --- a/progs/old/setcap.c +++ b/progs/old/setcap.c @@ -1,5 +1,5 @@ /* - * $Id: setcap.c,v 1.2 1997/05/04 05:34:32 morgan Exp $ + * $Id: setcap.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ * * Copyright (c) 1997 Andrew G. Morgan <morgan@parc.power.net> * @@ -113,6 +113,9 @@ int main(int argc, char **argv) /* * $Log: setcap.c,v $ + * Revision 1.1.1.1 1999/04/17 22:16:31 morgan + * release 1.0 of libcap + * * Revision 1.2 1997/05/04 05:34:32 morgan * non void main * diff --git a/progs/setpcaps.c b/progs/setpcaps.c index 0389129..9ec3d5f 100644 --- a/progs/setpcaps.c +++ b/progs/setpcaps.c @@ -1,5 +1,5 @@ /* - * $Id: setpcaps.c,v 1.3 1998/09/20 23:07:08 morgan Exp $ + * $Id: setpcaps.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> * @@ -127,6 +127,9 @@ int main(int argc, char **argv) /* * $Log: setpcaps.c,v $ + * Revision 1.1.1.1 1999/04/17 22:16:31 morgan + * release 1.0 of libcap + * * Revision 1.3 1998/09/20 23:07:08 morgan * fixed comment at top * diff --git a/progs/sucap.c b/progs/sucap.c index 3c9c293..b567430 100644 --- a/progs/sucap.c +++ b/progs/sucap.c @@ -1,5 +1,5 @@ /* - * $Id: sucap.c,v 1.3 1999/01/30 03:40:39 morgan Exp $ + * $Id: sucap.c,v 1.1.1.1 1999/04/17 22:16:31 morgan Exp $ * * This was written by Finn Arne Gangstad <finnag@guardian.no> * |