Trusted Solaris Administrator's Procedures

Using Device-Clean Scripts

A device-clean script is run any time a device is allocated or deallocated. The user who allocates the device usually deallocates it. If necessary, the Revoke button on the Device Allocation: Maintenance dialog box can be used by an authorized role to forcibly deallocate a device.

If your site adds additional allocatable devices to the system, the added devices may need new scripts. See the following descriptions of the existing device-clean scripts for ideas on how they work, and see also "Writing New Device-Clean Scripts".

Device-Clean Script for Tape Devices

The st_clean device-clean script is used for all tape devices.

The st_clean script uses the mt(1) command with the -rewoffl option to clean the device. When the script is run during system boot, it queries the device to see if it is on line and has any storage media in it. If necessary, the script prompts the operator to eject the storage media, and then it displays the appropriate label for the user to write on a physical label on the storage media.

Until deallocation completes, 1/4 inch tape devices are placed in the allocate error state, and 1/2 inch tape devices are taken off line. The allocate error state forces an authorized user to manually clean up the device before a user can allocate it again.

Device-Clean Scripts for Floppy Disks and CD-ROM

The disk_clean script is used for both floppy disk drives and CD-ROM devices. When the disk_clean script is run during boot time, any media found in a device is ejected. Whether it is run at boot time or when the device is deallocated, if the eject succeeds, the script prompts the user to affix to the media a physical label with the appropriate label. If the eject(1) command fails, the device is put in the allocate error state.

When a file system from either a floppy or CD is mounted as part of allocation, a File Manager pops up with the current directory set to the mount point. The Security Administrator role can prevent the automatic display of the File Manager by following the procedure in "To Prevent File Manager Display After Device Allocation". The mounting of file systems from floppy disks is handled differently from the mounting of file systems from CDs, as described in "Mounting an Allocated CD-ROM Device" and "Mounting an Allocated Floppy Device".

Device-Clean Script for Audio

The audiotool device is cleaned up using the audio_clean program.

This program performs an AUDIO_DRAIN ioctl to flush the device, and then an AUDIO_SETINFO ioctl to reset the device configuration to the default. In addition, this program retrieves the audio chip registers using the AUDIOGETREG ioctl, and any registers deviating from default are reset using AUDIOSETREG ioctl. Because the audio device does not contain any removable media, it does not require an external physical label, and therefore the label is not displayed by the audio_clean script.

Writing New Device-Clean Scripts

Devices that can be made allocatable include modems, terminals, and graphics tablets. The task of making any of these devices allocatable includes writing a new device-clean script. Device-clean scripts should also be created for any added tape devices, except for Xylogics or Archive tape drives, which can use the default device_clean(1M) script (/etc/security/lib/st_clean).

The default location for device-clean scripts is /etc/security/lib.

Device-clean scripts must return 0 for success and greater than 0 for failure.

Failure or inability to forcibly eject the medium must put the device in the allocate error state.

The deallocate(1) command passes four parameters to the device-clean scripts as shown here:


device_clean -[I|F|S] -[A|D] device_name label

The option letters -I|-F|-S help the script determine its running mode. -I is needed during system boot only. All output must go to the system console. -F is for forced clean up and -S is for standard cleanup. These are interactive and assume that the user is there to respond to prompts. With the -F option, the script must attempt to complete the cleanup if one part of the cleanup fails.

[-[A]-[D]] indicates whether the clean script is called from allocate(1) or deallocate.

The device_name field is a string with the name of the device.

The label field is a hexadecimal representation of the label.