star/star-1.5-selinux.patch

269 lines
9.2 KiB
Diff

--- star-1.5/conf/configure.in.selinux 2006-02-07 11:23:13.000000000 -0500
+++ star-1.5/conf/configure.in 2006-02-22 10:11:28.000000000 -0500
@@ -357,6 +357,15 @@
echo no
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
@@ -373,5 +382,6 @@
AC_SUBST(lib_acl_test)
AC_SUBST(lib_attr)
AC_SUBST(lib_secdb)
+AC_SUBST(lib_selinux)
AC_OUTPUT(rules.cnf)
--- star-1.5/conf/rules.cnf.in.selinux 2005-12-20 06:41:02.000000000 -0500
+++ star-1.5/conf/rules.cnf.in 2006-02-22 10:12:56.000000000 -0500
@@ -10,3 +10,5 @@
LIB_ACL_TEST= @lib_acl_test@
LIB_ATTR = @lib_attr@
LIB_SECDB = @lib_secdb@
+LIB_SELINUX = @lib_selinux@
+
--- star-1.5/star/pax.mk.selinux 2006-02-02 10:00:31.000000000 -0500
+++ star-1.5/star/pax.mk 2006-02-22 10:10:09.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 2006-02-22 10:10:09.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 2006-02-22 10:10:09.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 2006-02-22 10:10:09.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 2006-02-18 14:09:39.000000000 -0500
+++ star-1.5/star/star.c 2006-02-22 10:10:09.000000000 -0500
@@ -42,6 +42,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));
@@ -375,6 +379,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-13 08:57:21.000000000 -0500
+++ star-1.5/star/extract.c 2006-02-22 10:14:45.000000000 -0500
@@ -224,6 +224,17 @@
continue;
}
#endif
+
+#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 2006-02-02 10:01:18.000000000 -0500
+++ star-1.5/star/cpio.mk 2006-02-22 10:10:09.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 2006-02-02 10:00:31.000000000 -0500
+++ star-1.5/star/gnutar.mk 2006-02-22 10:10:09.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 2006-02-02 10:00:31.000000000 -0500
+++ star-1.5/star/suntar.mk 2006-02-22 10:10:09.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 2006-02-22 10:10:09.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 <selinux/selinux.h>
+extern BOOL setselinux __PR((register FINFO *info));
+extern int selinux_enabled;
+#endif
#endif
/*
--- star-1.5/star/xattr.c.selinux 2006-02-13 20:00:40.000000000 -0500
+++ star-1.5/star/xattr.c 2006-02-22 10:16:44.000000000 -0500
@@ -181,6 +181,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)
@@ -194,6 +217,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 (lsetxattr(info->f_name, xap->name, xap->value,
xap->value_len, 0) != 0) {
if (!errhidden(E_SETXATTR, info->f_name)) {