From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: src/
Date: Sat, 10 Sep 2011 21:11:13 +0000 (UTC) [thread overview]
Message-ID: <d26443ff1b6cdb411dd4f7c195e4dc7824d5fcee.blueness@gentoo> (raw)
commit: d26443ff1b6cdb411dd4f7c195e4dc7824d5fcee
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 10 21:11:06 2011 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Sep 10 21:11:06 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=d26443ff
src/paxctl-ng.c: remove create_flags option
---
src/paxctl-ng.c | 112 ++++++++++++-------------------------------------------
1 files changed, 24 insertions(+), 88 deletions(-)
diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index 0957e36..4a099ec 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -54,7 +54,6 @@ 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"
- " : -C Created PT_PAX_FLAGS program header\n"
" : -h Print out this help\n",
basename(v),
basename(v)
@@ -65,7 +64,7 @@ print_help(char *v)
char *
-parse_cmd_args( int c, char *v[], int *pax_flags, int *create_flag )
+parse_cmd_args( int c, char *v[], int *pax_flags )
{
int i, oc;
@@ -73,7 +72,6 @@ parse_cmd_args( int c, char *v[], int *pax_flags, int *create_flag )
error(EXIT_FAILURE, 0, "Usage: %s {[-pPeEmMrRxXsSzZC] ELFfile | [-h]}", v[0]);
*pax_flags = 0;
- *create_flag = 0;
while((oc = getopt(c, v,":pPeEmMrRxXsSzZCh")) != -1)
switch(oc)
{
@@ -105,9 +103,6 @@ parse_cmd_args( int c, char *v[], int *pax_flags, int *create_flag )
break ;
case 'Z':
break;
- case 'C':
- *create_flag = 1;
- break;
case 'h':
print_help(v[0]);
break;
@@ -139,112 +134,53 @@ no_pt_pax_flags(Elf *e)
int
-create_pt_pax_flags(Elf *e)
-{
- size_t i, phnum;
- GElf_Phdr phdr;
-
- elf_getphdrnum(e, &phnum);
- for(i=0; i<phnum; ++i)
- {
- if(gelf_getphdr(e, i, &phdr) != &phdr)
- error(EXIT_FAILURE, 0, "gelf_getphdr(): %s", elf_errmsg(elf_errno()));
- if(phdr.p_type == PT_NULL)
- {
- phdr.p_type = PT_PAX_FLAGS;
- phdr.p_flags = PF_NOEMUTRAMP|PF_NORANDEXEC;
- if(!gelf_update_phdr(e, i, &phdr))
- error(EXIT_FAILURE, 0, "gelf_update_phdr(): %s", elf_errmsg(elf_errno()));
- return 1;
- }
- }
-
-
- /*
- if( !(phdr = gelf_newphdr(Elf *e, size_t phnum)) )
- {
- phdr.p_type = PT_PAX_FLAGS;
- //phdr.p_offset
- //phdr.p_vaddr
- //phdr.p_paddr
- //phdr.p_filesz
- //phdr.p_memsz
- phdr.p_flags = PF_NOEMUTRAMP|PF_NORANDEXEC;
- //phdr.p_align
-
- if(!gelf_update_phdr(e, i, &phdr))
- error(EXIT_FAILURE, 0, "gelf_update_phdr(): %s", elf_errmsg(elf_errno()));
- return 1;
- }
- error(EXIT_FAILURE, 0, "gelf_newphdr(): %s", elf_errmsg(elf_errno()));
- */
-
-}
-
-
-int
main( int argc, char *argv[])
{
int fd;
- int pax_flags, create_flag;
+ int pax_flags;
char *f_name;
Elf *elf;
GElf_Ehdr ehdr;
- f_name = parse_cmd_args(argc, argv, &pax_flags, &create_flag);
+ f_name = parse_cmd_args(argc, argv, &pax_flags);
if(elf_version(EV_CURRENT) == EV_NONE)
error(EXIT_FAILURE, 0, "Library out of date.");
- if(create_flag)
- {
- if((fd = open(f_name, O_RDWR)) < 0)
- error(EXIT_FAILURE, 0, "open() fail.");
- if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL)
- error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno()));
- }
- else
- {
- if((fd = open(f_name, O_RDONLY)) < 0)
- error(EXIT_FAILURE, 0, "open() fail.");
- if((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL)
- error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno()));
- }
+ if((fd = open(f_name, O_RDWR)) < 0)
+ error(EXIT_FAILURE, 0, "open() fail.");
+ if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL)
+ error(EXIT_FAILURE, 0, "elf_begin() fail: %s", elf_errmsg(elf_errno()));
if(elf_kind(elf) != ELF_K_ELF)
error(EXIT_FAILURE, 0, "elf_kind() fail: this is not an elf file.");
+ /*
+ if(gelf_getehdr(elf, &ehdr) != &ehdr)
+ error(EXIT_FAILURE, 0, "gelf_getehdr(): %s", elf_errmsg(elf_errno()));
+ ehdr.e_ident[EI_PAX] = 0;
+ ehdr.e_ident[EI_PAX + 1] = 0;
+ if(!gelf_update_ehdr(elf, &ehdr))
+ error(EXIT_FAILURE, 0, "gelf_update_ehdr(): %s", elf_errmsg(elf_errno()));
- if(create_flag)
+ if(no_pt_pax_flags(elf))
{
- //To be safe, let's make sure EI_PAX flags are zero-ed for most secure legacy
- if(gelf_getehdr(elf, &ehdr) != &ehdr)
- error(EXIT_FAILURE, 0, "gelf_getehdr(): %s", elf_errmsg(elf_errno()));
-
- ehdr.e_ident[EI_PAX] = 0;
- ehdr.e_ident[EI_PAX + 1] = 0;
-
- if(!gelf_update_ehdr(elf, &ehdr))
- error(EXIT_FAILURE, 0, "gelf_update_ehdr(): %s", elf_errmsg(elf_errno()));
-
- if(no_pt_pax_flags(elf))
+ printf("PT_PAX_FLAGS phdr not found: creating one\n");
+ if(create_pt_pax_flags(elf))
{
- printf("PT_PAX_FLAGS phdr not found: creating one\n");
- if(create_pt_pax_flags(elf))
- {
- printf("PT_PAX_FLAGS phdr create: succeeded\n");
- }
- else
- error(EXIT_FAILURE, 0, "PT_PAX_FLAGS phdr create: failed");
+ printf("PT_PAX_FLAGS phdr create: succeeded\n");
}
else
- error(EXIT_FAILURE, 0, "PT_PAX_FLAGS phdr found: nothing to do");
- }
-
+ error(EXIT_FAILURE, 0, "PT_PAX_FLAGS phdr create: failed");
+ }
+ else
+ error(EXIT_FAILURE, 0, "PT_PAX_FLAGS phdr found: nothing to do");
+ }
+ */
/*
next reply other threads:[~2011-09-10 21:11 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-10 21:11 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-22 19:51 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-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=d26443ff1b6cdb411dd4f7c195e4dc7824d5fcee.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