1 | #!/bin/sh - |
---|
2 | # |
---|
3 | # $Id: config_afs.sh,v 1.21 2003-06-19 20:06:42 zacheiss Exp $ |
---|
4 | # |
---|
5 | # This script configures the workstation's notion of AFS. |
---|
6 | # 1. It updates the cell location information from /usr/vice/etc/CellServDB |
---|
7 | # 2. It updates the cell setuid information from /usr/vice/etc/SuidCells |
---|
8 | # 3. It updates the cell alias information from /usr/vice/etc/CellAlias |
---|
9 | PATH=/bin:/bin/athena:/usr/bin; export PATH |
---|
10 | |
---|
11 | VICEDIR=/usr/vice/etc |
---|
12 | CELLDB=${VICEDIR}/CellServDB |
---|
13 | SUIDDB=${VICEDIR}/SuidCells |
---|
14 | ALIAS=${VICEDIR}/CellAlias |
---|
15 | HOSTTYPE=`/bin/athena/machtype` |
---|
16 | |
---|
17 | echo "Updating cell location information" |
---|
18 | rm -f ${VICEDIR}/Ctmp |
---|
19 | cp /afs/athena.mit.edu/service/CellServDB ${VICEDIR}/Ctmp && |
---|
20 | [ -s ${VICEDIR}/Ctmp ] && |
---|
21 | mv -f ${VICEDIR}/Ctmp ${CELLDB}.public && |
---|
22 | cat ${CELLDB}.public ${CELLDB}.local >${VICEDIR}/Ctmp 2>/dev/null |
---|
23 | [ -s ${VICEDIR}/Ctmp ] && { |
---|
24 | cmp -s ${VICEDIR}/Ctmp ${CELLDB} || { |
---|
25 | rm -f ${CELLDB}.last && |
---|
26 | ln ${CELLDB} ${CELLDB}.last && |
---|
27 | mv -f ${VICEDIR}/Ctmp ${CELLDB} && |
---|
28 | chmod 644 ${CELLDB} && |
---|
29 | sync && |
---|
30 | awk ' |
---|
31 | /^>/ {printf("\nfs newcell %s", \ |
---|
32 | substr($1,2,length($1)-1))}; |
---|
33 | /^[0-9]/ {printf(" %s",$1)}; |
---|
34 | END {printf("\n")}' ${CELLDB} | sh |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | echo "Updating setuid cell information" |
---|
39 | rm -f ${VICEDIR}/Ctmp |
---|
40 | cp /afs/athena.mit.edu/service/SuidCells ${VICEDIR}/Ctmp && |
---|
41 | [ -s ${VICEDIR}/Ctmp ] && |
---|
42 | mv -f ${VICEDIR}/Ctmp ${SUIDDB}.public && |
---|
43 | cat ${SUIDDB}.public ${SUIDDB}.local >${VICEDIR}/Ctmp 2>/dev/null |
---|
44 | [ -s ${VICEDIR}/Ctmp ] && |
---|
45 | mv -f ${VICEDIR}/Ctmp ${SUIDDB} && |
---|
46 | chmod 644 ${SUIDDB} |
---|
47 | |
---|
48 | echo "Only allowing setuid/setgid programs from the following cells:" |
---|
49 | |
---|
50 | for cellname in `/etc/athena/listsuidcells`; do |
---|
51 | fs setcell "$cellname" -nosuid |
---|
52 | done |
---|
53 | cat ${SUIDDB} | awk ' |
---|
54 | /^-$/ { numcells = 0; exit; } |
---|
55 | /^-/ { suid[substr($1,2,length($1)-1)] = 0; } |
---|
56 | /^[^-]/ { suid[$1] = 1; |
---|
57 | cells[numcells++] = $1; } |
---|
58 | END { for (i = 0; i < numcells; i++) { |
---|
59 | if (suid[cells[i]]) { |
---|
60 | printf("fs setcell %s -suid\n", cells[i]); |
---|
61 | printf("echo %s\n", cells[i]); } } }' | sh |
---|
62 | |
---|
63 | |
---|
64 | echo "Updating cell alias information" |
---|
65 | rm -f ${VICEDIR}/Ctmp |
---|
66 | cp /afs/athena.mit.edu/service/CellAlias ${VICEDIR}/Ctmp && |
---|
67 | [ -s ${VICEDIR}/Ctmp ] && |
---|
68 | mv -f ${VICEDIR}/Ctmp ${ALIAS}.public && |
---|
69 | cat ${ALIAS}.public ${ALIAS}.local >${VICEDIR}/Ctmp 2>/dev/null |
---|
70 | [ -s ${VICEDIR}/Ctmp ] && { |
---|
71 | cmp -s ${VICEDIR}/Ctmp ${ALIAS} || { |
---|
72 | rm -f ${ALIAS}.last && |
---|
73 | mv -f ${VICEDIR}/Ctmp ${ALIAS} && |
---|
74 | chmod 644 ${ALIAS} && |
---|
75 | sync && |
---|
76 | awk ' |
---|
77 | /^#/ {next} \ |
---|
78 | NF == 2 {print "fs newalias",$2,$1}' ${ALIAS} | sh |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | rm -f ${VICEDIR}/Ctmp |
---|
83 | exit 0 |
---|