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 1RHhba-00035a-IH for garchives@archives.gentoo.org; Sat, 22 Oct 2011 19:51:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7F06F21C01F; Sat, 22 Oct 2011 19:51:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4BDD321C01F for ; Sat, 22 Oct 2011 19:51:33 +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 B97181B400D for ; Sat, 22 Oct 2011 19:51:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2CAEC80042 for ; Sat, 22 Oct 2011 19:51:32 +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: <3756d21245b0876cd7cae0252df1a87e2b1a0cdc.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: 3756d21245b0876cd7cae0252df1a87e2b1a0cdc Date: Sat, 22 Oct 2011 19:51:32 +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: 90a5ac29b1ba508cd832791f34ffee71 commit: 3756d21245b0876cd7cae0252df1a87e2b1a0cdc Author: Anthony G. Basile gentoo org> AuthorDate: Sat Oct 22 19:51:25 2011 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Sat Oct 22 19:51:25 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/elfix.git;a=3D= commit;h=3D3756d212 src/paxctl-ng.c: create and copy XT_PAX flags --- src/paxctl-ng.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c index b77b6f8..2b0946a 100644 --- a/src/paxctl-ng.c +++ b/src/paxctl-ng.c @@ -74,7 +74,7 @@ print_help(char *v) =20 =20 char * -parse_cmd_args(int c, char *v[], uint16_t *pax_flags, int *view_flags) +parse_cmd_args(int c, char *v[], uint16_t *pax_flags, int *view_flags, i= nt *cp_flags) { int i, oc; int compat, solitaire; @@ -83,6 +83,7 @@ parse_cmd_args(int c, char *v[], uint16_t *pax_flags, i= nt *view_flags) solitaire =3D 0; *pax_flags =3D 0; *view_flags =3D 0; + *cp_flags =3D 0;=20 while((oc =3D getopt(c, v,":PpEeMmRrXxSsZzCcFfvh")) !=3D -1) switch(oc) { @@ -147,15 +148,19 @@ parse_cmd_args(int c, char *v[], uint16_t *pax_flag= s, int *view_flags) break; case 'C': solitaire +=3D 1; + *cp_flags =3D 1; break; case 'c': solitaire +=3D 1; + *cp_flags =3D 2; break; case 'F': solitaire +=3D 1; + *cp_flags =3D 3; break; case 'f': solitaire +=3D 1; + *cp_flags =3D 4; break; case 'v': *view_flags =3D 1; @@ -464,19 +469,57 @@ set_flags(int fd, uint16_t *pax_flags) } =20 =20 +void +create_xt_flag(fd, cp_flags) +{ + uint16_t xt_flags; + + if(cp_flags =3D=3D 1) + xt_flags =3D PF_PAGEEXEC | PF_SEGMEXEC | PF_MPROTECT | + PF_NOEMUTRAMP | PF_RANDMMAP | PF_NORANDEXEC; + else if(cp_flags =3D=3D 2) + xt_flags =3D 0; + + fsetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t), XATTR_CREATE)= ; +} + + +void +copy_xt_flag(fd, cp_flags) +{ + uint16_t flags; + if(cp_flags =3D=3D 3) + { + flags =3D get_pt_flags(fd); + set_xt_flags(fd, flags); + } + else if(cp_flags =3D=3D 4) + { + flags =3D get_xt_flags(fd); + set_pt_flags(fd, flags); + } +} + + int main( int argc, char *argv[]) { const char *f_name; int fd; uint16_t flags; - int view_flags; + int view_flags, cp_flags; =20 - f_name =3D parse_cmd_args(argc, argv, &flags, &view_flags); + f_name =3D parse_cmd_args(argc, argv, &flags, &view_flags, &cp_flags); =20 if((fd =3D open(f_name, O_RDWR)) < 0) error(EXIT_FAILURE, 0, "open() fail."); =20 + if(cp_flags =3D=3D 1 || cp_flags =3D=3D 2) + create_xt_flag(fd, cp_flags); + + if(cp_flags =3D=3D 3 || cp_flags =3D=3D 4) + copy_xt_flag(fd, cp_flags); + if(flags !=3D 1) set_flags(fd, &flags); =20