SafeDelete 1.3b
---------------

SafeDelete is a set of commands which are meant to safely delete files
and allow them to be undeleted.  It is intended to be a shell enhancement
to the /bin/rm command.

COMMANDS:

safedelete - The main program which, when invoked, makes a compressed copy
             of the file(s) specified on the command line and places them 
             in a preselected directory under a program-generated file
             name.  It then updates a log file to keep track of the original
             file name as well as the generated file name.

             Only regular files and symbolic links are processed by safedelete.
             Special files, etc are ignored.  Hard links are processed like 
             regular files.

undelete   - This command undeletes files by scanning the log, created by
             the safedelete command, for the file name specified on the 
             command line.  Once found,  the file is restored by decompressing
             the program-generated file name then copying it back to its 
             original location (along with the original permissions, dates,
             etc).

             A file name on the command line is optional, if none is specified
             a full-screen scrollable list is displayed (using curses) 
             allowing the user to select which file(s) to undelete.

	     *** Strangely, the curses stuff works best on an xterm terminal.
	     *** Ascii terminals such as vt100 and vt220 show a lot of
	     *** garbage where the xterm shows box lines around the windows. 
	     *** At this point I'd recommend using either undeltk (if
	     *** you have X configured and Tcl/Tk installed) or undelsh
	     *** (which runs under /bin/bash or /bin/ksh) instead of
	     *** the curses stuff.
	     *** Both undeltk and undelsh provide the same functionality
	     *** as the curses application as well as a few more bells and
	     *** whistles.  Read the man pages for undeltk and undelsh
	     *** for additional details.

undeltk    - A Tcl/Tk script which does essentially the same thing as
             the undelete command, except with a nicer interface.

	     It allows you to undelete, remove, and obtain information
	     about files either one at a time, all at the same time,
	     or with multiple selections.  You can also specify a search
	     pattern (it looks somewhat like a regular expression)
	     so that only those files matching the pattern are listed.

undelsh    - A shell script which does essentially the same thing as
             the undelete command, except without the color.

	     It allows you to undelete, remove, and obtain information
	     about files either one at a time, all at the same time,
	     or with multiple selections.  You can also specify a search
	     pattern (this a regular expression passed to the egrep command)
	     so that only those files matching the pattern are listed.

safedelchk - Scans the directory containing the users safedeleted files and
             deletes those that are older than a preset maximum number of
             days.  The users log file is also updated to reflect which files
             can still be undeleted.

safecnvt   - Converts a users .safedelete.log from other formats to the format 
             required by release 1.3.  It also copies the files that they
             currently have safedeleted from the directory used by release 1.0
             to the new directory used in release 1.3.  

	     If you are using releases 1.1 or 1.2 the files are already in
	     the proper location and are not moved.

There are also a complete set of man pages describing the options for each of
these commands.



FILES:

.safedelete.log - Each user has one in their $HOME directory.  It is basically
             a cross-reference between the original file names and their 
             generated file names.  It also contains the original inode
             information for each file.

.safedelete.lock - this file is created dynamically to control access to the
             .safedelete.log.  Each program first tries to acquire the lock
             before performing any processing.  The lockbusy option in the
             .Safedelrc file describes what action should be taken if the lock
             cannot be acquired.

.Safedelrc - This is an optional file which the user can place in their $HOME
             directory.  It contains detail on items used by the SafeDelete
             commands.

             There are three sections in the .Safedelrc file.  Each section
             begins with a header label and ends with a trailer label.  The
             sections are:

             [safedays] -- contains filename patterns and the number of days
                           files matching the pattern should be kept.  The 
                           pattern must begin in column 1 and at least one
                           blank must separate the pattern from the number 
                           of days.  Multiple patterns can be specified on the
                           same line and must be separated by commas.  The 
                           pattern can contain at most 1 asterisk (for a 
                           wildcard character) or can be a complete filename.
                           Files not matching any of the patterns will use
                           the $SAFEDAYS variable to determine when the 
                           safedeleted file should be purged.  Specifying 0
                           for the number of days prevents files matching
                           the pattern from being safedeleted.

                           Syntax: <pattern>[,pattern][,...] <no. of days>

                           Example:

                           [safedays]
                           core,/tmp/* 0
                           *.c 7
                           test*.o 1
                           [endsection]

                           In the example, all core files and all files in the
                           /tmp directory will not be safedeleted.  All files
                           ending in .c will be safedeleted for 7 days and
                           files beginning with test and ending with .o will be
                           safedeleted for 1 day.


             [compression] -- contains filename patterns and the compression
                           commands to be used for each.  The special keyword 
                           "none" is recognized for files that should not be
                           compressed.  Both the compression and decompression 
                           commands must be specified for each pattern.  The 
                           commands must be separated by a forward slash "/".
                           Up to 40 characters can be used for each command.

                           The pattern must begin in column 1 with at least one
                           blank separating the pattern from the commands.

                           Syntax: <pattern>[,pattern][,...]
                                        <compress>/<decompress>

                           Example:

                           [compression]
                           *.gz,*.tgz,*.Z none
                           *.c gzip -9/gunzip
                           test* compress/uncompress
                           [endsection]

                           In the example, all files ending with .gz, .tgz and
                           .Z should not be compressed while those ending with
                           .c should be compressed with the gzip command and
                           decompressed with gunzip.  All files starting with
                           test should be compressed with compress and 
                           decompressed with uncompress.


             [suffix] ---- contains compression commands followed by the suffix
                           each adds to the filename.  Multiple commands,
                           separated by commas, can be entered on one
                           line and at least one blank must separate the 
                           commands from the suffix.

                           Each suffix can be at most 8 characters long (a dot
                           followed by up to 7 characters).

                           Syntax: <command>[,command][,...] <.suffix>

                           Example:

                           [suffix]
                           gzip .gz
                           compress .Z
                           [endsection]

                           In the example, the gzip command adds the .gz suffix
                           while the compress command adds the .Z suffix.

             [options] --- contains various options that affect the behavior
                           of the commands.

                           Syntax:

                           lockbusy <action> - what to do if the lock file is
                                               already in use.

                           where <action> is one of the following:

                               wait - wait until the lock file becomes available.
                                      a message is issued every 5 seconds indicating
                                      that the lock file is still busy.

                               prompt - issue a propmt every 5 seconds asking if the
                                      command should continue waiting for the lock
                                      file.  This is the default action.

                               quit - don't wait for the lock file, just terminate.

                            Example:
 
                            [options]
                            lockbusy wait
                            [endsection]

             See the safedelrc(5) man page on for complete details.



PROBLEM REPORTING:

If you encounter any bugs or have any questions or comments I can be reached at
renicke@attglobal.net


MY SYSTEM CONFIGURATION:

This package was built and tested on a RedHat 6.2 system
with the following configuration:

   Linux kernel 2.2.16-3
   egcs 1.1.2-30 (gcc complier)
   libc 5.3.12-31
   glibc 2.1.3-15
   ncurses 5.0-11
   tcl 8.0.5-35
   tk 8.0.5-35


LICENSING:

This product is licensed under the "Artistic License".  See the file LICENSE
for details.


UPDATES SINCE RELEASE 1.3a:

- use 4 digit year 
- time stamp added to "Last access/modified" on "undelete -i"
- fixed logic and coding errors in safedelchk command
- added -v option to safedelchk command (for verbose output)
- fixed logic and coding errors in undelete command
- added Tcl/Tk script "undeltk"
- added sdquery and udtkfmt commands for use by undeltk
- added -g option to undelete command for use by undeltk
- updated safedelchk man page to describe new "-v" flag

*** Special thanks goes to Alexandar Howard at the University of Washington for
*** the porting of the locking code to SunOS 5.8.  Thank you!!!!



================================================================================
You only need to read the following if you are really interested in how it works
================================================================================

This utility is patterned after the SmartCan utility from Symantec Corp.  When 
a file is deleted by the user a compressed copy of it is placed in a preselected
directory under a generated file name and removed from its original location.
Each user has a log file which keeps track of each file they have deleted and
cross-references them to the generated file names.  The log file name is 
.safedelete.log and is kept in the users home directory.  

To prevent the filesystem from filling up with user-deleted files the safedelchk 
command scans the users .safedelete.log and safedelete directory removing all
files older than a set number of days (see the MAXDAYS variable in the
Makefile).  The user's .safedelete.log is updated to reflect any files removed
from their safedelete directory.  Safedelchk also scans for inconsistencies
between the .safedelete.log and the directory reporting to the user any that
are found.

To allow some flexibility for the users a variable called SAFEDAYS can be set
in either /etc/profile or the .bash_profile for each user.  This variable is
used by both the safedelete and the safedelchk programs.  When safedelete starts
processing it checks to see if the variable is defined.  If $SAFEDAYS is not 
defined, or is defined and is non-zero, the files specified on the command line
are safedeleted as described above.  If $SAFEDAYS is defined and has a value of
zero, safedelete just invokes the /bin/rm command to remove the files, thus
turning off the safedelete function.  This can be handy if you know that the
files you'll be deleting will never be needed again.  Just set $SAFEDAYS to 0
and safedelete will ignore all requests to safely delete files.  Don't forget
to reset $SAFEDAYS to a non-zero value when you're done.

For more granularity at the filename level, each user can optionally have a
.Safedelrc file in their $HOME directory.  This file contains file names and
patterns which control the number of days a particular file should be kept
in the safedelete directory.  Any file name not matching a pattern in the 
.Safedelrc will be controlled by the $SAFEDAYS or the $MAXDAYS variable, 
whichever has the lower value.

Safedelchk is coded to run in two different modes, user mode and administrator
mode.  In user mode (i.e. invoked by the user) only those files in the user's
safedelete directory are scanned and removed.  In administrator mode 
(i.e. invoked by root) the files for all users are scanned and removed.
The reasoning for this way of doing things goes like this:

- safedelchk is really meant to be executed from either /etc/profile or from 
  each users .bash_profile.
- if executed from /etc/profile, no problem,  the users old safedeleted files
  will be removed to prevent a bunch of old files cluttering up the filesystem.
- if executed from the users .bash_profile the user has the option of never
  running safedelchk (they can just remove it from their .bash_profile).
- thus, setting a crontab entry from root to invoke safedelchk on a periodic
  basis enforces system policy for safedeleted files.  Invoking safedelchk as
  root defaults to running in administrator mode.  To run safedelchk in user
  mode as root you must use the -u option.

The undelete command undeletes the files that were previously removed with 
safedelete.  It has two modes, command and interactive.  In command mode, the
user specifies the name of the file on the command line (only one file at a
time, for now).  Undelete then scans the user's .safedelete.log looking for the
most recent occurence of that file (this allows multiple copies of the same file
to exist in the safedelete directory).  The file is then restored to its 
original location along with its original permissions and timestamps.  Some
safety checks are performed internally to make sure the file was successfully
undeleted.  Once the undelete process is verified the safedeleted copy of the 
file, and its corresponding log entry, are removed.

To enter interactive mode just issue the undelete command with no options.
This will display a scrollable list of files that the user currently has listed
in their .safedelete.log.  This display facility uses ncurses (the System V
curses, not the BSD curses).  This allows the user to pick and choose which
file(s) to undelete.  The actual undelete process is the same as for command
mode.
