[SOLVED] Why can't use USB MassStorage device under non-root account?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why can't use USB MassStorage device under non-root account?
Hello everybody:
I met a problem.When I used a USB Mass Storage device under root account,everything is OK.But uder a non-root account,a proble is comming.
1.I used mknod xxx b 11 x to make a device file.
2.Then used libusb to send a command to device.Under usb in kernel,is used SCSI driver.In linux is a sr(11) device.
3.Everything is OK.The device return ok.
But I used uper step in non-root account,device return error.
1.I used chmod 4777 /bin/mknod changed mknod's attribute to root.
2.But send command under non-root account,device return error.
a.What's different in root and non-root send command to usb-mass-storage device?
b.How to solve this proble?
Is your USB Mass Storage ntfs? If it is: You cannot change privileges of ntfs filesystem. After chmod 4777 check ls -l /bin/ and you'll see that privileges are not changed. Access to ntfs is reserved to root(or admin users in general). It is possible that you may change this through some kind of a .conf file, or maybe through adding user to 'plugdev' group. That's all I can help
You should probably wait a little bit for someone else's opinion about this.
To hogar.strashni
LQ Newbie:
The problem also exist!But,thank you all the same!!
My device is a USB device that used Mass Storage protocol,but not a udisk.I used a program to send command to the device.Under linux usb driver,is using SCSI driver that the linux operating system's self-install.Under root I send command to the device,everything is OK.But under non-root the device returned err.
I don't know how to solve this problem.It's mean that how can I send command to device successfully under non-root account?????
Thanks a lot!
Nobody's answering, so I'll give it a try again. You probably tried this, but I hope you won't mind.
Plug it in and mount as a root. It will be mounted someway, won't it?! "ls -l" folder where you mounted it, so you could check out the group it belongs to. Hope it's not root. If not, add user to that group.
Good luck, and give me some feedback, I really would like to know what's the answer.
"chmod 777 /dev/foo" is changing attributes to a device. If you do not know which device you should change attribute to, again mount it as a root, and you'll have it in the /etc/mtab. In the same line where is written mount point(folder) of your drive, you'll have something starting with /dev/xxxx.
Hope I'm not to detailed.
Last edited by hogar.strashni; 02-25-2011 at 07:47 PM.
Reason: I'm so stupid
To hogar.strashni:
Thank you very much for your help!I am trying your method!Then I will give you some feedback!!!
Your mechod is using system's self create mouted point,in linux my device is /dev/sr1.But why isn't work using myself create device file?I used mknod to create a device file,then I used chomod 4777 xxxx changed this file's attribute,but when I used this device file to send command is error!
To hogar.strashni:
I used your method,using chmod 4777 /dev/sr1.But still not worked!I send command,the device still return err.But in root is OK.Thank you all the same!
The proble is still exist!Any method?Thanks!
plug in your drive and mount it as a root. If "/path/directory" is mount point type:
Quote:
ls -l /path/
You should get output such as:
Quote:
drwxrwx--- 1 root xxxxxxx 12288 2011-01-27 04:11 podaci
Notice "xxxxxxx". That is name of a group directory "podaci" belongs to. Also notice privileges: "drwxrwx---". Make sure you have same or "drwxrwxrwx".
Than add user to the group that stands on the place of "xxxxxxx". You should be couscous with group names such as "root" and "admin", and ask people here, who have more experience then I do(there's plenty of such, I'm far from veteran ) to tell you more about that group and what you gave your user with membership to the group.
If that doesn't work, I'm depleted.
Last edited by hogar.strashni; 02-25-2011 at 09:58 PM.
To hogar.strashni:
My dear friend,I used your method.My device is mounted:/dev/sr1.
I used chmod 777 /dev/sr1
ls -lh /dev/sr1:
brwxrwxrwx+ 1 root cdrom 11, 1 Feb 26 12:09 /dev/sr1
And then I add my common user account to group:
cdrom:x:11:yuan
But when I under the non-root commom user account:yuan,I send command,the device return still error!
Oh, My God!What's the point to solve the issue???????????
I didn't mean to "ls -l /dev/sr1" device.
I meant to do it with mount point directory - directory(place) where you are mounting your mass storage to the file system. e.g. if you are mounting cd /dev/cdrom to /mnt/mymusic do the "ls -l /mnt/"
I'm sorry, but I have to go to sleep. I'm dropping dead. It's 6 AM here. Good luck, and don't forget to post the solution when you make it work, and to mark this thread as solved
Last edited by hogar.strashni; 02-25-2011 at 11:08 PM.
To hogar.strashni my der friend:
Until now,the problem is still exist!When I solved,I'll give the answer!Thank you verify much!The time here is 14:40 PM.Have a nice dream.
Anynone can help me???????Thanks!!!!
I want to use a usb device under non-root account in linux.
Hi,All:
Thank you very muchu for the people who helped me to solve this problem!Thank you!!!!
Through mknod to make device file or used linux system-self create device file,under non-root account used program to send command to device,will be error.
This is because,my device is used USB Mass Storate protocol,used ioctl system function to send command,in kernel,it is request root priviledge, so under user account or user terminal all to be error!
The solved method is to create a service,my program to communicate to the service,the service to send command to the device,the problem is broken!!!!!!!Because service in linux like windows have root priviledge!
Ok,hope is helpful to the people who have the same problem!!!!!
Thank you everyone who answered this problem!!!Thanks!!!
Everybody have a nice day!!!!Linux is wonderful!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.