rpm --dump
will print file mode in 7-digit octal format:
$ rpm -q --dump rpm | grep -E '/usr/bin/rpmdb|/var/lib/rpm ' | cut -d' ' -f1,5
/usr/bin/rpmdb 0100755
/var/lib/rpm 040755
$
What do all those digits mean? I guess some of it will be related to file type, but can I reproduce the same string given I have an existing file and standard command line tools (+ perl/python, etc. if necessary)?
I've looked at rpm(1), which does not reveal anything (only calls the field "mode"), and stat(1), which only mentions the usual 4-digit mode. Closest I got is this other question about 6-digit format on AIX.
Edit: I just noticed it's sometimes 6 digits; question remains mostly the same, though.