aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Ludd <solar@gentoo.org>2006-02-12 16:51:21 +0000
committerNed Ludd <solar@gentoo.org>2006-02-12 16:51:21 +0000
commitca1cf5d2a495824cae329759e7ad3fc6d5a96f3f (patch)
treeabc759f3be80e3a91afca8238b1a4992ad109111
parentdont bother eating spaces anymore as our format string should cover that (diff)
downloadpax-utils-ca1cf5d2a495824cae329759e7ad3fc6d5a96f3f.tar.gz
pax-utils-ca1cf5d2a495824cae329759e7ad3fc6d5a96f3f.tar.bz2
pax-utils-ca1cf5d2a495824cae329759e7ad3fc6d5a96f3f.zip
- add include globbing support for ld.so.conf handling. mainly only useful on distros other than gentoo
-rw-r--r--BUGS8
-rw-r--r--Makefile6
-rw-r--r--porting.h8
-rw-r--r--scanelf.c53
4 files changed, 60 insertions, 15 deletions
diff --git a/BUGS b/BUGS
index 48ccf55..2df43a4 100644
--- a/BUGS
+++ b/BUGS
@@ -1,7 +1,13 @@
KNOWN BUGS
----------
-none at the moment
+dumpelf -vvvv ; This can segv on some malformed ELF files when trying to
+print *data;
+
+when using scanelf -ln and the /etc/ld.so.conf includes file which
+includes the orig /etc/ld.so.conf again will cause a recursion segv.
+This is not really a problem however as any system containing such a
+malformed ld.so.conf would have bigger problems.
REPORTING BUGS
diff --git a/Makefile b/Makefile
index 87d38bf..5e6be2c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# Copyright 2003 Ned Ludd <solar@linbsd.net>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/Makefile,v 1.49 2006/01/28 19:47:47 solar Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/Makefile,v 1.50 2006/02/12 16:51:21 solar Exp $
####################################################################
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
@@ -49,8 +49,8 @@ all: $(OBJS) $(TARGETS)
debug:
$(MAKE) CFLAGS="$(CFLAGS) -g3 -ggdb -nopie" clean all
- @-/sbin/chpax -permsx $(TARGETS)
- @-/sbin/paxctl -permsx $(TARGETS)
+ @-/sbin/chpax -permsx $(ELF_TARGETS)
+ @-/sbin/paxctl -permsx $(ELF_TARGETS)
%.o: %.c
ifeq ($(findstring s,$(MAKEFLAGS)),)
diff --git a/porting.h b/porting.h
index 4d47869..8f149b3 100644
--- a/porting.h
+++ b/porting.h
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2006 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/porting.h,v 1.11 2006/01/13 11:31:55 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/porting.h,v 1.12 2006/02/12 16:51:21 solar Exp $
*
* Copyright 2005-2006 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2006 Mike Frysinger - <vapier@gentoo.org>
@@ -29,6 +29,12 @@
#include <ctype.h>
#include <pwd.h>
+#ifndef HATE_GLOB
+# undef HAVE_GLOB
+# define HAVE_GLOB
+# include <glob.h>
+#endif
+
#include <sys/mman.h>
#include "elf.h"
#if defined(__linux__)
diff --git a/scanelf.c b/scanelf.c
index 3832614..7f26674 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2006 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.122 2006/02/11 04:11:44 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.123 2006/02/12 16:51:21 solar Exp $
*
* Copyright 2003-2006 Ned Ludd - <solar@gentoo.org>
* Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org>
@@ -9,7 +9,7 @@
#include "paxinc.h"
-static const char *rcsid = "$Id: scanelf.c,v 1.122 2006/02/11 04:11:44 vapier Exp $";
+static const char *rcsid = "$Id: scanelf.c,v 1.123 2006/02/12 16:51:21 solar Exp $";
#define argv0 "scanelf"
#define IS_MODIFIER(c) (c == '%' || c == '#')
@@ -1189,24 +1189,56 @@ static int scanelf_from_file(char *filename)
return 0;
}
-static void load_ld_so_conf()
+static int load_ld_so_conf(int i, const char *fname)
{
FILE *fp = NULL;
char *p;
char path[__PAX_UTILS_PATH_MAX];
- int i = 0;
- if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL)
- return;
+ if (i + 1 == sizeof(ldpaths) / sizeof(*ldpaths))
+ return i;
- while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
- if (*path != '/')
- continue;
+ if ((fp = fopen(fname, "r")) == NULL)
+ return i;
+ while ((fgets(path, __PAX_UTILS_PATH_MAX, fp)) != NULL) {
if ((p = strrchr(path, '\r')) != NULL)
*p = 0;
if ((p = strchr(path, '\n')) != NULL)
*p = 0;
+#ifdef HAVE_GLOB
+ // recursive includes of the same file will make this segfault.
+ if ((*path == 'i') && (strncmp(path, "include", 7) == 0) && isblank(path[7])) {
+ glob64_t gl;
+ size_t x;
+ char gpath[__PAX_UTILS_PATH_MAX];
+
+ gpath[sizeof(gpath)] = 0;
+
+ if (path[8] != '/')
+ snprintf(gpath, sizeof(gpath)-1, "/etc/%s", &path[8]);
+ else
+ strncpy(gpath, &path[8], sizeof(gpath)-1);
+
+ if ((glob64(gpath, 0, NULL, &gl)) == 0) {
+ for (x = 0; x < gl.gl_pathc; ++x) {
+ /* try to avoid direct loops */
+ if (strcmp(gl.gl_pathv[x], fname) == 0)
+ continue;
+ i = load_ld_so_conf(i, gl.gl_pathv[x]);
+ if (i + 1 >= sizeof(ldpaths) / sizeof(*ldpaths)) {
+ globfree64(&gl);
+ return i;
+ }
+ }
+ globfree64 (&gl);
+ continue;
+ } else
+ abort();
+ }
+#endif
+ if (*path != '/')
+ continue;
ldpaths[i++] = xstrdup(path);
@@ -1216,6 +1248,7 @@ static void load_ld_so_conf()
ldpaths[i] = NULL;
fclose(fp);
+ return i;
}
/* scan /etc/ld.so.conf for paths */
@@ -1508,7 +1541,7 @@ static void parseargs(int argc, char *argv[])
/* now lets actually do the scanning */
if (scan_ldpath || use_ldcache)
- load_ld_so_conf();
+ load_ld_so_conf(0, "/etc/ld.so.conf");
if (scan_ldpath) scanelf_ldpath();
if (scan_envpath) scanelf_envpath();
if (from_file) {