Storage node availability check ignores `FOG_SSH_PORT` (hardcoded port 22)
-
Storage node availability check ignores
FOG_SSH_PORT(hardcoded port 22)Environment
FOG version 1.6.0-beta (branch working-1.6)Upgraded from 1.5.10.1826 OS Ubuntu (Apache 2.4.66, PHP-FPM) Storage node single master node, same host as the FOG server SSH sshd listening on a non-standard port (not 22) Summary
StorageNode::loadOnline()probes the node on a hardcoded TCP port 22 instead of reading theFOG_SSH_PORTglobal setting. On a server whose sshd listens on a non-standard port, every storage node is permanently reported as offline, which makes all imaging and registration tasks fail.This is the SSH counterpart of the FTP issue already fixed in PR #801 (“Remove hardcoded ftp port for storage node availability check”, released in 1.5.10.1812).
Steps to reproduce
- Configure sshd on the FOG server to listen on a non-standard port (e.g.
Port 35002), withSubsystem sftp internal-sftpenabled. - Set the matching value in the database:
UPDATE globalSettings SET settingValue='35002' WHERE settingKey='FOG_SSH_PORT'; - Open the dashboard and look at the storage node status.
- PXE boot a client and select any task (registration or deployment).
Expected behaviour
The availability probe uses the port configured in
FOG_SSH_PORT, the node is reported as online, and tasks proceed normally.Actual behaviour
- The dashboard shows the storage node as unavailable, even though the node is enabled, is the master node, has free client slots, and accepts SFTP connections normally on its configured port.
- Saving the storage node in the web UI returns
Warning Unable to connect using ip, user, and/or password provided!(this part is fixed onceFOG_SSH_PORTis set, sincefogssh.class.phpreads it correctly — but the dashboard status remains wrong). - Any task selected from the iPXE menu fails with HTTP 5xx. Apache logs:
PHP Fatal error: Uncaught Exception: No nodes available in /var/www/fog/lib/fog/storagegroup.class.php:338 Stack trace: #0 /var/www/fog/lib/fog/bootmenu.class.php(1021): StorageGroup->getOptimalStorageNode() #1 /var/www/fog/lib/fog/bootmenu.class.php(1468): BootMenu->falseTasking() #2 /var/www/fog/lib/fog/bootmenu.class.php(1400): BootMenu->setTasking() #3 /var/www/fog/lib/fog/bootmenu.class.php(541): BootMenu->verifyCreds() #4 /var/www/fog/service/ipxe/boot.php(52): BootMenu->__construct()Root cause
packages/web/lib/fog/storagenode.class.php, methodloadOnline():public function loadOnline() { $test = self::$FOGURLRequests->isAvailable($this->get('ip'), '0.1', 22, 'tcp'); $this->set('online', array_shift($test)); }The port is a literal
22. TheFOG_SSH_PORTsetting is never consulted here, althoughpackages/web/lib/fog/fogssh.class.phpdoes read it correctly:list($portOverride) = FOGCore::getSetting(['FOG_SSH_PORT']); if (!$port) { if ($portOverride) { $port = $portOverride; } else { $port = $this->port; } }onlinebeingfalsemakesStorageGroup::getOptimalStorageNode()skip the node on its firstcontinue, leaving$winnernull and throwingNo nodes available.Proposed fix
Mirror the logic already present in
fogssh.class.php:public function loadOnline() { list($sshPort) = FOGCore::getSetting(['FOG_SSH_PORT']); $sshPort = $sshPort ?: 22; $test = self::$FOGURLRequests->isAvailable($this->get('ip'), '0.1', $sshPort, 'tcp'); $this->set('online', array_shift($test)); }Verified on my install: the node immediately reports as online and deployment tasks are created normally.
Additional note
FOG_SSH_PORTexists inglobalSettings(category “General Settings”) but is not exposed anywhere in the web UI, so it can only be set through direct SQL. Exposing it under FOG Settings would make this configuration discoverable.Workaround
Either patch
loadOnline()as above, or addPort 22to the sshd configuration alongside the custom port.French version :
Le contrôle de disponibilité du nœud de stockage ignore
FOG_SSH_PORT(port 22 en dur)Environnement
Version FOG 1.6.0-beta (branche working-1.6)Migré depuis 1.5.10.1826 OS Ubuntu (Apache 2.4.66, PHP-FPM) Nœud de stockage nœud maître unique, sur le même hôte que le serveur FOG SSH sshd à l’écoute sur un port non standard (pas 22) Résumé
StorageNode::loadOnline()teste la disponibilité du nœud sur le port TCP 22 écrit en dur, au lieu de lire le réglage globalFOG_SSH_PORT. Sur un serveur dont sshd écoute sur un port non standard, tous les nœuds de stockage sont durablement considérés comme hors ligne, ce qui fait échouer l’ensemble des tâches de déploiement et d’enregistrement.C’est l’équivalent SSH du problème FTP déjà corrigé par la PR #801 (« Remove hardcoded ftp port for storage node availability check », livrée en 1.5.10.1812).
Étapes de reproduction
- Configurer sshd sur le serveur FOG pour écouter sur un port non standard (par exemple
Port 35002), avecSubsystem sftp internal-sftpactivé. - Renseigner la valeur correspondante en base :
UPDATE globalSettings SET settingValue='35002' WHERE settingKey='FOG_SSH_PORT';- Ouvrir le tableau de bord et observer l’état du nœud de stockage.
- Démarrer un client en PXE et sélectionner n’importe quelle tâche (enregistrement ou déploiement).
Comportement attendu
Le test de disponibilité utilise le port configuré dans
FOG_SSH_PORT, le nœud est signalé en ligne, et les tâches se déroulent normalement.Comportement constaté
- Le tableau de bord affiche le nœud de stockage comme indisponible, alors qu’il est activé, qu’il est bien le nœud maître, qu’il dispose de créneaux clients libres et qu’il accepte les connexions SFTP sans problème sur son port configuré.
- L’enregistrement du nœud de stockage dans l’interface web retourne
Warning Unable to connect using ip, user, and/or password provided!(ce point-là est résolu une foisFOG_SSH_PORTrenseigné, puisquefogssh.class.phple lit correctement — mais l’état affiché au tableau de bord reste erroné). - Toute tâche sélectionnée depuis le menu iPXE échoue en HTTP 5xx. Journaux Apache :
PHP Fatal error: Uncaught Exception: No nodes available in /var/www/fog/lib/fog/storagegroup.class.php:338 Stack trace: #0 /var/www/fog/lib/fog/bootmenu.class.php(1021): StorageGroup->getOptimalStorageNode() #1 /var/www/fog/lib/fog/bootmenu.class.php(1468): BootMenu->falseTasking() #2 /var/www/fog/lib/fog/bootmenu.class.php(1400): BootMenu->setTasking() #3 /var/www/fog/lib/fog/bootmenu.class.php(541): BootMenu->verifyCreds() #4 /var/www/fog/service/ipxe/boot.php(52): BootMenu->__construct()Cause racine
packages/web/lib/fog/storagenode.class.php, méthodeloadOnline():public function loadOnline() { $test = self::$FOGURLRequests->isAvailable($this->get('ip'), '0.1', 22, 'tcp'); $this->set('online', array_shift($test)); }Le port est un littéral
22. Le réglageFOG_SSH_PORTn’est jamais consulté ici, alors quepackages/web/lib/fog/fogssh.class.phple lit correctement :list($portOverride) = FOGCore::getSetting(['FOG_SSH_PORT']); if (!$port) { if ($portOverride) { $port = $portOverride; } else { $port = $this->port; } }onlineétant àfalse,StorageGroup::getOptimalStorageNode()écarte le nœud dès son premiercontinue, laisse$winnerà null et lèveNo nodes available.Correctif proposé
Reprendre la logique déjà présente dans
fogssh.class.php:public function loadOnline() { list($sshPort) = FOGCore::getSetting(['FOG_SSH_PORT']); $sshPort = $sshPort ?: 22; $test = self::$FOGURLRequests->isAvailable($this->get('ip'), '0.1', $sshPort, 'tcp'); $this->set('online', array_shift($test)); }Vérifié sur
- Configure sshd on the FOG server to listen on a non-standard port (e.g.
-
@Lucas26 Thanks for letting us know and should be fixed in the latest.
Also found a similar class of bug for FTP ports and we are porting the FTP side to dev-branch as we speak.
Please let us know if this is working now?