Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper call of "daemon" shell function in rc startup script leads to "dirname" error [CORE5069] #5356

Open
firebird-automations opened this issue Jan 6, 2016 · 4 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Steve Friedl (sjfriedl)

Votes: 1

After installing FirebirdCS-2.5.5.26952-0.amd64.rpm on a CentOS 6.7 system and switching into SuperClassic mode, starting the service produces a script type error:

#⁠ service firebird start
Starting Firebird server [default] /usr/bin/dirname: extra operand `-daemon'
Try `/usr/bin/dirname --help' for more information.
[ OK ]

This comes from /etc/rc.d/init.d/firebird here:

case "$1" in
start)
echo -n "Starting $FULLNAME "
daemon --user=$FBRunUser "export FIREBIRD LD_LIBRARY_PATH; $GUARDIAN -pidfile $pidfile -daemon -forever"

The issue is that the daemon() shell function is trying to extract the actual executable name (which is $GUARDIAN) from the second parameter, but it's getting confused by the string, attempting to run dirname on te wrong thing. It's very confused.

This causes - among other things - the pid file not to be created properly, and the "service" infrastructure doesn't know if it's running or not.

The fix is to add a

--check="$GUARDIAN"

parameter to the daemon line (I put it first), which provides the executable name so the shell function doesn't have to guess.

daemon --check="$GUARDIAN" --user=$FBRunUser "export FIREBIRD LD_LIBRARY_PATH; $GUARDIAN -pidfile $pidfile -daemon -forever"

This /etc/rc.d/init.d/firebird script is pulled from the install bundle in /opt/firebird/misc/firebird.init.d.mandrake, and this is why I'm not submitting this as a patch.

The fix I mention works great on CentOS 6.7, but I have no idea if it works or breaks on Mandrake, or on other versions of Linux; this requires a bit more installation study that I can't do - I've never used and don't have Mandrake.

Looking in the svn logs, it appears that this behavior was changed to use the "daemon" shell function here:

 r43324 \| alexpeshkoff \| 2009\-07\-21 04:02:30 \-0700 \(Tue, 21 Jul 2009\) \| 2 lines
 Updated startup script from Philippe Makowski

This is a suspiciously long time ago for this issue to appear to be unreported (I couldn't find it in the tracker), so I'm not sure what introduced the issue.

@firebird-automations
Copy link
Collaborator Author

Commented by: Steve Friedl (sjfriedl)

Subsequent STFW suggests that the issue was a RedHat change in 6.6 (initscripts-9.03.40-2.el6_5.2.x86_64).

It's not clear to me if there's any portable way to fix this.

@firebird-automations
Copy link
Collaborator Author

Commented by: Steve Friedl (sjfriedl)

Digging yet more makes it pretty clear that the right answer is to add the --check="X" parameter into the file

  firebird/trunk/builds/install/arch\-specific/linux/firebird\.init\.d\.mandrake\.in

An obvious question is whether --check is supported widely enough, and the answer is yes. Looking at CentOS 5.11, which has a kernel much older than one supported by FIrebird 2.5.5, /etc/rc.d/init.d/functions has a daemon() that accepts the --check parameter..

The question of Mandrake is also moot, as that seems to be a dead distribution and I doubt even the most recent release would support 2.5.5, so I guess a better fix would be to also rename the file to http://firebird.init.d.redhat.in but that's a different issue.

Still unaddressed is CentOS 7, on which this still doesn't install, but that's also a different issue.

@firebird-automations
Copy link
Collaborator Author

Commented by: Steve Friedl (sjfriedl)

This issue persists in 2.5.6; the fix is the same

@firebird-automations
Copy link
Collaborator Author

Commented by: Steve Friedl (sjfriedl)

This issue persists in 2.5.8, the fix is the same. We've been using this updated fix very widely on hundreds of CentOS 6 and 7 servers with no issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant