1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 37 unchanged lines hidden (view full) --- 46 47#ifndef lint 48static char copyright[] = 49"@(#) Copyright (c) 1989, 1993\n\ 50 The Regents of the University of California. All rights reserved.\n"; 51#endif /* not lint */ 52 53#ifndef lint |
54#if 0 |
55static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; |
56#else 57static const char rcsid[] = 58 "$Id$"; 59#endif |
60#endif /* not lint */ 61 62/* 63 * Finger prints out information about users. It is not portable since 64 * certain fields (e.g. the full user name, office, and phone numbers) are 65 * extracted from the gecos field of the passwd file which other UNIXes 66 * may not have or may use for other things. 67 * --- 24 unchanged lines hidden (view full) --- 92#include "finger.h" 93 94DB *db; 95time_t now; 96int entries, lflag, mflag, pplan, sflag, oflag, Tflag; 97char tbuf[1024]; 98 99static void loginlist __P((void)); |
100static void usage __P((void)); |
101static void userlist __P((int, char **)); 102 103int 104option(argc, argv) 105 int argc; 106 char **argv; 107{ 108 int ch; --- 20 unchanged lines hidden (view full) --- 129 case 'o': 130 oflag = 1; /* office info */ 131 break; 132 case 'T': 133 Tflag = 1; /* disable T/TCP */ 134 break; 135 case '?': 136 default: |
137 usage(); |
138 } 139 140 return optind; 141} 142 |
143static void 144usage() 145{ 146 (void)fprintf(stderr, "usage: finger [-lmpshoT] [login ...]\n"); 147 exit(1); 148} 149 150int |
151main(argc, argv) 152 int argc; 153 char **argv; 154{ |
155 int envargc, argcnt; |
156 char *envargv[3]; 157 158 (void) setlocale(LC_ALL, ""); 159 160 /* remove this line to get remote host */ 161 oflag = 1; /* default to old "office" behavior */ 162 163 /* --- 48 unchanged lines hidden (view full) --- 212 DBT data, key; 213 struct passwd *pw; 214 struct utmp user; 215 int r, sflag; 216 char name[UT_NAMESIZE + 1]; 217 218 if (!freopen(_PATH_UTMP, "r", stdin)) 219 err(1, "%s", _PATH_UTMP); |
220 name[UT_NAMESIZE] = '\0'; |
221 while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { 222 if (!user.ut_name[0]) 223 continue; 224 if ((pn = find_person(user.ut_name)) == NULL) { 225 bcopy(user.ut_name, name, UT_NAMESIZE); 226 if ((pw = getpwnam(name)) == NULL) 227 continue; 228 if (hide(pw)) --- 49 unchanged lines hidden (view full) --- 278 * Traverse the list of possible login names and check the login name 279 * and real name against the name specified by the user. 280 */ 281 if (mflag) 282 for (p = argv; *p; ++p) 283 if (((pw = getpwnam(*p)) != NULL) && !hide(pw)) 284 enter_person(pw); 285 else |
286 warnx("%s: no such user", *p); |
287 else { 288 while ((pw = getpwent()) != NULL) { 289 for (p = argv, ip = used; *p; ++p, ++ip) 290 if (match(pw, *p) && !hide(pw)) { 291 enter_person(pw); 292 *ip = 1; 293 } 294 } 295 for (p = argv, ip = used; *p; ++p, ++ip) 296 if (!*ip) |
297 warnx("%s: no such user", *p); |
298 } 299 300 /* Handle network requests. */ 301net: for (p = nargv; *p;) { 302 netfinger(*p++); 303 if (*p || entries) 304 printf("\n"); 305 } --- 30 unchanged lines hidden --- |