54 lines
1.3 KiB
Text
54 lines
1.3 KiB
Text
$NetBSD: patch-ap,v 1.2 2003/03/31 16:33:22 taca Exp $
|
|
|
|
Expand & in the gecos field to a capitalized login name.
|
|
|
|
--- lib/system.c.orig 2003-02-05 15:14:52.000000000 +0900
|
|
+++ lib/system.c
|
|
@@ -776,6 +776,11 @@ static int num_lookups; /* Counter so we
|
|
|
|
static void copy_pwent(struct saved_pw *dst, struct passwd *pass)
|
|
{
|
|
+#ifdef BSD
|
|
+ char *bp, *gecos, *p, buf[PSTRING_LEN];
|
|
+ int buflen;
|
|
+#endif
|
|
+
|
|
memcpy((char *)&dst->pass, pass, sizeof(struct passwd));
|
|
|
|
unix_to_dos(dst->pw_name, pass->pw_name);
|
|
@@ -785,6 +790,35 @@ static void copy_pwent(struct saved_pw *
|
|
dst->pass.pw_passwd = dst->pw_passwd;
|
|
|
|
unix_to_dos(dst->pw_gecos, pass->pw_gecos);
|
|
+#ifdef BSD
|
|
+ gecos = dst->pw_gecos;
|
|
+ if (*gecos == '*')
|
|
+ gecos++;
|
|
+ bp = buf;
|
|
+
|
|
+ /* copy gecos, interpolating & to be full name */
|
|
+ for (p = gecos; *p != '\0'; p++) {
|
|
+ if (bp >= &buf[PSTRING_LEN - 1]) {
|
|
+ /* buffer overflow */
|
|
+ gecos = pass->pw_name;
|
|
+ goto gecos_done;
|
|
+ }
|
|
+ if (*p == '&') {
|
|
+ /* interpolate full name */
|
|
+ snprintf(bp, PSTRING_LEN - (bp - buf), "%s",
|
|
+ pass->pw_name);
|
|
+ *bp = toupper(*bp);
|
|
+ bp += strlen(bp);
|
|
+ }
|
|
+ else
|
|
+ *bp++ = *p;
|
|
+ }
|
|
+ *bp = '\0';
|
|
+ gecos = buf;
|
|
+
|
|
+ gecos_done:
|
|
+ fstrcpy(dst->pw_gecos, gecos);
|
|
+#endif
|
|
dst->pass.pw_gecos = dst->pw_gecos;
|
|
|
|
unix_to_dos(dst->pw_dir, pass->pw_dir);
|