#!/bin/sh # build-rw --- creates a writable kiosk directory. # See http://www.dnalounge.com/backstage/src/kiosk/ for details. # Copyright (c) 2000, 2003, 2004 by The DNA Lounge # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 28-Apr-2001, Jamie Zawinski verbose= dir= make_rw() { if [ ! -d $dir ]; then echo "$0: directory $dir/ does not exist" >&2 exit 1 fi if [ ! -d $dir/lost+found ]; then echo "$0: directory $dir/ does not look right..." >&2 exit 1 fi set -x umask 022 chmod 755 $dir rm -rf $dir/* cd $dir mkdir lost+found ######################################################################## # We only need to create directories in here which the client # needs to write to, or which contain files that the client needs to # write to. mkdir boot dev etc home tmp var mkdir -p etc/ntp \ etc/ssh \ etc/ntp \ home/guest \ lib \ var/lock/console var/lock/subsys \ var/cache var/log var/preserve var/run var/run/netreport \ var/spool/at var/spool/cron \ var/spool/mqueue var/spool/clientmqueue \ var/state/misc \ var/lib \ var/tmp chmod 1777 var/tmp chown ntp.ntp etc/ntp chown smmsp.smmsp var/spool/clientmqueue chmod 770 var/spool/clientmqueue # Copy over the devices we need: cp -a /dev/{audio*,dsp*,initctl,log,tty,tty?,ttyS?,cua?,ttyp?,pty*} \ /dev/{console,null,mem,mouse,psaux,gpmdata,*random} \ dev/ # Create placeholders for these files, which we will fill # in eventually: touch boot/kernel.h \ etc/HOSTNAME \ etc/issue \ etc/issue.net \ etc/ssh/ssh_host_key \ etc/ssh/ssh_host_key.pub \ etc/ssh/ssh_host_rsa_key \ etc/ssh/ssh_host_rsa_key.pub \ etc/ssh/ssh_host_dsa_key \ etc/ssh/ssh_host_dsa_key.pub \ etc/ssh/ssh_random_seed \ etc/ssh/moduli \ var/lib/random-seed \ var/log/lastlog \ etc/ntp/drift # Now, in each directory we've created, fill it with symlinks to # every existing file in "/ro" (excepting the files we've already # created.) Ignore the ``File exists'' and ``cannot overwrite # directory'' errors. for d in `find * -type d`; do ln -s /ro/$d/* $d done # But not here: rm var/{log,lock,lock/subsys,preserve,run,spool/mqueue}/* rm -rf var/cache/* rm etc/named.* var/named rm etc/ntp/{drift,keys} cp -p /etc/ntp/{drift,keys} etc/ntp rm -rf tmp ln -s var/tmp tmp rm etc/named.* var/named rm -rf home mkdir -p home/guest chown guest.guest home/guest ln -s /ro2/home/guest-ro home ######################################################################## # these kiosks have a cd on hda rm dev/cdrom ln -s hda dev/cdrom # because of the funny place we keep /usr/local ln -s /ro2/home/local home/local # Clean up some extra crap that might have gotten copied over find . \( -name core -o -name a.out -o -name %backup%~ \ -o -name '*~' -o -name '#*' -o -name '*#' \ -o -name '.#*' \ -o -name '.*~' \ -o -name '%*' \ -o -name '*.orig' -o -name '*.rej' -o -name '*.bak' \ -o -name '*.rpmsave' -o -name '*.rpmnew' -o -name '*.rpmorig' \ -o -name '.saves-*' \ -o -name '[*]' \ \) -print | xargs rm -f # Install the pregenerated ssh host keys fix_ssh } fix_ssh() { pwd cp -a ../share/etc/ssh/sshd_config \ ../ssh_keys/$dir/ssh_host_key \ ../ssh_keys/$dir/ssh_host_key.pub \ ../ssh_keys/$dir/ssh_host_rsa_key \ ../ssh_keys/$dir/ssh_host_rsa_key.pub \ ../ssh_keys/$dir/ssh_host_dsa_key \ ../ssh_keys/$dir/ssh_host_dsa_key.pub \ etc/ssh/ } usage() { echo "usage: `basename $0` [-v] output-directory" exit 1 } main() { while [ $# -gt 0 ]; do case $1 in -v) verbose=1 ;; *) if [ -z "$dir" ]; then dir=$1 else usage fi ;; esac shift done if [ -z "$dir" ]; then usage fi make_rw } main "$@" exit 0