From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: src/, /, poc/
Date: Thu, 5 May 2011 23:50:55 +0000 (UTC) [thread overview]
Message-ID: <646f75362042124158b075efb3c7eb8cd779539f.blueness@gentoo> (raw)
commit: 646f75362042124158b075efb3c7eb8cd779539f
Author: Anthony G. Basile <basile <AT> opensource <DOT> dyc <DOT> edu>
AuthorDate: Thu May 5 23:50:15 2011 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu May 5 23:50:15 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=646f7536
poc/mangle-paxflags.c and src/fix-gnustack.c: added help option
---
autogen.sh | 1 +
configure.ac | 4 ++--
poc/mangle-paxflags.c | 29 ++++++++++++++++++++++++++---
src/fix-gnustack.c | 26 ++++++++++++++++++++++++--
4 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index 66ed103..3888ff3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,5 +1,6 @@
#!/bin/sh
aclocal && \
+autoheader && \
autoconf && \
automake --add-missing --copy
diff --git a/configure.ac b/configure.ac
index 039a269..560cc82 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,9 +2,9 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.65])
-AC_INIT([elfix], [0.1], [blueness@gentoo.org])
+AC_INIT([elfix], [0.1.3], [http://bugs.gentoo.org/])
AC_CONFIG_SRCDIR([src/fix-gnustack.c])
-#AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.11 foreign])
AC_ARG_ENABLE(
diff --git a/poc/mangle-paxflags.c b/poc/mangle-paxflags.c
index 8853b13..301dad7 100644
--- a/poc/mangle-paxflags.c
+++ b/poc/mangle-paxflags.c
@@ -28,6 +28,8 @@
#include <fcntl.h>
#include <unistd.h>
+#include <config.h>
+
// From chpax.h
#define EI_PAX 14 // Index in e_ident[] where to read flags
#define HF_PAX_PAGEEXEC 1 // 0: Paging based non-exec pages
@@ -37,22 +39,40 @@
#define HF_PAX_RANDEXEC 16 // 1: Randomize ET_EXEC base
#define HF_PAX_SEGMEXEC 32 // 0: Segmentation based non-exec pages
-
#define PRINT(E,F,I) printf("%s:\t%s\n", #E, E & F ? ( I ? "enabled" : "disabled" ) : ( I ? "disabled" : "enabled" ) );
#define CASE(N,P) case P: printf("%d: %s\n", (int)N, #P); break
+void
+print_help(char *v)
+{
+ printf(
+ "Package Name : " PACKAGE_STRING "\n"
+ "Bug Reports : " PACKAGE_BUGREPORT "\n"
+ "Description : Check for, or conditionally remove, executable flag from PT_GNU_STACK\n\n"
+ "Usage : %s {-h | [-e] [-p] ELFfile}\n"
+ "options : Print out EI_PAX and PT_PAX_FLAGS information\n"
+ " : -e Set all EI_PAX flags to least secure setting, pEmrXs\n"
+ " : -p Remove PT_PAX_FLAGS program header\n"
+ " : -h Print out this help\n",
+ v
+ );
+
+ exit(EXIT_SUCCESS);
+}
+
+
char *
parse_cmd_args( int c, char *v[], int *flag_ei_pax, int *flag_pt_pax_flags )
{
int i, oc;
if((c != 2)&&(c != 3)&&(c != 4))
- error(EXIT_FAILURE, 0, "Usage: %s [-e] [-p] elffile", v[0]);
+ error(EXIT_FAILURE, 0, "Usage: %s {[-e] [-p] ELFfile | [-h]}", v[0]);
*flag_ei_pax = 0;
*flag_pt_pax_flags = 0;
- while((oc = getopt(c, v,":ep")) != -1)
+ while((oc = getopt(c, v,":eph")) != -1)
switch(oc)
{
case 'e':
@@ -61,6 +81,9 @@ parse_cmd_args( int c, char *v[], int *flag_ei_pax, int *flag_pt_pax_flags )
case 'p':
*flag_pt_pax_flags = 1;
break;
+ case 'h':
+ print_help(v[0]);
+ break;
case '?':
default:
error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ;
diff --git a/src/fix-gnustack.c b/src/fix-gnustack.c
index 75d72ea..02eb4d5 100644
--- a/src/fix-gnustack.c
+++ b/src/fix-gnustack.c
@@ -28,6 +28,25 @@
#include <fcntl.h>
#include <unistd.h>
+#include <config.h>
+
+
+void
+print_help(char *v)
+{
+ printf(
+ "Package Name : " PACKAGE_STRING "\n"
+ "Bug Reports : " PACKAGE_BUGREPORT "\n"
+ "Description : Check for, or conditionally remove, executable flag from PT_GNU_STACK\n\n"
+ "Usage : %s {[-f] ELFfile | [-h]}\n"
+ "options : Print out protection flags on PT_GNU_STACK\n"
+ " : -f Remove X if WX flags are set on PT_GNU_STACK\n"
+ " : -h Print out this help\n",
+ v
+ );
+
+ exit(EXIT_SUCCESS);
+}
char *
@@ -36,15 +55,18 @@ parse_cmd_args( int c, char *v[], int *flagv )
int i, oc;
if((c != 2)&&(c != 3))
- error(EXIT_FAILURE, 0, "Usage: %s [-f] elffile", v[0]);
+ error(EXIT_FAILURE, 0, "Usage: %s {-h | [-f] ELFfile}", v[0]);
*flagv = 0 ;
- while((oc = getopt(c, v,":f")) != -1)
+ while((oc = getopt(c, v,":fh")) != -1)
switch(oc)
{
case 'f':
*flagv = 1 ;
break ;
+ case 'h':
+ print_help(v[0]);
+ break;
case '?':
default:
error(EXIT_FAILURE, 0, "option -%c is invalid: ignored.", optopt ) ;
next reply other threads:[~2011-05-05 23:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-05 23:50 Anthony G. Basile [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-05-06 2:43 [gentoo-commits] proj/elfix:master commit in: src/, /, poc/ Anthony G. Basile
2011-05-07 2:21 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=646f75362042124158b075efb3c7eb8cd779539f.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