Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 279058 - net-misc/hamachi init.d script is not POSIX shell compliant
Summary: net-misc/hamachi init.d script is not POSIX shell compliant
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High minor (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-25 15:23 UTC by Michał Górny
Modified: 2009-07-30 10:10 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Proposed fixes to the init.d script (hamachi.initd.diff,2.34 KB, patch)
2009-07-25 22:48 UTC, Michał Górny
Details | Diff
Patch with Roy's suggestion applied (hamachi.initd.diff,2.35 KB, patch)
2009-07-30 09:59 UTC, Michał Górny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2009-07-25 15:23:25 UTC
OpenRC executes init.d scripts through /bin/sh thus they should be POSIX compliant. Initscript provided with hamachi uses bashisms which cause it even to be unusable with dash shell.

This causes users having dash linked to /bin/sh to have problems starting Hamachi using initscripts. Although the daemon starts correctly, it does not log in automatically.

/etc/init.d/hamachi start outputs following error:
hamachi           |* Starting hamachi...
hamachi           |[: 223: 0: unexpected operator
[ ok ]i           |

Moreover, sometimes script does use '&>' and sometimes '2>&1 >'.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2009-07-25 22:48:53 UTC
Created attachment 199173 [details, diff]
Proposed fixes to the init.d script

I've made following changes:
1) retab!
2) quoted all user-provided variables, especially paths,
3) changed '&>' to '2>&1 >',
4) removed '&' after hamachi start, hamachi goes to background itself,
5) because of that, removed 'sleep 1' too,
6) changed result test to numeric operator ('-eq') instead of bashish string '==',
7) removed '-R' from chown … ipc_sock — it is not a directory, and below chmod doesn't use '-R' anyway,
8) changed init() to return hamachi-init's result instead of chmod one,
9) provided correct service name to 'service_started' call,
10) made status() return non-zero if service isn't running.
Comment 2 Víctor Ostorga (RETIRED) gentoo-dev 2009-07-26 13:38:53 UTC
CCing base-system to know their feedback in the openrc init-scripts
Comment 3 Roy Marples 2009-07-26 13:52:41 UTC
Looks good, but you could change $myservice to $SVCNAME
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2009-07-30 09:59:11 UTC
Created attachment 199631 [details, diff]
Patch with Roy's suggestion applied
Comment 5 Samuli Suominen (RETIRED) gentoo-dev 2009-07-30 10:10:07 UTC
committed in tree as -r3