policycoreutils: setfiles/restorecon: fix -r/-R option
A spec file was incorrectly stored as rootpath when -r option was used Fixes: /sbin/setfiles: /tmp/install_root is not located in /etc/selinux/targeted/contexts/files/file_contexts Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
This commit is contained in:
parent
b03543cdc0
commit
219eea83ce
|
@ -153,6 +153,9 @@ int main(int argc, char **argv)
|
||||||
int recurse; /* Recursive descent. */
|
int recurse; /* Recursive descent. */
|
||||||
const char *base;
|
const char *base;
|
||||||
int mass_relabel = 0, errors = 0;
|
int mass_relabel = 0, errors = 0;
|
||||||
|
const char *ropts = "e:f:hilno:pqrsvFRW0";
|
||||||
|
const char *sopts = "c:de:f:hilno:pqr:svFR:W0";
|
||||||
|
const char *opts;
|
||||||
|
|
||||||
memset(&r_opts, 0, sizeof(r_opts));
|
memset(&r_opts, 0, sizeof(r_opts));
|
||||||
|
|
||||||
|
@ -196,6 +199,7 @@ int main(int argc, char **argv)
|
||||||
r_opts.add_assoc = 1;
|
r_opts.add_assoc = 1;
|
||||||
r_opts.fts_flags = FTS_PHYSICAL | FTS_XDEV;
|
r_opts.fts_flags = FTS_PHYSICAL | FTS_XDEV;
|
||||||
ctx_validate = 1;
|
ctx_validate = 1;
|
||||||
|
opts = sopts;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* restorecon:
|
* restorecon:
|
||||||
|
@ -215,6 +219,7 @@ int main(int argc, char **argv)
|
||||||
r_opts.add_assoc = 0;
|
r_opts.add_assoc = 0;
|
||||||
r_opts.fts_flags = FTS_PHYSICAL;
|
r_opts.fts_flags = FTS_PHYSICAL;
|
||||||
ctx_validate = 0;
|
ctx_validate = 0;
|
||||||
|
opts = ropts;
|
||||||
|
|
||||||
/* restorecon only: silent exit if no SELinux.
|
/* restorecon only: silent exit if no SELinux.
|
||||||
Allows unconditional execution by scripts. */
|
Allows unconditional execution by scripts. */
|
||||||
|
@ -226,7 +231,7 @@ int main(int argc, char **argv)
|
||||||
r_opts.nfile = exclude_non_seclabel_mounts();
|
r_opts.nfile = exclude_non_seclabel_mounts();
|
||||||
|
|
||||||
/* Process any options. */
|
/* Process any options. */
|
||||||
while ((opt = getopt(argc, argv, "c:de:f:hilno:pqrsvFRW0")) > 0) {
|
while ((opt = getopt(argc, argv, opts)) > 0) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
|
@ -315,18 +320,13 @@ int main(int argc, char **argv)
|
||||||
recurse = 1;
|
recurse = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (optind + 1 >= argc) {
|
|
||||||
fprintf(stderr, "usage: %s -r rootpath\n",
|
|
||||||
argv[0]);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
if (NULL != r_opts.rootpath) {
|
if (NULL != r_opts.rootpath) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: only one -r can be specified\n",
|
"%s: only one -r can be specified\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
set_rootpath(argv[optind++]);
|
set_rootpath(optarg);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
use_input_file = 1;
|
use_input_file = 1;
|
||||||
|
|
Loading…
Reference in New Issue