Information about selinuxfs
Helo.
A information about the selinuxfs filesystem.
The directory name and the path to mount o selinuxfs must be alway /selinux.
A change on this name (/selinux) only affect the sysvinit and initrd, what set the directory name and path, or it will cause others problems ?
Many thanks.
Signature · 10 lines
Carlos Anisio Monteiro <[email protected]> IPEN/CNEN-SP Sao Paulo - Brasil -- 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 · Carlos Anísio Monteiro
Helo.
A information about the selinuxfs filesystem.
The directory name and the path to mount o selinuxfs must be alway /selinux. A change on this name (/selinux) only affect the sysvinit and initrd, what set the directory name and path, or it will cause others problems ?
libselinux expects selinuxfs to be mounted on /selinux for the various security_* calls. However, someone recently suggested that we change libselinux to discover the selinuxfs mount point at runtime from /proc/mounts, which would allow you to change the mount point without requiring a patch and rebuild for libselinux.
There have been suggestions to move the selinuxfs mount point from /selinux to somewhere else, e.g. /security/selinux, but no final decision yet.
Signature · 8 lines
Stephen Smalley <[email protected]> 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.
PATCH 1/1 Change libselinux to discover selinuxfs mount point via /proc/mounts (Was: Re: Information about selinuxfs)
Quoted 5 lines · Stephen Smalley
libselinux expects selinuxfs to be mounted on /selinux for the various security_* calls. However, someone recently suggested that we change libselinux to discover the selinuxfs mount point at runtime from
/proc/mounts, which would allow you to change the mount point without requiring a patch and rebuild for libselinux.
The attached patch makes the change described above to libselinux. A constructor function determines the selinuxfs mount point from /proc/mounts during initialization, and this mount point directory is then used by the libselinux functions. This eliminates the need to rebuild libselinux in the future if the mount point changes.
libselinux/src/check_context.c | 6 +++ libselinux/src/compute_av.c | 5 ++- libselinux/src/compute_create.c | 5 ++- libselinux/src/compute_relabel.c | 5 ++- libselinux/src/compute_user.c | 5 ++- libselinux/src/getenforce.c | 5 ++- libselinux/src/init.c | 62 +++++++++++++++++++++++++++++++++++++++ libselinux/src/load_policy.c | 6 +++ libselinux/src/policy.h | 3 + libselinux/src/policyvers.c | 5 ++- libselinux/src/setenforce.c | 5 ++- 11 files changed, 103 insertions(+), 9 deletions(-)
Signature · 2 lines
Stephen Smalley <[email protected]> National Security Agency
Index: selinux-usr/libselinux/src/check_context.c
libselinux/src/check_context.c renamed from libselinux/src/check_context.c:1.2 +5 -1
@@ -4,14 +4,18 @@#include <stdlib.h> #include <errno.h> #include <string.h> +#include <stdio.h> #include <selinux/selinux.h> #include "policy.h" +#include <limits.h> int security_check_context (security_context_t con) { +char path[PATH_MAX ];int fd, ret; - fd =open (SELINUXMNT "context" ,O_RDWR ); +snprintf (path,sizeof path,"%s/context" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/compute_av.c
libselinux/src/compute_av.c renamed from libselinux/src/compute_av.c:1.5 +4 -1
@@ -8,6 +8,7 @@#include <asm/page.h> #include <selinux/selinux.h> #include "policy.h" +#include <limits.h> int security_compute_av(security_context_t scon, security_context_t tcon,
@@ -15,11 +16,13 @@access_vector_t requested, struct av_decision *avd) { + char path[PATH_MAX];char *buf;size_t len;int fd, ret; - fd =open (SELINUXMNT "access" ,O_RDWR ); +snprintf (path,sizeof path,"%s/access" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/compute_create.c
libselinux/src/compute_create.c renamed from libselinux/src/compute_create.c:1.7 +4 -1
@@ -8,17 +8,20 @@#include <asm/page.h> #include <selinux/selinux.h> #include "policy.h" +#include <limits.h> int security_compute_create (security_context_t scon,security_context_t tcon,security_class_t tclass,security_context_t *newcon) { +char path[PATH_MAX ];char *buf;size_t size;int fd, ret; - fd =open (SELINUXMNT "create" ,O_RDWR ); +snprintf (path,sizeof path,"%s/create" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/compute_relabel.c
libselinux/src/compute_relabel.c renamed from libselinux/src/compute_relabel.c:1.7 +4 -1
@@ -8,17 +8,20 @@#include <asm/page.h> #include <selinux/selinux.h> #include "policy.h" +#include <limits.h> int security_compute_relabel (security_context_t scon,security_context_t tcon,security_class_t tclass,security_context_t *newcon) { +char path[PATH_MAX ];char *buf;size_t size;int fd, ret; - fd =open (SELINUXMNT "relabel" ,O_RDWR ); +snprintf (path,sizeof path,"%s/relabel" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/compute_user.c
libselinux/src/compute_user.c renamed from libselinux/src/compute_user.c:1.5 +4 -1
@@ -8,18 +8,21 @@#include <asm/page.h> #include <selinux/selinux.h> #include "policy.h" +#include <limits.h> int security_compute_user (security_context_t scon,const char *user,security_context_t **con) { +char path[PATH_MAX ];char **ary;char *buf, *ptr;size_t size;int fd, ret;unsigned int i, nel; - fd =open (SELINUXMNT "user" ,O_RDWR ); +snprintf (path,sizeof path,"%s/user" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/getenforce.c
libselinux/src/getenforce.c renamed from libselinux/src/getenforce.c:1.1 +4 -1
@@ -7,13 +7,16 @@#include <selinux/selinux.h> #include "policy.h" #include <stdio.h> +#include <limits.h> int security_getenforce (void ) {int fd, ret, enforce =0 ; +char path[PATH_MAX ];char buf[20 ]; - fd =open (SELINUXMNT "enforce" ,O_RDONLY ); +snprintf (path,sizeof path,"%s/enforce" , selinux_mnt); + fd =open (path,O_RDONLY );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/init.c
libselinux/src/init.c new file +62 -0
62 lines not on this page · raw message
Index: selinux-usr/libselinux/src/load_policy.c
libselinux/src/load_policy.c renamed from libselinux/src/load_policy.c:1.2 +5 -1
@@ -2,15 +2,19 @@#include <sys/types.h> #include <fcntl.h> #include <stdlib.h> +#include <stdio.h> #include <errno.h> #include <selinux/selinux.h> #include "policy.h" +#include <limits.h> int security_load_policy (void *data,size_t len) { +char path[PATH_MAX ];int fd, ret; - fd =open (SELINUXMNT "load" ,O_RDWR ); +snprintf (path,sizeof path,"%s/load" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Index: selinux-usr/libselinux/src/policy.h
libselinux/src/policy.h renamed from libselinux/src/policy.h:1.4 +3 -0
@@ -9,6 +9,9 @@/* Initial length guess for getting contexts. */ #define INITCONTEXTLEN 255 +/* selinuxfs mount point */ +extern char *selinux_mnt; +#endif
Index: selinux-usr/libselinux/src/policyvers.c
libselinux/src/policyvers.c renamed from libselinux/src/policyvers.c:1.1 +4 -1
@@ -7,16 +7,19 @@#include <selinux/selinux.h> #include <stdio.h> #include "policy.h" +#include <limits.h> #define DEFAULT_POLICY_VERSION 15int security_policyvers (void ) {int fd, ret; +char path[PATH_MAX ];char buf[20 ];unsigned vers =DEFAULT_POLICY_VERSION ; - fd =open (SELINUXMNT "policyvers" ,O_RDONLY ); +snprintf (path,sizeof path,"%s/policyvers" , selinux_mnt); + fd =open (path,O_RDONLY );if (fd <0 )return vers;memset (buf,0 ,sizeof buf);
Index: selinux-usr/libselinux/src/setenforce.c
libselinux/src/setenforce.c renamed from libselinux/src/setenforce.c:1.1 +4 -1
@@ -7,13 +7,16 @@#include <selinux/selinux.h> #include "policy.h" #include <stdio.h> +#include <limits.h> int security_setenforce (int value) {int fd, ret; +char path[PATH_MAX ];char buf[20 ]; - fd =open (SELINUXMNT "enforce" ,O_RDWR ); +snprintf (path,sizeof path,"%s/enforce" , selinux_mnt); + fd =open (path,O_RDWR );if (fd <0 )return -1 ;
Re: [patch] Change libselinux to discover selinuxfs mount point via /proc/mounts (Was: Re: Information about selinuxfs)
Quoted 5 lines · Stephen Smalley
The attached patch makes the change described above to libselinux. A constructor function determines the selinuxfs mount point from
/proc/mountsduring initialization, and this mount point directory is then used by the libselinux functions. This eliminates the need to rebuild libselinux in the future if the mount point changes.
Dan Walsh pointed out that this patch to libselinux breaks the SELinux-patched /sbin/init program, because:
a) when the init_selinuxmnt() constructor runs for /sbin/init, selinuxfs has not yet been mounted, so selinux_mnt cannot be determined,
b) even if init_selinuxmnt() were explicitly called by /sbin/init after performing the mount, it still cannot obtain the information from /proc/mounts because /proc is not mounted yet.
An updated sysvinit-selinux.patch is attached; this patch causes /sbin/init to explicitly set selinux_mnt to avoid this problem. Dan has updated RPMs on his page (under ftp://people.redhat.com/dwalsh/SELinux).
Signature · 2 lines
Stephen Smalley <[email protected]> National Security Agency
src/Makefile renamed from src/Makefile.selinux +2 -2
@@ -32,7 +32,7 @@ all: $(PROGS) init: init.o init_utmp.o - $(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o + $(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o -lselinux halt: halt.o ifdown.o hddown.o utmp.o reboot.h $(CC) $(LDFLAGS) -o $@ halt.o ifdown.o hddown.o utmp.o
@@ -62,7 +62,7 @@ $(CC) $(LDFLAGS) -o $@ bootlogd.o init.o: init.c init.h set.h reboot.h - $(CC) -c $(CFLAGS) init.c + $(CC) -c $(CFLAGS) -DWITH_SELINUX init.c utmp.o: utmp.c init.h $(CC) -c $(CFLAGS) utmp.c
src/init.c renamed from src/init.c.selinux +89 -0
101 lines not on this page · raw message
Quoted 5 lines · Carlos Anísio Monteiro
A information about the selinuxfs filesystem.
The directory name and the path to mount o selinuxfs must be alway /selinux. A change on this name (/selinux) only affect the sysvinit and initrd, what set the directory name and path, or it will cause others problems ?
Every program that wants to verify the validity of a security context, load new security policy, check the version of the policy, or do almost any other operation that involves SE Linux will depend on the path. So changing the mount point will require recompiling libselinux.
There has been some discussion about this, but so far no decision has been made.
Why do you want to change it and where do you think would be the best place?
Signature · 11 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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.