All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Paul Menzel <paulepanter@users.sourceforge.net>
Cc: selinux@tycho.nsa.gov
Subject: Re: context of files not adapted to new directory when moved (was: htpasswd file outside of standard Apache location)
Date: Fri, 01 Jul 2011 09:46:21 -0400	[thread overview]
Message-ID: <1309527981.31276.21.camel@moss-pluto> (raw)
In-Reply-To: <1309388512.13175.35.camel@mattotaupa>

On Thu, 2011-06-30 at 01:01 +0200, Paul Menzel wrote:
> That solved my problem. The reason seems to be that I had that file
> first in my home directory and then used
> 
>         sudo mv ~/bar.tar.gz /srv/www/…
> 
> to move it to the Web site directory. `mv` seems to preserve the old
> SELinux contexts and I have to relabel it afterward. Is there a way to
> make the relabel step obsolete?

The semantics of mv are that it preserves the attributes of the original
file.  In the case where the source and destination are within the same
filesystem, mv uses rename(2) and thus the file (inode) doesn't change
at all, so you wouldn't expect any of the attributes to change.

If you had instead used cp, then the attributes would not have been
preserved by default (unless you used the appropriate options), and the
new file that was created would have been labeled in accordance with the
parent directory.

Some versions of install are instrumented to explicitly look up the
SELinux context from the file_contexts configuration and set the label
on the newly installed file accordingly.  Package managers like rpm and
dpkg are likewise instrumented.

-- 
Stephen Smalley
National Security Agency


--
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.

      reply	other threads:[~2011-07-01 13:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29 16:57 htpasswd file outside of standard Apache location Paul Menzel
2011-06-29 17:15 ` Dominick Grift
2011-06-29 23:01   ` context of files not adapted to new directory when moved (was: htpasswd file outside of standard Apache location) Paul Menzel
2011-07-01 13:46     ` Stephen Smalley [this message]

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=1309527981.31276.21.camel@moss-pluto \
    --to=sds@tycho.nsa.gov \
    --cc=paulepanter@users.sourceforge.net \
    --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.