diff --git a/Makefile.am b/Makefile.am index 0079d94..ae35ca0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,7 @@ libhttp_la_SOURCES = libhttp/hashmap.c \ $(LIBHTTP_INCLUDES) \ libhttp/libhttp.sym libhttp_la_LDFLAGS = -export-symbols $(top_srcdir)/libhttp/libhttp.sym \ - -version 1:0:0 -ldl + -version 1:0:0 shellinaboxd_SOURCES = shellinabox/shellinaboxd.c \ shellinabox/externalfile.c \ @@ -71,21 +71,24 @@ shellinaboxd_SOURCES = shellinabox/shellinaboxd.c \ shellinabox/beep.wav shellinaboxd_LDADD = liblogging.la \ libhttp.la -shellinaboxd_LDFLAGS = -static -ldl +shellinaboxd_LDFLAGS = -static libtool: $(LIBTOOL_DEPS) $(SHELL) ./config.status --recheck shellinaboxd.1: shellinabox/shellinaboxd.man.in - @echo preprocess "$<" '>'"$@" - @if echo " $(DEFS)" | grep HAVE_OPENSSL_BIO_H | \ - grep HAVE_OPENSSL_ERR_H | \ - grep -q HAVE_OPENSSL_SSL_H; then \ - sed -e '/^#ifdef *HAVE_OPENSSL$$/d;/^#endif$$/d' "$<" >"$@"; \ - else \ - sed -e '/^#ifdef *HAVE_OPENSSL$$/,/^#endif$$/d' "$<" >"$@"; \ - fi - @man -Tps "./$@" >`echo "$@"|sed -e 's/\.[^.]*$$/.ps/'` || true + @src="${top_srcdir}/shellinabox/shellinaboxd.man.in"; \ + echo preprocess "$$src" '>'"$@"; \ + if echo " $(DEFS)" | grep HAVE_OPENSSL_BIO_H | \ + grep HAVE_OPENSSL_ERR_H | \ + grep -q HAVE_OPENSSL_SSL_H; then \ + sed -e '/^#ifdef *HAVE_OPENSSL$$/d' \ + -e '/^#endif$$/d' "$$src" >"$@"; \ + else \ + sed -e '/^#ifdef *HAVE_OPENSSL$$/,/^#endif$$/d' "$$src" >"$@"; \ + fi + @man -Tps "./$@" >`echo "$@" 2>/dev/null|sed -e 's/\.[^.]*$$/.ps/'` \ + || true clean-local: -rm -rf shellinaboxd.1 \ @@ -99,114 +102,135 @@ clean-local: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" .html.o: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" .ico.o: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" .js.o: @$(ECHO) preprocess "$<" \| objcopy "$@" @trap 'rm -f "$@.pre"' EXIT INT TERM QUIT; \ - sed -e "`sed -e 's/^#define *\([^ ]*\) *\(.*\)/\/^[^#]\/s\/\1\/\2 \\\\\/* \1 *\\\\\/\/g/; \ - t;d' "$<"` \ - ;s/^#/\/\/ #/ \ - ;s/VERSION/\"@VERSION@\"/g" "$<" >"$@.pre" && \ -objcopy \ + sed -e "`sed -e 's/^#define *\([^ ]*\) *\(.*\)/\/^[^#]\/s\/\1\/\2 \\\\\/* \1 *\\\\\/\/g/' \ + -e t \ + -e d "$<"`" \ + -e "s/^#/\/\/ #/" \ + -e "s/VERSION/\"@VERSION@\"/g" "$<" >"$@.pre" && \ + \ -I binary `echo $(host_cpu) | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$@" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_pre_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_pre_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_pre_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$@" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_pre_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_pre_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_pre_size/'` \ "$@.pre" "$@" .wav.o: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" diff --git a/Makefile.in b/Makefile.in index 90ee59b..a310b45 100644 --- a/Makefile.in +++ b/Makefile.in @@ -287,7 +287,7 @@ libhttp_la_SOURCES = libhttp/hashmap.c \ libhttp/libhttp.sym libhttp_la_LDFLAGS = -export-symbols $(top_srcdir)/libhttp/libhttp.sym \ - -version 1:0:0 -ldl + -version 1:0:0 shellinaboxd_SOURCES = shellinabox/shellinaboxd.c \ shellinabox/externalfile.c \ @@ -311,7 +311,7 @@ shellinaboxd_SOURCES = shellinabox/shellinaboxd.c \ shellinaboxd_LDADD = liblogging.la \ libhttp.la -shellinaboxd_LDFLAGS = -static -ldl +shellinaboxd_LDFLAGS = -static all: all-am .SUFFIXES: @@ -968,15 +968,18 @@ libtool: $(LIBTOOL_DEPS) $(SHELL) ./config.status --recheck shellinaboxd.1: shellinabox/shellinaboxd.man.in - @echo preprocess "$<" '>'"$@" - @if echo " $(DEFS)" | grep HAVE_OPENSSL_BIO_H | \ - grep HAVE_OPENSSL_ERR_H | \ - grep -q HAVE_OPENSSL_SSL_H; then \ - sed -e '/^#ifdef *HAVE_OPENSSL$$/d;/^#endif$$/d' "$<" >"$@"; \ - else \ - sed -e '/^#ifdef *HAVE_OPENSSL$$/,/^#endif$$/d' "$<" >"$@"; \ - fi - @man -Tps "./$@" >`echo "$@"|sed -e 's/\.[^.]*$$/.ps/'` || true + @src="${top_srcdir}/shellinabox/shellinaboxd.man.in"; \ + echo preprocess "$$src" '>'"$@"; \ + if echo " $(DEFS)" | grep HAVE_OPENSSL_BIO_H | \ + grep HAVE_OPENSSL_ERR_H | \ + grep -q HAVE_OPENSSL_SSL_H; then \ + sed -e '/^#ifdef *HAVE_OPENSSL$$/d' \ + -e '/^#endif$$/d' "$$src" >"$@"; \ + else \ + sed -e '/^#ifdef *HAVE_OPENSSL$$/,/^#endif$$/d' "$$src" >"$@"; \ + fi + @man -Tps "./$@" >`echo "$@" 2>/dev/null|sed -e 's/\.[^.]*$$/.ps/'` \ + || true clean-local: -rm -rf shellinaboxd.1 \ @@ -990,115 +993,136 @@ clean-local: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" .html.o: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" .ico.o: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" .js.o: @$(ECHO) preprocess "$<" \| objcopy "$@" @trap 'rm -f "$@.pre"' EXIT INT TERM QUIT; \ - sed -e "`sed -e 's/^#define *\([^ ]*\) *\(.*\)/\/^[^#]\/s\/\1\/\2 \\\\\/* \1 *\\\\\/\/g/; \ - t;d' "$<"` \ - ;s/^#/\/\/ #/ \ - ;s/VERSION/\"@VERSION@\"/g" "$<" >"$@.pre" && \ -objcopy \ + sed -e "`sed -e 's/^#define *\([^ ]*\) *\(.*\)/\/^[^#]\/s\/\1\/\2 \\\\\/* \1 *\\\\\/\/g/' \ + -e t \ + -e d "$<"`" \ + -e "s/^#/\/\/ #/" \ + -e "s/VERSION/\"@VERSION@\"/g" "$<" >"$@.pre" && \ + \ -I binary `echo $(host_cpu) | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$@" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_pre_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_pre_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_pre_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$@" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_pre_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_pre_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_pre_size/'` \ "$@.pre" "$@" .wav.o: @$(ECHO) objcopy "$<" "$@" @objcopy \ -I binary `echo "$(host_cpu)" | \ - grep -q '^i[0-9]86$$' && \ - echo ' -O elf32-i386 -B i386' || \ - echo ' -O elf64-x86-64 -B i386:x86-64'` \ - `echo "$<" | sed -e ' \ - s/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /; \ - t0; s/\([^.]*\)\([.].*\)/\1\2=\1 /; t0; s/.*/&=& /;:0; \ - s/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/; \ - :1; \ - s/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/; \ - t1; \ - s/.\{53\}$$//; \ - s/[/.]/_/g; \ - s/^/--redefine-sym _binary_/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/; \ - s/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/; \ - s/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ + grep -q '^i[0-9]86$$' && \ + echo ' -O elf32-i386 -B i386' || \ + echo ' -O elf64-x86-64 -B i386:x86-64'` \ + `echo "$<" | sed \ + -e 's/\(.*\/\)\([^.]*\)\([.].*\)/\1\2\3=\2 /' \ + -e 't0' \ + -e 's/\([^.]*\)\([.].*\)/\1\2=\1 /' \ + -e 't0' \ + -e 's/.*/&=& /' \ + -e ':0' \ + -e 's/$$/aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ/' \ + -e ':1' \ + -e 's/\(=[^_]*\)_\([a-z]\)\([^ ]* .*\2\)\(.\)/\1\4\3\4/' \ + -e 't1' \ + -e 's/.\{53\}$$//' \ + -e 's/[/.]/_/g' \ + -e 's/^/--redefine-sym _binary_/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_end\2End/' \ + -e 's/\([^=]*\)\(=[^ ]*\)/& \1_start\2Start/' \ + -e 's/[^ ]*\([^=]*\)=[^ ]*/-N\1_size/'` \ "$<" "$@" # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/configure b/configure index 4b855d8..2822d09 100755 --- a/configure +++ b/configure @@ -20142,6 +20142,219 @@ fi done + +for ac_func in dlopen +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + LIBS="-ldl $LIBS" +fi + +fi +done + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef _XOPEN_SOURCE + #define _XOPEN_SOURCE + #endif + #ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + #include +int +main () +{ +ptsname_r(0, 0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_PTSNAME_R 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF diff --git a/configure.ac b/configure.ac index f321526..4a2a6cf 100644 --- a/configure.ac +++ b/configure.ac @@ -10,5 +10,17 @@ AC_PROG_GCC_TRADITIONAL AC_CHECK_HEADERS([openssl/bio.h openssl/err.h openssl/ssl.h pthread.h \ security/pam_appl.h security/pam_misc.h sys/prctrl.h \ utmpx.h]) +AC_CHECK_FUNCS(dlopen, [], + [AC_CHECK_LIB(dl, dlopen, LIBS="-ldl $LIBS")]) +AC_TRY_LINK([#ifndef _XOPEN_SOURCE + #define _XOPEN_SOURCE + #endif + #ifndef _GNU_SOURCE + #define _GNU_SOURCE + #endif + #include ], + [ptsname_r(0, 0, 0);], + [AC_DEFINE(HAVE_PTSNAME_R, 1, + Define to 1 if you have a re-entrant version of ptsname)]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c index 8c3c07c..5d11c75 100644 --- a/shellinabox/launcher.c +++ b/shellinabox/launcher.c @@ -366,11 +366,35 @@ void closeAllFds(int *exceptFds, int num) { } } +#ifndef HAVE_PTSNAME_R +static int ptsname_r(int fd, char *buf, size_t buflen) { + // It is unfortunate that ptsname_r is not universally available. + // For the time being, this is not a big problem, as ShellInABox is + // single-threaded (and so is the launcher process). But if this + // code gets re-used in a multi-threaded application, that could + // lead to problems. + if (buf == NULL) { + errno = EINVAL; + return -1; + } + char *p = ptsname(fd); + if (p == NULL) { + return -1; + } + if (buflen < strlen(p) + 1) { + errno = ERANGE; + return -1; + } + strcpy(buf, p); + return 0; +} +#endif + static int forkPty(int *pty, int useLogin, struct Utmp **utmp, const char *peerName) { int slave; char ptyPath[PATH_MAX]; - if ((*pty = getpt()) < 0 || + if ((*pty = posix_openpt(O_RDWR|O_NOCTTY)) < 0 || grantpt(*pty) < 0 || unlockpt(*pty) < 0 || ptsname_r(*pty, ptyPath, sizeof(ptyPath)) < 0 || @@ -438,7 +462,9 @@ static const struct passwd *getPWEnt(uid_t uid) { struct passwd pwbuf, *pw; char *buf; int len = sysconf(_SC_GETPW_R_SIZE_MAX); - check(len > 0); + if (len <= 0) { + len = 4096; + } check(buf = malloc(len)); check(!getpwuid_r(uid, &pwbuf, buf, len, &pw) && pw); struct passwd *passwd; diff --git a/shellinabox/privileges.c b/shellinabox/privileges.c index 2ee6ef5..b321f3b 100644 --- a/shellinabox/privileges.c +++ b/shellinabox/privileges.c @@ -156,7 +156,9 @@ const char *getUserName(uid_t uid) { struct passwd pwbuf, *pw; char *buf; int len = sysconf(_SC_GETPW_R_SIZE_MAX); - check(len > 0); + if (len <= 0) { + len = 4096; + } check(buf = malloc(len)); char *user; if (getpwuid_r(uid, &pwbuf, buf, len, &pw) || !pw) { @@ -172,13 +174,15 @@ const char *getUserName(uid_t uid) { uid_t getUserId(const char *name) { struct passwd pwbuf, *pw; char *buf; - int len = sysconf(_SC_GETPW_R_SIZE_MAX); - check(len > 0); - check(buf = malloc(len)); + int len = sysconf(_SC_GETPW_R_SIZE_MAX); + if (len <= 0) { + len = 4096; + } + check(buf = malloc(len)); if (getpwnam_r(name, &pwbuf, buf, len, &pw) || !pw) { fatal("Cannot look up user id \"%s\"", name); } - uid_t uid = pw->pw_uid; + uid_t uid = pw->pw_uid; free(buf); return uid; } @@ -204,7 +208,9 @@ const char *getGroupName(gid_t gid) { struct group grbuf, *gr; char *buf; int len = sysconf(_SC_GETGR_R_SIZE_MAX); - check(len > 0); + if (len <= 0) { + len = 4096; + } check(buf = malloc(len)); char *group; if (getgrgid_r(gid, &grbuf, buf, len, &gr) || !gr) { @@ -221,7 +227,9 @@ gid_t getGroupId(const char *name) { struct group grbuf, *gr; char *buf; int len = sysconf(_SC_GETGR_R_SIZE_MAX); - check(len > 0); + if (len <= 0) { + len = 4096; + } check(buf = malloc(len)); if (getgrnam_r(name, &grbuf, buf, len, &gr) || !gr) { fatal("Cannot look up group \"%s\"", name);