Merge branch 'alt', remote-tracking branch 'ldv@ALT/maint' into altM/80P

This commit is contained in:
Ivan Zakharyaschev 2016-12-09 03:27:26 +03:00
commit f415265c95
6 changed files with 83 additions and 27 deletions

View File

@ -939,6 +939,7 @@ AC_OUTPUT([ Doxyfile Makefile rpmrc macros platform rpmpopt
scripts/find-debuginfo-files
scripts/find-scriptlet-requires
scripts/fixup-binconfig
scripts/fixup-libraries
scripts/fixup-libtool
scripts/fixup-pkgconfig
scripts/fixup-desktop

View File

@ -3,7 +3,7 @@
Name: rpm
Version: 4.0.4
Release: alt100.95.M80P.1
Release: alt100.96.M80P.1
%define ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
%define get_dep() %(rpm -q --qf '%%{NAME} >= %%|SERIAL?{%%{SERIAL}:}|%%{VERSION}-%%{RELEASE}' %1 2>/dev/null || echo '%1 >= unknown')
@ -478,6 +478,7 @@ fi
%rpmattr %_rpmlibdir/brp.d/*
%rpmattr %_rpmlibdir/*_files
%rpmattr %_rpmlibdir/cpp.*
%rpmattr %_rpmlibdir/is_elf_so_executable
%rpmattr %_rpmlibdir/ldd
%rpmattr %_rpmlibdir/rpm2cpio.sh
%rpmattr %_rpmlibdir/find-lang
@ -532,6 +533,10 @@ fi
%_bindir/rpm2cpio.static
%changelog
* Tue Dec 06 2016 Dmitry V. Levin <ldv@altlinux.org> 4.0.4-alt100.96.2
- fixup-libraries: fixed recognition of PIEs.
- verify-elf: treat PIEs as executables in the check for unresolved symbols.
* Thu Dec 1 2016 Ivan Zakharyaschev <imz@altlinux.org> 4.0.4-alt100.95.M80P.1
- Build for p8.

View File

@ -18,6 +18,7 @@ EXTRA_DIST = \
fixup-binconfig fixup-pkgconfig fixup-libtool fixup-libraries \
fixup-desktop fixup-desktop.awk \
files.req files.req.files 0common-files.req.list \
is_elf_so_executable \
ldd lib.req lib.req.files lib.prov lib.prov.files shlib.req.awk \
pam.req pam.req.files pam.prov pam.prov.files \
percolate \
@ -50,6 +51,7 @@ config_SCRIPTS = \
fixup-binconfig fixup-pkgconfig fixup-libtool fixup-libraries \
fixup-desktop fixup-desktop.awk \
files.req files.req.files \
is_elf_so_executable \
ldd lib.req lib.req.files lib.prov lib.prov.files shlib.req.awk \
pam.req pam.req.files pam.prov pam.prov.files \
pkgconfig.req pkgconfiglib.req pkgconfig.req.files \

View File

@ -2,7 +2,7 @@
#
# fixup-shared - fix permissions of libraries.
#
# Copyright (C) 2003-2005,2008 Dmitry V. Levin <ldv@altlinux.org>
# Copyright (C) 2003-2016 Dmitry V. Levin <ldv@altlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -26,24 +26,8 @@ for file in "$@"; do
chmod -v u+w,a-x,ug-s "$file"
;;
ELF\ *\ shared\ object,\ *|*\ ELF\ *\ shared\ object,\ *)
file_header="$(readelf --wide --file-header "$file")" || continue
entry=`printf %s "$file_header" |sed -ne 's/^ \+Entry point address: \+0x0*\([0-9a-f]\+\)$/\1/p'`
[ -n "$entry" ] || continue
section_header="$(readelf --wide --sections "$file")" || continue
# See: comm -12 <(fgrep -l .interp /usr/lib/ldscripts/*) <(fgrep -le --shared /usr/lib/ldscripts/*)
if printf %s "$section_header" |fgrep -qs ' .interp '; then
continue
fi
text=`printf %s "$section_header" |sed -ne 's/^ *\[ *[0-9]\+\] \.text \+PROGBITS \+0*\([0-9a-f]\+\) \+.*/\1/p'`
[ -n "$text" ] || continue
[ "$entry" = "$text" ] || continue
[ -n "${file##*/lib64/ld-*.so}" ] || continue
chmod -c u+w,a-x,ug-s "$file"
@RPMCONFIGDIR@/is_elf_so_executable "$file" ||
chmod -c u+w,a-x,ug-s "$file"
;;
esac
done

58
scripts/is_elf_so_executable Executable file
View File

@ -0,0 +1,58 @@
#!/bin/sh -e
#
# is_elf_so_executable - checks whether the given ELF shared object
# should be treated as an executable.
#
# Not an every shared object is a library.
# For example, PIEs should be treated as executables.
#
# Copyright (C) 2003-2016 Dmitry V. Levin <ldv@altlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
[ $# -eq 1 ]
file="$1"; shift
# This dynamic linker used to have its entry point
# equal to the text segment start address.
[ -n "${file##*/lib64/ld-*.so}" ] || exit 0
section_header="$(readelf --wide --sections "$file" ||:)"
# An .interp section means it is an executable, see
# comm -12 <(grep -Fl .interp /usr/lib/ldscripts/*)
# <(grep -Fle --shared /usr/lib/ldscripts/*)
if printf %s "$section_header" |grep -Fqs ' .interp '; then
exit 0
fi
file_header="$(readelf --wide --file-header "$file" ||:)"
# Zero entry point is treated like no entry points.
entry="$(printf %s "$file_header" |
sed -ne 's/^ \+Entry point address: \+0x0*\([1-9a-f][0-9a-f]*\)$/\1/p')"
# Zero text segment start address is treated like no text segments.
text="$(printf %s "$section_header" |
sed -ne 's/^ *\[ *[0-9]\+\] \.text \+PROGBITS \+0*\([1-9a-f][0-9a-f]*\) \+.*/\1/p')"
# Missing entry point or text segment means it is not an executable.
# Also, if entry point and text segment start address are equal,
# it is not an executable.
[ -z "$entry" ] ||
[ -z "$text" ] ||
[ "$entry" = "$text" ] ||
exit 0
exit 1

View File

@ -142,15 +142,19 @@ verify_rpath()
done
fi
local found_p
for p in $RPM_BUILD_ROOT $RPM_BUILD_DIR $RPM_SOURCE_DIR /lib/../lib64; do
if printf %s "$rpath" | grep -Fqs "$p"; then
found_p="$(printf %s "$rpath" | { grep -F "$p" || [ "$?" -eq 1 ]; } )"
if [ -n "$found_p" ]; then
error_relaxed RPATH "$f" "RPATH contains illegal entry \"$p\": $rpath"
found=1
fi
done
for p in /lib /lib64 /usr/lib /usr/lib64; do
if printf %s " $rpath " | tr : ' ' | grep -Fqs " $p "; then
found_p="$(printf %s " $rpath " | tr : ' ' | { grep -F " $p " || [ "$?" -eq 1 ]; } )"
if [ -n "$found_p" ]; then
error_normal RPATH "$f" "RPATH contains standard library path \"$p\": $rpath"
found=1
fi
@ -175,7 +179,7 @@ verify_unresolved()
fi
rpath="$(printf %s "$rpath" |
tr -s '[:space:]' '\n' |
grep -v '^$' |
{ grep -v '^$' || [ "$?" -eq 1 ]; } |
LANG=C uniq |
sed -e "s|^|$RPM_BUILD_ROOT&|" |
tr -s '[:space:]' : |
@ -196,7 +200,8 @@ verify_unresolved()
;;
*)
if [ -z "${t##*ELF* executable*dynamically linked*}" ] ||
lookup_path "${fname%/*}" "$RPM_VERIFY_ELF_LDD_RPATH"; then
lookup_path "${fname%/*}" "$RPM_VERIFY_ELF_LDD_RPATH" ||
@RPMCONFIGDIR@/is_elf_so_executable "$f"; then
ldd_rc=1
else
ldd_rc=0
@ -258,13 +263,14 @@ verify_stack()
nsp0='[^[:space:]]*'
sp1='[[:space:]]\+'
hex='0x[0-9a-f]\+'
stack="$(printf '%s\n' "$elf_segments" |grep "^${sp0}GNU_STACK${sp1}")" || {
stack="$(printf '%s\n' "$elf_segments" | { grep "^${sp0}GNU_STACK${sp1}" || [ "$?" -eq 1 ]; } )"
[ -n "$stack" ] || {
error_strict STACK "$f" 'STACK entry not found'
return
}
exe_reg="${sp0}GNU_STACK${sp1}${hex}${sp1}${hex}${sp1}${hex}${sp1}${hex}${sp1}${hex}${sp1}${nsp0}E${nsp0}${sp1}${hex}"
exe_stack="$(printf '%s\n' "$stack" |grep -x "$exe_reg")" ||
return 0
exe_stack="$(printf '%s\n' "$stack" | { grep -x "$exe_reg" || [ "$?" -eq 1 ]; } )"
[ -z "$exe_stack" ] ||
error_strict STACK "$f" "found executable STACK entry: $exe_stack"
}