From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1R2VDI-0005QB-CA for garchives@archives.gentoo.org; Sat, 10 Sep 2011 21:35:48 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9906B21C0F7; Sat, 10 Sep 2011 21:35:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 6730521C0F7 for ; Sat, 10 Sep 2011 21:35:39 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DD23A1B4007 for ; Sat, 10 Sep 2011 21:35:38 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 120EC80042 for ; Sat, 10 Sep 2011 21:35:38 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: <4d1278d1d5b52aa9a0e10fd660473243269e52da.blueness@gentoo> Subject: [gentoo-commits] proj/elfix:master commit in: src/ X-VCS-Repository: proj/elfix X-VCS-Files: src/paxctl-ng.c X-VCS-Directories: src/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: 4d1278d1d5b52aa9a0e10fd660473243269e52da Date: Sat, 10 Sep 2011 21:35:38 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 65c76d4e51f95ed1e4a2bb84d1d12a04 commit: 4d1278d1d5b52aa9a0e10fd660473243269e52da Author: Anthony G. Basile gentoo org> AuthorDate: Sat Sep 10 21:35:32 2011 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sat Sep 10 21:35:32 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/elfix.git;a=3D= commit;h=3D4d1278d1 src/paxctl-ng.c: remove create PAX_FLAGS and read flags option --- src/paxctl-ng.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index 4a099ec..5f33ebe 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -54,6 +54,7 @@ print_help(char *v) " : -x Disable RANDEXEC\t-X Enable RANDEXEC\n" " : -s Disable SEGMEXEC\t-X Enable SEGMEXEC\n" " : -z Default least secure\t-Z Default most secure\n" + " : -v view the flags\n" " : -h Print out this help\n", basename(v), basename(v) @@ -69,10 +70,10 @@ parse_cmd_args( int c, char *v[], int *pax_flags ) int i, oc; =20 if((c !=3D 2)&&(c !=3D 3)&&(c !=3D 4)) - error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZC] ELFfile | [-h]}"= , v[0]); + error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]}"= , v[0]); =20 *pax_flags =3D 0; - while((oc =3D getopt(c, v,":pPeEmMrRxXsSzZCh")) !=3D -1) + while((oc =3D getopt(c, v,":pPeEmMrRxXsSzZvh")) !=3D -1) switch(oc) { case 'p': @@ -103,6 +104,9 @@ parse_cmd_args( int c, char *v[], int *pax_flags ) break ; case 'Z': break; + case 'v': + *pax_flags =3D -1; // Invalid flag signal read flags, not set + break; case 'h': print_help(v[0]); break; @@ -115,8 +119,11 @@ parse_cmd_args( int c, char *v[], int *pax_flags ) } =20 =20 +/* + * return 1 if PAX_FLAGS program header exists, 0 otherwise + */ int -no_pt_pax_flags(Elf *e) +pt_pax_flags(Elf *e) { size_t i, phnum; GElf_Phdr phdr; @@ -127,9 +134,9 @@ no_pt_pax_flags(Elf *e) if(gelf_getphdr(e, i, &phdr) !=3D &phdr) error(EXIT_FAILURE, 0, "gelf_getphdr(): %s", elf_errmsg(elf_errno()))= ; if(phdr.p_type =3D=3D PT_PAX_FLAGS) - return 0; + return 1; } - return 1; + return 0; } =20 =20 @@ -150,6 +157,7 @@ main( int argc, char *argv[]) =20 if((fd =3D open(f_name, O_RDWR)) < 0) error(EXIT_FAILURE, 0, "open() fail."); + if((elf =3D elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) =3D=3D NULL) error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno())= ); =20