From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov, Joshua Brindle <method@manicmethod.com>,
Chad Sellers <csellers@tresys.com>
Subject: Re: [RFC][PATCH] setfiles: only call realpath if the path is relative
Date: Thu, 30 Jul 2009 13:05:06 -0400 [thread overview]
Message-ID: <4A71D2C2.5080102@redhat.com> (raw)
In-Reply-To: <1248967075.11627.170.camel@moss-pluto.epoch.ncsc.mil>
On 07/30/2009 11:17 AM, Stephen Smalley wrote:
> Since we can now safely use restorecon -R / on kernels >= 2.6.30 without
> concern about restorecon descending into filesystems that do not support
> labeling, I wanted to compare it against running setfiles on the list of
> filesystems that support labeling. I noticed a significant difference
> in performance that I traced to the use of realpath() when setfiles is
> called as restorecon.
>
> When called as restorecon, setfiles calls realpath() so that sequences
> like:
> cd /etc
> restorecon shadow gshadow
> will work as expected.
>
> This patch changes the logic to only apply realpath() if the pathname is
> relative, which covers the above case. However, if a user runs
> restorecon /a/b/c and any of the components is a symlink, restorecon
> won't apply realpath after this patch and thus may not match the correct
> file contexts entry. Thoughts?
>
> diff --git a/policycoreutils/setfiles/setfiles.c b/policycoreutils/setfiles/setfiles.c
> index 5e5d957..996d230 100644
> --- a/policycoreutils/setfiles/setfiles.c
> +++ b/policycoreutils/setfiles/setfiles.c
> @@ -311,7 +311,7 @@ int match(const char *name, struct stat *sb, char **con)
> {
> char path[PATH_MAX + 1];
>
> - if (expand_realpath) {
> + if (expand_realpath && name[0] != '/') {
> if (S_ISLNK(sb->st_mode)) {
> if (verbose > 1)
> fprintf(stderr,
>
>
The place where this is a problem is
restorecon -Rv /etc/init.d
versus
restorecon -Rv /etc/rc.d/init.d
What happens to the labeling?
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2009-07-30 17:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-30 15:17 [RFC][PATCH] setfiles: only call realpath if the path is relative Stephen Smalley
2009-07-30 17:05 ` Daniel J Walsh [this message]
2009-07-30 17:28 ` Stephen Smalley
2009-07-30 18:58 ` Daniel J Walsh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A71D2C2.5080102@redhat.com \
--to=dwalsh@redhat.com \
--cc=csellers@tresys.com \
--cc=method@manicmethod.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.