diff options
author | John Kohl <jtkohl@mit.edu> | 1988-11-23 10:58:30 +0000 |
---|---|---|
committer | John Kohl <jtkohl@mit.edu> | 1988-11-23 10:58:30 +0000 |
commit | 22b59a82bc617d3570168e0b7d1d3a9c756693a3 (patch) | |
tree | bbee7abea6bc23aa6f0f8e9a7431eb0ac3e65b93 | |
parent | e66c0fee1278c437b1d5af576a1248b97f437a88 (diff) |
fetch name from password file
-rw-r--r-- | clients/zwrite/zwrite.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/clients/zwrite/zwrite.c b/clients/zwrite/zwrite.c index ac9af16..913152f 100644 --- a/clients/zwrite/zwrite.c +++ b/clients/zwrite/zwrite.c @@ -16,6 +16,8 @@ #include <zephyr/zephyr.h> #include <string.h> #include <netdb.h> +#include <pwd.h> +#include <ctype.h> #ifndef lint static char rcsid_zwrite_c[] = "$Header$"; @@ -42,7 +44,7 @@ main(argc, argv) { ZNotice_t notice; int retval, arg, nocheck, nchars, msgsize, filsys, tabexpand; - char bfr[BUFSIZ], *message, *signature; + char bfr[BUFSIZ], *message, *signature = NULL; char classbfr[BUFSIZ], instbfr[BUFSIZ], sigbfr[BUFSIZ]; whoami = argv[0]; @@ -157,6 +159,29 @@ main(argc, argv) exit (1); } + if (!signature) { + /* try to find name in the password file */ + register struct passwd *pwd; + register char *cp = sigbfr; + register char *cp2, *pp; + + pwd = getpwuid(getuid()); + if (pwd) { + cp2 = pwd->pw_gecos; + for (; *cp2 && *cp2 != ',' ; cp2++) { + if (*cp2 == '&') { + pp = pwd->pw_name; + *cp++ = islower(*pp) ? toupper(*pp) : *pp; + pp++; + while (*pp) + *cp++ = *pp++; + } else + *cp++ = *cp2; + } + signature = sigbfr; + } + } + notice.z_kind = ACKED; notice.z_port = 0; notice.z_class = class; |