Skip to contentSkip to conversation

runcon/chcon patch

PATCH Russell Coker 1 participant 1 message Oct 19, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

The attached patch has the changes needed to chcon.c and runcon.c to compile with the latest coreutils (5.0.91).

The latest coreutils does many more tests on utility programs and is much more fussy about return codes. So programs that return the wrong values in some situations or which make the wrong choices about whether to write to stdout or stderr will break the build.

Also changing the value of optind seems to not work for me. So I use a separate variable prog_ind to contain the index of the program to be run. It also makes the code slightly clearer.

Even if compiling against an older coreutils 99% of this patch can still be usefully applied. Giving the right return codes is good even if no-one is checking. Not abusing optind is good even if you can get it to work either way. The only change that can't be applied with old versions of coreutils is the first change to chcon.c.

Signature · 4 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page
chcon.c renamed from tmp/chcon.c +6 -3
@@ -32,7 +32,7 @@
   V_off
 };
 
-static int change_dir_context PARAMS ((const char *dir, const struct stat *statp));
+static int change_dir_context (const char *dir, const struct stat *statp);
 
 /* The name the program was run with. */
 char *program_name;
@@ -50,8 +50,8 @@
 /* Level of verbosity.  */
 static enum Verbosity verbosity = V_off;
 
-/* The name of the context file is being given. */
-static const char *specified_context;
+/* The context the file is being given. */
+static security_context_t specified_context;
 
 /* Specific components of the context */
 static const char *specified_user;
@@ -326,6 +326,9 @@
 
   recurse = force_silent = 0;
   
+  if(argc == 1)
+    usage(0);
+
   while ((optc = getopt_long (argc, argv, "Rcfhvu:r:t:l:", long_options, NULL)) != -1)
   {
 	  switch (optc)
runcon.c renamed from tmp/runcon.c +51 -14

125 lines not on this page · raw message