aboutsummaryrefslogtreecommitdiff
path: root/progs/RCS/setpcaps.c,v
diff options
context:
space:
mode:
Diffstat (limited to 'progs/RCS/setpcaps.c,v')
-rw-r--r--progs/RCS/setpcaps.c,v207
1 files changed, 0 insertions, 207 deletions
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 $
-@