Menu

#86 libmagic results as 'file' results with local config

Next Release
open
nobody
None
9
2025-01-28
2025-01-28
rno
No

hi,

tested with v5.2.1

libmagic file command line results and worker results are another if having a local /etc/magic config with entries.

searching about it I found it's simple to do,
with adding magic_getpath(NULL,0) to the magic_load() call.

in worker :
magic_db.cc:48: magic_load( m_magic_cookie, magic_getpath(NULL,0) );

->then libmagic 'file' command and worker return the same.

magic_getpath() description can be found in libmagic manual page, and should work with any linux distros.

a way to test with a png image:

file bot_grey.png
bot_grey.png: PNG image data, 196 x 158, 8-bit/color RGBA, non-interlaced

adding in /etc/magic:
0 string \x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0DIHDR PNG with etc magic

file bot_grey.png
bot_grey.png: PNG with etc magic

Discussion


Log in to post a comment.

MongoDB Logo MongoDB