Remove id(1)
Distributions use id(1) from GNU coreutils or BusyBox. Drop ours. Closes: <https://github.com/shadow-maint/shadow/issues/1005> Suggested-by: dkwo <nicolopiazzalunga@gmail.com> Cc: "Serge E. Hallyn" <serge@hallyn.com> Cc: Iker Pedrosa <ipedrosa@redhat.com> Cc: Michael Vetter <jubalh@iodoru.org> Cc: Sam James <sam@gentoo.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
379e9c32f7
commit
c7981fdd00
@@ -471,7 +471,7 @@
|
||||
|
||||
The Shadow Suite contains replacement programs for:
|
||||
|
||||
su, login, passwd, newgrp, chfn, chsh, and id
|
||||
su, login, passwd, newgrp, chfn, chsh
|
||||
|
||||
The package also contains the new programs:
|
||||
|
||||
@@ -586,8 +586,6 @@
|
||||
|
||||
· /usr/bin/chsh
|
||||
|
||||
· /usr/bin/id
|
||||
|
||||
The BETA package has a save target in the Makefile, but it's commented
|
||||
out because different distributions place the programs in different
|
||||
places.
|
||||
@@ -637,8 +635,6 @@
|
||||
|
||||
· /usr/man/man1/chsh.1.gz
|
||||
|
||||
· /usr/man/man1/id.1.gz
|
||||
|
||||
· /usr/man/man1/login.1.gz
|
||||
|
||||
· /usr/man/man1/passwd.1.gz
|
||||
|
||||
+1
-3
@@ -200,8 +200,6 @@ EXTRA_DIST = \
|
||||
$(man_XMANS) \
|
||||
config.xml \
|
||||
$(addprefix login.defs.d/,$(login_defs_v)) \
|
||||
man1/id.1 \
|
||||
id.1.xml \
|
||||
man8/sulogin.8 \
|
||||
sulogin.8.xml \
|
||||
generate_mans.mak \
|
||||
@@ -227,7 +225,7 @@ if ENABLE_REGENERATE_MAN
|
||||
|
||||
include generate_mans.mak
|
||||
|
||||
CLEANFILES = $(man_MANS) man1/id.1 man8/sulogin.8
|
||||
CLEANFILES = $(man_MANS) man8/sulogin.8
|
||||
|
||||
else
|
||||
$(man_MANS):
|
||||
|
||||
@@ -23,7 +23,6 @@ man_MANS += man8/lastlog.8
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/groupmems.8 \
|
||||
man8/logoutd.8
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
.TH ID 1 "GNU Shell Utilities" "FSF" \" \-*\- nroff \-*\-
|
||||
.do hla cs
|
||||
.do hpf hyphen.cs
|
||||
.SH JMÉNO
|
||||
id \- vypíše reálný a efektivní UID a GID
|
||||
.SH POUŽITÍ
|
||||
.B id
|
||||
[\-gnruG] [\-\-group] [\-\-name] [\-\-real] [\-\-user] [\-\-groups]
|
||||
[\-\-help] [\-\-version] [uživatel]
|
||||
.SH POPIS
|
||||
Tato dokumentace není dále udržována a může být nepřesná nebo neúplná.
|
||||
Autoritativním zdrojem je Texinfo dokumentace.
|
||||
.PP
|
||||
Tato manuálová stránka popisuje GNU verzi příkazu
|
||||
.BR id .
|
||||
Příkaz
|
||||
.B id
|
||||
vypíše informace o zadaném uživateli nebo (pokud není jméno uživatele
|
||||
zadáno) o uživateli, který program
|
||||
.B id
|
||||
spustil. Implicitně vypisuje reálné user ID, reálné group ID,
|
||||
efektivní user ID, pokud se liší od reálného user ID, efektivní
|
||||
group ID, pokud se liší od reálného group ID, a group ID skupin,
|
||||
v nichž je uživatel členem. Před každou z hodnot je vypsán řetězec
|
||||
určující o jakou hodnotu se jedná a za každou jsou odpovídající
|
||||
jména skupin a uživatelů v závorkách.
|
||||
.PP
|
||||
Volby způsobí, že program
|
||||
.B id
|
||||
vypisuje pouze některé z těchto informací.
|
||||
.SS VOLBY
|
||||
.TP
|
||||
.I "\-g, \-\-group"
|
||||
Vypíše pouze group ID.
|
||||
.TP
|
||||
.I "\-G, \-\-groups"
|
||||
Vypíše pouze skupiny, v nichž je uživatel členem.
|
||||
.TP
|
||||
.I "\-\-help"
|
||||
Vypíše návod k použití na standardní výstup a bezchybně skončí.
|
||||
.TP
|
||||
.I "\-n, \-\-name"
|
||||
Vypíše jméno uživatele nebo skupiny místo čísla ID.
|
||||
Vyžaduje
|
||||
.IR \-u ,
|
||||
.IR \-g ,
|
||||
nebo
|
||||
.IR \-G .
|
||||
.TP
|
||||
.I "\-r, \-\-real"
|
||||
Vypíše reálné místo efektivních user a group ID.
|
||||
Vyžaduje
|
||||
.IR \-u ,
|
||||
.IR \-g ,
|
||||
nebo
|
||||
.IR \-G .
|
||||
.TP
|
||||
.I "\-u, \-\-user"
|
||||
Vypíše pouze user ID.
|
||||
.TP
|
||||
.I "\-\-version"
|
||||
Vypíše číslo verze na standardní výstup a bezchybně skončí.
|
||||
+1
-2
@@ -21,8 +21,7 @@ man_MANS += $(man_nopam)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1
|
||||
$(man_MANS)
|
||||
|
||||
if USE_PAM
|
||||
EXTRA_DIST += $(man_nopam)
|
||||
|
||||
@@ -58,7 +58,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/sulogin.8
|
||||
|
||||
if USE_PAM
|
||||
|
||||
@@ -68,7 +68,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/sulogin.8
|
||||
|
||||
if USE_PAM
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
.TH ID 1 "GNU Shell Utilities" "FSF" \" \-*\- nroff \-*\-
|
||||
.SH NÉV
|
||||
id \- kiírja a valóságos és effektív UID\-eket és GID\-eket
|
||||
.SH ÁTTEKINTÉS
|
||||
.B id
|
||||
[\-gnruG] [\-\-group] [\-\-name] [\-\-real] [\-\-user] [\-\-groups]
|
||||
[\-\-help] [\-\-version] [username]
|
||||
.SH LEÍRÁS
|
||||
Ezt a dokumentációt a továbbiakban nem tartjuk karban, így
|
||||
pontatlan vagy hiányos lehet. A Texinfo dokumentáció a hiteles forrás.
|
||||
.PP
|
||||
Ez a kézikönyv lap az
|
||||
.BR id
|
||||
GNU változatát írja le. Az
|
||||
.B id
|
||||
információt szolgáltat az adott felhasználóról, vagy arról aki a
|
||||
programot futtatja, ha felhasználó nincs megadva.
|
||||
Alapértelmezésben a valódi felhasználói ID\-t írja ki,
|
||||
a valódi csoport ID\-t, az effektív felhasználói ID\-t, ha az különbözik a
|
||||
valódi felhasználói ID\-től, az effektív csoport ID\-t, ha az különbözik a
|
||||
valódi csoport ID\-től, és a kiegészítő csoportok ID\-it.
|
||||
A parancs ezeket a paramétereket egy sorban, egymás után
|
||||
irja ki, zárójelben megadva a felhasználó, illetve a csoport nevét.
|
||||
.PP
|
||||
Az alábbi opciókkal az
|
||||
.B id
|
||||
képes a fenti információk egy részének a megjelenítésére is.
|
||||
.SS OPCIÓK
|
||||
.TP
|
||||
.I "\-g, \-\-group"
|
||||
Csak a csoport ID\-jét írja ki.
|
||||
.TP
|
||||
.I "\-G, \-\-groups"
|
||||
Csak a kiegészítő csoportok ID\-it írja ki.
|
||||
.TP
|
||||
.I "\-\-help"
|
||||
Használati útmutatót ír a standard kimenetre és kilép.
|
||||
.TP
|
||||
.I "\-n, \-\-name"
|
||||
A nevet jeleníti meg az ID helyet.
|
||||
Szükséges az
|
||||
.IR \-u ,
|
||||
.IR \-g ,
|
||||
vagy
|
||||
.IR \-G
|
||||
paraméter.
|
||||
.TP
|
||||
.I "\-r, \-\-real"
|
||||
A valódi felhasználói vagy csoport ID\-t jeleníti meg az effektív helyett.
|
||||
Szükséges
|
||||
.IR \-u ,
|
||||
.IR \-g ,
|
||||
vagy
|
||||
.IR \-G
|
||||
paraméter.
|
||||
.TP
|
||||
.I "\-u, \-\-user"
|
||||
Csak a felhasználó ID\-jét jeleníti meg.
|
||||
.TP
|
||||
.I "\-\-version"
|
||||
A program verziójáról ír ki információt a standard kimenetre és kilép.
|
||||
.SH MAGYAR FORDÍTÁS
|
||||
Ámon Tamás <sajt@erba.hu>
|
||||
@@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
SPDX-FileCopyrightText: 1991 , Julianne Frances Haugh
|
||||
SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
|
||||
SPDX-License-Identifier: BSD-3-Clause
|
||||
-->
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||
<!-- SHADOW-CONFIG-HERE -->
|
||||
]>
|
||||
<refentry id='id.1'>
|
||||
<!-- $Id$ -->
|
||||
<refentryinfo>
|
||||
<author>
|
||||
<firstname>Julianne Frances</firstname>
|
||||
<surname>Haugh</surname>
|
||||
<contrib>Creation, 1991</contrib>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Thomas</firstname>
|
||||
<surname>Kłoczko</surname>
|
||||
<email>kloczek@pld.org.pl</email>
|
||||
<contrib>shadow-utils maintainer, 2000 - 2007</contrib>
|
||||
</author>
|
||||
<author>
|
||||
<firstname>Nicolas</firstname>
|
||||
<surname>François</surname>
|
||||
<email>nicolas.francois@centraliens.net</email>
|
||||
<contrib>shadow-utils maintainer, 2007 - now</contrib>
|
||||
</author>
|
||||
</refentryinfo>
|
||||
<refmeta>
|
||||
<refentrytitle>id</refentrytitle>
|
||||
<manvolnum>1</manvolnum>
|
||||
<refmiscinfo class="sectdesc">User Commands</refmiscinfo>
|
||||
<refmiscinfo class="source">shadow-utils</refmiscinfo>
|
||||
<refmiscinfo class="version">&SHADOW_UTILS_VERSION;</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv id='name'>
|
||||
<refname>id</refname>
|
||||
<refpurpose>display current user and group ID names</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>id</command> <arg choice='opt'>-a </arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1 id='description'>
|
||||
<title>DESCRIPTION</title>
|
||||
<para>
|
||||
The <command>id</command> command displays the current real and
|
||||
effective user and group ID names or values. If the value does not
|
||||
have a corresponding entry in <filename>/etc/passwd</filename> or
|
||||
<filename>/etc/group</filename>, the value will be displayed without
|
||||
the corresponding name. The optional <option>-a</option> flag will
|
||||
display the group set on systems which support supplementary groups
|
||||
(see <citerefentry><refentrytitle>initgroups</refentrytitle>
|
||||
<manvolnum>3</manvolnum></citerefentry>).
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='files'>
|
||||
<title>FILES</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><filename>/etc/group</filename></term>
|
||||
<listitem>
|
||||
<para>Group account information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><filename>/etc/passwd</filename></term>
|
||||
<listitem>
|
||||
<para>User account information.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='see_also'>
|
||||
<title>SEE ALSO</title>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>getgid</refentrytitle><manvolnum>2</manvolnum>
|
||||
</citerefentry>,
|
||||
<citerefentry>
|
||||
<refentrytitle>getgroups</refentrytitle><manvolnum>2</manvolnum>
|
||||
</citerefentry>,
|
||||
<citerefentry>
|
||||
<refentrytitle>getuid</refentrytitle><manvolnum>2</manvolnum>
|
||||
</citerefentry>,
|
||||
<citerefentry>
|
||||
<refentrytitle>initgroups</refentrytitle><manvolnum>3</manvolnum>
|
||||
</citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
@@ -58,7 +58,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/sulogin.8
|
||||
|
||||
if USE_PAM
|
||||
|
||||
@@ -52,7 +52,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man3/shadow.3 \
|
||||
man8/sulogin.8
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
.\" SPDX-FileCopyrightText: 1991 Julianne Frances Haugh
|
||||
.\" SPDX-FileCopyrightText: Copyright (c) 2000 ISHIKAWA Keisuke
|
||||
.\" SPDX-License-Identifier: BSD-3-Clause
|
||||
.\"
|
||||
.\" Translated Thu Nov 9 23:17:10 JST 2000
|
||||
.\" by ISHIKAWA Keisuke
|
||||
.\" Modified Tue 16 Sep 2002 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
|
||||
.\"
|
||||
.\" $Id$
|
||||
.\"
|
||||
.TH ID 1
|
||||
.SH 名前
|
||||
id \- 現在のユーザ ID 名とグループ ID 名を表示する
|
||||
.SH 書式
|
||||
\fBid\fR [\fB\-a\fR]
|
||||
.SH 説明
|
||||
\fBid\fRは、現在の実ユーザ ID、実効ユーザ ID、実グループ ID、
|
||||
実効グループ ID の名前または値を表示する。
|
||||
値に対応するエントリが \fI/etc/passwd\fR や
|
||||
\fI/etc/group\fR に存在しない場合は、
|
||||
対応する名前は表示されずに値だけが表示される。
|
||||
ユーザが同時に複数のグループのメンバーになれるシステムでは、
|
||||
\fB\-a\fR オプションを指定するとグループの集合が表示される。
|
||||
.SH ファイル
|
||||
\fI/etc/passwd\fR \- ユーザーアカウント情報
|
||||
.br
|
||||
\fI/etc/group\fR \ \- グループ情報
|
||||
.SH 関連項目
|
||||
.BR getgid (2),
|
||||
.BR getgroups (2),
|
||||
.BR getuid (2)
|
||||
.SH 著者
|
||||
Julianne Frances Haugh <julie78787@gmail.com>
|
||||
@@ -1,52 +0,0 @@
|
||||
.TH ID 1L "GNU 쉘 유틸리티" "FSF" \" \-*\- nroff \-*\-
|
||||
.SH 이름
|
||||
id \- 실제, 유효 UID와 GID를 출력한다.
|
||||
.SH 개요
|
||||
.B id
|
||||
[\-gnruG] [\-\-group] [\-\-name] [\-\-real] [\-\-user] [\-\-groups]
|
||||
[\-\-help] [\-\-version] [username]
|
||||
.SH 설명
|
||||
이 맨페이지는 GNU 버전의
|
||||
.BR id
|
||||
를 다룬다.
|
||||
.B id
|
||||
는 주어진 사용자, 또는 사용자가 주어지지 않는 경우 프로세스의 주인에 대한
|
||||
정보를 출력한다. 기본적으로 실제 사용자 ID, 실제 그룹 ID, 만약 실제 사용자
|
||||
ID와 다르다면 유효 사용자 ID를, 마찬가지로 실제 그룹 ID와 다르다면 유효 그룹
|
||||
ID를 출력하고 추가 그룹 ID를 출력한다. 각 항목은 식별 문자 그리고 괄호 안에
|
||||
해당하는 사용자 또는 그룹명으로 표현된다.
|
||||
.PP
|
||||
.B id
|
||||
에 옵션을 주면 위에서 열거한 정보의 일부만 보여준다.
|
||||
.SS 옵션
|
||||
.TP
|
||||
.I "\-g, \-\-group"
|
||||
오로지 그룹 ID만 출력한다.
|
||||
.TP
|
||||
.I "\-G, \-\-groups"
|
||||
추가 그룹만 출력한다.
|
||||
.TP
|
||||
.I "\-\-help"
|
||||
표준출력으로 사용법을 출력하고 정상적으로 종료한다.
|
||||
.TP
|
||||
.I "\-n, \-\-name"
|
||||
ID 번호 대신 사용자명, 그룹명을 출력한다.
|
||||
.IR \-u ,
|
||||
.IR \-g ,
|
||||
또는
|
||||
.IR \-G
|
||||
를 필요로 한다.
|
||||
.TP
|
||||
.I "\-r, \-\-real"
|
||||
유효 사용자, 유효 그룹 ID가 아니라 실제 ID 를 출력한다.
|
||||
.IR \-u ,
|
||||
.IR \-g ,
|
||||
또는
|
||||
.IR \-G
|
||||
를 필요로 한다.
|
||||
.TP
|
||||
.I "\-u, \-\-user"
|
||||
오로지 사용자 ID 만 출력한다.
|
||||
.TP
|
||||
.I "\-\-version"
|
||||
표준출력으로 버전정보를 출력하고 정상적으로 종료한다.
|
||||
+1
-2
@@ -36,8 +36,7 @@ man_MANS += $(man_nopam)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1
|
||||
$(man_MANS)
|
||||
|
||||
if USE_PAM
|
||||
EXTRA_DIST += $(man_nopam)
|
||||
|
||||
@@ -58,7 +58,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/sulogin.8
|
||||
|
||||
if USE_PAM
|
||||
|
||||
+1
-2
@@ -41,8 +41,7 @@ man_MANS += $(man_nopam)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1
|
||||
$(man_MANS)
|
||||
|
||||
if USE_PAM
|
||||
EXTRA_DIST += $(man_nopam)
|
||||
|
||||
@@ -57,7 +57,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/sulogin.8
|
||||
|
||||
if USE_PAM
|
||||
|
||||
@@ -58,7 +58,6 @@ endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_MANS) \
|
||||
man1/id.1 \
|
||||
man8/sulogin.8
|
||||
|
||||
if USE_PAM
|
||||
|
||||
@@ -94,7 +94,6 @@ src/groups.c
|
||||
src/grpck.c
|
||||
src/grpconv.c
|
||||
src/grpunconv.c
|
||||
src/id.c
|
||||
src/lastlog.c
|
||||
src/login.c
|
||||
src/login_nopam.c
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
/grpck
|
||||
/grpconv
|
||||
/grpunconv
|
||||
/id
|
||||
/lastlog
|
||||
/login
|
||||
/logoutd
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ usbin_PROGRAMS = \
|
||||
usermod \
|
||||
vipw
|
||||
|
||||
# id and groups are from gnu, sulogin from sysvinit
|
||||
noinst_PROGRAMS = id sulogin
|
||||
# sulogin from sysvinit
|
||||
noinst_PROGRAMS = sulogin
|
||||
|
||||
suidusbins =
|
||||
suidbins =
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
|
||||
* SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
|
||||
* SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
|
||||
* SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/*
|
||||
* id - print current process user identification information
|
||||
*
|
||||
* Print the current process identifiers. This includes the
|
||||
* UID, GID, effective-UID and effective-GID. Optionally print
|
||||
* the concurrent group set if the current system supports it.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id$"
|
||||
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "alloc/malloc.h"
|
||||
#include "defines.h"
|
||||
|
||||
/* local function prototypes */
|
||||
static void usage (void);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
(void) fputs (_("Usage: id [-a]\n"), stderr);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
uid_t ruid, euid;
|
||||
gid_t rgid, egid;
|
||||
long sys_ngroups;
|
||||
|
||||
/*
|
||||
* This block of declarations is particularly strained because of several
|
||||
* different ways of doing concurrent groups. Old BSD systems used int for
|
||||
* gid's, but short for the type passed to getgroups(). Newer systems use
|
||||
* gid_t for everything. Some systems have a small and fixed NGROUPS,
|
||||
* usually about 16 or 32. Others use bigger values.
|
||||
*/
|
||||
GETGROUPS_T *groups;
|
||||
int ngroups;
|
||||
bool aflg = 0;
|
||||
struct passwd *pw;
|
||||
struct group *gr;
|
||||
|
||||
(void) setlocale (LC_ALL, "");
|
||||
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
(void) textdomain (PACKAGE);
|
||||
|
||||
/*
|
||||
* Dynamically get the maximum number of groups from system, instead
|
||||
* of using the symbolic constant NGROUPS_MAX. This ensures that the
|
||||
* group limit is not hard coded into the binary, so it will still
|
||||
* work if the system library is recompiled.
|
||||
*/
|
||||
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
|
||||
groups = MALLOC(sys_ngroups, GETGROUPS_T);
|
||||
|
||||
/*
|
||||
* See if the -a flag has been given to print out the concurrent
|
||||
* group set.
|
||||
*/
|
||||
|
||||
if (argc > 1) {
|
||||
if (argc > 2 || strcmp(argv[1], "-a") != 0)
|
||||
usage();
|
||||
else
|
||||
aflg = true;
|
||||
}
|
||||
|
||||
ruid = getuid ();
|
||||
euid = geteuid ();
|
||||
rgid = getgid ();
|
||||
egid = getegid ();
|
||||
|
||||
/*
|
||||
* Print out the real user ID and group ID. If the user or group
|
||||
* does not exist, just give the numerical value.
|
||||
*/
|
||||
|
||||
pw = getpwuid (ruid); /* local, no need for xgetpwuid */
|
||||
if (NULL != pw) {
|
||||
(void) printf ("UID=%lu(%s)",
|
||||
(unsigned long) ruid, pw->pw_name);
|
||||
} else {
|
||||
(void) printf ("UID=%lu", (unsigned long) ruid);
|
||||
}
|
||||
|
||||
gr = getgrgid (rgid);; /* local, no need for xgetgrgid */
|
||||
if (NULL != gr) {
|
||||
(void) printf (" GID=%lu(%s)",
|
||||
(unsigned long) rgid, gr->gr_name);
|
||||
} else {
|
||||
(void) printf (" GID=%lu", (unsigned long) rgid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out the effective user ID and group ID if they are
|
||||
* different from the real values.
|
||||
*/
|
||||
|
||||
if (ruid != euid) {
|
||||
pw = getpwuid (euid); /* local, no need for xgetpwuid */
|
||||
if (NULL != pw) {
|
||||
(void) printf (" EUID=%lu(%s)",
|
||||
(unsigned long) euid, pw->pw_name);
|
||||
} else {
|
||||
(void) printf (" EUID=%lu", (unsigned long) euid);
|
||||
}
|
||||
}
|
||||
if (rgid != egid) {
|
||||
gr = getgrgid (egid); /* local, no need for xgetgrgid */
|
||||
if (NULL != gr) {
|
||||
(void) printf (" EGID=%lu(%s)",
|
||||
(unsigned long) egid, gr->gr_name);
|
||||
} else {
|
||||
(void) printf (" EGID=%lu", (unsigned long) egid);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out the concurrent group set if the user has requested it.
|
||||
* The group numbers will be printed followed by their names.
|
||||
*/
|
||||
if (aflg && (ngroups = getgroups (sys_ngroups, groups)) != -1) {
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Start off the group message. It will be of the format
|
||||
*
|
||||
* groups=###(aaa),###(aaa),###(aaa)
|
||||
*
|
||||
* where "###" is a numerical value and "aaa" is the
|
||||
* corresponding name for each respective numerical value.
|
||||
*/
|
||||
(void) puts (_(" groups="));
|
||||
for (i = 0; i < ngroups; i++) {
|
||||
if (0 != i)
|
||||
(void) putchar (',');
|
||||
|
||||
/* local, no need for xgetgrgid */
|
||||
gr = getgrgid (groups[i]);
|
||||
if (NULL != gr) {
|
||||
(void) printf ("%lu(%s)",
|
||||
(unsigned long) groups[i],
|
||||
gr->gr_name);
|
||||
} else {
|
||||
(void) printf ("%lu",
|
||||
(unsigned long) groups[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
free (groups);
|
||||
|
||||
/*
|
||||
* Finish off the line.
|
||||
*/
|
||||
(void) putchar ('\n');
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user