Bug 181544

Summary: [patch] file(1) fails to respect -L with --mime-type
Product: Base System Reporter: sec
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me Keywords: patch
Priority: Normal    
Version: 8.4-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description sec 2013-08-26 11:30:06 UTC
file (as in /usr/bin/file) does not honor "-L" when using mime type output.

As the ports makefile checks for shared library existance vie "file -L
--mime-type" = "application/x-sharedlib" this results in ports trying to
re-install already existing libraries.

Fix: Honestly, I'm not sure what the "&= MAGIC_MIME_TYPE" is supposed to do here,
but it actually deletes all other options from flags.

Someone with a better understanding of the code might want to check if the
code maybe was actually supposed to be "ms->flags |= MAGIC_MIME_TYPE" here?

I just added MAGIC_SYMLINK here to keep it from being deleted to fix the
problem at hand.
How-To-Repeat: 
run file with "-L" and "--mime-type" on a symlink.

without "-L" it's ok:

ice:~>file -b --mime-type /usr/local/lib/libdb-4.2.so.2 
application/x-symlink

actual output:

ice:~>file -b -L --mime-type /usr/local/lib/libdb-4.2.so.2                   :(
application/x-symlink

expected output:

ice:~>LD_LIBRARY_PATH=/usr/obj/usr/src/lib/libmagic file -b -L --mime-type /usr/local/lib/libdb-4.2.so.2
application/x-sharedlib
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:58:37 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:39:15 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>