|
|
@@ -48,11 +48,11 @@ require Exporter;
|
|
|
@EXPORT = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
|
|
|
process_maptbl check_and_add_entry getMappedEntries
|
|
|
getHashedPassword debug createInfFromConfig
|
|
|
- isValidServerID isValidUser makePaths);
|
|
|
+ isValidServerID isValidUser makePaths getLogin);
|
|
|
@EXPORT_OK = qw(portAvailable getAvailablePort isValidDN addSuffix getMappedEntries
|
|
|
process_maptbl check_and_add_entry getMappedEntries
|
|
|
getHashedPassword debug createInfFromConfig
|
|
|
- isValidServerID isValidUser makePaths);
|
|
|
+ isValidServerID isValidUser makePaths getLogin);
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
@@ -111,6 +111,10 @@ sub isValidServerID {
|
|
|
return $servid =~ /^[$validchars]+$/o;
|
|
|
}
|
|
|
|
|
|
+sub getLogin {
|
|
|
+ return getlogin || (getpwuid($>))[0] || $ENV{USER} || die "Error: could not determine the current user ID: $!";
|
|
|
+}
|
|
|
+
|
|
|
sub isValidUser {
|
|
|
my $user = shift;
|
|
|
# convert numeric uid to string
|
|
|
@@ -122,7 +126,7 @@ sub isValidUser {
|
|
|
}
|
|
|
}
|
|
|
if ($> != 0) { # if not root, the user must be our uid
|
|
|
- my $username = getlogin;
|
|
|
+ my $username = getLogin;
|
|
|
if ($strans ne $username) {
|
|
|
return ("dialog_ssuser_must_be_same", $username);
|
|
|
}
|
|
|
@@ -799,8 +803,8 @@ sub createInfFromConfig {
|
|
|
print $outfh "start_server= 0\n";
|
|
|
|
|
|
my $suffix;
|
|
|
- my $ent = $conn->search("cn=ldbm database,cn=plugins,cn=config",
|
|
|
- "one", "(objectclass=*)");
|
|
|
+ $ent = $conn->search("cn=ldbm database,cn=plugins,cn=config",
|
|
|
+ "one", "(objectclass=*)");
|
|
|
if (!$ent) {
|
|
|
push @{$errs}, "error_opening_dseldif", $fname, $!;
|
|
|
close $outfh;
|