finger.c (100521) | finger.c (102944) |
---|---|
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 --- 43 unchanged lines hidden (view full) --- 52 53#if 0 54#ifndef lint 55static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; 56#endif 57#endif 58 59#include <sys/cdefs.h> | 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 --- 43 unchanged lines hidden (view full) --- 52 53#if 0 54#ifndef lint 55static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; 56#endif 57#endif 58 59#include <sys/cdefs.h> |
60__FBSDID("$FreeBSD: head/usr.bin/finger/finger.c 100521 2002-07-22 17:19:54Z ume $"); | 60__FBSDID("$FreeBSD: head/usr.bin/finger/finger.c 102944 2002-09-04 23:29:10Z dwmalone $"); |
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 * 68 * There are currently two output formats; the short format is one line --- 28 unchanged lines hidden (view full) --- 97char tbuf[1024]; 98 99static void loginlist(void); 100static int option(int, char **); 101static void usage(void); 102static void userlist(int, char **); 103 104static int | 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 * 68 * There are currently two output formats; the short format is one line --- 28 unchanged lines hidden (view full) --- 97char tbuf[1024]; 98 99static void loginlist(void); 100static int option(int, char **); 101static void usage(void); 102static void userlist(int, char **); 103 104static int |
105option(argc, argv) 106 int argc; 107 char **argv; | 105option(int argc, char **argv) |
108{ 109 int ch; 110 111 optind = 1; /* reset getopt */ 112 113 while ((ch = getopt(argc, argv, "46glmpshoT")) != -1) 114 switch(ch) { 115 case '4': --- 30 unchanged lines hidden (view full) --- 146 default: 147 usage(); 148 } 149 150 return optind; 151} 152 153static void | 106{ 107 int ch; 108 109 optind = 1; /* reset getopt */ 110 111 while ((ch = getopt(argc, argv, "46glmpshoT")) != -1) 112 switch(ch) { 113 case '4': --- 30 unchanged lines hidden (view full) --- 144 default: 145 usage(); 146 } 147 148 return optind; 149} 150 151static void |
154usage() | 152usage(void) |
155{ 156 (void)fprintf(stderr, "usage: finger [-46lmpshoT] [login ...]\n"); 157 exit(1); 158} 159 160int | 153{ 154 (void)fprintf(stderr, "usage: finger [-46lmpshoT] [login ...]\n"); 155 exit(1); 156} 157 158int |
161main(argc, argv) 162 int argc; 163 char **argv; | 159main(int argc, char **argv) |
164{ 165 int envargc, argcnt; 166 char *envargv[3]; 167 struct passwd *pw; 168 static char myname[] = "finger"; 169 170 if (getuid() == 0 || geteuid() == 0) { 171 if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) { --- 52 unchanged lines hidden (view full) --- 224 lflag_print(); 225 else 226 sflag_print(); 227 } 228 return (0); 229} 230 231static void | 160{ 161 int envargc, argcnt; 162 char *envargv[3]; 163 struct passwd *pw; 164 static char myname[] = "finger"; 165 166 if (getuid() == 0 || geteuid() == 0) { 167 if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) { --- 52 unchanged lines hidden (view full) --- 220 lflag_print(); 221 else 222 sflag_print(); 223 } 224 return (0); 225} 226 227static void |
232loginlist() | 228loginlist(void) |
233{ 234 PERSON *pn; 235 DBT data, key; 236 struct passwd *pw; 237 struct utmp user; 238 int r, sflag1; 239 char name[UT_NAMESIZE + 1]; 240 --- 23 unchanged lines hidden (view full) --- 264 if (r == 1) 265 break; 266 memmove(&tmp, data.data, sizeof tmp); 267 enter_lastlog(tmp); 268 } 269} 270 271static void | 229{ 230 PERSON *pn; 231 DBT data, key; 232 struct passwd *pw; 233 struct utmp user; 234 int r, sflag1; 235 char name[UT_NAMESIZE + 1]; 236 --- 23 unchanged lines hidden (view full) --- 260 if (r == 1) 261 break; 262 memmove(&tmp, data.data, sizeof tmp); 263 enter_lastlog(tmp); 264 } 265} 266 267static void |
272userlist(argc, argv) 273 int argc; 274 char **argv; | 268userlist(int argc, char **argv) |
275{ 276 PERSON *pn; 277 DBT data, key; 278 struct utmp user; 279 struct passwd *pw; 280 int r, sflag1, *used, *ip; 281 char **ap, **nargv, **np, **p; 282 FILE *conf_fp; --- 122 unchanged lines hidden --- | 269{ 270 PERSON *pn; 271 DBT data, key; 272 struct utmp user; 273 struct passwd *pw; 274 int r, sflag1, *used, *ip; 275 char **ap, **nargv, **np, **p; 276 FILE *conf_fp; --- 122 unchanged lines hidden --- |