summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-09-30 15:07:41 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2015-09-30 15:07:41 (GMT)
commit5897b1bc3b059a29f57bde6c08344deceb41bd23 (patch)
treef2ca2ba16403ac0d65286fc1b5e3d9783440b32b /lib
parentefb5d6557591ef21c27aa46aae220d862c36feeb (diff)
major cleanup for all utils
Diffstat (limited to 'lib')
-rwxr-xr-xlib/RHRD/rddb.pm19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 3957459..894c03e 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -575,13 +575,26 @@ sub add_group_member
{
my ($dbh, $groupname, $username) = @_;
- my ($cnt, $result, $errostring) = is_group_member($dbh, $groupname, $username);
+ my $sql = qq{select count(*) from USERS where LOGIN_NAME = ?;};
+ my $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute($username)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my ($cnt) = $sth->fetchrow_array();
+ $sth->finish();
+ if($cnt < 1) {
+ return (undef, 'ERROR', "user '" . $username . "' does not exist");
+ }
+
+ ($cnt, my $result, my $errostring) = is_group_member($dbh, $groupname, $username);
if($cnt > 0) {
return (undef, 'ERROR', "already a member");
}
- my $sql = qq{insert into USER_PERMS (GROUP_NAME, USER_NAME) values (?, ?);};
- my $sth = $dbh->prepare($sql)
+ $sql = qq{insert into USER_PERMS (GROUP_NAME, USER_NAME) values (?, ?);};
+ $sth = $dbh->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
$cnt = $sth->execute($groupname, $username)