diff --git a/TODO b/TODO index 6ec3360c..27848579 100644 --- a/TODO +++ b/TODO @@ -68,7 +68,7 @@ FIXED 0001210 Add start- and endtime to autoresponder 0001211 Generated MySQL username too long 0001208 HTML Tags in Support Tickets 0001207 FTP Passw�rter mit Umlauten - 0001201 Virtualusers conflict with local users when using libnss-mysql +FIXED 0001201 Virtualusers conflict with local users when using libnss-mysql 0001204 php5-suhosin FIXED 0001203 Add check for PHP version and required PHP modules in install script 0001198 More online help wanted diff --git a/lib/functions/system/function.checklastguid.php b/lib/functions/system/function.checklastguid.php new file mode 100644 index 00000000..02dc703b --- /dev/null +++ b/lib/functions/system/function.checklastguid.php @@ -0,0 +1,85 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Language + * @version $Id: 185.spf.php 106 2010-01-25 10:06:34Z d00p $ + */ + +/* + * Function checkLastGuid + * + * Checks if the system's last guid + * is not higher than the one saved + * in froxlor's database. + * If it's higher, froxlor needs to + * set its last guid to this one + * to avoid conflicts with libnss-users + * + * @param int guid (from froxlor database) + * + * @return null + */ +function checkLastGuid($froxlor_guid = 0) +{ + global $cronlog; + + $group_lines = array(); + $group_guids = array(); + $update_to_guid = 0; + + $g_file = '/etc/group'; + + if(file_exists($g_file)) + { + if(is_readable($g_file)) + { + if(true == ($groups = file_get_contents($g_file))) + { + $group_lines = explode("\n", $groups); + + foreach($group_lines as $group) + { + $group_guids[] = explode(":", $group); + } + + foreach($group_guids as $idx => $group) + { + $guid = $group[2]; + + if($guid > $froxlor_guid) + { + $update_to_guid = $guid; + } + } + + if($update_to_guid > $froxlor_guid) + { + $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Updating froxlor last guid to '.$update_to_guid); + saveSetting('system', 'lastguid', $update_to_guid); + } + } + else + { + $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group not readable; cannot check for latest guid'); + } + } + else + { + $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group not readable; cannot check for latest guid'); + } + } + else + { + $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'File /etc/group does not exist; cannot check for latest guid'); + } +} diff --git a/scripts/cron_tasks.php b/scripts/cron_tasks.php index 94ff36b8..eaba25f9 100644 --- a/scripts/cron_tasks.php +++ b/scripts/cron_tasks.php @@ -259,6 +259,14 @@ if($db->num_rows($result_tasks) != 0) $db->query('UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = UNIX_TIMESTAMP() WHERE `settinggroup` = \'system\' AND `varname` = \'last_tasks_run\' '); +/* + * we have to check the system's last guid with every cron run + * in case the admin installed new software which added a new user + * so users in the database don't conflict with system users + */ +$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Checking system\'s last guid'); +checkLastGuid($settings['system']['lastguid']); + /** * STARTING CRONSCRIPT FOOTER */