added regex checks and error messages to build_uploadAccounts()

This commit is contained in:
Roland Gruber 2004-09-26 17:39:27 +00:00
parent 2c991d9075
commit 5e771bff23
1 changed files with 16 additions and 7 deletions

View File

@ -54,36 +54,44 @@ class posixGroup extends baseModule {
$errors = array(); $errors = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup"; if (!in_array("posixGroup", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "posixGroup";
if (eregi(".*", $rawAccounts[$i][$ids['posixGroup_cn']])) { // TODO use real regex for group name // group name
if (get_preg($rawAccounts[$i][$ids['posixGroup_cn']], 'groupname')) {
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixGroup_cn']]; $partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['posixGroup_cn']];
} }
else {
$errors[] =$this->messages['cn'][2];
}
// GID
if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") { if ($rawAccounts[$i][$ids['posixGroup_gid']] == "") {
// TODO autoGID // TODO autoGID
$partialAccounts[$i]['gidNumber'] = 42; $partialAccounts[$i]['gidNumber'] = 42;
} }
elseif (eregi(".*", $rawAccounts[$i][$ids['posixGroup_gid']])) { // TODO use real regex for group name elseif (get_preg($rawAccounts[$i][$ids['posixGroup_gid']], 'digit')) {
$partialAccounts[$i]['gidNumber'] = $rawAccounts[$i][$ids['posixGroup_gid']]; $partialAccounts[$i]['gidNumber'] = $rawAccounts[$i][$ids['posixGroup_gid']];
} }
// description (UTF-8, no regex check needed)
if ($rawAccounts[$i][$ids['posixGroup_description']] == "") { if ($rawAccounts[$i][$ids['posixGroup_description']] == "") {
$partialAccounts[$i]['description'] = $partialAccounts[$i]['cn']; $partialAccounts[$i]['description'] = $partialAccounts[$i]['cn'];
} }
elseif (eregi(".*", $rawAccounts[$i][$ids['posixGroup_description']])) { // TODO use real regex for group name else {
$partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixGroup_description']]; $partialAccounts[$i]['description'] = $rawAccounts[$i][$ids['posixGroup_description']];
} }
// group members
if ($rawAccounts[$i][$ids['posixGroup_members']] != "") { if ($rawAccounts[$i][$ids['posixGroup_members']] != "") {
if (eregi(".*", $rawAccounts[$i][$ids['posixGroup_members']])) { // TODO use real regex for group name if (get_preg($rawAccounts[$i][$ids['posixGroup_members']], 'usernameList')) {
$partialAccounts[$i]['memberUid'] = explode(",", $rawAccounts[$i][$ids['posixGroup_members']]); $partialAccounts[$i]['memberUid'] = explode(",", $rawAccounts[$i][$ids['posixGroup_members']]);
} }
else { else {
$errors[] = array(); // TODO error message $errors[] = $this->messages['memberUID'][0];
} }
} }
// password
if ($rawAccounts[$i][$ids['posixGroup_password']] != "") { if ($rawAccounts[$i][$ids['posixGroup_password']] != "") {
if (eregi(".*", $rawAccounts[$i][$ids['posixGroup_password']])) { // TODO use real regex for group name if (get_preg($rawAccounts[$i][$ids['posixGroup_password']], 'password')) {
$partialAccounts[$i]['userPassword'] = pwd_hash($rawAccounts[$i][$ids['posixGroup_password']], true, $this->moduleSettings['posixAccount_pwdHash'][0]); $partialAccounts[$i]['userPassword'] = pwd_hash($rawAccounts[$i][$ids['posixGroup_password']], true, $this->moduleSettings['posixAccount_pwdHash'][0]);
} }
else { else {
$errors[] = array(); // TODO error message $errors[] = $this->messages['userPassword'][1];
} }
} }
} }
@ -401,6 +409,7 @@ class posixGroup extends baseModule {
$this->messages['cn'][0] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.')); $this->messages['cn'][0] = array('WARN', _('Groupname'), _('You are using a capital letters. This can cause problems because windows isn\'t case-sensitive.'));
$this->messages['cn'][1] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.')); $this->messages['cn'][1] = array('WARN', _('Groupname'), _('Groupname in use. Selected next free groupname.'));
$this->messages['cn'][2] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !')); $this->messages['cn'][2] = array('ERROR', _('Groupname'), _('Groupname contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
$this->messages['memberUID'][0] = array('ERROR', 'PosixGroup_members', _("This value must be a list of user names separated by semicolons."));
} }