mirror of
https://github.com/SELinuxProject/selinux
synced 2025-01-30 17:32:17 +00:00
policycoreutils: setfiles: Fix process_glob to handle error situations properly
Rather than error when a glob does not match return success as this is not a problem. Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Eric Paris <eparis@redhat.com>
This commit is contained in:
parent
a0e2e16878
commit
ddc5063c16
@ -368,19 +368,21 @@ int process_glob(char *name, int recurse) {
|
|||||||
int errors;
|
int errors;
|
||||||
memset(&globbuf, 0, sizeof(globbuf));
|
memset(&globbuf, 0, sizeof(globbuf));
|
||||||
errors = glob(name, GLOB_TILDE | GLOB_PERIOD, NULL, &globbuf);
|
errors = glob(name, GLOB_TILDE | GLOB_PERIOD, NULL, &globbuf);
|
||||||
if (errors)
|
if (errors == GLOB_NOMATCH)
|
||||||
errors = process_one_realpath(name, recurse);
|
return 0;
|
||||||
else {
|
|
||||||
for (i = 0; i < globbuf.gl_pathc; i++) {
|
if (errors)
|
||||||
int len = strlen(globbuf.gl_pathv[i]) -2;
|
return errors;
|
||||||
if (len > 0 && strcmp(&globbuf.gl_pathv[i][len--], "/.") == 0)
|
|
||||||
continue;
|
for (i = 0; i < globbuf.gl_pathc; i++) {
|
||||||
if (len > 0 && strcmp(&globbuf.gl_pathv[i][len], "/..") == 0)
|
int len = strlen(globbuf.gl_pathv[i]) -2;
|
||||||
continue;
|
if (len > 0 && strcmp(&globbuf.gl_pathv[i][len--], "/.") == 0)
|
||||||
errors |= process_one_realpath(globbuf.gl_pathv[i], recurse);
|
continue;
|
||||||
}
|
if (len > 0 && strcmp(&globbuf.gl_pathv[i][len], "/..") == 0)
|
||||||
globfree(&globbuf);
|
continue;
|
||||||
|
errors |= process_one_realpath(globbuf.gl_pathv[i], recurse);
|
||||||
}
|
}
|
||||||
|
globfree(&globbuf);
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user