version 1.16, 2010/05/31 14:01:49 |
version 1.17, 2011/03/11 04:30:21 |
|
|
|
|
(void)setlocale(LC_ALL, ""); |
(void)setlocale(LC_ALL, ""); |
|
|
if (argc == 1) |
while ((ch = getopt(argc, argv, "a")) != -1) |
usage(); |
|
|
|
/* Don't accept command args but check since old whereis(1) used to */ |
|
while ((ch = getopt(argc, argv, "a")) != -1) { |
|
switch (ch) { |
switch (ch) { |
case 'a': |
case 'a': |
allmatches = 1; |
allmatches = 1; |
|
|
default: |
default: |
usage(); |
usage(); |
} |
} |
} |
argc -= optind; |
|
argv += optind; |
|
|
|
if (argc == 0) |
|
usage(); |
|
|
/* |
/* |
* which(1) uses user's $PATH. |
* which(1) uses user's $PATH. |
* whereis(1) uses user.cs_path from sysctl(3). |
* whereis(1) uses user.cs_path from sysctl(3). |
|
|
if (setuid(geteuid())) |
if (setuid(geteuid())) |
err(1, "Can't set uid to %u", geteuid()); |
err(1, "Can't set uid to %u", geteuid()); |
|
|
for (n = optind; n < argc; n++) |
for (n = 0; n < argc; n++) |
if (findprog(argv[n], path, progmode, allmatches) == 0) |
if (findprog(argv[n], path, progmode, allmatches) == 0) |
notfound++; |
notfound++; |
|
|
exit((notfound == 0) ? 0 : ((notfound == argc - 1) ? 2 : 1)); |
exit((notfound == 0) ? 0 : ((notfound == argc) ? 2 : 1)); |
} |
} |
|
|
int |
int |