Mercurial > hg > toybox
comparison main.c @ 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 | 313980d3d78c |
children | 0f2b9d0b1f7a |
comparison
equal
deleted
inserted
replaced
1310:7baa19cdce59 | 1311:726d3e67d8c1 |
---|---|
96 if (uid != euid) | 96 if (uid != euid) |
97 if (!setuid(euid=uid)) perror_exit("setuid"); // drop root | 97 if (!setuid(euid=uid)) perror_exit("setuid"); // drop root |
98 } else if (CFG_TOYBOX_DEBUG && uid && which != toy_list) | 98 } else if (CFG_TOYBOX_DEBUG && uid && which != toy_list) |
99 error_msg("Not installed suid root"); | 99 error_msg("Not installed suid root"); |
100 | 100 |
101 if ((which->flags & TOYFLAG_NEEDROOT) && euid) error_exit("Not root"); | 101 if ((which->flags & TOYFLAG_NEEDROOT) && euid) { |
102 toys.exithelp++; | |
103 error_exit("Not root"); | |
104 } | |
102 } | 105 } |
103 | 106 |
104 // Free old toys contents (to be reentrant), but leave rebound if any | 107 // Free old toys contents (to be reentrant), but leave rebound if any |
105 | 108 |
106 if (toys.optargs != toys.argv+1) free(toys.optargs); | 109 if (toys.optargs != toys.argv+1) free(toys.optargs); |