From 8f222481f9c010f4c3d8060726234dbb779ce77f Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Thu, 18 Jun 2009 11:46:20 -0400 Subject: Check for options conflicts with --unprivileged. --- main.cxx | 119 ++++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 87 insertions(+), 32 deletions(-) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index 56d70b85..4530075e 100644 --- a/main.cxx +++ b/main.cxx @@ -44,6 +44,7 @@ extern "C" { using namespace std; +#define PATH_TBD string("__TBD__") void version () @@ -356,6 +357,90 @@ setup_kernel_release (systemtap_session &s, const char* kstr) { } } +static void +checkOptions (systemtap_session &s) +{ + bool optionsConflict = false; + + if(!s.bulk_mode && !s.merge) + { + cerr << "-M option is valid only for bulk (relayfs) mode." < 1) + { + cerr << "You can't specify -I and --unprivileged together." << endl; + optionsConflict = true; + } + if (s.runtime_path != string(PKGDATADIR) + "/runtime") + { + cerr << "You can't use -R to specify an alternate runtime path when --unprivileged is specified." << endl; + optionsConflict = true; + } + if (s.kernel_build_tree.substr(0, 13) != "/lib/modules/") + { + cerr << "You can't use -r to specify a kernel release which is not installed when --unprivileged is specified." << endl; + optionsConflict = true; + } + if (! s.macros.empty ()) + { + cerr << "You can't specify -D and --unprivileged together." << endl; + optionsConflict = true; + } + + if (getenv ("SYSTEMTAP_TAPSET")) + { + cerr << "The environment variable SYSTEMTAP_TAPSET can not be defined when --unprivileged is specified." << endl; + optionsConflict = true; + } + if (getenv ("SYSTEMTAP_RUNTIME")) + { + cerr << "The environment variable SYSTEMTAP_RUNTIME can not be defined when --unprivileged is specified." << endl; + optionsConflict = true; + } + if (getenv ("SYSTEMTAP_DEBUGINFO_PATH")) + { + cerr << "The environment variable SYSTEMTAP_DEBUGINFO_PATH can not be defined when --unprivileged is specified." << endl; + optionsConflict = true; + } + } + + if (!s.kernel_symtab_path.empty()) + { + if (s.consult_symtab) + { + cerr << "You can't specify --kelf and --kmap together." << endl; + optionsConflict = true; + } + s.consult_symtab = true; + if (s.kernel_symtab_path == PATH_TBD) + s.kernel_symtab_path = string("/boot/System.map-") + s.kernel_release; + } + + if (optionsConflict) + usage (s, 1); +} + int main (int argc, char * const argv []) { @@ -625,7 +710,6 @@ main (int argc, char * const argv []) case 'g': s.guru_mode = true; - s.unprivileged = false; break; case 'P': @@ -715,7 +799,6 @@ main (int argc, char * const argv []) if (optarg) s.kernel_symtab_path = optarg; else -#define PATH_TBD string("__TBD__") s.kernel_symtab_path = PATH_TBD; break; case LONG_OPT_IGNORE_VMLINUX: @@ -749,7 +832,6 @@ main (int argc, char * const argv []) break; case LONG_OPT_UNPRIVILEGED: s.unprivileged = true; - s.guru_mode = false; break; default: cerr << "Internal error parsing command arguments." << endl; @@ -763,35 +845,8 @@ main (int argc, char * const argv []) } } - if(!s.bulk_mode && !s.merge) - { - cerr << "-M option is valid only for bulk (relayfs) mode." < 4 && -- cgit