]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Fix useage of MAXLOGNAME to include terminating NUL, by using
authorDavid Nugent <davidn@FreeBSD.org>
Fri, 7 Feb 1997 10:58:13 +0000 (10:58 +0000)
committerDavid Nugent <davidn@FreeBSD.org>
Fri, 7 Feb 1997 10:58:13 +0000 (10:58 +0000)
max(MAXLOGNAME-1,UT_NAMESIZE).
Tidy up "pretty" printing format for longer usernames.

pw/pw.c
pw/pw_user.c

diff --git a/pw/pw.c b/pw/pw.c
index b7336e11ee0154620c1e5d81112babbb8f8cb041..91412a8f35faac05de9dda7ec219e92cc0b8896c 100644 (file)
--- a/pw/pw.c
+++ b/pw/pw.c
@@ -62,7 +62,7 @@ main(int argc, char *argv[])
                { /* user */
                        "C:qn:u:c:d:e:p:g:G:mk:s:oL:i:w:h:Db:NPy:Y",
                        "C:qn:u:rY",
-                       "C:qn:u:c:d:e:p:g:G:mk:s:w:L:h:FNPY",
+                       "C:qn:u:c:d:e:p:g:G:ml:k:s:w:L:h:FNPY",
                        "C:qn:u:FPa",
                        "C:q"
                },
index effad9a98558006cb94b493c3fedcc2006344235..ebc754a774a7b34da9a6ca81d9b4b169fa3461b4 100644 (file)
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
+#include <utmp.h>
+#if defined(USE_MD5RAND)
 #include <md5.h>
+#endif
 #include "pw.h"
 #include "bitmap.h"
 #include "pwupd.h"
 
+#if (MAXLOGNAME-1) > UT_NAMESIZE
+#define LOGNAMESIZE UT_NAMESIZE
+#else
+#define LOGNAMESIZE (MAXLOGNAME-1)
+#endif
+
 static int      print_user(struct passwd * pwd, int pretty);
 static uid_t    pw_uidpolicy(struct userconf * cnf, struct cargs * args);
 static uid_t    pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer);
@@ -993,7 +1002,7 @@ print_user(struct passwd * pwd, int pretty)
                  strftime(acexpire, sizeof acexpire, "%c", tptr);
                if (pwd->pw_change > (time_t)9 && (tptr = localtime(&pwd->pw_change)) != NULL)
                  strftime(pwexpire, sizeof pwexpire, "%c", tptr);
-               printf("Login Name: %-10s   #%-16ld  Group: %-10s   #%ld\n"
+               printf("Login Name: %-15s   #%-12ld Group: %-15s   #%ld\n"
                       " Full Name: %s\n"
                       "      Home: %-26.26s      Class: %s\n"
                       "     Shell: %-26.26s     Office: %s\n"
@@ -1041,7 +1050,7 @@ pw_checkname(u_char *name, int gecos)
                                            name[l]);
                ++l;
        }
-       if (!gecos && l > MAXLOGNAME)
+       if (!gecos && l > LOGNAMESIZE)
                cmderr(EX_DATAERR, "name too long `%s'\n", name);
        return (char *)name;
 }