Next Previous Contents

5. Configuring LIDS

5.1 How do I protect a file as read only?

# lidsadm -A -o /some/file      -j READ

This will prevent anyone (including root) from modifying or deleting /some/file as long as LIDS is enabled. If you are in a LFS, you are free to modify /some/file assuming you have appropriate file system permissions and the partition isn't mounted read-only.

5.2 OK, so how do a protect a directory as read only?

Same as above, only specify /some/directory

# lidsadm -A -o /some/directory  -j READ

When the object is a directory, LIDS protects the directory itself, and it recursively protects everything underneath it within the same file system. (e.g. LIDS ACLs do not cross file system boundries!). This is very important to remember so you don't accidentally leave part of your system unprotected.

A directory that you may want to protect as read only, is the /etc directory.

# lidsadm -A -o /etc -j READ

5.3 How can I hide a file/directory from everyone?

# lidsadm -A -o /some/file_or_directory   -j DENY
Again, this will prevent even root from accessing it. And, if it is a directory, all files and directories underneath it are also hidden (within the same file system of course).

5.4 How can I protect log files so they can only be appended to?

# lidsadm -A -o /some/log/file  -j APPEND
This will allow someone to write to the end of the file while at the same time preventing him/her from erasing or modifying it's existing contents.

An easy way to protect your system logs as append only would be:

# lidsadm -A -o /var/log  -j APPEND

This will protect all files under /var/log as append only. As with READ and DENY, this target is also recursive.

5.5 If nothing is allowed to read my /etc/shadow file, how can I authenticate myself to the system?

In order to allow users to authenticate themselves to the system, it is necessary to give certain programs read only access to the /etc/shadow. Some of the programs you may want to consider giving read access to are: login, sshd, su, and vlock.

To allow the login program to read /etc/shadow, use the following ACL:

# lidsadm -A -s /bin/login -o /etc/shadow -j READ
The "-s" option specifies a subject, which is /bin/login in this case. We are giving the subject read only access to the object (/etc/shadow in this case).

5.6 If I protect /etc as read only, how will mount be able to write to /etc/mtab?

It won't. You can give mount and umount write access to /etc/mtab like this:

# lidsadm -A -s /bin/mount -o /etc/mtab  -j WRITE

or you can remove the /etc/mtab file and replace it with a symbolic link to /proc/mounts. In order for this to work, you must modify your startup scripts to use the "-n" option with every mount and umount command. This tells mount and umount not to update the /etc/mtab file.

5.7 LIDS complains that it can't write to my modules.dep file during startup. What's wrong?

This happens when you protect /lib as read only (a good thing to do). The error received is something similar to:

LIDS: depmod (3 12 inode 16119) pid 13203 user (0/0) on tty2: Try to open /lib/modules/2.2.18/modules.dep for writing,flag=578

This occurs during startup because the /etc/rc.d/rc.sysinit init script tries to recreate all of your module dependencies. Normally this is not needed because the module dependencies don't change unless add,change, or delete modules. The error is harmless, but if you don't like seeing it, you can simply comment out the line in your /etc/rc.d/rc.sysinit script that recreates the module dependencies (Look for depmod -a or something similar).

5.8 If I protect my logs as append only, how will logrotate rotate my logs?

It won't. Log rotation is something that will have to be done manually by executing your log rotation utility when LIDS_GLOBAL is disabled. You should disable the cron job that initiates log rotation.

5.9 Why can't I just give my log rotation utility write access to the directory containing my log files so it can rotate them?

You can, but it's not recommended. If someone were to break into you system, even though they couldn't modify your logs, they could rotate them enough times that the log containing the information gathered during the intrusion is dropped off the face of the earth. This is part of the price you pay for high security.

5.10 When LIDS is active, my file systems won't unmount during shutdown. What do I do?

This happens when you have disabled the CAP_SYS_ADMIN capability globally and have not given the proper authority to unmount your file systems to your shutdown script(s). For example, on Red Hat 6.2, the /etc/rc.d/init.d/halt script unmounts your file systems. You must give it the CAP_SYS_ADMIN capability so it can unmount your file systems:

# lidsadm -A -s /etc/rc.d/init.d/halt -t -o CAP_SYS_ADMIN  -j INHERIT

The "-t" option tells LIDS that the object is a capability and not a device or file. The target "INHERIT" tells LIDS that all processes started by the halt script will inherit this capability.

Beware that this also allows anyone who can execute your /etc/rc.d/init.d/halt script to unmount your file systems. If you have physical access to your box, you may just want to turn off LIDS_GLOBAL before shutting down your system rather than grant capabilities to your shutdown scripts. However, if you have a UPS that can shutdown your system in case of power failure, you may not be around to disable LIDS_GLOBAL.

5.11 Why can't I start a service that runs on a privileged port as root?

Services that run a privileged port (those below 1024) require the CAP_NET_BIND_SERVICE capability in order to bind to the port. If you have disabled this capability globally in the /etc/lids/lids.cap file, you must either grant the program that capability

# lidsadm -A -s /usr/local/bin/apache -t -o CAP_NET_BIND_SERVICE -j NO_INHERIT
or, start the service when LIDS_GLOBAL is disabled.

5.12 Why can't I start a service that runs on a privileged port from a LFS?

A LFS applies to a single terminal session. A daemon forks itself in order to separate itself from the controlling terminal. Once this happens, it is no longer connected to the LFS on your terminal and is now protected by LIDS.

5.13 How do I disable/enable capabilities?

The /etc/lids/lids.cap file contains a list of all the capabilities available under a LIDS enhanced Linux kernel. Those that have a "+" in front of them are enabled, and those with a "-" in front of them are disabled. To change the status of a capability, simple edit the text file and change the "+" to a "-" to disable a capability and vice-versa to enable it. After you're done editing the file, you must tell LIDS to reload the configuration files.

5.14 Why won't the X Window System work with LIDS enabled?

The X server that you are using requires the CAP_SYS_RAWIO capability. Try

# lidsadm -A -s /path/to/your/X_server -t -o CAP_SYS_RAWIO -j NO_INHERIT

5.15 With all of these ACLs, how can I possibly keep track of my configuration?

It is recommended that you create a shell script of all the ACLs that you wish to add to your system. That way you don't accidentally leave something unprotected when you make changes to your system. You can start the script out by flushing your old ACLs so you don't create duplicates.

# lidsadm -Z

5.16 I can't see my /etc/lids directory when LIDS is enabled. What's going on?

LIDS automatically protects the /etc/lids directory with DENY.

5.17 How can I give init write access to /etc/initrunlvl so LIDS doesn't complain about it during startup and shutdown?

Unfortunately, there isn't much you can do about this. Because init recreates this file each time you boot, it will have a different inode number every time. This makes it difficult for LIDS to handle. It is a harmless error, and your system will still function properly without /etc/initrunlvl.


Next Previous Contents