Why am I able to open this file?

Ruslan

While debugging a USB device usage I've come across a puzzling behavior of open(2):

admin@anahata-core-i5:/tmp$ groups
admin sudo
admin@anahata-core-i5:/tmp$ ls -l /dev/bus/usb/001/051
crw-rw----+ 1 root audio 189, 50 Jun 19 20:03 /dev/bus/usb/001/051
admin@anahata-core-i5:/tmp$ cat test.c 
#include <fcntl.h>

int main()
{
    return open("/dev/bus/usb/001/051",O_RDWR);
}
admin@anahata-core-i5:/tmp$ gcc test.c -o test && ./test ; echo $?
3

As you can see in the above session log, despite /dev/bus/usb/001/051 being accessible only to user root and group audio, I still successfully open the file for reading and writing.

What's going on? Why don't I get EPERM?

EDIT in response to comment:

admin@anahata-core-i5:/tmp$ getfacl  /dev/bus/usb/001/051
getfacl: Removing leading '/' from absolute path names
# file: dev/bus/usb/001/051
# owner: root
# group: audio
user::rw-
user:admin:rw-
group::rw-
mask::rw-
other::---
Ruslan

The + in mode output of ls -l (crw-rw----+) means that ACLs are being used. The output of getfacl /dev/bus/usb/001/051 in the OP contains one particular line:

user:admin:rw-

This means that, in addition to other permission settings, user admin is granted read and write permission for this file.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why am I not able to use relative path to open a file in CLion?

From Dev

Why am I not able to open a VS project

From Dev

Why am I able to still write to a file marked 400

From Dev

Why am I getting a crash using QTextStream on an open FILE *

From Dev

Why am I not Able to Construct This Regex

From Dev

Why am I not able to wget these types of links?

From Dev

Why am I not able to change worksheet reference?

From Dev

Why am I not able to add a JPanel to a JPanel?

From Dev

Why am I not able to use $this is an opencart helper?

From Dev

Why am I not able to add this route?

From Dev

Why am I not able to buy applications?

From Dev

I am not able to get the file path

From Dev

Why am I not able to compile a file that references jquery.d.ts?

From Dev

Why am I only able to read/processs one file from an SI MessageSource?

From Dev

Why I am no able to install audacity from neither the ppa repositories, nor the the .deb file?

From Dev

Why I am Not able to create and add data to the sqlite file at the same time?

From Dev

Why Am I able to edit /etc/resolv.conf on a read only file system?

From Dev

With CTE why i am not able to print 1 to 1000 number or more but 1 to 100 i am able to print

From Dev

Why am i not able to print the whole character as i have entered it?

From Dev

Why am I not able to consistently have a `HashTable` serialized?

From Dev

Why I am not able to populate the json data in bootstrap table

From Dev

Why am I able to print this field in a static method?

From Dev

Why am I not being able to compile SASS with Webpack?

From Dev

Why am I able to instantiate my Abstract Base Class in Python?

From Java

Why am I able to edit a LINQ list while iterating over it?

From Dev

Why I am not able to update to the lastest iOS Cordova Platform?

From Dev

Why i am not able to pass optional value ( ? ) for getting image url?

From Dev

Why am I not able to initialize Generic Parameter and Array?

From Dev

Why am I not able to use FindResource() in Windows phone programming?

Related Related

  1. 1

    Why am I not able to use relative path to open a file in CLion?

  2. 2

    Why am I not able to open a VS project

  3. 3

    Why am I able to still write to a file marked 400

  4. 4

    Why am I getting a crash using QTextStream on an open FILE *

  5. 5

    Why am I not Able to Construct This Regex

  6. 6

    Why am I not able to wget these types of links?

  7. 7

    Why am I not able to change worksheet reference?

  8. 8

    Why am I not able to add a JPanel to a JPanel?

  9. 9

    Why am I not able to use $this is an opencart helper?

  10. 10

    Why am I not able to add this route?

  11. 11

    Why am I not able to buy applications?

  12. 12

    I am not able to get the file path

  13. 13

    Why am I not able to compile a file that references jquery.d.ts?

  14. 14

    Why am I only able to read/processs one file from an SI MessageSource?

  15. 15

    Why I am no able to install audacity from neither the ppa repositories, nor the the .deb file?

  16. 16

    Why I am Not able to create and add data to the sqlite file at the same time?

  17. 17

    Why Am I able to edit /etc/resolv.conf on a read only file system?

  18. 18

    With CTE why i am not able to print 1 to 1000 number or more but 1 to 100 i am able to print

  19. 19

    Why am i not able to print the whole character as i have entered it?

  20. 20

    Why am I not able to consistently have a `HashTable` serialized?

  21. 21

    Why I am not able to populate the json data in bootstrap table

  22. 22

    Why am I able to print this field in a static method?

  23. 23

    Why am I not being able to compile SASS with Webpack?

  24. 24

    Why am I able to instantiate my Abstract Base Class in Python?

  25. 25

    Why am I able to edit a LINQ list while iterating over it?

  26. 26

    Why I am not able to update to the lastest iOS Cordova Platform?

  27. 27

    Why i am not able to pass optional value ( ? ) for getting image url?

  28. 28

    Why am I not able to initialize Generic Parameter and Array?

  29. 29

    Why am I not able to use FindResource() in Windows phone programming?

HotTag

Archive