carlton@cs.berkeley.edu (Mike Carlton) (01/22/91)
Can anyone tell me how to eject a floppy disk under software control? And how to tell when a new one has been inserted? Why do I want to do this? Well, I'd like to write a 'split' like program to write files larger than the size of a floppy to a series of disks (e.g. a compressed tar file of my home directory :-). The only way I can see is to use /usr/etc/disk and this is kludgey. It should be possible to write a suid script that does '/usr/etc/disk -e /dev/rfd0a'. Unfortunately, csh doesn't want to execute my script (csh: Permission denied) even after I made the owner root and did a chmod 4555 on the script. I imagine there's a simple fix I'm overlooking. Even so, using /usr/etc/disk has the problem that the Workspace doesn't get updated (it leaves the icon of the (no longer present) disk on the shelf). Clicking on the disk icon results in a panel asking for the disk back. Ideally, I'd guess that it should be possible to message the Workspace to eject the disk and to prompt for a new one. Unfortunately, I can't find any reference on this (I've looked in the 1.0 man pages and NextAnswers, I don't have the programmer's reference manuals). Any ideas? Thanks, Cheers, mike Mike Carlton carlton@cs.berkeley.edu
lacsap@media-lab.MEDIA.MIT.EDU (Pascal Chesnais) (01/22/91)
In article <10365@pasteur.Berkeley.EDU>, carlton@cs.berkeley.edu (Mike Carlton) writes: > Can anyone tell me how to eject a floppy disk under software control? > And how to tell when a new one has been inserted? > > Why do I want to do this? Well, I'd like to write a 'split' like > program to write files larger than the size of a floppy to a series > of disks (e.g. a compressed tar file of my home directory :-). > The first thing you may want to consider is that the floppy driver deals with floppy volumes and not floppy drives. That is to say I can do: /etc/mount /dev/fd0a /mnt_a it will ask me to put the diskette in for volume 0 /etc/mount /dev/fd1a /mnt_b it will eject the volume 0 diskette and then it will ask me for volume 1 then when I refer to /mnt_a/foo it will automatically eject volume 1 and ask me for the volume 0 diskette. So for your application I would split the big compresses tar file into files that would fit onto a diskette. You will want to have the diskettes initialized as a UNIX filesystem. The I would mount the filesystems I am interested in, copy the split file onto the right volume and then cleanly unmount and eject each of the volumes. now the thing you will have to remember is that you want to cleanly umount the floppy before using the disk command to eject the disk... the safest way to remove a floppy from the machine is to first try to drag the floppy into the recycler in the browser. If you want to backup a whole filesystem you probably want to use the dump(8) command, which you can tell how much a floppy can hold. The documentation is online, Librarian is your friend. Maybe someone will write an application to do this for people. pasc -- Pascal Chesnais, Research Specialist, Electronic Publishing Group Media Laboratory, E15-348, 20 Ames Street, Cambridge, Ma, 02139 (617) 253-0311 email: lacsap@plethora.media.mit.edu (NeXT)
carlton@aldebaran (Mike Carlton) (01/25/91)
In article <7887@umd5.umd.edu> matthews@lewhoosh.umd.edu (Mike Matthews) writes: +In article <10365@pasteur.Berkeley.EDU> carlton@cs.berkeley.edu (Mike Carlton) writes: ... +>The only way I can see is to use /usr/etc/disk and this is kludgey. It +>should be possible to write a suid script that does '/usr/etc/disk -e +>/dev/rfd0a'. Unfortunately, csh doesn't want to execute my script +>(csh: Permission denied) even after I made the owner root and did a +>chmod 4555 on the script. I imagine there's a simple fix I'm +>overlooking. + +You're also overlooking a real big security hole. REAL big. + ... +>Mike Carlton carlton@cs.berkeley.edu +------ +Mike Matthews, matthews@lewhoosh.umd.edu (NeXT)/matthews@umdd (bitnet) +------ +Backed up the system lately? +[these random quotes sure can hit the bullseye sometimes, eh? :-)] The fix to make suid scripts is to give them the -b option, i.e. begin the script with '#! /bin/csh -b'. Would you care to give a little more detail on the security hole? Obviously if someone obtains write access to a suid script you've got big problems. But if they can get access to a root owned, 4755 file, then you're already got problems because there are plenty of those on the disk already. Or is there something else to worry about? Mike Carlton carlton@cs.berkeley.edu
matthews@lewhoosh.umd.edu (Mike Matthews) (01/25/91)
In article <10415@pasteur.Berkeley.EDU> carlton@aldebaran.berkeley.edu (Mike Carlton) writes: >Would you care to give a little more detail on the security hole? >Obviously if someone obtains write access to a suid script you've >got big problems. But if they can get access to a root owned, 4755 >file, then you're already got problems because there are plenty of those >on the disk already. Or is there something else to worry about? I haven't tried this personally, heard it on comp.unix.admin I think. Try making a link to that suid script. Then run it with nice +64. After a second or two, recreate the link to whatever you want to do. It will have already gotten the suid bit, so whatever you relink to will run as root. That thing can be anything you wish, running as root... Come to think of it, that'll work for anything. Hmm. Maybe I'm mistaken. Can anyone verify this? >Mike Carlton carlton@cs.berkeley.edu ------ Mike Matthews, matthews@lewhoosh.umd.edu (NeXT)/matthews@umdd (bitnet) ------ "The Street finds its own uses for technology." -- William Gibson
amarcum@next.com (Alan M. Marcum) (01/26/91)
carlton@cs.berkeley.edu (Mike Carlton) in <10365@pasteur.Berkeley.EDU>:
> The only way I can see is to use /usr/etc/disk and this is kludgey.
One could write a small C program which includes a line similar to
ioctl(fd, DKIOCEJECT, 0);
after opening the appropriate device and assigning its file descriptor
to fd. DKIOCEJECT is defined in <nextdev/disk.h>.
--
Alan M. Marcum
NeXT Technical Support
amm@NeXT.COM