Sample Header Ad - 728x90

setuid not working with C code and system() call

0 votes
1 answer
190 views
I have NICE-DCV installed in RHEL-8.10 and **as root** doing a dcv list-sessions shows all sessions on the system. But if a user does dcv list-sessions then the output from that is only their session and it doesn't report any other session; this is normal. In writing C code in an admin effort to pretty the list-session output, and allow all users to see what active sessions there currently are, I attempted to **setuid** on my /usr/local/bin/dcvlist c executable and it shows as -rwsrwxr-x. 1 root root dcvlist. As root when I run this dcvlist executable I get expected output of all sessions happening but as a regular user account that still does not happen. Am I doing something wrong based on what I explained? Am I mistaken thinking the setuid should also apply to the system("dcv list-sessions") within my C code which it appears not to be? All my C code is doing is system("dcv list-sessions") ... actually a popen and then I'm just reprinting that output. also, the dcv program takes many parameters in addition to list-sessions so I don't want to allow sudo access to allow users to run that as root.
Asked by ron (8647 rep)
Aug 27, 2024, 03:54 PM
Last activity: Aug 27, 2024, 04:25 PM