udev: cleanup selinux integration
Hi Harald,
could you please verify that the selinux build still works in your environment. I've changed the way it is integrated into udev.
It has it's own .c-file instead of the big inline header and the kernel name is passed down to find the ide media in /proc without assuming that the node name is equal to the kernel name.
Thanks,
Kay
Makefile +6 -1
@@ -203,7 +203,7 @@ udev_db.h \ udev_sysfs.h \ logging.h \ - selinux.h \ + udev_selinux.h \ list.h SYSFS_OBJS = \
@@ -243,6 +243,11 @@ klibc_fixups/klibc_fixups.o OBJS += klibc_fixups/klibc_fixups.a +endif + +ifeq ($(strip $(USE_SELINUX)),true) + UDEV_OBJS += udev_selinux.o + LIB_OBJS += -lselinux endif ifeq ($(strip $(V)),false)
selinux.h deleted +0 -148
148 lines not on this page · raw message
udev_add.c +7 -8
@@ -43,8 +43,7 @@#include "logging.h" #include "namedev.h" #include "udev_db.h" - -#include "selinux.h" +#include "udev_selinux.h" /* * the major/minor of a device is stored in a file called "dev"
@@ -68,7 +67,7 @@return -1 ; } -static int make_node (char *file,int major,int minor,unsigned int mode,uid_t uid,gid_t gid) +static int make_node (struct udevice *udev,char *file,int major,int minor,unsigned int mode,uid_t uid,gid_t gid) {struct stat stats;int retval =0 ;
@@ -80,7 +79,7 @@if (((stats.st_mode &S_IFMT ) ==S_IFBLK || (stats.st_mode &S_IFMT ) ==S_IFCHR ) && (stats.st_rdev ==makedev (major, minor))) {dbg ("preserve file '%s', cause it has correct dev_t" , file); -selinux_setfilecon (file,stats.st_mode); +selinux_setfilecon (file, udev->kernel_name, stats.st_mode); goto perms; }
@@ -90,7 +89,7 @@dbg ("already present file '%s' unlinked" , file); create: -selinux_setfscreatecon (file, mode); +selinux_setfscreatecon (file, udev->kernel_name, mode); retval =mknod (file, mode,makedev (major, minor));if (retval !=0 ) { dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
@@ -184,7 +183,7 @@if (!udev->test_run) {info ("creating device node '%s'" , filename); -if (make_node (filename, udev->major, udev->minor, udev->mode, uid, gid) !=0 ) +if (make_node (udev, filename, udev->major, udev->minor, udev->mode, uid, gid) !=0 ) goto error; }else { info("creating device node '%s', major = '%d', minor = '%d', "
@@ -199,7 +198,7 @@for (i =1 ; i <= udev->partitions; i++) {strfieldcpy (partitionname, filename);strintcat (partitionname, i); -make_node (partitionname, udev->major, udev->minor + i, udev->mode, uid, gid); +make_node (udev, partitionname, udev->major, udev->minor + i, udev->mode, uid, gid); } } }
@@ -237,7 +236,7 @@dbg ("symlink(%s, %s)" , linktarget, filename);if (!udev->test_run) { -selinux_setfscreatecon (filename,S_IFLNK ); +selinux_setfscreatecon (filename, udev->kernel_name,S_IFLNK );unlink (filename);if (symlink (linktarget, filename) !=0 ) dbg("symlink(%s, %s) failed with error '%s'",
udev_selinux.h new file +148 -0
148 lines not on this page · raw message
Quoted 7 lines · Kay Sievers
Hi Harald,
could you please verify that the selinux build still works in your environment. I've changed the way it is integrated into udev.It has it's own .c-file instead of the big inline header and the kernel name is passed down to find the ide media in /proc without assuming that the node name is equal to the kernel name.
Sorry, one file was missing in the patch.
Thanks,
Kay
Makefile +6 -1
@@ -203,7 +203,7 @@ udev_db.h \ udev_sysfs.h \ logging.h \ - selinux.h \ + udev_selinux.h \ list.h SYSFS_OBJS = \
@@ -243,6 +243,11 @@ klibc_fixups/klibc_fixups.o OBJS += klibc_fixups/klibc_fixups.a +endif + +ifeq ($(strip $(USE_SELINUX)),true) + UDEV_OBJS += udev_selinux.o + LIB_OBJS += -lselinux endif ifeq ($(strip $(V)),false)
selinux.h deleted +0 -148
148 lines not on this page · raw message
udev_add.c +7 -8
@@ -43,8 +43,7 @@#include "logging.h" #include "namedev.h" #include "udev_db.h" - -#include "selinux.h" +#include "udev_selinux.h" /* * the major/minor of a device is stored in a file called "dev"
@@ -68,7 +67,7 @@return -1 ; } -static int make_node (char *file,int major,int minor,unsigned int mode,uid_t uid,gid_t gid) +static int make_node (struct udevice *udev,char *file,int major,int minor,unsigned int mode,uid_t uid,gid_t gid) {struct stat stats;int retval =0 ;
@@ -80,7 +79,7 @@if (((stats.st_mode &S_IFMT ) ==S_IFBLK || (stats.st_mode &S_IFMT ) ==S_IFCHR ) && (stats.st_rdev ==makedev (major, minor))) {dbg ("preserve file '%s', cause it has correct dev_t" , file); -selinux_setfilecon (file,stats.st_mode); +selinux_setfilecon (file, udev->kernel_name, stats.st_mode); goto perms; }
@@ -90,7 +89,7 @@dbg ("already present file '%s' unlinked" , file); create: -selinux_setfscreatecon (file, mode); +selinux_setfscreatecon (file, udev->kernel_name, mode); retval =mknod (file, mode,makedev (major, minor));if (retval !=0 ) { dbg("mknod(%s, %#o, %u, %u) failed with error '%s'",
@@ -184,7 +183,7 @@if (!udev->test_run) {info ("creating device node '%s'" , filename); -if (make_node (filename, udev->major, udev->minor, udev->mode, uid, gid) !=0 ) +if (make_node (udev, filename, udev->major, udev->minor, udev->mode, uid, gid) !=0 ) goto error; }else { info("creating device node '%s', major = '%d', minor = '%d', "
@@ -199,7 +198,7 @@for (i =1 ; i <= udev->partitions; i++) {strfieldcpy (partitionname, filename);strintcat (partitionname, i); -make_node (partitionname, udev->major, udev->minor + i, udev->mode, uid, gid); +make_node (udev, partitionname, udev->major, udev->minor + i, udev->mode, uid, gid); } } }
@@ -237,7 +236,7 @@dbg ("symlink(%s, %s)" , linktarget, filename);if (!udev->test_run) { -selinux_setfscreatecon (filename,S_IFLNK ); +selinux_setfscreatecon (filename, udev->kernel_name,S_IFLNK );unlink (filename);if (symlink (linktarget, filename) !=0 ) dbg("symlink(%s, %s) failed with error '%s'",
udev_selinux.c new file +166 -0
166 lines not on this page · raw message
udev_selinux.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* udev_selinux.h +* +* Copyright (C) 2004 Daniel Walsh +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation version 2 of the License. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., +* 675 Mass Ave, Cambridge, MA 02139, USA. +* +*/ +#ifndef _UDEV_SELINUX_H +#define _UDEV_SELINUX_H + +#ifdef USE_SELINUX + +extern void selinux_setfilecon (const char *file,const char *devname,unsigned int mode); +extern void selinux_setfscreatecon (const char *file,const char *devname,unsigned int mode); +extern void selinux_init (void ); +extern void selinux_restore (void ); + +#else + +static inline void selinux_setfilecon (const char *file,const char *devname,unsigned int mode) {} +static inline void selinux_setfscreatecon (const char *file,const char *devname,unsigned int mode) {} +static inline void selinux_init (void ) {} +static inline void selinux_restore (void ) {} + +#endif /* USE_SELINUX */ +#endif /* _UDEV_USE_SELINUX */