From a29f12e3090d7b6f9360150d51ea840989fca13d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 19:34:58 +0200 Subject: mod_http_files: Strip trailing directory separator regardless of directionality of the slash (fixes #545) --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 3a9368b9..9d81f540 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -62,7 +62,7 @@ function serve(opts) local request, response = event.request, event.response; local orig_path = request.path; local full_path = base_path .. (path and "/"..path or ""); - local attr = stat((full_path:gsub('%'..path_sep..'+$',''))); + local attr = stat(full_path:match("^.*[^\\/]")); -- Strip trailing path separator because Windows if not attr then return 404; end -- cgit v1.2.3 From 60ca835146d1b3857be9a82579907afe5449556e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 19:35:56 +0200 Subject: mod_http_files: Translate forward slashes to local directory separators --- plugins/mod_http_files.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index 9d81f540..9839fed9 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -61,7 +61,7 @@ function serve(opts) local function serve_file(event, path) local request, response = event.request, event.response; local orig_path = request.path; - local full_path = base_path .. (path and "/"..path or ""); + local full_path = base_path .. (path and "/"..path or ""):gsub("/", path_sep); local attr = stat(full_path:match("^.*[^\\/]")); -- Strip trailing path separator because Windows if not attr then return 404; -- cgit v1.2.3 From b456d66edb94ee5d10524e94606a5980dcb3c9c1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 21:39:26 +0200 Subject: mod_posix: Normalize indentation --- plugins/mod_posix.lua | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index c9b9f3aa..e9e43fa0 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -31,27 +31,27 @@ pposix.umask(umask); -- Allow switching away from root, some people like strange ports. module:hook("server-started", function () - local uid = module:get_option("setuid"); - local gid = module:get_option("setgid"); - if gid then - local success, msg = pposix.setgid(gid); - if success then - module:log("debug", "Changed group to %s successfully.", gid); - else - module:log("error", "Failed to change group to %s. Error: %s", gid, msg); - prosody.shutdown("Failed to change group to %s", gid); - end + local uid = module:get_option("setuid"); + local gid = module:get_option("setgid"); + if gid then + local success, msg = pposix.setgid(gid); + if success then + module:log("debug", "Changed group to %s successfully.", gid); + else + module:log("error", "Failed to change group to %s. Error: %s", gid, msg); + prosody.shutdown("Failed to change group to %s", gid); end - if uid then - local success, msg = pposix.setuid(uid); - if success then - module:log("debug", "Changed user to %s successfully.", uid); - else - module:log("error", "Failed to change user to %s. Error: %s", uid, msg); - prosody.shutdown("Failed to change user to %s", uid); - end + end + if uid then + local success, msg = pposix.setuid(uid); + if success then + module:log("debug", "Changed user to %s successfully.", uid); + else + module:log("error", "Failed to change user to %s. Error: %s", uid, msg); + prosody.shutdown("Failed to change user to %s", uid); end - end); + end +end); -- Don't even think about it! if not prosody.start_time then -- server-starting -- cgit v1.2.3 From 36b5ae5e248a7f38aff69987adc07c093c75f17b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 21:41:11 +0200 Subject: mod_posix: Detect failure to load util.signal by first pcall return value not by type of the second --- plugins/mod_posix.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/mod_posix.lua b/plugins/mod_posix.lua index e9e43fa0..7e6d8799 100644 --- a/plugins/mod_posix.lua +++ b/plugins/mod_posix.lua @@ -14,8 +14,8 @@ if pposix._VERSION ~= want_pposix_version then module:log("warn", "Unknown version (%s) of binary pposix module, expected %s. Perhaps you need to recompile?", tostring(pposix._VERSION), want_pposix_version); end -local signal = select(2, pcall(require, "util.signal")); -if type(signal) == "string" then +local have_signal, signal = pcall(require, "util.signal"); +if not have_signal then module:log("warn", "Couldn't load signal library, won't respond to SIGTERM"); end @@ -162,7 +162,7 @@ end module:hook("server-stopped", remove_pidfile); -- Set signal handlers -if signal.signal then +if have_signal then signal.signal("SIGTERM", function () module:log("warn", "Received SIGTERM"); prosody.unlock_globals(); -- cgit v1.2.3 From ddc546654041db461661773e9346fcbeb199719a Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 23:29:50 +0200 Subject: util-src/Makefile: Move list of .so files in a variable --- util-src/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/util-src/Makefile b/util-src/Makefile index 3674975c..1f092b1e 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -11,18 +11,18 @@ CXX?=g++ LD?=gcc CFLAGS+=-ggdb +ALL=encodings.so hashes.so net.so pposix.so signal.so table.so + .PHONY: all install clean .SUFFIXES: .c .o .so -all: encodings.so hashes.so net.so pposix.so signal.so table.so +all: $(ALL) -install: encodings.so hashes.so net.so pposix.so signal.so table.so - install *.so ../util/ +install: $(ALL) + install $^ ../util/ clean: - rm -f *.o - rm -f *.so - rm -f ../util/*.so + rm -f $(ALL) encodings.so: encodings.o MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; -- cgit v1.2.3 From 321cfea3f348b4dd902d8a444c800a288578fffc Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 23:38:09 +0200 Subject: util-src/Makefile: Use variables for install binary and target directory --- util-src/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util-src/Makefile b/util-src/Makefile index 1f092b1e..d99c9515 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -11,6 +11,9 @@ CXX?=g++ LD?=gcc CFLAGS+=-ggdb +INSTALL_DATA=install -m644 +TARGET?=../util/ + ALL=encodings.so hashes.so net.so pposix.so signal.so table.so .PHONY: all install clean @@ -19,7 +22,7 @@ ALL=encodings.so hashes.so net.so pposix.so signal.so table.so all: $(ALL) install: $(ALL) - install $^ ../util/ + $(INSTALL_DATA) $^ $(TARGET) clean: rm -f $(ALL) -- cgit v1.2.3 From 1ea718fb813a295219492f3a23d5f733bc71e5be Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 26 Sep 2015 23:42:46 +0200 Subject: configure, util-src/Makefile: Move OS X deployment flag to an C compiler argument set by configure --- configure | 1 + util-src/Makefile | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/configure b/configure index 53ee3757..6a2b57f5 100755 --- a/configure +++ b/configure @@ -112,6 +112,7 @@ do LUA_INCDIR_SET=yes LUA_LIBDIR=/usr/local/lib LUA_LIBDIR_SET=yes + CFLAGS="$CFLAGS -mmacosx-version-min=10.3" LDFLAGS="-bundle -undefined dynamic_lookup" fi if [ "$OSTYPE" = "linux" ]; then diff --git a/util-src/Makefile b/util-src/Makefile index d99c9515..8cf3b876 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -28,17 +28,14 @@ clean: rm -f $(ALL) encodings.so: encodings.o - MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) -o $@ $< $(LDFLAGS) $(IDNA_LIBS) hashes.so: hashes.o - MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(CC) -o $@ $< $(LDFLAGS) -l$(OPENSSL_LIB) .c.o: $(CC) $(CFLAGS) -I$(LUA_INCDIR) -c -o $@ $< .o.so: - MACOSX_DEPLOYMENT_TARGET="10.3"; export MACOSX_DEPLOYMENT_TARGET; $(LD) -o $@ $< $(LDFLAGS) -- cgit v1.2.3 From 0941a2d8f4d0cd675c5b35f6da188bcf16eefb72 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:04:14 +0200 Subject: util-src/Makefile: Move Lua include path into CFLAGS variable --- util-src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util-src/Makefile b/util-src/Makefile index 8cf3b876..91c60d7f 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -9,7 +9,7 @@ OPENSSL_LIB?=crypto CC?=gcc CXX?=g++ LD?=gcc -CFLAGS+=-ggdb +CFLAGS+=-ggdb -I$(LUA_INCDIR) INSTALL_DATA=install -m644 TARGET?=../util/ @@ -34,7 +34,7 @@ hashes.so: hashes.o $(CC) -o $@ $< $(LDFLAGS) -l$(OPENSSL_LIB) .c.o: - $(CC) $(CFLAGS) -I$(LUA_INCDIR) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< .o.so: $(LD) -o $@ $< $(LDFLAGS) -- cgit v1.2.3 From ffa983b26574bdf668422a1f152f52004e1ede9c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:08:46 +0200 Subject: util-src/Makefile: Tell Make how to build .so from .o in a modern way (Let built-in rules handle .o) --- util-src/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/util-src/Makefile b/util-src/Makefile index 91c60d7f..c71e06b4 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -33,9 +33,5 @@ encodings.so: encodings.o hashes.so: hashes.o $(CC) -o $@ $< $(LDFLAGS) -l$(OPENSSL_LIB) -.c.o: - $(CC) $(CFLAGS) -c -o $@ $< - -.o.so: - $(LD) -o $@ $< $(LDFLAGS) - +%.so: %.o + $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) -- cgit v1.2.3 From 265af7c012f777491530e62ccdf089e6f780c7db Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:10:18 +0200 Subject: util-src/Makefile: Don't make exceptions for how to build .so for util.hashes and util.encodings --- util-src/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/util-src/Makefile b/util-src/Makefile index c71e06b4..f35c20bc 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -27,11 +27,9 @@ install: $(ALL) clean: rm -f $(ALL) -encodings.so: encodings.o - $(CC) -o $@ $< $(LDFLAGS) $(IDNA_LIBS) +encodings.so: LDLIBS+=$(IDNA_LIBS) -hashes.so: hashes.o - $(CC) -o $@ $< $(LDFLAGS) -l$(OPENSSL_LIB) +hashes.so: LDLIBS+=-l$(OPENSSL_LIB) %.so: %.o $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) -- cgit v1.2.3 From 945a98ba5bc025c4140035c94327e4c0dc64576e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:12:07 +0200 Subject: util-src/Makefile: Remove redundant variables (set in config.unix already) --- util-src/Makefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/util-src/Makefile b/util-src/Makefile index f35c20bc..5af97f35 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -1,14 +1,6 @@ include ../config.unix -LUA_SUFFIX?=5.1 -LUA_INCDIR?=/usr/include/lua$(LUA_SUFFIX) -LUA_LIB?=lua$(LUA_SUFFIX) -IDN_LIB?=idn -OPENSSL_LIB?=crypto -CC?=gcc -CXX?=g++ -LD?=gcc CFLAGS+=-ggdb -I$(LUA_INCDIR) INSTALL_DATA=install -m644 -- cgit v1.2.3 From 4d24241616d652a6c94ca698454ed764a72a0d46 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:14:18 +0200 Subject: Makefile: Simplify generation of prosody.version using magic Make magic --- Makefile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e7a36ffe..403bf842 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,13 @@ util/%.so: prosody.cfg.lua.install: prosody.cfg.lua.dist sed 's|certs/|$(INSTALLEDCONFIG)/certs/|' $^ > $@ -prosody.version: $(wildcard prosody.release .hg/dirstate) - test -f .hg/dirstate && \ - hexdump -n6 -e'6/1 "%02x"' .hg/dirstate > $@ || true - test -f prosody.release && \ - cp prosody.release $@ || true +%.version: %.release + cp $^ $@ + +%.version: .hg/dirstate + hexdump -n6 -e'6/1 "%02x"' $^ > $@ + +%.version: + echo unknown > $@ + + -- cgit v1.2.3 From 8891876d7de90501961c187f9b2f210f9cafa74e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:15:57 +0200 Subject: Makefile: Support generating prosody.version from hg archive metadata file --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 403bf842..c508dc5f 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,9 @@ prosody.cfg.lua.install: prosody.cfg.lua.dist %.version: %.release cp $^ $@ +%.version: .hg_archival.txt + sed -n 's/^node: \(............\).*/\1/p' $^ > $@ + %.version: .hg/dirstate hexdump -n6 -e'6/1 "%02x"' $^ > $@ -- cgit v1.2.3 From 787f6a522a3f655de889a0daa062e2a489eb49ea Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:16:34 +0200 Subject: Makefile: Use hypen to tell Make when to ignore errors --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c508dc5f..e2eca7f1 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ INSTALLEDDATA = $(DATADIR) all: prosody.install prosodyctl.install prosody.cfg.lua.install prosody.version $(MAKE) -C util-src install ifeq ($(EXCERTS),yes) - $(MAKE) -C certs localhost.crt example.com.crt || true + -$(MAKE) -C certs localhost.crt example.com.crt endif install: prosody.install prosodyctl.install prosody.cfg.lua.install util/encodings.so util/encodings.so util/pposix.so util/signal.so @@ -42,7 +42,7 @@ install: prosody.install prosodyctl.install prosody.cfg.lua.install util/encodin install -m644 certs/* $(CONFIG)/certs install -m644 man/prosodyctl.man $(MAN)/man1/prosodyctl.1 test -f $(CONFIG)/prosody.cfg.lua || install -m644 prosody.cfg.lua.install $(CONFIG)/prosody.cfg.lua - test -f prosody.version && install -m644 prosody.version $(SOURCE)/prosody.version || true + -test -f prosody.version && install -m644 prosody.version $(SOURCE)/prosody.version $(MAKE) install -C util-src clean: -- cgit v1.2.3 From 9a4c2f7e52b68d56c4c883234cc704ef1b045b33 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 27 Sep 2015 00:28:46 +0200 Subject: configure,util-src/Makefile: Make a variable that includes -l for OpenSSL (like with IDNA_LIBS) --- configure | 4 +++- util-src/Makefile | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6a2b57f5..b64c2654 100755 --- a/configure +++ b/configure @@ -310,6 +310,8 @@ then IDNA_LIBS="-l$IDN_LIB" fi +OPENSSL_LIBS="-l$OPENSSL_LIB" + echo -n "Checking Lua includes... " lua_h="$LUA_INCDIR/lua.h" if [ -f "$lua_h" ] @@ -362,7 +364,7 @@ LUA_BINDIR=$LUA_BINDIR REQUIRE_CONFIG=$REQUIRE_CONFIG IDN_LIB=$IDN_LIB IDNA_LIBS=$IDNA_LIBS -OPENSSL_LIB=$OPENSSL_LIB +OPENSSL_LIBS=$OPENSSL_LIBS CFLAGS=$CFLAGS LDFLAGS=$LDFLAGS CC=$CC diff --git a/util-src/Makefile b/util-src/Makefile index 5af97f35..5f35b81b 100644 --- a/util-src/Makefile +++ b/util-src/Makefile @@ -21,7 +21,7 @@ clean: encodings.so: LDLIBS+=$(IDNA_LIBS) -hashes.so: LDLIBS+=-l$(OPENSSL_LIB) +hashes.so: LDLIBS+=$(OPENSSL_LIBS) %.so: %.o $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) -- cgit v1.2.3