public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/elfix:master commit in: scripts/, /
@ 2015-09-03 22:49 Anthony G. Basile
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2015-09-03 22:49 UTC (permalink / raw
  To: gentoo-commits

commit:     0c769ad9174df3da0bec260f675d64c5b40d7061
Author:     James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Thu Sep  3 21:23:29 2015 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Sep  3 22:48:58 2015 +0000
URL:        https://gitweb.gentoo.org/proj/elfix.git/commit/?id=0c769ad9

scripts/paxmark.sh: make.conf can be a directory

Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>

 ChangeLog          |  4 ++++
 scripts/paxmark.sh | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d9993b1..f602585 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-09-03
+
+	* scripts/paxmark.sh: make.conf can be a directory
+
 2014-12-22
 
 	* scripts/paxmark.sh: remove erroneous elog functions

diff --git a/scripts/paxmark.sh b/scripts/paxmark.sh
index 408e6aa..9d151f0 100755
--- a/scripts/paxmark.sh
+++ b/scripts/paxmark.sh
@@ -87,6 +87,14 @@ paxmarksh() {
 }
 
 MAKE_CONF="/etc/portage/make.conf"
-[[ -e $MAKE_CONF ]] && source $MAKE_CONF
+
+if [[ -d $MAKE_CONF ]]; then
+	for MC in $MAKE_CONF/*; do
+		source $MC
+	done
+elif [[ -e $MAKE_CONF ]]; then
+	source $MAKE_CONF
+fi
+
 PAX_MARKINGS=${PAX_MARKINGS:="PT"}
 paxmarksh "$@"


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: scripts/, /
@ 2013-05-21 15:21 Anthony G. Basile
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2013-05-21 15:21 UTC (permalink / raw
  To: gentoo-commits

commit:     23bd1a2c5cf2e448001e78b197ca9dae9e00988d
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 15:20:10 2013 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Tue May 21 15:20:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=23bd1a2c

Rename scripts/pax-mark -> scripts/paxmark.sh to avoid name collision with the eclass

---
 ChangeLog                        |    4 ++--
 scripts/Makefile.am              |    2 +-
 scripts/{pax-mark => paxmark.sh} |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 03ee71e..c6b049f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,8 +5,8 @@
 	elfutils from libelf.  The former will not build on uclibc, but the laster
 	does not provide ELF_C_RDWR_MMAP.
 	* Clean up the tests so they work for all combinations of --{en,dis}able-{pt,xt}pax
-	* Add a bash utility which does pax-marking like the eclass.  This is for
-	build systems that do pax-marking during the build.
+	* Add a bash utility, paxmark.sh, which does PaX marking like the eclass.  This is for
+	build systems that do PaX marking during the build.
 
 2012-12-28
 

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 5cef3e1..e5e5291 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1,4 +1,4 @@
 ACLOCAL_AMFLAGS = -I m4
 
-dist_sbin_SCRIPTS = migrate-pax pax-mark pypaxctl revdep-pax
+dist_sbin_SCRIPTS = migrate-pax paxmark.sh pypaxctl revdep-pax
 EXTRA_DIST = paxmodule.c setup.py

diff --git a/scripts/pax-mark b/scripts/paxmark.sh
similarity index 99%
rename from scripts/pax-mark
rename to scripts/paxmark.sh
index c8fc7ed..02f966e 100755
--- a/scripts/pax-mark
+++ b/scripts/paxmark.sh
@@ -5,7 +5,7 @@ has() {
 	return 1
 }
 
-pax-mark() {
+paxmarksh() {
 
 	local f					# loop over paxables
 	local flags				# pax flags
@@ -108,4 +108,4 @@ pax-mark() {
 }
 
 PAX_MARKINGS=${PAX_MARKINGS:="PT XT"}
-pax-mark "$@"
+paxmarksh "$@"


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: scripts/, /
@ 2012-12-13 20:37 Anthony G. Basile
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2012-12-13 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f54c4dc0be5c0a0572250db2b73a4e809e74e8d1
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 13 20:34:58 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Dec 13 20:34:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=f54c4dc0

scripts/paxmodule.c: do not use '-' when setting null XATTR PAX flags

This repeats the fix for src/paxctl-ng.c but for scripts/paxmodule.c.
TODO: There is a lot of shared code between the two and a convenience
library should be to minimize the repeated code.

X-Gentoo-Bug: 446518
X-Gentoo-Bug-URL: https://bugs.gentoo.org/446518

---
 TODO                |    2 +-
 scripts/paxmodule.c |  107 +++++++++++++++++++++++++++++++++++----------------
 2 files changed, 75 insertions(+), 34 deletions(-)

diff --git a/TODO b/TODO
index 83b1012..a58192d 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,3 @@
 
 	* src/paxctl-ng.c: add verbose error reporting for xattr (like for set/get phdr)
-
+	* src/paxctl-ng.c, scripts/paxmodule.c: reduce the shared code to a convenience library

diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index 8ae10be..422d193 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -162,32 +162,36 @@ get_pt_flags(int fd)
 uint16_t
 string2bin(char *buf)
 {
+	int i;
 	uint16_t flags = 0;
 
-	if( buf[0] == 'P' )
-		flags |= PF_PAGEEXEC;
-	else if( buf[0] == 'p' )
-		flags |= PF_NOPAGEEXEC;
-
-	if( buf[1] == 'S' )
-		flags |= PF_SEGMEXEC;
-	else if( buf[1] == 's' )
-		flags |= PF_NOSEGMEXEC;
-
-	if( buf[2] == 'M' )
-		flags |= PF_MPROTECT;
-	else if( buf[2] == 'm' )
-		flags |= PF_NOMPROTECT;
-
-	if( buf[3] == 'E' )
-		flags |= PF_EMUTRAMP;
-	else if( buf[3] == 'e' )
-		flags |= PF_NOEMUTRAMP;
-
-	if( buf[4] == 'R' )
-		flags |= PF_RANDMMAP;
-	else if( buf[4] == 'r' )
-		flags |= PF_NORANDMMAP;
+	for(i = 0; i < 5; i++)
+	{
+		if(buf[i] == 'P')
+			flags |= PF_PAGEEXEC;
+		else if(buf[i] == 'p')
+			flags |= PF_NOPAGEEXEC;
+
+		if(buf[i] == 'E')
+			flags |= PF_EMUTRAMP;
+		else if(buf[i] == 'e')
+			flags |= PF_NOEMUTRAMP;
+
+		if(buf[i] == 'M')
+			flags |= PF_MPROTECT;
+		else if(buf[i] == 'm')
+			flags |= PF_NOMPROTECT;
+
+		if(buf[i] == 'R')
+			flags |= PF_RANDMMAP;
+		else if(buf[i] == 'r')
+			flags |= PF_NORANDMMAP;
+
+		if(buf[i] == 'S')
+			flags |= PF_SEGMEXEC;
+		else if(buf[i] == 's')
+			flags |= PF_NOSEGMEXEC;
+	}
 
 	return flags;
 }
@@ -211,22 +215,59 @@ get_xt_flags(int fd)
 
 
 void
-bin2string(uint16_t flags, char *buf)
+bin2string4print(uint16_t flags, char *buf)
 {
 	buf[0] = flags & PF_PAGEEXEC ? 'P' :
 		flags & PF_NOPAGEEXEC ? 'p' : '-' ;
 
-	buf[1] = flags & PF_SEGMEXEC   ? 'S' :
-		flags & PF_NOSEGMEXEC ? 's' : '-';
+	buf[1] = flags & PF_EMUTRAMP   ? 'E' :
+		flags & PF_NOEMUTRAMP ? 'e' : '-';
 
 	buf[2] = flags & PF_MPROTECT   ? 'M' :
 		flags & PF_NOMPROTECT ? 'm' : '-';
 
-	buf[3] = flags & PF_EMUTRAMP   ? 'E' :
-		flags & PF_NOEMUTRAMP ? 'e' : '-';
-
-	buf[4] = flags & PF_RANDMMAP   ? 'R' :
+	buf[3] = flags & PF_RANDMMAP   ? 'R' :
 		flags & PF_NORANDMMAP ? 'r' : '-';
+
+	buf[4] = flags & PF_SEGMEXEC   ? 'S' :
+		flags & PF_NOSEGMEXEC ? 's' : '-';
+}
+
+
+void
+bin2string(uint16_t flags, char *buf)
+{
+	int i;
+
+	for(i = 0; i < 5; i++)
+		buf[i] = 0;
+
+	i = 0;
+
+	if(flags & PF_PAGEEXEC)
+		buf[i++] = 'P';
+	else if(flags & PF_NOPAGEEXEC)
+		buf[i++] = 'p';
+
+	if(flags & PF_EMUTRAMP)
+		buf[i++] = 'E';
+	else if(flags & PF_NOEMUTRAMP)
+		buf[i++] = 'e';
+
+	if(flags & PF_MPROTECT)
+		buf[i++] = 'M';
+	else if(flags & PF_NOMPROTECT)
+		buf[i++] = 'm';
+
+	if(flags & PF_RANDMMAP)
+		buf[i++] = 'R';
+	if(flags & PF_NORANDMMAP)
+		buf[i++] = 'r';
+
+	if(flags & PF_SEGMEXEC)
+		 buf[i++] = 'S';
+	else if(flags & PF_NOSEGMEXEC)
+		buf[i++] = 's';
 }
 
 
@@ -266,7 +307,7 @@ pax_getflags(PyObject *self, PyObject *args)
 	if( flags != UINT16_MAX )
 	{
 		memset(buf, 0, FLAGS_SIZE);
-		bin2string(flags, buf);
+		bin2string4print(flags, buf);
 	}
 #endif
 
@@ -275,7 +316,7 @@ pax_getflags(PyObject *self, PyObject *args)
 	if( flags != UINT16_MAX )
 	{
 		memset(buf, 0, FLAGS_SIZE);
-		bin2string(flags, buf);
+		bin2string4print(flags, buf);
 	}
 #endif
 


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: scripts/, /
@ 2012-07-21 16:13 Anthony G. Basile
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2012-07-21 16:13 UTC (permalink / raw
  To: gentoo-commits

commit:     a245f5a428d1f1fb54bfc7bf7d93a25566c5314e
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 21 16:13:42 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jul 21 16:13:42 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=a245f5a4

scripts/paxmodule.c: add setstrstring function

---
 .gitignore          |    2 ++
 scripts/paxmodule.c |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3d33206..0de2e42 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,5 @@ fix-gnustack
 paxctl-ng
 bad-gnustack
 daemon
+#
+scripts/build

diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index bd009dc..18c64aa 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -329,3 +329,35 @@ pax_setflags(PyObject *self, PyObject *args)
 
 	return Py_BuildValue("");
 }
+
+static PyObject *
+pax_setstrflags(PyObject *self, PyObject *args)
+{
+	const char *f_name, *sflags;
+	int fd;
+	uint16_t flags;
+
+	if (!PyArg_ParseTuple(args, "ss", &f_name, &sflags))
+	{
+		PyErr_SetString(PaxError, "pax_setflags: PyArg_ParseTuple failed");
+		return NULL;
+	}
+
+	if((fd = open(f_name, O_RDWR)) < 0)
+	{
+		PyErr_SetString(PaxError, "pax_setflags: open() failed");
+		return NULL;
+	}
+
+	flags = string2bin(sflags);
+
+	set_pt_flags(fd, flags);
+
+#ifdef XATTR
+	set_xt_flags(fd, flags);
+#endif
+
+	close(fd);
+
+	return Py_BuildValue("");
+}


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: scripts/, /
@ 2012-07-21 13:45 Anthony G. Basile
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2012-07-21 13:45 UTC (permalink / raw
  To: gentoo-commits

commit:     ee28fa8fd2bbaabcab2c11a8f8862f52150a63ae
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 21 13:45:23 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Jul 21 13:45:23 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=ee28fa8f

scripts/paxmodule.c: switch to string implementation of XT_PAX

---
 .gitignore          |    1 +
 scripts/paxmodule.c |   56 +++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index 5321107..3d33206 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ stamp-h1
 #
 .deps
 *.o
+*.swp
 fix-gnustack
 paxctl-ng
 bad-gnustack

diff --git a/scripts/paxmodule.c b/scripts/paxmodule.c
index b665412..3dfc656 100644
--- a/scripts/paxmodule.c
+++ b/scripts/paxmodule.c
@@ -31,12 +31,12 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#define BUF_SIZE	7	//Buffer size for holding human readable flags
-
 #ifdef XATTR
-#define PAX_NAMESPACE	"user.pax"
+#define PAX_NAMESPACE	"user.pax.flags"
 #endif
 
+#define FLAGS_SIZE	6
+
 
 static PyObject * pax_getflags(PyObject *, PyObject *);
 static PyObject * pax_setflags(PyObject *, PyObject *);
@@ -114,11 +114,50 @@ get_pt_flags(int fd)
 
 #ifdef XATTR
 uint16_t
+string2bin(char *buf)
+{
+	uint16_t flags = 0;
+
+	if( buf[0] == 'P' )
+		flags |= PF_PAGEEXEC;
+	else if( buf[0] == 'p' )
+		flags |= PF_NOPAGEEXEC;
+
+	if( buf[1] == 'S' )
+		flags |= PF_SEGMEXEC;
+	else if( buf[1] == 's' )
+		flags |= PF_NOSEGMEXEC;
+
+	if( buf[2] == 'M' )
+		flags |= PF_MPROTECT;
+	else if( buf[2] == 'm' )
+		flags |= PF_NOMPROTECT;
+
+	if( buf[3] == 'E' )
+		flags |= PF_EMUTRAMP;
+	else if( buf[3] == 'e' )
+		flags |= PF_NOEMUTRAMP;
+
+	if( buf[4] == 'R' )
+		flags |= PF_RANDMMAP;
+	else if( buf[4] == 'r' )
+		flags |= PF_NORANDMMAP;
+
+	return flags;
+}
+
+
+uint16_t
 get_xt_flags(int fd)
 {
+	char buf[FLAGS_SIZE];
 	uint16_t xt_flags = UINT16_MAX;
 
-	fgetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t));
+	memset(buf, 0, FLAGS_SIZE);
+
+	if(fgetxattr(fd, PAX_NAMESPACE, buf, FLAGS_SIZE) != -1)
+		xt_flags = string2bin(buf);
+
 	return xt_flags;
 }
 #endif
@@ -141,9 +180,6 @@ bin2string(uint16_t flags, char *buf)
 
 	buf[4] = flags & PF_RANDMMAP   ? 'R' :
 		flags & PF_NORANDMMAP ? 'r' : '-';
-
-	buf[5] = flags & PF_RANDEXEC   ? 'X' :
-		flags & PF_NORANDEXEC ? 'x' : '-';
 }
 
 
@@ -253,7 +289,11 @@ set_pt_flags(int fd, uint16_t pt_flags)
 void
 set_xt_flags(int fd, uint16_t xt_flags)
 {
-	fsetxattr(fd, PAX_NAMESPACE, &xt_flags, sizeof(uint16_t), 0);
+	char buf[FLAGS_SIZE];
+
+	memset(buf, 0, FLAGS_SIZE);
+	bin2string(xt_flags, buf);
+	fsetxattr(fd, PAX_NAMESPACE, buf, strlen(buf), XATTR_REPLACE);
 }
 #endif
 



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/elfix:master commit in: scripts/, /
@ 2011-10-23 16:13 Anthony G. Basile
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony G. Basile @ 2011-10-23 16:13 UTC (permalink / raw
  To: gentoo-commits

commit:     5d77ef93c39b0f26350ef4a691ddd9d3cb438023
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 23 16:13:34 2011 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Oct 23 16:13:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=5d77ef93

Update build system

---
 configure.ac        |    2 +-
 scripts/Makefile.am |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 592d346..24508c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.65])
-AC_INIT([elfix], [0.3], [http://bugs.gentoo.org/])
+AC_INIT([elfix], [0.4], [http://bugs.gentoo.org/])
 AC_CONFIG_SRCDIR([src/fix-gnustack.c])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([1.11 foreign])

diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 089cc3c..5cbc314 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1 +1,2 @@
 dist_sbin_SCRIPTS = revdep-pax
+EXTRA_DIST = paxmodule.c setup.py



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-03 22:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-03 22:49 [gentoo-commits] proj/elfix:master commit in: scripts/, / Anthony G. Basile
  -- strict thread matches above, loose matches on Subject: below --
2013-05-21 15:21 Anthony G. Basile
2012-12-13 20:37 Anthony G. Basile
2012-07-21 16:13 Anthony G. Basile
2012-07-21 13:45 Anthony G. Basile
2011-10-23 16:13 Anthony G. Basile

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox