home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume18 / diskhog2 / README < prev   
Encoding:
Text File  |  1989-03-26  |  4.8 KB  |  121 lines

  1. [  NOTE:  You  might have to edit "diskhog" to turn the printable control
  2.    characters in the "stty" line into their real values. --r$  ]
  3.  
  4. DISKHOG.
  5.  
  6. 1.  Introduction.
  7.  
  8.           'diskhog' is a set of scripts to allow you to enforce disk quotas
  9.        under system V.  You need to specify the blocks allowed for each. 
  10.        user (as reported by 'du'), and run a check script every night.  Users
  11.        who are listed in the 'allowed' file have disk quotas; those which are
  12.        not listed have not.  
  13.  
  14.            You can also specify 'alternate' directories which are counted 
  15.        as well as the user's home directory.  (for example, I have 
  16.        "/usr/dave" and "~nuucp/dave").  All the files, irrespective of 
  17.        owner, are counted in these directories, which is perhaps a little 
  18.        unfair ... 
  19.  
  20.  
  21. 2.  How it works. 
  22.  
  23.             Basically, there is a file called "allowed", which  has
  24.        a list of the number of disk blocks (as per "du") which each
  25.        user is allowed.  The format of this file is
  26.  
  27.                <user> <allowance>
  28.  
  29.        where <user> is the user's login name,  and  <allowance>  is
  30.        the maximum number of block they are allowed (as per "du").
  31.  
  32.             There is also  an  optional  file  called  "alternate",
  33.        containing   additional   directories  to  be  searched  for
  34.        particular users. This is in the form:
  35.  
  36.                         user    directory ....
  37.                 e.g.
  38.                         dave    /usr/spool/uucppublic/dave /sys/dave
  39.  
  40.             Each night, the script "dcheck" is run  from  the  root
  41.        crontab entry, and checks each user's allowance. If the user
  42.        has more than the allowance, a mail message is sent  to  the
  43.        user asking them to remove some files.
  44.  
  45.             If after a certain number of  days  the  user  has  not
  46.        removed  enough  files, then a diskhog "tag" is created. The
  47.        next time the user logs on, the shell notices this tag,  and
  48.        spawns a restricted shell via the script "diskhog".
  49.  
  50.             When running via "diskhog", the user's PATH is  set  to
  51.        "/diskhog:/usr/diskhog",   so  that  you  can  restrict  the
  52.        commands which are available. On my system, all the commands
  53.        in   these   directories   relate  to  removing  files,  and
  54.        formatting floppy disks to put them on.
  55.  
  56.             When the user logs out of the restricted shell, another
  57.        disk  check  is  performed,  and  if enough blocks have been
  58.        removed, the login is allowed to proceed. If not,  "diskhog"
  59.        is  run  again.  "Diskhog"  is  interrupt-proof,  but can be
  60.        killed by a SIGHUP signal (i.e. turning off the terminal).
  61.  
  62.             In order to prevent the user from removing the  diskhog
  63.        "tag"  file,  the tag file is placed in a directory owned by
  64.        root, which is not writeable by anyone else. The tag file is
  65.        removed  by  a special command "nohog", which is executed by
  66.        "diskhog" when enough files have been removed. "Nohog"  runs
  67.        suid  root,  and is (hopefully) immune from fraud: it always
  68.        removes the tag of the login user.
  69.  
  70.             Obviously, you should not put "nohog" in the restricted
  71.        PATH,  or the user would be able to remove their own diskhog
  72.        tag!
  73.  
  74.             All you need to run disk quotas is:
  75.  
  76.          1.  An "allowed" file, containing disk allowances.
  77.  
  78.          2.  If your system has "csh", then you need to type  "make
  79.              csh", since csh does not have a system-wide init file.
  80.              A small program is provided, which makes the  relevant
  81.              check, and then calls the real csh.
  82.  
  83.          3.  Add a line to the beginning of the file "/etc/profile"
  84.              which reads:
  85.  
  86.                      if [ -f $DQUOTAS/hogs/$LOGNAME ] ; then diskhog ; fi
  87.  
  88.              where DQUTOAS is defined  as  your  disk  quota  admin
  89.              directory (see Makefile).
  90.  
  91.          4.  Make yourself an entry in the root crontab, which runs
  92.              the program "dcheck" sometime during the night.
  93.  
  94.                   This will read something like:
  95.  
  96.              03      01      *       *       *       /usr/bin/dcheck
  97.  
  98.              to run at 01:30 am every night.
  99.  
  100.  
  101.        3.  Using csh with diskhog
  102.  
  103.             Since   my   "csh"   doesn't   have    a    system-wide
  104.        initialisation  file, it's difficult to intercept the logins
  105.        of people using the c-shell.
  106.  
  107.             I decided to intercept /bin/csh itself, so I moved  the
  108.        real  csh  to  /etc/csh, and wrote a stub program which just
  109.        checks for a tag file, and calls diskhog  if  it  finds  it.
  110.        Then it calls the real csh.
  111.  
  112.             This works fine on my system, but make  sure  it's  not
  113.        going  to  interfere  with  things on your system before you
  114.        install it.
  115.  
  116.             Have fun.
  117.  
  118.  
  119.             Dave Settle, SMB Business Software, Thorn EMI Datasolve
  120.             [ Now Universal (CMS) Ltd.]
  121.