ZLIBC FREQUENTLY ASKED QUESTIONS

The latest released version is zlibc-0.9k.

How do I set up zlibc to work works with set-uid programs

LD_PRELOAD is normally ignored by set-uid programs, for security reasons.

To make in work anyways, 3 conditions must be met:

  1. The zlibc library must be stored in /lib or /usr/lib
  2. The setuid bit must be set on the uncompress.so itself
  3. LD_PRELOAD (or /etc/ld.so.preload) should list just uncompress.so, not /lib/uncompress.so (no absolute path)

# cp /usr/src/zlibc/uncompress.so /lib
# chmod +s /lib/uncompress.so

> export LD_PRELOAD=uncompres.o
> chsh

Alternatively, you may set up zlibc as a system-wide preloadable object (by listing it in /etc/ld.so.preload). In that case, it may live in any directory, and the suid bit need not be set.

Zlibc breaks foo program, what should I do?

Program foo is unable to use zlibc

Zlibc is unable to follow symlinks to compressed files.

If you have a file named foo, and a symlink bar pointing to it, you need to change that symlink when compressing foo:
> ls -l
total 2
lrwxrwxr-x  1 knaff           3 Nov 22 17:51 bar -> foo
-rw-rw-r--  1 knaff           6 Nov 22 17:51 foo
> gzip foo
> rm bar
rm: remove bar? y
> ln -s foo.gz bar.gz

Can I also compress executables?

Zlibc cannot use compressed executables. However there is another program, UPX which can do this. To save most disk space, use the two programs together. (zlibc is able to use compressed data files, but not executables, and UPX is able to use compressed executables, but not data files)

How should I report bugs?

Can I also compress libraries?

You can compress static libraries (.a) and shared libraries stubs (.sa) without any problems. However, you can't compress shared library objects (.so)

Which files shouldn't I compress?

  1. Files associated with the boot and shutdown process, especially if your gzip doesn't live on the root partition. These files are /etc/rc, /etc/inittab, /etc/fstab, ...
  2. Files which are smaller than 1024 bytes (or 512 bytes on a Dos fs). Filesystem space is allocated in blocks of 1024 bytes, so if your file is already smaller than that, you don't win anything by compressing it.
  3. Shared libraries (.so)
  4. Executables and kernels (get UPX to do that)

Is there a {Free,386,Net}BSD port?

Not yet.

How can I remove zlibc when I don't want it any more?

  1. Buy a huge disk :-)
  2. Uncompress your compressed files with gunzip.
  3. unset LD_PRELOAD, or remove it from /etc/ld.so.preload

When are changes in zlibrc files taken into account?

If your zlibrc file is still syntactically correct, all changes in the zlibrc files are taken into account at least for the programs which are started after the change. To check the correctness of your zlibrc file, set then environmental variable LD_ZLIB_VERBOSE to 1. This prints lot of informational messages, and also error messages.

Since the 20050220 patch, the zlibrc files are parsed by each program whenever they are first needed, i.e. when the programs first tries to uncompress a file. Thus changes MAY affect already running programs, and CERTAINLY affect programs which are started after the change.

Does zlibrc recognize the names of scripts?

No. In a script the current command name is always the name of the shell, thus zlibc cannot recognize the name of the script itself.

My system is dog slow since I installed zlibc?

With some programs, I get 'gzip: stdin: unexpected end of file' messages when chosing compressed file creation.

What probably happens is that the program uses the obsolete 'creat' call. The 'creat' call is not as flexible as open, and so the program needs to open the file twice:

 close(creat(file, mode)); /* create the tmp file */
 open(file, O_RDWR, mode); /* open it in the desired mode */

The creat call creates the compressed file. A gzip is started in the background to do this (it has to run in parallel with the main program, just in case that program tried to write to the file descriptor.) Because the open follows immediately afterwards, the creating gzip may not yet been done. Open spawns an uncompressing gzip, which finds an invalid compressed file. Thus gzip prints that error message. This error message is benign, as the file was empty anyways.

In order to avoid it, try to find out the relevant file using strace or LD_ZLIB_VERBOSE, and switch compression off for it. Very often these are just temporary files. Putting the following line in the class of the offending program thus clears away most of these messages:

 dir "/tmp" no-create-compressed

[This is a good idea anyways, because usually you don't want tmp files to be compressed.]