Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars
@@ -17,10 +17,12 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
+ * Copyright (c) 2013 Gary Mills
+ *
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Portions Copyright 2009 Chad Mynhier
*/
@@ -57,17 +59,24 @@
Die(gettext("invalid user name: %s\n"), name);
return (pwd->pw_uid);
}
void
-pwd_getname(uid_t uid, char *name, int length, int noresolve)
+pwd_getname(uid_t uid, char *name, size_t length, int noresolve,
+ int termcap, size_t width)
{
struct passwd *pwd;
+ size_t n;
if (noresolve || (pwd = getpwuid(uid)) == NULL) {
(void) snprintf(name, length, "%u", uid);
} else {
+ n = strlen(pwd->pw_name);
+ if (termcap && n > width)
+ (void) snprintf(name, length, "%.*s%c",
+ width - 1, pwd->pw_name, '*');
+ else
(void) snprintf(name, length, "%s", pwd->pw_name);
}
}
void