[pvrusb2] Permission denied writing to cur_val

Michael Krufky mkrufky at linuxtv.org
Tue Oct 21 14:57:13 CDT 2008


On Tue, Oct 21, 2008 at 3:53 PM, Mike Isely <isely at isely.net> wrote:
>
>
> On Tue, 21 Oct 2008, Larry on the Dell wrote:
>
>>
>> My happauge PVR-USB2 wants to default to television input rather than my
>> preferred s-video.  So I read cur_val could be written to control this.
>> So working my in
>>
>> lj at mythtv:/sys/class/pvrusb2/sn-8504958/ctl_input$ cd
>> /sys/class/pvrusb2/sn-8504958/ctl_input
>> lj at mythtv:/sys/class/pvrusb2/sn-8504958/ctl_input$ ls -al
>> total 0
>> drwxr-xr-x  2 root root    0 2008-10-21 12:35 .
>> drwxr-xr-x 56 root root    0 2008-10-21 12:33 ..
>> -rw-rw-r--  1 root root 4096 2008-10-21 12:35 cur_val
>> -r--r--r--  1 root root 4096 2008-10-21 12:35 enum_val
>> -r--r--r--  1 root root 4096 2008-10-21 12:35 name
>> -r--r--r--  1 root root 4096 2008-10-21 12:35 type
>>
>> lj at mythtv:/sys/class/pvrusb2/sn-8504958/ctl_input$ cat cur_val
>> television
>>
>> so I don't want the television input, I want the s-video input.  So
>> attempt to write that
>>
>> lj at mythtv:/sys/class/pvrusb2/sn-8504958/ctl_input$ echo s-video > cur_val
>>
>> which results in
>>
>> -bash: cur_val: Permission denied
>>
>> so I tried
>>
>> lj at mythtv:/sys/class/pvrusb2/sn-8504958/ctl_input$  sudo  echo s-video >
>> cur_val
>>
>> with the same result.
>>
>> -bash: cur_val: Permission denied
>>
>> This is with  mythbuntu and
>> MythTV Version   : 18207
>> MythTV Branch    : branches/release-0-21-fixes
>> Library API      : 0.21.20080304-1
>>
>>
>>  From the command line,  how do I set  ctl_imput  to s-video?
>>
>
> You have to be root in order to do that.  The sudo trick should have
> worked, but maybe your distro is doing something strange with sudo?
> Try using "sudo -s" to get a root shell.  Then you can at least verify
> that you really are root.  (And also once you're in the shell you can
> try to directly modify those sysfs nodes.)
>
> As for why you need to be root, there isn't much the driver can do about
> that.  From the viewpoint of inside the kernel there really isn't a way
> to change the owner of those sysfs files.  The permissions can be
> adjusted, but it's unwise for those fields to be world-writeable - since
> then anything can take over control of the device.  With device control,
> usually one changes the gid of the files to match a specific group (e.g.
> "video") and then users with permission to operate the device need only
> be associated with that group.  But even there the driver can't do
> anything even if it wanted to, since the actual integer gid value for,
> say, "video" is distro-specific.  One clean, theoretical, way to fix
> this is for there to be a udev rule that executes a chgrp on all of
> /sys/class/pvrusb2/sn-xxxxxx at the point when the device appears.
> That has the additional advantage that udev can know the correct
> distro-specific gid value to use.  But I haven't implemented this (this
> is a task really outside of the driver).  But it would be a useful
> exercrise for someone else to set up.

An explanation for why sudo does not work:

The sysfs interface creates a filesystem that can only be touched by
root.  The "sudo" command elevates privileges for the "echo" command,
but the redirection " > " is still being handled by the shell (bash)
that the user is actually logged in to.  If you do "sudo su" , that
will start a new shell AS user root, and then redirection will work.

Regards,

Mike Krufky


More information about the pvrusb2 mailing list