From owner-freebsd-bugs@FreeBSD.ORG Mon Aug 26 10:30:06 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id BCBB5A81 for ; Mon, 26 Aug 2013 10:30:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A0917227A for ; Mon, 26 Aug 2013 10:30:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r7QAU6dc058029 for ; Mon, 26 Aug 2013 10:30:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r7QAU6JL058028; Mon, 26 Aug 2013 10:30:06 GMT (envelope-from gnats) Resent-Date: Mon, 26 Aug 2013 10:30:06 GMT Resent-Message-Id: <201308261030.r7QAU6JL058028@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Stefan `Sec` Zehl Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 45ACB8DF for ; Mon, 26 Aug 2013 10:27:02 +0000 (UTC) (envelope-from sec@42.org) Received: from ice.42.org (ice.42.org [46.41.23.238]) by mx1.freebsd.org (Postfix) with ESMTP id 0865F221F for ; Mon, 26 Aug 2013 10:27:01 +0000 (UTC) Received: by ice.42.org (Postfix, from userid 1000) id 3A67B2841E; Mon, 26 Aug 2013 12:20:09 +0200 (CEST) Message-Id: <20130826102009.3A67B2841E@ice.42.org> Date: Mon, 26 Aug 2013 12:20:09 +0200 (CEST) From: Stefan `Sec` Zehl To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: bin/181544: file(1) fails to respect -L with --mime-type X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Stefan `Sec` Zehl List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Aug 2013 10:30:06 -0000 >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@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: