Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/user Do the previous differently. Run through the p...



details:   https://anonhg.NetBSD.org/src/rev/aa3f15f2207d
branches:  trunk
changeset: 524853:aa3f15f2207d
user:      agc <agc%NetBSD.org@localhost>
date:      Sun Mar 31 21:31:10 2002 +0000

description:
Do the previous differently. Run through the possible ranges for uids in
the command line order, then check the default range after that, if none
has yet been found.

Prompted by Brian Poole <raj%cerias.purdue.edu@localhost>.

diffstat:

 usr.sbin/user/user.c |  11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diffs (36 lines):

diff -r 8f1ce5db9bde -r aa3f15f2207d usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Sun Mar 31 21:13:24 2002 +0000
+++ b/usr.sbin/user/user.c      Sun Mar 31 21:31:10 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.46 2002/02/05 19:18:29 agc Exp $ */
+/* $NetBSD: user.c,v 1.47 2002/03/31 21:31:10 agc Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -35,7 +35,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999 \
                The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.46 2002/02/05 19:18:29 agc Exp $");
+__RCSID("$NetBSD: user.c,v 1.47 2002/03/31 21:31:10 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -899,13 +899,14 @@
        /* if no uid was specified, get next one in [low_uid..high_uid] range */
        sync_uid_gid = (strcmp(up->u_primgrp, "=uid") == 0);
        if (up->u_uid == -1) {
-               /* default is in index '0' in array */
-               for (i = up->u_rc - 1 ; i >= 0 ; --i) {
+               /* default is in index '0' in u_rv array */
+               for (i = 1 ; i < up->u_rc ; i++) {
                        if (getnextuid(sync_uid_gid, &up->u_uid, up->u_rv[i].r_from, up->u_rv[i].r_to)) {
                                break;
                        }
                }
-               if (i == up->u_rc) {
+               if (i == up->u_rc &&
+                   !getnextuid(sync_uid_gid, &up->u_uid, up->u_rv[0].r_from, up->u_rv[0].r_to)) {
                        (void) close(ptmpfd);
                        (void) pw_abort();
                        errx(EXIT_FAILURE, "can't get next uid for %d", up->u_uid);



Home | Main Index | Thread Index | Old Index