1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

s4:provision - Use netbios name for FDS instance name.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Endi S. Dewata
2010-01-28 19:35:29 -06:00
committed by Andrew Bartlett
parent 07669b0704
commit 02533c9f1b
3 changed files with 29 additions and 24 deletions

View File

@ -67,7 +67,7 @@ sub slapd_stop($$)
{ {
my ($self, $envvars) = @_; my ($self, $envvars) = @_;
if ($self->{ldap} eq "fedora-ds") { if ($self->{ldap} eq "fedora-ds") {
system("$envvars->{LDAPDIR}/slapd-samba4/stop-slapd"); system("$envvars->{LDAPDIR}/slapd-$envvars->{LDAP_INSTANCE}/stop-slapd");
} elsif ($self->{ldap} eq "openldap") { } elsif ($self->{ldap} eq "openldap") {
open(IN, "<$envvars->{OPENLDAP_PIDFILE}") or open(IN, "<$envvars->{OPENLDAP_PIDFILE}") or
die("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}"); die("unable to open slapd pid file: $envvars->{OPENLDAP_PIDFILE}");
@ -211,22 +211,22 @@ type: 0x3
sub mk_fedora_ds($$) sub mk_fedora_ds($$)
{ {
my ($self, $ldapdir) = @_; my ($self, $ctx) = @_;
#Make the subdirectory be as fedora DS would expect #Make the subdirectory be as fedora DS would expect
my $fedora_ds_dir = "$ldapdir/slapd-samba4"; my $fedora_ds_dir = "$ctx->{ldapdir}/slapd-$ctx->{ldap_instance}";
my $pidfile = "$fedora_ds_dir/logs/slapd-samba4.pid"; my $pidfile = "$fedora_ds_dir/logs/slapd-$ctx->{ldap_instance}.pid";
return ($fedora_ds_dir, $pidfile); return ($fedora_ds_dir, $pidfile);
} }
sub mk_openldap($$) sub mk_openldap($$)
{ {
my ($self, $ldapdir) = @_; my ($self, $ctx) = @_;
my $slapd_conf_d = "$ldapdir/slapd.d"; my $slapd_conf_d = "$ctx->{ldapdir}/slapd.d";
my $pidfile = "$ldapdir/slapd.pid"; my $pidfile = "$ctx->{ldapdir}/slapd.pid";
return ($slapd_conf_d, $pidfile); return ($slapd_conf_d, $pidfile);
} }
@ -683,6 +683,7 @@ nogroup:x:65534:nobody
REALM => $ctx->{realm}, REALM => $ctx->{realm},
PASSWORD => $ctx->{password}, PASSWORD => $ctx->{password},
LDAPDIR => $ctx->{ldapdir}, LDAPDIR => $ctx->{ldapdir},
LDAP_INSTANCE => $ctx->{ldap_instance},
WINBINDD_SOCKET_DIR => $ctx->{winbindd_socket_dir}, WINBINDD_SOCKET_DIR => $ctx->{winbindd_socket_dir},
NCALRPCDIR => $ctx->{ncalrpcdir}, NCALRPCDIR => $ctx->{ncalrpcdir},
LOCKDIR => $ctx->{lockdir}, LOCKDIR => $ctx->{lockdir},
@ -792,6 +793,8 @@ sub provision($$$$$$$)
if ($self->{ldap} eq "fedora-ds") { if ($self->{ldap} eq "fedora-ds") {
$ctx->{sid_generator} = "backend"; $ctx->{sid_generator} = "backend";
} }
$ctx->{ldap_instance} = lc($ctx->{netbiosname});
} }
my $ret = $self->provision_raw_step1($ctx); my $ret = $self->provision_raw_step1($ctx);
@ -801,12 +804,12 @@ sub provision($$$$$$$)
push (@{$ctx->{provision_options}}, "--ldap-backend-type=" . $self->{ldap}); push (@{$ctx->{provision_options}}, "--ldap-backend-type=" . $self->{ldap});
if ($self->{ldap} eq "openldap") { if ($self->{ldap} eq "openldap") {
push (@{$ctx->{provision_options}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD}); push (@{$ctx->{provision_options}}, "--slapd-path=" . $ENV{OPENLDAP_SLAPD});
($ret->{SLAPD_CONF_D}, $ret->{OPENLDAP_PIDFILE}) = $self->mk_openldap($ctx->{ldapdir}) or die("Unable to create openldap directories"); ($ret->{SLAPD_CONF_D}, $ret->{OPENLDAP_PIDFILE}) = $self->mk_openldap($ctx) or die("Unable to create openldap directories");
} elsif ($self->{ldap} eq "fedora-ds") { } elsif ($self->{ldap} eq "fedora-ds") {
push (@{$ctx->{provision_options}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd"); push (@{$ctx->{provision_options}}, "--slapd-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/ns-slapd");
push (@{$ctx->{provision_options}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl"); push (@{$ctx->{provision_options}}, "--setup-ds-path=" . "$ENV{FEDORA_DS_ROOT}/sbin/setup-ds.pl");
($ret->{FEDORA_DS_DIR}, $ret->{FEDORA_DS_PIDFILE}) = $self->mk_fedora_ds($ctx->{ldapdir}) or die("Unable to create fedora ds directories"); ($ret->{FEDORA_DS_DIR}, $ret->{FEDORA_DS_PIDFILE}) = $self->mk_fedora_ds($ctx) or die("Unable to create fedora ds directories");
} }
} }

View File

@ -551,6 +551,7 @@ class FDSBackend(LDAPBackend):
self.root = root self.root = root
self.setup_ds_path = setup_ds_path self.setup_ds_path = setup_ds_path
self.ldap_instance = self.names.netbiosname.lower()
self.sambadn = "CN=Samba" self.sambadn = "CN=Samba"
@ -596,6 +597,7 @@ class FDSBackend(LDAPBackend):
"DNSDOMAIN": self.names.dnsdomain, "DNSDOMAIN": self.names.dnsdomain,
"LDAPDIR": self.paths.ldapdir, "LDAPDIR": self.paths.ldapdir,
"DOMAINDN": self.names.domaindn, "DOMAINDN": self.names.domaindn,
"LDAP_INSTANCE": self.ldap_instance,
"LDAPMANAGERDN": self.names.ldapmanagerdn, "LDAPMANAGERDN": self.names.ldapmanagerdn,
"LDAPMANAGERPASS": self.ldapadminpass, "LDAPMANAGERPASS": self.ldapadminpass,
"SERVERPORT": serverport}) "SERVERPORT": serverport})
@ -670,7 +672,7 @@ class FDSBackend(LDAPBackend):
self.credentials.set_bind_dn(self.names.ldapmanagerdn) self.credentials.set_bind_dn(self.names.ldapmanagerdn)
# Destory the target directory, or else setup-ds.pl will complain # Destory the target directory, or else setup-ds.pl will complain
fedora_ds_dir = os.path.join(self.paths.ldapdir, "slapd-samba4") fedora_ds_dir = os.path.join(self.paths.ldapdir, "slapd-" + self.ldap_instance)
shutil.rmtree(fedora_ds_dir, True) shutil.rmtree(fedora_ds_dir, True)
self.slapd_provision_command = [self.slapd_path, "-D", fedora_ds_dir, "-i", self.paths.slapdpid] self.slapd_provision_command = [self.slapd_path, "-D", fedora_ds_dir, "-i", self.paths.slapdpid]
@ -678,7 +680,7 @@ class FDSBackend(LDAPBackend):
self.slapd_provision_command.append("-d0") self.slapd_provision_command.append("-d0")
#the command for the final run is the normal script #the command for the final run is the normal script
self.slapd_command = [os.path.join(self.paths.ldapdir, "slapd-samba4", "start-slapd")] self.slapd_command = [os.path.join(self.paths.ldapdir, "slapd-" + self.ldap_instance, "start-slapd")]
# If we were just looking for crashes up to this point, it's a # If we were just looking for crashes up to this point, it's a
# good time to exit before we realise we don't have Fedora DS on # good time to exit before we realise we don't have Fedora DS on
@ -699,7 +701,7 @@ class FDSBackend(LDAPBackend):
# Load samba-admin # Load samba-admin
retcode = subprocess.call([ retcode = subprocess.call([
os.path.join(self.paths.ldapdir, "slapd-samba4", "ldif2db"), "-s", self.sambadn, "-i", self.samba_ldif], os.path.join(self.paths.ldapdir, "slapd-" + self.ldap_instance, "ldif2db"), "-s", self.sambadn, "-i", self.samba_ldif],
close_fds=True, shell=False) close_fds=True, shell=False)
if retcode != 0: if retcode != 0:
raise ProvisioningError("ldif2db failed") raise ProvisioningError("ldif2db failed")

View File

@ -8,20 +8,20 @@ ldapifilepath=${LDAPDIR}/ldapi
Suffix= ${DOMAINDN} Suffix= ${DOMAINDN}
RootDN= ${LDAPMANAGERDN} RootDN= ${LDAPMANAGERDN}
RootDNPwd= ${LDAPMANAGERPASS} RootDNPwd= ${LDAPMANAGERPASS}
ServerIdentifier= samba4 ServerIdentifier= ${LDAP_INSTANCE}
${SERVERPORT} ${SERVERPORT}
inst_dir= ${LDAPDIR}/slapd-samba4 inst_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}
config_dir= ${LDAPDIR}/slapd-samba4 config_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}
schema_dir= ${LDAPDIR}/slapd-samba4/schema schema_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/schema
lock_dir= ${LDAPDIR}/slapd-samba4/lock lock_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/lock
log_dir= ${LDAPDIR}/slapd-samba4/logs log_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/logs
run_dir= ${LDAPDIR}/slapd-samba4/logs run_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/logs
db_dir= ${LDAPDIR}/slapd-samba4/db db_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/db
bak_dir= ${LDAPDIR}/slapd-samba4/bak bak_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/bak
tmp_dir= ${LDAPDIR}/slapd-samba4/tmp tmp_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/tmp
ldif_dir= ${LDAPDIR}/slapd-samba4/ldif ldif_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}/ldif
cert_dir= ${LDAPDIR}/slapd-samba4 cert_dir= ${LDAPDIR}/slapd-${LDAP_INSTANCE}
start_server= 0 start_server= 0
install_full_schema= 0 install_full_schema= 0