Postinst script: permission denied for /etc/init.d/

I’ve got a new MOX with a fresh Turris OS 5.4.0 and want to install xinetd on it (required for muninlite).

% opkg install xinetd
Installing xinetd (2.3.15-5) to root...
Downloading https://repo.turris.cz/hbs/mox/packages/packages/xinetd_2.3.15-5_aarch64_cortex-a53.ipk
Configuring xinetd.
//usr/lib/opkg/info/xinetd.postinst: line 261: /etc/init.d/: Permission denied

The postinst script is only a few lines long, so the line number is misleading.

I installed strace and reinstalled xinetd. Same error again, and in the trace I found

8930  rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
8930  close(10)                         = 0
8930  rt_sigaction(SIGQUIT, NULL, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=0}, 8) = 0
8930  execve("/etc/init.d/", ["/etc/init.d/", "enabled"], 0x5588b2fbe8 /* 17 vars */) = -1 EACCES (Permission denied)
8930  writev(2, [{iov_base="//usr/lib/opkg/info/xinetd.posti"..., iov_len=37}, {iov_base=NULL, iov_len=0}], 2) = 37
8930  writev(2, [{iov_base="line 261: ", iov_len=10}, {iov_base=NULL, iov_len=0}], 2) = 10
8930  writev(2, [{iov_base="/etc/init.d/: Permission denied", iov_len=31}, {iov_base=NULL, iov_len=0}], 2) = 31
8930  writev(2, [{iov_base="", iov_len=0}, {iov_base="\n", iov_len=1}], 2) = 1
8930  exit_group(126)                   = ?
8930  +++ exited with 126 +++

So, something seems to try to exec the /etc/init.d/ directory, which doesn’t make any sense.

Any idea what’s going on?
Is the same happening on your devices?

I think you should file in a bug report in openwrt repository since its pulled from there

done:

I just thought to use collectd instead. But it results in the same error:

# opkg install collectd-mod-sensors
Installing collectd-mod-sensors (5.12.0-1) to root...
Downloading https://repo.turris.cz/hbs/mox/packages/packages/collectd-mod-sensors_5.12.0-1_aarch64_cortex-a53.ipk
Installing libltdl (2.4.6-2) to root...
Downloading https://repo.turris.cz/hbs/mox/packages/base/libltdl_2.4.6-2_aarch64_cortex-a53.ipk
Installing collectd (5.12.0-1) to root...
Downloading https://repo.turris.cz/hbs/mox/packages/packages/collectd_5.12.0-1_aarch64_cortex-a53.ipk
Configuring libltdl.
Configuring collectd.
//usr/lib/opkg/info/collectd.postinst: line 261: /etc/init.d/: Permission denied
Configuring collectd-mod-sensors.

@Pepe is seemingly reporting the same with fail2ban and a Turris 1.1: https://github.com/openwrt/packages/issues/19102

Perhaps it is Turris specific?

For now, it seems like it, I’d need to investigate that further.

This seems to be a bug that’s only happening in Turris OS 5 and should be solved in Turris OS 6. opkg install uses default_postinst from /lib/functions.sh which tries to get the enabled status of all services the package provides from /usr/lib/opkg/info/${pkgname}.list. On 5.4, this list contains an entry for both the service file and the directory, on TOS 6.0, this list only contains the service directory.

Turris MOX, Turris OS 6.0

root@turris:~# cat /usr/lib/opkg/info/xinetd.list | grep ^/etc/init.d
/etc/init.d/xinetd

Turris Omnia, Turris OS 5.4.1

root@turris:~# cat /usr/lib/opkg/info/xinetd.list | grep ^/etc/init.d
/etc/init.d/
/etc/init.d/xinetd

This means, /lib/functions.sh will try to get the enabled status of /etc/init.d/ (run /etc/init.d/ enabled) which will fail. This should be a harmless warning and should be fixed with Turris OS 6.0 that we hope to release soon.

1 Like

Correction: this was still happening to me on TOS 6.0 on 1 out of 3 routers I tested this on. I am not yet sure what’s the underlying issue, but I fixed it in patches/openwrt: fix Permission denied warning (!555) · Merge requests · Turris / Turris OS / Turris Build · GitLab, so it shouldn’t happen on TOS 6.0.