summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/staprun.c
diff options
context:
space:
mode:
authorfche <fche>2007-10-12 01:51:10 +0000
committerfche <fche>2007-10-12 01:51:10 +0000
commit3a9627f69d4983ba02c9456fd87fc599ddc26711 (patch)
tree49af98b8380a774bb401611dd39dae14429649b7 /runtime/staprun/staprun.c
parent0fda8ffb9c598d009f0d39b884dda2c53cd06f26 (diff)
downloadsystemtap-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.
Diffstat (limited to 'runtime/staprun/staprun.c')
-rw-r--r--runtime/staprun/staprun.c20
1 files changed, 11 insertions, 9 deletions
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]);