2015-04-10 16:35:46 +02:00
|
|
|
From: Some One <nobody@opensuse.org>
|
|
|
|
Date: Thu, 9 Apr 2015 14:55:38 +0200
|
|
|
|
Subject: [PATCH] suse-binarieschecks.diff
|
|
|
|
|
2013-06-28 15:29:34 +02:00
|
|
|
===================================================================
|
2015-04-10 16:35:46 +02:00
|
|
|
---
|
|
|
|
BinariesCheck.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
|
1 file changed, 56 insertions(+), 2 deletions(-)
|
|
|
|
|
2019-01-13 15:33:18 +01:00
|
|
|
Index: rpmlint-rpmlint-1.11/BinariesCheck.py
|
2017-09-28 13:35:09 +02:00
|
|
|
===================================================================
|
2019-01-13 15:33:18 +01:00
|
|
|
--- rpmlint-rpmlint-1.11.orig/BinariesCheck.py
|
|
|
|
+++ rpmlint-rpmlint-1.11/BinariesCheck.py
|
2017-09-28 13:35:09 +02:00
|
|
|
@@ -16,7 +16,7 @@ import rpm
|
2011-04-21 12:12:02 +02:00
|
|
|
|
2010-10-15 17:16:45 +02:00
|
|
|
import AbstractCheck
|
|
|
|
import Config
|
2017-09-28 13:35:09 +02:00
|
|
|
-from Filter import addDetails, printError, printWarning
|
|
|
|
+from Filter import addDetails, printError, printWarning, printInfo
|
2010-10-15 17:16:45 +02:00
|
|
|
import Pkg
|
2017-09-28 13:35:09 +02:00
|
|
|
|
|
|
|
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -54,6 +54,9 @@ class BinaryInfo(object):
|
|
|
|
setuid_call_regex = create_regexp_call(r'set(?:res|e)?uid')
|
|
|
|
setgroups_call_regex = create_regexp_call(r'(?:ini|se)tgroups')
|
2017-09-28 13:35:09 +02:00
|
|
|
chroot_call_regex = create_regexp_call('chroot')
|
2017-09-30 10:27:35 +02:00
|
|
|
+ debuginfo_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.debug_.*\s+')
|
|
|
|
+ symtab_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.symtab\s+')
|
2017-09-28 22:25:27 +02:00
|
|
|
+ gethostbyname_call_regex = create_regexp_call(r'(gethostbyname|gethostbyname2|gethostbyaddr|gethostbyname_r|gethostbyname2_r|gethostbyaddr_r)')
|
2017-09-28 13:35:09 +02:00
|
|
|
|
|
|
|
forbidden_functions = Config.getOption("WarnOnFunction")
|
|
|
|
if forbidden_functions:
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -83,7 +86,10 @@ class BinaryInfo(object):
|
2009-09-16 18:41:21 +02:00
|
|
|
self.exec_stack = False
|
2009-03-13 16:06:45 +01:00
|
|
|
self.exit_calls = []
|
2015-11-26 11:24:13 +01:00
|
|
|
self.forbidden_calls = []
|
2010-05-03 23:18:30 +02:00
|
|
|
+ self.calls_gethostbyname = False
|
2009-09-16 18:41:21 +02:00
|
|
|
fork_called = False
|
2017-09-28 22:25:27 +02:00
|
|
|
+ self.debuginfo = False
|
|
|
|
+ self.symtab = False
|
2009-03-13 16:06:45 +01:00
|
|
|
self.tail = ''
|
2019-01-13 15:33:18 +01:00
|
|
|
self.lto_sections = False
|
2008-04-21 18:36:30 +02:00
|
|
|
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -134,6 +140,14 @@ class BinaryInfo(object):
|
2017-09-28 22:25:27 +02:00
|
|
|
self.non_pic = False
|
|
|
|
continue
|
|
|
|
|
|
|
|
+ if BinaryInfo.debuginfo_regex.search(l):
|
|
|
|
+ self.debuginfo = True
|
|
|
|
+ continue
|
|
|
|
+
|
|
|
|
+ if BinaryInfo.symtab_regex.search(l):
|
|
|
|
+ self.symtab = True
|
|
|
|
+ continue
|
|
|
|
+
|
2019-01-13 15:33:18 +01:00
|
|
|
r = BinaryInfo.soname_regex.search(line)
|
2017-09-28 22:25:27 +02:00
|
|
|
if r:
|
|
|
|
self.soname = r.group(1)
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -174,6 +188,9 @@ class BinaryInfo(object):
|
|
|
|
if BinaryInfo.chroot_call_regex.search(line):
|
2017-09-28 20:23:54 +02:00
|
|
|
self.chroot = True
|
2010-05-03 23:18:30 +02:00
|
|
|
|
2017-09-28 20:23:54 +02:00
|
|
|
+ if BinaryInfo.gethostbyname_call_regex.search(l):
|
2010-05-03 23:18:30 +02:00
|
|
|
+ self.calls_gethostbyname = True
|
|
|
|
+
|
2017-09-28 20:23:54 +02:00
|
|
|
if BinaryInfo.forbidden_functions:
|
|
|
|
for r_name, func in BinaryInfo.forbidden_functions.items():
|
2019-01-13 15:33:18 +01:00
|
|
|
ret = func['f_regex'].search(line)
|
|
|
|
@@ -432,13 +449,26 @@ class BinariesCheck(AbstractCheck.Abstra
|
2011-04-21 12:12:02 +02:00
|
|
|
continue
|
|
|
|
|
|
|
|
# stripped ?
|
|
|
|
- if 'not stripped' in pkgfile.magic:
|
2017-09-28 22:25:27 +02:00
|
|
|
+ if ('not stripped' in pkgfile.magic and
|
|
|
|
+ (os.environ.get('BUILD_DIR', '') == '' or
|
|
|
|
+ os.environ.get('BUILD_DEBUG', '') != '')):
|
2011-04-21 12:12:02 +02:00
|
|
|
printWarning(pkg, 'unstripped-binary-or-object', fname)
|
|
|
|
|
|
|
|
# inspect binary file
|
2010-10-14 14:32:03 +02:00
|
|
|
is_shlib = so_regex.search(fname)
|
|
|
|
bin_info = BinaryInfo(pkg, pkgfile.path, fname, is_ar, is_shlib)
|
2008-06-25 19:08:32 +02:00
|
|
|
|
2010-10-14 14:32:03 +02:00
|
|
|
+ # stripped static library
|
|
|
|
+ if is_ar:
|
|
|
|
+ if bin_info.readelf_error:
|
|
|
|
+ pass
|
|
|
|
+ elif not bin_info.symtab:
|
|
|
|
+ printError(pkg, 'static-library-without-symtab', fname)
|
2017-09-28 22:25:27 +02:00
|
|
|
+ elif (not bin_info.debuginfo and
|
|
|
|
+ (os.environ.get('BUILD_DIR', '') == '' or
|
|
|
|
+ os.environ.get('BUILD_DEBUG', '') != '')):
|
2010-10-14 14:32:03 +02:00
|
|
|
+ printWarning(pkg, 'static-library-without-debuginfo', fname)
|
2008-06-25 19:08:32 +02:00
|
|
|
+
|
2010-10-14 14:32:03 +02:00
|
|
|
if is_shlib:
|
|
|
|
has_lib = True
|
2010-05-03 23:18:30 +02:00
|
|
|
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -496,6 +526,10 @@ class BinariesCheck(AbstractCheck.Abstra
|
2015-11-26 11:24:13 +01:00
|
|
|
printWarning(pkg, ec, fname,
|
|
|
|
BinaryInfo.forbidden_functions[ec]['f_name'])
|
2010-10-14 14:32:03 +02:00
|
|
|
|
2011-04-21 12:12:02 +02:00
|
|
|
+ # gethostbyname ?
|
2010-10-14 14:32:03 +02:00
|
|
|
+ if bin_info.calls_gethostbyname:
|
2011-04-21 12:12:02 +02:00
|
|
|
+ printInfo(pkg, 'binary-or-shlib-calls-gethostbyname', fname)
|
2010-05-03 23:18:30 +02:00
|
|
|
+
|
2010-10-14 14:32:03 +02:00
|
|
|
# rpath ?
|
|
|
|
if bin_info.rpath:
|
|
|
|
for p in bin_info.rpath:
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -724,6 +758,14 @@ with the intended shared libraries only.
|
2008-04-21 18:36:30 +02:00
|
|
|
'ldd-failed',
|
|
|
|
'''Executing ldd on this file failed, all checks could not be run.''',
|
2008-06-25 19:08:32 +02:00
|
|
|
|
2008-04-21 18:36:30 +02:00
|
|
|
+'static-library-without-symtab',
|
|
|
|
+'''The static library doesn't contain any symbols and therefore can't be linked
|
|
|
|
+against. This may indicated that it was strip.''',
|
|
|
|
+
|
|
|
|
+'static-library-without-debuginfo',
|
|
|
|
+'''The static library doesn't contain any debuginfo. Binaries linking against
|
|
|
|
+this static library can't be properly debugged.''',
|
2008-06-25 19:08:32 +02:00
|
|
|
+
|
|
|
|
'executable-stack',
|
|
|
|
'''The binary declares the stack as executable. Executable stack is usually an
|
|
|
|
error as it is only needed if the code contains GCC trampolines or similar
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -736,6 +778,10 @@ don\'t define a proper .note.GNU-stack s
|
2010-05-03 23:18:30 +02:00
|
|
|
make the stack executable. Usual suspects include use of a non-GNU linker or
|
|
|
|
an old GNU linker version.''',
|
|
|
|
|
|
|
|
+'binary-or-shlib-calls-gethostbyname',
|
|
|
|
+'''The binary calls gethostbyname(). Please port the code to use
|
|
|
|
+getaddrinfo().''',
|
|
|
|
+
|
|
|
|
'shared-lib-calls-exit',
|
|
|
|
'''This library package calls exit() or _exit(), probably in a non-fork()
|
|
|
|
context. Doing so from a library is strongly discouraged - when a library
|
2019-01-13 15:33:18 +01:00
|
|
|
@@ -754,6 +800,12 @@ that use prelink, make sure that prelink
|
2011-04-21 12:12:02 +02:00
|
|
|
placing a blacklist file in /etc/prelink.conf.d. For more information, see
|
|
|
|
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900#49''',
|
2011-08-12 18:08:36 +02:00
|
|
|
|
2011-04-21 12:12:02 +02:00
|
|
|
+'unstripped-binary-or-object',
|
|
|
|
+'''stripping debug info from binaries happens automatically according to global
|
|
|
|
+project settings. So there's normally no need to manually strip binaries.
|
|
|
|
+Left over unstripped binaries could therefore indicate a bug in the automatic
|
|
|
|
+stripping process.''',
|
2011-08-12 18:08:36 +02:00
|
|
|
+
|
|
|
|
'non-position-independent-executable',
|
|
|
|
'''This executable must be position independent. Check that it is built with
|
|
|
|
-fPIE/-fpie in compiler flags and -pie in linker flags.''',
|