1 |
jonen |
1.1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
2 |
|
|
<html xmlns="http://www.w3.org/1999/xhtml"> |
3 |
|
|
<head> |
4 |
|
|
<title>trashcan under GNU/Linux with 'libtrash' mini-HowTo</title> |
5 |
jonen |
1.3 |
<link rel="stylesheet" href="http://netfrag.org/horde/css.php?app=chora" type="text/css" /> |
6 |
jonen |
1.1 |
<link rev="made" href="mailto:root@localhost" /> |
7 |
|
|
</head> |
8 |
|
|
|
9 |
jonen |
1.3 |
<body> |
10 |
|
|
<table border="0" width="100%" cellspacing="0" cellpadding="3"> |
11 |
|
|
<tr><td class="block" valign="middle"> |
12 |
|
|
<big><strong><span class="block"> trashcan under GNU/Linux with 'libtrash' mini-HowTo</span></strong></big> |
13 |
|
|
</td></tr> |
14 |
|
|
</table> |
15 |
jonen |
1.1 |
|
16 |
|
|
<p><a name="__index__"></a></p> |
17 |
|
|
<!-- INDEX BEGIN --> |
18 |
|
|
|
19 |
|
|
<ul> |
20 |
|
|
|
21 |
|
|
<ul> |
22 |
|
|
|
23 |
|
|
<li><a href="#implements_a_trash_can_under_gnu/linux_with_'libtrash'">Implements a ``trash can'' under GNU/Linux with 'libtrash'</a></li> |
24 |
|
|
<ul> |
25 |
|
|
|
26 |
|
|
<li><a href="#description">Description</a></li> |
27 |
|
|
<ul> |
28 |
|
|
|
29 |
|
|
<li><a href="#install_libtrash">install libtrash</a></li> |
30 |
|
|
<li><a href="#test">test</a></li> |
31 |
|
|
<li><a href="#enable_libtrash_at_login">enable libtrash at login</a></li> |
32 |
|
|
<li><a href="#create_user_specify_config">create user specify config</a></li> |
33 |
|
|
<li><a href="#use_'cleantrash'_for_cleaning_trash_via_cronjob">use 'cleanTrash' for cleaning Trash via cronjob</a></li> |
34 |
|
|
<ul> |
35 |
|
|
|
36 |
|
|
<li><a href="#insert_cronjob_for_root">insert cronjob for root</a></li> |
37 |
|
|
</ul> |
38 |
|
|
|
39 |
|
|
</ul> |
40 |
|
|
|
41 |
|
|
<li><a href="#important_notes">Important Notes</a></li> |
42 |
|
|
<li><a href="#resources">Resources</a></li> |
43 |
|
|
</ul> |
44 |
|
|
|
45 |
|
|
</ul> |
46 |
|
|
|
47 |
|
|
</ul> |
48 |
|
|
<!-- INDEX END --> |
49 |
|
|
|
50 |
|
|
<hr /> |
51 |
|
|
<p> |
52 |
|
|
</p> |
53 |
|
|
<h2><a name="implements_a_trash_can_under_gnu/linux_with_'libtrash'">Implements a ``trash can'' under GNU/Linux with 'libtrash'</a></h2> |
54 |
jonen |
1.3 |
<p>Sebastian Utz <a href="mailto:seut@tunemedia.de">seut@tunemedia.de</a></p> |
55 |
|
|
<p><strong>last changes</strong></p> |
56 |
|
|
<pre> |
57 |
|
|
Revision 1.2 2003/01/25 09:06:51 jonen |
58 |
|
|
+ updated</pre> |
59 |
jonen |
1.1 |
<p> |
60 |
|
|
</p> |
61 |
|
|
<h3><a name="description">Description</a></h3> |
62 |
jonen |
1.3 |
<p>All stuff here is mainly copied from the libtrash doc.</p> |
63 |
jonen |
1.1 |
<pre> |
64 |
|
|
libtrash is a shared library which, when preloaded, implements a trash can under GNU/Linux. |
65 |
|
|
This way, your mistakes (at least those of the "rm -rf dir /" class :-)) will no longer cause |
66 |
|
|
the loss of a week's work or your system's binaries.</pre> |
67 |
|
|
<p> |
68 |
|
|
</p> |
69 |
|
|
<h4><a name="install_libtrash">install libtrash</a></h4> |
70 |
|
|
<pre> |
71 |
|
|
apt-get install libtrash</pre> |
72 |
|
|
<pre> |
73 |
|
|
or for those of you that aren't running Debian GNU/Linux: |
74 |
|
|
|
75 |
|
|
wget <a href="http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz">http://www.m-arriaga.net/software/libtrash/libtrash-latest.tgz</a> |
76 |
|
|
tar xzf libtrash-latest.tgz |
77 |
|
|
cd libtrash-1.7/ |
78 |
|
|
|
79 |
|
|
edit Makefile for common settings |
80 |
|
|
|
81 |
|
|
make install (as root)</pre> |
82 |
|
|
<p> |
83 |
|
|
</p> |
84 |
|
|
<h4><a name="test">test</a></h4> |
85 |
|
|
<pre> |
86 |
|
|
export LD_PRELOAD=/usr/lib/libtrash/libtrash.so |
87 |
|
|
rm -r <some_test_file></pre> |
88 |
|
|
<p> |
89 |
|
|
</p> |
90 |
|
|
<h4><a name="enable_libtrash_at_login">enable libtrash at login</a></h4> |
91 |
|
|
<pre> |
92 |
|
|
Include this in your ~/.bash_profile(or for system-wide usage in /etc/profile) |
93 |
|
|
to enable libtrash every time you log in (or otherwise start a login shell)</pre> |
94 |
|
|
<pre> |
95 |
|
|
#-------------- snip --------------------------- |
96 |
|
|
LIBTRASH=/usr/lib/libtrash/libtrash.so</pre> |
97 |
|
|
<pre> |
98 |
|
|
LIBTRASH_dest=$LIBTRASH |
99 |
|
|
if test -L $LIBTRASH ; then |
100 |
|
|
LIBTRASH_dest="$(dirname $LIBTRASH)/$(ls -l "$LIBTRASH" | \ |
101 |
|
|
sed -e 's/^.\+ -> //')" |
102 |
|
|
fi</pre> |
103 |
|
|
<pre> |
104 |
|
|
if test x${LD_PRELOAD+set} = x -a -f "$LIBTRASH_dest" ; then |
105 |
|
|
LD_PRELOAD="$LIBTRASH" |
106 |
|
|
export LD_PRELOAD |
107 |
|
|
if test x$0 = x-bash ; then |
108 |
|
|
exec bash ${1+"$@"} |
109 |
|
|
else |
110 |
|
|
exec $0 ${1+"$@"} |
111 |
|
|
fi |
112 |
|
|
fi |
113 |
|
|
#-------------- end snip ---------------------------</pre> |
114 |
|
|
<p> |
115 |
|
|
</p> |
116 |
|
|
<h4><a name="create_user_specify_config">create user specify config</a></h4> |
117 |
|
|
<pre> |
118 |
|
|
- READ /etc/libtrash.conf !! |
119 |
|
|
- overwrite default values by setting up a ~/.libtrash for each user:</pre> |
120 |
|
|
<pre> |
121 |
|
|
# sample ~/.libtrash: |
122 |
|
|
#-------------- snip --------------------------- |
123 |
|
|
GLOBAL_PROTECTION = YES |
124 |
|
|
INTERCEPT_FOPEN = YES |
125 |
|
|
INTERCEPT_FREOPEN = YES |
126 |
|
|
INTERCEPT_OPEN = YES |
127 |
|
|
IGNORE_HIDDEN = NO |
128 |
|
|
IGNORE_EXTENSIONS= o;exe |
129 |
|
|
#-------------- end snip ---------------------------</pre> |
130 |
|
|
<p> |
131 |
|
|
</p> |
132 |
|
|
<h4><a name="use_'cleantrash'_for_cleaning_trash_via_cronjob">use 'cleanTrash' for cleaning Trash via cronjob</a></h4> |
133 |
|
|
<pre> |
134 |
|
|
- gunzip & copy '/usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz' |
135 |
|
|
to '/usr/local/bin/cleanTrash' e.g: |
136 |
|
|
|
137 |
|
|
'zcat /usr/share/doc/libtrash/examples/cleanTrash/ct2.pl.gz > /usr/local/bin/cleanTrash'</pre> |
138 |
|
|
<pre> |
139 |
|
|
- edit '/usr/local/bin/cleanTrash' for local configuration</pre> |
140 |
|
|
<p> |
141 |
|
|
</p> |
142 |
|
|
<h5><a name="insert_cronjob_for_root">insert cronjob for root</a></h5> |
143 |
|
|
<pre> |
144 |
|
|
- crontab -e (as root) |
145 |
|
|
- insert: 3,13,23,33,43,53 * * * * root /usr/local/bin/cleanTrash</pre> |
146 |
|
|
<p> |
147 |
|
|
</p> |
148 |
|
|
<h3><a name="important_notes">Important Notes</a></h3> |
149 |
|
|
<dl> |
150 |
|
|
<dt><strong><a name="item_gerneral">Gerneral</a></strong><br /> |
151 |
|
|
</dt> |
152 |
|
|
<dd> |
153 |
|
|
<pre> |
154 |
|
|
READ /etc/libtrash.conf !! |
155 |
|
|
If libtrash.so is global enabled via /etc/profile, a DEFAULT or WRONG ~/.libtrash configuration would |
156 |
|
|
causes gdm, root writes(if root writes are also protected by lintrash), kde etc. stops working !! |
157 |
|
|
|
158 |
|
|
solution to disable libtrash in enviroment immediately: |
159 |
|
|
- export LD_PRELOAD=""</pre> |
160 |
|
|
</dd> |
161 |
|
|
<dt><strong><a name="item_xterm">XTerm</a></strong><br /> |
162 |
|
|
</dt> |
163 |
|
|
<dd> |
164 |
|
|
<pre> |
165 |
jonen |
1.2 |
to get a login shell, start XTerm with '-ls' (~/.profile will not be executed if not)</pre> |
166 |
jonen |
1.1 |
</dd> |
167 |
|
|
</dl> |
168 |
|
|
<p> |
169 |
|
|
</p> |
170 |
|
|
<h3><a name="resources">Resources</a></h3> |
171 |
|
|
<dl> |
172 |
|
|
<dt><strong><a name="item_libtrash_%2d_implements_a_%22trash_can%22_under_gn">Libtrash - Implements a ``trash can'' under GNU/Linux</a></strong><br /> |
173 |
|
|
</dt> |
174 |
|
|
<dd> |
175 |
|
|
<pre> |
176 |
|
|
<a href="http://www.m-arriaga.net/software/libtrash/">http://www.m-arriaga.net/software/libtrash/</a></pre> |
177 |
|
|
</dd> |
178 |
|
|
</dl> |
179 |
jonen |
1.3 |
<p><a href="#__index__"><small>back to top</small></a></p> |
180 |
|
|
<table border="0" width="100%" cellspacing="0" cellpadding="3"> |
181 |
|
|
<tr><td class="block" valign="middle"> |
182 |
|
|
<big><strong><span class="block"> trashcan under GNU/Linux with 'libtrash' mini-HowTo</span></strong></big> |
183 |
|
|
</td></tr> |
184 |
|
|
</table> |
185 |
jonen |
1.1 |
|
186 |
|
|
</body> |
187 |
|
|
|
188 |
|
|
</html> |