added proper quoting to some variable assignments
authormlenz <mlenz@physik.uni-wuerzburg.de>
Wed, 13 Jun 2007 18:53:03 +0000 (18:53 +0000)
committermlenz <mlenz@physik.uni-wuerzburg.de>
Wed, 13 Jun 2007 18:53:03 +0000 (18:53 +0000)
create-sysvinit-file.pl

index 7831727..5e7873e 100644 (file)
@@ -26,6 +26,14 @@ print "# Description:       ";
 print join("\n#                    ",split("\n",$initparams{"Description"})). "\n";
 print "\n";
 
+# prevent quoted strings from breaking the generated script:
+
+my %quoted_initparams;
+
+while (my ($k, $v) = each %initparams){
+       $quoted_initparams{$k} = quotemeta $v;
+}
+
 print << "EOF"
 ### END INIT INFO
 
@@ -36,10 +44,10 @@ print << "EOF"
 
 # PATH should only include /usr/* if it runs after the mountnfs.sh script
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
-DESC="$initparams{"Desc"}"
-NAME=$initparams{"Name"}
+DESC=$quoted_initparams{"Desc"}
+NAME=$quoted_initparams{"Name"}
 DAEMON=$initparams{"Path"}
-DAEMON_ARGS="$initparams{"Args"}"
+DAEMON_ARGS=$quoted_initparams{"Args"}
 PIDFILE=/var/run/\$NAME.pid
 SCRIPTNAME=/etc/init.d/\$NAME
 EOF