From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: src/
Date: Sun, 27 Nov 2011 00:59:36 +0000 (UTC) [thread overview]
Message-ID: <389a4e631f3877ac7f06ee1667faeccab1b7fdbd.blueness@gentoo> (raw)
commit: 389a4e631f3877ac7f06ee1667faeccab1b7fdbd
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 00:59:24 2011 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 00:59:24 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=389a4e63
src/paxctl-ng.c: made verbosity more consistant
---
src/paxctl-ng.c | 89 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 53 insertions(+), 36 deletions(-)
diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index 427281b..5700b98 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -56,7 +56,7 @@ print_help_exit(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 -PpEeMmRrXxSsv ELF | -Zv ELF | -zv ELF\n"
+ "Usage : %s -PpSsMmEeRrXxv ELF | -Zv ELF | -zv ELF\n"
#ifdef XATTR
" : %s -Cv ELF | -cv ELF | Fv ELF | -fv ELF\n"
#endif
@@ -88,7 +88,7 @@ print_help_exit(char *v)
void
-parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *view_flags, int *cp_flags,
+parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *verbose, int *cp_flags,
int *begin, int *end)
{
int i, oc;
@@ -97,9 +97,13 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *view_flags, int
compat = 0;
solitaire = 0;
*pax_flags = 0;
- *view_flags = 0;
+ *verbose = 0;
*cp_flags = 0;
- while((oc = getopt(argc, argv,":PpEeMmRrXxSsZzCcFfvh")) != -1)
+#ifdef XATTR
+ while((oc = getopt(argc, argv,":PpSsMmEeRrXxZzCcFfvh")) != -1)
+#else
+ while((oc = getopt(argc, argv,":PpSsMmEeRrXxZzvh")) != -1)
+#endif
{
switch(oc)
{
@@ -181,7 +185,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *view_flags, int
break;
#endif
case 'v':
- *view_flags = 1;
+ *verbose = 1;
break;
case 'h':
print_help_exit(argv[0]);
@@ -194,7 +198,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *view_flags, int
if( ((compat == 1 && solitaire == 0) ||
(compat == 0 && solitaire == 1) ||
- (compat == 0 && solitaire == 0 && *view_flags == 1)
+ (compat == 0 && solitaire == 0 && *verbose == 1)
) && argv[optind] != NULL)
{
*begin = optind;
@@ -206,7 +210,7 @@ parse_cmd_args(int argc, char *argv[], uint16_t *pax_flags, int *view_flags, int
uint16_t
-get_pt_flags(int fd)
+get_pt_flags(int fd, int verbose)
{
Elf *elf;
GElf_Phdr phdr;
@@ -216,20 +220,23 @@ get_pt_flags(int fd)
if(elf_version(EV_CURRENT) == EV_NONE)
{
- printf("\tELF ERROR: Library out of date.\n");
+ if(verbose)
+ printf("\tELF ERROR: Library out of date.\n");
return pt_flags;
}
if((elf = elf_begin(fd, ELF_C_READ_MMAP, NULL)) == NULL)
{
- printf("\tELF ERROR: elf_begin() fail: %s\n", elf_errmsg(elf_errno()));
+ if(verbose)
+ printf("\tELF ERROR: elf_begin() fail: %s\n", elf_errmsg(elf_errno()));
return pt_flags;
}
if(elf_kind(elf) != ELF_K_ELF)
{
elf_end(elf);
- printf("\tELF ERROR: elf_kind() fail: this is not an elf file.\n");
+ if(verbose)
+ printf("\tELF ERROR: elf_kind() fail: this is not an elf file.\n");
return pt_flags;
}
@@ -240,7 +247,8 @@ get_pt_flags(int fd)
if(gelf_getphdr(elf, i, &phdr) != &phdr)
{
elf_end(elf);
- printf("\tELF ERROR: gelf_getphdr(): %s\n", elf_errmsg(elf_errno()));
+ if(verbose)
+ printf("\tELF ERROR: gelf_getphdr(): %s\n", elf_errmsg(elf_errno()));
return pt_flags;
}
@@ -289,12 +297,12 @@ bin2string(uint16_t flags, char *buf)
void
-print_flags(int fd)
+print_flags(int fd, int verbose)
{
uint16_t flags;
char buf[BUF_SIZE];
- flags = get_pt_flags(fd);
+ flags = get_pt_flags(fd, verbose);
if( flags == UINT16_MAX )
printf("\tPT_PAX: not found\n");
else
@@ -429,7 +437,7 @@ update_flags(uint16_t flags, uint16_t pax_flags)
void
-set_pt_flags(int fd, uint16_t pt_flags)
+set_pt_flags(int fd, uint16_t pt_flags, int verbose)
{
Elf *elf;
GElf_Phdr phdr;
@@ -437,20 +445,23 @@ set_pt_flags(int fd, uint16_t pt_flags)
if(elf_version(EV_CURRENT) == EV_NONE)
{
- printf("\tELF ERROR: Library out of date.\n");
+ if(verbose)
+ printf("\tELF ERROR: Library out of date.\n");
return;
}
if((elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL)) == NULL)
{
- printf("\tELF ERROR: elf_begin() fail: %s\n", elf_errmsg(elf_errno()));
+ if(verbose)
+ printf("\tELF ERROR: elf_begin() fail: %s\n", elf_errmsg(elf_errno()));
return;
}
if(elf_kind(elf) != ELF_K_ELF)
{
elf_end(elf);
- printf("\tELF ERROR: elf_kind() fail: this is not an elf file.\n");
+ if(verbose)
+ printf("\tELF ERROR: elf_kind() fail: this is not an elf file.\n");
return;
}
@@ -461,7 +472,8 @@ set_pt_flags(int fd, uint16_t pt_flags)
if(gelf_getphdr(elf, i, &phdr) != &phdr)
{
elf_end(elf);
- printf("\tELF ERROR: gelf_getphdr(): %s\n", elf_errmsg(elf_errno()));
+ if(verbose)
+ printf("\tELF ERROR: gelf_getphdr(): %s\n", elf_errmsg(elf_errno()));
return;
}
@@ -472,7 +484,8 @@ set_pt_flags(int fd, uint16_t pt_flags)
if(!gelf_update_phdr(elf, i, &phdr))
{
elf_end(elf);
- printf("\tELF ERROR: gelf_update_phdr(): %s", elf_errmsg(elf_errno()));
+ if(verbose)
+ printf("\tELF ERROR: gelf_update_phdr(): %s", elf_errmsg(elf_errno()));
}
}
}
@@ -491,17 +504,17 @@ set_xt_flags(int fd, uint16_t xt_flags)
void
-set_flags(int fd, uint16_t *pax_flags, int rdwr_pt_pax)
+set_flags(int fd, uint16_t *pax_flags, int rdwr_pt_pax, int verbose)
{
uint16_t flags;
if(rdwr_pt_pax)
{
- flags = get_pt_flags(fd);
+ flags = get_pt_flags(fd, verbose);
if( flags == UINT16_MAX )
flags = PF_NOEMUTRAMP | PF_NORANDEXEC;
flags = update_flags( flags, *pax_flags);
- set_pt_flags(fd, flags);
+ set_pt_flags(fd, flags, verbose);
}
#ifdef XATTR
@@ -516,7 +529,7 @@ set_flags(int fd, uint16_t *pax_flags, int rdwr_pt_pax)
#ifdef XATTR
void
-create_xt_flags(fd, cp_flags)
+create_xt_flags(int fd, int cp_flags)
{
uint16_t xt_flags;
@@ -531,18 +544,18 @@ create_xt_flags(fd, cp_flags)
void
-copy_xt_flags(fd, cp_flags)
+copy_xt_flags(int fd, int cp_flags, int verbose)
{
uint16_t flags;
if(cp_flags == 3)
{
- flags = get_pt_flags(fd);
+ flags = get_pt_flags(fd, verbose);
set_xt_flags(fd, flags);
}
else if(cp_flags == 4)
{
flags = get_xt_flags(fd);
- set_pt_flags(fd, flags);
+ set_pt_flags(fd, flags, verbose);
}
}
#endif
@@ -553,22 +566,25 @@ main( int argc, char *argv[])
{
int fd, fi;
uint16_t pax_flags;
- int view_flags, cp_flags, begin, end;
+ int verbose, cp_flags, begin, end;
int rdwr_pt_pax = 1;
- parse_cmd_args(argc, argv, &pax_flags, &view_flags, &cp_flags, &begin, &end);
+ parse_cmd_args(argc, argv, &pax_flags, &verbose, &cp_flags, &begin, &end);
for(fi = begin; fi < end; fi++)
{
- printf("%s:\n", argv[fi]);
+ if(verbose)
+ printf("%s:\n", argv[fi]);
if((fd = open(argv[fi], O_RDWR)) < 0)
{
rdwr_pt_pax = 0;
- printf("\topen(O_RDWR) failed: cannot change PT_PAX flags\n");
+ if(verbose)
+ printf("\topen(O_RDWR) failed: cannot change PT_PAX flags\n");
if((fd = open(argv[fi], O_RDONLY)) < 0)
{
- printf("\topen(O_RDONLY) failed: cannot change PT_PAX flags\n\n");
+ if(verbose)
+ printf("\topen(O_RDONLY) failed: cannot change PT_PAX flags\n\n");
continue;
}
}
@@ -578,18 +594,19 @@ main( int argc, char *argv[])
create_xt_flags(fd, cp_flags);
if(cp_flags == COPY_PT_TO_XT_FLAGS || (cp_flags == COPY_XT_TO_PT_FLAGS && rdwr_pt_pax))
- copy_xt_flags(fd, cp_flags);
+ copy_xt_flags(fd, cp_flags, verbose);
#endif
if(pax_flags != 1)
- set_flags(fd, &pax_flags, rdwr_pt_pax);
+ set_flags(fd, &pax_flags, rdwr_pt_pax, verbose);
- if(view_flags == 1)
- print_flags(fd);
+ if(verbose == 1)
+ print_flags(fd, verbose);
close(fd);
- printf("\n");
+ if(verbose)
+ printf("\n");
}
exit(EXIT_SUCCESS);
next reply other threads:[~2011-11-27 0:59 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-27 0:59 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: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-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=389a4e631f3877ac7f06ee1667faeccab1b7fdbd.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