<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Latest snippets tagged security linux sysadmin</title>
  <link rel="alternate" href="http://snippets.prendreuncafe.com/snippets/tagged/security+linux+sysadmin/order_by/date"></link>
  <id>http://snippets.prendreuncafe.com/snippets/tagged/security+linux+sysadmin/order_by/date</id>
  <updated>2007-02-05T22:10:24Z</updated>
  <author>
    <name>Symfony</name>
    <author_email>noreply@symfony-project.com</author_email>
  </author>
<entry>
  <title>Sécuriser /tmp</title>
  <link href="http://snippets.prendreuncafe.com/snippet/54"></link>
  <updated>2007-02-05T22:10:24Z</updated>
  <id>54</id>
  <summary type="html">Beaucoup de script-kiddies s'amusent beaucoup avec le répertoire /tmp, par défaut aisément accessible et donc réceptacle à executables falacieux de tous poils.

Voici une méthode permettant de remplacer ce point de montage par un nouveau, de 40Mo mais dont la particularité sera de ne pas autoriser l'execution de programmes (héhé) :

[code bash]
# create a 40MB block device which will be the /tmp file system
cd /root
dd if=/dev/zero of=/root/tmpMnt bs=1024 count=40000
mkfs.ext3 -F /root/tmpMnt
# mount it at /tmp
mv /tmp /tmp.backup
mkdir /tmp
mount -o loop,noexec,nosuid,rw /root/tmpMnt /tmp
chmod 0777 /tmp
# make it so it is used on boot up
if ! grep -qai tmpMnt /etc/fstab ; then 
     echo &quot;/root/tmpMnt /tmp ext3 loop,noexec,nosuid,rw  0 0&quot; &gt;&gt; /etc/fstab
fi
# check your syntax is ok
mount -a
# check that programs in /tmp will not run
cp /bin/ls /tmp/
/tmp/ls
[/code]

Pour remonter /tmp avec droits d'execution :

[code bash]
# umount /tmp
# mount -o loop,rw /root/tmpMnt /tmp
[/code]

Et remonter la partition sans les droits d'execution :

[code bash]
# umount /tmp
# mount -o loop,noexec,nosuid,rw /root/tmpMnt /tmp
[/code]</summary>
</entry>
</feed>