* Wed May 15 2024 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-10.sme
- fix user@0.service failed to start [SME: 12568] - stop loging in audit crond success - drop cpu and use esmith:util::ldap [SME: 12663]
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# copyright (C) 1999-2005 Mitel Networks Corporation
|
||||
# copyright (C) 2024 Koozali Foundation inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -27,6 +28,7 @@ use strict;
|
||||
use Errno;
|
||||
use esmith::util;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::util::ldap;
|
||||
|
||||
my $conf = esmith::ConfigDB->open_ro
|
||||
or die "Could not open Config DB";
|
||||
@@ -34,6 +36,9 @@ my $conf = esmith::ConfigDB->open_ro
|
||||
my $ldapauth = $conf->get('ldap')->prop('Authentication') || 'disabled';
|
||||
my $x = 0; # exit value
|
||||
|
||||
# prepare LDAP bind
|
||||
my $ldap=esmith::util::ldap->new();
|
||||
|
||||
my $event = $ARGV [0];
|
||||
my $userName = $ARGV [1];
|
||||
|
||||
@@ -53,11 +58,21 @@ if ($ldapauth ne 'enabled')
|
||||
( $x = 255, warn "Failed to delete (unix) account $userName.\n" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
my $discard = `/bin/rm -rf /home/e-smith/files/users/$userName`;
|
||||
if ($? != 0)
|
||||
{
|
||||
( $x = 255, warn "Failed to delete home dir of account $userName.\n" );
|
||||
}
|
||||
|
||||
system("/usr/sbin/cpu", "userdel", "-r", $userName) == 0
|
||||
or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) account $userName.\n" );
|
||||
}
|
||||
# delete user
|
||||
my $result = $ldap->ldapdeluser($userName);
|
||||
$result && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) account $userName.\n" );
|
||||
|
||||
system("/usr/sbin/cpu", "-C/etc/cpu-system.conf", "groupdel", $userName) == 0
|
||||
or ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) group account $userName.\n" );
|
||||
# delete user dedicated group
|
||||
$result = $ldap->ldapdelgroup($userName);
|
||||
$result && ( $x = $ldapauth ne 'enabled' ? $x : 255, warn "Failed to delete (ldap) group account $userName.\n" );
|
||||
|
||||
exit ($x);
|
||||
|
Reference in New Issue
Block a user