star/star-1.5-selinux.patch

173 lines
5.3 KiB
Diff
Raw Normal View History

2005-08-15 12:21:48 +00:00
--- star-1.5/star/pax.mk.selinux 2005-08-12 11:06:56.000000000 +0200
+++ star-1.5/star/pax.mk 2005-08-12 11:07:46.000000000 +0200
2004-11-22 14:57:57 +00:00
@@ -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)
2005-08-15 12:21:48 +00:00
+LIBS= -ldeflt -lrmt -lschily $(LIB_ACL) $(LIB_ATTR) $(LIB_SOCKET) $(LIB_SELINUX)
2004-11-22 14:57:57 +00:00
XMK_FILE= spaxman.mk
###########################################################################
2005-08-15 12:21:48 +00:00
--- star-1.5/star/Makefile.selinux 2005-08-12 11:08:26.000000000 +0200
+++ star-1.5/star/Makefile 2005-08-12 11:09:13.000000000 +0200
@@ -24,6 +24,7 @@
2004-11-22 14:57:57 +00:00
CPPOPTS += -DUSE_LARGEFILES
CPPOPTS += -DUSE_ACL
CPPOPTS += -DUSE_XATTR
+CPPOPTS += -DWITH_SELINUX
CPPOPTS += -DUSE_FFLAGS
CPPOPTS += -DCOPY_LINKS_DELAYED
2005-08-15 12:21:48 +00:00
CPPOPTS += -DSTAR_FAT
@@ -43,7 +44,7 @@
2004-11-22 14:57:57 +00:00
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)
2005-08-15 12:21:48 +00:00
+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
2004-11-22 14:57:57 +00:00
2005-08-15 12:21:48 +00:00
--- star-1.5/star/star.c.selinux 2005-08-12 11:09:41.000000000 +0200
+++ star-1.5/star/star.c 2005-08-12 11:12:28.000000000 +0200
@@ -40,6 +40,10 @@
2004-11-22 14:57:57 +00:00
#endif
#include "dumpdate.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));
2005-08-15 12:21:48 +00:00
@@ -358,6 +362,11 @@
2004-11-22 14:57:57 +00:00
comerr("Panic cannot set back effective uid.\n");
}
2005-08-15 12:21:48 +00:00
my_uid = geteuid();
+
2004-11-22 14:57:57 +00:00
+#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.
2005-08-15 12:21:48 +00:00
--- star-1.5/star/extract.c.selinux 2005-08-12 11:12:39.000000000 +0200
+++ star-1.5/star/extract.c 2005-08-12 11:15:17.000000000 +0200
@@ -209,6 +209,16 @@
2004-11-22 14:57:57 +00:00
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
2005-08-15 12:21:48 +00:00
+
if (finfo.f_xflags & XF_BAD_META) {
if (!void_bad(&finfo))
break;
--- star-1.5/star/starsubs.h.selinux 2005-08-12 11:15:44.000000000 +0200
+++ star-1.5/star/starsubs.h 2005-08-12 11:16:46.000000000 +0200
@@ -293,6 +293,11 @@
2004-11-22 14:57:57 +00:00
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
/*
2005-08-15 12:21:48 +00:00
--- star-1.5/star/xattr.c.selinux 2005-08-12 11:17:12.000000000 +0200
+++ star-1.5/star/xattr.c 2005-08-12 11:21:01.000000000 +0200
@@ -159,6 +159,29 @@
2004-11-22 14:57:57 +00:00
#endif /* USE_XATTR */
}
2005-08-15 12:21:48 +00:00
+
2004-11-22 14:57:57 +00:00
+#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
2005-08-15 12:21:48 +00:00
+
2004-11-22 14:57:57 +00:00
+
/* ARGSUSED */
EXPORT BOOL
set_xattr(info)
2005-08-15 12:21:48 +00:00
@@ -171,6 +194,10 @@
2004-11-22 14:57:57 +00:00
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)) {
2005-08-15 12:21:48 +00:00
--- star-1.5/conf/configure.in.selinux 2005-08-12 11:04:08.000000000 +0200
+++ star-1.5/conf/configure.in 2005-08-12 11:05:22.000000000 +0200
@@ -312,6 +312,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
@@ -327,5 +336,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 2005-08-12 11:05:53.000000000 +0200
+++ star-1.5/conf/rules.cnf.in 2005-08-12 11:06:12.000000000 +0200
@@ -9,3 +9,5 @@
LIB_ACL= @lib_acl@
LIB_ACL_TEST= @lib_acl_test@
LIB_ATTR = @lib_attr@
+LIB_SELINUX = @lib_selinux@
+