summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-01-13 16:19:53 -0500
committerDave Brolley <brolley@redhat.com>2009-01-13 16:19:53 -0500
commit21325e0c78f4de1e772813c8f071d909d83e1b58 (patch)
treef37745871b66343986890725829fb8df5f7b4fee
parent790c4dd6eff3fbc127b67e23478d7edc6bf1cd08 (diff)
downloadsystemtap-steved-21325e0c78f4de1e772813c8f071d909d83e1b58.tar.gz
systemtap-steved-21325e0c78f4de1e772813c8f071d909d83e1b58.tar.xz
systemtap-steved-21325e0c78f4de1e772813c8f071d909d83e1b58.zip
Ensure that the client/server scripts call the installed copies of any
other systemtap tools.
-rw-r--r--ChangeLog6
-rwxr-xr-xstap-client56
-rwxr-xr-xstap-find-or-start-server10
-rwxr-xr-xstap-server6
-rwxr-xr-xstap-serverd21
-rwxr-xr-xstap-start-server9
6 files changed, 75 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index ff418c40..e724de69 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2009-01-13 Dave Brolley <brolley@redhat.com>
+ * stap-find-or-start-server,stap-start-server,stap-serverd,stap-server:
+ Ensure we call other systemtap tools from the installed location.
+ * stap-client: Likewise. Also, use SYSTEMTAP_STAPRUN if it is set.
+
+2009-01-13 Dave Brolley <brolley@redhat.com>
+
* stap-add-server-cert: Failure to make the client database readable
is now only a warning. Directory argument now refers to the location
of the 'client' directory.
diff --git a/stap-client b/stap-client
index 69bd935c..09ee60bf 100755
--- a/stap-client
+++ b/stap-client
@@ -38,12 +38,28 @@ function initialization {
umask 0
staprun_running=0
+ # Where are we installed?
+ if test "`basename $0`" = "stap" -a "$0" = `which stap`; then
+ # The dejagnu test harness may invoke us as 'stap' relying on $PATH to
+ # find us. If so, then use the $PATH to find the rest of the systemtap
+ # tools.
+ exec_prefix=""
+ # Also, set the prefix to point to where we were found.
+ prefix=`which stap`
+ prefix=`dirname $prefix`
+ else
+ # Assume we were installed normally
+ exec_prefix=`dirname $0`
+ exec_prefix=`cd $exec_prefix && pwd`/
+ prefix=`dirname $exec_prefix`
+ fi
+
# Default location for server certificates if we're not root
if test $EUID != 0; then
local_ssl_dbs="$HOME/.systemtap/ssl/client"
fi
# Additional location for all users.
- public_ssl_dbs="`dirname $0`/../etc/systemtap/ssl/client"
+ public_ssl_dbs=$prefix/etc/systemtap/ssl/client
# Default options settings
p_phase=5
@@ -480,7 +496,7 @@ function find_and_connect_to_server {
# Use a temp file here instead of a pipeline so that the side effects
# of choose_server are seen by the rest of this script.
cd $tmpdir_client
- stap-find-servers > servers
+ ${exec_prefix}stap-find-servers > servers
choose_server < servers
rm -fr servers
}
@@ -548,8 +564,8 @@ function send_receive {
do
# Send the request and receive the response using stap-client-connect
echo "Attempting connection with $server using certificate database in '$db'" >> $tmpdir_client/connect
- stap-client-connect -i $zip_client -o $jar_server -d $db -p $port -h $server >> $tmpdir_client/connect 2>&1 &
- wait '%stap-client-connect'
+ ${exec_prefix}stap-client-connect -i $zip_client -o $jar_server -d $db -p $port -h $server >> $tmpdir_client/connect 2>&1 &
+ wait '%${exec_prefix}stap-client-connect'
test $? = 0 && ssl_db=$db && return 0
sleep 1
done
@@ -560,8 +576,8 @@ function send_receive {
do
# Send the request and receive the response using stap-client-connect
echo "Attempting connection with $server using certificate database in '$db'" >> $tmpdir_client/connect
- stap-client-connect -i $zip_client -o $jar_server -d $db -p $port -h $server >> $tmpdir_client/connect 2>&1 &
- wait '%stap-client-connect'
+ ${exec_prefix}stap-client-connect -i $zip_client -o $jar_server -d $db -p $port -h $server >> $tmpdir_client/connect 2>&1 &
+ wait '%${exec_prefix}stap-client-connect'
test $? = 0 && ssl_db=$db && return 0
sleep 1
done
@@ -652,7 +668,7 @@ function maybe_call_staprun {
if test $v_level -ge 2; then
echo "running `which staprun` $staprun_opts $tmpdir_stap/`ls $tmpdir_stap | grep '.ko$'`" >&2
fi
- PATH=`staprun_PATH` eval staprun "$staprun_opts" \
+ eval `staprun_PATH` "$staprun_opts" \
$tmpdir_stap/`ls $tmpdir_stap | grep '.ko$'`
staprun_running=1
wait '%?staprun' > /dev/null 2>&1
@@ -676,23 +692,25 @@ function maybe_call_staprun {
#
# Compute a PATH suitable for running staprun.
function staprun_PATH {
- # staprun may invoke 'stap'. So we can use the current PATH if we were
- # not invoked as 'stap' or we are not the first 'stap' on the PATH.
- local first_stap=`which stap 2>/dev/null`
-
- if test "X$first_stap" = "X"; then
- echo "$PATH"
+ # If $SYSTEMTAP_STAPRUN is set, then use that
+ if test "X$SYSTEMTAP_STAPRUN" != "X"; then
+ echo $SYSTEMTAP_STAPRUN
return
fi
- if test `which $0 2>/dev/null` != $first_stap; then
- echo "$PATH"
+ # Otherwise, if there is an exec_prefix, then use it.
+ if test "X$exec_prefix" != "X"; then
+ echo ${exec_prefix}staprun
return
fi
- # Otherwise, remove the PATH component where we live from the PATH
+ # Otherwise, we have been called by the dejagnu test harness as 'stap'
+ # and we are the first 'stap' on the path. Since staprun may call
+ # 'stap', remove the PATH component where we live from the PATH in order to
+ # avoid recursion.
+ local first_stap=`which stap`
local PATH_component=`dirname $first_stap`
- echo "$PATH" | sed "s,$PATH_component,,g"
+ echo "PATH=$PATH staprun" | sed "s,$PATH_component,,g"
}
# function: fatal [ MESSAGE ]
@@ -731,7 +749,7 @@ function terminate {
kill -s SIGTERM '%?staprun' 2>/dev/null
# Kill any stap-client-connect job
- kill -s SIGTERM '%stap-client-connect'
+ kill -s SIGTERM '%${exec_prefix}stap-client-connect'
exit 1
}
@@ -748,7 +766,7 @@ function interrupt {
# Kill any stap-client-connect job
# SIGINT won't do it.
- kill -s SIGTERM '%stap-client-connect'
+ kill -s SIGTERM '%${exec_prefix}stap-client-connect'
# If staprun was not running, then exit.
cleanup
diff --git a/stap-find-or-start-server b/stap-find-or-start-server
index beef05fc..efe23558 100755
--- a/stap-find-or-start-server
+++ b/stap-find-or-start-server
@@ -2,7 +2,7 @@
# Find or start a systemtap server
#
-# Copyright (C) 2008 Red Hat Inc.
+# Copyright (C) 2008, 2009 Red Hat Inc.
#
# This file is part of systemtap, and is free software. You can
# redistribute it and/or modify it under the terms of the GNU General
@@ -17,11 +17,15 @@
#
# Otherwise, it echoes -1 and exits with 1
+# Where are we installed?
+exec_prefix=`dirname $0`
+exec_prefix=`cd $exec_prefix && pwd`
+
# Is there a server available?
-stap-find-servers >/dev/null 2>&1 && echo 0 && exit 0
+$exec_prefix/stap-find-servers >/dev/null 2>&1 && echo 0 && exit 0
# No server available, try to start one.
-pid=`stap-start-server "$@"`
+pid=`$exec_prefix/stap-start-server "$@"`
if test $? = 0; then
echo $pid
exit 0
diff --git a/stap-server b/stap-server
index 857a9025..4f1ccf9b 100755
--- a/stap-server
+++ b/stap-server
@@ -36,6 +36,10 @@ function initialization {
p_phase=5
keep_temps=0
+ # Where are we installed?
+ exec_prefix=`dirname $0`
+ exec_prefix=`cd $exec_prefix && pwd`
+
# Request file name.
zip_client=$1
test -f $zip_client || \
@@ -312,7 +316,7 @@ function call_stap {
server_p_phase=$p_phase
fi
- eval stap "$cmdline" -k -p $server_p_phase \
+ eval $exec_prefix/stap "$cmdline" -k -p $server_p_phase \
>> $tmpdir_server/stdout \
2>> $tmpdir_server/stderr
diff --git a/stap-serverd b/stap-serverd
index 2971c67f..2c7abba1 100755
--- a/stap-serverd
+++ b/stap-serverd
@@ -24,6 +24,11 @@ function initialization {
# Default settings.
avahi_type=_stap._tcp
+ # Where are we installed?
+ exec_prefix=`dirname $0`
+ exec_prefix=`cd $exec_prefix && pwd`
+ prefix=`dirname $exec_prefix`
+
# What port will we listen on?
port=$1
test "X$port" = "X" && port=65000
@@ -40,15 +45,15 @@ function initialization {
# If no certificate/key database has been specified, then find/create
# a local one.
if test $EUID = 0; then
- ssl_db=`dirname $0`/../etc/systemtap/ssl/server
+ ssl_db=$prefix/etc/systemtap/ssl/server
else
ssl_db=$HOME/.systemtap/ssl/server
fi
if ! test -f $ssl_db/stap-server.cert; then
- stap-gen-server-cert `dirname $ssl_db` || exit 1
+ $exec_prefix/stap-gen-server-cert `dirname $ssl_db` || exit 1
# Now add the server's certificate to the client's database,
# making it a trusted peer.
- stap-add-server-cert $ssl_db/stap-server.cert `dirname $ssl_db` || exit 1
+ $exec_prefix/stap-add-server-cert $ssl_db/stap-server.cert `dirname $ssl_db` || exit 1
fi
fi
nss_pw=$ssl_db/pw
@@ -77,8 +82,8 @@ function advertise_presence {
function listen {
# The stap-server-connect program will listen forever
# accepting requests.
- stap-server-connect -p $port -n $nss_cert -d $ssl_db -w $nss_pw 2>&1 &
- wait '%stap-server-connect' >/dev/null 2>&1
+ $exec_prefix/stap-server-connect -p $port -n $nss_cert -d $ssl_db -w $nss_pw 2>&1 &
+ wait '%$exec_prefix/stap-server-connect' >/dev/null 2>&1
}
# function: fatal [ MESSAGE ]
@@ -98,12 +103,12 @@ function terminate {
echo "$0: Exiting"
# Kill the running 'avahi-publish-service' job
- kill -s SIGTERM %avahi-publish-service 2> /dev/null
+ kill -s SIGTERM '%avahi-publish-service' 2> /dev/null
wait '%avahi-publish-service' >/dev/null 2>&1
# Kill any running 'stap-server-connect' job.
- kill -s SIGTERM "%stap-server-connect" 2> /dev/null
- wait "%stap-server-connect" >/dev/null 2>&1
+ kill -s SIGTERM '%$exec_prefix/stap-server-connect' 2> /dev/null
+ wait '%$exec_prefix/stap-server-connect' >/dev/null 2>&1
exit
}
diff --git a/stap-start-server b/stap-start-server
index 04a3e2d3..c8ea8178 100755
--- a/stap-start-server
+++ b/stap-start-server
@@ -12,15 +12,20 @@
# This script attempts to start a systemtap server and echoes the
# process id, if successful.
+# Where are we installed?
+exec_prefix=`dirname $0`
+exec_prefix=`cd $exec_prefix && pwd`
+prefix=`dirname $exec_prefix`
+
# start the server
-stap-serverd "$@" </dev/null >/dev/null 2>&1 &
+$exec_prefix/stap-serverd "$@" </dev/null >/dev/null 2>&1 &
server_pid=$!
# Make sure the server is started
for ((attempt=0; $attempt < 5; ++attempt))
do
if test $EUID = 0; then
- if ! test -f `dirname $0`/../etc/systemtap/ssl/server/stap-server.cert; then
+ if ! test -f $prefix/etc/systemtap/ssl/server/stap-server.cert; then
sleep 1
continue;
fi