==== chmod_abs_0000 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/chmod 0644 regress/file
/bin/chmod 0000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]

==== chmod_abs_0644 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/chmod 0644 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100644' ]

==== chmod_sym_0644 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/chmod u=rw,go=r regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100644' ]

==== chmod_sym_0000 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/chmod 0644 regress/file
/bin/chmod a-rwx regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]

==== chmod_R_0755 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]

==== chmod_RP_0755 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -RP 0755 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]

==== chmod_RH_0755 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -RH 0755 regress/linked_dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]

==== chmod_RL_0755 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -RL 0755 regress/linked_dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40755' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100755' ]

==== chmod_h_abs_0000 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h 0000 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120000' ]

==== chmod_h_abs_0644 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h 0644 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120644' ]

==== chmod_h_sym_0000 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h a-rwx regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120000' ]

==== chmod_h_sym_0644 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h u=rw,go=r regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120644' ]

==== chmod_h_go_minus_r ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h go-r regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120711' ]

==== chmod_h_go_minus_rx ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h go-rx regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120700' ]

==== chmod_h_go_plus_r ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h go+r regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_h_go_plus_rx ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod -h go+rx regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_abs_0000 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod 0000 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_abs_0644 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod 0644 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100644' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_sym_0000 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod a-rwx regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_sym_0644 ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod u=rw,go=r regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100644' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_go_minus_r ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod go-r regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_go_minus_rx ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod go-rx regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_go_plus_r ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod go+r regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100044' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_via_link_go_plus_rx ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
/bin/chmod -h 755 regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]
/bin/chmod go+rx regress/link
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100055' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link` == '120755' ]

==== chmod_error ====
/bin/chmod foo bar 2>chmod.err || true
/usr/bin/diff -up /home/src/regress/bin/chmod/chmod.error chmod.err

==== chgrp_error ====
doas -n /bin/chgrp __hopefully_not_existing_group bar 2>chgrp.err || true
/usr/bin/diff -up /home/src/regress/bin/chmod/chgrp.error chgrp.err

==== chown_error ====
doas -n /sbin/chown __hopefully_not_existing_user bar 2>chown.err || true
/usr/bin/diff -up /home/src/regress/bin/chmod/chown.error chown.err

==== chflags ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/usr/bin/chflags dump regress/file
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '0' ]
/usr/bin/chflags nodump regress/file
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '1' ]

==== chflags_no ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/usr/bin/chflags dump regress/file
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '0' ]
/usr/bin/chflags nodump regress/file
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '1' ]
/usr/bin/chflags dump regress/file
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '0' ]

==== chflags_R ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
/usr/bin/chflags -RL dump regress
/usr/bin/chflags -R nodump regress/dir
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file1` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file2` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/link_target_file` == '0' ]

==== chflags_RP ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
/usr/bin/chflags -RL dump regress
/usr/bin/chflags -RP nodump regress/dir
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file1` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file2` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/link_target_file` == '0' ]

==== chflags_RH ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
/usr/bin/chflags -RL dump regress
/usr/bin/chflags -RH nodump regress/linked_dir
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file1` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file2` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/link_target_file` == '0' ]

==== chflags_RL ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
/usr/bin/chflags -RL dump regress
/usr/bin/chflags -RL nodump regress/linked_dir
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file1` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir/file2` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/dir` == '1' ]
[ `doas -n /usr/bin/stat -f '%f' regress/link_target_file` == '1' ]

==== chflags_via_link ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
/usr/bin/chflags dump regress/file
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '0' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/link
chflags -h uchg regress/link
chflags nodump regress/link
[ `doas -n /usr/bin/stat -f '%f' regress/link` == '2' ]
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '1' ]
chflags -h nouchg regress/link
chflags dump regress/link
[ `doas -n /usr/bin/stat -f '%f' regress/link` == '0' ]
[ `doas -n /usr/bin/stat -f '%f' regress/file` == '0' ]

==== chflags_error ====
/usr/bin/chflags foo bar 2>chflags.err || true
/usr/bin/diff -up /home/src/regress/bin/chmod/chflags.error chflags.err

==== chgrp_id ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
doas -n /bin/chgrp 32767 regress/file
[ `doas -n /usr/bin/stat -f '%g' regress/file` == 32767 ]

==== chgrp_name ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
doas -n /bin/chgrp nobody regress/file
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'nobody' ]

==== chgrp_symlink ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/symlink
doas -n /sbin/chown -h root:wheel regress/symlink
[ `doas -n /usr/bin/stat -f '%Su' regress/symlink` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/symlink` == 'wheel' ]
doas -n /bin/chgrp nobody regress/symlink
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/symlink` == 'wheel' ]

==== chgrp_h_symlink ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/symlink
doas -n /sbin/chown -h root:wheel regress/symlink
[ `doas -n /usr/bin/stat -f '%Su' regress/symlink` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/symlink` == 'wheel' ]
doas -n /bin/chgrp -h nobody regress/symlink
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/symlink` == 'nobody' ]

==== chgrp_R ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /bin/chgrp -R nobody regress/dir
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/link_target_file` == 'wheel' ]

==== chgrp_RP ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /bin/chgrp -RP nobody regress/dir
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/link_target_file` == 'wheel' ]

==== chgrp_RH ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /bin/chgrp -RH nobody regress/linked_dir
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/link_target_file` == 'wheel' ]

==== chgrp_RL ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /bin/chgrp -RL nobody regress/linked_dir
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/link_target_file` == 'nobody' ]

==== chown_id ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
doas -n /sbin/chown 32767 regress/file
[ `doas -n /usr/bin/stat -f '%u' regress/file` == 32767 ]

==== chown_name ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
doas -n /sbin/chown nobody regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'nobody' ]

==== chown_symlink ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/symlink
doas -n /sbin/chown -h root:wheel regress/symlink
[ `doas -n /usr/bin/stat -f '%Su' regress/symlink` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/symlink` == 'wheel' ]
doas -n /sbin/chown nobody regress/symlink
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/symlink` == 'root' ]

==== chown_h_symlink ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress
/usr/bin/touch regress/file
/bin/chmod 000 regress/file
[ `doas -n /usr/bin/stat -f '%p' regress/file` == '100000' ]
doas -n /sbin/chown root:wheel regress/file
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/file` == 'wheel' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/file regress/symlink
doas -n /sbin/chown -h root:wheel regress/symlink
[ `doas -n /usr/bin/stat -f '%Su' regress/symlink` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Sg' regress/symlink` == 'wheel' ]
doas -n /sbin/chown -h nobody regress/symlink
[ `doas -n /usr/bin/stat -f '%Su' regress/file` == 'root' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/symlink` == 'nobody' ]

==== chown_R ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /sbin/chown -R nobody regress/dir
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/link_target_file` != 'nobody' ]

==== chown_RP ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /sbin/chown -RP nobody regress/dir
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/link_target_file` != 'nobody' ]

==== chown_RH ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /sbin/chown -RH nobody regress/linked_dir
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/link_target_file` != 'nobody' ]

==== chown_RL ====
doas -n /bin/rm -f *.err
/bin/chmod -R 0700 regress 2>/dev/null || true
doas -n /bin/rm -rf regress
/bin/mkdir -p regress/dir
/usr/bin/touch regress/dir/file1
/usr/bin/touch regress/dir/file2
/bin/chmod 000 regress/dir/file1
/bin/chmod 000 regress/dir/file2
/usr/bin/touch regress/link_target_file
/bin/chmod 0600 regress/link_target_file
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file1` == '100000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/dir/file2` == '100000' ]
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/link_target_file regress/dir/linked_file
/bin/ln -s /home/src/regress/bin/chmod/obj/regress/dir regress/linked_dir
/bin/chmod 000 regress/dir
[ `doas -n /usr/bin/stat -f '%p' regress/dir` == '40000' ]
[ `doas -n /usr/bin/stat -f '%p' regress/link_target_file` == '100600' ]
/bin/chmod -R 0755 regress
doas -n /sbin/chown -RL root:wheel regress
doas -n /sbin/chown -RL nobody regress/linked_dir
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file1` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir/file2` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/dir` == 'nobody' ]
[ `doas -n /usr/bin/stat -f '%Su' regress/link_target_file` == 'nobody' ]