On 2015/09/21 21:31, Jan Stary wrote:
> On Sep 17 07:30:23, st...@cvs.openbsd.org wrote:
> > update to libmagic (file) 5.25
> 
> What is the relation of OpenBSD's own new file(1) to devel/libmagic?

No code relation. libmagic is a package built from sources of the old
file(1) (but only provides the library part, not the executable).

> The magic(5) file used by file(1) is version 4.24, while
> the magic(4) file that comes with libmagic is version 5.25.
> Can libmagic use the /etc/magic that comes with file(1)?
> It doesn't seem to be the case: the naive program below
> shows a bunch of errors when trying to magic_compile(),
> starting with
> 
>       /tmp/magfile, 627: Warning: string modifier `B' invalid
>       /tmp/magfile, 628: Warning: Current entry does not yet have
>       a description for ad ding a MIME type
> 
> Is this the discrepancy in the magic file format version?
> Does that mean that /etc/magic is only used/usable by file(1),
> but ports using libmagic (e.g. sox) can only use the magic file
> that comes with it, /usr/local/share/misc/magic.mgc ?

magic.mgc is compiled from files in magdir in the source tree.
If you take those input files and cat them into a single /etc/magic
file, that file is usable with file(1) in base, but the reverse isn't
true, libmagic's parser doesn't like some of the things in base's
/etc/magic (e.g. lots of the uses of %ld) so for now libmagic needs
to use its own file.

I think it would be nice to get them consolidated, I do have a diff to
update file/magdir in base from the newer magic files in the upstream
distribution, but it does bad things to detection of OpenBSD object
code, e.g.

$ file /bsd /bin/ls /usr/bin/rcs   # current /etc/magic from base
/bsd:         ELF 64-bit LSB executable, x86-64, version 1
/bin/ls:      ELF 64-bit LSB shared object, x86-64, version 1
/usr/bin/rcs: ELF 64-bit LSB shared object, x86-64, version 1

$ file /bsd /bin/ls /usr/bin/rcs  # modified /etc/magic
/bsd:         ELF 64-bit LSB (SYSV)
/bin/ls:      ELF 64-bit LSB (SYSV)
/usr/bin/rcs: ELF 64-bit LSB (SYSV)

Diff available on request if anyone wants to try and figure out those
issues (unsure whether file(1) just doesn't support some things used
in the new magic files, or if it's something else), it's too big to
post here (17K lines).

Reply via email to