Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 10138 - installing a regular cron + anacron messes up rc
Summary: installing a regular cron + anacron messes up rc
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-03 10:32 UTC by salmiakki
Modified: 2003-02-04 19:42 UTC (History)
1 user (show)

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


Attachments
/sbin/rc (rc,8.91 KB, text/plain)
2002-11-04 15:04 UTC, salmiakki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description salmiakki 2002-11-03 10:32:21 UTC
I've installed vcron, then anacron ( both from portage ).
Now whenever the default runlevel is entered, rc is confused because of the 
'*cron' link, and expands /etc/init.d/anacron and /etc/init.d/cron at the 
same time.

+ '[' '!' -e /etc/init.d/anacron /etc/init.d/vcron ']'
/sbin/rc: [: /etc/init.d/anacron: binary operator expected
+ ln -sf /etc/init.d/anacron /etc/init.d/vcron 
'/mnt/.init.d/softscripts.new/*cron'
ln: when making multiple links, last argument must be a directory
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-11-04 11:35:03 UTC
Can you attach your /sbin/rc ?  I am not sure what happens here, as it
is not supposed to reference '*cron'.

-------------------relevant piece of code---------------------
for x in ${myscripts}
do
        if [ ! -e /etc/init.d/${x} ]
        then
                ewarn "WARNING:  /etc/init.d/${x} missing; skipping..."
                continue
        fi
        # the -f eliminates a warning if the symlink already exists, 
        # which can happen if a service is in both the boot level and
        # the current "normal" runlevel
        ln -sf /etc/init.d/${x} ${svcdir}/softscripts.new/${x}
done
-------------------------------------------------------------
Comment 2 salmiakki 2002-11-04 15:04:31 UTC
Created attachment 5369 [details]
/sbin/rc

this is my /sbin/rc
Comment 3 D Wollmann 2002-11-17 08:16:23 UTC
I emerged vcron and am experiencing a similar problem.

The cause would seem to be the pathname:

/etc/runlevels/default/*cron


I'm no bash guru, but it doesn't seem like a good idea to use '*' in critical
system runlevel filenames unless you really want to make your life more
complicated. I'm going to tinker with this problem today and see if I can figure
out a fix.

For what it's worth, I notice that in /sbin/rc there are a few calls to the
dolisting() func from /sbin/functions.sh where the params aren't quoted. The
comment attached to dolisting() warns, in part: "quote the params if they
contain globs".
Comment 4 Martin Schlemmer (RETIRED) gentoo-dev 2002-11-17 12:54:53 UTC
Nowhere does it call 'dolisting /foo/*' ...

Also I cannot see where '*cron' is referenced.
Comment 5 D Wollmann 2002-11-18 05:58:26 UTC
/etc/runlevels/default/*cron is referenced at /sbin/rc line 222. Quoting the
variable in the symlink test at that line eliminates one of the errors but not
all of them.

As for a fix, I removed /etc/runlevels/default/*cron and ran '/sbin/rc-update
add vcron default', then rebooted. No more error messages and after boot cron is
running as expected.

Because the test failure prevents the filename containing the glob character or
any of the elements of the expanded glob being appended to myscripts, the errors
are harmless; the other values for x cause no errors and are appended to
myscripts if they are symlinks, as expected.

rc calls the dolisting() function from /sbin/functions.sh passing it the string
"/etc/runlevels/default". dolisting() changes the default directory to
/etc/runlevels/default and builds a space-separated string of <path>/<symlink>
strings and returns it. /sbin/rc tests each element of the list produced by the
word splitting of this string without quoting it, permitting glob expansion of
the element "/etc/runlevels/default/*cron" so that the test expression becomes:

if [ -L /etc/runlevels/default/*cron /etc/runlevels/default/anacron
/etc/runlevels/default/vcron ]

This is the cause of the first error, -L expects a single argument.

Note what happens in the first example when ${f} is unquoted in the argument to
-L. The glob "*cron" is expanded to the list "*cron vcron". In the filer's case,
this list expands to "*cron anacron vcron".

$ for f in \*cron vcron; do if [ -L ${f} ]; then echo "syml: ${f}"; else echo
not syml: ${f}; fi; done
[: *cron: binary operator expected
not syml: *cron vcron
syml: vcron

$ for f in \*cron vcron; do if [ -L "${f}" ]; then echo "syml: ${f}"; else echo
"not syml: ${f}"; fi; done
not syml: *cron
syml: vcron
Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2002-11-18 12:45:37 UTC
Let me put it this way .. I do not see how you get "/etc/runlevels/default/*cron"
in there ?  I checked it this side, and it works fine.

Maybe im just too involved to see what could be going wrong your side,
but ....
Comment 7 D Wollmann 2002-11-19 19:30:52 UTC
There was a file called:

/etc/runlevels/default/*cron       <-- That's a literal asterisk.

I rm'd that file and the errors went away.

At some point a script probably tried to perform some operation against all the
cron-related symlinks in that directory but did it in such a way that the glob
wasn't expanded. My guess would be that it happened when I emerged vcron.

I'll try to figure out where that file comes from the next time I do an install,
probably within the next couple of days.
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2002-11-19 22:43:24 UTC
It wont be vron, as the ebuild never touch /etc/runlevels.  Only thing it could
be is rc-update,
or something else in baselayout.  Only problem is that I have never seen this :(

How did you call rc-update to add vcron and anacron ?
Comment 9 salmiakki 2002-12-07 03:27:38 UTC
I didn't run rc-update when I first installed the stuff out of ignorance. So it's not rc-update.
Then on next startup this error occured.
My guess is that that *cron link must have been there since one of the install phases of gentoo ?
I've compiled all phases myself.
Comment 10 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-18 01:53:29 UTC
I quoted the tests in rc-update and /sbin/rc ... it should handle '*' in links
much better now.  This will be present in baselayout-1.8.5.6 ...