Compare commits
10 Commits
79f2906b9e
...
438915eda3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
438915eda3 | ||
|
|
3a02c11099 | ||
|
|
c7ccd582be | ||
|
|
f68f4bb7bc | ||
|
|
e030e54c58 | ||
|
|
b761a02542 | ||
|
|
e1bad8b1e9 | ||
|
|
fcf4f21ca1 | ||
|
|
61ac7a68e0 | ||
|
|
c0b56a42d2 |
@ -1,4 +1,4 @@
|
||||
From ab2220a8d4c1b52d12e9f3e0fa7a132e30849ee5 Mon Sep 17 00:00:00 2001
|
||||
From bba354e18cfac11cc69a1032cbda23960b7c05d0 Mon Sep 17 00:00:00 2001
|
||||
From: Jan Kaluza <hanzz.k@gmail.com>
|
||||
Date: Thu, 15 Dec 2011 16:15:41 +0100
|
||||
Subject: [PATCH] file-localmagic.patch
|
||||
@ -9,9 +9,8 @@ Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
---
|
||||
magic/magic.local | 3 +++
|
||||
src/Makefile.am | 2 +-
|
||||
src/Makefile.in | 2 +-
|
||||
src/apprentice.c | 2 +-
|
||||
4 files changed, 6 insertions(+), 3 deletions(-)
|
||||
3 files changed, 5 insertions(+), 2 deletions(-)
|
||||
create mode 100644 magic/magic.local
|
||||
|
||||
diff --git a/magic/magic.local b/magic/magic.local
|
||||
@ -24,7 +23,7 @@ index 0000000..283a863
|
||||
+# Insert here your local magic data. Format is described in magic(5).
|
||||
+
|
||||
diff --git a/src/Makefile.am b/src/Makefile.am
|
||||
index 3f67f2c..b43cb8e 100644
|
||||
index 96749b5..e3eaf36 100644
|
||||
--- a/src/Makefile.am
|
||||
+++ b/src/Makefile.am
|
||||
@@ -1,4 +1,4 @@
|
||||
@ -33,30 +32,17 @@ index 3f67f2c..b43cb8e 100644
|
||||
lib_LTLIBRARIES = libmagic.la
|
||||
nodist_include_HEADERS = magic.h
|
||||
|
||||
diff --git a/src/Makefile.in b/src/Makefile.in
|
||||
index 59f3b5e..a8f56cf 100644
|
||||
--- a/src/Makefile.in
|
||||
+++ b/src/Makefile.in
|
||||
@@ -356,7 +356,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
-MAGIC = $(pkgdatadir)/magic
|
||||
+MAGIC = /etc/magic:$(pkgdatadir)/magic
|
||||
lib_LTLIBRARIES = libmagic.la
|
||||
nodist_include_HEADERS = magic.h
|
||||
AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
|
||||
diff --git a/src/apprentice.c b/src/apprentice.c
|
||||
index 1437bcc..b609dd1 100644
|
||||
index db21787..5134682 100644
|
||||
--- a/src/apprentice.c
|
||||
+++ b/src/apprentice.c
|
||||
@@ -460,7 +460,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
|
||||
@@ -496,7 +496,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action)
|
||||
#ifndef COMPILE_ONLY
|
||||
map = apprentice_map(ms, fn);
|
||||
if (map == NULL) {
|
||||
- if (ms->flags & MAGIC_CHECK)
|
||||
+ if (ms->flags & MAGIC_CHECK && strcmp("/etc/magic", fn) != 0)
|
||||
file_magwarn(ms, "using regular magic file `%s'", fn);
|
||||
file_magwarn(NULL, "using regular magic file `%s'", fn);
|
||||
map = apprentice_load(ms, fn, action);
|
||||
if (map == NULL)
|
||||
--
|
||||
|
||||
@ -1,133 +0,0 @@
|
||||
From 363d7fcf703ad3ebf37b45693b2c9e43eb8b4176 Mon Sep 17 00:00:00 2001
|
||||
From: Christos Zoulas <christos@zoulas.com>
|
||||
Date: Sat, 22 Aug 2020 18:04:18 +0000
|
||||
Subject: [PATCH] Improve detection of static-pie binaries, and don't call them
|
||||
"dynamically linked", but call them "static-pie" linked.
|
||||
|
||||
---
|
||||
src/readelf.c | 37 ++++++++++++++++++++++++++-----------
|
||||
1 file changed, 26 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/src/readelf.c b/src/readelf.c
|
||||
index cf1dc91..d390d5f 100644
|
||||
--- a/src/readelf.c
|
||||
+++ b/src/readelf.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
-FILE_RCSID("@(#)$File: readelf.c,v 1.173 2020/06/07 22:12:54 christos Exp $")
|
||||
+FILE_RCSID("@(#)$File: readelf.c,v 1.174 2020/08/22 18:04:18 christos Exp $")
|
||||
#endif
|
||||
|
||||
#ifdef BUILTIN_ELF
|
||||
@@ -1099,7 +1099,7 @@ do_auxv_note(struct magic_set *ms, unsigned char *nbuf, uint32_t type,
|
||||
|
||||
private size_t
|
||||
dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
|
||||
- int clazz, int swap)
|
||||
+ int clazz, int swap, int *pie, size_t *need)
|
||||
{
|
||||
Elf32_Dyn dh32;
|
||||
Elf64_Dyn dh64;
|
||||
@@ -1117,11 +1117,15 @@ dodynamic(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
|
||||
|
||||
switch (xdh_tag) {
|
||||
case DT_FLAGS_1:
|
||||
+ *pie = 1;
|
||||
if (xdh_val & DF_1_PIE)
|
||||
ms->mode |= 0111;
|
||||
else
|
||||
ms->mode &= ~0111;
|
||||
break;
|
||||
+ case DT_NEEDED:
|
||||
+ (*need)++;
|
||||
+ break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1608,9 +1612,10 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
}
|
||||
|
||||
/*
|
||||
- * Look through the program headers of an executable image, searching
|
||||
- * for a PT_INTERP section; if one is found, it's dynamically linked,
|
||||
- * otherwise it's statically linked.
|
||||
+ * Look through the program headers of an executable image, to determine
|
||||
+ * if it is statically or dynamically linked. If it has a dynamic section,
|
||||
+ * it is pie, and does not have an interpreter or needed libraries, we
|
||||
+ * call it static pie.
|
||||
*/
|
||||
private int
|
||||
dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
@@ -1619,12 +1624,13 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
{
|
||||
Elf32_Phdr ph32;
|
||||
Elf64_Phdr ph64;
|
||||
- const char *linking_style = "statically";
|
||||
+ const char *linking_style;
|
||||
unsigned char nbuf[BUFSIZ];
|
||||
char ibuf[BUFSIZ];
|
||||
char interp[BUFSIZ];
|
||||
ssize_t bufsize;
|
||||
- size_t offset, align, len;
|
||||
+ size_t offset, align, len, need = 0;
|
||||
+ int pie = 0, dynamic = 0;
|
||||
|
||||
if (num == 0) {
|
||||
if (file_printf(ms, ", no program header") == -1)
|
||||
@@ -1654,7 +1660,6 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
switch (xph_type) {
|
||||
case PT_DYNAMIC:
|
||||
doread = 1;
|
||||
- linking_style = "dynamically";
|
||||
break;
|
||||
case PT_NOTE:
|
||||
if (sh_num) /* Did this through section headers */
|
||||
@@ -1694,6 +1699,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
/* Things we can determine when we seek */
|
||||
switch (xph_type) {
|
||||
case PT_DYNAMIC:
|
||||
+ dynamic = 1;
|
||||
offset = 0;
|
||||
// Let DF_1 determine if we are PIE or not.
|
||||
ms->mode &= ~0111;
|
||||
@@ -1701,7 +1707,8 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
if (offset >= CAST(size_t, bufsize))
|
||||
break;
|
||||
offset = dodynamic(ms, nbuf, offset,
|
||||
- CAST(size_t, bufsize), clazz, swap);
|
||||
+ CAST(size_t, bufsize), clazz, swap,
|
||||
+ &pie, &need);
|
||||
if (offset == 0)
|
||||
break;
|
||||
}
|
||||
@@ -1710,6 +1717,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
break;
|
||||
|
||||
case PT_INTERP:
|
||||
+ need++;
|
||||
if (ms->flags & MAGIC_MIME)
|
||||
continue;
|
||||
if (bufsize && nbuf[0]) {
|
||||
@@ -1744,8 +1752,15 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
}
|
||||
if (ms->flags & MAGIC_MIME)
|
||||
return 0;
|
||||
- if (file_printf(ms, ", %s linked", linking_style)
|
||||
- == -1)
|
||||
+ if (dynamic) {
|
||||
+ if (pie && need == 0)
|
||||
+ linking_style = "static-pie";
|
||||
+ else
|
||||
+ linking_style = "dynamically";
|
||||
+ } else {
|
||||
+ linking_style = "statically";
|
||||
+ }
|
||||
+ if (file_printf(ms, ", %s linked", linking_style) == -1)
|
||||
return -1;
|
||||
if (interp[0])
|
||||
if (file_printf(ms, ", interpreter %s",
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
BIN
file-5.39.tar.gz
BIN
file-5.39.tar.gz
Binary file not shown.
BIN
file-5.45.tar.gz
Normal file
BIN
file-5.45.tar.gz
Normal file
Binary file not shown.
32
file.spec
32
file.spec
@ -1,16 +1,15 @@
|
||||
Name: file
|
||||
Version: 5.39
|
||||
Release: 5
|
||||
Version: 5.45
|
||||
Release: 1
|
||||
Summary: A tool to identify the type of a particular file type
|
||||
License: BSD
|
||||
URL: http://www.darwinsys.com/file/
|
||||
Source0: ftp://ftp.astron.com/pub/file/file-%{version}.tar.gz
|
||||
|
||||
Patch1: 0001-file-localmagic.patch
|
||||
Patch2: 0002-improve-detection-of-static-pie-binaries.patch
|
||||
|
||||
Requires: %{name}-libs = %{version}-%{release}
|
||||
BuildRequires: autoconf automake libtool git zlib-devel
|
||||
BuildRequires: autoconf automake libtool zlib-devel make
|
||||
|
||||
%description
|
||||
The program checks to see if the file is empty,or if
|
||||
@ -55,7 +54,7 @@ This package contains the Python 3 bindings to access to the libmagic
|
||||
API. The libmagic library is also used by the familiar file(1) command.
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -S git
|
||||
%autosetup -p1
|
||||
|
||||
iconv doc/libmagic.man -f iso-8859-1 -t utf-8 -o doc/libmagic.man_
|
||||
touch -r doc/libmagic.man doc/libmagic.man_
|
||||
@ -83,6 +82,7 @@ cd -
|
||||
|
||||
%make_install
|
||||
rm -f ${RPM_BUILD_ROOT}%{_libdir}/*.la
|
||||
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}
|
||||
cp -dR ./magic/magic.local ${RPM_BUILD_ROOT}%{_sysconfdir}/magic
|
||||
cat magic/Magdir/* > ${RPM_BUILD_ROOT}%{_datadir}/misc/magic
|
||||
ln -s misc/magic ${RPM_BUILD_ROOT}%{_datadir}/magic
|
||||
@ -95,16 +95,17 @@ cd %{py3dir}
|
||||
%ldconfig_scriptlets libs
|
||||
|
||||
%check
|
||||
make check
|
||||
export LD_LIBRARY_PATH=$PWD/src/.libs
|
||||
make -C tests check
|
||||
|
||||
%files
|
||||
%doc ChangeLog README
|
||||
%doc ChangeLog
|
||||
%license COPYING
|
||||
%config(noreplace) %{_sysconfdir}/magic
|
||||
%{_bindir}/*
|
||||
|
||||
%files libs
|
||||
%doc ChangeLog README
|
||||
%doc ChangeLog
|
||||
%license COPYING
|
||||
%{_libdir}/*so.*
|
||||
%{_datadir}/magic*
|
||||
@ -129,6 +130,21 @@ make check
|
||||
%{python3_sitelib}/__pycache__/*
|
||||
|
||||
%changelog
|
||||
* Mon Oct 23 2023 li weigang - <weigangli99@gmail.com> - 5.45-1
|
||||
- update to version 5.45
|
||||
|
||||
* Thu Feb 9 2023 lihaoxiang <lihaoxiang9@huawei.com> - 5.44-1
|
||||
- upgrade to 5.44
|
||||
|
||||
* Wed Oct 19 2022 lihaoxiang <lihaoxiang9@huawei.com> - 5.41-2
|
||||
- fix typos fxlb
|
||||
|
||||
* Fri Nov 26 2021 yanglongkang <yanglongkang@huawei.com> - 5.41-1
|
||||
- update to 5.41
|
||||
|
||||
* Fri Jul 30 2021 chenyanpanHW <chenyanpan@huawei.com> - 5.39-6
|
||||
- DESC: delete -S git from %autosetup, and delete BuildRequires git
|
||||
|
||||
* Fri Oct 30 2020 yanglongkang <yanglongkang@huawei.com> - 5.39-5
|
||||
- remove python2 dependency
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user