From 18d52b3b5a11b9625a4780bff85ed9dc49af93fc Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 14 Jun 2013 13:40:06 +0200 Subject: [PATCH] Install libcoloredstderr.so read-only. Prevents accidental truncates of libcoloredstderr.so with `cp` which crash all programs which have loaded it. --- README | 5 +++++ src/Makefile.am | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/README b/README index 34cff30..298ce4f 100644 --- a/README +++ b/README @@ -51,6 +51,11 @@ inconsistent state causing a segmentation fault when using any functions of the library. Just remove the file first and then copy it. `make install` handles the install in this way and is therefore not affected. +As a simple safeguard, `make` builds and installs the `libcoloredstderr.so` +file non-writable to prevent accidental overwrites. Even if the overwrite is +forced with `cp -f`, the file is unlinked and recreated by `cp` because the +file is non-writable, preventing the problem. + USAGE ----- diff --git a/src/Makefile.am b/src/Makefile.am index 1526e1d..46f9289 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,3 +6,12 @@ libcoloredstderr_la_SOURCES = coloredstderr.c \ hookmacros.h \ ldpreload.h \ trackfds.h + +# Make sure the library is not writable. See README why this is important. Is +# not run with `make libcoloredstderr.la`, but this isn't common usage. +all-local: $(lib_LTLIBRARIES) + find .libs -type f -exec chmod ugo-w '{}' \; +# `install` uses normal permissions, "fix" them so `make install` also +# installs non-writable files. +install-exec-hook: + find $(DESTDIR)$(libdir) -type f -exec chmod ugo-w '{}' \; -- 2.45.2