$filemode()
DESCRIPTION
for a given path, returns its mode in octal format
SYNOPSIS
$filemode(s)
ARGUMENTS
s - a quoted string, or string expression, representing a file or directory path
EXAMPLES
# pikt +C 'output $filemode("/etc")'
040755
# pikt +C 'output $filemode("/etc/shadow")'
100640
rule
set $fm = $filemode($inlin)
if $fm ne "100640"
output mail "$inlin mode $fm is incorrect, should be "100640"
fi
rule
set $fm = $filemode($inlin)
set $modother = $mid($fm,6,1)
if "762" =~ $modother
output mail "$inlin mode is $fm, $inlin is other-writable!"
fi
// at this point, any $partitions remaining are candidates for
// backing up
rule // check devfile ownerships and permissions
set $devfile = =devfile($mount)
# ifdef debug
output $devfile
# endifdef
if #fileuid($devfile) != 0 // root
output "$mount devfile $devfile not root-owned"
fi
if #filegid($devfile) != =sysgid
output "$mount devfile $devfile not sys-owned"
fi
if $filemode($devfile) ne "060640"
output "$mount devfile $devfile perms not 060640, are $filemode($devfile)"
fi
SEE ALSO
String Functions
Numerical Functions