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.
diff --git a/main.c b/main.c
index 38f6d1a..f0969df 100644
--- a/main.c
+++ b/main.c
@@ -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