Compare commits

..

2 commits

Author SHA1 Message Date
Benoît S. 07f1096a73 Missing --follow-symlinks :( 2019-06-04 16:45:24 +02:00
Benoît S. 51b6112e71 Wrapper evoacme
Used by Quai13. Will be redo properly by Nicolas ;)
2019-06-04 16:33:07 +02:00
35 changed files with 621 additions and 1456 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
conf/config.local.php
.vagrant
.idea

View file

@ -1,66 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project does not follow semantic versioning.
The **major** part of the version is the year
The **minor** part changes is the month
The **patch** part changes is incremented if multiple releases happen the same month
## [Unreleased]
### Added
### Changed
### Fixed
### Removed
### Security
## [24.04]
### Added
* Prevent op_del to fail and able to remove web account when part of it is already removed
### Changed
* Add sendmail_path and open_basedir in LXC PHP pool configs
### Fixed
* letsencrypt: Add required check when retrieving certificate. (Avoid TypeError.)
* web-add.sh: Fix ssh group membership (#94)
### Removed
### Security
## [23.02] 2023-02-20
### Added
* web : Display web-add.sh version
### Changed
* Readme.md : Translated to english. New contribution guidelines and misc information
### Fixed
* web-add.sh : Deleting mysql user with DROP USER to stay compatible with MariaDB 10.5+ - #78
* web-add.sh : Correcting deletion order to avoid dependency issues - #76
### Removed
### Security

1
INSTALL Normal file
View file

@ -0,0 +1 @@
* Ajouter les autorisations sudo nécessaires

250
README.md
View file

@ -1,48 +1,242 @@
# Evoadmin-web
# evoadmin-web
Web interface and management scripts for web hosting
Panel d'administration de serveur web et scripts shell.
Project leader : ?
## Versions & Branches
## Versions
The `master` branch is ready for production.
It's compatible with the current Debian version (and few previous ones)
Code for older Debian releases (Wheezy, Jessie) is archived on separate branches.
The `unstable` branch contains not sufficiently tested changes that we don't consider ready for production yet.
### Versions
* Debian Stretch, Buster, Bullseye → use branch `master` (current stable version)
* Debian Jessie → use branch `jessie` (old, archive branch)
* Debian Wheezy → use branch `wheezy` (old, archive branch)
* Stable Wheezy → git checkout wheezy
* Stable Jessie → git checkout jessie
* Stretch → master
## Installation
Installation should be done with Ansible.
The role `packweb-apache` will handle all dependencies (Apache, PHP, MariaDB...) installation and configuration.
It will also use the role `webapps/evoadmin-web` to setup the web-interface and management sw
Via ansible avec le role packweb-apache. Le role webapps/evoadmin-web en dépendance se charge de l'installation de l'interface et de ses scripts.
### Manually
### Manuelle
TODO
## Contributing
Contributions are welcome, especially bug fixes. They will be merged in if they are consistent with our conventions and use cases. They might be rejected if they introduce complexity, cover features we don't need or don't fit "style".
### Activation du mode Multi PHP avec des conteneurs LXC
Before starting anything of importance, we suggest opening an issue to discuss what you'd like to add or change.
Installer les paquets nécessaires :
All modifications should be documented in the CHANGELOG file, to help review releases. We encourage atomic commits and with the CHANGELOG in the same commit.
~~~
# apt install lxc debootstrap
~~~
# Workflow
Modifier la configuration de LXC :
The ideal and most typical workflow is to create a branch, based on the `unstable` branch. The branch should have a descriptive name (a ticket/issue number is great). The branch can be treated as a pull-request or merge-request. It should be propery tested and reviewed before merging into `unstable`.
~~~
# cat /etc/lxc/default.conf
Changes that don't introduce significant changes — or that must go faster that the typical workflow — can be commited directly into `unstable`.
# Set the default network virtualization method.
lxc.network.type = none
Hotfixes, can be prepared on a new branch, based on `master` or `unstable` (to be decided by the author). When ready, it can be merged back to `master` for immediate deployment and to `unstable` for proper backporting.
# Mount /home into containers.
lxc.mount.entry = /home home none bind 0 0
Other workflow are not forbidden, but should be discussed in advance.
# Only one tty is enough.
# This require that you disabled others tty ([2-6]) in systemd.
lxc.tty = 1
# Run 64bits containers
lxc.arch = x86_64
# Start containers on boot by default
lxc.start.auto = 1
~~~
Dans cette configuration, les containers LXC n'ont pas leur interface réseau virtualisée. Et /home de l'hôte est partagé dans les containers.
#### PHP 5.6
On installe un conteneur Debian Jessie :
~~~
# lxc-create --name php56 --template debian --bdev dir --logfile /var/log/lxc/lxc-php56.log --logpriority INFO -- --arch amd64 --release jessie
~~~
Puis on installe les paquets PHP 5.6 dans ce conteneur :
~~~
# lxc-start -n php56
# lxc-attach -n php56 apt install php5-fpm php5-cli php5-gd php5-imap php5-ldap php5-mcrypt php5-mysql php5-pgsql php-gettext php5-intl php5-curl php5-ssh2 libphp-phpmailer
~~~
#### PHP 7.0
On installe un conteneur Debian Stretch :
~~~
# lxc-create --name php70 --template debian --bdev dir --logfile /var/log/lxc/lxc-php70.log --logpriority INFO -- --arch amd64 --release stretch
~~~
Puis on installe les paquets PHP 7.0 dans ce conteneur :
~~~
# lxc-start -n php70
# lxc-attach -n php70 apt install php-fpm php-cli php-gd php-intl php-imap php-ldap php-mcrypt php-mysql php-pgsql php-gettext php-curl php-ssh2 composer libphp-phpmailer
~~~
#### PHP 7.3
On installe un conteneur Debian Stretch :
~~~
# lxc-create --name php73 --template debian --bdev dir --logfile /var/log/lxc/lxc-php73.log --logpriority INFO -- --arch amd64 --release stretch
~~~
Puis on installe les paquets PHP 7.3 dans ce conteneur :
~~~
# lxc-start -n php73
# lxc-attach -n php73
# apt-get update && apt-get install -y --no-install-recommends wget apt-transport-https ca-certificates gnupg
# curl https://packages.sury.org/php/apt.gpg | apt-key add
# echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/sury.list
# apt-get update && apt-get install -y --no-install-recommends php7.3 php7.3-fpm php7.3-cli php7.3-curl php7.3-mysql php7.3-pgsql php7.3-ldap php7.3-imap php7.3-gd php-ssh2 php-gettext composer libphp-phpmailer
~~~
#### Pour toutes les versions de PHP
Dans les containers, il faut ajouter le fichier **z-evolinux-defaults.ini** dans le dossier **conf.d** des réglages de PHP FPM et CLI
> Pour PHP5 **/etc/php5/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php5/cli/conf.d/z-evolinux-defaults.ini**
>
> Pour PHP7.0 **/etc/php/7.0/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini**
>
> Pour PHP7.3 **/etc/php/7.3/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php/7.3/cli/conf.d/z-evolinux-defaults.ini**
~~~
[PHP]
short_open_tag = Off
expose_php = Off
display_errors = Off
log_errors = On
html_errors = Off
allow_url_fopen = Off
disable_functions = exec,shell-exec,system,passthru,putenv,popen
~~~
Après cela, il faut redémarrer FPM
~~~
# lxc-attach -n php56 /etc/init.d/php5-fpm restart
# lxc-attach -n php70 /etc/init.d/php7.0-fpm restart
# lxc-attach -n php73 /etc/init.d/php7.3-fpm restart
~~~
Une fois les conteneurs installés, il faut configurer evoadmin-web pour lui indiquer les versions disponibles de PHP dans **/etc/evolinux/web-add.conf** (pour *web-add.sh*) et dans **/home/evoadmin/www/conf/config.local.php** pour l'interface web
~~~
# cat /etc/evolinux/web-add.conf
#(...)
PHP_VERSIONS=(56 70 73)
#(...)
~~~
~~~
# cat /home/evoadmin/www/conf/config.local.php
// (...)
$localconf['php_versions'] = array(70, 73);
// (...)
~~~
#### Apache
Il est nécessaire d'activer le mod proxy pour apache2 si ce n'a pas déjà été fait :
~~~
# a2enmod proxy_fcgi
# systemctl restart apache2.service
~~~
Si vous rencontrez l'erreur "File not found" avec les fichiers php, bien vérifier que le rootfs des conteneurs est en 755 :
~~~
# chmod 755 /var/lib/lxc/php56/rootfs
# chmod 755 /var/lib/lxc/php70/rootfs
# chmod 755 /var/lib/lxc/php73/rootfs
~~~
#### Email
Pour envoyer des mails, on peut installer **ssmtp** qui va forwarder les mails du conteneur vers l'hôte (à faire par conteneur via lxc-attach) :
Avant d'installer le paquet, il faut ajouter le hostname du conteneur dans **/etc/hosts**, sinon la configuration du paquet retourne une erreur :
~~~
127.0.0.1 php70
~~~
~~~
# apt install ssmtp
~~~
Editer **/etc/ssmtp/ssmtp.conf** (remplacer example.com par le hostname complet de votre machine) :
~~~
root=postmaster
mailhub=127.0.0.1
hostname=example.com
FromLineOverride=YES
~~~
#### PHP-CLI
~~~
$ cat /usr/local/bin/exec73
#!/bin/bash
php_cmd=$(printf "/usr/bin/php %q" "$@" )
lxc-attach -n php73 -- su - "$SUDO_USER" -c "$php_cmd"
~~~
Il faut ensuite s'assurer que ce script peut être exécuté via sudo.
## Méthodes de collaboration
Lire le fichier GUIDELINES.
Chaque version stable a le nom de la version Debian dans une branche. (Wheezy, Jessie, …)
On ne touche pas à ces branches, sauf pour corriger un bug critique,
qu'on appellera dans le commit "Hotfix #IDBugRedmine. Description du commit/bug".
Le project leader se charge de merger les futures version (wheezy-dev, jessie-dev, …)
dans la branche stable et de faire un changelog.
Chaque version de redmine est prévu à l'avance dans la roadmap de Redmine.
Quand une version de développement est terminé (tout les bugs fermés),
on utilisera les tags pour se repérer dans l'historique GIT.
Puis une fois que la version est décrété stable, elle sera mergé dans la branche stable.
Pour travailler sur une version spécifique, il faut travailler dans la branche "$release".
Voir les branches sur le remote :
```
$ git branch -r
origin/jessie-dev
origin/wheezy-dev
origin/wheezy
```
Il suffira de « checkout » dessus, et commencer à commiter. Les commits doivent
être nommés "Implement #IDBugRedmine. Description feature." ou
"Fix #IDBugRedmine. Description correction du bug.".
```
$ git checkout wheezy-dev
[…] hack hack […]
$ git commit
$ git push
```
## Licence
Evoadmin-web est un projet [Evolix](https://evolix.com) et est distribué sour licence AGPLv3, voir le fichier [LICENSE](LICENSE) pour les détails.

View file

@ -1,180 +0,0 @@
### Activation du mode Multi PHP avec des conteneurs LXC
Installer les paquets nécessaires :
~~~
# apt install lxc debootstrap
~~~
Modifier la configuration de LXC :
~~~
# cat /etc/lxc/default.conf
# Set the default network virtualization method.
lxc.network.type = none
# Mount /home into containers.
lxc.mount.entry = /home home none bind 0 0
# Only one tty is enough.
# This require that you disabled others tty ([2-6]) in systemd.
lxc.tty = 1
# Run 64bits containers
lxc.arch = x86_64
# Start containers on boot by default
lxc.start.auto = 1
~~~
Dans cette configuration, les containers LXC n'ont pas leur interface réseau virtualisée. Et /home de l'hôte est partagé dans les containers.
#### PHP 5.6
On installe un conteneur Debian Jessie :
~~~
# lxc-create --name php56 --template debian --bdev dir --logfile /var/log/lxc/lxc-php56.log --logpriority INFO -- --arch amd64 --release jessie
~~~
Puis on installe les paquets PHP 5.6 dans ce conteneur :
~~~
# lxc-start -n php56
# lxc-attach -n php56 apt install php5-fpm php5-cli php5-gd php5-imap php5-ldap php5-mcrypt php5-mysql php5-pgsql php-gettext php5-intl php5-curl php5-ssh2 libphp-phpmailer
~~~
#### PHP 7.0
On installe un conteneur Debian Stretch :
~~~
# lxc-create --name php70 --template debian --bdev dir --logfile /var/log/lxc/lxc-php70.log --logpriority INFO -- --arch amd64 --release stretch
~~~
Puis on installe les paquets PHP 7.0 dans ce conteneur :
~~~
# lxc-start -n php70
# lxc-attach -n php70 apt install php-fpm php-cli php-gd php-intl php-imap php-ldap php-mcrypt php-mysql php-pgsql php-gettext php-curl php-ssh2 composer libphp-phpmailer
~~~
#### PHP 7.3
On installe un conteneur Debian Stretch :
~~~
# lxc-create --name php73 --template debian --bdev dir --logfile /var/log/lxc/lxc-php73.log --logpriority INFO -- --arch amd64 --release stretch
~~~
Puis on installe les paquets PHP 7.3 dans ce conteneur :
~~~
# lxc-start -n php73
# lxc-attach -n php73
# apt-get update && apt-get install -y --no-install-recommends wget apt-transport-https ca-certificates gnupg
# curl https://packages.sury.org/php/apt.gpg | apt-key add
# echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/sury.list
# apt-get update && apt-get install -y --no-install-recommends php7.3 php7.3-fpm php7.3-cli php7.3-curl php7.3-mysql php7.3-pgsql php7.3-ldap php7.3-imap php7.3-gd php-ssh2 php-gettext composer libphp-phpmailer
~~~
#### Pour toutes les versions de PHP
Dans les containers, il faut ajouter le fichier **z-evolinux-defaults.ini** dans le dossier **conf.d** des réglages de PHP FPM et CLI
> Pour PHP5 **/etc/php5/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php5/cli/conf.d/z-evolinux-defaults.ini**
>
> Pour PHP7.0 **/etc/php/7.0/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini**
>
> Pour PHP7.3 **/etc/php/7.3/fpm/conf.d/z-evolinux-defaults.ini** et **/etc/php/7.3/cli/conf.d/z-evolinux-defaults.ini**
~~~
[PHP]
short_open_tag = Off
expose_php = Off
display_errors = Off
log_errors = On
html_errors = Off
allow_url_fopen = Off
disable_functions = exec,shell-exec,system,passthru,putenv,popen
~~~
Après cela, il faut redémarrer FPM
~~~
# lxc-attach -n php56 /etc/init.d/php5-fpm restart
# lxc-attach -n php70 /etc/init.d/php7.0-fpm restart
# lxc-attach -n php73 /etc/init.d/php7.3-fpm restart
~~~
Une fois les conteneurs installés, il faut configurer evoadmin-web pour lui indiquer les versions disponibles de PHP dans **/etc/evolinux/web-add.conf** (pour *web-add.sh*) et dans **/home/evoadmin/www/conf/config.local.php** pour l'interface web
~~~
# cat /etc/evolinux/web-add.conf
#(...)
PHP_VERSIONS=(56 70 73)
#(...)
~~~
~~~
# cat /home/evoadmin/www/conf/config.local.php
// (...)
$localconf['php_versions'] = array(70, 73);
// (...)
~~~
#### Apache
Il est nécessaire d'activer le mod proxy pour apache2 si ce n'a pas déjà été fait :
~~~
# a2enmod proxy_fcgi
# systemctl restart apache2.service
~~~
Si vous rencontrez l'erreur "File not found" avec les fichiers php, bien vérifier que le rootfs des conteneurs est en 755 :
~~~
# chmod 755 /var/lib/lxc/php56/rootfs
# chmod 755 /var/lib/lxc/php70/rootfs
# chmod 755 /var/lib/lxc/php73/rootfs
~~~
#### Email
Pour envoyer des mails, on peut installer **ssmtp** qui va forwarder les mails du conteneur vers l'hôte (à faire par conteneur via lxc-attach) :
Avant d'installer le paquet, il faut ajouter le hostname du conteneur dans **/etc/hosts**, sinon la configuration du paquet retourne une erreur :
~~~
127.0.0.1 php70
~~~
~~~
# apt install ssmtp
~~~
Editer **/etc/ssmtp/ssmtp.conf** (remplacer example.com par le hostname complet de votre machine) :
~~~
root=postmaster
mailhub=127.0.0.1
hostname=example.com
FromLineOverride=YES
~~~
#### PHP-CLI
~~~
$ cat /usr/local/bin/exec73
#!/bin/bash
php_cmd=$(printf "/usr/bin/php %q" "$@" )
lxc-attach -n php73 -- su - "$SUDO_USER" -c "$php_cmd"
~~~
Il faut ensuite s'assurer que ce script peut être exécuté via sudo.

7
TODO Normal file
View file

@ -0,0 +1,7 @@
* Verification des paramètres passés dans le script ftpadmin.sh
* Vérifier lors de la suppression que c'est bien la personne a qui appartient le compte qui lance la commande
* Tableau "sortable" (TableKit ?)
* Mettre en place EvoLog et logger la sortie des scripts
* Validation plus (très) stricte sur les entrées de formulaire
* Listage des comptes utilisateurs
* Total espace disque FTP

View file

@ -8,35 +8,36 @@
* $Id: config.php 273 2009-05-12 13:54:50Z tmartin $
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
// Email pour les notifications
$oriconf['admin']['mail'] = 'admin@example.com';
$oriconf['techmail'] = 'jdoe@example.com';
$oriconf['debug'] = false;
$oriconf['debug'] = FALSE;
$oriconf['superadmin'] = array('superadmin');
$oriconf['script_path'] = '/usr/share/scripts/evoadmin';
$oriconf['cluster'] = false;
$oriconf['cluster'] = FALSE;
$oriconf['servers'] = array('servers');
$oriconf['cache'] = '/home/evoadmin/www/cache.sqlite';
$oriconf['known_host'] = '/home/evoadmin/www/known_host';
$oriconf['ftpadmin'] = false;
$oriconf['bindadmin'] = false;
// Warning: Don't forget to add available PHP versions into : /etc/evolinux/web-add.conf
// $oriconf['php_versions'] = array();
$oriconf['quota'] = false;
$oriconf['dbadmin'] = false;
$oriconf['ftpadmin'] = FALSE;
$oriconf['bindadmin'] = FALSE;
// Penser à rajouter également les versions de PHP disponibles dans /etc/evolinux/web-add.conf
$oriconf['php_versions'] = array();
$oriconf['quota'] = FALSE;
$oriconf['dbadmin'] = FALSE;
$oriconf['noreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
$oriconf['postponedreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
$oriconf['immediatereplication'] = array('srv00.example.com', 'srv01.example.com');
$oriconf['postponedreplication_mode'] = array('1 fois/jour', '3 fois/jour', '1 fois/jour');
// Generate password hashes : mkpasswd --method=sha-512 (cli) or with PHP's password_hash()
// auth (sha256 hashs)
$oriconf['logins'] = array();
//$oriconf['logins']['foo'] = '$6$X0jqa/ausLSBkj4m$dLMMcPGVxak.aDPo4V/GJLm2d8vU8/QA5LbGTuqXCdxSNYU0kRKBgDl16GAyp0GqXXZ5wwDEJKQ1npgFwiuV81';
//$oriconf['logins']['bar'] = '$6$Q6233S6mlWAF6p.j$LtzwG02YucozwqjAgSpeldh24Mnz7lBuVSbOQYbKKh9FiUx3tMVl6kJZkmrNdPqeadFXKAYXrqn.gy8KposF5.';
//$oriconf['logins']['foo'] = 'd5d3c723fb82cb0078f399888af78204234535ec2ef3da56710fdd51f90d2477';
//$oriconf['logins']['bar'] = '7938c84d6e43d1659612a7ea7c1101ed02e52751bb64597a8c20ebaba8ba4303';

View file

@ -461,13 +461,13 @@ class AlphaNumericalTextInputFormField extends FormField {
class DomainInputFormField extends FormField {
protected $mandatory = NULL;
//protected $textsize = NULL;
protected $textsize = NULL;
public function __construct($label, $mandatory=TRUE, $hidden=FALSE) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->hidden = $hidden;
//$this->textsize = $textsize;
$this->textsize = $textsize;
}
public function verify($set_error) {
@ -491,7 +491,7 @@ class DomainInputFormField extends FormField {
else
$input .= '<input type="text" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'" value="'.htmlspecialchars($this->value,ENT_QUOTES).'"';
//$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
if($this->read_only) { $input .= 'readonly="readonly="'; }
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';
@ -516,12 +516,12 @@ class DomainInputFormField extends FormField {
class DomainListInputFormField extends FormField {
protected $mandatory = NULL;
//protected $textsize = NULL;
protected $textsize = NULL;
public function __construct($label, $mandatory=TRUE) {
parent::__construct($label);
$this->mandatory = $mandatory;
//$this->textsize = $textsize;
$this->textsize = $textsize;
}
public function verify($set_error) {
@ -547,7 +547,7 @@ class DomainListInputFormField extends FormField {
$input = '';
$input .= '<input type="text" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'" value="'.htmlspecialchars($this->value,ENT_QUOTES).'"';
//$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
if($this->read_only) { $input .= 'readonly="readonly="'; }
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';

View file

@ -1,4 +1,5 @@
<?php
/**
* file included in every PHP file
*
@ -96,25 +97,6 @@ function is_multiphp() {
return array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1;
}
/**
* Webadd
*
* @return boolean - True when it's a multi PHP system
*/
function run_webadd_cmd($command) {
global $conf;
$cmd = 'web-add.sh '. $command;
$data_output = null;
$exec_return = null;
sudoexec($cmd, $data_output, $exec_return);
return $data_output;
}
/**
* Includes
*/

View file

@ -30,10 +30,6 @@ h1#top {
margin-bottom: 10px;
}
h3.form-error {
color: red;
}
div#disclaimer {
margin-top: 30px;
}
@ -139,11 +135,6 @@ span.form-error {
margin-left: 4px;
}
span.form-warning {
color: #E84D0C;
margin-left: 4px;
}
span.form-mandatory {
color: red;
}
@ -172,3 +163,4 @@ form#form-add legend {
form#form-add p {
text-align: left;
}

View file

@ -21,12 +21,6 @@ function switch_disabled(name) {
}
document.observe("dom:loaded", function() {
if (document.getElementById('vhost-delete-db') != null) {
document.getElementById('vhost-delete-db').onclick = function() {
console.log("clicked box");
switch_disabled('vhost-dbname');
}
}
document.getElementById('password_random').onclick = function() {
switch_disabled('password');
}

View file

@ -30,7 +30,7 @@ header('Content-Type: text/html; charset=utf-8');
/**
* Requires
*/
require_once EVOADMIN_BASE . '../inc/common.php';
require_once EVOADMIN_BASE . 'common.php';
$uri = $_SERVER['REQUEST_URI'];
@ -48,47 +48,26 @@ if (!array_key_exists('auth', $_SESSION) || $_SESSION['auth']!=1) {
include_once EVOADMIN_BASE . '../inc/webadmin.php';
} elseif (preg_match('#^/webadmin?#', $uri)) {
} elseif (preg_match('#^/webadmin/(.*)/domain/?(edit)?/?(.*)?/$#', $uri, $params)) {
// Redirect to /webadmin in order to set $_SESSION['non_stanard']
if (!isset($_SESSION['non_standard']))
http_redirect('/webadmin');
include_once EVOADMIN_BASE . '../inc/webadmin-servername.php';
// block the non-standard vhost modification
if (in_array(htmlspecialchars(basename($_SERVER['REDIRECT_URL'])), $_SESSION['non_standard']))
http_redirect('/webadmin');
} elseif (preg_match('#^/webadmin/(.*)/itk/?(enable|disable)?/?(.*)?/$#', $uri, $params)) {
if (preg_match('#^/webadmin/(.*)/domain/?(edit)?/?(.*)?/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-itk.php';
include_once EVOADMIN_BASE . '../inc/webadmin-servername.php';
} elseif (preg_match('#^/webadmin/(.*)/php/$#', $uri, $params)) {
} elseif (preg_match('#^/webadmin/(.*)/itk/?(enable|disable)?/?(.*)?/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-php.php';
include_once EVOADMIN_BASE . '../inc/webadmin-itk.php';
} elseif (preg_match('#^/webadmin/(.*)/alias/?(add|delete)?/?(.*)?/$#', $uri, $params)) {
} elseif (preg_match('#^/webadmin/(.*)/php/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-edit.php';
include_once EVOADMIN_BASE . '../inc/webadmin-php.php';
} elseif (preg_match('#^/webadmin/suppr/(.*)/?$#', $uri, $params)) {
} elseif (preg_match('#^/webadmin/(.*)/alias/?(add|delete)?/?(.*)?/$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-suppr.php';
include_once EVOADMIN_BASE . '../inc/webadmin-edit.php';
} elseif (preg_match('#^/webadmin/delete/(.*)/?$#', $uri, $params)) {
//TODO: fix according to route naming convention
include_once EVOADMIN_BASE . '../inc/webadmin-delete.php';
} elseif (preg_match('#^/webadmin/suppr/(.*)/?$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-suppr.php';
} elseif (preg_match('#^/webadmin/(.*)/letsencrypt/?$#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/webadmin-letsencrypt.php';
} else {
http_redirect('/webadmin');
}
} elseif (is_superadmin() && preg_match('#^/accounts/?#', $uri, $params)) {
include_once EVOADMIN_BASE . '../inc/accounts.php';

View file

@ -53,7 +53,7 @@ function web_add($form, $admin_mail) {
}
}
if (array_key_exists('php_versions', $conf) && is_array($conf['php_versions'])) {
if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) {
$exec_cmd .= sprintf(' -r %s', $conf['php_versions'][$form->getField('php_version')->getValue()]);
}
@ -347,7 +347,7 @@ if ($conf['bindadmin']) {
$form->addField('use_gmail_mxs', new CheckboxInputFormField("Utilisation des serveurs Gmail en MX&nbsp;?", FALSE));
}
if (array_key_exists('php_versions', $conf) && is_array($conf['php_versions'])) {
if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) {
$form->addField('php_version', new SelectFormField("Version de PHP", TRUE, $conf['php_versions']));
}

View file

@ -1,53 +1,43 @@
<?php
/**
* Authentification controler
* Authentification page
*
* Copyright (c) 2009-2022 Evolix - Tous droits reserves
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* @author Evolix <info@evolix.fr>
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @author and others.
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST)) {
$input_username = $_POST['login'];
$input_password = $_POST['passw'];
if ((empty($_GET['form']) || $_GET['form']!=1) && !empty($_POST)) {
$username=$_POST['login'];
$password=$_POST['passw'];
if (isset($conf['logins'][$input_username]) && strlen($conf['logins'][$input_username]) != 64 && password_verify($input_password, $conf['logins'][$input_username]) ) {
$_SESSION['auth'] = true;
$_SESSION['user'] = $input_username;
$_SESSION['user_id'] = posix_getpwnam($input_username) ? posix_getpwnam($input_username)['uid'] : 65534;
$_SESSION['cli_version'] = run_webadd_cmd('version')[0];
unset($_SESSION['error']);
} elseif (isset($conf['logins'][$input_username]) && strlen($conf['logins'][$input_username]) == 64 && hash("sha256",$input_password) === $conf['logins'][$input_username]) {
// Compatibility mode for previous installs (sha256)
$_SESSION['auth'] = true;
$_SESSION['user'] = $input_username;
$_SESSION['user_id'] = posix_getpwnam($input_username) ? posix_getpwnam($input_username)['uid'] : 65534;
$_SESSION['cli_version'] = run_webadd_cmd('version')[0];
unset($_SESSION['error']);
} else {
$_SESSION['auth'] = false;
$_SESSION['user'] = '';
$_SESSION['error'] = true;
}
http_redirect('/');
if (hash("sha256",$password) == $conf['logins'][$username]) {
$_SESSION['auth']=1;
$_SESSION['user']=$username;
$_SESSION['error']='';
} else {
$_SESSION['auth']=0;
$_SESSION['user']='';
$_SESSION['error']=1;
}
http_redirect('/');
} else {
if (!empty($_SESSION['error'])) {
$error = $_SESSION['error'];
unset($_SESSION['error']);
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/auth.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
if(!empty($_SESSION['error'])) {
$error=$_SESSION['error'];
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/auth.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,72 +0,0 @@
<?php
/**
* Apache VirtualHost Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
require_once EVOADMIN_BASE . '../lib/bdd.php';
require_once EVOADMIN_BASE . '../lib/domain.php';
global $conf;
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
if (isset($_POST['delete-vhost'])) {
$domain = $params[1];
while(true) {
// Errors handling
if (empty($_POST['vhost-name'])) {
print "<p>Veuillez entrer le nom du compte web à supprimer.</p>";
printf ('<p><a href="%s">Retour</a></p>', $_SERVER['REDIRECT_URL']);
break;
}
if ($_POST['vhost-name'] !== $domain) {
print "Le nom de compte ne correspond pas.";
printf ('<p><a href="%s">Retour</a></p>', $_SERVER['REDIRECT_URL']);
break;
}
if (isset($_POST['vhost-delete-db']) && empty($_POST['vhost-dbname'])) {
print "Veuillez spécifier un nom de base de données.";
printf ('<p><a href="%s">Retour</a></p>', $_SERVER['REDIRECT_URL']);
break;
}
// Shell arguments
if (!empty($_POST['vhost-dbname']))
$exec_cmd = "web-add.sh del -y " . $domain . " " . $_POST['vhost-dbname'];
else
$exec_cmd = "web-add.sh del -y " . $domain;
// Execute script
sudoexec($exec_cmd, $exec_output, $exec_return);
// Deal with response code
if ($exec_return == 0)
print "<p>Compte supprimé.</p>";
else
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
break;
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} else {
include_once EVOADMIN_BASE . '../tpl/webadmin-delete.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,11 +1,11 @@
<?php
/**
* Apache VirtualHost Management Page
* Apache VirtualHost Management Page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
@ -68,10 +68,10 @@ if (isset($params[2]) && $params[2] == "delete") {
sudoexec($exec_cmd, $exec_output, $exec_return);
if ($exec_return == 0) {
if (! $bdd->del_serveralias($serveralias))
if (! $bdd->del_serveralias($serveralias))
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
printf ('<p>Alias %s est supprimé.</p>', $serveralias['alias']);
} else
} else
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
}
@ -134,7 +134,7 @@ elseif (isset($params[2]) && $params[2] == "add") {
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
'alias' => $form->getField('domain_alias')->getValue(),
);
$account_name=$serveralias['domain'];
$account = $bdd->get_account($account_name);
@ -214,7 +214,7 @@ elseif (isset($params[2]) && $params[2] == "add") {
}
else {
print "<center>";
printf ('<p>Echec dans la creation de l\'alias %s</p>', $serveralias['alias']);
printf ('<p>Echec dans la creation de l\'alias %s du domaine %s</p>', $serveralias['alias'], $serveralias['domain']);
print ('<p>L\'alias existe dans d\'autres vhosts.');
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
print "</center>";
@ -222,10 +222,10 @@ elseif (isset($params[2]) && $params[2] == "add") {
}
}
else {
print "<h2>Ajout d'un alias</h2><hr>";
print "<h2>Ajout d'un serveralias</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Ajout d'un alias</legend>";
print " <legend>Ajout d'un serveralias</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
print " </fieldset>";
@ -233,10 +233,10 @@ elseif (isset($params[2]) && $params[2] == "add") {
}
} else {
print "<h2>Ajout d'un alias</h2><hr>";
print "<h2>Ajout d'un serveralias</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Ajout d'un alias</legend>";
print " <legend>Ajout d'un serveralias</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
print " </fieldset>";

View file

@ -19,9 +19,10 @@ require_once EVOADMIN_BASE . '../lib/domain.php';
global $conf;
if (isset($params[2]) && $params[2] != "") {
$redirect_url = "/webadmin/" . $params[1] . "/itk/";
if (isset($params[3]) && $params[3] == "") http_redirect($redirect_url);
require_once EVOADMIN_BASE . '../evolibs/Form.php';
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
@ -29,32 +30,36 @@ if (isset($params[2]) && $params[2] != "") {
$servername = array (
'domain' => $params[1],
'servername' => $params[3]
);
if ($params[2] == "enable") {
$enable_cmd = 'web-add.sh enable-user-itk ' . $servername['domain'];
$enable_cmd = 'web-add.sh enable-user-itk ' . $servername['servername'] . ' ' . $servername['domain'];
sudoexec($enable_cmd, $enable_cmd_output, $enable_cmd_return);
sudoexec($enable_cmd, $enable_cmd_output, $enable_cmd_return);
if ($enable_cmd_return == 0) {
print 'Sécurité ITK activée.';
printf ('<p><a href="%s">Retour à la gestion ITK</a></p>', $redirect_url);
}
if ($enable_cmd_return == 0) {
print 'Sécurité ITK activée.';
printf ('<p><a href="%s">Retour à la gestion ITK</a></p>', $redirect_url);
}
}
elseif ($params[2] == "disable") {
$disable_cmd = 'web-add.sh disable-user-itk ' . $servername['domain'];
$disable_cmd = 'web-add.sh disable-user-itk ' . $servername['servername'] . ' ' . $servername['domain'];
sudoexec($disable_cmd, $disable_cmd_output, $disable_cmd_return);
sudoexec($disable_cmd, $disable_cmd_output, $disable_cmd_return);
if ($disable_cmd_return == 0) {
print 'Sécurité ITK désactivée';
printf ('<p><a href="%s">Retour à la gestion ITK</a></p>', $redirect_url);
}
if ($disable_cmd_return == 0) {
print 'Sécurité ITK désactivée';
printf ('<p><a href="%s">Retour à la gestion ITK</a></p>', $redirect_url);
}
}
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
} else {
}
else {
$domain = $params[1];
$data_list = array();
// TODO: adapt for cluster mode
if ($conf['cluster']) {
@ -78,17 +83,33 @@ if (isset($params[2]) && $params[2] != "") {
$alias_list = $bdd->list_serveralias($domain);
}
else {
$cmd_itk = 'web-add.sh list-user-itk ' . $domain;
$cmd = 'web-add.sh list-servername ' . $domain;
if(!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
}
sudoexec($cmd, $data_output, $exec_return);
# à revérifier (notamment gestion erreurs)
if ($exec_return == 0) {
foreach($data_output as $data_line) {
$cmd_itk = 'web-add.sh list-user-itk ' . $data_line . ' ' . $domain;
sudoexec($cmd_itk, $data_output_itk, $exec_return_itk);
$user_itk = $data_output_itk[0];
# on prend le premier résultat du tableau, ne fonctionne pas s'il y a plusieurs la même ligne ou des commentaires etc.
array_push($data_list, ['servername' => $data_line, 'user' => $data_output_itk[0]]);
unset($data_output_itk); # reset variable pour éviter conflits
}
}
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
include_once EVOADMIN_BASE . '../tpl/webadmin-itk.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,168 +0,0 @@
<?php
require_once EVOADMIN_BASE . '../lib/letsencrypt.php';
use lib\LetsEncrypt as letsencryt;
// store domain and aliases in session
if (!isset($_SESSION['lestencrypt-domains']) || empty($_SESSION['letsencrypt-domains'])) {
$domain = $params[1];
$cmd = 'web-add.sh list-vhost ' . $domain;
sudoexec($cmd, $data_output, $exec_return);
$data_split = explode(':', $data_output[0]);
$aliases = explode(',', $data_split[3]);
$domains = array();
// store domain and aliases
array_push($domains, $data_split[2]);
foreach ($aliases as $alias) {
array_push($domains, $alias);
}
$_SESSION['letsencrypt-domains'] = array_filter($domains);
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$letsencrypt = new letsencryt();
$errorMessage = '';
$warningMessage = '';
if (isset($_POST['submit'])) {
while (true) {
// check HTTP
$isRemoteResourceAvailable = $letsencrypt->checkRemoteResourceAvailability($_SESSION['letsencrypt-domains'][0]);
if (!$isRemoteResourceAvailable) {
$errorMessage = "Erreur : Le challenge HTTP a échoué.<br>
Merci de vérifier que le dossier <code>/.well-known/evoacme-challenge/</code> est accessible.";
break;
}
// check DNS
$valid_domains = $letsencrypt->checkDNSValidity($_SESSION['letsencrypt-domains']);
$failed_domains = array_diff($_SESSION['letsencrypt-domains'], $valid_domains);
if (!empty($failed_domains)) {
$errorMessage = "Erreur : La vérification DNS a échoué.<br>
Merci de vérifier les enregistrements de type A et AAAA pour les domaine(s) suivant(s) :";
break;
}
// make csr
$isCsrGenerated = $letsencrypt->makeCsr($params[1], $_SESSION['letsencrypt-domains']);
if (!$isCsrGenerated) {
$errorMessage = "Erreur : La génération de demande de certificat a échoué.<br>
Merci de contacter un administrateur pour continuer.";
break;
}
// evoacme TEST
$testGenerateCert = $letsencrypt->generateSSLCertificate($params[1]);
if (!$testGenerateCert) {
$errorMessage = "Erreur : La génération de certificat en mode TEST a échoué.<br>
Merci de contacter un administrateur pour continuer.";
break;
}
// evoacme
$generateCert = $letsencrypt->generateSSLCertificate($params[1], false);
if (!$generateCert) {
$errorMessage = "Erreur : La génération de certificat a échoué.<br>
Merci de contacter un administrateur pour continuer.";
break;
}
break;
}
} else {
$validUntil = '';
while(true) {
// check domains list
if (empty($_SESSION['letsencrypt-domains'])) {
$errorMessage = "Erreur : la liste des domaines est vide.";
break;
}
// check if evoacme is installed
$binaries_installed = $letsencrypt->isEvoacmeInstalled();
if (!$binaries_installed) {
$errorMessage = "Erreur : les binaires Evoacme ne sont pas installés.
Veuillez contacter un administrateur.";
break;
}
// Check existing SSL certificate
$domainsIncluded = array();
foreach ($_SESSION['letsencrypt-domains'] as $domain) {
$existingSSLCertificate = $letsencrypt->getCertificate($domain);
// if no certificate is present (false returned) for this domain, go to the next domain
if (is_bool($existingSSLCertificate)) {
continue;
}
$parsedCertificate = $letsencrypt->parseCertificate($existingSSLCertificate);
// check if LE is the certificate issuer
$isIssuerValid = $letsencrypt->isCertIssuedByLetsEncrypt($parsedCertificate["issuer"]);
if (!$isIssuerValid) {
$errorMessage = "Erreur : le certificat existant n'est pas géré par Let's Encrypt.";
break 2; // break the foreach and the while
}
// check wether the certificate is valid or expired
$isCertValid = $letsencrypt->isCertValid($parsedCertificate["validUntil"]);
if (!$isCertValid && !isset($_POST['force_renew'])) {
$warningMessage = "Attention : le certificat existant n'est plus valide.
Souhaitez-vous le renouveller ?";
break 2;
} else {
$validUntil = date("d/m/Y", $parsedCertificate["validUntil"]);
}
// check if the domain is already in the certificate
$isDomainIncluded = $letsencrypt->isDomainIncludedInCert($domain, $parsedCertificate["includedDomains"]);
if ($isDomainIncluded) {
array_push($domainsIncluded, $domain);
continue; // break only the current foreach iteration
}
}
// contains all the domains included in the existing certificate
if (!empty($domainsIncluded) && !isset($_POST['force_renew'])) {
$domainsNotIncluded = array_diff($_SESSION['letsencrypt-domains'], $domainsIncluded);
if (empty($domainsNotIncluded)) {
$errorMessage = "Le certificat existant couvre déjà tous les domaines jusqu'au " . $validUntil . ".";
break;
}
$warningMessage = "Attention : le certificat existant couvre déjà le(s) domaine(s) jusqu'au " . $validUntil . " :<br>";
foreach ($domainsIncluded as $domainIncluded) {
$warningMessage .= $domainIncluded . "<br>";
}
$warningMessage .= "<br><strong>En confirmant le renouvellement, vous allez ajouter :</strong><br>";
foreach ($domainsNotIncluded as $domainNotIncluded) {
$warningMessage .= $domainNotIncluded . "<br>";
}
break;
}
break;
}
}
include_once EVOADMIN_BASE . '../tpl/webadmin-letsencrypt.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';

View file

@ -28,8 +28,8 @@ if (isset($params[2]) && $params[2] == "edit") {
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
$form = new FormPage("Modification du Servername", FALSE);
$form->addField('domain_servername', new DomainInputFormField("Servername", TRUE), $params[3]);
$form = new FormPage("Modification du ServerName", FALSE);
$form->addField('domain_servername', new DomainInputFormField("ServerName", TRUE), $params[3]);
$form->addField('previous_servername', new DomainInputFormField("", TRUE, TRUE), $params[3]);
if (!empty($_POST)) {
@ -126,40 +126,40 @@ if (isset($params[2]) && $params[2] == "edit") {
if ($exec_return == 0) {
//domain_add($serveralias['alias'], gethostbyname($master) , false); TODO avec l'IP du load balancer
print "<center>";
printf ('<p>Le Servername %s a bien été modifié</p>', $servername['servername']);
printf ('<p><a href="%s">Retour à la liste des Servernames</a></p>', $redirect_url);
printf ('<p>Le ServerName %s a bien été modifié</p>', $servername['servername']);
printf ('<p><a href="%s">Retour à la liste des ServerNames</a></p>', $redirect_url);
print "</center>";
}
else {
print "<center>";
printf ('<p>Echec dans la modification du Servername %s</p>', $servername['servername']);
printf ('<p><a href="%s">Retour à la liste des Servernames</a></p>', $redirect_url);
printf ('<p>Echec dans la modification du ServerName %s</p>', $servername['servername']);
printf ('<p><a href="%s">Retour à la liste des ServerNames</a></p>', $redirect_url);
print "</center>";
}
}
else {
print "<center>";
printf ('<p>Echec dans la modification du Servername %s</p>', $servername['servername']);
printf ('<p>Echec dans la modification du ServerName %s</p>', $servername['servername']);
print ('<p>Le domaine existe déjà dans d\'autres vhosts.');
printf ('<p><a href="%s">Retour à la liste des Servernames</a></p>', $redirect_url);
printf ('<p><a href="%s">Retour à la liste des ServerNames</a></p>', $redirect_url);
print "</center>";
}
}
} else {
print "<h2>Modification du Servername</h2><hr>";
print "<h2>Modification du ServerName</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Modification du Servername</legend>";
print " <legend>Modification du ServerName</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Modifier\"/></p>";
print " </fieldset>";
print "</form>";
}
} else {
print "<h2>Modification du Servername</h2><hr>";
print "<h2>Modification du ServerName</h2><hr>";
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
print " <fieldset>";
print " <legend>Modification du Servername</legend>";
print " <legend>Modification du ServerName</legend>";
print $form;
print " <p><input type=\"submit\" value=\"Modifier\"/></p>";
print " </fieldset>";
@ -197,15 +197,17 @@ if (isset($params[2]) && $params[2] == "edit") {
$alias_list = $bdd->list_serveralias($domain);
}
else {
$cmd = 'web-add.sh list-vhost ' . $domain;
$cmd = 'web-add.sh list-servername ' . $domain;
if(!is_superadmin()) {
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
}
sudoexec($cmd, $data_output, $exec_return);
$data_vhost = explode(':', $data_output[0]);
$servername = $data_vhost[2];
foreach($data_output as $data_line) {
array_push($servername_list, $data_line);
}
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';

View file

@ -30,12 +30,6 @@ if (!$conf['cluster']) {
/* Récupération de cette liste dans le tableau $vhost_list */
$vhost_list = array();
if (!isset($_SESSION['non_standard'])) {
$_SESSION['non_standard'] = array();
}
foreach($data_output as $data_line) {
$data_split = explode(':', $data_line);
@ -78,11 +72,6 @@ if (!$conf['cluster']) {
$occupation = "";
}
// current vhost isn't standard and thus not manageable by evoadmin-web
if (!$data_split[9] && (!in_array($data_split[0], $_SESSION['non_standard']))) {
array_push($_SESSION['non_standard'], $data_split[0]);
}
array_push($vhost_list, array(
'owner' => $data_split[0],
'configid' => $data_split[1],

View file

@ -1,217 +0,0 @@
<?php
namespace lib;
/**
* LetsEncrypt
*/
class LetsEncrypt
{
const HTTP_OK = 200;
const HTTP_CHALLENGE_URL = '/.well-known/acme-challenge/testfile';
/**
* create the file used to test the HTTP challenge
*/
private function createFileHttpChallenge()
{
$cmd = 'web-add.sh manage-http-challenge-file create';
sudoexec($cmd, $data_output, $exec_return);
}
/**
* delete the file used to test the HTTP challenge
*/
private function deleteFileHttpChallenge()
{
$cmd = 'web-add.sh manage-http-challenge-file delete';
sudoexec($cmd, $data_output, $exec_return);
}
/**
* generate a CSR
* @param string $vhost
* @param Array $domains
* @return boolean
*/
public function makeCsr($vhost, $domains)
{
$domains = implode(' ', $domains);
$cmd = 'web-add.sh generate-csr ' . $vhost . ' ' . "$domains";
sudoexec($cmd, $data_output, $exec_return);
if ($exec_return == 0) {
return true;
}
return false;
}
/**
* Generate a SSL certificate
* @param string $vhost
* @param boolean $test generate in TEST mode or not
* @return boolean
*/
public function generateSSLCertificate($vhost, $test = true)
{
$cmd = 'web-add.sh generate-ssl-certificate ' . $vhost . ' ' . ($test ? "true" : "false");
sudoexec($cmd, $data_output, $exec_return);
if ($exec_return == 0) {
return true;
}
return false;
}
/**
* perform a cURL call on the remote resource
* the cURL call follows redirections
* @param Array $domains list of domains
* @return boolean
*/
public function checkRemoteResourceAvailability($domain)
{
$this->createFileHttpChallenge();
$curl_handler = curl_init();
// setting cURL options
curl_setopt($curl_handler, CURLOPT_URL, $domain . self::HTTP_CHALLENGE_URL);
curl_setopt($curl_handler, CURLOPT_TIMEOUT, 3);
curl_setopt($curl_handler, CURLOPT_HEADER, true);
curl_setopt($curl_handler, CURLOPT_NOBODY, true);
curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl_handler, CURLOPT_MAXREDIRS, 3);
curl_setopt($curl_handler, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true);
curl_exec($curl_handler);
$returned_http_code = curl_getinfo($curl_handler, CURLINFO_HTTP_CODE);
$returned_http_url = curl_getinfo($curl_handler, CURLINFO_EFFECTIVE_URL);
$this->deleteFileHttpChallenge();
if ($returned_http_code === self::HTTP_OK && strpos($returned_http_url, self::HTTP_CHALLENGE_URL)) {
$returned_http_url = str_replace(self::HTTP_CHALLENGE_URL, '', $returned_http_url);
$returned_http_url = preg_replace('#^https?://#', '', $returned_http_url);
return true;
}
return false;
}
/**
* Query the corresponding IP for each domain
* @param Array $domains list of HTTP checked domains
* @return Array $valid_dns_domains list of valid domains
*/
public function checkDNSValidity($domains)
{
$valid_dns_domains = array();
$serverIP = exec("ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\\1/p'");
foreach ($domains as $domain) {
//FQDN syntax
$domain .= '.';
$dns_record_ipv4 = dns_get_record($domain, DNS_A);
$dns_record_ipv6 = dns_get_record($domain, DNS_AAAA);
if ($dns_record_ipv4[0]['ip'] === $serverIP || $dns_record_ipv6[0]['ip'] === $serverIP) {
// remove the last dot added for the FQDN syntax
$domain = rtrim($domain, '.');
array_push($valid_dns_domains, $domain);
}
}
return $valid_dns_domains;
}
/**
* check the presence of make-csr and evoacme binaries
* @return boolean
*/
public function isEvoacmeInstalled()
{
$output_make_csr = shell_exec("which make-csr");
$output_evoacme = shell_exec("which evoacme");
if (empty($output_make_csr) || empty($output_evoacme)) {
return false;
}
return true;
}
/**
* Retrieve the SSL certificate from the URL
* @param string $domain
* @return Array|false $cont list of parameters of the certificate, or false
*/
public function getCertificate($domain)
{
$stream = stream_context_create(array("ssl" => array("capture_peer_cert" => true)));
$read = stream_socket_client("ssl://" . $domain . ":443", $errno, $errstr, 10, STREAM_CLIENT_CONNECT, $stream);
if ($read === false) {
return false;
}
$cont = stream_context_get_params($read);
return $cont;
}
/**
* Parse the certificat arguments and extract data
* @param Array $certificateParameters certificat arguments
* @return Array $infosCert contains only the issuer, domains and expiration date
*/
public function parseCertificate($certificateParameters)
{
$infosCert = array();
$parsedParameters = openssl_x509_parse($certificateParameters["options"]["ssl"]["peer_certificate"]);
$issuer = $parsedParameters["issuer"]["O"];
$includedDomains = $parsedParameters["extensions"]["subjectAltName"];
$validUntil = $parsedParameters["validTo_time_t"];
$infosCert["issuer"] = $issuer;
$infosCert["includedDomains"] = $includedDomains;
$infosCert["validUntil"] = $validUntil;
return $infosCert;
}
/**
* Check wether the certificat is issued by Let's Encrypt or not
* @param string $issuer name of the certificat issuer
* @return boolean
*/
public function isCertIssuedByLetsEncrypt($issuer)
{
return ($issuer === "Let's Encrypt") ? true : false;
}
/**
* Check wether the certificat is valid or not
* @param string $timestampCertValidUntil certificat expiration date in timestamp
* @return boolean
*/
public function isCertValid($timestampCertValidUntil)
{
$currentDate = time();
return ($timestampCertValidUntil > $currentDate) ? true : false;
}
public function isDomainIncludedInCert($domainRequested, $san)
{
$san = preg_replace('/DNS:| DNS:/', '', $san);
$sanArray = explode(',', $san);
return (in_array($domainRequested, $sanArray)) ? true : false;
}
}

View file

@ -0,0 +1,32 @@
#!/bin/bash
vhost=$1
dryrun=${2:-no}
echo "$0 $@ invocated at $(date -R)" >> /var/log/evoacme-wrapper.log
if [[ -f /etc/letsencrypt/${vhost}/live/fullchain.pem ]]; then
echo "Le certificat est déjà en place ! Ouvrir un ticket si il faut ajouter un domaine au certificat."
openssl x509 -text -in /etc/letsencrypt/${vhost}/live/fullchain.pem | grep -e etc -e CN= -e DNS: -e After;
exit 1
fi
if [[ ! -f /etc/ssl/requests/${vhost}.csr ]]; then
source /usr/share/scripts/evoadmin/evoacme.sh $1
fi
if [[ "$dryrun" == "dry-run" ]]; then
export VERBOSE=1
export DRY_RUN=1
echo "Lancement en dry-run"
/usr/local/sbin/evoacme $vhost
else
export VERBOSE=1
/usr/local/sbin/evoacme $vhost
fi
grep -q "*:80>" /etc/apache2/sites-enabled/${vhost}.conf
if [ $? -eq 0 ] ; then
sed -i --follow-symlinks 's@<VirtualHost \*:80>@<VirtualHost \*:80 \*:443>@' /etc/apache2/sites-enabled/${vhost}.conf
sed -i --follow-symlinks "s@</VirtualHost>@Include /etc/apache2/ssl/$vhost.conf\n</VirtualHost>@" /etc/apache2/sites-enabled/${vhost}.conf
fi

13
scripts/evoacme.sh Normal file
View file

@ -0,0 +1,13 @@
#!/bin/bash
in_login="$1"
domain=$(bash /usr/share/scripts/evoadmin/web-add.sh list-vhost $in_login | cut -d ':' -f3)
alias=$(bash /usr/share/scripts/evoadmin/web-add.sh list-vhost $in_login | cut -d ':' -f4 | tr ',' ' ')
echo $domain $alias | /usr/local/sbin/make-csr "$in_login"
if [[ ${PIPESTATUS[1]} != 0 ]]; then
echo "Erreur avec echo $domain $alias | /usr/local/sbin/make-csr $in_login"
return 1
fi
return 0

View file

@ -63,28 +63,26 @@ get_user_login_by_UID() {
}
list_accounts_by_UID() {
uid=$1
# Remove # and empty lines
ftp_users=$(grep -v -E '^[[:blank:]]*(#.*)*$' "$VPASSWD_PATH")
uid=$1
for line in $ftp_users; do
line_uid="$(echo "$line" | cut -d":" -f3)"
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
username=$(get_user_login_by_UID "$line_uid")
account=$(echo "$line" | cut -d":" -f1)
path=$(echo "$line" | cut -d":" -f6)
size="inconnue"
# Check output of daily "du" cron job
# (set by ansible-roles/packweb-apache/tasks/main.yml)
if [ -r "$path/.size" ]; then
size=$(cat "$path/.size")
fi
#modif="$(cat $path/.lastmodified)"
echo "$username:$account:$path:$size${modif:+:$modif}"
fi
done
while IFS=$'\n' read -r line;
do
line_uid="$(echo "$line" | cut -d":" -f3)"
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
username="$(get_user_login_by_UID "$line_uid")"
account="$(echo "$line" | cut -d":" -f1)"
path="$(echo "$line" | cut -d":" -f6)"
size="$(du -s "$path" | cut -f 1)"
#modif="$(cat $path/.lastmodified)"
# Passage en minuscule ?
#account="$(echo $account | tr '[A-Z]' '[a-z]')"
#path="$(echo $path | tr '[A-Z]' '[a-z]')"
echo "$username:$account:$path:$size${modif:+:$modif}"
fi
done < "$VPASSWD_PATH"
}
add_account() {
@ -121,7 +119,7 @@ delete_account() {
account_name=$1
ftpasswd --passwd --file=$VPASSWD_PATH --name="$account_name" --delete-user
ftpasswd --passwd --file=$VPASSWD_PATH --name="$account_name" --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --delete-user
log_msg "Suppression du compte $account_name"
}

View file

@ -1,4 +1,4 @@
<VirtualHost *:80 *:443>
<VirtualHost *:80>
# FQDN principal
ServerName SERVERNAME
@ -7,11 +7,6 @@
# Repertoire principal
DocumentRoot HOME_DIR/XXX/www/
# SSL
# Apache < 2.4.30 (Jessie, Stretch) va générer une erreur si le fichier
# désigné sans regex n'existe pas. On contourne ça avec [f] à place de f
IncludeOptional /etc/apache2/ssl/XXX.con[f]
# Propriete du repertoire
<Directory HOME_DIR/XXX/www/>
#Options +Indexes +SymLinksIfOwnerMatch
@ -69,3 +64,4 @@
#php_value default_charset ISO-8859-15
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f www-XXX"
php_admin_value open_basedir "/usr/share/php:HOME_DIR/XXX:/tmp"

View file

@ -388,7 +388,7 @@ op_del() {
set -x
deluser www-data $login
userdel -f $login
userdel $login
groupdel $login
sed -i.bak "/^$login:/d" /etc/aliases

View file

@ -14,7 +14,6 @@
set -e
VERSION="24.04"
HOME="/root"
CONTACT_MAIL="jdoe@example.org"
WWWBOUNCE_MAIL="jdoe@example.org"
@ -23,7 +22,6 @@ LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.local.sh"
PRE_LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.pre-local.sh"
TPL_AWSTATS="$SCRIPTS_PATH/awstats.XXX.conf"
SSH_GROUP="evolinux-ssh"
HOST="$(hostname -f)"
# Set to nginx if you use nginx and not apache
WEB_SERVER="apache"
@ -60,7 +58,6 @@ config_file="/etc/evolinux/web-add.conf"
usage() {
cat <<EOT >&2
Evoadmin web tooling - Version $VERSION
Usage: $0 COMMAND [ARG]
add [ [OPTIONS] LOGIN WWWDOMAIN ]
@ -103,18 +100,12 @@ add [ [OPTIONS] LOGIN WWWDOMAIN ]
Example : web-add.sh add -m testdb -r 56 testlogin testdomain.com
del [ [OPTIONS] LOGIN [DBNAME] ]
del LOGIN [DBNAME]
Delete account and all files related (Apache, Awstats, etc)
Archive home directory.
Remove MySQL database only if DBNAME is specified.
-y
Don't ask for confirmation
Example : web-add.sh del -y testlogin testdatabase
list-vhost LOGIN
List Apache vhost for user LOGIN
@ -131,26 +122,30 @@ del-alias VHOST ALIAS
Del a ServerAlias from an Apache vhost
list-servername LOGIN
List ServerName(s) for user LOGIN
update-servername VHOST SERVERNAME OLD_SERVERNAME
Replace the OLD_SERVERNAME with the SERVERNAME for an Apache vhost
Also apply to rewrite rules
Also apply to rules
check-occurence NAME
List all occurences of NAME in vhosts
list-user-itk LOGIN
list-user-itk DOMAIN LOGIN
List the assigned ITK user for the LOGIN specified
List the assigned ITK user for the DOMAIN specified
enable-user-itk LOGIN
enable-user-itk DOMAIN LOGIN
Enable the assigned ITK user for the LOGIN specified
Enable the assigned ITK user for the DOMAIN specified
disable-user-itk LOGIN
disable-user-itk DOMAIN LOGIN
Disable the assigned ITK user for the LOGIN specified
Disable the assigned ITK user for the DOMAIN specified
setphpversion LOGIN VERSION
@ -159,25 +154,6 @@ setphpversion LOGIN VERSION
setquota LOGIN QUOTA_SOFT:QUOTA_HARD
Change quotas for LOGIN
manage-http-challenge-file [CREATE | DELETE]
Create or delete a dummy file for the Let's Encrypt HTTP challenge
The default directory is /var/lib/letsencrypt/.well-known/
generate-csr LOGIN DOMAINS
Generate the request for the Let's Encrypt certificate
generate-ssl-certificate LOGIN [false]
Generate the Let's Encrypt certificate
Run in TEST mode unless "false" is used
version
Obtain the script version
EOT
}
@ -194,7 +170,7 @@ EOT
}
gen_random_passwd() {
apg -c /dev/urandom -MNCL -n1 -m18 -E oOlL10
apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\'
}
validate_login() {
@ -237,15 +213,6 @@ validate_wwwdomain() {
in_error "Le nom de domaine est obligatoire"
return 1
fi
case "$wwwdomain" in
*'/'*)
in_error "Le caractère / n'est pas autorisé. Avez-vous confondu nom de domaine (example.com) et URL (https://example.com) ?"
return 1;;
*':'*)
in_error "Le caractère : n'est pas autorisé. Avez-vous confondu nom de domaine (example.com) et URL (https://example.com) ?"
return 1;;
esac
return 0
}
@ -363,12 +330,14 @@ create_www_account() {
lxc-attach -n php"${php_version}" -- /usr/sbin/adduser --disabled-password --home "$HOME_DIR_USER"/www --no-create-home --shell /bin/false --gecos "WWW $in_login" www-"$in_login" --uid "$www_uid" --ingroup "$in_login" --force-badname >/dev/null
done
if grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
if grep -qE '^AllowGroups' /etc/ssh/sshd_config; then
if ! grep -qE "^AllowGroups(\\s+\\S+)*(\\s+$SSH_GROUP)" /etc/ssh/sshd_config; then
sed -i "s/^AllowGroups .*/& $SSH_GROUP/" /etc/ssh/sshd_config
groupadd --force $SSH_GROUP
fi
usermod -a -G $SSH_GROUP "$in_login"
elif grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
else
if getent group "$SSH_GROUP" 1>/dev/null 2>&1; then
usermod --append --groups "$SSH_GROUP" "$in_login"
fi
fi
/etc/init.d/ssh reload
@ -428,14 +397,6 @@ create_www_account() {
pool_path="/etc/php/7.0/fpm/pool.d/"
elif [ "$php_version" = "73" ]; then
pool_path="/etc/php/7.3/fpm/pool.d/"
elif [ "$php_version" = "74" ]; then
pool_path="/etc/php/7.4/fpm/pool.d/"
elif [ "$php_version" = "80" ]; then
pool_path="/etc/php/8.0/fpm/pool.d/"
elif [ "$php_version" = "81" ]; then
pool_path="/etc/php/8.1/fpm/pool.d/"
elif [ "$php_version" = "82" ]; then
pool_path="/etc/php/8.2/fpm/pool.d/"
else
pool_path="/etc/php5/fpm/pool.d/"
fi
@ -448,15 +409,10 @@ group = ${in_login}
listen = ${phpfpm_socket_path}
listen.owner = ${in_login}
listen.group = ${in_login}
pm = ondemand
pm.status_path = /evolinux_fpm_status-$(apg -Mncl -n1 -m32)
pm.max_children = 10
pm.process_idle_timeout = 10s
php_admin_value[error_log] = /home/${in_login}/log/php.log
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f www-${in_login}@${HOST}"
php_admin_value[open_basedir] = "/usr/share/php:/home/${in_login}:/tmp"
EOT
step_ok "Création du pool FPM ${php_version}"
done
@ -465,9 +421,6 @@ EOT
random=$RANDOM
if [ "$WEB_SERVER" == "apache" ]; then
# On s'assure que /etc/apache2/ssl pour le IncludeOptional de la conf
mkdir -p /etc/apache2/ssl
vhostfile="/etc/apache2/sites-available/${in_login}.conf"
sed -e "s/XXX/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/RANDOM/$random/ ; s#HOME_DIR#$HOME_DIR#" < $TPL_VHOST > "$vhostfile"
@ -493,7 +446,7 @@ EOT
sed -i -e "s/^\\(.*\\)#\\(ServerAlias\\).*$/\\1\\2 $subweb/" "$vhostfile"
fi
a2ensite "${in_login}.conf" >/dev/null
a2ensite "$in_login" >/dev/null
step_ok "Configuration d'Apache"
@ -605,18 +558,6 @@ EOT
elif [ "$php_version" = "73" ]; then
initscript_path="/etc/init.d/php7.3-fpm"
binary="php-fpm7.3"
elif [ "$php_version" = "74" ]; then
initscript_path="/etc/init.d/php7.4-fpm"
binary="php-fpm7.4"
elif [ "$php_version" = "80" ]; then
initscript_path="/etc/init.d/php8.0-fpm"
binary="php-fpm8.0"
elif [ "$php_version" = "81" ]; then
initscript_path="/etc/init.d/php8.1-fpm"
binary="php-fpm8.1"
elif [ "$php_version" = "82" ]; then
initscript_path="/etc/init.d/php8.2-fpm"
binary="php-fpm8.2"
else
initscript_path="/etc/init.d/php5-fpm"
binary="php5-fpm"
@ -671,161 +612,28 @@ EOT
}
op_del() {
#
# Mode interactif
#
if [ $# -eq 0 ]; then
echo
echo "Suppression d'un compte WEB"
echo
until [ "$login" ]; do
echo -n "Entrez le login du compte à supprimer : "
read -r tmp
login="$tmp"
done
echo -n "Voulez-vous aussi supprimer un compte/base MySQL ? [y|N]"
read -r confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
echo -n "Entrez le nom de la base de donnees ($login par defaut) : "
read -r tmp
if [ -z "$tmp" ]; then
dbname=$login
else
dbname="$tmp"
fi
fi
#
# Mode non interactif
#
if [ $# -lt 1 ]; then
usage
exit 1
else
while getopts hy opt; do
case "$opt" in
y)
force_confirm=1
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ $# -gt 0 ] && [ $# -le 2 ]; then
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
else
usage
exit 1
fi
fi
echo
echo "----------------------------------------------"
echo "Nom du compte : $login"
if [ "$dbname" ]; then
echo "Base de données MySQL : $dbname"
fi
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then
echo -n "Confirmer la suppression ? [y/N] : "
read -r tmp
echo
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
echo "Annulation..."
echo
exit 1
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
fi
echo "Deleting account $login. Continue ?"
read -r
set -x
# Crontab dump needs to be done **before** user deletion
if crontab -l -u "$login"; then
crontab -l -u "$login" &> /home/$login/crontab-$(date '+%Y%m%d-%H%M%S').bak
crontab -r -u "$login"
fi
# Deactivate web vhost (apache or nginx)
if [ "$WEB_SERVER" == "apache" ]; then
if a2query -s "${login}" >/dev/null 2&>1; then
a2dissite "${login}.conf"
fi
rm -f /etc/apache2/sites-available/"$login.conf"
apache2ctl configtest
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
phpfpm_dir="/etc/php/7.0/fpm/pool.d/"
initscript_path="/etc/init.d/php7.0-fpm"
elif [ "$php_version" = "73" ]; then
phpfpm_dir="/etc/php/7.3/fpm/pool.d/"
initscript_path="/etc/init.d/php7.3-fpm"
elif [ "$php_version" = "74" ]; then
phpfpm_dir="/etc/php/7.4/fpm/pool.d/"
initscript_path="/etc/init.d/php7.4-fpm"
elif [ "$php_version" = "80" ]; then
phpfpm_dir="/etc/php/8.0/fpm/pool.d/"
initscript_path="/etc/init.d/php8.0-fpm"
elif [ "$php_version" = "81" ]; then
phpfpm_dir="/etc/php/8.1/fpm/pool.d/"
initscript_path="/etc/init.d/php8.1-fpm"
elif [ "$php_version" = "82" ]; then
phpfpm_dir="/etc/php/8.2/fpm/pool.d/"
initscript_path="/etc/init.d/php8.2-fpm"
else
phpfpm_dir="/etc/php5/fpm/pool.d/"
initscript_path="/etc/init.d/php5-fpm"
fi
rm -f /var/lib/lxc/php"${php_version}"/rootfs/${phpfpm_dir}/"${login}".conf
lxc-attach -n php"${php_version}" -- $initscript_path restart >/dev/null
done
elif [ "$WEB_SERVER" == "nginx" ]; then
rm -f /etc/nginx/sites-{available,enabled}/"$login"
rm -f /etc/munin/plugins/phpfpm_"${in_login}"*
nginx -t
userdel www-"$login"
fi
rm -f /etc/awstats/awstats."$login.conf"
sed -i.bak "/-config=$login /d" /etc/cron.d/awstats
if [ "$WEB_SERVER" == "apache" ]; then
if id www-"$login" &> /dev/null; then
userdel -f www-"$login"
fi
for php_version in "${PHP_VERSIONS[@]}"; do
if lxc-attach -n php"${php_version}" -- getent passwd www-"$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
fi
if lxc-attach -n php"${php_version}" -- getent passwd "$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f "$login"
fi
done
fi
if getent passwd "$login" &> /dev/null; then
userdel -f "$login"
fi
userdel "$login"
for php_version in "${PHP_VERSIONS[@]}"; do
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
lxc-attach -n php"${php_version}" -- userdel -f "$login"
done
sed -i.bak "/^$login:/d" /etc/aliases
if [ "$WEB_SERVER" == "apache" ]; then
sed -i.bak "/^www-$login:/d" /etc/aliases
@ -842,15 +650,42 @@ op_del() {
echo "warning : $HOME_DIR/$login does not exist"
fi
if [ -d /etc/letsencrypt/"$login" ]; then
rm -r /etc/letsencrypt/"$login"
fi
if [ "$WEB_SERVER" == "apache" ]; then
a2dissite "$login"
rm /etc/apache2/sites-available/"$login.conf"
rm /etc/awstats/awstats."$login.conf"
sed -i.bak "/-config=$login /d" /etc/cron.d/awstats
apache2ctl configtest
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
phpfpm_dir="/etc/php/7.0/fpm/pool.d/"
initscript_path="/etc/init.d/php7.0-fpm"
elif [ "$php_version" = "73" ]; then
phpfpm_dir="/etc/php/7.3/fpm/pool.d/"
initscript_path="/etc/init.d/php7.3-fpm"
else
phpfpm_dir="/etc/php5/fpm/pool.d/"
initscript_path="/etc/init.d/php5-fpm"
fi
rm /var/lib/lxc/php"${php_version}"/rootfs/${phpfpm_dir}/"${login}".conf
lxc-attach -n php"${php_version}" -- $initscript_path restart >/dev/null
done
elif [ "$WEB_SERVER" == "nginx" ]; then
rm /etc/nginx/sites-{available,enabled}/"$login"
rm /etc/awstats/awstats."$login.conf"
rm /etc/munin/plugins/phpfpm_"${in_login}"*
sed -i.bak "/-config=$login/d" /etc/cron.d/awstats
nginx -t
fi
set +x
if [ -n "$dbname" ]; then
echo "Deleting mysql DATABASE $dbname and mysql user $login. Continue ?"
read -r
set -x
echo "DROP DATABASE \`$dbname\`; DROP USER \`$login\`@localhost; FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
echo "DROP DATABASE $dbname; delete from mysql.user where user='$login' ; FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
set +x
fi
}
@ -920,6 +755,9 @@ arg_processing() {
del-alias)
op_aliasdel "$@"
;;
list-servername)
op_listservername "$@"
;;
update-servername)
op_servernameupdate "$@"
;;
@ -941,18 +779,6 @@ arg_processing() {
setquota)
op_setquota "$@"
;;
manage-http-challenge-file)
op_managehttpchallengefile "$@"
;;
generate-csr)
op_makecsr "$@"
;;
generate-ssl-certificate)
op_generatesslcertificate "$@"
;;
version)
op_version "$@"
;;
*)
usage
;;
@ -960,64 +786,6 @@ arg_processing() {
fi
}
op_makecsr() {
if [ $# -gt 1 ]; then
vhost="$1"
domains=""
# remove the first argument to keep only the domains
shift 1
for domain in "$@"; do
domains="${domains:+${domains} }${domain}"
done
# pipe the domains to make-csr because we don't have STDIN
echo "$domains" | make-csr "$vhost"
else usage
fi
}
op_generatesslcertificate() {
if [ $# -gt 1 ]; then
vhost="$1"
test_mode="$2"
if [ "$test_mode" = "false" ]; then
if [ -L /etc/letsencrypt/$vhost/live ]; then
rm /etc/letsencrypt/$vhost/live
fi
evoacme "$vhost"
else
DRY_RUN=1 evoacme "$vhost"
fi
else usage
fi
}
op_managehttpchallengefile() {
if [ $# -eq 1 ]; then
folder="/var/lib/letsencrypt/.well-known"
file="testfile"
action=${1};
if [ "$action" = "create" ]; then
if [ ! -d "$folder" ]; then
mkdir -p "$folder/acme-challenge"
fi
if [ ! -f "$folder/acme-challenge/$file" ]; then
touch "$folder/acme-challenge/$file"
fi
chmod -R 755 "$folder"
elif [ "$action" = "delete" ]; then
rm -r "$folder"
else usage
fi
else usage
fi
}
op_listvhost() {
if [ $# -eq 1 ]; then
configlist="$VHOST_PATH/${1}.conf";
@ -1025,6 +793,7 @@ op_listvhost() {
configlist="$VHOST_PATH/*";
fi
for configfile in $configlist; do
if [ -r "$configfile" ] && echo "$configfile" |grep -qvE "/(000-default|default-ssl|evoadmin)\\.conf$"; then
servername="$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$configfile" | head -n 1)"
@ -1042,17 +811,9 @@ op_listvhost() {
else
is_enabled=0
fi
count_virtualhosts="$(grep "<VirtualHost" "$configfile" | wc -l)"
if [ "$count_virtualhosts" -eq 1 ]; then
is_standard=1
else
is_standard=0
fi
if [ "$servername" ] && [ "$userid" ]; then
configid=$(basename "$configfile")
echo "$userid:$configid:$servername:$serveraliases:$size:$quota_soft:$quota_hard:$phpversion:$is_enabled:$is_standard"
echo "$userid:$configid:$servername:$serveraliases:$size:$quota_soft:$quota_hard:$phpversion:$is_enabled"
fi
fi
done
@ -1062,23 +823,12 @@ op_aliasadd() {
if [ $# -eq 2 ]; then
vhost="${1}.conf"
alias=$2
vhost_file="${VHOST_PATH}/${vhost}"
if [ -f "${vhost_file}" ]; then
sed -i "/ServerName .*/a \\\tServerAlias $alias" "${vhost_file}" --follow-symlinks
else
echo "VHost file \`${vhost_file}' not found'" >&2
return 1
fi
[ -f $VHOST_PATH/"$vhost" ] && sed -i "/ServerName .*/a \\\tServerAlias $alias" "$VHOST_PATH"/"$vhost" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
apache2ctl configtest 2>/dev/null
/etc/init.d/apache2 force-reload >/dev/null
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else usage
fi
}
@ -1109,6 +859,25 @@ op_aliasdel() {
fi
}
op_listservername() {
if [ $# -eq 1 ]; then
vhost_file="$VHOST_PATH/${1}.conf";
if [ -f "${vhost_file}" ]; then
servernames=$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$vhost_file" | uniq)
for servername in $servernames; do
echo "$servername";
done
else
echo "VHost file \`${vhost_file}' not found'" >&2
return 1
fi
else
usage
fi
}
op_servernameupdate() {
if [ $# -eq 3 ]; then
vhost="${1}.conf"
@ -1116,6 +885,7 @@ op_servernameupdate() {
old_servername=$3
vhost_file="${VHOST_PATH}/${vhost}"
# Remplacement de toutes les directives ServerName, on assume qu'il s'agit du même pour chaque vhost du fichier
if [ -f "${vhost_file}" ]; then
sed -i "/^ *ServerName/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
sed -i "/^ *RewriteCond/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
@ -1145,34 +915,36 @@ op_checkoccurencename() {
if [ -r "$configfile" ]; then
alias=$(perl -ne 'print "$1 " if /^[[:space:]]*ServerAlias (.*)/' "$configfile" | head -n 1)
aliases="$aliases $alias"
servername=$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$configfile" | uniq)
servernames="$servernames $servername"
fi
done
echo "$servernames" "$aliases" | grep -E "(^|\s)$name(\s|$)"
echo "$servernames" "$aliases" | grep -w "$name"
else
usage
fi
}
op_listuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH/${1}.conf"
awk '/AssignUserID/ {print $2}' "$configfile" | uniq
if [ $# -eq 2 ]; then
domain=${1}
configfile="$VHOST_PATH/${2}.conf"
sed -n "/$domain/,/<\/VirtualHost>/p" "$configfile" | awk '/AssignUserID/ {print $2}' | uniq
else
usage
fi
}
op_enableuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH/${1}.conf"
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
if [ $# -eq 2 ]; then
domain=${1}
configfile="$VHOST_PATH/${2}.conf"
group=$(sed -n "/$domain/,/<\/VirtualHost>/p" "$configfile" | awk '/AssignUserID/ {print $3}' | uniq)
sed -i "s/^ *AssignUserID $group/ AssignUserID www-$group/" "$configfile" --follow-symlinks
sed -i "/$domain/,/<\/VirtualHost>/ s/^ *AssignUserID $group/ AssignUserID www-$group/" "$configfile" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
@ -1188,11 +960,12 @@ op_enableuseritk() {
}
op_disableuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH"/"${1}".conf
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
if [ $# -eq 2 ]; then
domain=${1}
configfile="$VHOST_PATH"/"${2}".conf
group=$(sed -n "/$domain/,/<\/VirtualHost>/p" $configfile | awk '/AssignUserID/ {print $3}' | uniq)
sed -i "s/^ *AssignUserID www-$group/ AssignUserID ${group}/" "$configfile" --follow-symlinks
sed -i "/$domain/,/<\/VirtualHost>/ s/^ *AssignUserID www-$group/ AssignUserID ${group}/" "$configfile" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
@ -1427,7 +1200,7 @@ op_checkvhosts() {
do
vhost_name=$(basename "$ln_path")
fix_conf="mv $ln_path $VHOST_PATH/$vhost_name"
fix_ln="a2ensite ${vhost_name}.conf"
fix_ln="a2ensite $vhost_name"
if [[ -z "$apply" ]]; then
echo "Suggested fixes for $vhost_name:"
@ -1441,10 +1214,5 @@ op_checkvhosts() {
done
}
# Return web-add.sh version
op_version(){
echo "$VERSION"
}
# Point d'entrée
arg_processing "$@"

View file

@ -1,46 +1,43 @@
<?php
/**
* Authentification page
* Authentification form
*
* Copyright (c) 2009-2022 Evolix - Tous droits reserves
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* @author Evolix <info@evolix.fr>
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @author and others.
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
?>
<h2>Evoadmin : Connexion</h2>
<br/><br/>
<form method="POST">
<table align="center">
<tr>
<td align="right">Utilisateur : &nbsp;</td>
<td align="left"><input type="text" name="login" /></td>
</tr>
<tr>
<td align="right">Mot de passe : &nbsp;</td>
<td align="left"><input type="password" name="passw" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left"><br/><input type="submit" value="Connexion" /></td>
</tr>
<?php
if (!empty($error)) {
?>
<tr>
<td colspan="2" class="auth-error">
Identifiants invalides.
Veuillez -essayer
</td>
</tr>
<?php
}
?>
<tr>
<td align="right">Utilisateur : &nbsp;</td>
<td align="left"><input type="text" name="login" /></td>
</tr>
<tr>
<td align="right">Mot de passe : &nbsp;</td>
<td align="left"><input type="password" name="passw" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left"><br/><input type="submit" value="Connexion" /></td>
</tr>
<?php
if (!empty($error)) {
?>
<tr>
<td colspan="2" class="auth-error">Identifiants invalides. Veuillez -essayer</td>
</tr>
<?php
}
?>
</table>
</form>

View file

@ -21,7 +21,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Evoadmin-web - Powered by Evolix</title>
<title>EvoAdmin - Powered by Evolix</title>
<link rel="stylesheet" href="/inc/css/main.css" type="text/css" media="screen, projection" />
<script type="text/javascript" src="/inc/js/lib/prototype-1.6.0.3.js"></script>
<script type="text/javascript" src="/inc/js/ftpadmin.js"></script>
@ -31,10 +31,10 @@
<body>
<div id="main">
<h1 id="top">Evoadmin-web
<h1 id="top">EvoAdmin
<?php
if(!empty($_SESSION['user'])) {
print ' v'.$_SESSION['cli_version'].' - '.$_SESSION['user'];
print ' - '.$_SESSION['user'];
if(is_superadmin()) {
print ' (Administrateur)';

View file

@ -1,36 +0,0 @@
<?php
/**
* Suppression d'un compte web
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
*/
?>
<h2>Suppression du compte web</h2>
<form name="form-delete-vhost" id="form-add" action="" method="POST">
<fieldset>
<p>
<label for="vhost-name">Nom du compte :</label>
<input type="text" name="vhost-name">
</p>
<p>
<label for="vhost-delete-db">Supprimer la base de données ? :</label>
<input id="vhost-delete-db" name="vhost-delete-db" checked="checked" value="1" type="checkbox">
</p>
<p>
<label for="vhost-dbname">Nom de la base de données :</label>
<input type="text" name="vhost-dbname" id="vhost-dbname">
</p>
<p>
<input type="submit" name="delete-vhost" value="Supprimer">
</p>
</fieldset>
</form>

View file

@ -5,7 +5,7 @@
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
@ -38,7 +38,7 @@
<?php
for ( $i=0; $i < count($alias_list); ++$i ) {
print '<tr>';
printf('<td>%s</td>',
printf('<td><a href="http://%s">http://%s</a></td>',
$alias_list[$i]['alias'], $alias_list[$i]['alias']);
if (is_superadmin())
printf('<td><a href="/webadmin/%s/alias/delete/%s/">Supprimer</a></td>',

View file

@ -17,11 +17,12 @@
<?php
if(!empty($user_itk)) { ?>
if(count($data_list) > 0) { ?>
<table id="tab-list">
<thead>
<tr>
<th>ServerName</th>
<th>Utilisateur</th>
<?php if (is_superadmin()) {
print '<th>Action</th>';
@ -30,23 +31,29 @@
</thead>
<tbody>
<?php
for ( $i=0; $i < count($data_list); ++$i ) {
print '<tr>';
printf('<td>%s</td>',
$data_list[$i]['servername']);
printf('<td>%s</td>',
$data_list[$i]['user']);
if (is_superadmin()) {
if (strpos($data_list[$i]['user'], 'www') !== false) {
$action = ['disable', 'Désactiver'];
} else {
$action = ['enable', 'Activer'];
}
print '<tr>';
printf('<td>%s</td>',
$user_itk);
if (is_superadmin()) {
// AssignUserID not set in the vhost, override previous action
if (empty($data_list[$i]['user'])) {
$action = ["", ""];
}
if (strpos($user_itk, 'www') !== false) {
$action = ['disable', 'Désactiver'];
} else {
$action = ['enable', 'Activer'];
}
printf('<td><a href="/webadmin/%s/itk/%s/">'.$action[1].'</a></td>',
$domain, $action[0]);
}
print '</tr>';
?>
printf('<td><a href="/webadmin/%s/itk/%s/%s/">'.$action[1].'</a></td>',
$domain, $action[0], $data_list[$i]['servername']);
}
print '</tr>';
} ?>
</tbody>
</table>
<?php

View file

@ -1,53 +0,0 @@
<h2>Gestion Let's Encrypt</h2>
<?php
if (isset($_POST['submit'])) {
if (!empty($errorMessage)) {
echo '<span class="form-error">' . $errorMessage . '</span>';
if (count($failed_domains) > 0) {
echo '<p>';
foreach ($failed_domains as $failed_domain) {
echo $failed_domain . "<br>";
}
echo '</p>';
}
} else {
echo "Votre certificat SSL a bien été installé !";
}
} else {
if (!empty($errorMessage)) {
echo '<span class="form-error">' . $errorMessage . '</span>';
if (count($failed_domains) > 0) {
echo '<p>';
foreach ($failed_domains as $failed_domain) {
echo $failed_domain . "<br>";
}
echo '</p>';
}
} elseif (!empty($warningMessage)) {
echo '<span class="form-warning">' . $warningMessage . '</span>'; ?>
<form name="form-confirm-renew-cert" id="form-confirm-renew-cert" action="" method="POST">
<p>
<input type="hidden" name="force_renew">
<input type="submit" name="submit" value="Confirmer l'installation" style="margin-left:0px;">
</p>
</form>
<?php
} else {
echo "<p>Les domaines suivants seront intégrés au certificat : </p>";
if (count($_SESSION['letsencrypt-domains']) > 0) {
echo '<p>';
foreach ($_SESSION['letsencrypt-domains'] as $domain) {
echo $domain . '<br>';
}
echo '</p>';
?>
<form name="form-confirm-install-cert" id="form-confirm-install-cert" action="" method="POST">
<p><input type="submit" name="submit" value="Installer le certificat" style="margin-left:0px;"></p>
</form>
<?php
}
}
}

View file

@ -13,16 +13,16 @@
?>
<h2>Servername</h2>
<h2>ServerNames</h2>
<?php
if(!empty($servername)) { ?>
if(count($servername_list) > 0) { ?>
<table id="tab-list">
<thead>
<tr>
<th>Servername</th>
<th>ServerName</th>
<?php if (is_superadmin()) {
print '<th>Action</th>';
} ?>
@ -30,19 +30,20 @@
</thead>
<tbody>
<?php
print '<tr>';
printf('<td>%s</td>',
$servername);
if (is_superadmin())
printf('<td><a href="/webadmin/%s/domain/edit/%s/">Modifier</a></td>',
$domain, $servername);
print '</tr>';
?>
for ( $i=0; $i < count($servername_list); ++$i ) {
print '<tr>';
printf('<td>%s</td>',
$servername_list[$i]);
if (is_superadmin())
printf('<td><a href="/webadmin/%s/domain/edit/%s/">Modifier</a></td>',
$domain, $servername_list[$i]);
print '</tr>';
} ?>
</tbody>
</table>
<?php
} else {
print "<p>Aucun Servername existant pour le domaine $domain !</p>";
print "<p>Aucun ServerName existant pour le domaine $domain !</p>";
}

View file

@ -22,9 +22,9 @@
<thead>
<tr>
<?php if(is_superadmin()) {
print '<th>Virtual Host</th>';
print '<th>Propriétaire</th>';
} ?>
<th>Servername</th>
<th>Domaine</th>
<?php if(is_superadmin()) {
print '<th>Alias</th>';
}
@ -61,7 +61,7 @@
if(is_superadmin()) {
printf('<td>%s</td>', $vhost_info['owner']);
}
printf('<td>%s</td>',
printf('<td><a href="http://%s">http://%s</a></td>',
$vhost_info['server_name'], $vhost_info['server_name']);
if ($conf['cluster']) {
@ -87,7 +87,7 @@
printf('<td>%s</td>', $vhost_info['slave']);
}
printf('<td>%s</td>', preg_replace('/,/','<br />',$vhost_info['server_alias']));
printf('<td align="left">%s</td>', preg_replace('/,/','<br />',$vhost_info['server_alias']));
if ($conf['quota']) {
printf('<td>%s</td>', $vhost_info['size']);
@ -103,18 +103,12 @@
if (is_superadmin()) {
printf('<td>');
if (!in_array($vhost_info['owner'], $_SESSION['non_standard'])) {
printf('<a href="/webadmin/%s/alias/">Alias</a> - ', $vhost_info['owner']);
printf('<a href="/webadmin/%s/domain/">Servername</a> - ', $vhost_info['owner']);
if(is_multiphp()) {
printf('<a href="/webadmin/%s/php/">PHP</a> - ', $vhost_info['owner']);
} else {
printf('<a href="/webadmin/%s/itk/">ITK</a> - ', $vhost_info['owner']);
}
printf('<a href="/webadmin/%s/letsencrypt/">Let\'s Encrypt</a> - ', $vhost_info['owner']);
printf('<a href="/webadmin/delete/%s">Supprimer</a>', $vhost_info['owner']);
printf('<a href="/webadmin/%s/alias/">Alias</a> - ', $vhost_info['owner']);
printf('<a href="/webadmin/%s/domain/">Servername</a> - ', $vhost_info['owner']);
if(is_multiphp()) {
printf('<a href="/webadmin/%s/php/">PHP</a>', $vhost_info['owner']);
} else {
print '<span class="form-mandatory-ok">VirtualHost non standard</span>';
printf('<a href="/webadmin/%s/itk/">ITK</a>', $vhost_info['owner']);
}
printf('</td>');