diff options
author | peter <peter@FreeBSD.org> | 1997-03-11 13:43:33 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-03-11 13:43:33 +0000 |
commit | deba7db48c7897a6302d3d706887bbddc3604c00 (patch) | |
tree | de15b52a10645135d816eb7c2d0fdc19e613c445 /usr.bin/finger | |
parent | dc74a95b3c87ac7e618302b89dfff6205c05cfc0 (diff) | |
download | FreeBSD-src-deba7db48c7897a6302d3d706887bbddc3604c00.zip FreeBSD-src-deba7db48c7897a6302d3d706887bbddc3604c00.tar.gz |
Merge from Lite2
Diffstat (limited to 'usr.bin/finger')
-rw-r--r-- | usr.bin/finger/finger.1 | 11 | ||||
-rw-r--r-- | usr.bin/finger/finger.c | 39 | ||||
-rw-r--r-- | usr.bin/finger/lprint.c | 9 | ||||
-rw-r--r-- | usr.bin/finger/net.c | 7 | ||||
-rw-r--r-- | usr.bin/finger/sprint.c | 9 | ||||
-rw-r--r-- | usr.bin/finger/util.c | 64 |
6 files changed, 68 insertions, 71 deletions
diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1 index 272cb17..9d0755c 100644 --- a/usr.bin/finger/finger.1 +++ b/usr.bin/finger/finger.1 @@ -1,4 +1,4 @@ -.\" Copyright (c) 1989, 1990, 1993 +.\" Copyright (c) 1989, 1990, 1993, 1994 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -29,9 +29,9 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" @(#)finger.1 8.2 (Berkeley) 2/16/94 +.\" @(#)finger.1 8.3 (Berkeley) 5/5/94 .\" -.Dd February 16, 1994 +.Dd May 5, 1994 .Dt FINGER 1 .Os BSD 4 .Sh NAME @@ -192,6 +192,11 @@ utilizes the following environment variable, if it exists: This variable may be set with favored options to .Nm finger . .El +.Sh FILES +.Bl -tag -width /var/log/lastlog -compact +.It Pa /var/log/lastlog +last login data base +.El .Sh SEE ALSO .Xr chpass 1 , .Xr w 1 , diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 657426f..9235d13 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -51,7 +51,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93"; +static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; #endif /* not lint */ /* @@ -69,16 +69,21 @@ static char sccsid[] = "@(#)finger.c 8.2 (Berkeley) 9/30/93"; */ #include <sys/param.h> + +#include <db.h> +#include <err.h> +#include <errno.h> #include <fcntl.h> -#include <time.h> #include <pwd.h> -#include <utmp.h> -#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> +#include <unistd.h> +#include <utmp.h> #include <db.h> #include <locale.h> + #include "finger.h" DB *db; @@ -185,7 +190,7 @@ main(argc, argv) lflag_print(); else sflag_print(); - exit(0); + return (0); } static void @@ -199,7 +204,7 @@ loginlist() char name[UT_NAMESIZE + 1]; if (!freopen(_PATH_UTMP, "r", stdin)) - err("%s: %s", _PATH_UTMP, strerror(errno)); + err(1, "%s", _PATH_UTMP); name[UT_NAMESIZE] = NULL; while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) @@ -216,12 +221,15 @@ loginlist() } if (db && lflag) for (sflag = R_FIRST;; sflag = R_NEXT) { + PERSON *tmp; + r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - enter_lastlog(*(PERSON **)data.data); + memmove(&tmp, data.data, sizeof tmp); + enter_lastlog(tmp); } } @@ -239,7 +247,7 @@ userlist(argc, argv) if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL || (used = calloc(argc, sizeof(int))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); /* Pull out all network requests. */ for (ap = p = argv, np = nargv; *p; ++p) @@ -260,13 +268,13 @@ userlist(argc, argv) */ if (mflag) for (p = argv; *p; ++p) - if ((pw = getpwnam(*p)) && !hide(pw)) + if (((pw = getpwnam(*p)) != NULL) && !hide(pw)) enter_person(pw); else (void)fprintf(stderr, "finger: %s: no such user\n", *p); else { - while (pw = getpwent()) { + while ((pw = getpwent()) != NULL) { for (p = argv, ip = used; *p; ++p, ++ip) if (match(pw, *p) && !hide(pw)) { enter_person(pw); @@ -294,7 +302,7 @@ net: for (p = nargv; *p;) { * appropriate data whenever a match occurs. */ if (!freopen(_PATH_UTMP, "r", stdin)) - err("%s: %s", _PATH_UTMP, strerror(errno)); + err(1, "%s", _PATH_UTMP); while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { if (!user.ut_name[0]) continue; @@ -304,11 +312,14 @@ net: for (p = nargv; *p;) { } if (db) for (sflag = R_FIRST;; sflag = R_NEXT) { + PERSON *tmp; + r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - enter_lastlog(*(PERSON **)data.data); + memmove(&tmp, data.data, sizeof tmp); + enter_lastlog(tmp); } } diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c index 93e4a9b..847f26d 100644 --- a/usr.bin/finger/lprint.c +++ b/usr.bin/finger/lprint.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)lprint.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> @@ -44,6 +44,7 @@ static char sccsid[] = "@(#)lprint.c 8.1 (Berkeley) 6/6/93"; #include <fcntl.h> #include <time.h> #include <db.h> +#include <err.h> #include <pwd.h> #include <utmp.h> #include <errno.h> @@ -71,15 +72,17 @@ lflag_print() extern int pplan; register PERSON *pn; register int sflag, r; + PERSON *tmp; DBT data, key; for (sflag = R_FIRST;; sflag = R_NEXT) { r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - pn = *(PERSON **)data.data; + memmove(&tmp, data.data, sizeof tmp); + pn = tmp; if (sflag != R_FIRST) putchar('\n'); lprint(pn); diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c index 4f04c04..1173847 100644 --- a/usr.bin/finger/net.c +++ b/usr.bin/finger/net.c @@ -35,7 +35,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)net.c 8.3 (Berkeley) 1/2/94"; +static char sccsid[] = "@(#)net.c 8.4 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> @@ -144,9 +144,8 @@ netfinger(name) * it isn't a space, we can simply set the 7th bit. Every ASCII * character with bit 7 set is printable. */ - if (fp = fdopen(s, "r")) { - int lastc = '\n'; - + lastc = 0; + if ((fp = fdopen(s, "r")) != NULL) { while ((c = getc(fp)) != EOF) { if (c == 0x0d) { if (lastc == '\r') /* ^M^M - skip dupes */ diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index 329c433..07218aa 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -35,13 +35,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)sprint.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)sprint.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/types.h> #include <sys/time.h> #include <time.h> #include <db.h> +#include <err.h> #include <pwd.h> #include <errno.h> #include <utmp.h> @@ -61,6 +62,7 @@ sflag_print() register WHERE *w; register int sflag, r, namelen; char p[80]; + PERSON *tmp; DBT data, key; /* @@ -88,10 +90,11 @@ sflag_print() for (sflag = R_FIRST;; sflag = R_NEXT) { r = (*db->seq)(db, &key, &data, sflag); if (r == -1) - err("db seq: %s", strerror(errno)); + err(1, "db seq"); if (r == 1) break; - pn = *(PERSON **)data.data; + memmove(&tmp, data.data, sizeof tmp); + pn = tmp; for (w = pn->whead; w != NULL; w = w->next) { namelen = MAXREALNAME; diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index da1bb40..6931f86 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -35,13 +35,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)util.c 8.1 (Berkeley) 6/6/93"; +static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/28/95"; #endif /* not lint */ #include <sys/param.h> #include <sys/stat.h> #include <fcntl.h> #include <db.h> +#include <err.h> #include <pwd.h> #include <utmp.h> #include <errno.h> @@ -81,14 +82,14 @@ match(pw, user) if ((p = strtok(p, ",")) == NULL) return(0); - for (t = name; *t = *p; ++p) + for (t = name; (*t = *p) != '\0'; ++p) if (*t == '&') { (void)strcpy(t, pw->pw_name); while (*++t); } else ++t; - for (t = name; p = strtok(t, "\t "); t = NULL) + for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL) if (!strcasecmp(p, user)) return(1); return(0); @@ -170,17 +171,18 @@ enter_person(pw) if (db == NULL && (db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL)) == NULL) - err("%s", strerror(errno)); + err(1, NULL); key.data = pw->pw_name; key.size = strlen(pw->pw_name); - switch((*db->get)(db, &key, &data, 0)) { + switch ((*db->get)(db, &key, &data, 0)) { case 0: - return(*(PERSON **)data.data); + memmove(&pn, data.data, sizeof pn); + return (pn); default: case -1: - err("db get: %s", strerror(errno)); + err(1, "db get"); /* NOTREACHED */ case 1: ++entries; @@ -191,8 +193,8 @@ enter_person(pw) data.size = sizeof(PERSON *); data.data = &pn; if ((*db->put)(db, &key, &data, 0)) - err("%s", strerror(errno)); - return(pn); + err(1, "db put"); + return (pn); } } @@ -204,6 +206,7 @@ find_person(name) register int cnt; DBT data, key; + PERSON *p; char buf[UT_NAMESIZE + 1]; if (!db) @@ -219,7 +222,10 @@ find_person(name) key.data = buf; key.size = cnt; - return((*db->get)(db, &key, &data, 0) ? NULL : *(PERSON **)data.data); + if ((*db->get)(db, &key, &data, 0)) + return (NULL); + memmove(&p, data.data, sizeof p); + return (p); } PERSON * @@ -228,7 +234,7 @@ palloc() PERSON *p; if ((p = malloc((u_int) sizeof(PERSON))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); return(p); } @@ -239,7 +245,7 @@ walloc(pn) register WHERE *w; if ((w = malloc((u_int) sizeof(WHERE))) == NULL) - err("%s", strerror(errno)); + err(1, NULL); if (pn->whead == NULL) pn->whead = pn->wtail = w; else { @@ -309,8 +315,7 @@ find_idle_and_ttywrite(w) (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty); if (stat(tbuf, &sb) < 0) { - (void)fprintf(stderr, - "finger: %s: %s\n", tbuf, strerror(errno)); + warn(tbuf); return; } w->idletime = now < sb.st_atime ? 0 : now - sb.st_atime; @@ -343,7 +348,7 @@ userinfo(pn, pw) /* ampersands get replaced by the login name */ if (!(p = strsep(&bp, ","))) return; - for (t = name; *t = *p; ++p) + for (t = name; (*t = *p) != '\0'; ++p) if (*t == '&') { (void)strcpy(t, pw->pw_name); if (islower(*t)) @@ -373,35 +378,6 @@ userinfo(pn, pw) } } -#if __STDC__ -#include <stdarg.h> -#else -#include <varargs.h> -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "finger: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} - /* * Is this user hiding from finger? * If ~<user>/.nofinger exists, return 1 (hide), else return 0 (nohide). |