Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setfiles: Add new argument '-y' to set a restorecon like run mode #383

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
setfiles: Add new argument '-y' to set a restorecon like run mode. This
allows to use the text representation of labels to be used for labeling
in a restorecon like mode. Useful in e.g. initrd where no policy is
loaded

Signed-off-by: Johannes Segitz <[email protected]>
  • Loading branch information
jsegitz committed Feb 23, 2023
commit 16541e2e57ba5541e67eeeb5279d782de21de4e7
4 changes: 4 additions & 0 deletions policycoreutils/setfiles/setfiles.8
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ use up to
threads. Specify 0 to create as many threads as there are available
CPU cores; 1 to use only a single thread (default); or any positive
number to use the given number of threads (if possible).
.TP
.BI \-y
run in a mode that resembles restorecon. Useful to relabel a complete system
in initrd when no policy is loaded

.SH "ARGUMENTS"
.TP
Expand Down
9 changes: 8 additions & 1 deletion policycoreutils/setfiles/setfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int main(int argc, char **argv)
const char *base;
int errors = 0;
const char *ropts = "e:f:hiIDlmno:pqrsvFRW0xT:";
const char *sopts = "c:de:f:hiIDlmno:pqr:svCEFR:W0T:";
const char *sopts = "c:de:f:hiIDlmno:pqr:svCEFR:W0T:y";
const char *opts;
union selinux_callback cb;
long unsigned skipped_errors;
Expand Down Expand Up @@ -265,6 +265,13 @@ int main(int argc, char **argv)
use_input_file = 1;
input_filename = optarg;
break;
case 'y':
r_opts.userealpath = SELINUX_RESTORECON_REALPATH;
r_opts.add_assoc = 0;
r_opts.xdev = 0;
r_opts.ignore_mounts = 0;
ctx_validate = 0;
break;
case 'd':
r_opts.debug = 1;
r_opts.log_matches =
Expand Down