Skip to content

Commit 94980eb

Browse files
committed
Fix an issue where a UID could match ZFS bytes
1 parent 6743fd0 commit 94980eb

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ZFS-Quota-Client.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
# IPPP, Durham University
55

66
servers[0]="/mt/home"
7-
servers[1]="/mt/fielding-home"
8-
servers[2]="/mt/user-batch"
9-
servers[3]="/mt/group-batch"
7+
servers[1]="/mt/storage"
108

119
if [ -z "$1" ]; then
1210
QUSER=$USER
@@ -38,14 +36,19 @@ printf "\n Quota Report for $QUSER\n"
3836
printf ' %-30s %-15s %-15s %-25s\n' "Mount Point" "Used" "Total" "Last Checked";
3937
QUID=$(id -u $QUSER)
4038
for i in "${servers[@]}"; do
41-
zquota=$(cat $i/quota.zfs 2>/dev/null | grep -m 1 -w $QUID);
39+
zquota=$(cat $i/quota.zfs 2>/dev/null | grep $QUID);
4240
if [[ ! -z "$zquota" ]]; then
43-
zused=$(echo $zquota | awk -F'::' '{print $2}' | numfmt --to=iec);
44-
ztotal=$(echo $zquota | awk -F'::' '{print $3}');
45-
if [[ $ztotal -ne "none" ]]; then
46-
ztotal=$(echo $ztotal | numfmt --to=iec);
47-
fi
48-
zperc=$(echo $zquota | awk -F'::' '{print $4}');
41+
for ii in $zquota; do
42+
zuid=$(echo $ii | awk -F'::' '{print $1}')
43+
if [[ $zuid == $QUID ]]; then
44+
zused=$(echo $ii | awk -F'::' '{print $2}' | numfmt --to=iec);
45+
ztotal=$(echo $ii | awk -F'::' '{print $3}');
46+
if [[ $ztotal -ne "none" ]]; then
47+
ztotal=$(echo $ztotal | numfmt --to=iec);
48+
fi
49+
zperc=$(echo $ii | awk -F'::' '{print $4}');
50+
fi
51+
done
4952
zage=$(date +"%c" -d @$(stat -c %Z $i/quota.zfs))
5053
printf ' %-30s %-15s %-15s %-25s\n' "$i" "$zused ($zperc)" "$ztotal" "$zage";
5154
fi

0 commit comments

Comments
 (0)