/etc/init.d/udev-finish attempts to write to read-only root

Bug #224870 reported by Remi Broemeling
2
Affects Status Importance Assigned to Milestone
udev (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: udev

In the /etc/init.d/udev-finish script it attempts to write to /etc/udev/rules.d, which will not work if the machine does not have write-access to that location (i.e. NFS RO-roots are a good example). Attached is a patch that naively fixes this by a simple -w check on /etc/udev/rules.d.

Revision history for this message
Remi Broemeling (remi-nexopia) wrote :
Revision history for this message
Remi Broemeling (remi-nexopia) wrote :

Note: I had to tweak the patch to make it work correctly using dash as the shell.

Specifically, in my case, `[ -w /etc/udev/rules.d ]` does not seem to work correctly using the dash built-ins, so I tweaked the conditional to give the full path to `[`, which bypasses the buggy built-in.

i.e.

if /usr/bin/[ -w /etc/udev/rules.d ]; then
...
fi

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

/usr may not be mounted at that point.

Why doesn't [ -w ... ] work in dash?

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Actually, -w doesn't work at all since POSIX says it can return TRUE if the filesystem is read-only.

An alternate test for writability is required.

Revision history for this message
Remi Broemeling (remi-nexopia) wrote :

[ -w /etc/udev/rules.d ] returns FALSE in BASH for a RO root
[ -w /etc/udev/rules.d ] returns TRUE in DASH for a RO root
/usr/bin/[ -w /etc/udev/rules.d ] returns FALSE in BASH and DASH (and I assume every other shell) for a RO root

I had thought that POSIX specified that -w should return FALSE when used on a read-only filesystem, but perhaps I was incorrect.

A kludge would be to try and touch a file in /etc/udev/rules.d (errors to /dev/null), and then check the return code.

Changed in udev:
importance: Undecided → Low
status: New → Triaged
Changed in udev:
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package udev - 137-1

---------------
udev (137-1) jaunty; urgency=low

  * New upstream release:
    - udevadm test no longer has force option.
    - udevd has --resolve-names=early|late|never option.
    - Group of IDE CD-ROM drives fixed. LP: #315997.
    - Group of DRI subsystem fixed. LP: #317430.
    - /etc/udev/rules.d not existing is not an error. LP: #315780.
    - Bug where device nodes would be replaced by symlinks on rename has been
      fixed. LP: #315979.

  * Use --resolve-names=never in the installer and initramfs, since we don't
    have a useful name service. LP: #319199.
  * Since we don't have to worry about group lookup, we may as well copy the
    default rules into the initramfs as well. This actually double-solves
    LP: #315979.
  * Make sure the root filesystem is writable before attempting to copy
    generated rules across. LP: #224870.
  * Remove /dev/MAKEDEV symlink; the FHS no longer requires it when /dev
    is automatically managed.

  * It is not permitted to call udevadm trigger or settle during an upgrade
    without depending on udev. Attempting this will fail.
  * Change /etc/init.d/udev restart to actually restart the daemon, with a
    bit of detection to print a warning if we missed events while the
    daemon was down.
  * Refreshing /dev is now /etc/init.d/udev refresh-devices
  * Restart udev daemon after upgrade. LP: #317944.

 -- Scott James Remnant <email address hidden> Fri, 23 Jan 2009 15:15:07 +0000

Changed in udev:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.