Skip to contentSkip to conversation

atsar system stats

DISCUSSION Erich Schubert 4 participants 4 messages Sep 13, 2004 – Sep 19, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
"atsar" is a system statistics utility. There is already a file context defined so it runs in the sysstat_t type, but i added the following rule to get rid of a warning:

dontaudit sysstat_t staff_home_dir_t:dir { search getattr };

No idea what atsar is trying to do there, but it works fine.

Gruß,
Erich Schubert

Signature · 9 lines
     erich@(mucl.de|debian.org)      --      GPG Key ID: 4B3A135C     (o_
      Which is worse: ignorance or apathy? Who knows? Who cares?      //\
 Man kann sich auch in Gesellschaft anderer einsam fühlen. Weizsäcker V_/_


--
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 5 lines · Erich Schubert

"atsar" is a system statistics utility. There is already a file context defined so it runs in the sysstat_t type, but i added the following rule to get rid of a warning:

dontaudit sysstat_t staff_home_dir_t:dir { search getattr };

sysstat is one of many programs that runs as UID==0 and tries to access it's home directory (probably because of being run from cron and cron will set the current directory before execution).

The policy for sysstat has a dontaudit rule for access to sysadm_home_dir_t but none for staff_home_dir_t.

Put sysadm_r before staff_r in the "users" entry for "root" and then rebuild the file_contexts file and relabel /root and things will work fine.

It's best to use sysadm_home_dir_t for /root so that someone who logs in as staff_r can't write to /root. If you have /root labelled as staff_home_dir_t then an attacker who gains access to staff_r:staff_t (IE someone who compromises sshd with strict policy) can replace /root/.bashrc etc and thus make it impossible for an administrator to safely login at the console.

I've attached a patch for the users file which does this.

Signature · 4 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
users renamed from usr/src/se/policy/users +1 -1
@@ -41,7 +41,7 @@
 
 # The sysadm_r user also needs to be permitted system_r if we are to allow
 # direct execution of daemons
-user root roles { staff_r sysadm_r ifdef(`direct_sysadm_daemon', `system_r') };
+user root roles { sysadm_r staff_r ifdef(`direct_sysadm_daemon', `system_r') };
 
 # sample for administrative user
 #user jadmin roles { staff_r sysadm_r ifdef(`direct_sysadm_daemon', `system_r') };
#2 lore raw

Basic problems with roles and domains

OS: stock Fedora Core 2

$ uname -a
Linux skorpion 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 i686 i386
GNU/Linux

Hi,

I'm trying to learn SELinux using FC2.
This is probably stupid problem, but it's difficult for a beginner.
First, I've added my user robert to 'users' file:

user robert roles { user_r };

In file_contexts/file_contexts:

/home/robert -d robert:object_r:user_home_dir_t
/home/robert/.+ robert:object_r:user_home_t

Policy rebuilt, filesystem relabeled, OK.
Then I've created file myfile.txt. By default, it's labeled:

$ ll -Z
-rw-rw-r--+ robert   robert   robert:object_r:user_home_t myfile.txt

In new file domains/program/robert.te, I added:

type myfile_txt_t, file_type;
type myfile_t, domain;
role robert_r types myfile_t;

allow user_t myfile_txt_t : file { getattr read };

... and

/home/robert/myfile.txt -- robert:object_r:myfile_txt_t

.. in file_contexts/program/robert.fc
I added role robert_r for use robert in users:

user robert roles { user_r robert_r};

Rebuilding, relabeling, etc.

Now, file has proper context:

$ ll -Z
-rw-rw-r--+ robert   robert   robert:object_r:myfile_txt_t    myfile.txt

And, as user robert, with context

$ id -Z
robert:user_r:user_t

I can read myfile.txt, but everything else is denied, according to 'allow' rule in domains/program/robert.te. Changing permissions in this rule works as expected, for domain user_t.

Now, I'd like to be able to access file only using new role robert_r (with domain myfile_t). So, I changed access rule to:

allow myfile_t myfile_txt_t : file { getattr read };

I added robert_r:myfile_t to /etc/security/default_type:

# grep robert  ../../../default_type
robert_r:myfile_t

Now, I don't have access as robert:user_r:user_t:

$ ll -Z ?---------+ ?        ?        (null)                         
myfile.txt

That's OK, but I cannot switch to role robert_r:

$ newrole -r robert_r
Authenticating robert.
Password:
failed to exec shell

Audit message:

Sep 19 15:52:28 skorpion kernel: audit(1095601948.937:0): avc:  denied 

{ transition } for pid=31796 exe=/usr/bin/newrole path=/bin/bash dev=hda3 ino=485768 scontext=robert:user_r:newrole_t tcontext=robert:robert_r:myfile_t tclass=process

The above happens if done in login shell, after 'su' it is:

$ newrole -r robert_r
Authenticating robert.
Password:
Warning!  Could not open /dev/pts/4.

I tried to follow guidelines from "Getting Started with SE Linux HOWTO", section 6 "Adding a new user domain" (changes in domains/user.te and macros/user_macros.te), but it didn't help.

Giving up, I tried to add myfile_t domain to user_r role:

role user_r types myfile_t;
allow myfile_t myfile_txt_t : file { getattr read };

As robert:user_r:user_t I have no access:

$ ll -Z
?---------+ ?        ?        (null)                          myfile.txt

Trying to switch domains:

$ newrole -t myfile_t
Authenticating robert.
Password:
failed to exec shell
Sep 19 16:15:34 skorpion kernel: audit(1095603334.119:0): avc:  denied 

{ transition } for pid=10171 exe=/usr/bin/newrole path=/bin/bash dev=hda3 ino=485768 scontext=robert:user_r:newrole_t tcontext=robert:user_r:myfile_t tclass=process

... for login shell, and, as before "Warning! Could not open /dev/pts/4." after su.

apol tool reports that user_r role contains myfile_t.

What else is necessary to set up new role ? Some additional domain transition rules ?

Thanks,
Robert

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

#3 lore raw

Re: Basic problems with roles and domains

Quoted 6 lines · Robert Kot

OS: stock Fedora Core 2

$ uname -a
Linux skorpion 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 i686 i386
GNU/Linux
Quoted 8 lines

Hi,

I'm trying to learn SELinux using FC2.
This is probably stupid problem, but it's difficult for a beginner.
First, I've added my user robert to 'users' file:

user robert roles { user_r };

okay: what this says is that when you do a make relabel, the program genhomedircon will go through looking for "ROLE" and automatically substitute and generate robert:object_r_user_home_t etc. on your behalf.

Quoted 5 lines

In new file domains/program/robert.te, I added:

type myfile_txt_t, file_type;
type myfile_t, domain;
role robert_r types myfile_t;

okay. creating new roles is a bit like doing new unix "groups". sort-of.

what i recommend here is that you examine russell's tutorial on selinux (which if you can't find it you should be able to reference via the ukuug.org web site because stephen tweedie did a 1day tutorial on selinux using russell's material, two months ago in leeds)

in the tutorial, they go through the creation of a role "professors_r".

and also take you through the necessary policy modification steps.

under normal circumstances, however, you really shouldn't need to create new roles: sysadm_r, staff_r and user_r are pretty much all that you'll ever need.

of course, for experimentation and as an aid to understanding, forget the above sentence :)

l.

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