bug 1273: use runCommand where former "echo"-syntax was used
authorFelix Dörre <felix@dogcraft.de>
Sun, 15 Jun 2014 09:48:10 +0000 (11:48 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sun, 15 Jun 2014 09:48:10 +0000 (11:48 +0200)
includes/account.php

index 0f2f05d..a5d1eef 100644 (file)
@@ -2812,8 +2812,10 @@ function buildSubjectFromSession() {
        {
                $CSR = clean_csr($CSR);
                $_SESSION['_config']['CSR'] = $CSR;
-               $_SESSION['_config']['subject'] = trim(shell_exec("echo \"$CSR\"|/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep \"Subject:\""));
-               $bits = explode(",", trim(shell_exec("echo \"$CSR\"|/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:")));
+               runCommand("/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep \"Subject:\"", $CSR, $CSRSubjects);
+               runCommand("/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:", $CSR, $CSRAlts);
+               $_SESSION['_config']['subject'] = trim($CSRSubjects);
+               $bits = explode(",", trim($CSRAlts));
                foreach($bits as $val)
                {
                        $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
@@ -2837,8 +2839,11 @@ function buildSubjectFromSession() {
        if($process != "" && $oldid == 46)
        {
                $CSR = clean_csr($_SESSION['_config']['CSR']);
-               $_SESSION['_config']['subject'] = trim(shell_exec("echo \"$CSR\"|/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep \"Subject:\""));
-               $bits = explode(",", trim(shell_exec("echo \"$CSR\"|/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:")));
+               runCommand("/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep \"Subject:\"", $CSR, $CSRSubjects);
+               runCommand("/usr/bin/openssl req -text -noout|tr -d \"\\0\"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:", $CSR, $CSRAlts);
+
+               $_SESSION['_config']['subject'] = trim($CSRSubjects);
+               $bits = explode(",", trim($CSRAlts));
                foreach($bits as $val)
                {
                        $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);