Any system call in C to change the permission of a file in HP-UX in a non-root user mode?. I used Chmod system call, it worked for me in the root user mode but not in the non-root user mode. I feel setuid system call will help me here, but i dnt know how to use it?. So any new suggestions to my problem or how to make use of setuid .
Asked
Active
Viewed 239 times
1
-
possible duplicate of [Any system call in C to change the permission of a file in HP-UX](http://stackoverflow.com/questions/5551557/any-system-call-in-c-to-change-the-permission-of-a-file-in-hp-ux) – Paul R Apr 06 '11 at 12:37
-
@Paul R: yes, because a comment on that question asked the OP to create a new question with more details (which was probably bad advice, but what can you do?) – Wooble Apr 06 '11 at 12:40
-
@Wooble: I see - yes, that was poor advice - the OP should have just updated his original question, not duplicated it. – Paul R Apr 06 '11 at 12:41
-
@Wooble and Paul : Sorry guys I m very new to stack overflow. – user205688 Apr 06 '11 at 12:48
1 Answers
0
chmod() is the correct syscall, but if you don't have access rights to change the permissions of the file then you're out of luck.
As you certainly can imagine, changing permissions of files you don't have the right to change permissions of would create a gaping security hole.
Wrt setuid(), that tends to be restricted to superusers, or programs with the setuid bit set. Again, for obvious security reasons, a random user cannot change himself to some other random user in the general case.
So if you want to make chmod() work without any kind of superuser privileges, the solution is that the process UID must be the same as the owner of the file you're trying to change permissions on.

janneb
- 36,249
- 2
- 81
- 97