Log onto the server as root: Is the /tmp directory in its own
partition?
- Do a “df –k”
Do you see a /tmp partition? If YES, then
move to step B; otherwise move to step C.
- Modify etc fstab
to change the definition for /tmp
Change “defaults” to
“rw,nosuid,noexec” and save etc fstab
Save the file, and execute the following
command:
mount -oremount loop,rw,nosuid,noexec /tmp
Skip to step E
-
The following will create a 100 MB /tmp directory on its
own partition with noexec and nosuid.
IMPORTANT:On CentOS and RedHat Enterprise 4.x, use /var or another partition with a large amount of free space rather than /dev as CentOS 4.x recreates the /dev partition every time the server reboots;
also, CentOS 4.x and RedHat Enterprise 4.x, do not use the "loop" parameter above.
cd /dev/
dd if=/dev/zero of=Tmp bs=1024 count=100000
mkfs -t ext3 /dev/Tmp
cd /
cp -aR /tmp /tmp_backup
mount -o loop,noexec,nosuid,rw /dev/Tmp
/tmp
cp -aR /tmp_backup/* /tmp/
chmod 0777 /tmp
chmod +t /tmp
- Modify etc fstab
to add the definition for /tmp
/dev/Tmp /tmp
ext3 loop,rw,nosuid,noexec 0 0
- Link /var/tmp to
/tmp
cd /var
Verify /var/tmp is empty
rm -fR /var/tmp
ln -s /tmp /var/tmp
NOTES:
The etc fstab entry means it will be mounted
automatically on boot up.
nosuid, noexec are to help protect against hackers
putting root kits in /tmp and building / executing them |