I cannot seem to open files that should be owned by me... I feel very silly, and a bit like im losing my mind, I don't know what is wrong... but i must be missing something.
# Example shows that all files in directory are owned by user2 with 664 permission
$ ls -la /home/user1/filestore
total 2788
drw-rw-r-- 2 user2 user2 2 0480 Jul 2 12:44 .
drwxrwxr-x 8558 user1 user1 2494464 Jul 1 16:28 ..
-rw-rw-r-- 1 user2 user2 23718 Jul 1 15:02 z6B00001-1593640926.readings
-rw-rw-r-- 1 user2 user2 73606 Jul 2 12:44 z6B00001-1593719061.readings
-rw-rw-r-- 1 user2 user2 232629 Jul 2 14:44 z6B00001-1593719062.readings
# showing current user
$ whoami
user1
# groups for current user
$ groups user1
user1 user2
# groups for user2
$ groups user2
user2 user1
# start python as user2
$ sudo -u user2 python
>>> open("/home/user1/filestore/z6B00001-1593640926.readings","rb") as f:
... f.read()
Traceback (most recent call last): #<<< what??????????
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: '/home/user1/filestore/z6B00001-1593719062.readings'
>>> os.system("whoami")
user2
0
>>> os.system("groups")
user2 user1
0
>>> os.system("ls -la /home/user1/filestore")
ls: cannot access '/home/user1/filestore/.': Permission denied
ls: cannot access '/home/user1/filestore/..': Permission denied
ls: cannot access '/home/user1/filestore/z6B00001-1593640926.readings': Permission denied
ls: cannot access '/home/user1/filestore/z6B00001-1593719061.readings': Permission denied
ls: cannot access '/home/user1/filestore/z6B00001-1593719062.readings': Permission denied
total 0
d????????? ? ? ? ? ? .
d????????? ? ? ? ? ? ..
-????????? ? ? ? ? ? z6B00001-1593640926.readings
-????????? ? ? ? ? ? z6B00001-1593719061.readings
-????????? ? ? ? ? ? z6B00001-1593719062.readings
256
>>> exit()
$ sudo -u user1 python
>>> open("/home/user1/filestore/z6B00001-1593640926.readings","rb") as f:
... f.read()
Traceback (most recent call last): #<<< what??????????
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: '/home/user1/filestore/z6B00001-1593719062.readings'
>>> os.system("whoami")
user1
0
>>> os.system("groups")
user1 user2
0
expected behaviour is to be able to open and read(and write) these files as either user1 or user2... currently neither works:(
I feel extra silly... apparently the directory needs the execute bit set , and I had no idea
resolved with chmod 775 /home/user1/filestore
sorry i posted a question and then answered it myself... but im going to leave it since i didnt see a dupe in my 2 minutes of searching:P feel free to point to a dupe and close if such a dupe exists, or put a more thorough answer than this
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.