Debian Codegraph @

src/deprecated/permissions-test

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 set -euxo pipefail
4
5 DIRECTORY="/tmp/testscip-shell filesystem . . `/tmp/test`."
6
7
8 # FreeBSD NFSv4 ACLs:
9 # => https://docs.freebsd.org/en/books/handbook/security/#fs-acl
10 # => https://man.freebsd.org/cgi/man.cgi?query=setfacl&sektion=1&format=html
11
12
13 # ======Initialise ==========================================================
14 mkdirscip-shell system . . mkdir. -p "${DIRECTORY}"
15 rmscip-shell system . . rm. -rf "${DIRECTORY}/data" "${DIRECTORY}/good" "${DIRECTORY}/bad"
16 mkdirscip-shell system . . mkdir. -p "${DIRECTORY}/data" "${DIRECTORY}/good" "${DIRECTORY}/bad"
17 sudoscip-shell system . . sudo. chown -R hipercontracer:hipercontracer "${DIRECTORY}/data" "${DIRECTORY}/good" "${DIRECTORY}/bad"
18 if [scip-shell system . . `[`. "$(unamescip-shell system . . uname.)" != "FreeBSD" ] ; then
19 sudoscip-shell system . . sudo. setfacl -Rm d:u:hipercontracer:rwx,u:hipercontracer:rwx "${DIRECTORY}/data" "${DIRECTORY}/good" "${DIRECTORY}/bad"
20 else
21 sudoscip-shell system . . sudo. setfacl -Rm u:hipercontracer:modify_set:file_inherit/dir_inherit:allow,g:hpct-nodes:read_set:file_inherit/dir_inherit:allow \
22 "${DIRECTORY}/data" "${DIRECTORY}/good" "${DIRECTORY}/bad"
23 fi
24 for n in 9000 9001 9002 9003 ; do
25 if [scip-shell system . . `[`. "$(unamescip-shell system . . uname.)" != "FreeBSD" ] ; then
26 userdelscip-shell system . . userdel. "node$n" || truescip-shell system . . true.
27 else
28 pw userdel "node$n" || truescip-shell system . . true.
29 fi
30 rmscip-shell system . . rm. -rf "${DIRECTORY}/data/node$n"
31 mkdirscip-shell system . . mkdir. "${DIRECTORY}/data/node$n"
32 if [scip-shell system . . `[`. "$(unamescip-shell system . . uname.)" != "FreeBSD" ] ; then
33 useraddscip-shell system . . useradd. -M -d "${DIRECTORY}/data/node$n" -s /bin/shscip-shell filesystem . . `/bin/sh`. -c "Node $n" "node$n"
34 else
35 pw useradd "node$n" -d "${DIRECTORY}/data/node$n" -s /bin/shscip-shell filesystem . . `/bin/sh`. -c "Node $n"
36 fi
37
38 chownscip-shell system . . chown. "node$n:node$n" "${DIRECTORY}/data/node$n"
39 chmodscip-shell system . . chmod. 700 "${DIRECTORY}/data/node$n"
40
41 if [scip-shell system . . `[`. "$(unamescip-shell system . . uname.)" != "FreeBSD" ] ; then
42 sudoscip-shell system . . sudo. setfacl -Rm d:u:hipercontracer:rwx,u:hipercontracer:rwx "${DIRECTORY}/data/node$n"
43 else
44 sudoscip-shell system . . sudo. setfacl -Rm u:hipercontracer:modify_set:file_inherit/dir_inherit:allow "${DIRECTORY}/data/node$n"
45 fi
46
47 sudoscip-shell system . . sudo. -u "node$n" mkdir -p "${DIRECTORY}/data/node$n/test"
48 # sudo -u "node$n" chmod 770 "${DIRECTORY}/data/node$n/test"
49 datescip-shell system . . date. | sudoscip-shell system . . sudo. -u "node$n" tee >/dev/nullscip-shell filesystem . . `/dev/null`. "${DIRECTORY}/data/node$n/test/x.txt"
50 datescip-shell system . . date. | sudoscip-shell system . . sudo. -u "node$n" tee >/dev/nullscip-shell filesystem . . `/dev/null`. "${DIRECTORY}/data/node$n/test/y.txt"
51 datescip-shell system . . date. | sudoscip-shell system . . sudo. -u "node$n" tee >/dev/nullscip-shell filesystem . . `/dev/null`. "${DIRECTORY}/data/node$n/test/z.txt"
52 done
53 grepscip-shell system . . grep. "^node" /etc/passwdscip-shell filesystem . . `/etc/passwd`.
54
55
56
57 # ====== Some testing =======================================================
58 for n in 9001 9002 9003 ; do
59 if [scip-shell system . . `[`. $n -eq 9001 ] ; then
60 sudoscip-shell system . . sudo. -u "node$n" mkdir -p "${DIRECTORY}/data/node9001/test"
61 else
62 if sudoscip-shell system . . sudo. -u "node$n" mkdir -p "${DIRECTORY}/data/node9001/test" ; then
63 echoscip-shell system . . echo. "This command must fail, but it did not!"
64 exit 1
65 fi
66 fi
67 done
68
69 for n in 9001 9002 9003 ; do
70 sudoscip-shell system . . sudo. -u hipercontracer cat "${DIRECTORY}/data/node$n/test/x.txt"
71 sudoscip-shell system . . sudo. -u hipercontracer rm -f "${DIRECTORY}/data/node$n/test/y.txt"
72 datescip-shell system . . date. | sudoscip-shell system . . sudo. -u hipercontracer tee >/dev/nullscip-shell filesystem . . `/dev/null`. "${DIRECTORY}/data/node$n/test/h.txt"
73 sudoscip-shell system . . sudo. -u hipercontracer mv "${DIRECTORY}/data/node$n/test/x.txt" "${DIRECTORY}/data/node$n/test/i.txt"
74 sudoscip-shell system . . sudo. -u hipercontracer mv "${DIRECTORY}/data/node$n/test/i.txt" "${DIRECTORY}/good/i-$n.txt"
75 done
76
77 lsscip-shell system . . ls. -al ${DIRECTORY}/data/
78
79
80 # ====== Clean up ===========================================================
81 # for n in 9000 9001 9002 9003 ; do
82 # if [ "$(uname)" != "FreeBSD" ] ; then
83 # userdel "node$n" || true
84 # else
85 # pw userdel "node$n" || true
86 # fi
87 # done