summaryrefslogtreecommitdiffstats
path: root/main.cxx
diff options
context:
space:
mode:
authorfche <fche>2006-11-19 19:39:35 +0000
committerfche <fche>2006-11-19 19:39:35 +0000
commitf59e98c4e44dabd7e6d85a6560b4b12ccbfe4e73 (patch)
tree69d8d3a53a8a3e4e623d6fbb06a76cb88cd56073 /main.cxx
parentfbec2ab76beb52878de6bb275ed1ed8d8f819c34 (diff)
downloadsystemtap-steved-f59e98c4e44dabd7e6d85a6560b4b12ccbfe4e73.tar.gz
systemtap-steved-f59e98c4e44dabd7e6d85a6560b4b12ccbfe4e73.tar.xz
systemtap-steved-f59e98c4e44dabd7e6d85a6560b4b12ccbfe4e73.zip
2006-11-19 Frank Ch. Eigler <fche@elastic.org>
* main.cxx (main): Signal parse error if a tapset script is given as the user script.
Diffstat (limited to 'main.cxx')
-rw-r--r--main.cxx25
1 files changed, 22 insertions, 3 deletions
diff --git a/main.cxx b/main.cxx
index e7f5d7da..af73715e 100644
--- a/main.cxx
+++ b/main.cxx
@@ -31,6 +31,7 @@ extern "C" {
#include <sys/utsname.h>
#include <sys/times.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <time.h>
#include <elfutils/libdwfl.h>
}
@@ -439,12 +440,17 @@ main (int argc, char * const argv [])
gettimeofday (&tv_before, NULL);
// PASS 1a: PARSING USER SCRIPT
- // XXX: pass args vector, so parser (or lexer?) can substitute
- // $1..$NN with actual arguments
+
+ struct stat user_file_stat;
+ int user_file_stat_rc = -1;
+
if (script_file == "-")
s.user_file = parser::parse (s, cin, s.guru_mode);
else if (script_file != "")
- s.user_file = parser::parse (s, script_file, s.guru_mode);
+ {
+ s.user_file = parser::parse (s, script_file, s.guru_mode);
+ user_file_stat_rc = stat (script_file.c_str(), & user_file_stat);
+ }
else
{
istringstream ii (cmdline_script);
@@ -501,11 +507,24 @@ main (int argc, char * const argv [])
for (unsigned j=0; j<globbuf.gl_pathc; j++)
{
// privilege only for /usr/share/systemtap?
+
stapfile* f = parser::parse (s, globbuf.gl_pathv[j], true);
if (f == 0)
rc ++;
else
s.library_files.push_back (f);
+
+ struct stat tapset_file_stat;
+ int stat_rc = stat (globbuf.gl_pathv[j], & tapset_file_stat);
+ if (stat_rc == 0 && user_file_stat_rc == 0 &&
+ user_file_stat.st_dev == tapset_file_stat.st_dev &&
+ user_file_stat.st_ino == tapset_file_stat.st_ino)
+ {
+ clog << "parse error: tapset file '" << globbuf.gl_pathv[j]
+ << "' is already processed as the user script." << endl;
+ rc ++;
+ }
+
}
globfree (& globbuf);