[Fusionforge-commits] r7851 - in trunk/gforge/common/include: . system
Julien HEYMAN
jheyman at libremir.placard.fr.eu.org
Thu Jun 18 12:43:40 CEST 2009
Author: jheyman
Date: 2009-06-18 12:43:40 +0200 (Thu, 18 Jun 2009)
New Revision: 7851
Modified:
trunk/gforge/common/include/Group.class.php
trunk/gforge/common/include/System.class.php
trunk/gforge/common/include/User.class.php
trunk/gforge/common/include/account.php
trunk/gforge/common/include/system/pgsql.class.php
Log:
Check if user/group name is not used by user/group
Modified: trunk/gforge/common/include/Group.class.php
===================================================================
--- trunk/gforge/common/include/Group.class.php 2009-06-18 10:33:43 UTC (rev 7850)
+++ trunk/gforge/common/include/Group.class.php 2009-06-18 10:43:40 UTC (rev 7851)
@@ -283,6 +283,7 @@
function create(&$user, $group_name, $unix_name, $description, $purpose, $unix_box='shell1', $scm_box='cvs1', $is_public=1, $send_mail=true) {
// $user is ignored - anyone can create pending group
+ global $SYS;
if ($this->getID()!=0) {
$this->setError(_('Group::create: Group object already exists'));
return false;
@@ -291,6 +292,9 @@
} else if (!account_groupnamevalid($unix_name)) {
$this->setError(_('Invalid Unix name'));
return false;
+ } else if (!$SYS->sysUseUnixName($unix_name)) {
+ $this->setError(_('Unix name already taken'));
+ return false;
} else if (db_numrows(db_query_params('SELECT group_id FROM groups WHERE unix_group_name=$1',
array ($unix_name))) > 0) {
$this->setError(_('Unix name already taken'));
Modified: trunk/gforge/common/include/System.class.php
===================================================================
--- trunk/gforge/common/include/System.class.php 2009-06-18 10:33:43 UTC (rev 7850)
+++ trunk/gforge/common/include/System.class.php 2009-06-18 10:43:40 UTC (rev 7851)
@@ -34,6 +34,17 @@
return true;
}
+ /**
+ * sysUseUnixName() - Check if user/group used the unix_name
+ *
+ * @param string The unix_name to check
+ * @returns true if used/false is free
+ *
+ */
+ function sysUseUnixName($unix_name) {
+ return true;
+ }
+
/*
* User management functions
*/
Modified: trunk/gforge/common/include/User.class.php
===================================================================
--- trunk/gforge/common/include/User.class.php 2009-06-18 10:33:43 UTC (rev 7850)
+++ trunk/gforge/common/include/User.class.php 2009-06-18 10:43:40 UTC (rev 7851)
@@ -236,6 +236,7 @@
function create($unix_name,$firstname,$lastname,$password1,$password2,$email,
$mail_site,$mail_va,$language_id,$timezone,$jabber_address,$jabber_only,$theme_id,
$unix_box='shell',$address='',$address2='',$phone='',$fax='',$title='',$ccode='US',$send_mail=true) {
+ global $SYS;
if (!$theme_id) {
$this->setError(_('You must supply a theme'));
return false;
@@ -266,6 +267,15 @@
$this->setError(_('Invalid Password:'));
return false;
}
+ $unix_name=strtolower($unix_name);
+ if (!account_namevalid($unix_name)) {
+ $this->setError(_('Invalid Unix Name.'));
+ return false;
+ }
+ if (!$SYS->sysUseUnixName($unix_name)) {
+ $this->setError(_('Unix name already taken'));
+ return false;
+ }
if (!validate_email($email)) {
$this->setError(_('Invalid Email Address'));
return false;
Modified: trunk/gforge/common/include/account.php
===================================================================
--- trunk/gforge/common/include/account.php 2009-06-18 10:33:43 UTC (rev 7850)
+++ trunk/gforge/common/include/account.php 2009-06-18 10:43:40 UTC (rev 7851)
@@ -73,9 +73,15 @@
$GLOBALS['register_error'] = _('Name is reserved.');
return 0;
}
- if ( exec("getent passwd $name") != "" ){
- $GLOBALS['register_error'] = _('That username already exists.');
- return 0;
+ if ($sys_use_shell) {
+ if ( exec("getent passwd $name") != "" ){
+ $GLOBALS['register_error'] = _('That username already exists.');
+ return 0;
+ }
+ if ( exec("getent group $name") != "" ){
+ $GLOBALS['register_error'] = _('That username already exists.');
+ return 0;
+ }
}
if (eregi("^(anoncvs_)",$name)) {
$GLOBALS['register_error'] = _('Name is reserved for CVS.');
Modified: trunk/gforge/common/include/system/pgsql.class.php
===================================================================
--- trunk/gforge/common/include/system/pgsql.class.php 2009-06-18 10:33:43 UTC (rev 7850)
+++ trunk/gforge/common/include/system/pgsql.class.php 2009-06-18 10:43:40 UTC (rev 7851)
@@ -59,6 +59,24 @@
return true;
}
+ /**
+ * sysUseUnixName() - Check if user/group used the unix_name
+ *
+ * @param string The unix_name to check
+ * @returns true if used/false is free
+ *
+ */
+ function sysUseUnixName($unix_name) {
+ $res1 = db_query_params ('SELECT user_id FROM users
+ WHERE user_name=$1',array($unix_name));
+ $res2 = db_query_params ('SELECT group_id FROM groups
+ WHERE unix_group_name=$1',array($unix_name));
+ if ( db_numrows($res1) == 0 && db_numrows($res2) == 0 ){
+ return true;
+ }
+ return false;
+ }
+
/*
* User management functions
*/
More information about the Fusionforge-commits
mailing list