LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Why can't use USB MassStorage device under non-root account? (https://www.linuxquestions.org/questions/linux-kernel-70/why-cant-use-usb-massstorage-device-under-non-root-account-864532/)

zyroot998 02-23-2011 09:19 AM

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?

Thanks a lot!

hogar.strashni 02-23-2011 11:56 AM

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.

zyroot998 02-24-2011 05:30 AM

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!

zyroot998 02-24-2011 08:46 PM

Anynone know how to solve this problem?Thanks!

nini09 02-25-2011 02:27 PM

Try to change your device attribute using chmod. Normally non-root can't write something to the device.

zyroot998 02-25-2011 07:28 PM

To nini09
Member:
How to change my device's attribute?I am a beginer to linux!Thanks!

hogar.strashni 02-25-2011 07:36 PM

hey, hi!

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.

hogar.strashni 02-25-2011 07:39 PM

"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.

zyroot998 02-25-2011 08:01 PM

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!

zyroot998 02-25-2011 09:17 PM

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!

hogar.strashni 02-25-2011 09:57 PM

Did you try what I mentioned four posts above:

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.

zyroot998 02-25-2011 10:50 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???????????

hogar.strashni 02-25-2011 11:06 PM

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 :)

zyroot998 02-26-2011 12:37 AM

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.

zyroot998 02-28-2011 05:31 AM

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!!


All times are GMT -5. The time now is 05:14 PM.