From b8e4bdf83a4889022b0f4fbfa17f7607d19f7b5d Mon Sep 17 00:00:00 2001 From: qjb Date: Fri, 5 Aug 1988 14:25:38 +0000 Subject: [PATCH] Initial revision --- gen/install_dirs | 95 ++++++++++++++++++++++++++++++++++++++++++++++ gen/install_quotas | 30 +++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 gen/install_dirs create mode 100644 gen/install_quotas diff --git a/gen/install_dirs b/gen/install_dirs new file mode 100644 index 00000000..9dc45a10 --- /dev/null +++ b/gen/install_dirs @@ -0,0 +1,95 @@ +#!/bin/csh -f +# This script installs new directories on NFS servers. + +# The following exit codes are defined and MUST BE CONSISTENT with the +# SMS error codes the library uses: +set SMS_PROTO = 47836477 + +set path=(/etc /bin /usr/bin /usr/etc) + +# Find out what device we're working on +set dev = $1 + +set TMPSTOR = /tmp/tmpstor # Temporary area for user . files +set USERTAR = /tmp/proto.tar # Tarfile for user . files + +# Give ourselves a fresh work area +rm -rf $USERTAR +rm -rf $TMPSTOR +mkdir $TMPSTOR +if ($status) exit SMS_PROTO + +# Make a tarfile containing the user prototype files for future use. +(cd /usr/prototype_user;tar cf - .) | (cd $TMPSTOR; tar xpf -) +# Remove the welcome file. This may change. +rm -f $TMPSTOR/welcome +chmod -R 444 $TMPSTOR +chmod 700 $TMPSTOR/Mail +(cd $TMPSTOR; tar cf $USERTAR .) +if ($status) exit SMS_PROTO +rm -rf $TMPSTOR + +# So that the new directories get the right protections. +umask 66 + +while (1) + # Do this until there are no more lines of input + set input = `echo $<` + if ($#input != 4) break + + set dir = $input[1] + set uid = $input[2] + set gid = $input[3] + set type = $input[4] + + # Don't do anything if the directory already exists + if (-d $dir) continue + + while (1) + set tmpdir = $dir:h/_$dir:t + # Don't clobber this directory if it exists. + if (-d $tmpdir) then + continue + else + mkdir $tmpdir + # At some point it may be wise to check the status here and + # return a soft failure, but the current protocol doesn't + # support this + break + endif + end + if (! -d $tmpdir) continue + chown $uid.$gid $tmpdir + + # At some point, we may wish to add a more elegant way of handling + # locker types. The current arrangement allows for easy adding of + # default actions here. + switch ($type) + case HOMEDIR: + + # ***** Remove this when /etc/encorce_quota becomes obsolete! + # Give this filesystem a 600K quota + setquota -u $dev $uid 600 + # ***** + + # Give user prototype files + # sms_untar is a setuid argv[1] tar xfp - + (cd $tmpdir; sms_untar $uid < $USERTAR) + if ($status) set WARN + breaksw + default: + breaksw + endsw + + mv $tmpdir $dir + ### Soft failure when ready +end + +# Cleanup +rm -f $USERTAR +exit 0 + +# +# $Source$ +# $Header$ +# diff --git a/gen/install_quotas b/gen/install_quotas new file mode 100644 index 00000000..c91953f4 --- /dev/null +++ b/gen/install_quotas @@ -0,0 +1,30 @@ +#!/bin/csh -f +# +# This script sets the quota for a uid on a filesystem. + +set dev=$1 + +# Checking for /etc/enforce_quota is transitional code and should be +# removed when the SMS database has an accurate understanding of what +# everyone's quotas are. +if ( -f /etc/enforce_quota ) then + while (1) + # set args = $< will NOT work. $< will be treated as a single word + set args = `echo $<` + + if (${#args} != 2) break + + set uid = args[1] + set quota = args[2] + + setquota -u $dev $uid $quota + if ($status) ### Soft failure + end +endif + +exit 0 + +# +# $Source$ +# $Header$ +# -- 2.45.2