Skip to contentSkip to conversation

something up with use of setfiles

DISCUSSION Luke Kenneth Casson Leighton 1 participant 2 messages May 20, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

hi, i just had to double-checked something, because this is rather odd.

when running make relabel, i'd expect the entire filesystem to be relabelled, and it isn't: /usr/bin/kdm is not changed from its context of lkcl_t:object_r:bin_t.

so, well, okay, i figured i'd do a manual setfiles, just like in /etc/dpkg/postinst.d/setfiles.

okay, here we go, setfiles -q -s
/etc/selinux/file_contexts/file_contexts
it expects input, so type
/usr/bin/kdm
/usr/bin/kdm_greet
/usr/bin/kdm_config
^D

and voila, ls --context /usr/bin/kdm* shows NO CHANGE. the context is UNCHANGED.

okay, so what about this, let's try...
setfiles -q -s
/etc/selinux/file_contexts/domain/xdm.te
/usr/bin/kdm
/usr/bin/kdm_greet
/usr/bin/kdm_config
^D

check it again... AH HA!

-rwxr-xr-x  root     root     system_u:object_r:xdm_exec_t   kdm
-rwxr-xr-x  root     root     lkcl:object_r:staff_home_dir_t kdm_config
-rwxr-xr-x  root     root     lkcl:object_r:staff_home_dir_t kdm_greet

ta-daa. double-checking for kdm_config and kdm_greet in xdm.te, of course, obviously, they're not there, well i can live with that.

okay, so let's have a look at the _contents_ of
file_contexts/file_contexts:

/root/.default_contexts -- system_u:object_r:default_context_t

uhn.... is that right?

i no unnerstand.

okay, taking a look at the /etc/selinux/Makefile, this section:

$(FC): $(FCFILES) domains/program domains/misc file_contexts/program file_contexts/misc users

	@echo "Building file_contexts ..."
	@m4 $(FCFILES) > [email protected]
	@grep -v "^/root" [email protected] > [email protected]
	@/usr/sbin/genhomedircon . [email protected]  > $@
	@grep "^/root" [email protected] >> $@
	@-rm [email protected] [email protected]

if i comment out the 2nd grep, i get a complete
file_contexts/file_contexts.

hm...

okedokeeyyy... what about if i switch off the grep -v in the first grep and switch on grep -v in the second?

	@grep "^/root" [email protected] > [email protected]
	@/usr/sbin/genhomedircon . [email protected]  > $@
	@grep -v "^/root" [email protected] >> $@
	@-rm [email protected] [email protected]

ah ha! i get results! i appear to get a list of err stuff that looks familiar, but it doesn't have /root/.default_contexts anywhere in it: is that right?

l.

Signature · 15 lines
-- 
expecting email to be received and understood is a bit like
picking up the telephone and immediately dialing without
checking for a dial-tone; speaking immediately without listening
for either an answer or ring-tone; hanging up immediately and
believing that you have actually started a conversation.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />


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

okay, i tracked the problem down, it is my fault.

the genhomedircon script was out-of-date, and instead of sorting out macros and instead of outputting to stdout it changed file_contexts in-place.

why was genhomedircon out-of-date? because it wasn't updated from the .deb i built.

why was that? because i didn't actually examine very carefully the debian packing .diff i had found.

oops.

so, it's fine: i manually installed genhomedircon (and setfiles for good luck)

_now_ i have a chance of having a working system.

l.

p.s. don't try this at home.

Quoted 88 lines · Luke Kenneth Casson Leighton

hi, i just had to double-checked something, because this is rather odd.

when running make relabel, i'd expect the entire filesystem to be relabelled, and it isn't: /usr/bin/kdm is not changed from its context of lkcl_t:object_r:bin_t.

so, well, okay, i figured i'd do a manual setfiles, just like in /etc/dpkg/postinst.d/setfiles.

okay, here we go, setfiles -q -s
/etc/selinux/file_contexts/file_contexts
it expects input, so type
/usr/bin/kdm
/usr/bin/kdm_greet
/usr/bin/kdm_config
^D

and voila, ls --context /usr/bin/kdm* shows NO CHANGE. the context is UNCHANGED.

okay, so what about this, let's try...
setfiles -q -s
/etc/selinux/file_contexts/domain/xdm.te
/usr/bin/kdm
/usr/bin/kdm_greet
/usr/bin/kdm_config
^D

check it again... AH HA!

(quoted diff) +0 -3
-rwxr-xr-x  root     root     system_u:object_r:xdm_exec_t   kdm
-rwxr-xr-x  root     root     lkcl:object_r:staff_home_dir_t kdm_config
-rwxr-xr-x  root     root     lkcl:object_r:staff_home_dir_t kdm_greet

ta-daa. double-checking for kdm_config and kdm_greet in xdm.te, of course, obviously, they're not there, well i can live with that.

okay, so let's have a look at the _contents_ of
file_contexts/file_contexts:

/root/.default_contexts -- system_u:object_r:default_context_t

uhn.... is that right?

i no unnerstand.

okay, taking a look at the /etc/selinux/Makefile, this section:

$(FC): $(FCFILES) domains/program domains/misc file_contexts/program file_contexts/misc users

	@echo "Building file_contexts ..."
	@m4 $(FCFILES) > [email protected]
	@grep -v "^/root" [email protected] > [email protected]
	@/usr/sbin/genhomedircon . [email protected]  > $@
	@grep "^/root" [email protected] >> $@
	@-rm [email protected] [email protected]

if i comment out the 2nd grep, i get a complete
file_contexts/file_contexts.

hm...

okedokeeyyy... what about if i switch off the grep -v in the first grep and switch on grep -v in the second?

	@grep "^/root" [email protected] > [email protected]
	@/usr/sbin/genhomedircon . [email protected]  > $@
	@grep -v "^/root" [email protected] >> $@
	@-rm [email protected] [email protected]

ah ha! i get results! i appear to get a list of err stuff that looks familiar, but it doesn't have /root/.default_contexts anywhere in it: is that right?

l.

Signature · 9 lines
-- 
expecting email to be received and understood is a bit like
picking up the telephone and immediately dialing without
checking for a dial-tone; speaking immediately without listening
for either an answer or ring-tone; hanging up immediately and
believing that you have actually started a conversation.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />
Signature · 15 lines
-- 
expecting email to be received and understood is a bit like
picking up the telephone and immediately dialing without
checking for a dial-tone; speaking immediately without listening
for either an answer or ring-tone; hanging up immediately and
believing that you have actually started a conversation.
--
<a href="http://lkcl.net">      lkcl.net      </a> <br />
<a href="mailto:[email protected]"> [email protected] </a> <br />


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