bin/181544: file(1) fails to respect -L with --mime-type
Stefan `Sec` Zehl
sec at 42.org
Mon Aug 26 10:30:06 UTC 2013
>Number: 181544
>Category: bin
>Synopsis: file(1) fails to respect -L with --mime-type
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Aug 26 10:30:06 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator: Stefan `Sec` Zehl
>Release: FreeBSD 8.4-STABLE amd64
>Organization:
>Environment:
System: FreeBSD ice 8.4-STABLE FreeBSD 8.4-STABLE #23 r252204: Tue Jun 25 14:30:35 CEST 2013 root at ice:/usr/obj/usr/src/sys/ICE amd64
FreeBSD-8 stable. From checking svnweb this problem might also exist on
FreeBSD-9, but somebody needs to confirm this.
>Description:
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.
>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
>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.
--- contrib/file/apprentice.c.org 2013-06-18 18:14:45.000000000 +0200
+++ contrib/file/apprentice.c 2013-08-26 12:01:20.000000000 +0200
@@ -2231,7 +2231,7 @@
if (ms->flags & MAGIC_MIME) {
asprintf(&buf, "%.*s.mime%s", (int)(q - fn), fn, ext);
if (access(buf, R_OK) != -1) {
- ms->flags &= MAGIC_MIME_TYPE;
+ ms->flags &= MAGIC_MIME_TYPE | MAGIC_SYMLINK;
return buf;
}
free(buf);
@@ -2240,7 +2240,7 @@
/* Compatibility with old code that looked in .mime */
if (strstr(p, ".mime") != NULL)
- ms->flags &= MAGIC_MIME_TYPE;
+ ms->flags &= MAGIC_MIME_TYPE | MAGIC_SYMLINK;
return buf;
}
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list