--- star-1.5/conf/configure.in.selinux 2005-10-11 04:51:05.000000000 -0400 +++ star-1.5/conf/configure.in 2005-11-08 16:36:57.000000000 -0500 @@ -314,6 +314,15 @@ LIBS="$ac_save_LIBS" fi +AC_CHECK_HEADERS(selinux/selinux.h) +if test "$ac_cv_header_selinux_selinux_h" = yes; then + AC_CHECKING(for SELinux support) + AC_CHECK_LIB(selinux, is_selinux_enabled, lib_selinux="-lselinux -lattr") + ac_save_LIBS="$LIBS" + LIBS="$LIBS $lib_selinux" + AC_CHECK_FUNCS(is_selinux_enabled) +fi + dnl Checks for OS madness. AC_BROKEN_LINUX_EXT2_FS_H AC_BROKEN_SRC_LINUX_EXT2_FS_H @@ -329,5 +338,6 @@ AC_SUBST(lib_acl) AC_SUBST(lib_acl_test) AC_SUBST(lib_attr) +AC_SUBST(lib_selinux) AC_OUTPUT(rules.cnf) --- star-1.5/conf/rules.cnf.in.selinux 2004-10-07 14:32:26.000000000 -0400 +++ star-1.5/conf/rules.cnf.in 2005-11-08 16:36:57.000000000 -0500 @@ -9,3 +9,5 @@ LIB_ACL= @lib_acl@ LIB_ACL_TEST= @lib_acl_test@ LIB_ATTR = @lib_attr@ +LIB_SELINUX = @lib_selinux@ + --- star-1.5/star/pax.mk.selinux 2005-02-09 18:31:56.000000000 -0500 +++ star-1.5/star/pax.mk 2005-11-08 16:36:57.000000000 -0500 @@ -17,6 +17,7 @@ CPPOPTS += -DUSE_LARGEFILES CPPOPTS += -DUSE_ACL CPPOPTS += -DUSE_XATTR +CPPOPTS += -DWITH_SELINUX CPPOPTS += -DUSE_FFLAGS CPPOPTS += -DPAX CFILES= pax.c header.c cpiohdr.c xheader.c xattr.c \ @@ -35,7 +36,7 @@ checkerr.h dumpdate.h bitstring.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= spaxman.mk ########################################################################### --- star-1.5/star/star.mk.selinux 2005-08-28 07:22:30.000000000 -0400 +++ star-1.5/star/star.mk 2005-11-08 16:36:57.000000000 -0500 @@ -19,6 +19,7 @@ CPPOPTS += -DUSE_XATTR CPPOPTS += -DUSE_FFLAGS CPPOPTS += -DCOPY_LINKS_DELAYED +CPPOPTS += -DWITH_SELINUX CFILES= star.c header.c cpiohdr.c xheader.c xattr.c \ list.c extract.c create.c append.c diff.c restore.c \ remove.c star_unix.c acl_unix.c acltext.c fflags.c \ @@ -35,7 +36,7 @@ checkerr.h dumpdate.h bitstring.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= Makefile.man starformatman.mk ########################################################################### --- star-1.5/star/star_fat.mk.selinux 2005-11-01 15:53:51.000000000 -0500 +++ star-1.5/star/star_fat.mk 2005-11-08 16:36:57.000000000 -0500 @@ -28,6 +28,7 @@ CPPOPTS += -DUSE_FFLAGS CPPOPTS += -DCOPY_LINKS_DELAYED CPPOPTS += -DSTAR_FAT +CPPOPTS += -DWITH_SELINUX CFILES= star_fat.c header.c cpiohdr.c xheader.c xattr.c \ list.c extract.c create.c append.c diff.c restore.c \ remove.c star_unix.c acl_unix.c acltext.c fflags.c \ @@ -48,7 +49,7 @@ find.h gettnum.h fetchdir.h walk.h find_list.h mem.h find_misc.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= Makefile.man starformatman.mk scpioman.mk gnutarman.mk \ spaxman.mk suntarman.mk Makefile.dfl --- star-1.5/star/Makefile.selinux 2005-11-01 15:53:51.000000000 -0500 +++ star-1.5/star/Makefile 2005-11-08 16:36:57.000000000 -0500 @@ -25,6 +25,7 @@ CPPOPTS += -DUSE_FIND CPPOPTS += -DUSE_ACL CPPOPTS += -DUSE_XATTR +CPPOPTS += -DWITH_SELINUX CPPOPTS += -DUSE_FFLAGS CPPOPTS += -DCOPY_LINKS_DELAYED CPPOPTS += -DSTAR_FAT @@ -48,7 +49,7 @@ find.h gettnum.h fetchdir.h walk.h find_list.h mem.h find_misc.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= Makefile.man starformatman.mk scpioman.mk gnutarman.mk \ spaxman.mk suntarman.mk Makefile.dfl --- star-1.5/star/star.c.selinux 2005-11-01 17:15:05.000000000 -0500 +++ star-1.5/star/star.c 2005-11-08 16:36:57.000000000 -0500 @@ -44,6 +44,10 @@ #include "starsubs.h" #include "checkerr.h" +#ifdef WITH_SELINUX +int selinux_enabled=0; +#endif + EXPORT int main __PR((int ac, char **av)); LOCAL void star_create __PR((int ac, char *const *av)); LOCAL void checkdumptype __PR((GINFO *gp)); @@ -374,6 +378,11 @@ comerr("Panic cannot set back effective uid.\n"); } my_uid = geteuid(); + +#ifdef WITH_SELINUX + selinux_enabled=is_selinux_enabled()>0; +#endif + /* * WARNING: We now are no more able to open a new remote connection * unless we have been called by root. --- star-1.5/star/extract.c.selinux 2005-11-08 16:35:01.000000000 -0500 +++ star-1.5/star/extract.c 2005-11-08 16:41:18.000000000 -0500 @@ -213,6 +213,16 @@ if (prblockno) (void) tblocks(); /* set curblockno */ +#ifdef WITH_SELINUX + if (!to_stdout && selinux_enabled) { + if (setselinux(&finfo) == FALSE) { + errmsgno(EX_BAD, + "Can not setup security context for '%s'. Not created.\n", + finfo.f_name); + } + } +#endif + if (finfo.f_flags & F_BAD_META) { if (!void_bad(&finfo)) break; --- star-1.5/star/cpio.mk.selinux 2005-02-09 18:31:56.000000000 -0500 +++ star-1.5/star/cpio.mk 2005-11-08 16:36:57.000000000 -0500 @@ -18,6 +18,7 @@ CPPOPTS += -DUSE_ACL CPPOPTS += -DUSE_XATTR CPPOPTS += -DUSE_FFLAGS +CPPOPTS += -DWITH_SELINUX CFILES= cpio.c header.c cpiohdr.c xheader.c xattr.c \ list.c extract.c create.c append.c diff.c restore.c \ remove.c star_unix.c acl_unix.c acltext.c fflags.c \ @@ -34,7 +35,7 @@ checkerr.h dumpdate.h bitstring.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= scpioman.mk ########################################################################### --- star-1.5/star/gnutar.mk.selinux 2005-02-09 18:31:56.000000000 -0500 +++ star-1.5/star/gnutar.mk 2005-11-08 16:36:57.000000000 -0500 @@ -18,6 +18,7 @@ CPPOPTS += -DUSE_ACL CPPOPTS += -DUSE_XATTR CPPOPTS += -DUSE_FFLAGS +CPPOPTS += -DWITH_SELINUX CFILES= gnutar.c header.c cpiohdr.c xheader.c xattr.c \ list.c extract.c create.c append.c diff.c restore.c \ remove.c star_unix.c acl_unix.c acltext.c fflags.c \ @@ -34,7 +35,7 @@ checkerr.h dumpdate.h bitstring.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= gnutarman.mk ########################################################################### --- star-1.5/star/suntar.mk.selinux 2005-02-09 18:31:56.000000000 -0500 +++ star-1.5/star/suntar.mk 2005-11-08 16:36:57.000000000 -0500 @@ -18,6 +18,7 @@ CPPOPTS += -DUSE_ACL CPPOPTS += -DUSE_XATTR CPPOPTS += -DUSE_FFLAGS +CPPOPTS += -DWITH_SELINUX CFILES= suntar.c header.c cpiohdr.c xheader.c xattr.c \ list.c extract.c create.c append.c diff.c restore.c \ remove.c star_unix.c acl_unix.c acltext.c fflags.c \ @@ -34,7 +35,7 @@ checkerr.h dumpdate.h bitstring.h #LIBS= -lunos #LIBS= -lschily -lc /usr/local/lib/gcc-gnulib -LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) +LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX) XMK_FILE= suntarman.mk ########################################################################### --- star-1.5/star/starsubs.h.selinux 2005-11-01 16:32:18.000000000 -0500 +++ star-1.5/star/starsubs.h 2005-11-08 16:36:57.000000000 -0500 @@ -301,6 +301,11 @@ extern BOOL get_xattr __PR((register FINFO *info)); extern BOOL set_xattr __PR((register FINFO *info)); extern void free_xattr __PR((star_xattr_t **xattr)); +#ifdef WITH_SELINUX +#include +extern BOOL setselinux __PR((register FINFO *info)); +extern int selinux_enabled; +#endif #endif /* --- star-1.5/star/xattr.c.selinux 2005-09-02 18:29:35.000000000 -0400 +++ star-1.5/star/xattr.c 2005-11-08 16:36:57.000000000 -0500 @@ -169,6 +169,29 @@ #endif /* USE_XATTR */ } + +#ifdef WITH_SELINUX +EXPORT BOOL +setselinux(info) + register FINFO *info; +{ +#if defined(USE_XATTR) && defined(HAVE_SETXATTR) && defined(WITH_SELINUX) + if (info->f_xattr) { + star_xattr_t *xap; + for (xap = info->f_xattr; xap->name != NULL; xap++) { + if (strcmp(xap->name, "security.selinux") == 0) { + if (setfscreatecon(xap->value)) { + return FALSE; + } + } + } + } +#endif /* USE_XATTR && WITH_SELINUX */ + return TRUE; +} +#endif + + /* ARGSUSED */ EXPORT BOOL set_xattr(info) @@ -181,6 +204,10 @@ return (TRUE); for (xap = info->f_xattr; xap->name != NULL; xap++) { +#ifdef WITH_SELINUX + if (selinux_enabled && (strcmp(xap->name, "security.selinux") == 0)) + continue; +#endif if (setxattr(info->f_name, xap->name, xap->value, xap->value_len, 0) != 0) { if (!errhidden(E_SETXATTR, info->f_name)) {