richardlehane / siegfried

signature-based file format identification
http://www.itforarchivists.com/siegfried
Apache License 2.0
214 stars 30 forks source link

Continue if SF encounters a directory for which the current user doesn't have read permissions #246

Closed ross-spencer closed 1 month ago

ross-spencer commented 3 months ago

I just noticed SF will stop if it encounters a directory without permissions it will return a fatal error and stop scanning.

$ sf *
---
siegfried   : 1.11.0
scandate    : 2024-03-24T15:14:17+01:00
signature   : default.sig
created     : 2023-11-05T19:42:07+01:00
identifiers : 
  - name    : 'pronom'
    details : 'DROID_SignatureFile_V114.xml; container-signature-20230822.xml'
2024/03/24 15:14:17 [FATAL] file access error for dir_0770_perms: open dir_0770_perms: permission denied

More idiomatically perhaps, SF should be able to report this as an error and move onto the remainder of the location to be scanned.

To recreate, create a directory and some content. Add another directory, e.g. a_directory so it appears lexicographically first. Change the ownership to another owner, e.g. sudo chown root:root a_directory and change its permissions, e.g. sudo chmod 0770 a_directory and try to scan. SF won't be able to scan the directory (expected) but will terminate the rest of the scan early (less expected).

richardlehane commented 1 month ago

sorry @ross-spencer this issue slipped under my radar - did you try the -coe flag for this?

ross-spencer commented 1 month ago

Not a problem, and good call! This resolves the issue!

quick test on my tmp dir like above, and I get 1495 files without -coe and then 1521 with -coe