/[gentoo-x86]/eclass/pax-utils.eclass
Gentoo

Diff of /eclass/pax-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.3
1# Copyright 1999-2006 Gentoo Foundation 1# Copyright 1999-2006 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/pax-utils.eclass,v 1.2 2006/11/15 22:14:25 kevquinn Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/pax-utils.eclass,v 1.3 2006/11/24 15:11:55 kevquinn Exp $
4 4
5# Author: 5# Author:
6# Kevin F. Quinn <kevquinn@gentoo.org> 6# Kevin F. Quinn <kevquinn@gentoo.org>
7# 7#
8# This eclass provides support for manipulating PaX markings on ELF 8# This eclass provides support for manipulating PaX markings on ELF
17# If paxctl is installed, but not chpax, then the legacy 17# If paxctl is installed, but not chpax, then the legacy
18# EI flags (which are not strip-safe) will not be set. 18# EI flags (which are not strip-safe) will not be set.
19# If neither are installed, falls back to scanelf (which 19# If neither are installed, falls back to scanelf (which
20# is always present, but currently doesn't quite do all 20# is always present, but currently doesn't quite do all
21# that paxctl can do). 21# that paxctl can do).
22_pax_list_files() {
23 local m cmd
24 m=$1 ; shift
25 for f in $*; do
26 ${cmd} " ${f}"
27 done
28}
22 29
23pax-mark() { 30pax-mark() {
24 local flags fail=0 31 local f flags fail=0 failures=""
25 flags=$1 32 flags=${1//-}
26 shift 33 shift
27 if [[ -x /sbin/chpax ]]; then 34 if [[ -x /sbin/chpax ]]; then
28 einfo "Legacy EI PaX marking $* with ${flags}" 35 einfo "Legacy EI PaX marking -${flags}"
29 /sbin/chpax -${flags} $* || fail=1 36 _pax_list_files echo $*
37 for f in $*; do
38 /sbin/chpax -${flags} ${f} && continue
39 fail=1
40 failures="${failures} ${f}"
41 done
30 fi 42 fi
31 if [[ -x /sbin/paxctl ]]; then 43 if [[ -x /sbin/paxctl ]]; then
32 einfo "PT PaX marking $* with ${flags}" 44 einfo "PT PaX marking -${flags}"
33 /sbin/paxctl -${flags} $* || 45 _pax_list_files echo $*
34 /sbin/paxctl -c${flags} $* || 46 for f in $*; do
35 /sbin/paxctl -C${flags} $* || fail=1 47 /sbin/paxctl -q${flags} ${f} && continue
48 /sbin/paxctl -qc${flags} ${f} && continue
49 /sbin/paxctl -qC${flags} ${f} && continue
50 fail=1
51 failures="${failures} ${f}"
52 done
36 elif [[ -x /usr/bin/scanelf ]]; then 53 elif [[ -x /usr/bin/scanelf ]]; then
37 einfo "Fallback PaX marking $* with ${flags}" 54 einfo "Fallback PaX marking -${flags}"
55 _pax_list_files echo $*
38 /usr/bin/scanelf -Xxz ${flags} $* 56 /usr/bin/scanelf -Xxz ${flags} $*
39 else 57 else
40 ewarn "Failed to set PaX markings ${flags} for files $*. Executables may be killed by PaX kernels." 58 failures="$*"
41 fail=1 59 fail=1
60 fi
61 if [[ ${fail} == 1 ]]; then
62 ewarn "Failed to set PaX markings -${flags} for:"
63 _pax_list_files ewarn ${failures}
64 ewarn "Executables may be killed by PaX kernels."
42 fi 65 fi
43 return ${fail} 66 return ${fail}
44} 67}
45 68
46##### host-is-pax 69##### host-is-pax

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.20