<?php
/**
- * account.php - A library of common account management functions.
+ * FusionForge account functions
*
- * Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright 1999-2001, VA Linux Systems, Inc.
*
- * @version $Id$
+ * This file is part of FusionForge.
*
- * This file is part of GForge.
- *
- * GForge is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GForge is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * FusionForge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with GForge; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with FusionForge; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
*/
/**
*
*/
function account_pwvalid($pw) {
- global $Language;
if (strlen($pw) < 6) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','sixchar');
+ $GLOBALS['register_error'] = _('Password must be at least 6 characters.');
return 0;
}
return 1;
*
*/
function account_namevalid($name) {
- global $Language;
+ global $sys_use_shell;
+
// no spaces
if (strrpos($name,' ') > 0) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','nospace');
+ $GLOBALS['register_error'] = _('There cannot be any spaces in the login name.');
return 0;
}
// min and max length
if (strlen($name) < 3) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','tooshort');
+ $GLOBALS['register_error'] = _('Name is too short. It must be at least 3 characters.');
return 0;
}
if (strlen($name) > 15) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','toolong');
+ $GLOBALS['register_error'] = _('Name is too long. It must be less than 15 characters.');
return 0;
}
if (!ereg('^[a-z][-a-z0-9_]+$', $name)) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','illegal');
+ $GLOBALS['register_error'] = _('Illegal character in name.');
return 0;
}
if (eregi("^((root)|(bin)|(daemon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)"
. "|(uucp)|(operator)|(games)|(mysql)|(httpd)|(nobody)|(dummy)"
. "|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download))$",$name)) {
- $GLOBALS['register_error'] = "Name is reserved.";
+ $GLOBALS['register_error'] = _('Name is reserved.');
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'] = $Language->getText('common_include_account','cvsreserved');
+ $GLOBALS['register_error'] = _('Name is reserved for CVS.');
return 0;
}
*
*/
function account_groupnamevalid($name) {
- global $Language;
if (!account_namevalid($name)) return 0;
// illegal names
if (eregi("^((www[0-9]?)|(cvs[0-9]?)|(shell[0-9]?)|(ftp[0-9]?)|(irc[0-9]?)|(news[0-9]?)"
. "|(mail[0-9]?)|(ns[0-9]?)|(download[0-9]?)|(pub)|(users)|(compile)|(lists)"
. "|(slayer)|(orbital)|(tokyojoe)|(webdev)|(projects)|(cvs)|(slayer)|(monitor)|(mirrors?))$",$name)) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','dnsreserved');
+ $GLOBALS['register_error'] = _('Name is reserved for DNS purposes.');
return 0;
}
if (eregi("_",$name)) {
- $GLOBALS['register_error'] = $Language->getText('common_include_account','nounderscore');
+ $GLOBALS['register_error'] = _('Group name cannot contain underscore for DNS reasons.');
return 0;
}
*
*/
function account_gensalt(){
-
+ global $unix_cipher;
+ // ncommander: modified for cipher selection
+ // crypt() selects the cipher based on
+ // the salt, so ...
+
$a = genchr();
$b = genchr();
- $salt = "$1$" . "$a$b";
+ switch($unix_cipher) {
+ case 'DES':
+ $salt = "$a$b";
+ break;
+ default:
+ case 'MD5':
+ $salt = "$1$" . "$a$b";
+ break;
+ case 'Blowfish':
+ $i = 0;
+ while (!$i = 16) {
+ $salt .= rand(64,126);
+ $i++;
+ }
+ return "$2a$".$salt;
+ break;
+ }
return $salt;
}
*
*/
function account_genunixpw($plainpw) {
- return crypt($plainpw,account_gensalt());
+ // ncommander: Support clear password hashing
+ // for usergroup_plain.php
+ global $unix_cipher;
+ if (strcasecmp($unix_cipher, 'Plain') == 0) {
+ return $plainpw;
+ } else {
+ return crypt($plainpw,account_gensalt());
+ }
}
/**
return $GLOBALS['groupdir_prefix'].'/'.$group;
}
-/**
- * account_group_cvsweb_url() - Returns URL for group's CVS interface WWW
- *
- * @param string The group name
- * @return URL to access CVS over HTTP
- */
-function account_group_cvsweb_url($group) {
- /*
- return 'http://'.$GLOBALS['sys_cvs_host'].'/cgi-bin/viewcvs.cgi/'.$group;
- */
- return 'http://'.$GLOBALS['sys_cvs_host'].'/cgi-bin/cvsweb.cgi?cvsroot='.$group;
-}
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
?>