e-smith-samba/root/etc/e-smith/events/actions/store-ldap-smbpasswd

41 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 2010 Firewall Services
# daniel@firewall-services.com
#
# 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
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#----------------------------------------------------------------------
use esmith::ConfigDB;
use esmith::util;
my $c = esmith::ConfigDB->open_ro;
my $l = $c->get('ldap') || die "ldap service not found\n";
my $s = $l->prop('status') || 'disabled';
unless ( $s eq 'enabled' ){
warn "Not running action script $0, LDAP service not enabled!\n";
exit(0);
}
exit(0) unless ($l->prop('Authentication') || 'disabled') eq 'enabled';
my $domain = $c->get("DomainName")
|| die("Could not determine domain name");
my $base = esmith::util::ldapBase ($domain->value);
my $pw = esmith::util::LdapPassword();
die "Error storing LDAP password in secret.tdb\n" unless
system('/usr/bin/smbpasswd', '-w', "$pw") == 0;