diff --git a/config.ini b/config.ini index 92b1e99..6b577e6 100644 --- a/config.ini +++ b/config.ini @@ -47,6 +47,7 @@ cat_path = "/usr/bin/cat" rm_path = "/usr/bin/rm" mkdir_path = "/usr/bin/mkdir" +sftpgo_user = "sftpgo" sftpgo_group = "sftpgo" ; Will be shown to users diff --git a/fn/ht.php b/fn/ht.php index 7d43593..a4c6c0a 100644 --- a/fn/ht.php +++ b/fn/ht.php @@ -16,7 +16,7 @@ function listFsDirs($username) { $absoluteDirs = glob(CONF['ht']['ht_path'] . '/' . $username . '/*/', GLOB_ONLYDIR); $dirs = []; foreach ($absoluteDirs as $absoluteDir) - if (preg_match('/^[\p{L}\p{N}_-]{1,64}$/Du', basename($absoluteDir))) + if (preg_match('/^[a-zA-Z0-9_-]{1,64}$/D', basename($absoluteDir))) array_push($dirs, basename($absoluteDir)); return $dirs; } @@ -32,14 +32,16 @@ function addSite($username, $siteDir, $domain, $domainType, $protocol) { ]); } -function dirsStatuses($username, $domainType, $protocol) { +function dirsStatuses($domainType, $protocol) { + if (isset($_SESSION['username']) !== true) + return []; $dbDirs = query('select', 'sites', [ - 'username' => $username, + 'username' => $_SESSION['username'], 'domain_type' => $domainType, 'protocol' => $protocol, ], 'site_dir'); $dirs = []; - foreach (listFsDirs($username) as $fsDir) + foreach (listFsDirs($_SESSION['username']) as $fsDir) $dirs[$fsDir] = in_array($fsDir, $dbDirs); return $dirs; } diff --git a/pages/auth/unregister.php b/pages/auth/unregister.php index 3122319..177578f 100644 --- a/pages/auth/unregister.php +++ b/pages/auth/unregister.php @@ -30,7 +30,7 @@ if (processForm()) { removeDirectory(CONF['ht']['tor_config_path'] . '/' . $_SESSION['username']); - exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['rm_path'] . ' --recursive ' . CONF['ht']['ht_path'] . '/' . $_SESSION['username'], result_code: $code); + exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['sftpgo_user'] . ' ' . CONF['ht']['rm_path'] . ' --recursive ' . CONF['ht']['ht_path'] . '/' . $_SESSION['username'], result_code: $code); if ($code !== 0) output(500, 'Can\'t remove user\'s directory.'); diff --git a/pages/ht/add-http-dns.php b/pages/ht/add-http-dns.php index b1a361d..2af37c3 100644 --- a/pages/ht/add-http-dns.php +++ b/pages/ht/add-http-dns.php @@ -1,14 +1,9 @@ dir.'); if (query('select', 'sites', ['domain' => $_POST['domain']], 'domain') !== []) @@ -65,6 +60,8 @@ if (processForm()) { output(200, 'Accès HTTP par domaine ajouté sur ce dossier !'); } +$dirsStatuses = dirsStatuses('onion', 'http'); + $proof = getAuthToken(); ?> diff --git a/pages/ht/add-http-onion.php b/pages/ht/add-http-onion.php index f3232d6..151c470 100644 --- a/pages/ht/add-http-onion.php +++ b/pages/ht/add-http-onion.php @@ -1,12 +1,7 @@ dir.'); rateLimit(); @@ -53,6 +48,8 @@ if (processForm()) { output(200, 'L\'adresse de votre service Onion HTTP est : http://' . $onion . '/'); } +$dirsStatuses = dirsStatuses('onion', 'http'); + ?>

diff --git a/pages/ht/del-http-dns.php b/pages/ht/del-http-dns.php index d2c831c..0daa33d 100644 --- a/pages/ht/del-http-dns.php +++ b/pages/ht/del-http-dns.php @@ -1,12 +1,7 @@ dir.'); htDeleteSite($_POST['dir'], domainType: 'dns', protocol: 'http'); @@ -14,6 +9,8 @@ if (processForm()) { output(200, 'Accès retiré.'); } +$dirsStatuses = dirsStatuses('onion', 'http'); + ?>

diff --git a/pages/ht/del-http-onion.php b/pages/ht/del-http-onion.php index d4aff78..3f1b9a6 100644 --- a/pages/ht/del-http-onion.php +++ b/pages/ht/del-http-onion.php @@ -1,12 +1,7 @@ dir.'); htDeleteSite($_POST['dir'], domainType: 'onion', protocol: 'http'); @@ -14,6 +9,8 @@ if (processForm()) { output(200, 'Accès retiré.'); } +$dirsStatuses = dirsStatuses('onion', 'http'); + ?>

diff --git a/pages/ht/index.php b/pages/ht/index.php index 50b1c79..761e11b 100644 --- a/pages/ht/index.php +++ b/pages/ht/index.php @@ -30,6 +30,12 @@ else { +

+

Ajouter un accès de site

+ +

Pour pouvoir y ajouter un accès par ce service, un site doit auparavent être téléversé dans un sous-dossier direct de l'espace SFTP. Le nom de ce sous-dossier ne peut contenir que a-z, A-Z, 0-9, _ et -.

+
+

SFTP