#47299 allow cmdline scripts to work with non-root user
Closed: wontfix None Opened 11 years ago by rmeggins.

When running as a non-root user, setup and start-dirsrv look in ~/.dirsrv for the initconfig files. The command line scripts such as db2ldif, db2ldif.pl, etc. should also use this. Also, there should be a way to override the location where the scripts look for the initconfig files (you can use -d with start-dirsrv).


Looks good. As for the "-D config dir", there is already support for it in the shell scripts, it's just not advertised in the usage.

commit 7f7f83c
Author: Rich Megginson rmeggins@redhat.com
Date: Thu Mar 21 10:20:19 2013 -0600

de4bed7..5aba964 389-ds-base-1.3.1 -> 389-ds-base-1.3.1
commit 5aba964
Author: Rich Megginson rmeggins@redhat.com
Date: Mon Apr 15 21:26:49 2013 -0600
845a221..6fb5b26 master -> master
commit 6fb5b26
Author: Rich Megginson rmeggins@redhat.com
Date: Mon Apr 15 21:26:49 2013 -0600

3 0001-Ticket-47299-allow-cmdline-scripts-to-work-with-non-.patch
0001-Ticket-47299-allow-cmdline-scripts-to-work-with-non-.3.patch

There is still a regression with the function - where you don't have to specify the server id if there is only instance. I'll work on this...

Replying to [comment:12 mreynolds]:

There is still a regression with the function - where you don't have to specify the server id if there is only instance. I'll work on this...

I see a problem if $servid is provided:

{{{
if ($instance_count > 1){
print "You must supply a valid server instance identifier. Use -Z to specify instance name\n";
print "Available instances: $instances\n";
exit (1);
}
}}}

$instance_count may be > 1 when the for loop is broken here:
{{{
if ($servid && ($servid eq $inst)) {
$found = 1;
last;
}
}}}

So the check should be
{{{
if (!$servid && ($instance_count > 1)){
print "You must supply a valid server instance identifier. Use -Z to specify instance name\n";
print "Available instances: $instances\n";
exit (1);
}
}}}

But that's only in the case where $servid was provided. If $servid is not provided, I'm not sure why it won't work with my latest patch.

4 0001-Ticket-47299-allow-cmdline-scripts-to-work-with-non-.patch
0001-Ticket-47299-allow-cmdline-scripts-to-work-with-non-.4.patch

Can you also add this:

diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index e439ea4..4d56206 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -1285,6 +1285,7 @@ sub get_server_id {
my $first = "yes";
my $instances = "<none>";
my $name;
+ my $inst;
my $file;
my @extra = ();
my $extradir = "";
@@ -1325,7 +1326,7 @@ sub get_server_id {
# skip admin server
if($file =~ m,/@package_name@-([^/]+)$, && $file !~ m,/@package_name@-admin$,){
$name = $file;
- my $inst = $1;
+ $inst = $1;
$instance_count++;
if ($servid && ($servid eq $inst)) {
$found = 1;
@@ -1350,14 +1351,16 @@ sub get_server_id {
print "No instances found in $dir\n";
exit (1);
}
+ if ($instance_count == 1){
+ $servid = $inst;
+ }

This will allow you to not specify -Z if there is only one instance.

Thanks.

5 0001-Ticket-47299-allow-cmdline-scripts-to-work-with-non-.patch
0001-Ticket-47299-allow-cmdline-scripts-to-work-with-non-.5.patch

We need one last change:

DSUtil.pm.in

sub get_info {
my %info = ();
my $dir = shift;
chomp($dir); <---- $dir has a newline, that breaks $dse_file.
my $dse_file = "$dir/dse.ldif";

I found another issue in DSSharedLib, working on it now...

Ok I'll let you handle it. I'm clearly not being very effective on this issue . . .

In the new normalize_server_id - what happens if $1 is "/home/rmeggins/.dirsrv/dirsrv-localhost"? The sed version handled this case as well as /etc/sysconfig/dirsrv-localhost.

Replying to [comment:19 rmeggins]:

In the new normalize_server_id - what happens if $1 is "/home/rmeggins/.dirsrv/dirsrv-localhost"? The sed version handled this case as well as /etc/sysconfig/dirsrv-localhost.

Not sure how that value could be possible and not correctly handled - $1 is always based off of %instconfigdir%. In the only other case is where the server id is provided by a user(-Z), specifying the full path is invalid anyway. Maybe I am missing something?

Also, the original sed version never worked, it always returned the original value.

Thank you, Rich and Mark!

The fix looks good and the utility is working nicely!

Replying to [comment:20 mreynolds]:

Replying to [comment:19 rmeggins]:

In the new normalize_server_id - what happens if $1 is "/home/rmeggins/.dirsrv/dirsrv-localhost"? The sed version handled this case as well as /etc/sysconfig/dirsrv-localhost.

Not sure how that value could be possible and not correctly handled - $1 is always based off of %instconfigdir%.

Not if running as a non-root user - see get_initconfig_files - user can also pass in the directory to use overriding %instconfigdir% via INITCONFIGDIR.

In the only other case is where the server id is provided by a user(-Z), specifying the full path is invalid anyway. Maybe I am missing something?

Also, the original sed version never worked, it always returned the original value.

Works for me - not sure why it's not working

Ok, new patch is ready for review...

master

git merge ticket47299
Updating 305dac5..694f914
Fast-forward
ldap/admin/src/scripts/DSSharedLib.in | 58 ++++++++++----------------------
ldap/admin/src/scripts/DSUtil.pm.in | 15 ++++----
ldap/admin/src/scripts/db2ldif.in | 7 ++--
3 files changed, 29 insertions(+), 51 deletions(-)

git push origin master
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 1.37 KiB, done.
Total 9 (delta 7), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
305dac5..694f914 master -> master

commit 694f914

1.3.1

git push origin 389-ds-base-1.3.1
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 1.41 KiB, done.
Total 9 (delta 7), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
473fc77..e5c70f8 389-ds-base-1.3.1 -> 389-ds-base-1.3.1

Metadata Update from @rmeggins:
- Issue assigned to rmeggins
- Issue set to the milestone: 1.3.1

7 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/636

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: Fixed)

3 years ago

Login to comment on this ticket.

Metadata