changeset 1311:726d3e67d8c1 draft

The "not root" test happens before looking for --help, so "./sulogin --help" doesn't show it. Instead make the "not root" failure case always show help text.
author Rob Landley <rob@landley.net>
date Sat, 24 May 2014 13:50:19 -0500
parents 7baa19cdce59
children ff3ecf9e5095
files main.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Sat May 24 12:51:53 2014 -0500
+++ b/main.c	Sat May 24 13:50:19 2014 -0500
@@ -98,7 +98,10 @@
     } else if (CFG_TOYBOX_DEBUG && uid && which != toy_list)
       error_msg("Not installed suid root");
 
-    if ((which->flags & TOYFLAG_NEEDROOT) && euid) error_exit("Not root");
+    if ((which->flags & TOYFLAG_NEEDROOT) && euid) {
+      toys.exithelp++;
+      error_exit("Not root");
+    }
   }
 
   // Free old toys contents (to be reentrant), but leave rebound if any