Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15733/ldapserver/ldap/admin/src/scripts
Modified Files: DSCreate.pm.in Inf.pm SetupDialogs.pm.in Util.pm.in Log Message: Resolves: bug 248145 Bug Description: Replace ds_newinst binary with perl script Reviewed by: nhosoi (Thanks!) Fix Description: 1) Inf needs to be able to read the .inf file from stdin. This is what ds_newinst.pl does currently. 2) getlogin seems not to work in all cases, so add a more robust replacement. Platforms tested: RHEL4, FC6 Flag Day: no Doc impact: no
Index: DSCreate.pm.in =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/DSCreate.pm.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DSCreate.pm.in 13 Jul 2007 18:35:32 -0000 1.1 +++ DSCreate.pm.in 13 Jul 2007 19:51:48 -0000 1.2 @@ -596,7 +596,7 @@
if (!$inf->{General}->{SuiteSpotUserID}) { if ($> != 0) { # if not root, use the user's uid - $inf->{General}->{SuiteSpotUserID} = getlogin; + $inf->{General}->{SuiteSpotUserID} = getLogin; } # otherwise, the uid must be specified }
Index: Inf.pm =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Inf.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Inf.pm 20 Jun 2007 14:40:24 -0000 1.3 +++ Inf.pm 13 Jul 2007 19:51:48 -0000 1.4 @@ -77,8 +77,14 @@
my $incontinuation = 0; my $curkey; - open INF, $filename or die "Error: could not open inf file $filename: $!"; - while (<INF>) { + my $inffh; + if ($filename eq "-") { + $inffh = *STDIN; + } else { + open INF, $filename or die "Error: could not open inf file $filename: $!"; + $inffh = *INF; + } + while (<$inffh>) { my $iscontinuation; chop; # trim trailing newline if (/^\s*$/) { # skip blank/empty lines @@ -107,7 +113,9 @@ $incontinuation = 0; } } - close INF; + if ($inffh ne *STDIN) { + close $inffh; + } }
sub section { @@ -149,6 +157,8 @@ $filename = $self->{filename}; }
+ return if ($filename eq "-"); + open INF, ">$filename" or die "Error: could not write inf file $filename: $!"; # write General section first $self->writeSection('General', *INF);
Index: SetupDialogs.pm.in =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/SetupDialogs.pm.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- SetupDialogs.pm.in 19 Jun 2007 18:24:57 -0000 1.1 +++ SetupDialogs.pm.in 13 Jul 2007 19:51:48 -0000 1.2 @@ -44,6 +44,7 @@ use Setup; use Dialog; use Net::Domain qw(hostfqdn); +use Util;
my $welcome = new DialogYesNo ( $EXPRESS, @@ -136,7 +137,7 @@ } } if ($> != 0) { # if not root, the user must be our uid - my $username = getlogin; + my $username = getLogin; if ($strans ne $username) { $self->{manager}->alert("dialog_ssuser_must_be_same", $username); return $DialogManager::SAME; @@ -218,7 +219,7 @@ if ($> == 0) { # if root, use the default user $username = "@defaultuser@"; } else { # if not root, use the user's uid - $username = getlogin; + $username = getLogin; } } return $username;
Index: Util.pm.in =================================================================== RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/Util.pm.in,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- Util.pm.in 13 Jul 2007 18:35:32 -0000 1.8 +++ Util.pm.in 13 Jul 2007 19:51:48 -0000 1.9 @@ -48,11 +48,11 @@ @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 @@ 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 @@ } } 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 @@ 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;
389-commits@lists.fedoraproject.org