psecflags.c revision d2a70789f056fc6c9ce3ab047b52126d80b0e3da
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/* Copyright 2015, Richard Lowe. */
#include <err.h>
#include <errno.h>
#include <grp.h>
#include <libintl.h>
#include <procfs.h>
#include <project.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/secflags.h>
#include <libproc.h>
#include <libzonecfg.h>
extern const char *__progname;
static void
{
char buf[1024];
}
/*
* Structure defining idtypes known to the priocntl command
* along with the corresponding names.
*/
static struct idtypes {
char *name;
} idtypes [] = {
{ P_ALL, "all" },
{ P_CTID, "contract" },
{ P_CTID, "ctid" },
{ P_GID, "gid" },
{ P_GID, "group" },
{ P_PGID, "pgid" },
{ P_PID, "pid" },
{ P_PPID, "ppid" },
{ P_PROJID, "project" },
{ P_PROJID, "projid" },
{ P_SID, "session", },
{ P_SID, "sid" },
{ P_SID, "sid" },
{ P_TASKID, "taskid" },
{ P_UID, "uid" },
{ P_UID, "user" },
{ P_ZONEID, "zone" },
{ P_ZONEID, "zoneid" },
{ 0, NULL }
};
static int
{
return (0);
}
}
return (-1);
}
static id_t
{
char *endp;
switch (type) {
case P_UID:
break;
case P_GID:
break;
case P_PROJID:
return (ret);
break;
case P_ZONEID:
return (ret);
break;
default:
break;
}
errno = 0;
return ((id_t)-1);
return (ret);
}
int
{
int ret = 0;
int pgrab_flags = PGRAB_RDONLY;
int opt;
char *idtypename = NULL;
int errc = 0;
switch (opt) {
case 'e':
break;
case 'F':
break;
case 'i':
idtypename = optarg;
break;
case 's':
switch (optarg[0]) {
case 'L':
break;
case 'U':
break;
case 'I':
which = PSF_INHERIT;
break;
case 'E':
"be changed", optarg[0]);
default:
"set: '%c'", optarg[0]);
}
optarg += 2;
}
optarg);
break;
case 'l':
break;
default:
break;
}
}
if (usage) {
gettext("usage:\t%s [-F] { pid | core } ...\n"),
gettext("\t%s -s spec [-i idtype] id ...\n"),
gettext("\t%s -s spec -e command [arg]...\n"),
return (2);
}
if (l_flag) {
secflag_t i;
const char *name;
return (0);
/*
* Don't use the strerror() message for EPERM, "Not Owner"
* which is misleading.
*/
switch (errc) {
case 0:
break;
case EPERM:
"security-flags: Permission denied"));
break;
default:
}
} else if (s_flag) {
int i;
if (idtypename != NULL)
for (i = 0; i < argc; i++) {
"identifier: '%s'"), argv[i]);
}
/*
* Don't use the strerror() message for EPERM, "Not
* Owner" which is misleading.
*/
switch (errno) {
case EPERM:
"security-flags: "
"Permission denied"));
break;
default:
"security-flags"));
}
}
}
return (0);
}
/* Display the flags for the given pids */
while (argc-- > 0) {
struct ps_prochandle *Pr;
const char *arg;
int gcode;
ret = 1;
continue;
}
} else {
(void) printf("%d:\t%.70s\n",
}
}
return (ret);
}