<?xml version="1.0" encoding="ISO-8859-1"?><rss version="2.0"><channel><title>Puppy Linux Blog</title><description>Pritlog</description><link>http://mainetrapshooting.com/blog/index.php/RS</link><item><link>http://mainetrapshooting.com/blog/index.php/RSS/liviewEntry/00040/secure--tmp-on-servers</link><title>secure /tmp on servers</title><category>linux</category><description>Check if /tmp is already secure. Some servers do not use a /tmp partition while others do.&lt;br&gt;-----command-----&lt;br&gt;df -h |grep tmp&lt;br&gt;-----command----- &lt;p&gt;If
 that displays nothing then go below to create a tmp partition. If you 
do have a tmp partition you need to see if it mounted with noexec.&lt;br&gt;-----command-----&lt;br&gt;cat /etc/fstab |grep tmp&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;If
 there is a line that includes /tmp and noexec then it is already 
mounted as non-executable. If not follow the instructions below to 
create one without having to physically format your disk. Idealy you 
would make a real partition when the disk was originally formated, that 
being said I have not had any trouble create a /tmp partition using the 
following method. &lt;/p&gt;&lt;p&gt;Create a ~800Mb partition&lt;br&gt;-----command-----&lt;br&gt;cd /dev/; dd if=/dev/zero of=tmpMnt bs=1024 count=800000&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Format the partion&lt;br&gt;-----command-----&lt;br&gt;mkfs.ext2 /dev/tmpMnt&lt;br&gt;-----command-----&lt;br&gt;When it asks about not being a block special device press Y&lt;/p&gt;&lt;p&gt;Make a backup of the old data&lt;br&gt;-----command-----&lt;br&gt;cp -Rp /tmp /tmp_backup&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Mount the temp filesystem&lt;br&gt;-----command-----&lt;br&gt;mount -o loop,noexec,nosuid,rw /dev/tmpMnt /tmp&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Set the permissions&lt;br&gt;-----command-----&lt;br&gt;chmod 0777 /tmp&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Copy the old files back&lt;br&gt;-----command-----&lt;br&gt;cp -Rp /tmp_backup/* /tmp/&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Once
 you do that go ahead and restart mysql and make sure it works ok. We do
 this because mysql places the mysql.sock in /tmp which neeeds to be 
moved. If not it migth have trouble starting. If it does you can add 
this line to the bottom of the /etc/fstab to automatically have it 
mounted: &lt;/p&gt;&lt;p&gt;Open the file in pico:&lt;br&gt;-----command-----&lt;br&gt;pico -w /etc/fstab&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Now add this single line at the bottom:&lt;/p&gt;&lt;p&gt;/dev/tmpMnt /tmp ext2 loop,noexec,nosuid,rw 0 0&lt;/p&gt;&lt;p&gt;While we are at it we are going to secure /dev/shm. Look for the mount line for /dev/shm and change it to the following:&lt;br&gt;none /dev/shm tmpfs noexec,nosuid 0 0&lt;/p&gt;&lt;p&gt;Umount and remount /dev/shm for the changes to take effect.&lt;br&gt;-----command-----&lt;br&gt;umount /dev/shm&lt;br&gt;mount /dev/shm&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Delete the old /var/tmp and create a link to /tmp&lt;br&gt;-----command-----&lt;br&gt;rm -rf /var/tmp/&lt;br&gt;ln -s /tmp/ /var/&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;If everything still works fine,&amp;nbsp; delete the /tmp_backup directory.&lt;br&gt;-----command-----&lt;br&gt;rm -rf /tmp_backup&lt;br&gt;-----command-----&lt;/p&gt;&lt;p&gt;Your
 /tmp, /var/tmp, and /dev/shm are now mounted in a way that no program 
can be directly run from these directories. &lt;br&gt;&lt;/p&gt;</description></item></channel></rss>


