[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#590744: Fails to boot if /sbin/init is a symlink



* Michael Biebl <biebl@debian.org> [Thu Jul 29, 2010 at 02:16:32AM +0200]:
> On 29.07.2010 01:37, Michael Prokop wrote:
> > * Michael Biebl <biebl@debian.org> [Thu Jul 29, 2010 at 01:13:01AM +0200]:

> >> for testing purposes, I installed the upstart binary as /sbin/upstart and
> >> created a symlink /sbin/init → /sbin/upstart
> >> This causes a boot failure, due to this check in /usr/share/initramfs-
> >> tools/init

> >> # Check init bootarg
> >> if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
> >>        echo "Target filesystem doesn't have ${init}."
> >>        init=
> >> fi

> >> To quote Mithrandir (from irc):
> >> <Mithrandir> -x follows symlinks
> >> <Mithrandir> but that means it'll look for symlinks in the initramfs, so the
> >> check is buggy.

> > You shouldn't use an absolut symlink here, use a relative one instead.
> > See Debian policy 10.5 for details.

> Well, changing it to /sbin/init -> upstart did indeed work for this particular
> case. But I still get the problem when the link is absolute, as is specified by
> the policy for symlinks not in the same directory.

> To be a bit more specific what I was doing:
> I tested the new systemd init system, which installs the binary in /bin/systemd
> (note the "/bin").

This isn't an existing + available Debian package yet, right?
Why is it installing itself to /bin/systemd? Is it supposed to be
executed by non-root users as well?

> So I moved /sbin/init from upstart to /sbin/upstart and made
> /sbin/init a symlink so I could easily test both systems. Using a relative
> symlink for /sbin/upstart does work, but an absolute symlink /sbin/init ->
> /bin/systemd does not.
> So I'm reopening the bug report and retitling appropriately.

If systemd really uses /bin for a reason we could use something like
the following in initramfs-tools' init:

  # Check init bootarg
  if [ -n "${init}" ] ; then

        # Work around absolute symlinks
        initsymlinktarget="${init}"
        if [ -d "${rootmnt}" ] && [ -h "${rootmnt}${init}" ] ; then
            case $(readlink "${rootmnt}${init}") in /*)
                initsymlinktarget=$(chroot "${rootmnt}" readlink "${init}")
                ;;
            esac
        fi

        if [ ! -x "${rootmnt}${init}" ] || [ ! -x "${rootmnt}${initsymlinktarget}" ] ; then
              echo "Target filesystem doesn't have ${init}."
              init=
        fi
  fi

Can you please give that a try?

regards,
-mika-

Attachment: signature.asc
Description: Digital signature


Reply to: