Solved `Shared object not found` only when service run at boot

Hello all,

I have a service, reduced to the following:

Code:
#!/bin/sh
#
# PROVIDE: test

. /etc/rc.subr

name="test"
rcvar="test_enable"

load_rc_config ${name}

command="/usr/sbin/daemon"
command_args="-f -o /var/log/test/test.log -u operator bash -c 'echo hi'"
run_rc_command "$1"

however it is behaving strangely. I have /test_enable="YES" in my /etc/rc.conf, and every boot it logs the following to the log file: /ld-elf.so.1: Shared object "libintl.so.8" not found, required by "bash".

I am unable to figure out why this happens, mostly due to the fact that when I run this service after boot it works as intended, logging /hi.

Does anyone have an idea why this may be the case? The specific program I try to execute does not matter much, python, bash, fish, all fail with similar errors. Help would be appreciated.

P.S.

This is in a jail, but I guessed that this should be irrelevant for this issue
 
The million dollar question: did you or someone else make bash the default system shell or alias bash as sh? Based on attached snippet above it shouldn't be calling bash at all, but it is...and since bash is running in a restricted environment it can't find a needed library.

For the record, don't make bash the shell for root. That's sooo linuxish.
 
Bash is not the default shell. Bash is being called explicitly, as the command being executed by `/usr/sbin/daemon` is `bash -c 'echo hi'`. This is not bash specific, other programs such as python show similar issues.

> since bash is running in a restricted environment it can't find a needed library

What do you mean by this? What restricted environment? Are services started under the boot process put under a different environment than when started by a user?
 
The issue was a missing dependency on the `ldconfig` service. This has nothing to do with default shell or restricted environment, or hypothetical "linuxish" configurations...
 
If you really have /usr/local/lib/libintl.so.8 (provided by devel/gettext-runtime), the error suggests that your rc.d script runs before /usr/local is mounted.
This cannot happen if you properly installed your rc.d script into /usr/local/etc/rc.d/ and library search path is configured properly.

So any rc.d script that wants anything installed via ports should:
  • being installed into /usr/local/etc/rc.d/, NOT into /etc/rc.d/
  • have
    sh:
    # REQUIRE: DAEMON
    (or something runs later instead) in it
to be safe.
 
If you really have /usr/local/lib/libintl.so.8 (provided by devel/gettext-runtime), the error suggests that your rc.d script runs before /usr/local is mounted.
This cannot happen if you properly installed your rc.d script into /usr/local/etc/rc.d/ and library search path is configured properly.

So any rc.d script that wants anything installed via ports should:
  • being installed into /usr/local/etc/rc.d/, NOT into /etc/rc.d/
  • have
    sh:
    # REQUIRE: DAEMON
    (or something runs later instead) in it
to be safe.
Thank you! I already "fixed" is by adding
sh:
# REQUIRE ldconfig
, but
sh:
# REQUIRE: DAEMON
is probably better (replies are still awaiting approval atm). The scripts are propperly installed in /usr/local/etc/rc.d, as they should be. I always thought of the linker(config) as a guarantee, not something that I would need to care about. I guess I was wrong!

P.S. How do I mark this as solved? I can't seem to find the button to edit the title
 
Back
Top