Useful CLI tools (bash) for Arch Linux administration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

3.6 KiB

* What is libetc ?

On my system I had way too much dotfiles:

% ls -d ~/.* | wc -l
421

For easier maintenance I wrote libetc. It is a LD_PRELOAD-able shared library
that intercepts file operations: if a program tries to open a dotfile in
$HOME, it is redirected to $XDG_CONFIG_HOME (as defined by freedesktop:
http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html).

You can then store all your config files in $XDG_CONFIG_HOME instead of using
zillions dotfiles in $HOME. If $XDG_CONFIG_HOME is not defined the dotfiles
are stored in $HOME/.config/

(for historical reasons you can also use $HOME/$ETC instead of $XDG_CONFIG_HOME)


* Install:

To use libetc you just need to do:

% make
% make install

On my computer I added the following lines to .xsession and .zshrc:

export XDG_CONFIG_HOME=/home/luc/config
export LD_PRELOAD=libetc.so.0
export LIBETC_BLACKLIST=/bin/ls:/bin/mv:/bin/cp:/bin/ln:/usr/bin/find:/bin/rm

And for xorg I use a small hack, I build libetc this way:
% CFLAGS=-DXAUTH_HACK make

It just adds some code which does this:
% ln -s $HOME/.Xauthority $XDG_CONFIG_HOME/Xauthority

You can also use /etc/ld.so.preload to use libetc with each user on your system
but it is a little bit dangerous (if you misstype the path to the library, or if
the library is buggy, you will need to use your rescue disk to restore
/etc/ld.so.preload)
Nb: if you misstype the path, you may just get the following warning:
ERROR: ld.so: object 'libetc.so.0' from LD_PRELOAD cannot be preloaded: ignored.

If you want to use a setuid binary (gnupg for example), you should read ld.so(8):
"For setuid/setgid ELF binaries, only libraries in the standard search
directories that are also setgid will be loaded."

I found that setgid is not enough, it works when the library is setuid. I read
on the net that the library has to be setuid+setguid to be loaded, so the "make
install" target does it.

And now I just have 8 dotfiles :

% ls -l ~/.*
-rw------- 1 luc luc 4065 2006-12-03 23:09 /home/luc/.fetchmailrc
lrwxrwxrwx 1 luc luc 17 2008-01-12 22:48 /home/luc/.procmailrc -> config/procmailrc
lrwxrwxrwx 1 luc luc 19 2008-01-12 22:45 /home/luc/.spamassassin -> config/spamassassin
-rw------- 1 luc luc 215 2008-01-26 11:14 /home/luc/.Xauthority
lrwxrwxrwx 1 luc luc 17 2008-01-23 19:46 /home/luc/.Xresources -> config/Xresources
lrwxrwxrwx 1 luc luc 15 2008-01-12 22:48 /home/luc/.xsession -> config/xsession
-rw------- 1 luc luc 85632 2008-01-27 21:10 /home/luc/.xsession-errors
lrwxrwxrwx 1 luc luc 12 2008-01-12 22:46 /home/luc/.zshrc -> config/zshrc

I start fetchmail (and procmail & spamassassin) from cron, so I need a
.fetchmailrc file (and fetchmail doesn't like symlinks).

.Xauthority and .xsession-errors are created by xorg (I use xdm)
.xsession and .Xauthority are needed by xorg.
.zshrc is needed by zsh (when I login on a console or by ssh).

On a Debian system some progams started from /etc/X11/Xsession.d might need
some dotfiles.

* License: GNU GPLv3 !

see the COPYING file.


* libetc should work with:

- openoffice
- kde
- gnome
- firefox
- mutt
- vim
- thunderbird
- sylpheed
- gimp
...


* Known bugs:

- libetc will do nothing on static programs (some non-free software for example)
A kernel module could work... but it's too much work for something not useful
- Some applications may have strange behaviors or crash when readding dotfiles
in your home directory
- clusterssh (debian package : 3.19.1-4) with xterm still creates ~/.ssh/known_hosts
(xterm is setguid utmp). Everything works fine with latest rxvt instead of
xterm.


* TODO:

- Bugfixes !

Luc Dufresne <luc@ordiluc.net>