summaryrefslogtreecommitdiffstats
path: root/apis/getconfig.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-06-23 19:49:05 +0200
committerSimon Rettberg2014-06-23 19:49:05 +0200
commit4d3b6c18bbb43c95974ef2cd892f94209cffb589 (patch)
tree12935292ab6efe7e0c759722f7062a61773e6e6e /apis/getconfig.inc.php
parentSome minor html fixes/improvements (diff)
downloadslx-admin-4d3b6c18bbb43c95974ef2cd892f94209cffb589.tar.gz
slx-admin-4d3b6c18bbb43c95974ef2cd892f94209cffb589.tar.xz
slx-admin-4d3b6c18bbb43c95974ef2cd892f94209cffb589.zip
Rebuild AD config modules if server IP changed...
Also add vmchooser URL to getconfig, fix shell string escaping
Diffstat (limited to 'apis/getconfig.inc.php')
-rw-r--r--apis/getconfig.inc.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/apis/getconfig.inc.php b/apis/getconfig.inc.php
index 0a8db6be..84393dbc 100644
--- a/apis/getconfig.inc.php
+++ b/apis/getconfig.inc.php
@@ -1,8 +1,15 @@
<?php
+/**
+ * Escape given string so it is a valid string in sh that can be surrounded
+ * by single quotes ('). This basically turns _'_ into _'"'"'_
+ *
+ * @param string $string input
+ * @return string escaped sh string
+ */
function escape($string)
{
- return str_replace("'", "\\'", $string);
+ return str_replace("'", "'\"'\"'", $string);
}
// Dump config from DB
@@ -12,12 +19,15 @@ $res = Database::simpleQuery('SELECT setting.setting, setting.defaultvalue, sett
ORDER BY setting ASC'); // TODO: Add setting groups and sort order
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
if (is_null($row['value'])) $row['value'] = $row['defaultvalue'];
- echo $row['setting'] . "='" . str_replace("'", "'\"'\"'", $row['value']) . "'\n";
+ echo $row['setting'] . "='" . escape($row['value']) . "'\n";
}
+
// Additional "intelligent" config
// Remote log URL
echo "SLX_REMOTE_LOG='http://" . escape($_SERVER['SERVER_ADDR']) . "/slxadmin/api.php?do=clientlog'\n";
+// vm list url
+echo "SLX_VMCHOOSER_BASE_URL='http://" . escape($_SERVER['SERVER_ADDR']) . "/vmchooser/'\n";
// VMStore path and type
$vmstore = Property::getVmStoreConfig();