[net.unix-wizards] VAX UNIX magtape lockout wanted

byrd (07/14/82)

As is well known, 4.1 bsd VAX UNIX does not protect magtapes by assigning
the tape drive to one user and locking out others.  As a result I get very
nervous when I mount my "tar" tape, ring in so I can update it.  Does anyone
have a solution to this?  We have a 45 ips Pertec drive, if it matters.

thomas (07/15/82)

At the risk of being 1 in 1000 replies, here goes.  Have your system
hack write a quicky suid root program which chown's the tape unit (all
of them) to you and sets the mode to 600, and another which chowns it
back to root and mode 666.  If the mode is already 600, the first should
at least ask if you are sure (at which point, you should say 'no' and
do a 'who' to see if the other person is still logged in).  Obviously
this requires a little cooperation, but protects you from random,
non-malicious use.

=Spencer Thomas

Program outline for assign:

main(argc, argv)
{
	/* Parse argument line */
	/* Make sure the name begins "/dev/mt" or "/dev/rmt" */
	/* Stat the dev. */
	/* If mode = 666 or owner = getuid(), proceed */
	/* Else, print message "Tape drive %s already in use by %s */
		/* Fork a who to show user who is on */
		/* ask "Are you sure?" */
		/* Abort if answer not "y" */
		/* (Alternatively, scan utmp to see if the user owning the */
		/* tape drive is logged on.  This can fail if people share */
		/* uids (as can the first method).) */
	/* For each tape unit in n+0, n+4, n+8, n+12 and for both mt and rmt */
		chown(tape, getuid(), getgid());
		chmod(tape, 0600);
}

Outline for deassign:

main(argc, argv)
{
	/* Parse argv */
	/* Make sure the requested dev is "/dev/mt*" or "/dev/rmt*" */
	/* Make sure mode is 600 and owner = getuid() or getuid() = 0 */
	/* For each tape unit in n+0, n+4, n+8, n+12, for mt and rmt */
		chown (tape, 0, 0);
		chmod (tape, 0666);
}

essick (07/15/82)

#R:iuvax:-17700:uiucdcs:13700004:000:888
uiucdcs!essick    Jul 15 10:42:00 1982

	I would imagine that implementing a utility to manage
assigning tape drives would be reasonably simple.
	In the simplest case, where anyone can use any device
(nice idealistic system), two programs would need to be written.

	assign	"device"

would merely change the ownership and protection bits on the
"device". So "assign /dev/rmt0" would assign the tape drive
to me. A similar program called "release" would set things back
to normal.
	One can build all sorts of checks into the program to
ensure that the user is allowed to use the device, that all
references to a device are caught (as in rmt0 and mt0). It would
also be a good idea to have the release program make sure that the
user owns the device before setting the permissions back. One can 
also add time-outs and all sorts of other bells and whistles.

	Ray Essick	University of Illinois at Urbana-Champaign
	uiucdcs!essick