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 1R2ZFP-0006ei-0U for garchives@archives.gentoo.org; Sun, 11 Sep 2011 01:54:15 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DA17821C0A5; Sun, 11 Sep 2011 01:54:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 905A921C0A5 for ; Sun, 11 Sep 2011 01:54:07 +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 EF8CE1B4007 for ; Sun, 11 Sep 2011 01:54:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 49B4280042 for ; Sun, 11 Sep 2011 01:54:06 +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: <9479f0ca040e95f24da74818242850f0cf8fff29.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: 9479f0ca040e95f24da74818242850f0cf8fff29 Date: Sun, 11 Sep 2011 01:54:06 +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: 9519830795b78e3abbadad7b861de4a6 commit: 9479f0ca040e95f24da74818242850f0cf8fff29 Author: Anthony G. Basile gentoo org> AuthorDate: Sun Sep 11 01:54:00 2011 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sun Sep 11 01:54:00 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/elfix.git;a=3D= commit;h=3D9479f0ca src/paxctl-ng.c: construct pax flags from command line --- src/paxctl-ng.c | 51 +++++++++++++++++++++++++++++++++++--------------= -- 1 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index d7c58a5..c7206c3 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -50,7 +50,7 @@ print_help(char *v) "Bug Reports : " PACKAGE_BUGREPORT "\n" "Program Name : %s\n" "Description : Get or set pax flags on an ELF object\n\n" - "Usage : %s {[-pPeEmMrRxXsSzZC] ELFfile | [-h]}\n" + "Usage : %s {[-PpEeMmRrXxSsZzv] ELFfile | [-h]}\n" "options : Print out pax flag information\n" " : -p Disable PAGEEXEC\t-P Enable PAGEEXEC\n" " : -e Disable EMUTRAMP\t-E Enable EMUTRAMP\n" @@ -74,41 +74,54 @@ parse_cmd_args(int c, char *v[], int *pax_flags, int = *view_flags) { int i, oc; =20 - if((c !=3D 2)&&(c !=3D 3)&&(c !=3D 4)) - error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]}"= , v[0]); - *pax_flags =3D 0; *view_flags =3D 0; - while((oc =3D getopt(c, v,":pPeEmMrRxXsSzZvh")) !=3D -1) + while((oc =3D getopt(c, v,":PpEeMmRrXxSsZzvh")) !=3D -1) switch(oc) { + case 'P': + *pax_flags |=3D PF_PAGEEXEC; + break; case 'p': + *pax_flags |=3D PF_NOPAGEEXEC; break ; - case 'P': + case 'S': + *pax_flags |=3D PF_SEGMEXEC; break; - case 'e': + case 's': + *pax_flags |=3D PF_NOSEGMEXEC; break ; - case 'E': + case 'M': + *pax_flags |=3D PF_MPROTECT; break; case 'm': + *pax_flags |=3D PF_NOMPROTECT; break ; - case 'M': + case 'E': + *pax_flags |=3D PF_EMUTRAMP; break; - case 'r': + case 'e': + *pax_flags |=3D PF_NOEMUTRAMP; break ; case 'R': + *pax_flags |=3D PF_RANDMMAP; break; - case 'x': + case 'r': + *pax_flags |=3D PF_NORANDMMAP; break ; case 'X': + *pax_flags |=3D PF_RANDEXEC; break; - case 's': - break ; - case 'S': - break; - case 'z': + case 'x': + *pax_flags |=3D PF_NORANDEXEC; break ; case 'Z': + *pax_flags =3D PF_PAGEEXEC | PF_SEGMEXEC | PF_MPROTECT | + PF_NOEMUTRAMP | PF_RANDMMAP | PF_RANDEXEC; + break ; + case 'z': + *pax_flags =3D PF_NOPAGEEXEC | PF_NOSEGMEXEC | PF_NOMPROTECT | + PF_EMUTRAMP | PF_NORANDMMAP | PF_NORANDEXEC; break; case 'v': *view_flags =3D 1; @@ -121,6 +134,12 @@ parse_cmd_args(int c, char *v[], int *pax_flags, int= *view_flags) error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ; } =20 +// if((c !=3D 2)&&(c !=3D 3)&&(c !=3D 4)) +// error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]= }", v[0]); + + if(v[optind] =3D=3D NULL) + error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZv] ELFfile | [-h]}"= , v[0]); + return v[optind] ; } =20