* SUMMARY: setuid on a C program that then tries to execute scu to eject
@ 2000-10-13 9:45 MacDonell, Dennis
0 siblings, 0 replies; only message in thread
From: MacDonell, Dennis @ 2000-10-13 9:45 UTC (permalink / raw)
To: tru64-unix-managers
Hi,
Robert Mulley had the right idea put something like
setuid(geteuid());
at the top of the program
here is the original question:
====================
Hi,
I scapped some code together that would allow users to mount, and
umount/eject mo disks from a Sony 4.1gb mo device. The machine its setup
on
has DU 4.0F. As root I can mount, and unmount the mo disks, and I can
use
the eject capabilities of the scu command to eject the disk.
For general users, I wanted to disable the eject button on the front of
the
device and build the eject into an unmount command which I knocked
together
in C. The compiled code has the permissions rws--x--x, and works fine
for
the mount and umount phases, but when it comes to the section of code
that
tries to do the eject, I get the following message
scu: No write permission on '/dev/rrz5c', EACCES (13) - Permission
denied
The executable does both the unmount and eject when I am using it as
root.
The code that is issuing the mount, umount and scu commands looks like
this
if( (pid=fork()) > 0)
{
/* get the parent to wait for the child to finish */
/* printf("real user id: %d \n ", getuid()); */
/* printf("effective user id: %d \n ", geteuid()); */
wait(&status);
}
else if(pid == 0)
{
/* get the child to execute the command and collapse */
/* printf("real user id: %d \n ", getuid()); */
/* printf("effective user id: %d \n ", geteuid()); */
if (execve(al[0],al,envp) != 0)
{
fprintf(stderr,"ERROR: errno=%d",errno);
perror (" ");
exit(1);
}
}
As you can see, I have checked to see that the thing is running with
effective uid of root. It looks as though scu is using real uid for
access
to the file /dev/rrz5c, and would appear to be a bug to me. Permissions
on
/dev/rrz5c are crw-------.
I don't know if sudo will solve this problem for me, it basically does
the
same trick of playing with effective uid's.
Maybe scu was fixed at a latter version of Tru64???
===============================
Dennis
######################################
Dennis Macdonell
Systems Administrator
AUSLIG
mail: PO Box 2, Belconnen, ACT 2617
email: mcdonell@auslig.gov.au
ph: 61 2 6201 4326
fax: 61 2 6201 4377
######################################
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-10-13 9:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-10-13 9:45 SUMMARY: setuid on a C program that then tries to execute scu to eject MacDonell, Dennis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox