diff options
author | Dave Brolley <brolley@redhat.com> | 2009-09-17 20:35:41 -0400 |
---|---|---|
committer | Dave Brolley <brolley@redhat.com> | 2009-09-17 20:35:41 -0400 |
commit | 8afee8bbf045e858dae186d40653293c99dbbcdd (patch) | |
tree | d170c0b3e060f8534ecbd2783074b4838dcf812c /stap-server | |
parent | 8150f846586bb04d05f51e4f17e86c00347cb7b6 (diff) | |
download | systemtap-steved-8afee8bbf045e858dae186d40653293c99dbbcdd.tar.gz systemtap-steved-8afee8bbf045e858dae186d40653293c99dbbcdd.tar.xz systemtap-steved-8afee8bbf045e858dae186d40653293c99dbbcdd.zip |
Check for unprivileged options conflicts on the server side.
Gneral work on options in the client and server.
Diffstat (limited to 'stap-server')
-rwxr-xr-x | stap-server | 100 |
1 files changed, 71 insertions, 29 deletions
diff --git a/stap-server b/stap-server index f9ccde04..98b54d96 100755 --- a/stap-server +++ b/stap-server @@ -32,6 +32,7 @@ function initialization { p_phase=5 keep_temps=0 unprivileged=0 + stap_options= # Request file name. zip_client=$1 @@ -135,19 +136,9 @@ function server_sysinfo { # # Make sure that systemtap as described by SYSINFO1 and SYSINFO2 are compaible function check_compatibility { - # Compatibility is irrelevant if the request is not for phase 5 activity. - test $p_phase -lt 5 && return - - # TODO: This needs work - # - Make sure the linux kernel matches exactly - local sysinfo1=$1 - local sysinfo2=$2 - - if test "$sysinfo1" != "$sysinfo2"; then - error "System configuration mismatch" - error " client: $sysinfo1" - fatal " server: $sysinfo2" - fi + # Compatibility is irrelevant. The client can choose any server + # it sees fit + return } # function: read_data_file PREFIX @@ -182,6 +173,13 @@ function read_data_file { # Examine the command line. We need not do much checking, but we do need to # parse all options in order to discover the ones we're interested in. function parse_options { + # We need to know in advance if --unprivileged was specified. + all_options="$@"" " + token=`expr "$all_options" : '.* \(--unprivileged\) .*'` + if test "X$token" = "X--unprivileged"; then + unprivileged=1 + fi + while test $# != 0 do advance_p=0 @@ -190,13 +188,6 @@ function parse_options { # Start of a new token. first_token=$1 - # Handle the --unprivileged option. - if test "X$first_token" = "X--unprivileged"; then - unprivileged=1 - shift - continue - fi - # Process the option. until test $advance_p != 0 do @@ -205,7 +196,16 @@ function parse_options { if test $dash_seen = 0; then if test "$first_char" = "-"; then if test "$first_token" != "-"; then - # It's not a lone dash, so it's an option. Remove the dash. + # It's not a lone dash, so it's an option. + # Is it a long option (i.e. --option)? + second_char=`expr "$first_token" : '.\(.\).*'` + if test "X$second_char" = "X-"; then + advance_p=$(($advance_p + 1)) + stap_options="$stap_options $first_token" + break + fi + # It's not a lone dash, or a long option, so it's a short option string. + # Remove the dash. first_token=`expr "$first_token" : '-\(.*\)'` dash_seen=1 first_char=`expr "$first_token" : '\(.\).*'` @@ -217,7 +217,12 @@ function parse_options { # If this is the first time, and -e has not been specified, # then it could be the name of the script file. if test "X$e_script" = "X" -a "X$script_file" = "X"; then - script_file=$first_token + script_file="$first_token" + fi + if test "$first_char" != "'"; then + stap_options="$stap_options '$first_token'" + else + stap_options="$stap_options $first_token" fi advance_p=$(($advance_p + 1)) break @@ -226,46 +231,83 @@ function parse_options { # We are at the start of an option. Look at the first character. case $first_char in - c) - get_arg $first_token "$2" + a) + get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" + ;; + B) + get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" + ;; + d) + get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" ;; D) get_arg $first_token $2 + if test $unprivileged = 1; then + fatal "You can't specify -D and --unprivileged together." + else + stap_options="$stap_options -$first_char $stap_arg" + fi ;; e) get_arg $first_token "$2" + stap_options="$stap_options -$first_char '$stap_arg'" process_e "$stap_arg" ;; I) get_arg $first_token $2 + if test $unprivileged = 1; then + fatal "You can't specify -I and --unprivileged together." + else + stap_options="$stap_options -$first_char $stap_arg" + fi ;; k) keep_temps=1 ;; l) get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" + process_p 2 + ;; + L) + get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" + process_p 2 ;; m) get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" ;; o) get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" ;; p) get_arg $first_token $2 process_p $stap_arg ;; - r) - get_arg $first_token $2 - ;; R) get_arg $first_token $2 + if test $unprivileged = 1; then + fatal "You can't specify -R and --unprivileged together." + else + stap_options="$stap_options -$first_char $stap_arg" + fi ;; s) get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" + ;; + S) + get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" ;; x) get_arg $first_token $2 + stap_options="$stap_options -$first_char $stap_arg" ;; *) # An unknown flag. Ignore it. @@ -274,6 +316,7 @@ function parse_options { if test $advance_p = 0; then # Just another flag character. Consume it. + stap_options="$stap_options -$first_char" first_token=`expr "$first_token" : '.\(.*\)'` if test "X$first_token" = "X"; then advance_p=$(($advance_p + 1)) @@ -302,7 +345,6 @@ function get_arg { advance_p=$(($advance_p + 1)) first=$1 fi - stap_arg="$first" advance_p=$(($advance_p + 1)) } @@ -340,7 +382,7 @@ function call_stap { server_p_phase=$p_phase fi - eval ${stap_exec_prefix}stap "$cmdline" -k -p $server_p_phase \ + eval ${stap_exec_prefix}stap "$stap_options" -k -p $server_p_phase \ >> $tmpdir_server/stdout \ 2>> $tmpdir_server/stderr |