I have two Users. User1 is running a program which tries to delete a file from user2. But my program always return me "permission denied".
When I try to delete the file myself as user1 with the rm command there is no problem. The permission of the files are 775 and my user1 is in the group of user2. This group is also the owner of the files. The permission of the directory in which the files are is 775 too.
For removing the file the program I have written uses the "remove" function from c/c++. Does anyone have a solution or idea ?
I have asked this question on unix.stackexchange.com before. They have sent me here.
Here is my code:
void deleteFile() {
if(0 != remove("File1.txt"))
cout<<"Error deleting File: "<<strerror(errno)<<endl;
if(0 != remove("File2.txt"))
cout<<"Error deleting File: "<<strerror(errno)<<endl;
}
i have renamed the files but i know the original paths are correct. i have already tested this
more information: ok i have runnned the program as user2 and the files have been deleted without any problems.
groups user1
users user2
groups user2
user2 adm www-data plugdev users ftp vsftpd
ls -lah
drwxrwxr-x 7 user2 user2 4.0K Nov 27 14:13 .
drwxrw-r-x 4 user2 user2 4.0K Nov 11 12:34 ..
-rwxrwxr-x 1 user2 user2 50 Nov 12 15:12 File1.txt
-rwxrwxr-x 1 user2 user2 826 Nov 27 14:13 File2.txt