All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: selinux@tycho.nsa.gov
Subject: Re: how to cope with file renames?
Date: Thu, 11 Mar 2010 12:42:10 -0500	[thread overview]
Message-ID: <4B992B72.7070907@redhat.com> (raw)
In-Reply-To: <20100311170014.GE24034@myhost.felk.cvut.cz>

On 03/11/2010 12:00 PM, Michal Svoboda wrote:
> Stephen Smalley wrote:
>    
>> http://pecl.php.net/package/selinux
>>      
> Thanks!
>
>    
>>> In short, I was wondering if there was a way for a rename()d file to be
>>> subjected to a type transition as if a new file was created? (I tried a
>>> type_trans rule but to no avail.) Or any other way to deal with renaming
>>> files between variously contexted dirs?
>>>        
>> No.  The best way of course is to create the file with the right
>> security context in the first place, whether explicitly or by uploading
>> it to the same parent directory as the final destination.
>>      
> That's what I do right now. I can do that because there's only one
> context. But in a web service your script isn't invoked until the file
> is already uploaded. So you can't pre-set the correct context and/or
> destination if you have two or more possibilities.
>
>    
>> Alternatively the php scriptlet can use the selinux bindings to
>> manipulate the context, or you can configure restorecond(8) to watch
>> for the destination file and reset its security context as needed.
>>      
> Does restorecond handle recursive directory restoring yet? (Last time I
> tried it worked only on single files.)
>
> But yes, in principle a cron job with 'restorecon -R' is a way too. But
> all those solutions are 'dirty', because they need you to make an extra
> effort. There's already a huge infrastructure with type inheritance and
> transitions, as to make the labeling independent of the application; but
> the rename operation just spoils that and forces you back to square one,
> to explicitly care about your files' contexts. Is there a fundamental
> reason why this is so (and can't be changed)?
>
>
> Michal Svoboda
>    
restorecond can handle * But not recursive.

You can watch ~/* for all entries in the homedir.  It would not be hard 
to add a watch an entire tree.

Just need to walk the tree adding watches for ever directory and any 
time a a new directory shows up you would add it to the watch list.  I 
am not sure how much inotify can handle.  We might get in trouble with 
the amount of resoures used.

~/...

Could watch millions of directories.


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

      parent reply	other threads:[~2010-03-11 17:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11  8:19 how to cope with file renames? Michal Svoboda
2010-03-11 13:32 ` Daniel J Walsh
2010-03-11 13:46 ` Stephen Smalley
2010-03-11 14:45   ` Richard Bullington-McGuire
2010-03-11 17:00   ` Michal Svoboda
2010-03-11 17:27     ` Stephen Smalley
2010-03-11 18:28       ` Michal Svoboda
2010-03-11 19:08         ` Stephen Smalley
2010-03-11 17:42     ` Daniel J Walsh [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=4B992B72.7070907@redhat.com \
    --to=dwalsh@redhat.com \
    --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.