The -s option needs to open the device O_RDWR for non-root users

Bug #27380 reported by Ben Collins
6
Affects Status Importance Assigned to Milestone
eject (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

If a user has read/write access to a device, they should be able to send SG_IO
commands to it. However, since eject only opens the device O_RDONLY, the kernel
returns EIO when using "eject -s" as a normal user.

The patch opens the device O_RDWR, since that's what you'll need in order to
send these commands (kernel ignores this requirement for root).

Revision history for this message
Ben Collins (ben-collins) wrote :

Created an attachment (id=5415)
Patch to open device RDWR for -s option

Revision history for this message
Martin Pitt (pitti) wrote :

Ben,

the patch you applied breaks eject for normal USB devices (and I suspect for
Firewire, too). The usual permissions for these are 0640, i. e. you cannot open
the device R/W and eject fails completely.

Maybe the patch should be modified to try r/w first, and fallback to r/o if r/w
fails?

Revision history for this message
Ben Collins (ben-collins) wrote :

Oops. Uploading a new version that falls back to RDONLY.

Revision history for this message
Martin Pitt (pitti) wrote :

 eject (2.0.13deb-18ubuntu3) dapper; urgency=low
 .
   * Fix patch from previous version: If the device cannot be opened r/w, try
     again r/o. This is the usual case for USB/FireWire devices.

I close this bug now, this is the best we can get.

Revision history for this message
Martin Pitt (pitti) wrote :

My upload was rejected; Ben, your's was faster :) Anyway, thanks for fixing it.

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.