setuid on a C program that then tries to execute scu to eject an mo disk fails.

From: MacDonell, Dennis <DennisMacDonell_at_auslig.gov.au>
Date: Fri, 13 Oct 2000 20:11:06 +1100

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_at_auslig.gov.au
ph: 61 2 6201 4326
fax: 61 2 6201 4377
######################################
Received on Fri Oct 13 2000 - 09:12:41 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:41 NZDT