Skip to contentSkip to conversation

Fix omissions in SELinux-patched fileutils

PATCH New Stephen Smalley 1 participant 1 message Oct 4, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix omissions in SELinux-patched fileutils

The attached patch, also committed to the sourceforge CVS tree, fixes some omissions in the SELinux-patched fileutils. To apply, cd selinux && patch -p1 < ~/fileutils.patch. Then rebuild your fileutils. 'make check' should then pass all tests.

--
Stephen D. Smalley, NAI Labs
[email protected]

Index: selinux/utils/fileutils-4.1/src/copy.c
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux/utils/fileutils-4.1/src/copy.c,v retrieving revision 1.1.1.1

utils/fileutils-4.1/src/copy.c +20 -0
diff -u -r1.1.1.1 copy.c
@@ -145,7 +145,11 @@
   /* For cp's -H option, dereference command line arguments, but do not
      dereference symlinks that are found via recursive traversal.  */
   if (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS)
+#ifdef FLASK_LINUX
+    non_command_line_options.xstat = lstat_secure;
+#else
     non_command_line_options.xstat = lstat;
+#endif
 
   namep = name_space;
   while (*namep != '\0')
@@ -424,7 +428,11 @@
       return 1;
     }
 
+#ifdef FLASK_LINUX
+  if (x->xstat == lstat_secure)
+#else
   if (x->xstat == lstat)
+#endif
     {
       same_link = same;
 
@@ -523,7 +531,11 @@
       && S_ISLNK (dst_sb_link->st_mode))
     return dst_sb_link->st_dev == src_sb_link->st_dev;
 
+#ifdef FLASK_LINUX
+  if (x->xstat == lstat_secure)
+#else
   if (x->xstat == lstat)
+#endif
     {
       if ( ! S_ISLNK (src_sb_link->st_mode))
 	tmp_src_sb = *src_sb_link;
@@ -761,7 +773,11 @@
 	    }
 	  else if (! S_ISDIR (dst_sb.st_mode)
 		   && (x->unlink_dest_before_opening
+#ifdef FLASK_LINUX
+		       || (x->xstat == lstat_secure
+#else
 		       || (x->xstat == lstat
+#endif
 			   && ! S_ISREG (src_sb.st_mode))))
 	    {
 	      if (unlink (dst_path) && errno != ENOENT)
@@ -1302,7 +1318,11 @@
 
   /* FIXME: for some reason this assertion always fails,
      at least on Solaris2.5.1.  Just disable it for now.  */
+#ifdef FLASK_LINUX
+  /* assert (co->xstat == lstat_secure || co->xstat == stat_secure); */
+#else
   /* assert (co->xstat == lstat || co->xstat == stat); */
+#endif
 
   /* Make sure xstat and dereference are consistent.  */
   /* FIXME */

Index: selinux/utils/fileutils-4.1/src/mv.c
===================================================================
RCS file: /cvsroot/selinux/nsa/selinux/utils/fileutils-4.1/src/mv.c,v retrieving revision 1.1.1.1

utils/fileutils-4.1/src/mv.c +9 -0
diff -u -r1.1.1.1 mv.c
@@ -27,6 +27,10 @@
 #include <sys/types.h>
 #include <assert.h>
 
+#ifdef FLASK_LINUX
+#include <fs_secure.h>
+#endif
+
 #include "system.h"
 #include "backupfile.h"
 #include "copy.h"
@@ -131,7 +135,12 @@
 
   x->update = 0;
   x->verbose = 0;
+#ifdef FLASK_LINUX
+  x->xstat = lstat_secure;
+  x->preserve_security_context = 0;
+#else
   x->xstat = lstat;
+#endif
 }
 
 /* If PATH is an existing directory, return nonzero, else 0.  */