SUMMARY: Allow users to mount floppy

From: M.Ramchand@car0101.wins.icl.co.uk
Date: Tue Apr 20 1993 - 20:43:23 CDT


------------------------------ Start of body part 1

Hi Sun Managers,
Sorry for the delay but I was on 2 weeks leave. I recieved 27
responses, 2 of which asked me to post a summary, the others
provided a variety of answers which fall into mainly 3
categories.

------------------------------ Start of body part 2

         1:
              setuid scripts. This approach was frowned upon due to the
         security implications. Essentially make a script which will do
         what you want, make it owned by root and then set the setuid bit.
         Many persons said DO NOT DO THIS. You have been warned.
         
         2: setuid programs. This is similar to above, though more
         secure. Write a quick and dirty C program to do it. This way you
         get around the security risk of a setuid script. Here is one
         provided by danny@ews7.dseg.ti.com
         
         <----------begin included message----------->
         
         both programs assume entry in /etc/fstab:
          /dev/fd0 /pcfs pcfs rw,noauto 0 0
         
         suid program to mount floppy:
         
         #include <stdio.h>
         #include <sys/types.h>
         #include <sys/stat.h>
         
         
         main()
            {
            dev_t root;
            struct stat buff;
            char *readonly = "";
         
            setreuid (0, 0);
         
            stat ("/", &buff);
            root = buff.st_dev;
         
            stat ("/pcfs", &buff);
         
            if (buff.st_dev != root)
               {
               fprintf (stderr, "**something already mounted; run pcumount
         first\n");
               }
            else
               {
               system ("mount /pcfs");
         
               stat ("/pcfs", &buff);
               if (buff.st_dev == root)
                  { /* try again read-only */
                  fprintf (stderr, "\n**the mount failed. will try again to
         mount read-only\n");
                  system ("mount -o ro /pcfs");
                  readonly = "read-only ";
                  stat ("/pcfs", &buff);
                  }
         
               if (buff.st_dev == root)
                  {
                  fprintf (stderr, "\n**the mount failed. make sure the
         floppy is\n");
                  fprintf (stderr, "** actually in the drive.\n");
                  }
               else
                  {
                  fprintf (stderr, "the floppy is mounted %sunder directory
         /pcfs\n",
                           readonly);
                  }
               }
         
            exit (0);
            }
         ------------------------------------------------------------------
         -
         suid program to dismount floppy:
         
         #include <stdio.h>
         #include <sys/types.h>
         #include <sys/stat.h>
         
         
         main()
            {
            dev_t root;
            struct stat buff;
         
            setreuid (0, 0);
         
            stat ("/", &buff);
            root = buff.st_dev;
         
            stat ("/pcfs", &buff);
            if (buff.st_dev == root)
               {
               fprintf (stderr, "floppy not mounted\n");
               }
            else
               {
               system ("umount /pcfs");
         
               stat ("/pcfs", &buff);
               if (buff.st_dev == root)
                  {
                  fprintf (stderr, "floppy successfully unmounted\n");
                  system ("eject");
                  }
               else
                  {
                  fprintf (stderr, "\n**the unmount failed. if a pcfs
         device busy error\n");
                  fprintf (stderr, "**came up, you need to 'cd' off of the
         drive or move\n");
                  fprintf (stderr, "**the file manager off of the
         drive.\n");
                  }
               }
         
            exit (0);
            }
         <------------- end included message ----------->
         
         I have not tried it but it looks like it should work.
         
         
         3: Finally (saved the best for last), there are a whole range of
         PD software about which do the trick.
              
              mtools: DOS like commands to interact with floppy.
         
              fdmount: allows user to mount/unmount floppy/cdrom
         
              usermount: as above
         
              mntdisk: as above
         
              mounttool and usermount stuff: as above
         
         I have used mtools before and can vouch for its niceness. These
         programs should all be available from your nearest ftp archive
         site. (Unfortunately I'm connected by an obscure X.400 gateway and
         have no ftp any longer, anybody know of a good mail archive server
         and how to use it?)
         
         Thanks to all who responded. (Not too many to list but almost
         impossible due to the way X.400 garbles the rfc822 headers)
         
         PS One person said that Sun said that Solaris 2.2 will do this
         automagically.

------------------------------ End of body part 2



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:07:45 CDT