Skip to contentSkip to conversation

Labeling confusion with apt-get/dpkg

DISCUSSION Roger Brunell 4 participants 11 messages Jun 3, 2005 – Jun 9, 2005 SELinux security module

lore
Share & tools
lore
#0 lore raw

Chalk this up to inexperience, but I am confused, I think.
I used apt-get to install tcsh on my system. 'dpkg' was updated with the sel-aware version. I then checked the labels and found conflicting data:

root@flattop:/usr/bin# cd /bin
root@flattop:/bin# ls -lZ bash
-rwxr-xr-x  root     root     system_u:object_r:shell_exec_t   bash
root@flattop:/bin# ls -lZ tcsh
-rwxr-xr-x  root     root     system_u:object_r:bin_t          tcsh
root@flattop:/bin# 

I look in /etc/selinux/strict/contexts/files/file_contexts:

    158 #
    159 # /bin
    160 #
    161 /bin(/.*)?                      system_u:object_r:bin_t
    162 /bin/tcsh               --      system_u:object_r:shell_exec_t
    163 /bin/bash               --      system_u:object_r:shell_exec_t
    164 /bin/bash2              --      system_u:object_r:shell_exec_t

bash's label came from line 163 (during a relabel op). While, it appears, that tcsh's label is from 161 (updated by dpkg). But why not a match with 162?

Who reads and interprets the file_contexts file? It doesn't appear to be conditional.

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________
Discover Yahoo!
Have fun online with music videos, cool games, IM and more. Check it out!
http://discover.yahoo.com/online.html

--
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 2 lines · Roger Brunell

Chalk this up to inexperience, but I am confused, I think. I used apt-get to install tcsh on my system.

you need to use se_apt-get, a wrapper around apt-get
that places apt-get into the right security domain or somethingorother i forget what

but if you run apt-get on its own, yep, that's pretty much what happens...

also have you installed the _modified_ version of dpkg - the one with the /etc/dpkg/postinst.d patch?

... get it while it hot, from selinux.lemuria.org/newselinux ...

if you want something to do "proper" fix, you would do well to analyse dpkg where it unpacks .debs and creates files/directories/symlinks, and to patch it to do setfilecon() calls at the appropriate points [just like rpm has been so patched - and accepted, it being rpm, redhat requiring FC to do selinux and all... ]

l.

Quoted 44 lines

'dpkg' was updated with the
sel-aware version. I then checked the labels and found conflicting data:

root@flattop:/usr/bin# cd /bin
root@flattop:/bin# ls -lZ bash
-rwxr-xr-x  root     root     system_u:object_r:shell_exec_t   bash
root@flattop:/bin# ls -lZ tcsh
-rwxr-xr-x  root     root     system_u:object_r:bin_t          tcsh
root@flattop:/bin# 

I look in /etc/selinux/strict/contexts/files/file_contexts:

    158 #
    159 # /bin
    160 #
    161 /bin(/.*)?                      system_u:object_r:bin_t
    162 /bin/tcsh               --      system_u:object_r:shell_exec_t
    163 /bin/bash               --      system_u:object_r:shell_exec_t
    164 /bin/bash2              --      system_u:object_r:shell_exec_t

bash's label came from line 163 (during a relabel op). While, it appears, that tcsh's label is from 161 (updated by dpkg). But why not a match with 162?

Who reads and interprets the file_contexts file? It doesn't appear to be conditional.

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________
Discover Yahoo!
Have fun online with music videos, cool games, IM and more. Check it out!
http://discover.yahoo.com/online.html

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

Signature · 8 lines
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

--
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.
#2 lore raw
Quoted 8 lines · --- Luke Kenneth Casson Leighton
Quoted 2 lines · Roger Brunell

Chalk this up to inexperience, but I am confused, I think. I used apt-get to install tcsh on my system.

you need to use se_apt-get, a wrapper around apt-get
that places apt-get into the right security domain or somethingorother i forget what

Ok; I tried that, so-so results, the full console is far below, but the essence is here:

root@flattop:/# se_apt-get tcsh
cannot find your entry in the passwd file.
authentication failed.

Is the auth procedure RedHat-centric? I am running Debian based.

root@flattop:/# which se_apt-get
/usr/sbin/se_apt-get
root@flattop:/# ll /usr/sbin/se_apt-get
lrwxrwxrwx  1 root root 7 Jun  2 12:37 /usr/sbin/se_apt-get -> se_dpkg
root@flattop:/# ll /usr/sbin/se_dpkg   
-rwxr-xr-x  1 root root 118 Jan 19 12:26 /usr/sbin/se_dpkg
root@flattop:/# file /usr/sbin/se_dpkg
/usr/sbin/se_dpkg: Bourne shell script text executable
root@flattop:/# cat /usr/sbin/se_dpkg
#!/bin/sh

EXEC=echo $0 | cut -f2 -d_

if [ "$EXEC" != "dpkg" ]; then
cd /
fi

exec /usr/sbin/run_init $EXEC "$@"
root@flattop:/#
root@flattop:/#

root@flattop:/# se_apt-get tcsh
cannot find your entry in the passwd file.
authentication failed.
root@flattop:/# 
root@flattop:/# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
root@flattop:/# grep root /etc/shadow
root:DEADZByreU07Q:12527:0:99999:7:::
root@flattop:/# 
Quoted 5 lines

but if you run apt-get on its own, yep, that's pretty much what happens...

also have you installed the _modified_ version of dpkg - the one with the /etc/dpkg/postinst.d patch?

Can't really say. I used an archive of SEL-aware packages supplied by Manoj
Srivastava. (www.golden-gryphon.com/software/security/selinux.xhtml)

Quoted 54 lines

... get it while it hot, from selinux.lemuria.org/newselinux ...

if you want something to do "proper" fix, you would do well to analyse dpkg where it unpacks .debs and creates files/directories/symlinks, and to patch it to do setfilecon() calls at the appropriate points [just like rpm has been so patched - and accepted, it being rpm, redhat requiring FC to do selinux and all... ]

l.

Quoted 20 lines

'dpkg' was updated with the
sel-aware version. I then checked the labels and found conflicting data:

root@flattop:/usr/bin# cd /bin
root@flattop:/bin# ls -lZ bash
-rwxr-xr-x  root     root     system_u:object_r:shell_exec_t   bash
root@flattop:/bin# ls -lZ tcsh
-rwxr-xr-x  root     root     system_u:object_r:bin_t          tcsh
root@flattop:/bin# 

I look in /etc/selinux/strict/contexts/files/file_contexts:

    158 #
    159 # /bin
    160 #
    161 /bin(/.*)?                      system_u:object_r:bin_t
    162 /bin/tcsh               --      system_u:object_r:shell_exec_t
    163 /bin/bash               --      system_u:object_r:shell_exec_t
    164 /bin/bash2              --      system_u:object_r:shell_exec_t
Quoted 1 line

bash's label came from line 163 (during a relabel op). While, it appears,

that

Quoted 19 lines

tcsh's label is from 161 (updated by dpkg). But why not a match with 162?

Who reads and interprets the file_contexts file? It doesn't appear to be conditional.

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________
Discover Yahoo!
Have fun online with music videos, cool games, IM and more. Check it out!
http://discover.yahoo.com/online.html

Quoted 11 lines
Quoted 3 lines

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected]

with

Quoted 1 line

the words "unsubscribe selinux" without quotes as the message.

Signature · 3 lines
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

--
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 13 lines · Roger Brunell
Quoted 8 lines · --- Luke Kenneth Casson Leighton
Quoted 2 lines · Roger Brunell

Chalk this up to inexperience, but I am confused, I think. I used apt-get to install tcsh on my system.

you need to use se_apt-get, a wrapper around apt-get
that places apt-get into the right security domain or somethingorother i forget what

Quoted 8 lines

Ok; I tried that, so-so results, the full console is far below, but the essence is here:

root@flattop:/# se_apt-get tcsh
cannot find your entry in the passwd file.
authentication failed.

Is the auth procedure RedHat-centric? I am running Debian based.

can you run strace -o log.txt -ff se_apt-get install tcsh for me, please, then post the logs ON A WEB SITE DO NOT ATTACH THEM TO THE LIST and let me know where the url is?

cheers,

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.

#4 lore raw
In reply to Roger Brunell
Quoted 17 lines · --- Roger Brunell
Quoted 8 lines · --- Luke Kenneth Casson Leighton
Quoted 2 lines · Roger Brunell

Chalk this up to inexperience, but I am confused, I think. I used apt-get to install tcsh on my system.

you need to use se_apt-get, a wrapper around apt-get
that places apt-get into the right security domain or somethingorother i forget what

Ok; I tried that, so-so results, the full console is far below, but the essence
is here:

Quoted 5 lines
root@flattop:/# se_apt-get tcsh
cannot find your entry in the passwd file.
authentication failed.

Is the auth procedure RedHat-centric? I am running Debian based.

Further research shows that run_init dynamicly links:

     root@flattop:/# ldd /usr/sbin/run_init
        libselinux.so.1 => /lib/libselinux.so.1 (0xb7fca000)
        libpam.so.0 => /lib/libpam.so.0 (0xb7fc1000)
        libpam_misc.so.0 => /lib/libpam_misc.so.0 (0xb7fbe000)
        libc.so.6 => /lib/tls/libc.so.6 (0xb7e89000)
        libdl.so.2 => /lib/tls/libdl.so.2 (0xb7e86000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)

and I do not have a libpam that is selinux aware. Manoj's site lists libpam as a target that needs to be worked, but as yet has no updated modules. I think I saw something on freenode:#selinux where he said there were 8000 lines of changes that needed to be reviewed and encorporated.

This may be a show-stopper....

Rog

Quoted 125 lines


root@flattop:/# which se_apt-get
/usr/sbin/se_apt-get
root@flattop:/# ll /usr/sbin/se_apt-get
lrwxrwxrwx  1 root root 7 Jun  2 12:37 /usr/sbin/se_apt-get -> se_dpkg
root@flattop:/# ll /usr/sbin/se_dpkg   
-rwxr-xr-x  1 root root 118 Jan 19 12:26 /usr/sbin/se_dpkg
root@flattop:/# file /usr/sbin/se_dpkg
/usr/sbin/se_dpkg: Bourne shell script text executable
root@flattop:/# cat /usr/sbin/se_dpkg
#!/bin/sh

EXEC=echo $0 | cut -f2 -d_

if [ "$EXEC" != "dpkg" ]; then
cd /
fi

exec /usr/sbin/run_init $EXEC "$@"
root@flattop:/#
root@flattop:/#

root@flattop:/# se_apt-get tcsh
cannot find your entry in the passwd file.
authentication failed.
root@flattop:/# 
root@flattop:/# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
root@flattop:/# grep root /etc/shadow
root:DEADZByreU07Q:12527:0:99999:7:::
root@flattop:/# 
Quoted 5 lines

but if you run apt-get on its own, yep, that's pretty much what happens...

also have you installed the _modified_ version of dpkg - the one with the /etc/dpkg/postinst.d patch?

Can't really say. I used an archive of SEL-aware packages supplied by
Manoj
Srivastava. (www.golden-gryphon.com/software/security/selinux.xhtml)

Quoted 53 lines

... get it while it hot, from selinux.lemuria.org/newselinux ...

if you want something to do "proper" fix, you would do well to analyse dpkg where it unpacks .debs and creates files/directories/symlinks, and to patch it to do setfilecon() calls at the appropriate points [just like rpm has been so patched - and accepted, it being rpm, redhat requiring FC to do selinux and all... ]

l.

Quoted 20 lines

'dpkg' was updated with the
sel-aware version. I then checked the labels and found conflicting data:

root@flattop:/usr/bin# cd /bin
root@flattop:/bin# ls -lZ bash
-rwxr-xr-x  root     root     system_u:object_r:shell_exec_t   bash
root@flattop:/bin# ls -lZ tcsh
-rwxr-xr-x  root     root     system_u:object_r:bin_t          tcsh
root@flattop:/bin# 

I look in /etc/selinux/strict/contexts/files/file_contexts:

    158 #
    159 # /bin
    160 #
    161 /bin(/.*)?                      system_u:object_r:bin_t
    162 /bin/tcsh               --      system_u:object_r:shell_exec_t
    163 /bin/bash               --      system_u:object_r:shell_exec_t
    164 /bin/bash2              --      system_u:object_r:shell_exec_t
Quoted 1 line

bash's label came from line 163 (during a relabel op). While, it appears,

that

Quoted 17 lines

tcsh's label is from 161 (updated by dpkg). But why not a match with 162?

Who reads and interprets the file_contexts file? It doesn't appear to be conditional.

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________
Discover Yahoo!
Have fun online with music videos, cool games, IM and more. Check it out!

Quoted 13 lines
Quoted 5 lines

http://discover.yahoo.com/online.html

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected]

with

Quoted 1 line

the words "unsubscribe selinux" without quotes as the message.

Signature · 3 lines
--
<a href="http://lkcl.net">http://lkcl.net</a>
--

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Quoted 5 lines

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

Roger Brunell

Infosec Engineer (retired)
"Born 20 years too early"

__________________________________
Discover Yahoo!
Stay in touch with email, IM, photo sharing and more. Check it out!
http://discover.yahoo.com/stayintouch.html

--
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
Quoted 4 lines · Roger Brunell

and I do not have a libpam that is selinux aware. Manoj's site lists libpam as a target that needs to be worked, but as yet has no updated modules. I think I saw something on freenode:#selinux where he said there were 8000 lines of changes that needed to be reviewed and encorporated.

Maybe there's 8K lines of changes *total* - but the SELinux patches that Fedora puts into the 'pam' RPM total all of....

% rpm2cpio pam-0.79-8.src.rpm | cpio -itv | grep selin 12990 blocks

-rw-rw-r--   1 root     root        60083 Apr  5 03:40 pam-0.78-selinux.patch
-rw-rw-r--   1 root     root        10327 Sep  9  2004 pam-pwdbselinux.patch

Certainly not 8K lines in there. 2500 or so according to 'wc', and of that a large chunk is adding a new PAM module. Might be a long afternoon's work, but probably not a "show stopper"

#6 lore raw
Quoted 2 lines · Valdis Kletnieks

Maybe there's 8K lines of changes *total* - but the SELinux patches that Fedora puts into the 'pam' RPM total all of....

Right. The issue here is integrating SELinux in with the
current Debian mods, and using a SCM that shall allow the maintainer to pull the changes back in. As an arch user, getting to know svn better is turning out to be a bad date ...

manoj

Signature · 8 lines
"Nature loves a vacuum.  Digital doesn't."  DEC sales letter
Manoj Srivastava   <[email protected]>    <[email protected]> 
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

--
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 Roger Brunell
Quoted 7 lines · Roger Brunell

and I do not have a libpam that is selinux aware. Manoj's site lists libpam as a target that needs to be worked, but as yet has no updated modules. I think I saw something on freenode:#selinux where he said there were 8000 lines of changes that needed to be reviewed and encorporated.

This may be a show-stopper....

I'm working on it. Sam Hartman want all this work to be based
off his svn repository, so he can merge changes back, and he wants ever one of Debian's patches checked and applied, if feasible. In the meanwhile I think Russell Coker's repository has the pam and sysvinit packages that you shall need.

I'll try and get pam into shape this week, or at least have
interim packages for people to use while I get things into shape that the Debian maintainer wants.

manoj

Signature · 9 lines
When a man's bad deeds are covered over by good ones, he illuminates
the world, like the moon breaking away from a cloud. 173
Manoj Srivastava   <[email protected]>    <[email protected]> 
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

--
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 8 lines · Manoj Srivastava
Quoted 5 lines · Roger Brunell

and I do not have a libpam that is selinux aware. Manoj's site lists libpam as a target that needs to be worked, but as yet has no updated modules. I think I saw something on freenode:#selinux where he said there were 8000 lines of changes that needed to be reviewed and encorporated.

Quoted 5 lines
Quoted 1 line

This may be a show-stopper....

I'm working on it. Sam Hartman want all this work to be based
off his svn repository,

... sam has taken over maintenance of pam? *hopeful*

--
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
In reply to Luke Kenneth Casson Leighton
Quoted 4 lines · Luke Kenneth Casson Leighton

also have you installed the _modified_ version of dpkg - the one with the /etc/dpkg/postinst.d patch?

... get it while it hot, from selinux.lemuria.org/newselinux ...

That version is unlikely to get into mainstream dpkg. There is
a newer version that does not create /etc/dpkg/postinst.d functionality, but uset matchpathcon and friends during unpacking to set the correct initial file context, which may get better reception.

http://www.glden-gryphon.com/software/security/Se-Linux.xhtml
for details.

manoj

Signature · 8 lines
We are what we pretend to be. Kurt Vonnegut, JR
Manoj Srivastava   <[email protected]>    <[email protected]> 
1024D/BF24424C print 4966 F272 D093 B493 410B  924B 21BA DABB BF24 424C

--
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.
#10 lore raw
Quoted 6 lines · Manoj Srivastava
Quoted 2 lines · Luke Kenneth Casson Leighton

also have you installed the _modified_ version of dpkg - the one with the /etc/dpkg/postinst.d patch?

Quoted 7 lines
Quoted 1 line

... get it while it hot, from selinux.lemuria.org/newselinux ...

That version is unlikely to get into mainstream dpkg. There is
a newer version that does not create /etc/dpkg/postinst.d functionality, but uset matchpathcon and friends during unpacking to set the correct initial file context, which may get better reception.

HOORAY.

Quoted 1 line

http://www.glden-gryphon.com/software/security/Se-Linux.xhtml

or: http://www.golden-gryphon.com/software/security/selinux.xhtml

:)

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