diff --git a/README.md b/README.md index 283de6d..d35f347 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Upload site's files to the server using SFTP. The way the site is accessed can t * Subdomain of a shared root domain * HTTP subpath of a shared domain +Some Apache configuration directive are available through `.htaccess`. + ## Software used [PHP](https://www.php.net/) @@ -58,7 +60,7 @@ Upload site's files to the server using SFTP. The way the site is accessed can t : static HTTP server, with content negotiation and `.htaccess` dynamic configuration [nginx](https://nginx.org/) -: HTTP reverse proxy for Apache; terminates TLS and enforces security header +: HTTP reverse proxy for Apache; terminates TLS and enforces security headers Tor : [Onion services](https://community.torproject.org/onion-services/) diff --git a/fn/ht.php b/fn/ht.php index 914172f..1a2ea21 100644 --- a/fn/ht.php +++ b/fn/ht.php @@ -88,19 +88,19 @@ function htDeleteSite($address, $type) { output(500, 'Failed to delete Tor configuration.'); // Reload Tor - exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], $output, $code); + exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], result_code: $code); if ($code !== 0) output(500, 'Failed to reload Tor.'); // Delete Tor keys - exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['rm_path'] . ' -r ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $dir, $output, $code); + exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['rm_path'] . ' -r ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $dir, result_code: $code); if ($code !== 0) output(500, 'Failed to delete Tor keys.'); } if ($type === 'dns') { // Delete Let's Encrypt certificate - exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' delete --quiet --cert-name ' . $address, $output, $code); + exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' delete --quiet --cert-name ' . $address, result_code: $code); if ($code !== 0) output(500, 'Certbot failed to delete the Let\'s Encrypt certificate.'); } diff --git a/pg-act/ht/add-onion.php b/pg-act/ht/add-onion.php index c484274..03e94f5 100644 --- a/pg-act/ht/add-onion.php +++ b/pg-act/ht/add-onion.php @@ -15,13 +15,12 @@ if (chmod($torConfFile, 0644) !== true) output(500, 'Failed to give correct permissions to new Tor configuration file.'); // Reload Tor -exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], $output, $code); +exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], result_code: $code); if ($code !== 0) output(500, 'Failed to reload Tor.'); // Get the address generated by Tor -exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['cat_path'] . ' ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'] . '/hostname', $output); -$onion = $output[0]; +$onion = exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['cat_path'] . ' ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'] . '/hostname'); if (preg_match('/^[0-9a-z]{56}\.onion$/D', $onion) !== 1) output(500, 'No onion address found.');