View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000523 | file | General | public | 2024-05-07 10:10 | 2024-05-12 18:19 |
Reporter | Heschl | Assigned To | christos | ||
Priority | low | Severity | trivial | Reproducibility | always |
Status | feedback | Resolution | open | ||
Platform | Desktop | OS | Linux | OS Version | Linux 1f59afd788 |
Product Version | 5.44 | ||||
Summary | 0000523: magic.mime file created upon installation but ignored | ||||
Description | Upon installing the file utility (on Debian) multiple files for manually adding file types are created. Among these is `/etc/magic.mime`. This file contains the following per default: ``` # Magic local data for file(1) command. # Insert here your local magic data. Format is described in magic(5). ``` Contrary to its content/documentation however, `/etc/magic.mime` is not consulted for file formats when running the file utility. In fact the `/etc/magic.mime` is not even opened. As per strace: ``` root@1f59afd788b3:/mount# strace --trace file file testing.bin execve("/usr/bin/file", ["file", "testing.bin"], 0x7ffe3b8fddc8 /* 8 vars */) = 0 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=4970, ...}, AT_EMPTY_PATH) = 0 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libmagic.so.1", O_RDONLY|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=174344, ...}, AT_EMPTY_PATH) = 0 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=1922136, ...}, AT_EMPTY_PATH) = 0 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=190456, ...}, AT_EMPTY_PATH) = 0 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libbz2.so.1.0", O_RDONLY|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=74688, ...}, AT_EMPTY_PATH) = 0 openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=121280, ...}, AT_EMPTY_PATH) = 0 newfstatat(AT_FDCWD, "/root/.magic.mgc", 0x7fff06a1bcf0, 0) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/root/.magic", 0x7fff06a1bcf0, 0) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/etc/magic.mgc", O_RDONLY) = -1 ENOENT (No such file or directory) newfstatat(AT_FDCWD, "/etc/magic", {st_mode=S_IFREG|0644, st_size=158, ...}, 0) = 0 openat(AT_FDCWD, "/etc/magic", O_RDONLY) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=158, ...}, AT_EMPTY_PATH) = 0 openat(AT_FDCWD, "/usr/share/misc/magic.mgc", O_RDONLY) = 3 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=8281024, ...}, AT_EMPTY_PATH) = 0 newfstatat(1, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}, AT_EMPTY_PATH) = 0 newfstatat(AT_FDCWD, "testing.bin", {st_mode=S_IFREG|0664, st_size=22, ...}, AT_SYMLINK_NOFOLLOW) = 0 openat(AT_FDCWD, "testing.bin", O_RDONLY|O_NONBLOCK|O_CLOEXEC) = 3 newfstatat(3, "", {st_mode=S_IFREG|0664, st_size=22, ...}, AT_EMPTY_PATH) = 0 testing.bin: My Custom Mime from /etc/magic +++ exited with 0 +++ ``` It is somewhat confusing for newcomers to libmagic to have the package create a file, which, as per its content is consulted when evaluating file formats, but is in fact not. | ||||
Steps To Reproduce | 1. Install the package 2. This automatically creates /etc/magic.mime 3. Add a custom file format description to /etc/magic.mime 4. The custom file format description is ignored | ||||
Tags | No tags attached. | ||||