LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-23-2011, 09:19 AM   #1
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Rep: Reputation: 0
Unhappy 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!
 
Old 02-23-2011, 11:56 AM   #2
hogar.strashni
Member
 
Registered: Dec 2007
Distribution: cp6
Posts: 44

Rep: Reputation: 2
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.
 
Old 02-24-2011, 05:30 AM   #3
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
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!
 
Old 02-24-2011, 08:46 PM   #4
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
Anynone know how to solve this problem?Thanks!
 
Old 02-25-2011, 02:27 PM   #5
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
Try to change your device attribute using chmod. Normally non-root can't write something to the device.
 
Old 02-25-2011, 07:28 PM   #6
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
To nini09
Member:
How to change my device's attribute?I am a beginer to linux!Thanks!
 
Old 02-25-2011, 07:36 PM   #7
hogar.strashni
Member
 
Registered: Dec 2007
Distribution: cp6
Posts: 44

Rep: Reputation: 2
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.
 
Old 02-25-2011, 07:39 PM   #8
hogar.strashni
Member
 
Registered: Dec 2007
Distribution: cp6
Posts: 44

Rep: Reputation: 2
"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
 
Old 02-25-2011, 08:01 PM   #9
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
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!
 
Old 02-25-2011, 09:17 PM   #10
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
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!
 
Old 02-25-2011, 09:57 PM   #11
hogar.strashni
Member
 
Registered: Dec 2007
Distribution: cp6
Posts: 44

Rep: Reputation: 2
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.

Last edited by hogar.strashni; 02-25-2011 at 09:58 PM.
 
Old 02-25-2011, 10:50 PM   #12
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
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???????????
 
Old 02-25-2011, 11:06 PM   #13
hogar.strashni
Member
 
Registered: Dec 2007
Distribution: cp6
Posts: 44

Rep: Reputation: 2
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.
 
Old 02-26-2011, 12:37 AM   #14
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
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.
 
Old 02-28-2011, 05:31 AM   #15
zyroot998
LQ Newbie
 
Registered: Feb 2011
Location: China
Posts: 17

Original Poster
Rep: Reputation: 0
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!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can root unplug/plug USB device with only command root ? frenchn00b Linux - General 2 10-16-2007 12:49 AM
Why is my common account can't open Terminal in XFCE4 but root account? notsay Slackware 4 08-18-2007 11:29 PM
USB device as root filesystem greeklegend Linux - Hardware 5 12-17-2006 01:50 AM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM
Read and write USB device with non-root access halfzware_shag Linux - Hardware 3 10-11-2004 04:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration