1

I want to write a udev rule that blocks access to USB storage. I want to add match options that can recognise the username and permit only some users to use USB storage.

How can I find out which user(s) a currently logged in?

1 Answer 1

1

Why do you think you need such a complicated approach which also will cause trouble in any multi-user scenario? Why detect user logons?

I think you should simply write a udev rule which changes device access rights (group and its permissions) for the USB subsystem, and maintain access via the group memebrship of users. This is a standard case for udev rules.

5
  • This is a much better aproach and much less work that trying to get udev to do this.
    – Mogget
    Oct 7, 2015 at 17:10
  • I dont want user need logout and login again after i add permisstion for him. Oct 13, 2015 at 9:43
  • @BehradIrani You're welcome. It was a pleasure answering your question. It's interesting to learn that you have requirements which you did not mention at first. But it's very hard to tell from your comment whether you did any unsuccessful research already, because there are solutions to your, erm, complaint. See e.g. man newgrp. But somebody with your knowledge may be better off with solutions he can understand, even if they cause other problems which he isn't aware of.
    – Run CMD
    Oct 13, 2015 at 11:27
  • I know about newgrp. but not for my enviroment.(users dont know about command line). I only need some way to find which user logged in on console. Oct 19, 2015 at 17:56
  • I think i found my answer. i find active login in /sys/class/tty/tty0/active. combination of content of this file and output of "w" i can find user. Oct 19, 2015 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.