# Fail to get perms on non-existent file. expect getperm failed: No such file or directory getperm /test expect getperm failed: No such file or directory getperm /dir/test # Create file: inherits from root (0 READ) write /test contents expect 0 READ getperm /test setid 1 expect 0 READ getperm /test expect contents read /test expect write failed: Permission denied write /test contents # Take away read access to file. setid 0 setperm /test 0 NONE setid 1 expect getperm failed: Permission denied getperm /test expect read failed: Permission denied read /test expect write failed: Permission denied write /test contents # Grant everyone write access to file. setid 0 setperm /test 0 WRITE setid 1 expect getperm failed: Permission denied getperm /test expect read failed: Permission denied read /test write /test contents2 setid 0 expect contents2 read /test # Grant everyone both read and write access. setperm /test 0 READ/WRITE setid 1 expect 0 READ/WRITE getperm /test expect contents2 read /test write /test contents3 expect contents3 read /test # Change so that user 1 owns it, noone else can do anything. setid 0 setperm /test 1 NONE setid 1 expect 1 NONE getperm /test expect contents3 read /test write /test contents4 # User 2 can do nothing. setid 2 expect setperm failed: Permission denied setperm /test 2 NONE expect getperm failed: Permission denied getperm /test expect read failed: Permission denied read /test expect write failed: Permission denied write /test contents4 # Tools can always access things. setid 0 expect 1 NONE getperm /test expect contents4 read /test write /test contents5