Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 562320 - sys-apps/openrc - required_{files,dirs} doesn't support files/paths with spaces
Summary: sys-apps/openrc - required_{files,dirs} doesn't support files/paths with spaces
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
: 581436 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-10-05 13:24 UTC by Thomas Deutschmann (RETIRED)
Modified: 2016-04-29 07:25 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Deutschmann (RETIRED) gentoo-dev 2015-10-05 13:24:30 UTC
Hi,

1) touch "/etc/my test.cfg"

2) Create "/etc/init.d/test-space" with the following content

#!/sbin/runscript
description="Test runscript for testing required_files with spaces"

command="/bin/true"

required_files="${TESTCFG}"

stop() {
        return 0
}


3) Create "/etc/conf.d/test-space" with the following content

TESTCFG="/etc/my test.cfg"


4) Now try to start your "test-space" service:

# /etc/init.d/test-space start
 * test-space: `/etc/my' is not readable
 * ERROR: test-space failed to start



You can try to double quote, e.g.

  required_files="\"${TESTCFG}\""

but this doesn't solve the problem.


Tested with openrc-0.17.
Comment 1 William Hubbs gentoo-dev 2015-10-13 13:39:36 UTC
This is fixed in commit 29f7e33 which will also be backported to
openrc-0.18.1.
Comment 2 Thomas Deutschmann (RETIRED) gentoo-dev 2015-10-13 13:56:53 UTC
Are you sure this is working?


$ cat config.sh
TESTCFG="/etc/my test.cfg"

$ cat test.sh
#!/bin/sh
source ./config.sh

required_files="${TESTCFG}"

eval "printf '%s\n' $required_files" | while read _f; do
        if [ ! -r "$_f" ]; then
                echo "\`$_f' is not readable"
                exit 1
        fi
done
unset _f


$ ./test.sh
`/etc/my' is not readable

Expecting
`/etc/my test.cfg' is not readable

or no error when "/etc/my test.cfg" exists.
Comment 3 Thomas Deutschmann (RETIRED) gentoo-dev 2015-10-13 14:11:53 UTC
OK, works for me. required_files now needs double quoting:

required_files="\"${TESTCFG}\""

Thanks!


FYI: Expansion doesn't work (i.e. you cannot use something link 'required_files="~/foo.cfg"' but I am not sure if this was ever supported or should be supported).
Comment 4 Thomas Deutschmann (RETIRED) gentoo-dev 2015-10-13 22:01:47 UTC
Uh, now I think I found a big problem with the commit: When required_files isn't set (=empty) than every runscript is failing now.
Comment 5 Vladimir Datsevich 2015-10-14 00:19:45 UTC
I get this when starting/stopping nginx f.e.:

nginx # /etc/init.d/nginx start
 * nginx: `' is not a directory
 * nginx: `' is not readable
Comment 6 William Hubbs gentoo-dev 2015-10-14 00:49:20 UTC
This was fixed a while ago in 0.18.2, and is these commits on the master
branch: 7da72ce fc777ae.

Thanks.

William
Comment 7 Marcin Mirosław 2016-04-29 07:25:23 UTC
*** Bug 581436 has been marked as a duplicate of this bug. ***