From 22b59a82bc617d3570168e0b7d1d3a9c756693a3 Mon Sep 17 00:00:00 2001 From: John Kohl Date: Wed, 23 Nov 1988 10:58:30 +0000 Subject: fetch name from password file --- clients/zwrite/zwrite.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'clients/zwrite') 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 #include #include +#include +#include #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; -- cgit v1.2.3