On 25/01/13 14:43, Hugo Mills wrote:
On Fri, Jan 25, 2013 at 07:29:44AM -0500, Gene Czarcinski wrote:
On 01/25/2013 06:55 AM, Roman Mamedov wrote:
On Fri, 25 Jan 2013 06:32:30 -0500
Gene Czarcinski <g...@czarc.net> wrote:

This patch hits a lot of files but adds little code.  It
could be considered a bugfix,  Currently, when one of the
btrfs user-space programs is executed by a regular user,
the result if oftem a number of strange error messages
which do not indicate the real problem.  This patch changes
that situation.

A test is performed as to whether the program is running
as root.  If it is not, issue an error message and exit.
Signed-off-by: Gene Czarcinski <g...@czarc.net>
$ ls -la /dev/sda
brw-rw---T 1 root disk 8, 0 Jan 15 12:11 /dev/sda

The user does not have to be root, they can be a member of the group "disk" to
manage this device.

Also some or all of the tools accept not just a block device, but also a
regular file as their parameter.

Wouldn't it be better to check whether or not the running user has
*write access* to the device or file to be operated on, before failing?
I knew there would be corner cases where root was not required for
execution.  After all, I do not need to be root to execute "btrfs
--version".  Now, is it worth the effort to determine the corner
cases and do you have a proposed solution as to determining what
privileges are needed when?  I can understand when it could be a
regular file but is it all that common for users to be part of group
disk?
    Don't try to check all the possible success conditions beforehand
-- that's what leads to websites that fail to work because your
browser is not IE, but work perfectly when you change your user-agent
string to "MSIE". This is highly frustrating for users.

    Instead, try whatever it is you were trying to do (open a file,
send an ioctl), and determine, as well as you can, why it failed by
looking at the error codes that you get back, and report that.
"Permission denied" -> means you don't have permissions -> you need to
be root, or have yourself put in the disk group, or get the
disk-management-capability. Let the user work out which of those
solutions they need, rather than forcing them to use the one you
thought of.

    Hugo.
As Hugo suggested, I'd rather that we fix or refine the code in order to get better error messages. All the different exceptions to requiring or not requiring root overly complicates things that, strictly speaking, shouldn't need to be handled in advance.

--
__________
Brendan Hide
http://swiftspirit.co.za/
http://www.webafrica.co.za/?AFF1E97

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to