Skip to contentSkip to conversation

Why cron doesn't work in strict policy

DISCUSSION Daniel J Walsh 3 participants 8 messages Feb 7, 2006 2 messages not in the archive SELinux security module

lore
Share & tools
lore
#2 lore raw
In reply to a message not in the archive
Quoted 11 lines · Ivan Gyurdiev
Quoted 10 lines

cron ---> getseuserbyname(system_u)
selinux <--- (user_u, s0)
cron ---> get_default_context_with_level(user_u, s0)
selinux <--- (user_u:user_r:user_xserver_t) (????)
cron ---> security_compute_av(user_u:user_r:user_xserver_t, system_u:object_r:system_cron_spool_t) selinux <-- not allowed

The problem comes from system_u being mapped to __default__ in the seusers file, although I have no idea why (user_u, s0) would return default context of user_xserver_t either.

So for using system cronfiles, the getseuserbyname() call needs to be skilled (since you've already decided on the user - system_u, user.c: line 87). Not sure about level. Alternatively you can query using root.

Seems to me we have two choices. One is to change cron to default to "root" when there is no username or to add system_u to the seusers file.

Right now cron has the following code in it.

   if (get_security_context(pw == NULL ? "system_u" : uname,
                crontab_fd,
                &u->scontext, tabname) != 0) {
       free_user(u);
       u = NULL;
       goto done;
   }

get_security_context()
...
if (getseuserbyname(name, &seuser, &level) == 0) {
retval=get_default_context_with_level(seuser, level, NULL,

&scontext);
       free(seuser);
       free(level);
       if (retval) {

...

Which causes cron jobs on strict policy and I would guess MLS to run at user_u since system_u is not defined and would run at level s0.

--
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
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines

cron ---> getseuserbyname(system_u)
selinux <--- (user_u, s0)
cron ---> get_default_context_with_level(user_u, s0)
selinux <--- (user_u:user_r:user_xserver_t) (????)
cron ---> security_compute_av(user_u:user_r:user_xserver_t, system_u:object_r:system_cron_spool_t) selinux <-- not allowed

The problem comes from system_u being mapped to __default__ in the seusers file, although I have no idea why (user_u, s0) would return default context of user_xserver_t either.

So for using system cronfiles, the getseuserbyname() call needs to be skilled (since you've already decided on the user - system_u, user.c: line 87). Not sure about level. Alternatively you can query using root.

Seems to me we have two choices. One is to change cron to default to "root" when there is no username or to add system_u to the seusers file.

Well, on second thought querying root is not going to get you system_u in any way... I think the seuser query just needs to be skipped if you've decided to use system_u.

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

#5 lore raw
In reply to Stephen Smalley
Quoted 39 lines · Stephen Smalley
Quoted 37 lines · Daniel J Walsh
Quoted 11 lines · Ivan Gyurdiev
Quoted 9 lines

cron ---> getseuserbyname(system_u)
selinux <--- (user_u, s0)
cron ---> get_default_context_with_level(user_u, s0)
selinux <--- (user_u:user_r:user_xserver_t) (????)
cron ---> security_compute_av(user_u:user_r:user_xserver_t, system_u:object_r:system_cron_spool_t) selinux <-- not allowed

The problem comes from system_u being mapped to __default__ in the seusers file, although I have no idea why (user_u, s0) would return default context of user_xserver_t either.

So for using system cronfiles, the getseuserbyname() call needs to be skilled (since you've already decided on the user - system_u, user.c: line 87). Not sure about level. Alternatively you can query using root.

Seems to me we have two choices. One is to change cron to default to "root" when there is no username or to add system_u to the seusers file.

Right now cron has the following code in it.

    if (get_security_context(pw == NULL ? "system_u" : uname,
                 crontab_fd,
                 &u->scontext, tabname) != 0) {
        free_user(u);
        u = NULL;
        goto done;
    }

get_security_context()
...
if (getseuserbyname(name, &seuser, &level) == 0) {
retval=get_default_context_with_level(seuser, level, NULL,

&scontext);
        free(seuser);
        free(level);
        if (retval) {

...

Quoted 6 lines
Quoted 2 lines

Which causes cron jobs on strict policy and I would guess MLS to run at user_u since system_u is not defined and would run at level s0.

We should add system_u to seusers.

system_u:system_u:s0-s0:c0.c255

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

#6 lore raw
In reply to Stephen Smalley
Quoted 6 lines
Quoted 3 lines

Which causes cron jobs on strict policy and I would guess MLS to run at user_u since system_u is not defined and would run at level s0.

We should add system_u to seusers.

Why? There's no such Linux user...
This will cause problems with genhomedircon.

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

#4 lore raw
In reply to Daniel J Walsh
Quoted 36 lines · Daniel J Walsh
Quoted 10 lines · Ivan Gyurdiev
Quoted 10 lines

cron ---> getseuserbyname(system_u)
selinux <--- (user_u, s0)
cron ---> get_default_context_with_level(user_u, s0) selinux <--- (user_u:user_r:user_xserver_t) (????) cron ---> security_compute_av(user_u:user_r:user_xserver_t, system_u:object_r:system_cron_spool_t)
selinux <-- not allowed

Quoted 6 lines
Quoted 3 lines

The problem comes from system_u being mapped to __default__ in the seusers file, although I have no idea why (user_u, s0) would return default context of user_xserver_t either.

So for using system cronfiles, the getseuserbyname() call needs to be skilled (since you've already decided on the user - system_u, user.c:
line 87). Not sure about level. Alternatively you can query using root.

Seems to me we have two choices. One is to change cron to default to "root" when there is no username or to add system_u to the seusers file.

Right now cron has the following code in it.

    if (get_security_context(pw == NULL ? "system_u" : uname,
                 crontab_fd,
                 &u->scontext, tabname) != 0) {
        free_user(u);
        u = NULL;
        goto done;
    }

get_security_context()
...
if (getseuserbyname(name, &seuser, &level) == 0) {
retval=get_default_context_with_level(seuser, level, NULL,

Quoted 8 lines
&scontext);
        free(seuser);
        free(level);
        if (retval) {

...

Which causes cron jobs on strict policy and I would guess MLS to run at user_u since system_u is not defined and would run at level s0.

We should add system_u to seusers.

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw
In reply to Ivan Gyurdiev
Quoted 8 lines · Ivan Gyurdiev
Quoted 6 lines
Quoted 3 lines

Which causes cron jobs on strict policy and I would guess MLS to run at user_u since system_u is not defined and would run at level s0.

We should add system_u to seusers.

Why? There's no such Linux user...
This will cause problems with genhomedircon.

What kind of problem? Other alternative is to have crond skip the getseuserbyname() lookup if dealing with a system cron job (indicated by use of system_u), which just means a special cased check in the crond code.

Signature · 8 lines
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 [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#8 lore raw
Quoted 2 lines

What kind of problem?

The user doesn't exist, while genhomedircon() will do a passwd check on it, and print out warnings.

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

#9 lore raw
Quoted 4 lines · Ivan Gyurdiev
Quoted 2 lines

What kind of problem?

The user doesn't exist, while genhomedircon() will do a passwd check on it, and print out warnings.

You could change genhomedircon to ignore it as it does for default and user_u now.

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