1 1.7.4.2 mjf #!/bin/sh 2 1.7.4.2 mjf # 3 1.7.4.2 mjf # $NetBSD: perusertmp,v 1.7.4.2 2007/12/04 22:09:02 mjf Exp $ 4 1.7.4.2 mjf # 5 1.7.4.2 mjf 6 1.7.4.2 mjf # PROVIDE: perusertmp 7 1.7.4.2 mjf # REQUIRE: mountall 8 1.7.4.2 mjf # BEFORE: cleartmp 9 1.7.4.2 mjf 10 1.7.4.2 mjf $_rc_subr_loaded . /etc/rc.subr 11 1.7.4.2 mjf 12 1.7.4.2 mjf name="perusertmp" 13 1.7.4.2 mjf rcvar="per_user_tmp" 14 1.7.4.2 mjf start_cmd="perusertmp_start" 15 1.7.4.2 mjf stop_cmd=":" 16 1.7.4.2 mjf 17 1.7.4.2 mjf perusertmp_start() 18 1.7.4.2 mjf { 19 1.7.4.2 mjf echo "Preparing per-user /tmp." 20 1.7.4.2 mjf 21 1.7.4.2 mjf # If /tmp is a mount point, we can't do anything. 22 1.7.4.2 mjf if [ -d "/tmp" ]; then 23 1.7.4.2 mjf local mount_point 24 1.7.4.2 mjf 25 1.7.4.2 mjf mount_point=$(cd /tmp && /bin/df . | /usr/bin/tail -1 | /usr/bin/awk '{print $6}') 26 1.7.4.2 mjf if [ "${mount_point}" = "/tmp" ]; then 27 1.7.4.2 mjf echo "WARNING: /tmp is mounted." 28 1.7.4.2 mjf exit 1 29 1.7.4.2 mjf fi 30 1.7.4.2 mjf fi 31 1.7.4.2 mjf 32 1.7.4.2 mjf # Enable magic symlinks. 33 1.7.4.2 mjf /sbin/sysctl -qw vfs.generic.magiclinks=1 34 1.7.4.2 mjf 35 1.7.4.2 mjf # Fixup real temporary directory. 36 1.7.4.2 mjf if [ ! -d ${per_user_tmp_dir} ]; then 37 1.7.4.2 mjf /bin/mkdir -p ${per_user_tmp_dir} 38 1.7.4.2 mjf fi 39 1.7.4.2 mjf /usr/sbin/chown root:wheel ${per_user_tmp_dir} 40 1.7.4.2 mjf /bin/chmod 0555 ${per_user_tmp_dir} 41 1.7.4.2 mjf 42 1.7.4.2 mjf # Create magic link for /tmp. 43 1.7.4.2 mjf if [ "$(/usr/bin/readlink /tmp)" != ${per_user_tmp_dir}/@ruid ]; then 44 1.7.4.2 mjf /bin/rm -rf /tmp 45 1.7.4.2 mjf /bin/ln -s ${per_user_tmp_dir}/@ruid /tmp 46 1.7.4.2 mjf fi 47 1.7.4.2 mjf } 48 1.7.4.2 mjf 49 1.7.4.2 mjf load_rc_config $name 50 1.7.4.2 mjf run_rc_command "$1" 51