1 diff -urNp -x '*.orig' chrpath-0.16.org/Makefile.am chrpath-0.16/Makefile.am
2 --- chrpath-0.16.org/Makefile.am 2014-01-12 08:52:21.000000000 +0100
3 +++ chrpath-0.16/Makefile.am 2023-12-16 18:36:06.850493419 +0100
4 @@ -12,12 +12,19 @@ debs:
5 fakeroot debian/rules binary
16 +lib_LTLIBRARIES = libchrpath32.la libchrpath64.la
17 +libchrpath32_la_SOURCES = chrpath.c killrpath.c elf.c protos.h
18 +libchrpath32_la_CFLAGS = -DSIZEOF_VOID_P=4
19 +libchrpath32_la_LDFLAGS = -avoid-version
20 +libchrpath64_la_SOURCES = chrpath.c killrpath.c elf.c protos.h
21 +libchrpath64_la_CFLAGS = -DSIZEOF_VOID_P=8
22 +libchrpath64_la_LDFLAGS = -avoid-version
24 EXTRA_DIST = $(man_MANS)
27 diff -urNp -x '*.orig' chrpath-0.16.org/configure.ac chrpath-0.16/configure.ac
28 --- chrpath-0.16.org/configure.ac 2014-01-12 09:01:52.000000000 +0100
29 +++ chrpath-0.16/configure.ac 2023-12-16 18:36:06.850493419 +0100
30 @@ -16,6 +16,7 @@ CHRPATH_LDRPATH_OPTION
31 dnl Checks for programs.
36 dnl Checks for libraries.
38 @@ -26,7 +27,6 @@ AC_CHECK_HEADERS([getopt.h elf.h fcntl.h
39 dnl Checks for typedefs, structures, and compiler characteristics.
42 -AC_CHECK_SIZEOF(void *)
44 dnl Checks for library functions.
45 AC_CHECK_FUNCS(getopt_long)
46 diff -urNp -x '*.orig' chrpath-0.16.org/main.c chrpath-0.16/main.c
47 --- chrpath-0.16.org/main.c 2014-01-14 10:15:59.000000000 +0100
48 +++ chrpath-0.16/main.c 2023-12-16 18:36:06.850493419 +0100
65 +typedef int (*killrpath_t)(const char *filename);
66 +typedef int (*chrpath_t)(const char *filename, const char *newpath, int convert);
68 #ifdef HAVE_GETOPT_LONG
69 # define GETOPT_LONG getopt_long
70 @@ -63,6 +69,30 @@ usage(char *progname)
75 +elf_class(const char *filename)
80 + fd = open(filename, O_RDONLY);
83 + if (read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr))
89 + if ((memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0)
90 + || (ehdr.e_ident[EI_VERSION] != EV_CURRENT))
92 + fprintf(stderr, "`%s' probably isn't an ELF file.\n", filename);
95 + return ehdr.e_ident[EI_CLASS];
99 main(int argc, char * const argv[])
101 @@ -75,6 +105,9 @@ main(int argc, char * const argv[])
102 #ifdef HAVE_GETOPT_LONG
103 int option_index = 0;
104 #endif /* HAVE_GETOPT_LONG */
106 + killrpath_t killrpath[2];
107 + chrpath_t chrpath[2];
111 @@ -119,14 +152,31 @@ main(int argc, char * const argv[])
115 + dll[0] = dlopen("libchrpath32.so", RTLD_LAZY);
116 + killrpath[0] = (killrpath_t)dlsym(dll[0], "killrpath");
117 + chrpath[0] = (chrpath_t)dlsym(dll[0], "chrpath");
119 + dll[1] = dlopen("libchrpath64.so", RTLD_LAZY);
120 + killrpath[1] = (killrpath_t)dlsym(dll[1], "killrpath");
121 + chrpath[1] = (chrpath_t)dlsym(dll[1], "chrpath");
123 while (optind < argc && (!retval || keep_going))
125 + const char* program = argv[optind++];
126 + unsigned eclass = elf_class(program);
133 - retval |= killrpath(argv[optind++]);
134 + retval |= killrpath[eclass - ELFCLASS32](program);
136 /* list by default, replace if path is set */
137 - retval |= chrpath(argv[optind++], newpath, convert);
138 + retval |= chrpath[eclass - ELFCLASS32](program, newpath, convert);