aboutsummaryrefslogtreecommitdiff
path: root/src/portal.cc
diff options
context:
space:
mode:
authorschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2005-06-05 10:21:03 +0000
committerschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2005-06-05 10:21:03 +0000
commitc2bbe6b25ba6d4cca2b836ee75a81a00a2bd8852 (patch)
tree26d909cee6710e853775506f65c94ac46d2f5efe /src/portal.cc
parentaaa4ad68fa305c5103df0b632edec573cbfe4d4a (diff)
Make parameters steerable.
Introduce "verbose" parameter. Announce to the portal by default. Introduce parameter to announce only every n seconds. Only announce every minute by default. When calling system(), make sure that there are no shell meta characters. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@37 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/portal.cc')
-rw-r--r--src/portal.cc39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/portal.cc b/src/portal.cc
index 8ade326..0a86256 100644
--- a/src/portal.cc
+++ b/src/portal.cc
@@ -1,6 +1,7 @@
// $Header$
#include <cassert>
+#include <cctype>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
@@ -133,9 +134,43 @@ namespace Formaline
+ // Check that the file name is sane
+ for (char const * p = scriptfilename; * p; ++ p)
+ {
+ if (! isalnum (* p))
+ {
+ // Allow only certain characters
+ switch (* p)
+ {
+ case '+':
+ case ',':
+ case '-':
+ case '.':
+ case '/':
+ case ':':
+ case '_':
+ case '~':
+ break;
+ default:
+ // We don't like this character
+ {
+ static bool did_complain = false;
+ if (! did_complain)
+ {
+ did_complain = true;
+ CCTK_WARN (1, "Strange character in file name -- not calling system()");
+ return;
+ }
+ }
+ }
+ }
+ }
+
+
+
// Make the script executable
ostringstream chmodbuf;
- chmodbuf << "chmod a+x '" << scriptfilenamestr << "'"
+ chmodbuf << "chmod a+x " << scriptfilenamestr
<< " < /dev/null > /dev/null 2> /dev/null";
string const chmodstr = chmodbuf.str();
char const * const chmod = chmodstr.c_str();
@@ -155,8 +190,8 @@ namespace Formaline
static bool did_complain = false;
if (! did_complain)
{
- CCTK_WARN (1, "Failed to send data to the portal");
did_complain = true;
+ CCTK_WARN (1, "Failed to send data to the portal");
}
}