* src/id.c: Ignore the return value of fputs(), puts(), putchar(),
and printf(). * src/id.c: Ignore return value of setlocale(), bindtextdomain(), and textdomain(). * src/id.c: Add brackets and parenthesis. * src/id.c: Avoid implicit conversion of pointers / integers to booleans.
This commit is contained in:
parent
c8626c09af
commit
91c8e1bf0d
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/id.c: Ignore the return value of fputs(), puts(), putchar(),
|
||||||
|
and printf().
|
||||||
|
* src/id.c: Ignore return value of setlocale(),
|
||||||
|
bindtextdomain(), and textdomain().
|
||||||
|
* src/id.c: Add brackets and parenthesis.
|
||||||
|
* src/id.c: Avoid implicit conversion of pointers / integers
|
||||||
|
to booleans.
|
||||||
|
|
||||||
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/chsh.c: Use a bool when possible instead of int integers.
|
* src/chsh.c: Use a bool when possible instead of int integers.
|
||||||
|
76
src/id.c
76
src/id.c
@ -53,9 +53,9 @@ static void usage (void);
|
|||||||
static void usage (void)
|
static void usage (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GETGROUPS
|
#ifdef HAVE_GETGROUPS
|
||||||
fputs (_("Usage: id [-a]\n"), stderr);
|
(void) fputs (_("Usage: id [-a]\n"), stderr);
|
||||||
#else
|
#else
|
||||||
fputs (_("Usage: id\n"), stderr);
|
(void) fputs (_("Usage: id\n"), stderr);
|
||||||
#endif
|
#endif
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
@ -77,14 +77,14 @@ static void usage (void)
|
|||||||
#ifdef HAVE_GETGROUPS
|
#ifdef HAVE_GETGROUPS
|
||||||
GETGROUPS_T *groups;
|
GETGROUPS_T *groups;
|
||||||
int ngroups;
|
int ngroups;
|
||||||
int aflg = 0;
|
bool aflg = 0;
|
||||||
#endif
|
#endif
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
|
|
||||||
setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dynamically get the maximum number of groups from system, instead
|
* Dynamically get the maximum number of groups from system, instead
|
||||||
@ -101,14 +101,16 @@ static void usage (void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (argc > 2 || strcmp (argv[1], "-a"))
|
if ((argc > 2) || (strcmp (argv[1], "-a") != 0)) {
|
||||||
usage ();
|
usage ();
|
||||||
else
|
} else {
|
||||||
aflg = 1;
|
aflg = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (argc > 1)
|
if (argc > 1) {
|
||||||
usage ();
|
usage ();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ruid = getuid ();
|
ruid = getuid ();
|
||||||
@ -122,16 +124,18 @@ static void usage (void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pw = getpwuid (ruid); /* local, no need for xgetpwuid */
|
pw = getpwuid (ruid); /* local, no need for xgetpwuid */
|
||||||
if (pw)
|
if (NULL != pw) {
|
||||||
printf ("UID=%u(%s)", ruid, pw->pw_name);
|
(void) printf ("UID=%u(%s)", ruid, pw->pw_name);
|
||||||
else
|
} else {
|
||||||
printf ("UID=%u", ruid);
|
(void) printf ("UID=%u", ruid);
|
||||||
|
}
|
||||||
|
|
||||||
gr = getgrgid (rgid);; /* local, no need for xgetgrgid */
|
gr = getgrgid (rgid);; /* local, no need for xgetgrgid */
|
||||||
if (gr)
|
if (NULL != gr) {
|
||||||
printf (" GID=%u(%s)", rgid, gr->gr_name);
|
(void) printf (" GID=%u(%s)", rgid, gr->gr_name);
|
||||||
else
|
} else {
|
||||||
printf (" GID=%u", rgid);
|
(void) printf (" GID=%u", rgid);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print out the effective user ID and group ID if they are
|
* Print out the effective user ID and group ID if they are
|
||||||
@ -140,17 +144,19 @@ static void usage (void)
|
|||||||
|
|
||||||
if (ruid != euid) {
|
if (ruid != euid) {
|
||||||
pw = getpwuid (euid); /* local, no need for xgetpwuid */
|
pw = getpwuid (euid); /* local, no need for xgetpwuid */
|
||||||
if (pw)
|
if (NULL != pw) {
|
||||||
printf (" EUID=%u(%s)", euid, pw->pw_name);
|
(void) printf (" EUID=%u(%s)", euid, pw->pw_name);
|
||||||
else
|
} else {
|
||||||
printf (" EUID=%u", euid);
|
(void) printf (" EUID=%u", euid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rgid != egid) {
|
if (rgid != egid) {
|
||||||
gr = getgrgid (egid); /* local, no need for xgetgrgid */
|
gr = getgrgid (egid); /* local, no need for xgetgrgid */
|
||||||
if (gr)
|
if (NULL != gr) {
|
||||||
printf (" EGID=%u(%s)", egid, gr->gr_name);
|
(void) printf (" EGID=%u(%s)", egid, gr->gr_name);
|
||||||
else
|
} else {
|
||||||
printf (" EGID=%u", egid);
|
(void) printf (" EGID=%u", egid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef HAVE_GETGROUPS
|
#ifdef HAVE_GETGROUPS
|
||||||
/*
|
/*
|
||||||
@ -167,17 +173,19 @@ static void usage (void)
|
|||||||
* where "###" is a numerical value and "aaa" is the
|
* where "###" is a numerical value and "aaa" is the
|
||||||
* corresponding name for each respective numerical value.
|
* corresponding name for each respective numerical value.
|
||||||
*/
|
*/
|
||||||
puts (_(" groups="));
|
(void) puts (_(" groups="));
|
||||||
for (i = 0; i < ngroups; i++) {
|
for (i = 0; i < ngroups; i++) {
|
||||||
if (i)
|
if (0 != i)
|
||||||
putchar (',');
|
(void) putchar (',');
|
||||||
|
|
||||||
/* local, no need for xgetgrgid */
|
/* local, no need for xgetgrgid */
|
||||||
gr = getgrgid (groups[i]);
|
gr = getgrgid (groups[i]);
|
||||||
if (gr)
|
if (NULL != gr) {
|
||||||
printf ("%u(%s)", groups[i], gr->gr_name);
|
(void) printf ("%u(%s)",
|
||||||
else
|
groups[i], gr->gr_name);
|
||||||
printf ("%u", groups[i]);
|
} else {
|
||||||
|
(void) printf ("%u", groups[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (groups);
|
free (groups);
|
||||||
@ -186,7 +194,7 @@ static void usage (void)
|
|||||||
/*
|
/*
|
||||||
* Finish off the line.
|
* Finish off the line.
|
||||||
*/
|
*/
|
||||||
putchar ('\n');
|
(void) putchar ('\n');
|
||||||
exit (0);
|
exit (0);
|
||||||
/* NOT REACHED */
|
/* NOT REACHED */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user