/*
* 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"
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <locale.h>
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <string.h>
#include <project.h>
#include <stdlib.h>
#include <alloca.h>
typedef enum TYPE {
} TYPE;
typedef enum PRINT {
} PRINT;
static int usage(void);
int
{
int i, j;
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
#endif
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'G':
return (usage());
break;
case 'g':
return (usage());
break;
case 'a':
aflag++;
break;
case 'n':
nflag++;
break;
case 'r':
rflag++;
break;
case 'u':
return (usage());
break;
case 'p':
return (usage());
project_flag++;
break;
case '?':
return (usage());
}
}
/* -n and -r must be combined with one of -[Ggu] */
/* -r cannot be combined with -G */
/* -a and -p cannot be combined with -[Ggu] */
return (usage());
if (argc == 2) {
gettext("id: invalid user name: \"%s\"\n"),
argv[1]);
return (1);
}
} else {
}
if (!rflag) {
}
if (user)
prgid);
else
if (i == -1)
perror("getgroups");
else if (i > 0) {
for (j = 0; j < i; ++j) {
continue;
(void) putchar(' ');
}
}
}
(void) putchar('\n');
} else {
if (aflag) {
if (user)
prgid);
else
if (i == -1)
perror("getgroups");
else if (i > 0) {
(void) printf(" groups=");
(void) printf("(%s)",
if (i)
(void) putchar(',');
}
}
}
#ifdef XPG4
/*
* POSIX requires us to show all supplementary groups
* groups other than the effective group already listed.
*
* This differs from -a above, because -a always shows
* all groups including the effective group in the group=
* line.
*
* It would be simpler if SunOS could just adopt this
* POSIX behavior, as it is so incredibly close to the
* the norm already.
*
* Then the magic -a flag could just indicate whether or
* not we are suppressing the effective group id.
*/
else {
if (user)
prgid);
else
if (i == -1)
perror("getgroups");
else if (i > 1) {
(void) printf(" groups=");
continue;
(void) printf("(%s)",
if (i)
(void) putchar(',');
}
}
}
#endif
if (project_flag) {
void *projbuf;
"memory\n");
return (2);
}
if (user) {
PROJECT_BUFSZ) != NULL)
(void) printf(" projid=%d(%s)",
else
/*
* This can only happen if project
* "default" has been removed from
* project database file was removed.
*/
(void) printf(" projid=(NONE)");
} else {
PROJECT_BUFSZ) == NULL)
(void) printf(" projid=%d",
(int)curprojid);
else
(void) printf(" projid=%d(%s)",
}
}
(void) putchar('\n');
}
return (0);
}
static int
usage()
{
"Usage: id [-ap] [user]\n"
" id -G [-n] [user]\n"
" id -g [-nr] [user]\n"
" id -u [-nr] [user]\n"));
return (2);
}
static void
{
else
}
static void
{
else
}
static void
{
char *s;
switch ((int)how) {
case UID:
s = "uid";
break;
case EUID:
s = " euid";
break;
case GID:
s = " gid";
break;
case EGID:
s = " egid";
break;
}
if (s != NULL)
(void) printf("%s=", s);
switch ((int)how) {
case UID:
case EUID:
{
}
break;
case GID:
case EGID:
{
}
break;
}
}
/*
* Get the supplementary group affiliation for the user
*/
int gidsetsize;
char *user;
{
char **gr_mem;
int ngroups = 0;
setgrent();
if (gidsetsize)
ngroups++;
}
endgrent();
if (gidsetsize && !ngroups)
return (ngroups);
}