mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-29 21:38:05 +00:00
Don't test features not supported by the bundled glob()
This commit is contained in:
parent
f7f8b6867e
commit
4cc54e4b81
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: globtest.c,v 1.2 2010/09/24 13:32:55 djm Exp $ */
|
/* $OpenBSD: globtest.c,v 1.1 2008/10/01 23:04:36 millert Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com>
|
* Public domain, 2008, Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
@ -27,7 +27,6 @@ struct gl_entry {
|
|||||||
int nresults;
|
int nresults;
|
||||||
char pattern[1024];
|
char pattern[1024];
|
||||||
char *results[MAX_RESULTS];
|
char *results[MAX_RESULTS];
|
||||||
mode_t modes[MAX_RESULTS];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int test_glob(struct gl_entry *);
|
int test_glob(struct gl_entry *);
|
||||||
@ -37,7 +36,7 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
FILE *fp = stdin;
|
FILE *fp = stdin;
|
||||||
char *buf, *cp;
|
char *buf, *cp;
|
||||||
int errors = 0, tests = 0, lineno, mode;
|
int errors = 0, tests = 0, lineno;
|
||||||
struct gl_entry entry;
|
struct gl_entry entry;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
@ -52,9 +51,9 @@ main(int argc, char **argv)
|
|||||||
* Read in test file, which is formatted thusly:
|
* Read in test file, which is formatted thusly:
|
||||||
*
|
*
|
||||||
* [pattern] <flags>
|
* [pattern] <flags>
|
||||||
* result1 [mode]
|
* result1
|
||||||
* result2 [mode]
|
* result2
|
||||||
* result3 [mode]
|
* result3
|
||||||
* ...
|
* ...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -108,7 +107,7 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
entry.flags = (int)strtol(buf, &cp, 0);
|
entry.flags = (int)strtol(buf, &cp, 0);
|
||||||
if (*cp != '>' || entry.flags < 0 || entry.flags > 0x4000) {
|
if (*cp != '>' || entry.flags < 0 || entry.flags > 0x2000) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"globtest: invalid flags: %s\n", buf);
|
"globtest: invalid flags: %s\n", buf);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -128,12 +127,6 @@ main(int argc, char **argv)
|
|||||||
entry.pattern, MAX_RESULTS);
|
entry.pattern, MAX_RESULTS);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if ((cp = strchr(buf, ' ')) != NULL) {
|
|
||||||
*cp++ = '\0';
|
|
||||||
mode = strtol(cp, NULL, 8);
|
|
||||||
} else
|
|
||||||
mode = -1;
|
|
||||||
entry.modes[entry.nresults] = (mode_t)mode;
|
|
||||||
entry.results[entry.nresults++] = strdup(buf);
|
entry.results[entry.nresults++] = strdup(buf);
|
||||||
}
|
}
|
||||||
if (entry.pattern[0]) {
|
if (entry.pattern[0]) {
|
||||||
@ -164,27 +157,13 @@ int test_glob(struct gl_entry *entry)
|
|||||||
for (i = 0; i < gl.gl_matchc; i++) {
|
for (i = 0; i < gl.gl_matchc; i++) {
|
||||||
if (strcmp(gl.gl_pathv[i], entry->results[i]) != 0)
|
if (strcmp(gl.gl_pathv[i], entry->results[i]) != 0)
|
||||||
goto mismatch;
|
goto mismatch;
|
||||||
if ((entry->flags & GLOB_KEEPSTAT) != 0) {
|
|
||||||
if (entry->modes[i] == -1 ||
|
|
||||||
gl.gl_statv[i] == NULL ||
|
|
||||||
entry->modes[i] != gl.gl_statv[i]->st_mode)
|
|
||||||
goto badmode;
|
|
||||||
}
|
|
||||||
free(entry->results[i]);
|
free(entry->results[i]);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
badmode:
|
|
||||||
fprintf(stderr, "globtest: mismatch mode for pattern %s, flags 0x%x, "
|
|
||||||
"file \"%s\" (found %07o, expected %07o)\n",
|
|
||||||
entry->pattern, entry->flags,
|
|
||||||
gl.gl_pathv[i], gl.gl_statv[i] ? gl.gl_statv[i]->st_mode : 0,
|
|
||||||
entry->modes[i]);
|
|
||||||
goto cleanup;
|
|
||||||
mismatch:
|
mismatch:
|
||||||
fprintf(stderr, "globtest: mismatch for pattern %s, flags 0x%x "
|
fprintf(stderr, "globtest: mismatch for pattern %s, flags 0x%x "
|
||||||
"(found \"%s\", expected \"%s\")\n", entry->pattern, entry->flags,
|
"(found \"%s\", expected \"%s\")\n", entry->pattern, entry->flags,
|
||||||
gl.gl_pathv[i], entry->results[i]);
|
gl.gl_pathv[i], entry->results[i]);
|
||||||
cleanup:
|
|
||||||
while (i < gl.gl_matchc) {
|
while (i < gl.gl_matchc) {
|
||||||
free(entry->results[i++]);
|
free(entry->results[i++]);
|
||||||
}
|
}
|
||||||
|
@ -46,54 +46,6 @@ fake/bin/systrace
|
|||||||
fake/bin/tar
|
fake/bin/tar
|
||||||
fake/bin/test
|
fake/bin/test
|
||||||
|
|
||||||
[fake/bin/[[:alpha:]]*] <0x4000>
|
|
||||||
fake/bin/cat 0100644
|
|
||||||
fake/bin/chgrp 0100644
|
|
||||||
fake/bin/chio 0100644
|
|
||||||
fake/bin/chmod 0100644
|
|
||||||
fake/bin/cksum 0100644
|
|
||||||
fake/bin/cp 0100644
|
|
||||||
fake/bin/cpio 0100644
|
|
||||||
fake/bin/csh 0100644
|
|
||||||
fake/bin/date 0100644
|
|
||||||
fake/bin/dd 0100644
|
|
||||||
fake/bin/df 0100644
|
|
||||||
fake/bin/domainname 0100644
|
|
||||||
fake/bin/echo 0100644
|
|
||||||
fake/bin/ed 0100644
|
|
||||||
fake/bin/eject 0100644
|
|
||||||
fake/bin/expr 0100644
|
|
||||||
fake/bin/hostname 0100644
|
|
||||||
fake/bin/kill 0100644
|
|
||||||
fake/bin/ksh 0100644
|
|
||||||
fake/bin/ln 0100644
|
|
||||||
fake/bin/ls 0100644
|
|
||||||
fake/bin/md5 0100644
|
|
||||||
fake/bin/mkdir 0100644
|
|
||||||
fake/bin/mt 0100644
|
|
||||||
fake/bin/mv 0100644
|
|
||||||
fake/bin/pax 0100644
|
|
||||||
fake/bin/ps 0100644
|
|
||||||
fake/bin/pwd 0100644
|
|
||||||
fake/bin/rcp 0100755
|
|
||||||
fake/bin/rksh 0100755
|
|
||||||
fake/bin/rm 0100755
|
|
||||||
fake/bin/rmail 0100755
|
|
||||||
fake/bin/rmd160 0100755
|
|
||||||
fake/bin/rmdir 0100755
|
|
||||||
fake/bin/sh 0100444
|
|
||||||
fake/bin/sha1 0100444
|
|
||||||
fake/bin/sha256 0100444
|
|
||||||
fake/bin/sha384 0100444
|
|
||||||
fake/bin/sha512 0100444
|
|
||||||
fake/bin/sleep 0100444
|
|
||||||
fake/bin/stty 0100444
|
|
||||||
fake/bin/sum 0100444
|
|
||||||
fake/bin/sync 0100444
|
|
||||||
fake/bin/systrace 0100444
|
|
||||||
fake/bin/tar 0100711
|
|
||||||
fake/bin/test 0100711
|
|
||||||
|
|
||||||
[fake/bin/rm{,dir,ail}] <0x80>
|
[fake/bin/rm{,dir,ail}] <0x80>
|
||||||
fake/bin/rm
|
fake/bin/rm
|
||||||
fake/bin/rmdir
|
fake/bin/rmdir
|
||||||
@ -110,7 +62,3 @@ fake/bin/sha512
|
|||||||
|
|
||||||
[fake/bin/ca[a-z]] <0x0>
|
[fake/bin/ca[a-z]] <0x0>
|
||||||
fake/bin/cat
|
fake/bin/cat
|
||||||
|
|
||||||
[fake/b[a-z]*] <0x4000>
|
|
||||||
fake/bin 0040755
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user