Skip to content

Commit

Permalink
3.7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Oct 30, 2023
1 parent 22d5ae6 commit 956861f
Show file tree
Hide file tree
Showing 27 changed files with 646 additions and 3,522 deletions.
4 changes: 2 additions & 2 deletions www/config/properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
'project_update_doc_url' => 'https://github.com/lbr38/repomanager/wiki/01.-Installation-and-update#update-repomanager',

// DEB default values
'deb_archs' => array('all', 'amd64', 'arm64', 'armel', 'armhf', 'i386', 'mips', 'mips64el', 'mipsel', 'ppc64el', 's390x'),
'deb_archs' => array('amd64', 'arm64', 'armel', 'armhf', 'i386', 'mips', 'mips64el', 'mipsel', 'ppc64el', 's390x', 'src'),

// RPM default values
'rpm_archs' => array('noarch', 'i386', 'i586', 'i686', 'x86_64', 'armv6hl', 'armv7hl', 'aarch64', 'ppc64', 'ppc64le', 's390x'),
'rpm_archs' => array('noarch', 'i386', 'i586', 'i686', 'x86_64', 'armv6hl', 'armv7hl', 'aarch64', 'ppc64', 'ppc64le', 's390x', 'src'),
);
174 changes: 85 additions & 89 deletions www/controllers/App/Config/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public static function get()
$settings = $mysettings->get();

/**
* Si certains paramètres sont vides alors on incrémente $EMPTY_CONFIGURATION_VARIABLES qui fera afficher un bandeau d'alertes.
* Certains paramètres font exceptions et peuvent rester vides
* If some settings are empty then we increment $EMPTY_CONFIGURATION_VARIABLES which will display a warning banner.
* Some settings are exceptions and can be empty
*/
foreach ($settings as $key => $value) {
/**
* Les paramètres suivants peuvent rester vides, on n'incrémente pas le compteur d'erreurs dans leur cas
* Following parameters can be empty, we don't increment the error counter in their case
*/
$ignoreEmptyParam = array('STATS_LOG_PATH', 'RPM_DEFAULT_ARCH', 'DEB_DEFAULT_ARCH', 'DEB_DEFAULT_TRANSLATION', 'REPO_CONF_FILES_PREFIX');

Expand All @@ -42,17 +42,12 @@ public static function get()
}

if (!defined('REPOS_DIR')) {
if (!empty($settings['REPOS_DIR'])) {
define('REPOS_DIR', $settings['REPOS_DIR']);
define('REPOS_DIR', '/home/repo');
}

if (!is_writable(REPOS_DIR)) {
++$__LOAD_SETTINGS_ERROR; // On force l'affichage d'un message d'erreur même si le paramètre n'est pas vide
$__LOAD_SETTINGS_MESSAGES[] = "Repos directory '" . REPOS_DIR . "' is not writeable.";
}
} else {
define('REPOS_DIR', '');
$__LOAD_SETTINGS_MESSAGES[] = 'Repos directory is not defined. ';
}
if (!is_writable(REPOS_DIR)) {
++$__LOAD_SETTINGS_ERROR;
$__LOAD_SETTINGS_MESSAGES[] = "Repos directory '" . REPOS_DIR . "' is not writeable.";
}

if (!defined('TIMEZONE')) {
Expand Down Expand Up @@ -100,18 +95,42 @@ public static function get()
}

if (!defined('WWW_USER')) {
if (!empty($settings['WWW_USER'])) {
define('WWW_USER', $settings['WWW_USER']);
} else {
define('WWW_USER', '');
$__LOAD_SETTINGS_MESSAGES[] = "Linux web dedied user is not defined.";
}
define('WWW_USER', 'www-data');
}

/**
* Paramètres de repos
* Repositories
*/

// Global settings
if (!defined('REPO_CONF_FILES_PREFIX')) {
if (!empty($settings['REPO_CONF_FILES_PREFIX'])) {
define('REPO_CONF_FILES_PREFIX', $settings['REPO_CONF_FILES_PREFIX']);
} else {
define('REPO_CONF_FILES_PREFIX', '');
}
}

if (!defined('RETENTION')) {
if (isset($settings['RETENTION']) and $settings['RETENTION'] >= 0) {
define('RETENTION', intval($settings['RETENTION'], 8));
} else {
define('RETENTION', '');
if (defined('PLANS_ENABLED') and PLANS_ENABLED == "true") {
$__LOAD_SETTINGS_MESSAGES[] = "Repository snapshots retention is not defined.";
}
}
}

// Mirroring settings
if (!defined('MIRRORING_PACKAGE_DOWNLOAD_TIMEOUT')) {
if (!empty($settings['MIRRORING_PACKAGE_DOWNLOAD_TIMEOUT'])) {
define('MIRRORING_PACKAGE_DOWNLOAD_TIMEOUT', $settings['MIRRORING_PACKAGE_DOWNLOAD_TIMEOUT']);
} else {
define('MIRRORING_PACKAGE_DOWNLOAD_TIMEOUT', '300');
}
}

// RPM
if (!defined('RPM_REPO')) {
if (!empty($settings['RPM_REPO'])) {
Expand Down Expand Up @@ -140,7 +159,7 @@ public static function get()
define('RELEASEVER', '');

/**
* On affiche un message uniquement si les repos RPM sont activés.
* Print a message only if RPM repositories are enabled.
*/
if (RPM_REPO == 'true') {
$__LOAD_SETTINGS_MESSAGES[] = "Release version for RPM repositories is not defined.";
Expand Down Expand Up @@ -205,6 +224,7 @@ public static function get()
}
}

// GPG signature key
if (!defined('GPG_SIGNING_KEYID')) {
if (!empty($settings['GPG_SIGNING_KEYID'])) {
define('GPG_SIGNING_KEYID', $settings['GPG_SIGNING_KEYID']);
Expand All @@ -213,19 +233,48 @@ public static function get()
* Define a default key ID
*/
define('GPG_SIGNING_KEYID', '');
$__LOAD_SETTINGS_MESSAGES[] = "GPG key Id is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "GPG signature key Id is not defined.";
}
}

// Statistics and metrics
if (!defined('STATS_ENABLED')) {
if (!empty($settings['STATS_ENABLED'])) {
define('STATS_ENABLED', $settings['STATS_ENABLED']);
} else {
define('STATS_ENABLED', '');
$__LOAD_SETTINGS_MESSAGES[] = "Enabling repos statistics is not defined.";
}
}

if (STATS_ENABLED == "true") {
if (!defined('STATS_LOG_PATH')) {
if (!empty($settings['STATS_LOG_PATH'])) {
define('STATS_LOG_PATH', $settings['STATS_LOG_PATH']);

/**
* On teste l'accès au chemin renseigné
*/
if (!is_readable(STATS_LOG_PATH)) {
++$__LOAD_SETTINGS_ERROR; // On force l'affichage d'un message d'erreur même si le paramètre n'est pas vide
$__LOAD_SETTINGS_MESSAGES[] = "Access log file to scan for statistics is not readable: '" . STATS_LOG_PATH . "'";
}
} else {
define('STATS_LOG_PATH', '');
$__LOAD_SETTINGS_MESSAGES[] = "Access log file to scan for statistics is not defined.";
}
}
}

/**
* Paramètres d'automatisation
* Planifications settings
*/
if (!defined('PLANS_ENABLED')) {
if (!empty($settings['PLANS_ENABLED'])) {
define('PLANS_ENABLED', $settings['PLANS_ENABLED']);
} else {
define('PLANS_ENABLED', '');
$__LOAD_SETTINGS_MESSAGES[] = "Enabling plans is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "Enabling planifications is not defined.";
}
}

Expand All @@ -243,7 +292,7 @@ public static function get()
} else {
define('PLANS_UPDATE_REPO', '');
if (defined('PLANS_ENABLED') and PLANS_ENABLED == "true") {
$__LOAD_SETTINGS_MESSAGES[] = "Allowing plans to update repositories is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "Allowing planifications to update repositories is not defined.";
}
}
}
Expand All @@ -254,24 +303,13 @@ public static function get()
} else {
define('PLANS_CLEAN_REPOS', '');
if (defined('PLANS_ENABLED') and PLANS_ENABLED == "true") {
$__LOAD_SETTINGS_MESSAGES[] = "Allowing plans to delete old repos snapshots is not defined.";
}
}
}

if (!defined('RETENTION')) {
if (isset($settings['RETENTION']) and $settings['RETENTION'] >= 0) {
define('RETENTION', intval($settings['RETENTION'], 8));
} else {
define('RETENTION', '');
if (defined('PLANS_ENABLED') and PLANS_ENABLED == "true") {
$__LOAD_SETTINGS_MESSAGES[] = "Old repos snapshots retention is not defined.";
$__LOAD_SETTINGS_MESSAGES[] = "Allowing planifications to delete old repos snapshots is not defined.";
}
}
}

/**
* Paramètres des hôtes
* Hosts and profiles settings
*/
if (!defined('MANAGE_HOSTS')) {
if (!empty($settings['MANAGE_HOSTS'])) {
Expand All @@ -282,6 +320,15 @@ public static function get()
}
}

if (!defined('MANAGE_PROFILES')) {
if (!empty($settings['MANAGE_PROFILES'])) {
define('MANAGE_PROFILES', $settings['MANAGE_PROFILES']);
} else {
define('MANAGE_PROFILES', '');
$__LOAD_SETTINGS_MESSAGES[] = "Enabling profiles management is not defined.";
}
}

/**
* CVE settings
*/
Expand Down Expand Up @@ -309,57 +356,6 @@ public static function get()
}
}

/**
* Paramètres des profils
*/
if (!defined('MANAGE_PROFILES')) {
if (!empty($settings['MANAGE_PROFILES'])) {
define('MANAGE_PROFILES', $settings['MANAGE_PROFILES']);
} else {
define('MANAGE_PROFILES', '');
$__LOAD_SETTINGS_MESSAGES[] = "Enabling profiles management is not defined.";
}
}

if (!defined('REPO_CONF_FILES_PREFIX')) {
if (!empty($settings['REPO_CONF_FILES_PREFIX'])) {
define('REPO_CONF_FILES_PREFIX', $settings['REPO_CONF_FILES_PREFIX']);
} else {
define('REPO_CONF_FILES_PREFIX', '');
}
}

/**
* Paramètres statistiques
*/
if (!defined('STATS_ENABLED')) {
if (!empty($settings['STATS_ENABLED'])) {
define('STATS_ENABLED', $settings['STATS_ENABLED']);
} else {
define('STATS_ENABLED', '');
$__LOAD_SETTINGS_MESSAGES[] = "Enabling repos statistics is not defined.";
}
}

if (STATS_ENABLED == "true") {
if (!defined('STATS_LOG_PATH')) {
if (!empty($settings['STATS_LOG_PATH'])) {
define('STATS_LOG_PATH', $settings['STATS_LOG_PATH']);

/**
* On teste l'accès au chemin renseigné
*/
if (!is_readable(STATS_LOG_PATH)) {
++$__LOAD_SETTINGS_ERROR; // On force l'affichage d'un message d'erreur même si le paramètre n'est pas vide
$__LOAD_SETTINGS_MESSAGES[] = "Access log file to scan for statistics is not readable: '" . STATS_LOG_PATH . "'";
}
} else {
define('STATS_LOG_PATH', '');
$__LOAD_SETTINGS_MESSAGES[] = "Access log file to scan for statistics is not defined.";
}
}
}

if (!defined('__LOAD_SETTINGS_ERROR')) {
define('__LOAD_SETTINGS_ERROR', $__LOAD_SETTINGS_ERROR);
}
Expand Down
11 changes: 9 additions & 2 deletions www/controllers/Browse.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ public static function printFile($file, $path)
echo '<li>';

/**
* On affiche une checkbox permettant de supprimer le fichier seulement si il s'agit d'un fichier .rpm ou .deb
* Print a checkbox to delete the file only if it is a package file
*/
if (substr($file, -4) == ".rpm" or substr($file, -4) == ".deb" or substr($file, -4) == ".dsc" or substr($file, -7) == ".tar.xz" or substr($file, -7) == ".tar.gz") {
if (substr($file, -4) == ".rpm"
or substr($file, -4) == ".deb"
or substr($file, -4) == ".asc"
or substr($file, -4) == ".bz2"
or substr($file, -4) == ".dsc"
or substr($file, -8) == ".diff.gz"
or substr($file, -7) == ".tar.gz"
or substr($file, -7) == ".tar.xz") {
echo '<div class="explorer-file-pkg header-light-blue"><input type="checkbox" class="packageName-checkbox pointer" name="packageName[]" filename="' . $file . '" path="' . $path . '" /><img src="/assets/icons/package.svg" class="icon" /><span>' . $file . '</span></div>';
} else {
echo '<div class="explorer-file header-blue"><img src="/assets/icons/file.svg" class="icon" /><span>' . $file . '</span></div>';
Expand Down
8 changes: 8 additions & 0 deletions www/controllers/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,4 +726,12 @@ public static function printProductIcon(string $product)
return '<img src="/assets/icons/package.svg" class="icon-np" />';
}
}

/**
* Returns true if string is a valid md5 hash
*/
public static function isMd5(string $md5)
{
return preg_match('/^[a-f0-9]{32}$/', $md5);
}
}
4 changes: 2 additions & 2 deletions www/controllers/Operation/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function validateForm(array $operations_params)
Param\Name::check($targetName);
Param\GpgCheck::check($operation_params['targetGpgCheck']);
Param\GpgResign::check($operation_params['targetGpgResign']);
Param\SourcePackageInc::check($operation_params['targetSourcePackage']);
// Param\SourcePackageInc::check($operation_params['targetSourcePackage']);

if ($packageType == 'deb') {
if (!empty($operation_params['targetPackageTranslation'])) {
Expand Down Expand Up @@ -317,7 +317,7 @@ public function validateForm(array $operations_params)
}

Param\Arch::check($operation_params['targetArch']);
Param\SourcePackageInc::check($operation_params['targetSourcePackage']);
// Param\SourcePackageInc::check($operation_params['targetSourcePackage']);

if ($packageType == 'deb') {
if (!empty($operation_params['targetPackageTranslation'])) {
Expand Down
4 changes: 2 additions & 2 deletions www/controllers/Operation/Param/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public static function check(string $name)
throw new Exception('Repository name must be specified');
}

if (!\Controllers\Common::isAlphanum($name, array('-'))) {
throw new Exception('Repository name cannot contain special characters except hyphen');
if (!\Controllers\Common::isAlphanum($name, array('-', '_'))) {
throw new Exception('Repository name contains invalid characters');
}
}
}
4 changes: 2 additions & 2 deletions www/controllers/Planification.php
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public function exec()
'targetGpgResign' => $this->targetGpgResign,
'targetEnv' => $this->targetEnv,
'targetArch' => $this->repo->getArch(),
'targetSourcePackage' => $this->repo->getSourcePackage(),
// 'targetSourcePackage' => $this->repo->getSourcePackage(),
'onlySyncDifference' => $this->onlySyncDifference
);

Expand Down Expand Up @@ -609,7 +609,7 @@ public function exec()
'targetGpgResign' => $this->targetGpgResign,
'targetEnv' => $this->targetEnv,
'targetArch' => $this->repo->getArch(),
'targetSourcePackage' => $this->repo->getSourcePackage(),
// 'targetSourcePackage' => $this->repo->getSourcePackage(),
'onlySyncDifference' => $this->onlySyncDifference
);

Expand Down
Loading

0 comments on commit 956861f

Please sign in to comment.