/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <limits.h>
#include <pwd.h>
#include <grp.h>
#include <libproc.h>
extern int _getgroupsbymember(const char *, gid_t[], int, int);
static int look(char *);
static int perr(char *);
static void usage(void);
static void initcred(void);
static char *command;
static char *procname;
static char *user;
static char *group;
static char *grplst;
static char *login;
static long ngroups_max;
int
{
int rc = 0;
int c;
command++;
else
return (perr("sysconf(_SC_NGROUPS_MAX)"));
opterr = 0;
switch (c) {
case 'a':
break;
case 'u':
break;
case 'g':
break;
case 'G':
break;
case 'l':
break;
default:
usage();
/*NOTREACHED*/
}
}
usage();
usage();
if (argc == 0)
usage();
if (doset)
initcred();
/*
* Make sure we'll have enough file descriptors to handle a target
* that has many many mappings.
*/
}
while (argc-- > 0)
}
static void
{
if (ngrp >= 0) {
}
}
static int
{
int gcode;
(void) perr("malloc");
exit(1);
}
}
return (1);
}
(void) perr("getcred");
return (1);
}
if (doset) {
(void) perr("setcred");
return (1);
}
return (0);
}
else
if (!all &&
else
(void) printf("euid=%u ruid=%u suid=%u ",
if (!all &&
else
(void) printf("egid=%u rgid=%u sgid=%u\n",
if (prcred->pr_ngroups != 0 &&
int i;
(void) printf("\tgroups:");
for (i = 0; i < prcred->pr_ngroups; i++)
(void) printf("\n");
}
return (0);
}
static int
perr(char *s)
{
if (s)
else
s = procname;
perror(s);
return (1);
}
static void
usage(void)
{
"\t%s [-u user] [-g group] [-G groups] pid ...\n"
"\t%s -l login pid ...\n"
" (report or modify process credentials)\n",
exit(2);
}
static uint32_t
{
unsigned long res;
char *p;
errno = 0;
return ((uint32_t)-1);
else
}
static gid_t
{
" or bad gid\n",
exit(1);
}
} else {
}
return (res);
}
static void
initcred(void)
{
(void) perr("malloc");
exit(1);
}
exit(1);
}
}
" or bad uid\n",
exit(1);
}
} else {
}
}
char *cgrp;
ngrp = 0;
if (ngrp >= ngroups_max) {
command);
exit(1);
}
/* For iterations of strtok */
}
}
}