summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw/pw_user.c
diff options
context:
space:
mode:
authordavidn <davidn@FreeBSD.org>1997-02-07 10:58:13 +0000
committerdavidn <davidn@FreeBSD.org>1997-02-07 10:58:13 +0000
commit42430059c615caced0bc277bea3f556a162d5bab (patch)
tree8c48e5fecc6e9d47c712573cc3ae36956992c378 /usr.sbin/pw/pw_user.c
parent2ee2d0c1f6ef42dfd3c8948d2917c8452a6ae0ae (diff)
downloadFreeBSD-src-42430059c615caced0bc277bea3f556a162d5bab.zip
FreeBSD-src-42430059c615caced0bc277bea3f556a162d5bab.tar.gz
Fix useage of MAXLOGNAME to include terminating NUL, by using
max(MAXLOGNAME-1,UT_NAMESIZE). Tidy up "pretty" printing format for longer usernames.
Diffstat (limited to 'usr.sbin/pw/pw_user.c')
-rw-r--r--usr.sbin/pw/pw_user.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index effad9a..ebc754a 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -36,11 +36,20 @@
#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;
}
OpenPOWER on IntegriCloud