#! /bin/bash

. ${0%/*}/test-lib.sh

require_runas
require_richacls
use_testdir

export LC_ALL=C

ncheck "touch a"

# Without write access, the ctime cannot be changed
runas -u 99 -g 99
check "touch a || :" <<EOF
touch: cannot touch 'a': Permission denied
EOF

runas
ncheck "setrichacl --set 'u:99:rw::allow' a"

# With write access, the ctime can be set to the current time, but not to
# any other time
runas -u 99 -g 99
ncheck "touch a"
check "touch -d '1 hour ago' a || :" <<EOF
touch: setting times of 'a': Operation not permitted
EOF

runas
ncheck "setrichacl --set 'u:99:rwA::allow' a"

# With set_attributes access, the ctime can be set to an arbitrary time
runas -u 99 -g 99
ncheck "touch -d '1 hour ago' a"
