From 48717db2c081e735c661e68f1aa35d21f58619e3 Mon Sep 17 00:00:00 2001 From: Ludovic <54670129+lbr38@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:17:56 +0200 Subject: [PATCH] 4.2.0 --- .github/workflows/phpcs.yml | 2 +- Todolist | 12 +- docker/Dockerfile | 12 +- docker/config/nginx/repomanager.conf | 2 +- docker/config/php/www.conf | 4 +- docker/entrypoint.sh | 6 +- www/controllers/Api/Host/Host.php | 2 +- www/controllers/Common.php | 7 +- www/controllers/Process.php | 2 +- www/controllers/Repo/Mirror/Deb.php | 4 +- www/controllers/Repo/Mirror/Mirror.php | 11 +- www/controllers/Repo/Mirror/Rpm.php | 2 +- www/controllers/Source.php | 16 +- www/controllers/Task/Form/Param/Schedule.php | 7 + www/controllers/Task/Repo/Package/Sync.php | 7 + www/controllers/ajax/source.php | 4 +- www/models/Connection.php | 6 +- www/models/Source.php | 5 +- www/public/resources/js/source.js | 13 +- www/public/resources/js/task.js | 28 ++-- www/public/resources/styles/common.css | 18 +- www/tasks/execute.php | 2 +- www/update/database/3.5.3.php | 16 +- www/update/database/4.2.0.php | 154 ++++++++++++++++++ www/update/database/x.x.x.php.wip | 26 --- www/version | 2 +- www/views/includes/repos-list.inc.php | 2 +- .../includes/tables/source_repos/list.inc.php | 9 +- 28 files changed, 282 insertions(+), 99 deletions(-) create mode 100644 www/update/database/4.2.0.php delete mode 100644 www/update/database/x.x.x.php.wip diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 904c843a..17dac416 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -16,7 +16,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.1' + php-version: '8.3' coverage: none tools: composer, cs2pr diff --git a/Todolist b/Todolist index 6c4d7cd6..986c19fa 100644 --- a/Todolist +++ b/Todolist @@ -4,12 +4,12 @@ - Update documentation -[ BUGS ] + [ REPOS ] - [ REPOS ] + - Add a way to sync Redhat repositories #169 - - (KO) Mirror a debian repo with translations => translations are not included by reprepro - - (KO) Mirror a debian repo with multiple archs and translations => translations are not included by reprepro + +[ BUGS ] [ IMPROVEMENTS / FEATURES ] @@ -17,8 +17,10 @@ [ GENERAL ] - (JS) Refactor and mutualize the ajax functions - - Rename PLANS_* constants to TASK_* + - Rename PLANS_REMINDERS_ENABLED constants to SCHEDULED_TASK_REMINDERS_ENABLED - Log catched fatal errors (catch (Error $e)) in FATAL_ERRORS_LOG dedicated file (Error class: https://www.php.net/manual/fr/class.error.php) + - Add more verbosity to urlReachable function (return http error) + - Add a stop task button in the tasks tab #170 [ REPOS ] diff --git a/docker/Dockerfile b/docker/Dockerfile index aefc2fd0..979069d0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -24,14 +24,14 @@ RUN apt-get install findutils iputils-ping git gnupg2 rpm librpmsign9 createrepo # Install postfix RUN apt-get install postfix -y -# Add nginx and PHP 8.1 repositories +# Add nginx and PHP 8.3 repositories RUN curl -sS https://packages.bespin.ovh/repo/gpgkeys/packages.bespin.ovh.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.bespin.ovh.gpg RUN echo "deb https://packages.bespin.ovh/repo/repomanager-nginx/bookworm/nginx_prod bookworm nginx" > /etc/apt/sources.list.d/nginx.list RUN echo "deb https://packages.bespin.ovh/repo/repomanager-php/bookworm/main_prod bookworm main" > /etc/apt/sources.list.d/php.list RUN apt-get update -y -# Install nginx and PHP 8.1 -RUN apt-get install nginx php8.1-fpm php8.1-cli php8.1-sqlite3 php8.1-xml php8.1-curl sqlite3 -y +# Install nginx and PHP 8.3 +RUN apt-get install nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-xml php8.3-curl sqlite3 -y # Clone project in the container RUN git clone https://github.com/lbr38/repomanager.git /tmp/repomanager @@ -50,9 +50,9 @@ RUN sed -i "s/__MAX_UPLOAD_SIZE__/$max_upload_size/g" /etc/nginx/sites-enabled/r RUN rm -rf /etc/nginx/sites-enabled/default /var/www/html # Configure PHP -RUN cp /tmp/repomanager/docker/config/php/www.conf /etc/php/8.1/fpm/pool.d/www.conf -RUN sed -i "s/^upload_max_filesize.*$/upload_max_filesize = $max_upload_size/g" /etc/php/8.1/fpm/php.ini -RUN sed -i "s/^post_max_size.*$/post_max_size = $max_upload_size/g" /etc/php/8.1/fpm/php.ini +RUN cp /tmp/repomanager/docker/config/php/www.conf /etc/php/8.3/fpm/pool.d/www.conf +RUN sed -i "s/^upload_max_filesize.*$/upload_max_filesize = $max_upload_size/g" /etc/php/8.3/fpm/php.ini +RUN sed -i "s/^post_max_size.*$/post_max_size = $max_upload_size/g" /etc/php/8.3/fpm/php.ini # Configure SQLite RUN echo ".headers on" > /root/.sqliterc diff --git a/docker/config/nginx/repomanager.conf b/docker/config/nginx/repomanager.conf index 7ab72475..4406c805 100644 --- a/docker/config/nginx/repomanager.conf +++ b/docker/config/nginx/repomanager.conf @@ -8,7 +8,7 @@ map $request_uri $loggable { # Path to unix socket upstream php-handler { - server unix:/run/php/php8.1-fpm.sock; + server unix:/run/php/php8.3-fpm.sock; } server { diff --git a/docker/config/php/www.conf b/docker/config/php/www.conf index 9a3ffd24..5851d6eb 100644 --- a/docker/config/php/www.conf +++ b/docker/config/php/www.conf @@ -33,7 +33,7 @@ group = www-data ; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /run/php/php8.1-fpm.sock +listen = /run/php/php8.3-fpm.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) @@ -238,7 +238,7 @@ pm.max_spare_servers = 3 ; last request memory: 0 ; ; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: /usr/share/php/8.1/fpm/status.html +; It's available in: /usr/share/php/8.3/fpm/status.html ; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 4929c721..d296acaf 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -23,15 +23,15 @@ if [ ! -z "$MAX_UPLOAD_SIZE" ];then # Nginx configuration sed -i "s/client_max_body_size.*$/client_max_body_size ${MAX_UPLOAD_SIZE};/g" /etc/nginx/sites-enabled/repomanager.conf # PHP configuration - sed -i "s/^upload_max_filesize.*$/upload_max_filesize = ${MAX_UPLOAD_SIZE}/g" /etc/php/8.1/fpm/php.ini - sed -i "s/^post_max_size.*$/post_max_size = ${MAX_UPLOAD_SIZE}/g" /etc/php/8.1/fpm/php.ini + sed -i "s/^upload_max_filesize.*$/upload_max_filesize = ${MAX_UPLOAD_SIZE}/g" /etc/php/8.3/fpm/php.ini + sed -i "s/^post_max_size.*$/post_max_size = ${MAX_UPLOAD_SIZE}/g" /etc/php/8.3/fpm/php.ini fi # Start services if [ -f "/etc/init.d/syslog-ng" ];then /usr/sbin/service syslog-ng start fi -/usr/sbin/service php8.1-fpm start +/usr/sbin/service php8.3-fpm start /usr/sbin/service nginx start /usr/sbin/service postfix start diff --git a/www/controllers/Api/Host/Host.php b/www/controllers/Api/Host/Host.php index 3833f5ce..f5dcd0a5 100644 --- a/www/controllers/Api/Host/Host.php +++ b/www/controllers/Api/Host/Host.php @@ -331,7 +331,7 @@ public function execute() if (!empty($this->data->status) and ($this->action == 'packages-update' or $this->action == 'general-status-update' or $this->action == 'packages-status-update' or $this->action == 'full-history-update') and $this->method == 'PUT') { try { $myhost->acknowledgeRequest($this->action, $this->data->status); - return array('message' => 'Acknowledge has been taken into account.'); + return array('message' => array('Acknowledge has been taken into account.')); } catch (Exception $e) { throw new Exception($e->getMessage()); } diff --git a/www/controllers/Common.php b/www/controllers/Common.php index 534079bb..237a6437 100644 --- a/www/controllers/Common.php +++ b/www/controllers/Common.php @@ -569,7 +569,7 @@ public static function xzUncompress(string $filename, string $outputFilename = n * Return true if distant URL is reachable * The target URL can be a file or a directory */ - public static function urlReachable(string $url, string $sslCertificatePath = null, string $sslPrivateKeyPath = null) + public static function urlReachable(string $url, string $sslCertificatePath = null, string $sslPrivateKeyPath = null, string $sslCustomCaCertificate = null) { $ch = curl_init($url); @@ -584,7 +584,7 @@ public static function urlReachable(string $url, string $sslCertificatePath = nu } /** - * If a custom SSL certificate and key have been specified + * If a custom SSL certificate / private key / ca certificate have been specified */ if (!empty($sslCertificatePath)) { curl_setopt($ch, CURLOPT_SSLCERT, $sslCertificatePath); @@ -592,6 +592,9 @@ public static function urlReachable(string $url, string $sslCertificatePath = nu if (!empty($sslPrivateKeyPath)) { curl_setopt($ch, CURLOPT_SSLKEY, $sslPrivateKeyPath); } + if (!empty($sslCustomCaCertificate)) { + curl_setopt($ch, CURLOPT_CAINFO, $sslCustomCaCertificate); + } if (curl_exec($ch) === false) { return false; diff --git a/www/controllers/Process.php b/www/controllers/Process.php index 6c7c1c50..5abd3dc3 100644 --- a/www/controllers/Process.php +++ b/www/controllers/Process.php @@ -4,7 +4,7 @@ class Process { - private $workingDir = ROOT . '/.temp'; // Working dir for php + private $workingDir = ROOT; // Working dir for php private $command; private $env = array('HOME' => ROOT, 'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'); private $process; diff --git a/www/controllers/Repo/Mirror/Deb.php b/www/controllers/Repo/Mirror/Deb.php index 1786d060..f5a6000d 100644 --- a/www/controllers/Repo/Mirror/Deb.php +++ b/www/controllers/Repo/Mirror/Deb.php @@ -19,7 +19,7 @@ private function getReleaseFile() $releasePossibleNames = array('InRelease', 'Release', 'Release.gpg'); foreach ($releasePossibleNames as $releaseFile) { - if (\Controllers\Common::urlReachable($this->url . '/dists/' . $this->dist . '/' . $releaseFile, $this->sslCustomCertificate, $this->sslCustomPrivateKey)) { + if (\Controllers\Common::urlReachable($this->url . '/dists/' . $this->dist . '/' . $releaseFile, $this->sslCustomCertificate, $this->sslCustomPrivateKey, $this->sslCustomCaCertificate)) { $this->download($this->url . '/dists/' . $this->dist . '/' . $releaseFile, $this->workingDir . '/' . $releaseFile); } } @@ -98,7 +98,7 @@ private function parseReleaseFile() /** * Include this Packages.xx/Sources.xx file only if it does really exist on the remote server (sometimes it can be declared in Release but not exists...) */ - if (\Controllers\Common::urlReachable($this->url . '/dists/' . $this->dist . '/' . $location, $this->sslCustomCertificate, $this->sslCustomPrivateKey)) { + if (\Controllers\Common::urlReachable($this->url . '/dists/' . $this->dist . '/' . $location, $this->sslCustomCertificate, $this->sslCustomPrivateKey, $this->sslCustomCaCertificate)) { if ($arch == 'src') { $this->sourcesIndicesLocation[] = array('location' => $location, 'checksum' => $checksum); } diff --git a/www/controllers/Repo/Mirror/Mirror.php b/www/controllers/Repo/Mirror/Mirror.php index 3bf3f344..fb921b84 100644 --- a/www/controllers/Repo/Mirror/Mirror.php +++ b/www/controllers/Repo/Mirror/Mirror.php @@ -27,6 +27,7 @@ class Mirror protected $outputFile; protected $sslCustomCertificate; protected $sslCustomPrivateKey; + protected $sslCustomCaCertificate; protected $curlHandle; public function setUrl(string $url) @@ -84,6 +85,11 @@ public function setSslCustomPrivateKey(string $path) $this->sslCustomPrivateKey = $path; } + public function setSslCustomCaCertificate(string $path) + { + $this->sslCustomCaCertificate = $path; + } + /** * Initialize mirroring task */ @@ -132,7 +138,7 @@ public function download(string $url, string $savePath) } /** - * If a custom ssl certificate and private key must be used + * If a custom ssl certificate / private key /ca certificate must be used */ if (!empty($this->sslCustomCertificate)) { curl_setopt($this->curlHandle, CURLOPT_SSLCERT, $this->sslCustomCertificate); @@ -140,6 +146,9 @@ public function download(string $url, string $savePath) if (!empty($this->sslCustomPrivateKey)) { curl_setopt($this->curlHandle, CURLOPT_SSLKEY, $this->sslCustomPrivateKey); } + if (!empty($this->sslCustomCaCertificate)) { + curl_setopt($this->curlHandle, CURLOPT_CAINFO, $this->sslCustomCaCertificate); + } /** * Execute curl diff --git a/www/controllers/Repo/Mirror/Rpm.php b/www/controllers/Repo/Mirror/Rpm.php index df44be4c..439893b8 100644 --- a/www/controllers/Repo/Mirror/Rpm.php +++ b/www/controllers/Repo/Mirror/Rpm.php @@ -656,7 +656,7 @@ public function mirror() */ foreach ($this->archUrls as $url) { - if (!\Controllers\Common::urlReachable($url . '/repodata/repomd.xml', $this->sslCustomCertificate, $this->sslCustomPrivateKey)) { + if (!\Controllers\Common::urlReachable($url . '/repodata/repomd.xml', $this->sslCustomCertificate, $this->sslCustomPrivateKey, $this->sslCustomCaCertificate)) { /** * Remove unreachable URL from array */ diff --git a/www/controllers/Source.php b/www/controllers/Source.php index e948ce8b..cd49d873 100644 --- a/www/controllers/Source.php +++ b/www/controllers/Source.php @@ -101,7 +101,7 @@ public function new(string $type, string $name, string $url, string $gpgKeyURL = /** * Edit a source repo */ - public function edit(int $id, string $name, string $url, string $gpgKeyURL = null, string $sslCertificatePath = null, string $sslPrivateKeyPath = null) + public function edit(int $id, string $name, string $url, string $gpgKeyURL = null, string $sslCertificatePath = null, string $sslPrivateKeyPath = null, string $sslCaCertificatePath = null) { /** * Check that source repo exists @@ -192,7 +192,19 @@ public function edit(int $id, string $name, string $url, string $gpgKeyURL = nul } } - $this->model->edit($id, $name, $url, $gpgKeyURL, $sslCertificatePath, $sslPrivateKeyPath); + /** + * SSL CA certificate file must be a file that exists and is readable + */ + if (!empty($sslCaCertificatePath)) { + if (!file_exists($sslCaCertificatePath)) { + throw new Exception('Specified CA certificate file does not exist'); + } + if (!is_readable($sslCaCertificatePath)) { + throw new Exception('Specified CA certificate file is not readable'); + } + } + + $this->model->edit($id, $name, $url, $gpgKeyURL, $sslCertificatePath, $sslPrivateKeyPath, $sslCaCertificatePath); } /** diff --git a/www/controllers/Task/Form/Param/Schedule.php b/www/controllers/Task/Form/Param/Schedule.php index 3b842016..bd7c645b 100644 --- a/www/controllers/Task/Form/Param/Schedule.php +++ b/www/controllers/Task/Form/Param/Schedule.php @@ -39,6 +39,13 @@ public static function check(array $scheduleParams) : void * Check that schedule time is set and valid */ self::checkTime($scheduleParams['schedule-time']); + + /** + * Check that date and time are not in the past + */ + if (strtotime($scheduleParams['schedule-date'] . ' ' . $scheduleParams['schedule-time']) < strtotime(date('Y-m-d H:i'))) { + throw new Exception('You cannot schedule a task in the past'); + } } /** diff --git a/www/controllers/Task/Repo/Package/Sync.php b/www/controllers/Task/Repo/Package/Sync.php index c0a1802a..fc07f66e 100644 --- a/www/controllers/Task/Repo/Package/Sync.php +++ b/www/controllers/Task/Repo/Package/Sync.php @@ -220,12 +220,19 @@ private function syncPackage() if (!empty($sourceDetails['Gpgkey'])) { $mymirror->setGpgKeyUrl($sourceDetails['Gpgkey']); } + + /** + * If the source repo has a custom SSL certificate, private key or CA certificate, then they will be used + */ if (!empty($sourceDetails['Ssl_certificate_path'])) { $mymirror->setSslCustomCertificate($sourceDetails['Ssl_certificate_path']); } if (!empty($sourceDetails['Ssl_private_key_path'])) { $mymirror->setSslCustomPrivateKey($sourceDetails['Ssl_private_key_path']); } + if (!empty($sourceDetails['Ssl_ca_certificate_path'])) { + $mymirror->setSslCustomCaCertificate($sourceDetails['Ssl_ca_certificate_path']); + } $mymirror->mirror(); unset($mymirror); diff --git a/www/controllers/ajax/source.php b/www/controllers/ajax/source.php index 20c0c3cc..59a037ea 100644 --- a/www/controllers/ajax/source.php +++ b/www/controllers/ajax/source.php @@ -25,11 +25,11 @@ /** * Edit a source repo */ -if ($_POST['action'] == 'edit' and !empty($_POST['id']) and !empty($_POST['name']) and !empty($_POST['url']) and isset($_POST['gpgkey']) and isset($_POST['sslCertificatePath']) and isset($_POST['sslPrivateKeyPath'])) { +if ($_POST['action'] == 'edit' and !empty($_POST['id']) and !empty($_POST['name']) and !empty($_POST['url']) and isset($_POST['gpgkey']) and isset($_POST['sslCertificatePath']) and isset($_POST['sslPrivateKeyPath']) and isset($_POST['sslCaCertificatePath'])) { $mysource = new \Controllers\Source(); try { - $mysource->edit($_POST['id'], $_POST['name'], $_POST['url'], $_POST['gpgkey'], $_POST['sslCertificatePath'], $_POST['sslPrivateKeyPath']); + $mysource->edit($_POST['id'], $_POST['name'], $_POST['url'], $_POST['gpgkey'], $_POST['sslCertificatePath'], $_POST['sslPrivateKeyPath'], $_POST['sslCaCertificatePath']); } catch (\Exception $e) { response(HTTP_BAD_REQUEST, $e->getMessage()); } diff --git a/www/models/Connection.php b/www/models/Connection.php index 61173f53..5e6915be 100644 --- a/www/models/Connection.php +++ b/www/models/Connection.php @@ -305,7 +305,8 @@ private function generateMainTables() Url VARCHAR(255) NOT NULL, Gpgkey VARCHAR(255), Ssl_certificate_path VARCHAR(255), - Ssl_private_key_path VARCHAR(255))"); + Ssl_private_key_path VARCHAR(255), + Ssl_ca_certificate_path VARCHAR(255))"); /** * users table @@ -506,7 +507,6 @@ private function generateMainTables() GPG_SIGNING_KEYID VARCHAR(255), /* Scheduled tasks settings */ PLANS_REMINDERS_ENABLED CHAR(5), - PLANS_CLEAN_REPOS CHAR(5), /* Statistics & metrics settings */ STATS_ENABLED CHAR(5), /* Hosts and profiles settings */ @@ -555,7 +555,6 @@ private function generateMainTables() DEB_INVALID_SIGNATURE, GPG_SIGNING_KEYID, PLANS_REMINDERS_ENABLED, - PLANS_CLEAN_REPOS, RETENTION, STATS_ENABLED, MANAGE_HOSTS, @@ -583,7 +582,6 @@ private function generateMainTables() 'error', '$gpgKeyId', 'false', - 'false', '3', 'false', 'false', diff --git a/www/models/Source.php b/www/models/Source.php index 0dd27212..5295553e 100644 --- a/www/models/Source.php +++ b/www/models/Source.php @@ -108,16 +108,17 @@ public function new(string $repoType, string $name, string $url, string $gpgKeyU /** * Edit a source repo */ - public function edit(string $id, string $name, string $url, string|null $gpgKeyURL, string|null $sslCertificatePath, string|null $sslPrivateKeyPath) + public function edit(string $id, string $name, string $url, string|null $gpgKeyURL, string|null $sslCertificatePath, string|null $sslPrivateKeyPath, string|null $sslCaCertificatePath) { try { - $stmt = $this->db->prepare('UPDATE sources SET Name = :name, Url = :url, Gpgkey = :gpgKeyUrl, Ssl_certificate_path = :sslCertificatePath, Ssl_private_key_path = :sslPrivateKeyPath WHERE Id = :id'); + $stmt = $this->db->prepare('UPDATE sources SET Name = :name, Url = :url, Gpgkey = :gpgKeyUrl, Ssl_certificate_path = :sslCertificatePath, Ssl_private_key_path = :sslPrivateKeyPath, Ssl_ca_certificate_path = :sslCaCertificatePath WHERE Id = :id'); $stmt->bindValue(':id', $id); $stmt->bindValue(':name', $name); $stmt->bindValue(':url', $url); $stmt->bindValue(':gpgKeyUrl', $gpgKeyURL); $stmt->bindValue(':sslCertificatePath', $sslCertificatePath); $stmt->bindValue(':sslPrivateKeyPath', $sslPrivateKeyPath); + $stmt->bindValue(':sslCaCertificatePath', $sslCaCertificatePath); $stmt->execute(); } catch (\Exception $e) { \Controllers\Common::dbError($e); diff --git a/www/public/resources/js/source.js b/www/public/resources/js/source.js index 97a5f87c..7ee34eb2 100644 --- a/www/public/resources/js/source.js +++ b/www/public/resources/js/source.js @@ -44,10 +44,11 @@ $(document).on('submit','.source-form',function () { var name = $(this).find('.source-input-name').val(); var url = $(this).find('.source-input-url').val(); var gpgkey = $(this).find('.source-gpgkey-input').val(); - var sslCertificatePath = $(this).find('.source-sslcrt-input').val(); - var sslPrivateKeyPath = $(this).find('.source-sslkey-input').val(); + var sslCertificatePath = $(this).find('.source-ssl-crt-input').val(); + var sslPrivateKeyPath = $(this).find('.source-ssl-key-input').val(); + var sslCaCertificatePath = $(this).find('.source-ssl-cacrt-input').val(); - editSource(id, name, url, gpgkey, sslCertificatePath, sslPrivateKeyPath); + editSource(id, name, url, gpgkey, sslCertificatePath, sslPrivateKeyPath, sslCaCertificatePath); return false; }); @@ -141,8 +142,9 @@ function newSource(repoType, name, url, gpgKeyURL, gpgKeyText) * @param {*} gpgkey * @param {*} sslCertificatePath * @param {*} sslPrivateKeyPath + * @param {*} sslCaCertificatePath */ -function editSource(id, name, url, gpgkey, sslCertificatePath, sslPrivateKeyPath) +function editSource(id, name, url, gpgkey, sslCertificatePath, sslPrivateKeyPath, sslCaCertificatePath) { $.ajax({ type: "POST", @@ -155,7 +157,8 @@ function editSource(id, name, url, gpgkey, sslCertificatePath, sslPrivateKeyPath url: url, gpgkey: gpgkey, sslCertificatePath: sslCertificatePath, - sslPrivateKeyPath: sslPrivateKeyPath + sslPrivateKeyPath: sslPrivateKeyPath, + sslCaCertificatePath: sslCaCertificatePath }, dataType: "json", success: function (data, textStatus, jqXHR) { diff --git a/www/public/resources/js/task.js b/www/public/resources/js/task.js index f15e8d1e..f08a2128 100644 --- a/www/public/resources/js/task.js +++ b/www/public/resources/js/task.js @@ -35,7 +35,7 @@ function reloadNewRepoDiv() */ function countChecked() { - var countTotal = $('.reposList').find('input[name=checkbox-repo\\[\\]]:checked').length; + var countTotal = $('.reposList').find('input[name=checkbox-repo]:checked').length; return countTotal; }; @@ -183,7 +183,7 @@ $(document).on('click','.delete-env-btn',function () { /** * Event: when a checkbox is checked/unchecked */ -$(document).on('click',"input[name=checkbox-repo\\[\\]]",function () { +$(document).on('click',"input[name=checkbox-repo]",function () { /** * Count the number of checked checkboxes */ @@ -195,7 +195,7 @@ $(document).on('click',"input[name=checkbox-repo\\[\\]]",function () { */ if (count_checked == 0) { $('#repo-actions-btn-container').hide(); - $('.reposList').find('input[name=checkbox-repo\\[\\]]').removeAttr('style'); + $('.reposList').find('input[name=checkbox-repo]').removeAttr('style'); return; } else { $('#newalert').remove(); @@ -206,13 +206,13 @@ $(document).on('click',"input[name=checkbox-repo\\[\\]]",function () { * If there is at least 1 checkbox checked then we display all the other checkboxes * All checked checkboxes are set to opacity = 1 */ - $('.reposList').find('input[name=checkbox-repo\\[\\]]').css("visibility", "visible"); - $('.reposList').find('input[name=checkbox-repo\\[\\]]:checked').css("opacity", "1"); + $('.reposList').find('input[name=checkbox-repo]').css("visibility", "visible"); + $('.reposList').find('input[name=checkbox-repo]:checked').css("opacity", "1"); /** * If a 'local' repo is checked then we hide the 'update' button */ - if ($('.reposList').find('input[name=checkbox-repo\\[\\]][repo-type=local]:checked').length > 0) { + if ($('.reposList').find('input[name=checkbox-repo][repo-type=local]:checked').length > 0) { $('.repo-action-btn[action=update]').hide(); } else { $('.repo-action-btn[action=update]').show(); @@ -238,7 +238,7 @@ $(document).on('click',".repo-action-btn",function () { /** * Loop through all checked repos and retrieve their id */ - $('.reposList').find('input[name=checkbox-repo\\[\\]]:checked').each(function () { + $('.reposList').find('input[name=checkbox-repo]:checked').each(function () { var obj = {}; /** @@ -293,11 +293,6 @@ $(document).on('click',".task-schedule-btn", function () { */ var form = $(this).parents('.task-form'); - /** - * Show schedule params from this form - */ - - /** * Change button text and color if schedule is checked */ @@ -492,7 +487,14 @@ $(document).on('submit','.task-form',function () { // Reload container: [], // Execute functions on success: - [ 'closePanel()' ] + [ + 'closePanel()', + // Uncheck all checkboxes and remove all styles JQuery could have applied + "$('.reposList').find('input[name=checkbox-repo]').prop('checked', false);", + "$('.reposList').find('input[name=checkbox-repo]').removeAttr('style');", + // Reload right panel + "reloadContainer('repos/properties')" + ] ); return false; diff --git a/www/public/resources/styles/common.css b/www/public/resources/styles/common.css index ce5bb8fc..4f52c7f8 100644 --- a/www/public/resources/styles/common.css +++ b/www/public/resources/styles/common.css @@ -1,5 +1,5 @@ /** - * v1.7 + * v1.8 */ @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap'); @@ -115,6 +115,7 @@ pre { .flex-direction-column {flex-direction: column} .grid {display: grid} .grid-2 {grid-template-columns: 1fr 1fr !important} +.grid-3 {grid-template-columns: 1fr 1fr 1fr !important} .grid-fr-1-2 {grid-template-columns: 1fr 2fr !important} .grid-fr-2-1 {grid-template-columns: 2fr 1fr !important} .grid-fr-4-1 {grid-template-columns: 4fr 1fr !important} @@ -126,7 +127,7 @@ pre { .align-content-center {align-content: center} .align-content-right {align-content: flex-end} .align-item-center {align-items: center} -.align-item-right {align-items: flex-end} +.align-item-right, .align-flex-end {align-items: flex-end} .align-self-center {align-self: center} .column-gap-1{column-gap: 1px}.column-gap-2 {column-gap: 2px}.column-gap-4 {column-gap: 4px}.column-gap-5{column-gap: 5px}.column-gap-6{column-gap: 6px}.column-gap-7{column-gap: 7px}.column-gap-8{column-gap: 8px}.column-gap-9{column-gap: 9px}.column-gap-10{column-gap: 10px}.column-gap-15{column-gap: 15px} .column-gap-20{column-gap: 20px}.column-gap-30{column-gap: 30px}.column-gap-40{column-gap: 40px}.column-gap-50{column-gap: 50px}.column-gap-60{column-gap: 60px}.column-gap-70{column-gap: 70px}.column-gap-80{column-gap: 80px}.column-gap-90{column-gap: 90px}.column-gap-100{column-gap: 100px} @@ -252,7 +253,10 @@ td { cursor: pointer; } .icon-small { - height: 8px; + height: 8px !important; +} +.icon-medium { + height: 12px !important; } .icon-lowopacity { opacity: 0.33; @@ -320,6 +324,7 @@ input::placeholder { display: inline-block; font-size: 14px; cursor: pointer; + box-shadow: rgba(12, 18, 20, 0.504) 0px 0px 10px 1px; } /* Tous les boutons bleus */ @@ -417,6 +422,7 @@ input::placeholder { background-color: #15bf7f; border-radius: 60px; cursor: pointer; + box-shadow: rgba(12, 18, 20, 0.504) 0px 0px 10px 1px; } [class^="slide-btn"] img { width: 16px; @@ -707,7 +713,7 @@ textarea { position: fixed; bottom: 0; left: 0; - z-index:1000; + z-index: 1000; background-color: #182b3e; border-top: 1px solid rgb(60, 70, 75); box-shadow: rgb(0 0 0) 0px 10px 13px -12px, rgb(0 0 0 / 15%) 0px 0px 10px 2px; @@ -756,7 +762,7 @@ textarea { display: flex; align-items: center; column-gap: 8px ; - z-index: 999; + z-index: 998; } #loading img { @@ -777,7 +783,7 @@ textarea { height: 100%; background-color: #182b3e82; border-radius: 8px; - z-index: 999; + z-index: 998; } /** diff --git a/www/tasks/execute.php b/www/tasks/execute.php index 68868243..401517e5 100644 --- a/www/tasks/execute.php +++ b/www/tasks/execute.php @@ -5,7 +5,7 @@ require_once(ROOT . "/controllers/Autoloader.php"); new \Controllers\Autoloader('api'); -ini_set('memory_limit', '256M'); +ini_set('memory_limit', '512M'); $myTask = new \Controllers\Task\Task(); $mylog = new \Controllers\Log\Log(); diff --git a/www/update/database/3.5.3.php b/www/update/database/3.5.3.php index 61f8cc34..ce9e4613 100644 --- a/www/update/database/3.5.3.php +++ b/www/update/database/3.5.3.php @@ -54,43 +54,43 @@ // centos 8 stream array( 'type' => 'rpm', - 'name' => 'baseos-8', + 'name' => 'centos8-baseos', 'url' => 'http://mirror.centos.org/centos/8-stream/BaseOS/$basearch/os/' ), array( 'type' => 'rpm', - 'name' => 'appstream-8', + 'name' => 'centos8-appstream', 'url' => 'http://mirror.centos.org/centos/8-stream/AppStream/$basearch/os/' ), array( 'type' => 'rpm', - 'name' => 'extras-8', + 'name' => 'centos8-extras', 'url' => 'http://mirror.centos.org/centos/8-stream/extras/$basearch/os/' ), array( 'type' => 'rpm', - 'name' => 'epel-8', + 'name' => 'epel8', 'url' => 'https://dl.fedoraproject.org/pub/epel/8/Everything/$basearch/' ), // centos 9 stream array( 'type' => 'rpm', - 'name' => 'baseos-9', + 'name' => 'centos9-baseos', 'url' => 'https://mirror.stream.centos.org/9-stream/BaseOS/$basearch/os/' ), array( 'type' => 'rpm', - 'name' => 'appstream-9', + 'name' => 'centos9-appstream', 'url' => 'https://mirror.stream.centos.org/9-stream/AppStream/$basearch/os/' ), array( 'type' => 'rpm', - 'name' => 'extras-common-9', + 'name' => 'centos9-extras-common', 'url' => 'https://mirror.stream.centos.org/SIGs/9-stream/extras/$basearch/extras-common/' ), array( 'type' => 'rpm', - 'name' => 'epel-9', + 'name' => 'epel9', 'url' => 'https://dl.fedoraproject.org/pub/epel/9/Everything/$basearch/' ) ); diff --git a/www/update/database/4.2.0.php b/www/update/database/4.2.0.php new file mode 100644 index 00000000..b3d55f41 --- /dev/null +++ b/www/update/database/4.2.0.php @@ -0,0 +1,154 @@ + +db->tableExist('planifications') === true) { + $this->db->exec('DROP TABLE planifications'); + $vacumm++; +} + +/** + * Drop 'operations' table if exists + */ +if ($this->db->tableExist('operations') === true) { + $this->db->exec('DROP TABLE operations'); + $vacumm++; +} + +/** + * Drop 'PLANS_CLEAN_REPOS' column from the settings table + */ +if ($this->db->columnExist('settings', 'PLANS_CLEAN_REPOS') === true) { + $this->db->exec('ALTER TABLE settings DROP COLUMN PLANS_CLEAN_REPOS'); + $vacumm++; +} + +/** + * Drop 'RPM_SIGN_IGNORE_MISSING_SIGNATURE' column from the settings table + */ +if ($this->db->columnExist('settings', 'RPM_SIGN_IGNORE_MISSING_SIGNATURE') === true) { + $this->db->exec('ALTER TABLE settings DROP COLUMN RPM_SIGN_IGNORE_MISSING_SIGNATURE'); + $vacumm++; +} + +/** + * Add 'Ssl_ca_certificate_path' column to the sources table + */ +if ($this->db->columnExist('sources', 'Ssl_ca_certificate_path') === false) { + $this->db->exec('ALTER TABLE sources ADD COLUMN Ssl_ca_certificate_path VARCHAR(255)'); + $vacumm++; +} + +if ($vacumm > 0) { + $this->db->exec('VACUUM'); +} + +/** + * Add Redhat sources repositories and GPG keys + */ +$mysource = new \Controllers\Source(); + +/** + * Sources URLs + */ +$sources = array( + // Redhat + array( + 'type' => 'rpm', + 'name' => 'redhat-baseos', + 'url' => 'https://cdn.redhat.com/content/dist/rhel$releasever/$releasever/x86_64/baseos/os' + ), + array( + 'type' => 'rpm', + 'name' => 'redhat-appstream', + 'url' => 'https://cdn.redhat.com/content/dist/rhel$releasever/$releasever/x86_64/appstream/os' + ), +); + +/** + * Sources GPG keys + */ +$gpgkeys = array( + // RPM-GPG-KEY-redhat-release + '-----BEGIN PGP PUBLIC KEY BLOCK----- + + mQINBErgSTsBEACh2A4b0O9t+vzC9VrVtL1AKvUWi9OPCjkvR7Xd8DtJxeeMZ5eF + 0HtzIG58qDRybwUe89FZprB1ffuUKzdE+HcL3FbNWSSOXVjZIersdXyH3NvnLLLF + 0DNRB2ix3bXG9Rh/RXpFsNxDp2CEMdUvbYCzE79K1EnUTVh1L0Of023FtPSZXX0c + u7Pb5DI5lX5YeoXO6RoodrIGYJsVBQWnrWw4xNTconUfNPk0EGZtEnzvH2zyPoJh + XGF+Ncu9XwbalnYde10OCvSWAZ5zTCpoLMTvQjWpbCdWXJzCm6G+/hx9upke546H + 5IjtYm4dTIVTnc3wvDiODgBKRzOl9rEOCIgOuGtDxRxcQkjrC+xvg5Vkqn7vBUyW + 9pHedOU+PoF3DGOM+dqv+eNKBvh9YF9ugFAQBkcG7viZgvGEMGGUpzNgN7XnS1gj + /DPo9mZESOYnKceve2tIC87p2hqjrxOHuI7fkZYeNIcAoa83rBltFXaBDYhWAKS1 + PcXS1/7JzP0ky7d0L6Xbu/If5kqWQpKwUInXtySRkuraVfuK3Bpa+X1XecWi24JY + HVtlNX025xx1ewVzGNCTlWn1skQN2OOoQTV4C8/qFpTW6DTWYurd4+fE0OJFJZQF + buhfXYwmRlVOgN5i77NTIJZJQfYFj38c/Iv5vZBPokO6mffrOTv3MHWVgQARAQAB + tDNSZWQgSGF0LCBJbmMuIChyZWxlYXNlIGtleSAyKSA8c2VjdXJpdHlAcmVkaGF0 + LmNvbT6JAjYEEwECACAFAkrgSTsCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK + CRAZni+R/UMdUWzpD/9s5SFR/ZF3yjY5VLUFLMXIKUztNN3oc45fyLdTI3+UClKC + 2tEruzYjqNHhqAEXa2sN1fMrsuKec61Ll2NfvJjkLKDvgVIh7kM7aslNYVOP6BTf + C/JJ7/ufz3UZmyViH/WDl+AYdgk3JqCIO5w5ryrC9IyBzYv2m0HqYbWfphY3uHw5 + un3ndLJcu8+BGP5F+ONQEGl+DRH58Il9Jp3HwbRa7dvkPgEhfFR+1hI+Btta2C7E + 0/2NKzCxZw7Lx3PBRcU92YKyaEihfy/aQKZCAuyfKiMvsmzs+4poIX7I9NQCJpyE + IGfINoZ7VxqHwRn/d5mw2MZTJjbzSf+Um9YJyA0iEEyD6qjriWQRbuxpQXmlAJbh + 8okZ4gbVFv1F8MzK+4R8VvWJ0XxgtikSo72fHjwha7MAjqFnOq6eo6fEC/75g3NL + Ght5VdpGuHk0vbdENHMC8wS99e5qXGNDued3hlTavDMlEAHl34q2H9nakTGRF5Ki + JUfNh3DVRGhg8cMIti21njiRh7gyFI2OccATY7bBSr79JhuNwelHuxLrCFpY7V25 + OFktl15jZJaMxuQBqYdBgSay2G0U6D1+7VsWufpzd/Abx1/c3oi9ZaJvW22kAggq + dzdA27UUYjWvx42w9menJwh/0jeQcTecIUd0d0rFcw/c1pvgMMl/Q73yzKgKYw== + =zbHE + -----END PGP PUBLIC KEY BLOCK----- + -----BEGIN PGP PUBLIC KEY BLOCK----- + + mQINBGIpIp4BEAC/o5e1WzLIsS6/JOQCs4XYATYTcf6B6ALzcP05G0W3uRpUQSrL + FRKNrU8ZCelm/B+XSh2ljJNeklp2WLxYENDOsftDXGoyLr2hEkI5OyK267IHhFNJ + g+BN+T5Cjh4ZiiWij6o9F7x2ZpxISE9M4iI80rwSv1KOnGSw5j2zD2EwoMjTVyVE + /t3s5XJxnDclB7ZqL+cgjv0mWUY/4+b/OoRTkhq7b8QILuZp75Y64pkrndgakm1T + 8mAGXV02mEzpNj9DyAJdUqa11PIhMJMxxHOGHJ8CcHZ2NJL2e7yJf4orTj+cMhP5 + LzJcVlaXnQYu8Zkqa0V6J1Qdj8ZXL72QsmyicRYXAtK9Jm5pvBHuYU2m6Ja7dBEB + Vkhe7lTKhAjkZC5ErPmANNS9kPdtXCOpwN1lOnmD2m04hks3kpH9OTX7RkTFUSws + eARAfRID6RLfi59B9lmAbekecnsMIFMx7qR7ZKyQb3GOuZwNYOaYFevuxusSwCHv + 4FtLDIhk+Fge+EbPdEva+VLJeMOb02gC4V/cX/oFoPkxM1A5LHjkuAM+aFLAiIRd + Np/tAPWk1k6yc+FqkcDqOttbP4ciiXb9JPtmzTCbJD8lgH0rGp8ufyMXC9x7/dqX + TjsiGzyvlMnrkKB4GL4DqRFl8LAR02A3846DD8CAcaxoXggL2bJCU2rgUQARAQAB + tDVSZWQgSGF0LCBJbmMuIChhdXhpbGlhcnkga2V5IDMpIDxzZWN1cml0eUByZWRo + YXQuY29tPokCUgQTAQgAPBYhBH5GJCWMQGU11W1vE1BU5KRaY0CzBQJiKSKeAhsD + BQsJCAcCAyICAQYVCgkICwIEFgIDAQIeBwIXgAAKCRBQVOSkWmNAsyBfEACuTN/X + YR+QyzeRw0pXcTvMqzNE4DKKr97hSQEwZH1/v1PEPs5O3psuVUm2iam7bqYwG+ry + EskAgMHi8AJmY0lioQD5/LTSLTrM8UyQnU3g17DHau1NHIFTGyaW4a7xviU4C2+k + c6X0u1CPHI1U4Q8prpNcfLsldaNYlsVZtUtYSHKPAUcswXWliW7QYjZ5tMSbu8jR + OMOc3mZuf0fcVFNu8+XSpN7qLhRNcPv+FCNmk/wkaQfH4Pv+jVsOgHqkV3aLqJeN + kNUnpyEKYkNqo7mNfNVWOcl+Z1KKKwSkIi3vg8maC7rODsy6IX+Y96M93sqYDQom + aaWue2gvw6thEoH4SaCrCL78mj2YFpeg1Oew4QwVcBnt68KOPfL9YyoOicNs4Vuu + fb/vjU2ONPZAeepIKA8QxCETiryCcP43daqThvIgdbUIiWne3gae6eSj0EuUPoYe + H5g2Lw0qdwbHIOxqp2kvN96Ii7s1DK3VyhMt/GSPCxRnDRJ8oQKJ2W/I1IT5VtiU + zMjjq5JcYzRPzHDxfVzT9CLeU/0XQ+2OOUAiZKZ0dzSyyVn8xbpviT7iadvjlQX3 + CINaPB+d2Kxa6uFWh+ZYOLLAgZ9B8NKutUHpXN66YSfe79xFBSFWKkJ8cSIMk13/ + Ifs7ApKlKCCRDpwoDqx/sjIaj1cpOfLHYjnefg== + =UZd/ + -----END PGP PUBLIC KEY BLOCK-----' +); + +foreach ($sources as $source) { + /** + * Check if source repo already exists + */ + if ($mysource->exists($source['type'], $source['name']) === true) { + continue; + } + + /** + * Insert source repo in database + */ + $mysource->new($source['type'], $source['name'], $source['url']); +} + +foreach ($gpgkeys as $gpgkey) { + $mysource->importGpgKey($gpgkey); +} diff --git a/www/update/database/x.x.x.php.wip b/www/update/database/x.x.x.php.wip deleted file mode 100644 index b9168e8d..00000000 --- a/www/update/database/x.x.x.php.wip +++ /dev/null @@ -1,26 +0,0 @@ - -db->tableExist('planifications') === true) { - $this->db->exec('DROP TABLE planifications'); - $vacumm++; -} - -/** - * Drop 'operations' table if exists - */ -if ($this->db->tableExist('operations') === true) { - $this->db->exec('DROP TABLE operations'); - $vacumm++; -} - -if ($vacumm > 0) { - $this->db->exec('VACUUM'); -} diff --git a/www/version b/www/version index 627a3f43..ef8d7569 100644 --- a/www/version +++ b/www/version @@ -1 +1 @@ -4.1.1 +4.2.0 \ No newline at end of file diff --git a/www/views/includes/repos-list.inc.php b/www/views/includes/repos-list.inc.php index 1725a831..070db64e 100644 --- a/www/views/includes/repos-list.inc.php +++ b/www/views/includes/repos-list.inc.php @@ -254,7 +254,7 @@ - repo-type="" title="Select and execute an action."> + repo-type="" title="Select and execute an action."> Path to SSL certificate - + Path to SSL private key - + + + + Path to SSL CA certificate + +