Skip to content

Commit

Permalink
Add restorecon -x option to not cross FS boundaries
Browse files Browse the repository at this point in the history
Fixes: SELinuxProject/selinux#208

Signed-off-by: Peter Whittaker <pww@edgekeep.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
  • Loading branch information
PeterWhittaker authored and bachradsusi committed Jun 18, 2020
1 parent f5ac120 commit 7ad84e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions policycoreutils/setfiles/restorecon.8
Expand Up @@ -13,6 +13,7 @@ restorecon \- restore file(s) default SELinux security contexts.
.RB [ \-F ]
.RB [ \-W ]
.RB [ \-I | \-D ]
.RB [ \-x ]
.RB [ \-e
.IR directory ]
.IR pathname \ ...
Expand All @@ -31,6 +32,7 @@ restorecon \- restore file(s) default SELinux security contexts.
.RB [ \-F ]
.RB [ \-W ]
.RB [ \-I | \-D ]
.RB [ \-x ]

.SH "DESCRIPTION"
This manual page describes the
Expand Down Expand Up @@ -153,6 +155,11 @@ option of GNU
.B find
produces input suitable for this mode.
.TP
.B \-x
prevent
.B restorecon
from crossing file system boundaries.
.TP
.SH "ARGUMENTS"
.IR pathname \ ...
The pathname for the file(s) to be relabeled.
Expand Down
13 changes: 10 additions & 3 deletions policycoreutils/setfiles/setfiles.c
Expand Up @@ -43,8 +43,8 @@ static __attribute__((__noreturn__)) void usage(const char *const name)
{
if (iamrestorecon) {
fprintf(stderr,
"usage: %s [-iIDFmnprRv0] [-e excludedir] pathname...\n"
"usage: %s [-iIDFmnprRv0] [-e excludedir] -f filename\n",
"usage: %s [-iIDFmnprRv0x] [-e excludedir] pathname...\n"
"usage: %s [-iIDFmnprRv0x] [-e excludedir] -f filename\n",
name, name);
} else {
fprintf(stderr,
Expand Down Expand Up @@ -168,7 +168,7 @@ int main(int argc, char **argv)
size_t buf_len;
const char *base;
int errors = 0;
const char *ropts = "e:f:hiIDlmno:pqrsvFRW0";
const char *ropts = "e:f:hiIDlmno:pqrsvFRW0x";
const char *sopts = "c:de:f:hiIDlmno:pqr:svEFR:W0";
const char *opts;
union selinux_callback cb;
Expand Down Expand Up @@ -386,6 +386,13 @@ int main(int argc, char **argv)
case '0':
null_terminated = 1;
break;
case 'x':
if (iamrestorecon) {
r_opts.xdev = SELINUX_RESTORECON_XDEV;
} else {
usage(argv[0]);
}
break;
case 'h':
case '?':
usage(argv[0]);
Expand Down

0 comments on commit 7ad84e7

Please sign in to comment.