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 1RUSZt-0005Dd-RS for garchives@archives.gentoo.org; Sun, 27 Nov 2011 00:26:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F1AD421C087; Sun, 27 Nov 2011 00:26:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B517B21C087 for ; Sun, 27 Nov 2011 00:26:34 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2F7741B400D for ; Sun, 27 Nov 2011 00:26:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 5BC4F80042 for ; Sun, 27 Nov 2011 00:26:33 +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: <43c2929f6a7e29a32cc812f3974857fc08544dd7.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: 43c2929f6a7e29a32cc812f3974857fc08544dd7 Date: Sun, 27 Nov 2011 00:26:33 +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: 0dcafdc4-8857-4a0a-8652-d3b291671fc3 X-Archives-Hash: 956f5e9c04d4532358a4c15cabfc00a9 commit: 43c2929f6a7e29a32cc812f3974857fc08544dd7 Author: Anthony G. Basile gentoo org> AuthorDate: Sun Nov 27 00:26:27 2011 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sun Nov 27 00:26:27 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/elfix.git;a=3D= commit;h=3D43c2929f src/paxctl-ng.c: build with/without xattr support --- src/paxctl-ng.c | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index 5527e40..427281b 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -24,7 +24,10 @@ #include =20 #include + +#ifdef XATTR #include +#endif =20 #include #include @@ -33,15 +36,16 @@ =20 #include =20 - +#ifdef XATTR #define PAX_NAMESPACE "user.pax" -#define BUF_SIZE 8 -#define FILE_NAME_SIZE 32768 =20 #define CREATE_XT_FLAGS_SECURE 1 #define CREATE_XT_FLAGS_DEFAULT 2 #define COPY_PT_TO_XT_FLAGS 3 #define COPY_XT_TO_PT_FLAGS 4 +#endif + +#define BUF_SIZE 8 =20 void print_help_exit(char *v) @@ -53,7 +57,9 @@ print_help_exit(char *v) "Program Name : %s\n" "Description : Get or set pax flags on an ELF object\n\n" "Usage : %s -PpEeMmRrXxSsv ELF | -Zv ELF | -zv ELF\n" +#ifdef XATTR " : %s -Cv ELF | -cv ELF | Fv ELF | -fv ELF\n" +#endif " : %s -v ELF | -h\n\n" "Options : -P enable PAGEEXEC\t-p disable PAGEEXEC\n" " : -S enable SEGMEXEC\t-s disable SEGMEXEC\n" @@ -62,10 +68,12 @@ print_help_exit(char *v) " : -R enable RANDMMAP\t-r disable RANDMMAP\n" " : -X enable RANDEXEC\t-x disable RANDEXEC\n" " : -Z most secure settings\t-z all default settings\n" +#ifdef XATTR " : -C create XT_PAX with most secure setting\n" " : -c create XT_PAX all default settings\n" " : -F copy PT_PAX to XT_PAX\n" " : -f copy XT_PAX to PT_PAX\n" +#endif " : -v view the flags, along with any accompanying operati= on\n" " : -h print out this help\n\n" "Note : If both enabling and disabling flags are set, the def= ault - is used\n\n", @@ -154,6 +162,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_= flags, int *view_flags, int PF_RANDMMAP | PF_NORANDMMAP | PF_RANDEXEC | PF_NORANDEXEC; solitaire +=3D 1; break; +#ifdef XATTR case 'C': solitaire +=3D 1; *cp_flags =3D CREATE_XT_FLAGS_SECURE; @@ -170,6 +179,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_= flags, int *view_flags, int solitaire +=3D 1; *cp_flags =3D COPY_XT_TO_PT_FLAGS; break; +#endif case 'v': *view_flags =3D 1; break; @@ -243,6 +253,7 @@ get_pt_flags(int fd) } =20 =20 +#ifdef XATTR uint16_t get_xt_flags(int fd) { @@ -251,6 +262,7 @@ get_xt_flags(int fd) fgetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t)); return xt_flags; } +#endif =20 =20 void @@ -292,6 +304,7 @@ print_flags(int fd) printf("\tPT_PAX: %s\n", buf); } =20 +#ifdef XATTR flags =3D get_xt_flags(fd); if( flags =3D=3D UINT16_MAX ) printf("\tXT_PAX: not found\n"); @@ -301,6 +314,7 @@ print_flags(int fd) bin2string(flags, buf); printf("\tXT_PAX: %s\n", buf); } +#endif } =20 =20 @@ -467,11 +481,13 @@ set_pt_flags(int fd, uint16_t pt_flags) } =20 =20 +#ifdef XATTR void set_xt_flags(int fd, uint16_t xt_flags) { fsetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t), XATTR_REPLACE= ); } +#endif =20 =20 void @@ -488,14 +504,17 @@ set_flags(int fd, uint16_t *pax_flags, int rdwr_pt_= pax) set_pt_flags(fd, flags); } =20 +#ifdef XATTR flags =3D get_xt_flags(fd); if( flags =3D=3D UINT16_MAX ) flags =3D PF_NOEMUTRAMP | PF_NORANDEXEC; flags =3D update_flags( flags, *pax_flags); set_xt_flags(fd, flags); +#endif } =20 =20 +#ifdef XATTR void create_xt_flags(fd, cp_flags) { @@ -526,6 +545,7 @@ copy_xt_flags(fd, cp_flags) set_pt_flags(fd, flags); } } +#endif =20 =20 int @@ -553,11 +573,13 @@ main( int argc, char *argv[]) } } =20 +#ifdef XATTR if(cp_flags =3D=3D CREATE_XT_FLAGS_SECURE || cp_flags =3D=3D CREATE_XT= _FLAGS_DEFAULT) create_xt_flags(fd, cp_flags); =20 if(cp_flags =3D=3D COPY_PT_TO_XT_FLAGS || (cp_flags =3D=3D COPY_XT_TO_= PT_FLAGS && rdwr_pt_pax)) copy_xt_flags(fd, cp_flags); +#endif =20 if(pax_flags !=3D 1) set_flags(fd, &pax_flags, rdwr_pt_pax);