From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: src/
Date: Sat, 22 Oct 2011 19:51:32 +0000 (UTC) [thread overview]
Message-ID: <3756d21245b0876cd7cae0252df1a87e2b1a0cdc.blueness@gentoo> (raw)
commit: 3756d21245b0876cd7cae0252df1a87e2b1a0cdc
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 22 19:51:25 2011 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Oct 22 19:51:25 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=3756d212
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)
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, int *cp_flags)
{
int i, oc;
int compat, solitaire;
@@ -83,6 +83,7 @@ parse_cmd_args(int c, char *v[], uint16_t *pax_flags, int *view_flags)
solitaire = 0;
*pax_flags = 0;
*view_flags = 0;
+ *cp_flags = 0;
while((oc = getopt(c, v,":PpEeMmRrXxSsZzCcFfvh")) != -1)
switch(oc)
{
@@ -147,15 +148,19 @@ parse_cmd_args(int c, char *v[], uint16_t *pax_flags, int *view_flags)
break;
case 'C':
solitaire += 1;
+ *cp_flags = 1;
break;
case 'c':
solitaire += 1;
+ *cp_flags = 2;
break;
case 'F':
solitaire += 1;
+ *cp_flags = 3;
break;
case 'f':
solitaire += 1;
+ *cp_flags = 4;
break;
case 'v':
*view_flags = 1;
@@ -464,19 +469,57 @@ set_flags(int fd, uint16_t *pax_flags)
}
+void
+create_xt_flag(fd, cp_flags)
+{
+ uint16_t xt_flags;
+
+ if(cp_flags == 1)
+ xt_flags = PF_PAGEEXEC | PF_SEGMEXEC | PF_MPROTECT |
+ PF_NOEMUTRAMP | PF_RANDMMAP | PF_NORANDEXEC;
+ else if(cp_flags == 2)
+ xt_flags = 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 == 3)
+ {
+ flags = get_pt_flags(fd);
+ set_xt_flags(fd, flags);
+ }
+ else if(cp_flags == 4)
+ {
+ flags = 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;
- f_name = parse_cmd_args(argc, argv, &flags, &view_flags);
+ f_name = parse_cmd_args(argc, argv, &flags, &view_flags, &cp_flags);
if((fd = open(f_name, O_RDWR)) < 0)
error(EXIT_FAILURE, 0, "open() fail.");
+ if(cp_flags == 1 || cp_flags == 2)
+ create_xt_flag(fd, cp_flags);
+
+ if(cp_flags == 3 || cp_flags == 4)
+ copy_xt_flag(fd, cp_flags);
+
if(flags != 1)
set_flags(fd, &flags);
next reply other threads:[~2011-10-22 19:51 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-22 19:51 Anthony G. Basile [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-12-13 14:48 [gentoo-commits] proj/elfix:master commit in: src/ Anthony G. Basile
2013-09-26 12:24 Anthony G. Basile
2012-12-28 23:07 Anthony G. Basile
2012-12-22 17:48 Anthony G. Basile
2012-12-21 20:36 Anthony G. Basile
2012-11-10 23:27 Anthony G. Basile
2012-11-10 22:29 Anthony G. Basile
2012-11-10 21:55 Anthony G. Basile
2012-11-10 21:35 Anthony G. Basile
2012-11-10 21:26 Anthony G. Basile
2012-07-27 22:00 Anthony G. Basile
2012-07-23 10:47 Anthony G. Basile
2012-07-21 12:37 Anthony G. Basile
2012-07-20 13:24 Anthony G. Basile
2012-07-20 11:56 Anthony G. Basile
2012-07-20 9:30 Anthony G. Basile
2011-11-27 0:59 Anthony G. Basile
2011-11-27 0:26 Anthony G. Basile
2011-11-15 16:07 Anthony G. Basile
2011-11-03 18:45 Anthony G. Basile
2011-11-03 18:16 Anthony G. Basile
2011-11-03 12:33 Anthony G. Basile
2011-10-18 22:48 Anthony G. Basile
2011-09-27 18:49 Anthony G. Basile
2011-09-27 17:58 Anthony G. Basile
2011-09-27 17:30 Anthony G. Basile
2011-09-18 22:48 Anthony G. Basile
2011-09-18 14:20 Anthony G. Basile
2011-09-11 21:12 Anthony G. Basile
2011-09-11 3:40 Anthony G. Basile
2011-09-11 2:32 Anthony G. Basile
2011-09-11 1:54 Anthony G. Basile
2011-09-11 0:23 Anthony G. Basile
2011-09-10 21:36 Anthony G. Basile
2011-09-10 21:35 Anthony G. Basile
2011-09-10 21:11 Anthony G. Basile
2011-05-13 12:01 Anthony G. Basile
2011-05-05 22:40 Anthony G. Basile
2011-05-04 2:15 Anthony G. Basile
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3756d21245b0876cd7cae0252df1a87e2b1a0cdc.blueness@gentoo \
--to=blueness@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox