tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: "MacDonell, Dennis" <DennisMacDonell () auslig ! gov ! au>
To: tru64-unix-managers
Subject: setuid on a C program that then tries to execute scu to eject an	mo
Date: Fri, 13 Oct 2000 09:11:06 +0000	[thread overview]
Message-ID: <97142817211933.tru64-unix-managers.marc@archive.invalid> (raw)


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
######################################

                 reply	other threads:[~2000-10-13  9:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox