Deprecated: Assigning the return value of new by reference is deprecated in /var/www/vhosts/pleskhosts.com/httpdocs/forum/includes/init.php on line 49

Create a Secure /tmp /var/tmp [Archive] - Forums

View Full Version : Create a Secure /tmp /var/tmp


speedy
03-27-2007, 11:31 AM
Backup the original /etc/fstab file just in case....

cp /etc/fstab /etc/fstab.bak

--Contents of original file –


/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0



Create /tmp

create the partition, 800mb
cd /dev/; dd if=/dev/zero of=tmpMnt bs=1024 count=812000

Format the partion
mke2fs /dev/tmpMnt

Make a backup of the old data
cp -Rp /tmp /tmp_backup

Mount the temp filesystem

mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp

Set the permissions

chmod 0777 /tmp


Copy the old files back

cp -Rp /tmp_backup/* /tmp/

Once you do that go ahead and start mysql and make sure it works ok. If it does you can add this line to the bottom of the /etc/fstab to automatically have it #mounted:

/dev/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0

Next delete the old /var/tmp and create a link to /tmp

rm -rf /var/tmp/
ln -s /tmp/ /var/


If everything still works fine you can go ahead and delete the /tmp_backup directory.

rm -rf /tmp_backup