Skip to content

Commit

Permalink
Merge pull request #1662 from RaspAP/fix/escapeshell-ovpncfg
Browse files Browse the repository at this point in the history
Apply escapeshellarg to OpenVPN auth + client configs
  • Loading branch information
billz authored Sep 20, 2024
2 parents 3889e2f + 74c7fb8 commit 56e5f6f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions includes/openvpn.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function DisplayOpenVPNConfig()
ftruncate($f, 0);
fclose($f);
}
} elseif (isset($_POST['log-openvpn']) || file_exists('/tmp/openvpn.log')) {
} elseif (isset($_POST['log-openvpn']) || filesize('/tmp/openvpn.log') >0) {
$logEnable = 1;
exec("sudo /etc/raspap/openvpn/openvpnlog.sh", $logOutput);
$logOutput = file_get_contents('/tmp/openvpn.log');
Expand Down Expand Up @@ -127,7 +127,7 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
$auth = $authUser .PHP_EOL . $authPassword .PHP_EOL;
file_put_contents($tmp_authdata, $auth);
chmod($tmp_authdata, 0644);
$client_auth = RASPI_OPENVPN_CLIENT_PATH.pathinfo($file['name'], PATHINFO_FILENAME).'_login.conf';
$client_auth = escapeshellarg(RASPI_OPENVPN_CLIENT_PATH.pathinfo($file['name'], PATHINFO_FILENAME).'_login.conf');
system("sudo mv $tmp_authdata $client_auth", $return);
system("sudo rm ".RASPI_OPENVPN_CLIENT_LOGIN, $return);
system("sudo ln -s $client_auth ".RASPI_OPENVPN_CLIENT_LOGIN, $return);
Expand All @@ -144,7 +144,7 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
}

// Move uploaded ovpn config from /tmp and create symlink
$client_ovpn = RASPI_OPENVPN_CLIENT_PATH.pathinfo($file['name'], PATHINFO_FILENAME).'_client.conf';
$client_ovpn = escapeshellarg(RASPI_OPENVPN_CLIENT_PATH.pathinfo($file['name'], PATHINFO_FILENAME).'_client.conf');
chmod($tmp_ovpn, 0644);
system("sudo mv $tmp_ovpn $client_ovpn", $return);
system("sudo rm ".RASPI_OPENVPN_CLIENT_CONFIG, $return);
Expand Down

0 comments on commit 56e5f6f

Please sign in to comment.