[net.wanted] 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);
}