sukmi@cs.psu.edu (Sukmi Lim) (02/22/90)
We just installed the r/w optical disk on our HP9000/300 running HP-UX6.5. We want each user to be able to have a mount point in their home directory and mount/umount the optical disk. Is there any way to mount/umount file system without being a superuser. I understand mount/umount can be only executed by superuser. We are looking for a way that we can give a user who wants to mount/umount the optical disk superuser priviledge temporarily while mounting/unmounting the disk. Or is it the only way for a system administrator to do it whenever a user asks for it? Please reply to: sukmi@terra.geosc.psu.edu Thank you in advance.
curt3028@oce.orst.edu (Curt Vandetta) (02/24/90)
Hello folks, I've written some C-code that we user here on an HP 9000 series 370, that runs setuid to root, so it allows normal users to mount and unmount the optical disk. I worked in some SCSI commands that HP provide to disable/enable the ejection button on the drive as well, so it helps to prevent the removal of mounted media. Basically the programs work as follows: odmount - Mounts the optical to the directory /optical (This is hard coded for security reasons but can be changed to any directory you see fit, and with some work it could probably even pick a directory under the users homedir. But I had problems with this i.e. ../../etc) And changes the ownership of /optical to the user. - Then it disables the ejection button on drive to prevent someone from ejecting the mounted disk. - Then it uses a file /usr/local/etc/odlock_file to record who has the optical mounted and when they mounted it. odumount - Unmounts the optical from /optical, but only if it is invoked by the same user that mounted it or root. - Enables the ejection button so that you can take the disk out. - Clears the /usr/local/etc/odlock_file. I would be happy to send copies to anyone who wishes to try the code. We've been using it for about 3 months now and have only found one real problem (discribed later). Infact my SE has requested a copy and I just sent it to him, so I still have a shar file all ready for mailing. The one problem is that the odmount program tries to mount the disk read-write, and it really hoses the drive (i.e. reboot) when you try to mount a disk that is write protected. But I'm sure if enough people get there hands on the code someone will figure out the SCSI command (if it exists) to check the disk first, then mount it apropriately. If your interested send me mail: curt@oce.orst.edu, if I get a flood of requests check this group I might post it here or get an anonymous ftp area set up for it. Also, I'm leaving town until March 2nd so only send me one message until then :-) Thanks Curt
rclark@speclab.bgp-usgs.gov (Roger N. Clark) (02/27/90)
> We just installed the r/w optical disk on our HP9000/300 running HP-UX6.5. > We want each user to be able to have a mount point in their home directory > and mount/umount the optical disk. > Is there any way to mount/umount file system without being a superuser. We have an optical disk and have the same problem. Below is a simple mount and unmount program. They get installed as set UID root. On our system, the optical disk is /i2 and the users can only mount and unmount /i2, but you can change /i2 to anything you want. If a user is using a disk, another user can't unmount it as long as a process has a directory on /i2 as a working directory. There is no manual, but the c programs are 2 lines long and should be obvious. Root should run the make. <add standard disclaimer here> Roger Clark ..!speclab!rclark #---------------------------------- cut here ---------------------------------- # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by Roger N. Clark <rclark@speclab> on Mon Feb 26 10:48:52 1990 # # This archive contains: # makefile mounti2.c umounti2.c # # Existing files will not be overwritten. # Error checking via wc(1) will be performed. # Error checking via sum(1) will be performed. unset LANG if sum -r </dev/null >/dev/null 2>&1 then sumopt='-r' else sumopt='' fi if test -f makefile then echo Ok to overwrite existing file makefile\? read answer case "$answer" in [yY]*) echo Proceeding;; *) echo Aborting; exit 1;; esac rm -f makefile if test -f makefile then echo Error: could not remove makefile, aborting exit 1 fi fi echo x - makefile cat >makefile <<'@EOF' all: /usr/bin/mounti2 /usr/bin/umounti2 /usr/bin/mounti2: mounti2.c cc -o mounti2 mounti2.c mv mounti2 /usr/bin/mounti2 chmod 4555 /usr/bin/mounti2 /usr/bin/umounti2: umounti2.c cc -o umounti2 umounti2.c mv umounti2 /usr/bin/umounti2 chmod 4555 /usr/bin/umounti2 @EOF set `sum $sumopt <makefile`; if test $1 -ne 10738 then echo ERROR: makefile checksum is $1 should be 10738 fi set `wc -lwc <makefile` if test $1$2$3 != 1127271 then echo ERROR: wc results of makefile are $* should be 11 27 271 fi chmod 644 makefile if test -f mounti2.c then echo Ok to overwrite existing file mounti2.c\? read answer case "$answer" in [yY]*) echo Proceeding;; *) echo Aborting; exit 1;; esac rm -f mounti2.c if test -f mounti2.c then echo Error: could not remove mounti2.c, aborting exit 1 fi fi echo x - mounti2.c cat >mounti2.c <<'@EOF' main() { system ("/etc/mount /dev/dsk/c6d0s2 /i2"); system ("/bin/chmod 775 /i2"); } @EOF set `sum $sumopt <mounti2.c`; if test $1 -ne 25919 then echo ERROR: mounti2.c checksum is $1 should be 25919 fi set `wc -lwc <mounti2.c` if test $1$2$3 != 51187 then echo ERROR: wc results of mounti2.c are $* should be 5 11 87 fi chmod 644 mounti2.c if test -f umounti2.c then echo Ok to overwrite existing file umounti2.c\? read answer case "$answer" in [yY]*) echo Proceeding;; *) echo Aborting; exit 1;; esac rm -f umounti2.c if test -f umounti2.c then echo Error: could not remove umounti2.c, aborting exit 1 fi fi echo x - umounti2.c cat >umounti2.c <<'@EOF' main() { system ("/etc/umount /i2"); system ("/bin/chmod 000 /i2"); } @EOF set `sum $sumopt <umounti2.c`; if test $1 -ne 43000 then echo ERROR: umounti2.c checksum is $1 should be 43000 fi set `wc -lwc <umounti2.c` if test $1$2$3 != 51072 then echo ERROR: wc results of umounti2.c are $* should be 5 10 72 fi chmod 644 umounti2.c exit 0
davidb@Pacer.UUCP (David Barts) (03/06/90)
In article <210045@speclab.bgp-usgs.gov>, rclark@speclab.bgp-usgs.gov (Roger N. Clar> [edited] > main() > { > system ("/etc/mount /dev/dsk/c6d0s2 /i2"); > system ("/bin/chmod 755 /i2"); > } Why not do something like: mount("/dev/dsk/c6d0s2", "/i2", 0); chmod("/i2", 0755); ...and avoid four unnecessary fork(2) calls? -- David Barts Pacer Corporation davidb@pacer.uucp ...!uunet!pilchuck!pacer!davidb
rdg@hpfcmgw.HP.COM (Rob Gardner) (03/07/90)
> > system ("/etc/mount /dev/dsk/c6d0s2 /i2"); > > system ("/bin/chmod 755 /i2"); > Why not do something like: > > mount("/dev/dsk/c6d0s2", "/i2", 0); > chmod("/i2", 0755); > > ...and avoid four unnecessary fork(2) calls? The mount command checks to make sure the file system is clean, and also makes entries in /etc/mnttab. The mount intrinsic does neither. These things are important, you know? The chmod command could be avoided easily, of course. Rob