Undelete for Samba

Jay Thompson J.Thompson at NAU.EDU
Fri Oct 6 16:13:19 GMT 2000

At 12:19 PM 10/6/2000 +0100, you wrote:
>Cass Surek wrote:
> >
> > Hello guys,
> >
> > We´ve used Novell here and there was a cool thing about it that wouldn´t
> > really delete a file when a user deleted that file. It´d be stored in a
> > spool directory and then we´d be able to recover it in case it was deleted
> > by mistake by the user.
>Samba doesn't actually do the deletion, it just uses the system unlink()
>call. Unix, unlike Netware, takes the attitude that if you ask it to
>delete a file, that's because you don't want the file. It ain't coming
>back...... The filesystems on most Unices are such that your chances of
>recovering data from deleted files are virtually nil. Use a tape

Hey Ya'll, sorry about the blank reply a few minutes ago.

What I have to offer here about file-delete protection is not really a samba
thing (as far as I know, there is no good samba solution for this). But
some of your samba admins must have pure UNIX users. This is for them.

For a little protection for my users (all of whom I set up with the CShell), I
put some code into their .cshrc file to do what I call "safe_rm".

To be fair, I can't take full credit for the idea. I got the idea from my 
time at the
University of Tennessee when I was completing my MS degree. I think
a guy named David Mutchler came up with the original idea, but I've
made so many changes to it over time I don't know if he'd recognize it
in its current form.

That said (wishing to give Dave his due)...

1 - I put a script in the user's ~/bin directories called "safe_rm" (I have 
that script).

2 - I plant some code in their .cshrc file. That code is attached as 
Note: in this code, "rm" is aliased to the "safe_rm" script. I have also 
aliased "RM"
to the real /bin/rm for those who are absolutely sure that they want to 
blow something
away right now.

3 - I plant the following code in their .logout file.

if ( $SAFERM == on ) then
   if ( -d $SAFERMDIR ) then
     setenv SAFERM on
     echo " "
     echo removing files from $SAFERMDIR
     echo " "
     /usr/bin/rm -R $SAFERMDIR
     mkdir $SAFERMDIR
     chmod 700 $SAFERMDIR

This last piece clears the "safe_rm" deleted files for their
current session when they log out (I don't have the disk space to
protect them forever). But this could be altered to delete
based on date stamp (holding deleted files for a longer time),
or it could be ignored completely, never clearing the
deleted files (which, in my opinion, would not be a very good

-------------- next part --------------
A non-text attachment was scrubbed...
Name: safe_rm
Type: application/octet-stream
Size: 1167 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba/attachments/20001006/29921e33/safe_rm.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cshrc.safe_rm
Type: application/octet-stream
Size: 1434 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba/attachments/20001006/29921e33/cshrc.obj
-------------- next part --------------

Jay Thompson
Support Systems Analyst, Sr.
Northern Arizona University
College of Ecosystem Science and Management
J.Thompson at NAU.EDU
(520) 523-8033

More information about the samba mailing list