Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/user From Liam Foy:



details:   https://anonhg.NetBSD.org/src/rev/e0e2fe0b9609
branches:  trunk
changeset: 584452:e0e2fe0b9609
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 18 14:15:53 2005 +0000

description:
>From Liam Foy:
- Correct lenght for the username
- First character in the login name cannot be '-' (OpenBSD)
- Remove some #ifdef EXTENSIONS. find_group_info is always needed
- When printing change, if it's -1, place a correct string.

diffstat:

 usr.sbin/user/user.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (70 lines):

diff -r bb9e6eefa1cb -r e0e2fe0b9609 usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Sun Sep 18 12:15:41 2005 +0000
+++ b/usr.sbin/user/user.c      Sun Sep 18 14:15:53 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.91 2005/09/12 15:45:03 christos Exp $ */
+/* $NetBSD: user.c,v 1.92 2005/09/18 14:15:53 christos 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.91 2005/09/12 15:45:03 christos Exp $");
+__RCSID("$NetBSD: user.c,v 1.92 2005/09/18 14:15:53 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -174,8 +174,7 @@
 enum {
        MaxShellNameLen = 256,
        MaxFileNameLen = MAXPATHLEN,
-       MaxUserNameLen = 32,
-       MaxFieldNameLen = 32,
+       MaxUserNameLen = LOGIN_NAME_MAX - 1,
        MaxCommandLen = 2048,
        MaxEntryLen = 2048,
        PasswordLength = 2048,
@@ -701,6 +700,10 @@
 {
        unsigned char   *cp;
 
+       /* First character of a login name cannot be '-'. */
+       if (*login_name == '-')
+               return 0;
+
        if (strlen(login_name) >= LOGIN_NAME_MAX) {
                return 0;
        }
@@ -1682,7 +1685,6 @@
 }
 #endif
 
-#ifdef EXTENSIONS
 /* see if we can find out the group struct */
 static struct group *
 find_group_info(const char *name)
@@ -1697,7 +1699,6 @@
        }
        return NULL;
 }
-#endif
 
 /* print out usage message, and then exit */
 void
@@ -2375,11 +2376,10 @@
        } else {
                (void)printf("groups\t%s %s\n", grp->gr_name, buf);
        }
-       (void)printf("change\t%s", pwp->pw_change ?
-           ctime(&pwp->pw_change) : "NEVER\n");
-#ifdef EXTENSIONS
+       (void)printf("change\t%s", pwp->pw_change > 0 ?
+           ctime(&pwp->pw_change) : pwp->pw_change == -1 ?
+           "NEXT LOGIN\n" : "NEVER\n");
        (void)printf("class\t%s\n", pwp->pw_class);
-#endif
        (void)printf("gecos\t%s\n", pwp->pw_gecos);
        (void)printf("dir\t%s\n", pwp->pw_dir);
        (void)printf("shell\t%s\n", pwp->pw_shell);



Home | Main Index | Thread Index | Old Index