| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | # SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | # shellcheck disable=SC2016 |
| 4 | set -eux |
| 5 | set -o pipefail |
| 6 | |
| 7 | test_quotasscip-shell shell systemd 261~rc3-1 test_quotas().() { |
| 8 | |
| 9 | local directory="$1" |
| 10 | local exec_directory_directive="$2" |
| 11 | local exec_quota_directive="$3" |
| 12 | local mountpoint="/datadrivescip-shell filesystem . . `/datadrive`." |
| 13 | |
| 14 | dev_num=$(lsblkscip-shell system . . lsblk. | grepscip-shell system . . grep. "498M" | awkscip-shell system . . awk. '{print $1}' | sedscip-shell system . . sed. 's/[^a-zA-Z0-9]*//g') |
| 15 | |
| 16 | if ! tune2fs -Q prjquota "/dev/${dev_num}"; then |
| 17 | return |
| 18 | fi |
| 19 | mkdirscip-shell system . . mkdir. -p "${mountpoint}" |
| 20 | mountscip-shell system . . mount. "/dev/${dev_num}" "${mountpoint}" |
| 21 | |
| 22 | mvscip-shell system . . mv. /var/lib/scip-shell filesystem . . `/var/lib/`. "${mountpoint}" |
| 23 | rmscip-shell system . . rm. -rf /var/lib/scip-shell filesystem . . `/var/lib/`. && lnscip-shell system . . ln. -s "${mountpoint}/lib/" /var/scip-shell filesystem . . `/var/`. |
| 24 | |
| 25 | rmscip-shell system . . rm. -rf "${directory}/quotadir" |
| 26 | |
| 27 | catscip-shell system . . cat. >/run/systemd/system/testservice-07-check-quotas.servicescip-shell filesystem . . `/run/systemd/system/testservice-07-check-quotas.service`. <<EOF |
| 28 | [Unit] |
| 29 | Description=Check quotas with ExecDirectory |
| 30 | |
| 31 | [Service] |
| 32 | # Relevant only for sanitizer runs |
| 33 | EnvironmentFile=-/usr/lib/systemd/systemd-asan-env |
| 34 | Type=oneshot |
| 35 | |
| 36 | MountAPIVFS=yes |
| 37 | DynamicUser=yes |
| 38 | PrivateUsers=yes |
| 39 | TemporaryFileSystem=/run /var/opt /var/lib /vol |
| 40 | ${exec_directory_directive} |
| 41 | ${exec_quota_directive} |
| 42 | ExecStart=bash -c ' \ |
| 43 | set -eux; \ |
| 44 | set -o pipefail; \ |
| 45 | touch ${directory}/quotadir/testfile; \ |
| 46 | ' |
| 47 | EOF |
| 48 | |
| 49 | systemctl daemon-reload |
| 50 | systemctl start testservice-07-check-quotas.service |
| 51 | |
| 52 | proj_id=$(lsattr -p "${directory}" | grepscip-shell system . . grep. "quotadir" | awkscip-shell system . . awk. '{print $1}') |
| 53 | [[ $proj_id -gt 0 ]] |
| 54 | |
| 55 | block_limit=$(repquota -P "${mountpoint}" | grepscip-shell system . . grep. -E "#$proj_id " | awkscip-shell system . . awk. '{print $5}') |
| 56 | inode_limit=$(repquota -P "${mountpoint}" | grepscip-shell system . . grep. -E "#$proj_id " | awkscip-shell system . . awk. '{print $8}') |
| 57 | [[ $block_limit -gt 0 ]] |
| 58 | [[ $inode_limit -gt 0 ]] |
| 59 | |
| 60 | # Test exceed limit |
| 61 | rmscip-shell system . . rm. -rf "${directory}/quotadir" |
| 62 | |
| 63 | catscip-shell system . . cat. >/run/systemd/system/testservice-07-check-quotas.servicescip-shell filesystem . . `/run/systemd/system/testservice-07-check-quotas.service`. <<EOF |
| 64 | [Unit] |
| 65 | Description=Check quotas with ExecDirectory |
| 66 | |
| 67 | [Service] |
| 68 | # Relevant only for sanitizer runs |
| 69 | EnvironmentFile=-/usr/lib/systemd/systemd-asan-env |
| 70 | Type=oneshot |
| 71 | |
| 72 | MountAPIVFS=yes |
| 73 | DynamicUser=yes |
| 74 | PrivateUsers=yes |
| 75 | TemporaryFileSystem=/run /var/opt /var/lib /vol |
| 76 | ${exec_directory_directive} |
| 77 | ${exec_quota_directive} |
| 78 | ExecStart=bash -c ' \ |
| 79 | set -eux; \ |
| 80 | set -o pipefail; \ |
| 81 | (! fallocate -l 10000G ${directory}/quotadir/largefile); \ |
| 82 | ' |
| 83 | EOF |
| 84 | |
| 85 | systemctl daemon-reload |
| 86 | systemctl start testservice-07-check-quotas.service |
| 87 | } |
| 88 | |
| 89 | test_quotasscip-shell shell systemd 261~rc3-1 test_quotas(). "/var/lib/privatescip-shell filesystem . . `/var/lib/private`." "StateDirectory=quotadir" "StateDirectoryQuota=1%" |
| 90 | |
| 91 | touchscip-shell system . . touch. /testokscip-shell filesystem . . `/testok`. |