diff options
author | fche <fche> | 2007-10-12 01:51:10 +0000 |
---|---|---|
committer | fche <fche> | 2007-10-12 01:51:10 +0000 |
commit | 3a9627f69d4983ba02c9456fd87fc599ddc26711 (patch) | |
tree | 49af98b8380a774bb401611dd39dae14429649b7 | |
parent | 0fda8ffb9c598d009f0d39b884dda2c53cd06f26 (diff) | |
download | systemtap-steved-3a9627f69d4983ba02c9456fd87fc599ddc26711.tar.gz systemtap-steved-3a9627f69d4983ba02c9456fd87fc599ddc26711.tar.xz systemtap-steved-3a9627f69d4983ba02c9456fd87fc599ddc26711.zip |
* staprun error-check reordering for parseko/cmdline* tests
* staprun.c (main): Move checks for init_cap and getuid
from just before command line argument parsing to just after.
-rw-r--r-- | runtime/staprun/ChangeLog | 5 | ||||
-rw-r--r-- | runtime/staprun/staprun.c | 20 |
2 files changed, 16 insertions, 9 deletions
diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog index 4e23c424..2a9029d0 100644 --- a/runtime/staprun/ChangeLog +++ b/runtime/staprun/ChangeLog @@ -1,3 +1,8 @@ +2007-10-11 Frank Ch. Eigler <fche@elastic.org> + + * staprun.c (main): Move checks for init_cap and getuid + from just before command line argument parsing to just after. + 2007-10-09 Martin Hunt <hunt@redhat.com> * common.c (set_clexec): New. diff --git a/runtime/staprun/staprun.c b/runtime/staprun/staprun.c index 67b01abb..44ac0313 100644 --- a/runtime/staprun/staprun.c +++ b/runtime/staprun/staprun.c @@ -211,15 +211,8 @@ int main(int argc, char **argv) exit(1); } - if (geteuid() != 0) { - err("ERROR: The effective user ID of staprun must be set to the root user.\n" - " Check permissions on staprun and ensure it is a setuid root program.\n"); - exit(1); - } - - if (!init_cap()) - exit(1); - + /* NB: Don't do the geteuid()!=0 check here, since we want to + test command-line error-handling while running non-root. */ /* Get rid of a few standard environment variables (which */ /* might cause us to do unintended things). */ rc = unsetenv("IFS") || unsetenv("CDPATH") || unsetenv("ENV") @@ -258,6 +251,15 @@ int main(int argc, char **argv) usage(argv[0]); } + if (geteuid() != 0) { + err("ERROR: The effective user ID of staprun must be set to the root user.\n" + " Check permissions on staprun and ensure it is a setuid root program.\n"); + exit(1); + } + + if (!init_cap()) + exit(1); + if (check_permissions() != 1) usage(argv[0]); |