Skip to contentSkip to conversation

selinux question

DISCUSSION Russell Coker 3 participants 5 messages Jul 23, 2002 – Jul 24, 2002 1 message not in the archive SELinux security module

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 13 lines · you

one thing I am still not clear on, how does selinux know to deny this:

Quoted 1 line

chsid system_u:object_r:user_netscape_rw_t ~/untrusted

/home/bam/untrusted: Permission denied

but not this:

Quoted 1 line

chsid bam:object_r:user_netscape_rw_t ~/untrusted

Jul 17 12:43:32 scrooge kernel: avc:  denied  { relabelto } for pid=3569

exe=/usr/bin/chsid path=/bam/untrusted dev=03:09 ino=423537 scontext=bam:user_r:user_t tcontext=system_u:object_r:user_netscape_rw_t tclass=dir

Quoted 5 lines

?

The rule seems to be the same in both cases.

allow user_t user_netscape_rw_t:{ dir file lnk_file } relabelto;

I'm not sure.

I've run into a similar issue, some scripts such as dh_installdocs call "cp -a" which tries to do such a chsid and fails. I think that "cp -a" should not preserve sids to avoid breaking compatability in such situations. Generally when "cp -a" is called you don't even want to preserve the UID, just the mode.

What do you think?

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#2 lore raw
Quoted 8 lines · Russell Coker
Quoted 7 lines · you

one thing I am still not clear on, how does selinux know to deny this:

Quoted 1 line

chsid system_u:object_r:user_netscape_rw_t ~/untrusted

/home/bam/untrusted: Permission denied

but not this:

Quoted 1 line

chsid bam:object_r:user_netscape_rw_t ~/untrusted

The first operation is denied by the policy/constraints configuration. As noted in the Configuring the SELinux Policy report, the constraint definitions specify additional restrictions on permissions that can be based on a combination of information from the user identity, TE, and RBAC models. These additional restrictions are specified as boolean expressions that must be satisfied in order for certain permissions to be granted. The relevant statement from policy/constraints is:

constrain dir_file_class_set { create relabelto relabelfrom }

	( u1 == u2 or t1 == privowner );

This statement limits the ability to create or relabel files with different user identities to domains that have the "privowner" attribute.

Quoted 7 lines

I've run into a similar issue, some scripts such as dh_installdocs call "cp -a" which tries to do such a chsid and fails. I think that "cp -a" should not preserve sids to avoid breaking compatability in such situations. Generally when "cp -a" is called you don't even want to preserve the UID, just the mode.

What do you think?

cp -a or cp -p does attempt to preserve the owner and group as well as the mode. cp -a or cp -p will treat a failed chown as an error if the user is root but will silently ignore failure if the user is non-root. The comment from the code says "If non-root uses -p, it's ok if we can't preserve ownership. But root probably wants to know, e.g. if NFS disallows it, or if the target system doesn't support file ownership." The same copying code is used by cp, install, and mv (for cross-filesystem moves).

We could have these utilities merely warn on failed chsid calls and not return an error by default. However, if we make such a change, we should definitely add a command line option to force the utility to treat it as an error for cases where this is desired.

--
Stephen D. Smalley, NAI Labs
[email protected]

--
You have received this message because you are subscribed to the selinux 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 1 line · Stephen Smalley

The first operation is denied by the policy/constraints configuration. As

Thanks.

Quoted 16 lines
Quoted 7 lines

I've run into a similar issue, some scripts such as dh_installdocs call "cp -a" which tries to do such a chsid and fails. I think that "cp -a" should not preserve sids to avoid breaking compatability in such situations. Generally when "cp -a" is called you don't even want to preserve the UID, just the mode.

What do you think?

cp -a or cp -p does attempt to preserve the owner and group as well as the mode. cp -a or cp -p will treat a failed chown as an error if the user is root but will silently ignore failure if the user is non-root. The comment from the code says "If non-root uses -p, it's ok if we can't preserve ownership. But root probably wants to know, e.g. if NFS disallows it, or if the target system doesn't support file ownership." The same copying code is used by cp, install, and mv (for cross-filesystem moves).

Quoted 4 lines

We could have these utilities merely warn on failed chsid calls and not return an error by default. However, if we make such a change, we should definitely add a command line option to force the utility to treat it as an error for cases where this is desired.

My problem is with a program that thinks it's root but isn't. For creating Debian packages we use a system called "fakeroot" which uses a LD_PRELOAD hack to override the getuid() system call and make a process think it's root. It also overrides the chown() and stat() system calls to make it look as if the file has changed ownership.

Maybe I should make the SE Linux programs use a shared object for the system call wrapper functions so that I can use a LD_PRELOAD hack to take over SE Linux system calls and replace them with my own equivalents. What do you think?

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
You have received this message because you are subscribed to the selinux 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 Russell Coker
Quoted 5 lines · Russell Coker

I've run into a similar issue, some scripts such as dh_installdocs call "cp -a" which tries to do such a chsid and fails. I think that "cp -a" should not preserve sids to avoid breaking compatability in such situations. Generally when "cp -a" is called you don't even want to preserve the UID, just the mode.

I have to ask why does dh_installdocs use cp -a, and not cp -dR.

It doesn't need to copy ownership or group, or permissions, as these will be reset later on by dh_fixperms.

It doesn't want to copy SIDs, as even if (or when) tar supported this, I don't think you want Debian packages to come supplied with built in SIDs.

Signature · 7 lines
Brian May <[email protected]>


--
You have received this message because you are subscribed to the selinux 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
Quoted 7 lines · Brian May
Quoted 5 lines · Russell Coker

I've run into a similar issue, some scripts such as dh_installdocs call "cp -a" which tries to do such a chsid and fails. I think that "cp -a" should not preserve sids to avoid breaking compatability in such situations. Generally when "cp -a" is called you don't even want to preserve the UID, just the mode.

Quoted 8 lines

I have to ask why does dh_installdocs use cp -a, and not cp -dR.

It doesn't need to copy ownership or group, or permissions, as these will be reset later on by dh_fixperms.

It doesn't want to copy SIDs, as even if (or when) tar supported this, I don't think you want Debian packages to come supplied with built in SIDs.

Good point. I've filed a bug report against dh_installdocs.

Signature · 3 lines
I do not get viruses because I do not use MS software.
If you use Outlook then please do not put my email address in your
address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line

From field.

--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.