summaryrefslogtreecommitdiffstats
path: root/main.cxx
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2010-01-11 20:13:40 -0500
committerDave Brolley <brolley@redhat.com>2010-01-11 20:13:40 -0500
commita0ace4915e5d963c28fa3b54f87afef34b82b6a5 (patch)
tree8498bb2c48473f92334e29eb7dcf7f9460b8ad8b /main.cxx
parent44f348171ea72bf8a195fd281a3226541468b65c (diff)
downloadsystemtap-steved-a0ace4915e5d963c28fa3b54f87afef34b82b6a5.tar.gz
systemtap-steved-a0ace4915e5d963c28fa3b54f87afef34b82b6a5.tar.xz
systemtap-steved-a0ace4915e5d963c28fa3b54f87afef34b82b6a5.zip
Rework filtering of client options. Add testsuite.
Diffstat (limited to 'main.cxx')
-rw-r--r--main.cxx86
1 files changed, 27 insertions, 59 deletions
diff --git a/main.cxx b/main.cxx
index 7b6e378d..265fb363 100644
--- a/main.cxx
+++ b/main.cxx
@@ -429,44 +429,6 @@ checkOptions (systemtap_session &s)
cerr << "You can't specify -g and --unprivileged together." << endl;
optionsConflict = true;
}
- if (s.stap_client)
- {
- if (s.stap_client_a)
- {
- cerr << "You can't specify -a and --unprivileged together." << endl;
- optionsConflict = true;
- }
- if (s.stap_client_B)
- {
- cerr << "You can't specify -B and --unprivileged together." << endl;
- optionsConflict = true;
- }
- if (s.stap_client_D)
- {
- cerr << "You can't specify -D and --unprivileged together." << endl;
- optionsConflict = true;
- }
- if (s.stap_client_I)
- {
- cerr << "You can't specify -I and --unprivileged together." << endl;
- optionsConflict = true;
- }
- if (s.stap_client_m)
- {
- cerr << "You can't specify -m and --unprivileged together." << endl;
- optionsConflict = true;
- }
- if (s.stap_client_r)
- {
- cerr << "You can't specify -r and --unprivileged together." << endl;
- optionsConflict = true;
- }
- if (s.stap_client_R)
- {
- cerr << "You can't specify -R and --unprivileged together." << endl;
- optionsConflict = true;
- }
- }
}
if (!s.kernel_symtab_path.empty())
@@ -578,14 +540,8 @@ main (int argc, char * const argv [])
s.load_only = false;
s.skip_badvars = false;
s.unprivileged = false;
- s.stap_client = false;
- s.stap_client_a = false;
- s.stap_client_B = false;
- s.stap_client_D = false;
- s.stap_client_I = false;
- s.stap_client_m = false;
- s.stap_client_r = false;
- s.stap_client_R = false;
+ bool client_options = false;
+ string client_options_disallowed;
// Location of our signing certificate.
// If we're root, use the database in SYSCONFDIR, otherwise
@@ -668,7 +624,7 @@ main (int argc, char * const argv [])
#define LONG_OPT_VERBOSE_PASS 5
#define LONG_OPT_SKIP_BADVARS 6
#define LONG_OPT_UNPRIVILEGED 7
-#define LONG_OPT_STAP_CLIENT 8
+#define LONG_OPT_CLIENT_OPTIONS 8
// NB: also see find_hash(), usage(), switch stmt below, stap.1 man page
static struct option long_options[] = {
{ "kelf", 0, &long_opt, LONG_OPT_KELF },
@@ -678,7 +634,7 @@ main (int argc, char * const argv [])
{ "skip-badvars", 0, &long_opt, LONG_OPT_SKIP_BADVARS },
{ "vp", 1, &long_opt, LONG_OPT_VERBOSE_PASS },
{ "unprivileged", 0, &long_opt, LONG_OPT_UNPRIVILEGED },
- { "stap-client", 0, &long_opt, LONG_OPT_STAP_CLIENT },
+ { "client-options", 0, &long_opt, LONG_OPT_CLIENT_OPTIONS },
{ NULL, 0, NULL, 0 }
};
int grc = getopt_long (argc, argv, "hVvtp:I:e:o:R:r:a:m:kgPc:x:D:bs:uqwl:d:L:FS:B:",
@@ -719,7 +675,8 @@ main (int argc, char * const argv [])
break;
case 'I':
- s.stap_client_I = s.stap_client;
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-I" : ", -I";
s.include_path.push_back (string (optarg));
break;
@@ -754,12 +711,14 @@ main (int argc, char * const argv [])
break;
case 'R':
- s.stap_client_R = s.stap_client;
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-R" : ", -R";
s.runtime_path = string (optarg);
break;
case 'm':
- s.stap_client_m = s.stap_client;
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-m" : ", -m";
s.module_name = string (optarg);
save_module = true;
{
@@ -806,13 +765,15 @@ main (int argc, char * const argv [])
break;
case 'r':
- s.stap_client_r = s.stap_client;
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-r" : ", -r";
setup_kernel_release(s, optarg);
break;
case 'a':
- s.stap_client_a = s.stap_client;
- s.architecture = string(optarg);
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-a" : ", -a";
+ s.architecture = string(optarg);
break;
case 'k':
@@ -859,7 +820,8 @@ main (int argc, char * const argv [])
break;
case 'D':
- s.stap_client_D = s.stap_client;
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-D" : ", -D";
s.macros.push_back (string (optarg));
break;
@@ -898,8 +860,9 @@ main (int argc, char * const argv [])
break;
case 'B':
- s.stap_client_B = s.stap_client;
- s.kbuildflags.push_back (string (optarg));
+ if (client_options)
+ client_options_disallowed += client_options_disallowed.empty () ? "-B" : ", -B";
+ s.kbuildflags.push_back (string (optarg));
break;
case 0:
@@ -952,8 +915,8 @@ main (int argc, char * const argv [])
case LONG_OPT_UNPRIVILEGED:
s.unprivileged = true;
break;
- case LONG_OPT_STAP_CLIENT:
- s.stap_client = true;
+ case LONG_OPT_CLIENT_OPTIONS:
+ client_options = true;
break;
default:
cerr << "Internal error parsing command arguments." << endl;
@@ -968,6 +931,11 @@ main (int argc, char * const argv [])
}
// Check for options conflicts.
+ if (client_options && s.unprivileged && ! client_options_disallowed.empty ())
+ {
+ cerr << "You can't specify " << client_options_disallowed << " when --unprivileged is specified." << endl;
+ usage (s, 1);
+ }
checkOptions (s);
// Warn in case the target kernel release doesn't match the running one.