Skip to contentSkip to conversation

missing features in user-land tools

DISCUSSION Russell Coker 2 participants 2 messages Feb 27, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

While working on my tutorial for the SE Linux symposium I noticed that there is some functionality that is missing from the utilities.

One thing is the display of the parent context. ps could be modified to have the option of displaying the parent context of every process, it's not absolutely required (things have been working well without that functionality), but it could be handy to have it.

Another is the possibility of creating a file with a specified context from a shell script. Of course it would be possible to do:

echo $CONTEXT > /proc/self/attr/fscreate
echo -n > $FILE

But that is a hack, even without the issue that it's impossible to unset it (see my previous message) this is not a desirable way of doing it.

I believe that for ideal functionality we want a program that will create a file with a specified context. It seems to me that modifying chcon would be a good way of doing this as chcon already supports specifying the context and the desired sym-link functionality. Something like "chcon -n $CONTEXT $FILE" with "-n" meaning that the file should be created if it doesn't exist (not sure whether we would want chcon to abort if the file doesn't already exist - maybe another option for that).

The precedent for that is touch(1) which will change the time-stamp or create the file if it doesn't exist.

I think it would also be good if mktemp(1) was modified to allow specifying the context of the file being created. Often a script creates a temp file which will be written to by a program running in a different context. Sure it could call chcon(1) after creating the temp file, but I think that having mktemp do it all would be better.

Signature · 9 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 12 lines · Russell Coker

I believe that for ideal functionality we want a program that will create a file with a specified context. It seems to me that modifying chcon would be a good way of doing this as chcon already supports specifying the context and the desired sym-link functionality. Something like "chcon -n $CONTEXT $FILE" with "-n" meaning that the file should be created if it doesn't exist (not sure whether we would want chcon to abort if the file doesn't already exist - maybe another option for that).

The precedent for that is touch(1) which will change the time-stamp or create the file if it doesn't exist.

Quoted 5 lines

I think it would also be good if mktemp(1) was modified to allow specifying the context of the file being created. Often a script creates a temp file which will be written to by a program running in a different context. Sure it could call chcon(1) after creating the temp file, but I think that having mktemp do it all would be better.

I could work out something on mktemp, it seems not difficult, but I will be able to do it after I finish the exams *sigh*.

Just lemme know how you want it (exactly) and what it needs to do among setting a proper context to the temporal file being created.

Also, maybe a helper within libselinux could be interesting.I would like to know what Stephen thinks at this point, if per-tool basis modification with the whole code for context setting or a common helper for those who share the same pattern.

Cheers,

Signature · 2 lines
Lorenzo Hernández García-Hierro <[email protected]> 
[1024D/6F2B2DEC] & [2048g/9AE91A22][http://tuxedo-es.org]