SELinux and LFS
Hi, after some weeks i decided to come back at work on SELinux. I'm still writing you about SELinux support problem on an LFS-based distribution.
So, here is what i have done so far:
1) Kernel Configuration
I built the kernel with these options:
# CONFIG_KEYS is not setCONFIG_SECURITY=yCONFIG_SECURITY_NETWORK=y
# CONFIG_SECURITY_NETWORK_XFRM is not set CONFIG_SECURITY_CAPABILITIES=y
# CONFIG_SECURITY_ROOTPLUG is not set CONFIG_SECURITY_SELINUX=y CONFIG_SECURITY_SELINUX_BOOTPARAM=y CONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1 CONFIG_SECURITY_SELINUX_DISABLE=y CONFIG_SECURITY_SELINUX_DEVELOP=y CONFIG_SECURITY_SELINUX_AVC_STATS=y CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
# CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULT is not set # CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAX is not set
Of course with Ext[23] extended attributes, NET && INET, NETWORK_SECMARK and AUDIT support.
2) I have built and installed the SELinux userland packages (checkpolicy,libselinux, policycoreutils, policy) from:
svn co
https://selinux.svn.sourceforge.net/svnroot/selinux/branches/stable/1_0/
3) I unpacked the latest refpolicy according to:
http://oss.tresys.com/projects/refpolicy/wiki/UseRefpolicy
4) I still haven't patched packages like coreutils and sons.
5) I have created the /selinux mountpoint directory and added the following lines in fstab:
none /selinux selinuxfs defaults 0 0
6) So i added this line to my "lilo.conf":
append="enforcing=0"
7) Finally i tried to boot with the new kernel (2.6.20) and after the reboot the result is:
# sestatus SELinux status: disabled # #############################
Of course i can't go ahead from the point 5 to 11 of the official README in "selinux-doc".
I don't know if i really forgot something or if i skip something while i'm configuring SELinux because this is my really first experience with selinux configuration. What am i missing?
Any help would be appreciated.
Thanks in advance for your help!
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 3 lines · Vincenzo Ciaglia
Hi, after some weeks i decided to come back at work on SELinux. I'm still writing you about SELinux support problem on an LFS-based distribution.
I think your problem is here:
Quoted 1 line
4) I still haven't patched packages like coreutils and sons.
You need a patched init to load the policy. If no policy is loaded, SELinux is disabled:
Quoted 2 lines
# sestatus SELinux status: disabled
Signature · 9 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- 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.
Quoted 1 line · Christopher J. PeBenito
You need a patched init to load the policy.
To be clearer, init does the initial policy load when the system boots. It doesn't load the policy at any other time.
Signature · 9 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- 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.
Quoted 6 lines · Christopher J. PeBenito
Quoted 1 line · Christopher J. PeBenito
You need a patched init to load the policy.
To be clearer, init does the initial policy load when the system boots. It doesn't load the policy at any other time.
It is also possible to do the policy load from an initial ramdisk. The key is that init needs to somehow end up with the correct context.
Karl
--
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.
Il giorno mer, 14/02/2007 alle 18.08 +0000, Christopher J. PeBenito ha scritto:
Quoted 4 lines
Quoted 1 line
4) I still haven't patched packages like coreutils and sons.
You need a patched init to load the policy. If no policy is loaded, SELinux is disabled:
Hi, i tried to re-configure sysvinit with this patch (the fedora's one):
http://www.netwosix.org/selinux/sysvinit-selinux.patch (is the only one needed?)
But i get these outputs:
# patch -Np1 -i sysvinit-selinux.patch patching file src/init.c Hunk #1 succeeded at 42 (offset -6 lines). Hunk #2 succeeded at 2607 (offset 92 lines). Hunk #3 succeeded at 2573 (offset -6 lines). patching file src/Makefile Hunk #1 succeeded at 57 with fuzz 1 (offset 25 lines). Hunk #2 FAILED at 75. 1 out of 2 hunks FAILED -- saving rejects to file src/Makefile.rej patching file src/sulogin.c Hunk #1 FAILED at 28. Hunk #2 succeeded at 338 (offset 3 lines). 1 out of 2 hunks FAILED -- saving rejects to file src/sulogin.c.rej
# make -C src make: Entering directory `/home/vciaglia/sysvinit-2.86/src' gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o mountpoint.o mountpoint.c gcc -s -o mountpoint mountpoint.o gcc -c -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE init.c init.c: In function 're_exec': init.c:1889: warning: missing sentinel in function call gcc -c -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -DINIT_MAIN utmp.c -o init_utmp.o gcc -s -o init init.o init_utmp.o -lsepol -lselinux gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o halt.o halt.c gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o ifdown.o ifdown.c gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o hddown.o hddown.c gcc -c -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE utmp.c gcc -s -o halt halt.o ifdown.o hddown.o utmp.o gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o dowall.o dowall.c gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o shutdown.o shutdown.c gcc -s -o shutdown dowall.o shutdown.o utmp.o gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o runlevel.o runlevel.c gcc -s -o runlevel runlevel.o gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -s killall5.c -o killall5 gcc -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE -c -o sulogin.o sulogin.c sulogin.c: In function 'sushell': sulogin.c:338: error: 'is_selinux_enabled' undeclared (first use in this function) sulogin.c:338: error: (Each undeclared identifier is reported only once sulogin.c:338: error: for each function it appears in.) sulogin.c:339: error: 'security_context_t' undeclared (first use in this function) sulogin.c:339: error: expected ';' before 'scon' sulogin.c:342: warning: implicit declaration of function 'getseuserbyname' sulogin.c:343: warning: implicit declaration of function 'get_default_context_with_level' sulogin.c:343: error: 'scon' undeclared (first use in this function) sulogin.c:344: warning: implicit declaration of function 'setexeccon' sulogin.c:346: warning: implicit declaration of function 'freecon' make: *** [sulogin.o] Error 1 make: Leaving directory `/home/vciaglia/sysvinit-2.86/src' #
What is going wrong ? Maybe i'm missing something? I get the same "errors" when i try to patch the coreutils.
Thank you a lot,
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Il giorno mer, 14/02/2007 alle 18.08 +0000, Christopher J. PeBenito ha scritto:
Quoted 2 lines
You need a patched init to load the policy. If no policy is loaded, SELinux is disabled:
I finally patched everything with fedora's patch (pam,coreutils,sysvinit,openssh) for selinux-support and everything seems to be ok.
Coreutils-6.7 now are selinux-ready:
# ls -Z -rw-r--r-- root root unlabeled System.map drwxr-xr-x root root unlabeled bin
So i tried to reboot my kernel.
I still can't get selinux enabled. I think that is still a sysvinit problem. Init still can't perform the /selinux mount.
Here the package patched and selinux-ready that i built:
http://www.netwosix.org/selinux/sysvinit-2.85-selinux.tar.gz
I compiled it with the standard options:
# make -C src
# make -C src install
I also created a script in the /etc/rc but nothing happened. Until init can't mount /selinux i can't use /selinux/enforce.
So i still have problems. Any suggestions? Am i missing something ?
Thank you in advance!
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 25 lines · Vincenzo Ciaglia
Il giorno mer, 14/02/2007 alle 18.08 +0000, Christopher J. PeBenito ha scritto:
Quoted 2 lines
You need a patched init to load the policy. If no policy is loaded, SELinux is disabled:
I finally patched everything with fedora's patch (pam,coreutils,sysvinit,openssh) for selinux-support and everything seems to be ok.
Coreutils-6.7 now are selinux-ready:
# ls -Z -rw-r--r-- root root unlabeled System.map drwxr-xr-x root root unlabeled binSo i tried to reboot my kernel.
I still can't get selinux enabled. I think that is still a sysvinit problem. Init still can't perform the /selinux mount.
Here the package patched and selinux-ready that i built:
http://www.netwosix.org/selinux/sysvinit-2.85-selinux.tar.gzI compiled it with the standard options:
Quoted 7 lines
# make -C src
# make -C src installI also created a script in the
/etc/rcbut nothing happened. Until init can't mount /selinux i can't use /selinux/enforce.So i still have problems. Any suggestions? Am i missing something ?
If you boot your kernel with init=/bin/bash and try to manually mount selinuxfs on /selinux, does it work?
Also, be warned that it is presently very difficult to find all of the selinux-related bits in Fedora and apply them elsewhere; there may be multiple patches in a single package that are selinux-related, they can be relative to non-selinux patches in the same package, and they have become increasingly intertwined with audit patches. Which is why people familiar with that code need to do some work to extract them, unify them, clean them up, and re-base them to an upstream (if one exists).
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.
Il giorno gio, 15/02/2007 alle 13.41 -0500, Stephen Smalley ha scritto:
Quoted 2 lines
If you boot your kernel with init=/bin/bash and try to manually mount selinuxfs on /selinux, does it work?
I don't know i still haven't tried but i think isn't a good idea to manually mount the selinuxfs. Like i said it will be a public-use gnu/linux distribution for networking and security related works. Even if could be used from expert and skilled users i think that this solution is really too uncomfortable, don't you?
However i also tried to add this line to my "/etc/rc" script:
/bin/mount -t selinuxfs /selinux
But nothing happened.
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 10 lines · Vincenzo Ciaglia
Il giorno gio, 15/02/2007 alle 13.41 -0500, Stephen Smalley ha scritto:
Quoted 2 lines
If you boot your kernel with init=/bin/bash and try to manually mount selinuxfs on /selinux, does it work?
I don't know i still haven't tried but i think isn't a good idea to manually mount the selinuxfs. Like i said it will be a public-use gnu/linux distribution for networking and security related works. Even if could be used from expert and skilled users i think that this solution is really too uncomfortable, don't you?
I'm not suggesting it for production use, just to independently check on your ability to mount selinuxfs, since you said that init seems to be failing at that point.
Quoted 5 lines
However i also tried to add this line to my "
/etc/rc" script:
/bin/mount-t selinuxfs /selinuxBut nothing happened.
Should be:
mount -t selinuxfs none /selinux
But doing it from init=/bin/bash will be closer to what init experiences than from your rc scripts.
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.
Il giorno mer, 14/02/2007 alle 18.08 +0000, Christopher J. PeBenito ha scritto:
Quoted 2 lines
You need a patched init to load the policy. If no policy is loaded, SELinux is disabled:
In addition here the pre-compiled tar.gz derived from the latest debian selinux-patched sysvinit.
http://www.netwosix.org/selinux/sysvinit-2.86-5-selinux.tar.gz
But again:
# sestatus SELinux status: disabled #
So i'm thinking that the problem isn't init anymore.
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 26 lines · Vincenzo Ciaglia
Hi, after some weeks i decided to come back at work on SELinux. I'm still writing you about SELinux support problem on an LFS-based distribution.
So, here is what i have done so far:
1) Kernel Configuration
I built the kernel with these options:
#
CONFIG_KEYSis not setCONFIG_SECURITY=yCONFIG_SECURITY_NETWORK=y
#CONFIG_SECURITY_NETWORK_XFRMis not setCONFIG_SECURITY_CAPABILITIES=y
#CONFIG_SECURITY_ROOTPLUGis not setCONFIG_SECURITY_SELINUX=yCONFIG_SECURITY_SELINUX_BOOTPARAM=yCONFIG_SECURITY_SELINUX_BOOTPARAM_VALUE=1CONFIG_SECURITY_SELINUX_DISABLE=yCONFIG_SECURITY_SELINUX_DEVELOP=yCONFIG_SECURITY_SELINUX_AVC_STATS=yCONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE=1
#CONFIG_SECURITY_SELINUX_ENABLE_SECMARK_DEFAULTis not set #CONFIG_SECURITY_SELINUX_POLICYDB_VERSION_MAXis not set
Quoted 1 line
Of course with Ext[23] extended attributes,
And CONFIG_EXT3_FS_SECURITY=y too, I assume (i.e. not just the base xattr support, but also the security xattr handler).
Quoted 2 lines
3) I unpacked the latest refpolicy according to:
http://oss.tresys.com/projects/refpolicy/wiki/UseRefpolicy
And built it and installed it? And created an /etc/selinux/config file? With what contents?
Quoted 5 lines
7) Finally i tried to boot with the new kernel (2.6.20) and after the reboot the result is:
# sestatus SELinux status: disabled
With what kernel messages from SELinux? e.g.
$ dmesg | grep SELinux SELinux: Initializing. SELinux: Starting in permissive mode SELinux: Registering netfilter hooks SELinux: Completing initialization. SELinux: Setting up existing superblocks. SELinux: initialized (dev dm-0, type ext3), uses xattr ...
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.
Il giorno gio, 15/02/2007 alle 14.12 -0500, Stephen Smalley ha scritto:
Quoted 4 lines
Quoted 1 line
Of course with Ext[23] extended attributes,
And
CONFIG_EXT3_FS_SECURITY=ytoo, I assume (i.e. not just the base xattr support, but also the security xattr handler).
Done, of course.
#
# File systems
#CONFIG_EXT2_FS=yCONFIG_EXT2_FS_XATTR=yCONFIG_EXT2_FS_POSIX_ACL=yCONFIG_EXT2_FS_SECURITY=yCONFIG_EXT2_FS_XIP=yCONFIG_FS_XIP=yCONFIG_EXT3_FS=yCONFIG_EXT3_FS_XATTR=yCONFIG_EXT3_FS_POSIX_ACL=yCONFIG_EXT3_FS_SECURITY=y
Quoted 4 lines
Quoted 2 lines
3) I unpacked the latest refpolicy according to:
http://oss.tresys.com/projects/refpolicy/wiki/UseRefpolicyAnd built it and installed it?
Yes, like it said in that page.
Quoted 1 line
And created an
/etc/selinux/configfile?
Yes.
Quoted 1 line
With what contents?
# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=permissive # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted # SETLOCALDEFS= Check local definition changes SETLOCALDEFS=0 #
Quoted 1 line
With what kernel messages from SELinux?
# dmesg | grep SELinux SELinux: Initializing. SELinux: Starting in permissive mode #
Thank you!
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 13 lines · Vincenzo Ciaglia
Quoted 1 line
With what contents?
# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=permissive # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted
And your policy is installed
under /etc/selinux/targeted/policy/policy.xx?
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.
Il giorno gio, 15/02/2007 alle 14.31 -0500, Stephen Smalley ha scritto:
Quoted 4 lines
SELINUXTYPE=targeted
And your policy is installed
under/etc/selinux/targeted/policy/policy.xx?
Ops...hh no. Here my error. My policy is under/etc/selinux/netwosix/policy/policy.21
So i rebooted and:
# dmesg | grep selinux selinux_register_security: Registering secondary module capability SELinux: initialized (dev selinuxfs, type selinuxfs), uses genfs_contexts # sestatus SELinux status: enabled SELinuxfs mount: /selinux Current mode: permissive Mode from config file: permissive Policy version: 21 Policy from config file: netwosix
Finally it works! Thank you very much! :)
Now i can start working on policies.
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 8 lines · Vincenzo Ciaglia
Il giorno gio, 15/02/2007 alle 14.31 -0500, Stephen Smalley ha scritto:
Quoted 4 lines
SELINUXTYPE=targeted
And your policy is installed
under/etc/selinux/targeted/policy/policy.xx?Ops...hh no. Here my error. My policy is under
/etc/selinux/netwosix/policy/policy.21
Ok. SELINUXTYPE= is just the name where your policy is located; it doesn't have to mean anything about the actual kind of policy (although conventionally we use "targeted", "strict", "mls", etc to indicate the kind of policy too.)
Quoted 6 lines
So i rebooted and:
# dmesg | grep selinux selinux_register_security: Registering secondary module capability SELinux: initialized (dev selinuxfs, type selinuxfs), uses genfs_contexts
You actually wanted to grep for "SELinux" (capitalization) or grep -i, but that's ok. Although I thought Eric was going to kill or at least silence by default many of those messages.
Quoted 9 lines
# sestatus SELinux status: enabled SELinuxfs mount: /selinux Current mode: permissive Mode from config file: permissive Policy version: 21 Policy from config file: netwosixFinally it works! Thank you very much! :)
Good. Of course, since it is permissive, it isn't enforcing anything yet, just logging what would be denied. Did you label your filesystems yet?
Quoted 1 line
Now i can start working on policies.
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.
Il giorno gio, 15/02/2007 alle 15.03 -0500, Stephen Smalley ha scritto:
Quoted 3 lines
You actually wanted to grep for "SELinux" (capitalization) or grep -i, but that's ok. Although I thought Eric was going to kill or at least silence by default many of those messages.
Here we are:
# dmesg | grep -i selinux SELinux: Initializing. SELinux: Starting in permissive mode selinux_register_security: Registering secondary module capability SELinux: Completing initialization. SELinux: Setting up existing superblocks. SELinux: initialized (dev hda1, type ext3), uses xattr SELinux: initialized (dev usbfs, type usbfs), uses genfs_contexts SELinux: initialized (dev selinuxfs, type selinuxfs), uses genfs_contexts SELinux: initialized (dev mqueue, type mqueue), uses transition SIDs SELinux: initialized (dev hugetlbfs, type hugetlbfs), uses genfs_contexts SELinux: initialized (dev devpts, type devpts), uses transition SIDs SELinux: initialized (dev eventpollfs, type eventpollfs), uses task SIDs SELinux: initialized (dev inotifyfs, type inotifyfs), uses genfs_contexts SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs SELinux: initialized (dev futexfs, type futexfs), uses genfs_contexts SELinux: initialized (dev pipefs, type pipefs), uses task SIDs SELinux: initialized (dev sockfs, type sockfs), uses task SIDs SELinux: initialized (dev proc, type proc), uses genfs_contexts SELinux: initialized (dev bdev, type bdev), uses genfs_contexts SELinux: initialized (dev rootfs, type rootfs), uses genfs_contexts SELinux: initialized (dev sysfs, type sysfs), uses genfs_contexts SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs SELinux: initialized (dev hdb1, type ext3), uses xattr
Quoted 3 lines
Good. Of course, since it is permissive, it isn't enforcing anything yet, just logging what would be denied. Did you label your filesystems yet?
Yes:
# cd /etc/selinux/refpolicy/src/policy/ # make relabel Relabeling filesystem types: ext2 ext3 xfs jfs /sbin/setfiles /etc/selinux/netwosix/contexts/files/file_contexts / /usr /sbin/setfiles: labeling files under / matchpathcon_filespec_eval: hash table stats: 2571 elements, 2559/65536 buckets used, longest chain length 2 /sbin/setfiles: labeling files under /usr matchpathcon_filespec_eval: hash table stats: 81537 elements, 20107/65536 buckets used, longest chain length 10 /sbin/setfiles: Done. #
So i rebooted and when i try to "sysadm_r" i get this:
# newrole -r sysadm_r Couldn't get default type. #
But i still haven't read anything about this. Now i'm too happy that selinux is enabled and it's working ... after many weeks of patch+patch +hack+hack on the new netwosix system :)
Thank you,
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 55 lines · Vincenzo Ciaglia
Il giorno gio, 15/02/2007 alle 15.03 -0500, Stephen Smalley ha scritto:
Quoted 3 lines
You actually wanted to grep for "SELinux" (capitalization) or grep -i, but that's ok. Although I thought Eric was going to kill or at least silence by default many of those messages.
Here we are:
# dmesg | grep -i selinux SELinux: Initializing. SELinux: Starting in permissive mode selinux_register_security: Registering secondary module capability SELinux: Completing initialization. SELinux: Setting up existing superblocks. SELinux: initialized (dev hda1, type ext3), uses xattr SELinux: initialized (dev usbfs, type usbfs), uses genfs_contexts SELinux: initialized (dev selinuxfs, type selinuxfs), uses genfs_contexts SELinux: initialized (dev mqueue, type mqueue), uses transition SIDs SELinux: initialized (dev hugetlbfs, type hugetlbfs), uses genfs_contexts SELinux: initialized (dev devpts, type devpts), uses transition SIDs SELinux: initialized (dev eventpollfs, type eventpollfs), uses task SIDs SELinux: initialized (dev inotifyfs, type inotifyfs), uses genfs_contexts SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs SELinux: initialized (dev futexfs, type futexfs), uses genfs_contexts SELinux: initialized (dev pipefs, type pipefs), uses task SIDs SELinux: initialized (dev sockfs, type sockfs), uses task SIDs SELinux: initialized (dev proc, type proc), uses genfs_contexts SELinux: initialized (dev bdev, type bdev), uses genfs_contexts SELinux: initialized (dev rootfs, type rootfs), uses genfs_contexts SELinux: initialized (dev sysfs, type sysfs), uses genfs_contexts SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs SELinux: initialized (dev hdb1, type ext3), uses xattrQuoted 3 lines
Good. Of course, since it is permissive, it isn't enforcing anything yet, just logging what would be denied. Did you label your filesystems yet?
Yes:
# cd /etc/selinux/refpolicy/src/policy/ # make relabel Relabeling filesystem types: ext2 ext3 xfs jfs /sbin/setfiles /etc/selinux/netwosix/contexts/files/file_contexts / /usr /sbin/setfiles: labeling files under / matchpathcon_filespec_eval: hash table stats: 2571 elements, 2559/65536 buckets used, longest chain length 2 /sbin/setfiles: labeling files under /usr matchpathcon_filespec_eval: hash table stats: 81537 elements, 20107/65536 buckets used, longest chain length 10 /sbin/setfiles: Done. #
Quoted 4 lines
So i rebooted and when i try to "
sysadm_r" i get this:# newrole -r sysadm_r Couldn't get default type. #
Targeted policy doesn't support user roles; it only confines specific programs, primarily focused on system services. Strict policy is what you want if you need user roles. In the future, we hope to reduce the divergence between them so that you can have a targeted system with some limited user roles.
Quoted 6 lines
But i still haven't read anything about this. Now i'm too happy that selinux is enabled and it's working ... after many weeks of patch+patch +hack+hack on the new netwosix system :)
Thank you,
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.
Il giorno gio, 15/02/2007 alle 15.34 -0500, Stephen Smalley ha scritto:
Quoted 5 lines
Targeted policy doesn't support user roles; it only confines specific programs, primarily focused on system services. Strict policy is what you want if you need user roles. In the future, we hope to reduce the divergence between them so that you can have a targeted system with some limited user roles.
Of course Netwosix will use "strict" policies. So i'm going to start working on it.
I'll keep you updated.
Thank you,
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 8 lines · Vincenzo Ciaglia
Il giorno gio, 15/02/2007 alle 15.34 -0500, Stephen Smalley ha scritto:
Quoted 5 lines
Targeted policy doesn't support user roles; it only confines specific programs, primarily focused on system services. Strict policy is what you want if you need user roles. In the future, we hope to reduce the divergence between them so that you can have a targeted system with some limited user roles.
Quoted 7 lines
Of course Netwosix will use "strict" policies. So i'm going to start working on it.
I'll keep you updated.
Thank you,
Taking a look at your post at netwosix.org I think you should know that you most likely still have some serious filesystem labeling problems.
Yours:
# ls -Z drwxr-xr-x root root system_u:object_r:file_t bin drwxr-xr-x root root system_u:object_r:file_t boot drwxr-xr-x root root system_u:object_r:file_t cdrom drwxr-xr-x root root system_u:object_r:tmpfs_t dev
Mine:
#ls -Z
drwxr-xr-x root root system_u:object_r:bin_t bin drwxr-xr-x root root system_u:object_r:boot_t boot drwxr-xr-x root root system_u:object_r:device_t dev
Maybe someone else can chime in with the best way to try this again since it doesn't look to me like the make relabel really got everything you needed (and I have no idea if you rc.sysinit is patched to pay attention to /.autorelabel)
-Eric
--
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.
Quoted 28 lines · Eric Paris
Quoted 8 lines · Vincenzo Ciaglia
Il giorno gio, 15/02/2007 alle 15.34 -0500, Stephen Smalley ha scritto:
Quoted 5 lines
Targeted policy doesn't support user roles; it only confines specific programs, primarily focused on system services. Strict policy is what you want if you need user roles. In the future, we hope to reduce the divergence between them so that you can have a targeted system with some limited user roles.
Quoted 7 lines
Of course Netwosix will use "strict" policies. So i'm going to start working on it.
I'll keep you updated.
Thank you,
Taking a look at your post at netwosix.org I think you should know that you most likely still have some serious filesystem labeling problems.
Yours:
# ls -Z drwxr-xr-x root root system_u:object_r:file_t bin drwxr-xr-x root root system_u:object_r:file_t boot drwxr-xr-x root root system_u:object_r:file_t cdrom drwxr-xr-x root root system_u:object_r:tmpfs_t devMine:
#ls -Z
Quoted 8 lines
drwxr-xr-x root root system_u:object_r:bin_t bin drwxr-xr-x root root system_u:object_r:boot_t boot drwxr-xr-x root root system_u:object_r:device_t devMaybe someone else can chime in with the best way to try this again since it doesn't look to me like the make relabel really got everything you needed (and I have no idea if you rc.sysinit is patched to pay attention to /.autorelabel)
Don't know about the /bin and /boot issues, but for /dev, I'd suggest checking that your udev is built with selinux support enabled. And also you should do a restorecon -R /dev from rc.sysinit or similar, as there will be some nodes created before selinux policy gets loaded.
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.
Il giorno gio, 15/02/2007 alle 15.59 -0500, Stephen Smalley ha scritto:
Quoted 4 lines
Don't know about the /bin and /boot issues, but for /dev, I'd suggest checking that your udev is built with selinux support enabled. And also you should do a restorecon -R /dev from rc.sysinit or similar, as there will be some nodes created before selinux policy gets loaded.
Ops. In the attach the /etc/rc. It's really late here guys.
Signature · 2 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org>
ELinux on Netwosix
/sbin/restorecon -R /dev
SELINUX=
if [ -r /selinux/enforce ] ; then
SELINUX= 'cat /selinux/enforce'
else
SELINUX=1
fi
# Other SELINUX stuff
disable_selinux() {
echo $"*** Warning -- SELinux is active"
echo $"*** Disabling security enforcement for system recovery." echo $"*** Run 'setenforce 1' to reenable."
echo "0" > /selinux/enforce
}
relabel_selinux() {
echo
echo $"*** Warning -- SELinux policy relabel is required. " echo $"*** Disabling security enforcement." echo $"*** Relabeling could take a very long time," echo $"*** depending on file system size."
echo "0" > /selinux/enforce /sbin/fixfiles -f -F relabel > /dev/null 2>&1 rm -f /.autorelabel
echo "*** Enabling security enforcement. ***"
echo $SELINUX > /selinux/enforce
}
Il giorno gio, 15/02/2007 alle 15.56 -0500, Eric Paris ha scritto:
Quoted 4 lines
Maybe someone else can chime in with the best way to try this again since it doesn't look to me like the make relabel really got everything you needed (and I have no idea if you rc.sysinit is patched to pay attention to /.autorelabel)
Yes, i'm just taking a look to the "ls -Z" of my Fedora's system and you're right. I'll pay attention later.
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Il giorno gio, 15/02/2007 alle 15.56 -0500, Eric Paris ha scritto:
Quoted 4 lines
Maybe someone else can chime in with the best way to try this again since it doesn't look to me like the make relabel really got everything you needed (and I have no idea if you rc.sysinit is patched to pay attention to /.autorelabel)
Ok, fixed!
In the attach the SELINUX portion of my /etc/rc. I think it's ok but actually it's just working.
Here the result:
# ls -Z -rw-r--r-- root root system_u:object_r:default_t System.map drwxr-xr-x root root system_u:object_r:bin_t bin drwxr-xr-x root root system_u:object_r:boot_t boot drwxr-xr-x root root system_u:object_r:default_t cdrom drwxr-xr-x root root system_u:object_r:device_t dev drwxr-xr-x root root system_u:object_r:etc_t etc drwxr-xr-x root root system_u:object_r:home_root_t home drwxr-xr-x root root system_u:object_r:default_t include drwxr-xr-x root root system_u:object_r:default_t info drwxr-xr-x root root system_u:object_r:lib_t lib drwxr-xr-x root root system_u:object_r:default_t libexec drwx------ root root system_u:object_r:lost_found_t lost+found drwxr-xr-x root root system_u:object_r:default_t man drwxr-xr-x root root system_u:object_r:mnt_t mnt drwxr-xr-x root root system_u:object_r:usr_t opt dr-xr-xr-x root root system_u:object_r:proc_t proc drwxr-x--- root root root:object_r:user_home_dir_t root drwxr-xr-x root root system_u:object_r:sbin_t sbin drwxr-xr-x root root system_u:object_r:security_t selinux drwxr-xr-x root root system_u:object_r:default_t share drwxr-xr-x root root system_u:object_r:sysfs_t sys drwxrwxrwt root root system_u:object_r:tmp_t tmp drwxr-xr-x root root system_u:object_r:usr_t usr drwxr-xr-x root root system_u:object_r:var_t var -rw-r--r-- root root system_u:object_r:default_t vmlinuz
However i rebuilt the refpolicy with "strict" options and now i get this:
# newrole -r sysadm_r Authenticating root. newrole: incorrect password for root #
I'm working no stop from almost 9 hours, so i'm in crash and unfortunately i have to stop.
Tomorrow i'll restart working on and maybe i'll fix this.
Of course if you want to save my time any help would be appreciated.
Thank you.
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Il giorno gio, 15/02/2007 alle 22.47 +0100, Vincenzo Ciaglia ha scritto:
Quoted 4 lines
# newrole -r sysadm_r Authenticating root. newrole: incorrect password for root #
Regarding to this problem i thought was a PAM problem. So i re-build the package with all the latest fedora's patch and i have created this, ready to "./configure --with-selinux":
http://www.netwosix.org/selinux/Linux-PAM-selinux-0.99.6.2.tar.gz
Here the patch applied and pre-build in that package:
http://www.netwosix.org/selinux/pam-0.99.2.1-selinux-nofail.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-drop-multiple.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-keycreate.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-select-context.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-use-current-range.patch
Moreover i adjusted some configurations in /etc/pam.d to try to do the trick. Here they are: http://www.netwosix.org/selinux/pam-seconf.tar.gz
Here the /etc/security ones:
http://www.netwosix.org/selinux/security-etc.tar.gz
And here my /lib/security/ :
http://www.netwosix.org/selinux/securitypam-selinux.tar.gz
Everything is ok but when i reboot i get this:
[vciaglia@desk ~]$ ssh -l root 192.168.0.4
[email protected]'s password:
# id -Z root:sysadm_r:sysadm_t # newrole -r sysadm_r Authenticating root. newrole: incorrect password for root # useradd -m test useradd: PAM authentication failed #
Is it still a PAM problem or i have some misconfigurations ?
Thank you in advance!
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 8 lines · Vincenzo Ciaglia
Il giorno gio, 15/02/2007 alle 22.47 +0100, Vincenzo Ciaglia ha scritto:
Quoted 4 lines
# newrole -r sysadm_r Authenticating root. newrole: incorrect password for root #Regarding to this problem i thought was a PAM problem.
Yes, IIRC, typically this indicates that your pam_unix doesn't fall back cleanly to the chkpwd helper when it cannot directly read /etc/shadow, and just fails. The original pam_unix logic was to only perform such a fallback if the caller was not uid 0, but that had to be changed for selinux since even a uid 0 process might not be allowed to directly read /etc/shadow under selinux.
Quoted 32 lines
So i re-build the
package with all the latest fedora's patch and i have created this, ready to "./configure --with-selinux":
http://www.netwosix.org/selinux/Linux-PAM-selinux-0.99.6.2.tar.gzHere the patch applied and pre-build in that package:
http://www.netwosix.org/selinux/pam-0.99.2.1-selinux-nofail.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-drop-multiple.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-keycreate.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-select-context.patch
http://www.netwosix.org/selinux/pam-0.99.6.2-selinux-use-current-range.patchMoreover i adjusted some configurations in
/etc/pam.dto try to do the trick. Here they are: http://www.netwosix.org/selinux/pam-seconf.tar.gz
Here the/etc/securityones:
http://www.netwosix.org/selinux/security-etc.tar.gz
And here my/lib/security/:
http://www.netwosix.org/selinux/securitypam-selinux.tar.gzEverything is ok but when i reboot i get this:
[vciaglia@desk ~]$ ssh -l root 192.168.0.4
[email protected]'s password:# id -Z root:sysadm_r:sysadm_t # newrole -r sysadm_r Authenticating root. newrole: incorrect password for root # useradd -m test useradd: PAM authentication failed #
Quoted 1 line
Is it still a PAM problem or i have some misconfigurations ?
Likely an issue with your pam, but I haven't looked at your packages yet.
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.
Il giorno ven, 16/02/2007 alle 10.13 -0500, Stephen Smalley ha scritto:
Quoted 2 lines
Likely an issue with your pam, but I haven't looked at your packages yet.
Could be a policycoreutils problem too?
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 6 lines · Vincenzo Ciaglia
Il giorno ven, 16/02/2007 alle 10.13 -0500, Stephen Smalley ha scritto:
Quoted 2 lines
Likely an issue with your pam, but I haven't looked at your packages yet.
Could be a policycoreutils problem too?
If it were only newrole failing, then yes. But you showed useradd failing too, which isn't provided or affected by policycoreutils.
Note however that you do need to build newrole on a system with pam-devel or equivalent installed, as the Makefile looks for /usr/include/security/pam_appl.h and disables PAM support if it isn't present.
And if you want audit and/or namespace support, you need to build newrole with the appropriate options.
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.
Il giorno ven, 16/02/2007 alle 12.04 -0500, Stephen Smalley ha scritto:
Quoted 4 lines
Note however that you do need to build newrole on a system with pam-devel or equivalent installed, as the
Makefilelooks for/usr/include/security/pam_appl.hand disables PAM support if it isn't present.
Done! I just recompiled the policycoreutils after i rebuilt shadow and pam and:
# id -Z root:sysadm_r:sysadm_t # newrole -r sysadm_r Authenticating root. Password: # id -Z root:sysadm_r:sysadm_t
Can i assign to the user "root" the staff_r:staff_t, so i can force him to "newrole -r sysadm_r" to make something on the system? Do i have to edit the "$policy/users/local.users" ?
Unfortunately i still have to solve some problem with pam here:
# useradd -m test useradd: PAM authentication failed
Just going crazy, today :)
Thank you!
Signature · 8 lines
Vincenzo Ciaglia, <vin(at)netwosix(dot)org> Linux Netwosix, <http://www.netwosix.org> -- 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.
Quoted 10 lines · Vincenzo Ciaglia
Il giorno ven, 16/02/2007 alle 12.04 -0500, Stephen Smalley ha scritto:
Quoted 4 lines
Note however that you do need to build newrole on a system with pam-devel or equivalent installed, as the
Makefilelooks for/usr/include/security/pam_appl.hand disables PAM support if it isn't present.Done! I just recompiled the policycoreutils after i rebuilt shadow and pam and:
Quoted 7 lines
# id -Z root:sysadm_r:sysadm_t # newrole -r sysadm_r Authenticating root. Password: # id -Z root:sysadm_r:sysadm_t
Not too exciting since you were already in sysadm_r to start with.
Quoted 3 lines
Can i assign to the user "root" the staff_r:staff_t, so i can force him to "newrole -r
sysadm_r" to make something on the system? Do i have to edit the "$policy/users/local.users" ?
If in enforcing mode and the ssh_sysadm_login boolean is off, this should already be the case for ssh logins. You can also adjust the ordering in $policy/contexts/users/root (root-specific) or $policy/contexts/default_contexts (system-wide defaults). First field of each line is the context of the daemon process (e.g. sshd), remainder of the line is a list of partial contexts in the preferred ordering of selection.
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.