xref: /openbsd/regress/sys/ffs/tests/chmod/07.t (revision f6aab3d8)
1#!/bin/sh
2# $FreeBSD: src/tools/regression/fstest/tests/chmod/07.t,v 1.1 2007/01/17 01:42:08 pjd Exp $
3
4desc="chmod returns EPERM if the operation would change the ownership, but the effective user ID is not the super-user"
5
6n0=`namegen`
7n1=`namegen`
8n2=`namegen`
9
10expect 0 mkdir ${n0} 0755
11cdir=`pwd`
12cd ${n0}
13expect 0 mkdir ${n1} 0755
14expect 0 chown ${n1} 65534 65534
15expect 0 -u 65534 -g 65534 create ${n1}/${n2} 0644
16expect 0 -u 65534 -g 65534 chmod ${n1}/${n2} 0642
17expect 0642 stat ${n1}/${n2} mode
18expect EPERM -u 65533 -g 65533 chmod ${n1}/${n2} 0641
19expect 0642 stat ${n1}/${n2} mode
20expect 0 chown ${n1}/${n2} 0 0
21expect EPERM -u 65534 -g 65534 chmod ${n1}/${n2} 0641
22expect 0642 stat ${n1}/${n2} mode
23expect 0 unlink ${n1}/${n2}
24expect 0 rmdir ${n1}
25cd ${cdir}
26expect 0 rmdir ${n0}
27