NO_GETPWENT is no more supported. Remove associated chunks of code.
This commit is contained in:
parent
60c167838f
commit
20dfe6ba98
@ -1,3 +1,8 @@
|
|||||||
|
2007-12-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/useradd.c, src/groupadd.c: NO_GETPWENT is no more supported. Remove
|
||||||
|
associated chunks of code.
|
||||||
|
|
||||||
2007-12-26 Nicolas François <nicolas.francois@centraliens.net>
|
2007-12-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* man/groupadd.8.xml: Document the long options (--force, --gid, --key,
|
* man/groupadd.8.xml: Document the long options (--force, --gid, --key,
|
||||||
|
@ -214,13 +214,8 @@ static void find_new_gid (void)
|
|||||||
* user specified one with -g) or looking for the largest unused
|
* user specified one with -g) or looking for the largest unused
|
||||||
* value.
|
* value.
|
||||||
*/
|
*/
|
||||||
#ifdef NO_GETGRENT
|
|
||||||
gr_rewind ();
|
|
||||||
while ((grp = gr_next ())) {
|
|
||||||
#else
|
|
||||||
setgrent ();
|
setgrent ();
|
||||||
while ((grp = getgrent ())) {
|
while ((grp = getgrent ())) {
|
||||||
#endif
|
|
||||||
if (strcmp (group_name, grp->gr_name) == 0) {
|
if (strcmp (group_name, grp->gr_name) == 0) {
|
||||||
if (fflg) {
|
if (fflg) {
|
||||||
fail_exit (E_SUCCESS);
|
fail_exit (E_SUCCESS);
|
||||||
@ -233,11 +228,7 @@ static void find_new_gid (void)
|
|||||||
if (fflg) {
|
if (fflg) {
|
||||||
/* turn off -g and search again */
|
/* turn off -g and search again */
|
||||||
gflg = 0;
|
gflg = 0;
|
||||||
#ifdef NO_GETGRENT
|
|
||||||
gr_rewind ();
|
|
||||||
#else
|
|
||||||
setgrent ();
|
setgrent ();
|
||||||
#endif
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fprintf (stderr, _("%s: GID %u is not unique\n"),
|
fprintf (stderr, _("%s: GID %u is not unique\n"),
|
||||||
@ -252,17 +243,9 @@ static void find_new_gid (void)
|
|||||||
}
|
}
|
||||||
if (!gflg && group_id == gid_max + 1) {
|
if (!gflg && group_id == gid_max + 1) {
|
||||||
for (group_id = gid_min; group_id < gid_max; group_id++) {
|
for (group_id = gid_min; group_id < gid_max; group_id++) {
|
||||||
#ifdef NO_GETGRENT
|
|
||||||
gr_rewind ();
|
|
||||||
while ((grp = gr_next ())
|
|
||||||
&& grp->gr_gid != group_id);
|
|
||||||
if (!grp)
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
/* local, no need for xgetgrgid */
|
/* local, no need for xgetgrgid */
|
||||||
if (!getgrgid (group_id))
|
if (!getgrgid (group_id))
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (group_id == gid_max) {
|
if (group_id == gid_max) {
|
||||||
fprintf (stderr, _("%s: can't get unique GID\n"), Prog);
|
fprintf (stderr, _("%s: can't get unique GID\n"), Prog);
|
||||||
|
@ -836,13 +836,8 @@ static void find_new_uid (void)
|
|||||||
* UID (if the user specified one with -u) or looking for the
|
* UID (if the user specified one with -u) or looking for the
|
||||||
* largest unused value.
|
* largest unused value.
|
||||||
*/
|
*/
|
||||||
#ifdef NO_GETPWENT
|
|
||||||
pw_rewind ();
|
|
||||||
while ((pwd = pw_next ())) {
|
|
||||||
#else /* using getpwent() we can check against NIS users etc. */
|
|
||||||
setpwent ();
|
setpwent ();
|
||||||
while ((pwd = getpwent ())) {
|
while ((pwd = getpwent ())) {
|
||||||
#endif
|
|
||||||
if (strcmp (user_name, pwd->pw_name) == 0) {
|
if (strcmp (user_name, pwd->pw_name) == 0) {
|
||||||
fprintf (stderr, _("%s: name %s is not unique\n"),
|
fprintf (stderr, _("%s: name %s is not unique\n"),
|
||||||
Prog, user_name);
|
Prog, user_name);
|
||||||
@ -876,17 +871,9 @@ static void find_new_uid (void)
|
|||||||
*/
|
*/
|
||||||
if (!uflg && user_id == uid_max + 1) {
|
if (!uflg && user_id == uid_max + 1) {
|
||||||
for (user_id = uid_min; user_id < uid_max; user_id++) {
|
for (user_id = uid_min; user_id < uid_max; user_id++) {
|
||||||
#ifdef NO_GETPWENT
|
|
||||||
pw_rewind ();
|
|
||||||
while ((pwd = pw_next ())
|
|
||||||
&& pwd->pw_uid != user_id);
|
|
||||||
if (!pwd)
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
/* local, no need for xgetpwuid */
|
/* local, no need for xgetpwuid */
|
||||||
if (!getpwuid (user_id))
|
if (!getpwuid (user_id))
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (user_id == uid_max) {
|
if (user_id == uid_max) {
|
||||||
fprintf (stderr, _("%s: can't get unique UID\n"), Prog);
|
fprintf (stderr, _("%s: can't get unique UID\n"), Prog);
|
||||||
@ -922,14 +909,8 @@ static void find_new_gid ()
|
|||||||
* GID (if the user specified one with -g) or looking for the
|
* GID (if the user specified one with -g) or looking for the
|
||||||
* largest unused value.
|
* largest unused value.
|
||||||
*/
|
*/
|
||||||
#ifdef NO_GETGRENT
|
|
||||||
gr_rewind ();
|
|
||||||
while ((grp = gr_next ()))
|
|
||||||
#else
|
|
||||||
setgrent ();
|
setgrent ();
|
||||||
while ((grp = getgrent ()))
|
while ((grp = getgrent ())) {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (strcmp (user_name, grp->gr_name) == 0) {
|
if (strcmp (user_name, grp->gr_name) == 0) {
|
||||||
user_gid = grp->gr_gid;
|
user_gid = grp->gr_gid;
|
||||||
return;
|
return;
|
||||||
@ -940,26 +921,11 @@ static void find_new_gid ()
|
|||||||
user_gid = grp->gr_gid + 1;
|
user_gid = grp->gr_gid + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef NO_GETGRENT /* glibc does have this, so ... */
|
|
||||||
/* A quick test gets here: if the UID is available
|
|
||||||
* as a GID, go ahead and use it */
|
|
||||||
if (!getgrgid (user_id)) { /* local, no need for xgetgrgid */
|
|
||||||
user_gid = user_id;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (user_gid == gid_max + 1) {
|
if (user_gid == gid_max + 1) {
|
||||||
for (user_gid = gid_min; user_gid < gid_max; user_gid++) {
|
for (user_gid = gid_min; user_gid < gid_max; user_gid++) {
|
||||||
#ifdef NO_GETGRENT
|
|
||||||
gr_rewind ();
|
|
||||||
while ((grp = gr_next ()) && grp->gr_gid != user_gid);
|
|
||||||
if (!grp)
|
|
||||||
break;
|
|
||||||
#else
|
|
||||||
/* local, no need for xgetgrgid */
|
/* local, no need for xgetgrgid */
|
||||||
if (!getgrgid (user_gid))
|
if (!getgrgid (user_gid))
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (user_gid == gid_max) {
|
if (user_gid == gid_max) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user