| 1 |
jonen |
1.1 |
################################################## |
| 2 |
jonen |
1.3 |
# $Id: mini-howto_trashcan-under-Linux_libtrash.pod,v 1.2 2003/01/25 09:06:51 jonen Exp $ |
| 3 |
jonen |
1.1 |
# |
| 4 |
|
|
################################################## |
| 5 |
|
|
# |
| 6 |
jonen |
1.2 |
# $Log: mini-howto_trashcan-under-Linux_libtrash.pod,v $ |
| 7 |
jonen |
1.3 |
# Revision 1.2 2003/01/25 09:06:51 jonen |
| 8 |
|
|
# + minor changes |
| 9 |
|
|
# |
| 10 |
jonen |
1.2 |
# Revision 1.1 2003/01/25 08:43:21 jonen |
| 11 |
|
|
# + moved/convert to perlpod format |
| 12 |
|
|
# |
| 13 |
jonen |
1.1 |
# |
| 14 |
|
|
# |
| 15 |
|
|
################################################## |
| 16 |
|
|
|
| 17 |
|
|
=pod |
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
|
|
=head2 Implements a "trash can" under GNU/Linux with 'libtrash' |
| 21 |
|
|
|
| 22 |
jonen |
1.3 |
Sebastian Utz S<seut@tunemedia.de> |
| 23 |
|
|
|
| 24 |
|
|
|
| 25 |
|
|
B<last changes> |
| 26 |
|
|
|
| 27 |
|
|
Revision 1.2 2003/01/25 09:06:51 jonen |
| 28 |
|
|
+ updated |
| 29 |
|
|
|
| 30 |
|
|
|
| 31 |
jonen |
1.1 |
|
| 32 |
|
|
=head3 Description |
| 33 |
|
|
|
| 34 |
jonen |
1.3 |
All stuff here is mainly copied from the libtrash doc. |
| 35 |
jonen |
1.1 |
|
| 36 |
|
|
libtrash is a shared library which, when preloaded, implements a trash can under GNU/Linux. |
| 37 |
|
|
This way, your mistakes (at least those of the "rm -rf dir /" class :-)) will no longer cause |
| 38 |
|
|
the loss of a week's work or your system's binaries. |
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
=head4 install libtrash |
| 42 |
|
|
|
| 43 |
|
|
apt-get install libtrash |
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
|
or for those of you that aren't running Debian GNU/Linux: |
| 47 |
|
|
|
| 48 |
|
|
wget http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz |
| 49 |
|
|
tar xzf libtrash-latest.tgz |
| 50 |
|
|
cd libtrash-1.7/ |
| 51 |
|
|
|
| 52 |
|
|
edit Makefile for common settings |
| 53 |
|
|
|
| 54 |
|
|
make install (as root) |
| 55 |
|
|
|
| 56 |
|
|
|
| 57 |
|
|
=head4 test |
| 58 |
|
|
|
| 59 |
|
|
export LD_PRELOAD=/usr/lib/libtrash/libtrash.so |
| 60 |
|
|
rm -r <some_test_file> |
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
=head4 enable libtrash at login |
| 64 |
|
|
|
| 65 |
|
|
Include this in your ~/.bash_profile(or for system-wide usage in /etc/profile) |
| 66 |
|
|
to enable libtrash every time you log in (or otherwise start a login shell) |
| 67 |
|
|
|
| 68 |
|
|
#-------------- snip --------------------------- |
| 69 |
|
|
LIBTRASH=/usr/lib/libtrash/libtrash.so |
| 70 |
|
|
|
| 71 |
|
|
LIBTRASH_dest=$LIBTRASH |
| 72 |
|
|
if test -L $LIBTRASH ; then |
| 73 |
|
|
LIBTRASH_dest="$(dirname $LIBTRASH)/$(ls -l "$LIBTRASH" | \ |
| 74 |
|
|
sed -e 's/^.\+ -> //')" |
| 75 |
|
|
fi |
| 76 |
|
|
|
| 77 |
|
|
if test x${LD_PRELOAD+set} = x -a -f "$LIBTRASH_dest" ; then |
| 78 |
|
|
LD_PRELOAD="$LIBTRASH" |
| 79 |
|
|
export LD_PRELOAD |
| 80 |
|
|
if test x$0 = x-bash ; then |
| 81 |
|
|
exec bash ${1+"$@"} |
| 82 |
|
|
else |
| 83 |
|
|
exec $0 ${1+"$@"} |
| 84 |
|
|
fi |
| 85 |
|
|
fi |
| 86 |
|
|
#-------------- end snip --------------------------- |
| 87 |
|
|
|
| 88 |
|
|
|
| 89 |
|
|
|
| 90 |
|
|
=head4 create user specify config |
| 91 |
|
|
|
| 92 |
|
|
- READ /etc/libtrash.conf !! |
| 93 |
|
|
- overwrite default values by setting up a ~/.libtrash for each user: |
| 94 |
|
|
|
| 95 |
|
|
# sample ~/.libtrash: |
| 96 |
|
|
#-------------- snip --------------------------- |
| 97 |
|
|
GLOBAL_PROTECTION = YES |
| 98 |
|
|
INTERCEPT_FOPEN = YES |
| 99 |
|
|
INTERCEPT_FREOPEN = YES |
| 100 |
|
|
INTERCEPT_OPEN = YES |
| 101 |
|
|
IGNORE_HIDDEN = NO |
| 102 |
|
|
IGNORE_EXTENSIONS= o;exe |
| 103 |
|
|
#-------------- end snip --------------------------- |
| 104 |
|
|
|
| 105 |
|
|
|
| 106 |
|
|
|
| 107 |
|
|
=head4 use 'cleanTrash' for cleaning Trash via cronjob |
| 108 |
|
|
|
| 109 |
|
|
- gunzip & copy '/usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz' |
| 110 |
|
|
to '/usr/local/bin/cleanTrash' e.g: |
| 111 |
|
|
|
| 112 |
|
|
'zcat /usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz > /usr/local/bin/cleanTrash' |
| 113 |
|
|
|
| 114 |
|
|
|
| 115 |
|
|
- edit '/usr/local/bin/cleanTrash' for local configuration |
| 116 |
|
|
|
| 117 |
|
|
|
| 118 |
|
|
|
| 119 |
|
|
=head5 insert cronjob for root |
| 120 |
|
|
|
| 121 |
|
|
- crontab -e (as root) |
| 122 |
|
|
- insert: 3,13,23,33,43,53 * * * * root /usr/local/bin/cleanTrash |
| 123 |
|
|
|
| 124 |
|
|
|
| 125 |
|
|
|
| 126 |
|
|
=head3 Important Notes |
| 127 |
|
|
|
| 128 |
|
|
|
| 129 |
|
|
=over |
| 130 |
|
|
|
| 131 |
|
|
=item Gerneral |
| 132 |
|
|
|
| 133 |
|
|
READ /etc/libtrash.conf !! |
| 134 |
|
|
If libtrash.so is global enabled via /etc/profile, a DEFAULT or WRONG ~/.libtrash configuration would |
| 135 |
|
|
causes gdm, root writes(if root writes are also protected by lintrash), kde etc. stops working !! |
| 136 |
|
|
|
| 137 |
|
|
solution to disable libtrash in enviroment immediately: |
| 138 |
|
|
- export LD_PRELOAD="" |
| 139 |
|
|
|
| 140 |
|
|
|
| 141 |
|
|
|
| 142 |
|
|
=item XTerm |
| 143 |
|
|
|
| 144 |
jonen |
1.2 |
to get a login shell, start XTerm with '-ls' (~/.profile will not be executed if not) |
| 145 |
jonen |
1.1 |
|
| 146 |
|
|
|
| 147 |
|
|
=back |
| 148 |
|
|
|
| 149 |
|
|
|
| 150 |
|
|
=head3 Resources |
| 151 |
|
|
|
| 152 |
|
|
=over |
| 153 |
|
|
|
| 154 |
|
|
=item Libtrash - Implements a "trash can" under GNU/Linux |
| 155 |
|
|
|
| 156 |
|
|
http://www.m-arriaga.net/software/libtrash/ |
| 157 |
|
|
|
| 158 |
|
|
=back |
| 159 |
|
|
|
| 160 |
|
|
|
| 161 |
|
|
|
| 162 |
|
|
=cut |
| 163 |
|
|
|