Bug 1211006

Summary: start/stop/restart-dirsrv utilities should ignore admin-serv directory
Product: Red Hat Enterprise Linux 6 Reporter: Viktor Ashirov <vashirov>
Component: 389-ds-baseAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED ERRATA QA Contact: Viktor Ashirov <vashirov>
Severity: unspecified Docs Contact:
Priority: high    
Version: 6.7CC: jgalipea, nkinder, rmeggins, salmy, tlavigne
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.2.11.15-59.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 06:37:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Viktor Ashirov 2015-04-12 01:37:07 UTC
Description of problem:
When invoked, {start,stop,restart}-dirsrv utilities are trying to start/stop/restart admin instance.
Command line utilities start-dirsv, stop-dirsrv and restart-dirsrv should ignore admin-serv directory.

Version-Release number of selected component (if applicable):
389-ds-base-1.2.11.15-53.el6.x86_64
389-ds-base-libs-1.2.11.15-53.el6.x86_64
389-admin-1.1.38-1.el6dsrv.x86_64
389-adminutil-1.1.21-1.el6dsrv.x86_64

How reproducible:
always

Steps to Reproduce:
1. yum install 389-ds-base 389-ds-admin
2. setup-ds.pl
3. run start-dirsrv, restart-dirsrv, stop-dirsrv

Actual results:
[root@rhel6ds ~]# start-dirsrv
Starting instance "admin"
/usr/sbin/start-dirsrv: line 63: ./ns-slapd: No such file or directory
Starting instance "rhel6ds"

[root@rhel6ds ~]# restart-dirsrv 
Restarting instance "admin"
No ns-slapd PID file found. Server is probably not running
/usr/sbin/start-dirsrv: line 63: ./ns-slapd: No such file or directory
Restarting instance "rhel6ds"

[root@rhel6ds ~]# stop-dirsrv 
Stopping instance "admin"
No ns-slapd PID file found. Server is probably not running
Stopping instance "rhel6ds"

Expected results:
Command line utilities start-dirsv, stop-dirsrv and restart-dirsrv should ignore admin-serv directory

Additional info:
This was fixed in https://fedorahosted.org/389/ticket/47299 for 1.3.x branch.

Comment 1 Noriko Hosoi 2015-04-12 06:44:50 UTC
Indeed, although it stops the DS, but it picks up unnecessary "admin", too...
# sh -x stop-dirsrv
+ getopts d: flag
+ shift 0
+ '[' '' = '' ']'
+ '[' root = root ']'
+ initconfig_dir=/etc/sysconfig
+ '[' 0 -eq 0 ']'
+ ret=0
+ for i in '$initconfig_dir/dirsrv-*'
+ regex=s,/etc/sysconfig/dirsrv-,,g
++ echo /etc/sysconfig/dirsrv-admin
++ sed -e s,/etc/sysconfig/dirsrv-,,g
+ inst=admin
+ echo Stopping instance '"admin"'
Stopping instance "admin"
+ stop_instance admin
+ SERV_ID=admin
+ '[' -f /etc/sysconfig/dirsrv-admin ']'
+ . /etc/sysconfig/dirsrv-admin
+ PIDFILE=/-admin.pid
+ test '!' -f /-admin.pid
+ echo No ns-slapd PID file found. Server is probably not running
No ns-slapd PID file found. Server is probably not running
+ return 2
+ '[' 2 -ne 0 ']'
+ ret=0
+ for i in '$initconfig_dir/dirsrv-*'
+ regex=s,/etc/sysconfig/dirsrv-,,g
...

Comment 2 Noriko Hosoi 2015-04-12 23:44:04 UTC
Upstream ticket:
https://fedorahosted.org/389/ticket/48148

Comment 4 Viktor Ashirov 2015-05-07 14:27:39 UTC
Build tested: 389-ds-base-1.2.11.15-54.el6.x86_64

start-dirsrv and stop-dirsrv are working fine:
[root@rhel6ds ~]# start-dirsrv
Starting instance "rhel6ds"
[root@rhel6ds ~]# stop-dirsrv 
Stopping instance "rhel6ds"

But restart-dirsrv picks up "admin" anyway:
[root@rhel6ds ~]# restart-dirsrv 
Restarting instance "admin"
Restarting instance "rhel6ds"
Stopping instance "rhel6ds"
Starting instance "rhel6ds"


[root@rhel6ds ~]# sh -x restart-dirsrv
+ getopts d: flag
+ shift 0
+ '[' '' = '' ']'
+ '[' root = root ']'
+ initconfig_dir=/etc/sysconfig
+ '[' 0 -eq 0 ']'
+ ret=0
+ for i in '$initconfig_dir/dirsrv-*'
+ regex=s,/etc/sysconfig/dirsrv-,,g
++ sed -e s,/etc/sysconfig/dirsrv-,,g
++ echo /etc/sysconfig/dirsrv-admin
+ inst=admin
+ echo Restarting instance '"admin"'
Restarting instance "admin"
+ restart_instance admin
+ SERV_ID=admin
+ server_already_stopped=0
+ /usr/sbin/stop-dirsrv -d /etc/sysconfig admin
+ status=0
+ '[' 0 -eq 1 ']'
+ '[' 0 -eq 2 ']'
+ /usr/sbin/start-dirsrv -d /etc/sysconfig admin
+ status=0
+ '[' 0 -eq 1 ']'
+ return 0
+ '[' 0 -ne 0 ']'


Also I found another issue when these utilities are run under unprivileged user:
[vashirov@rhel6ds ~]$ mkdir /tmp/test && cd /tmp/test
[vashirov@rhel6ds test]$ touch foobar
[vashirov@rhel6ds test]$ start-dirsrv
Instance foobar not found.

[vashirov@rhel6ds test]$ sh -x start-dirsrv
+ '[' -f /etc/sysconfig/dirsrv ']'
+ . /etc/sysconfig/dirsrv
+++ uname -s
++ OS=Linux
++ '[' Linux = SunOS -a -f /usr/lib/libumem.so ']'
++ '[' Linux = SunOS -a -f /usr/lib/64/libumem.so ']'
+ getopts d: flag
+ shift 0
+ '[' '' = '' ']'
+ '[' vashirov = root ']'
+ initconfig_dir=/home/vashirov/.dirsrv
+ '[' 0 -eq 0 ']'
+ ret=0
+ for i in '$initconfig_dir/dirsrv-*'
+ regex=s,/home/vashirov/.dirsrv/dirsrv-,,g
++ sed -e s,/home/vashirov/.dirsrv/dirsrv-,,g
++ echo '/home/vashirov/.dirsrv/dirsrv-*'
+ inst='*'
+ start_instance foobar
+ SERV_ID=foobar
+ shift
+ '[' foobar == admin ']'
+ '[' -f /home/vashirov/.dirsrv/dirsrv-foobar ']'
+ echo Instance foobar not found.
Instance foobar not found.
+ return 1
+ '[' 1 -ne 0 ']'
+ ret=0
+ exit 0

Comment 5 Viktor Ashirov 2015-05-13 09:24:41 UTC
Build tested: 
389-ds-base-1.2.11.15-55.el6

Under root user:

[root@rhel6ds ~]# start-dirsrv
Starting instance "rhel6ds"
[root@rhel6ds ~]# restart-dirsrv 
Restarting instance "rhel6ds"
Stopping instance "rhel6ds"
Starting instance "rhel6ds"
[root@rhel6ds ~]# stop-dirsrv 
Stopping instance "rhel6ds"

Under non-root user:

[vashirov@rhel6ds ~]$ start-dirsrv
[vashirov@rhel6ds ~]$ echo $?
0
[vashirov@rhel6ds ~]$ stop-dirsrv 
[vashirov@rhel6ds ~]$ echo $?
0
[vashirov@rhel6ds ~]$ restart-dirsrv 
[vashirov@rhel6ds ~]$ echo $?
0

Marking as VERIFIED.

Comment 6 Noriko Hosoi 2015-06-03 21:08:54 UTC
Justification:
Defects were reported by covscan in errata.
If a customer does not install bash, start|stop|restart dirsrv script does not work due to the shell syntax error.  Since these are the basic tools for the directory server, we should fix it.

Comment 7 Viktor Ashirov 2015-06-16 11:35:37 UTC
Marking this bug as VERIFIED, since original issue is fixed and these scripts are working with dash (POSIX-compliant implementation of /bin/sh) instead of bash.

Comment 8 errata-xmlrpc 2015-07-22 06:37:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1326.html