forked from GrapheneOS/hardened_malloc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement hardened-malloc-kicksecure-enable package
- Loading branch information
Patrick Schleizer
committed
Oct 8, 2020
1 parent
310e270
commit 82ea528
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
|
||
## Copyright (C) 2020 - 2020 ENCRYPTED SUPPORT LP <adrelanos@riseup.net> | ||
## See the file COPYING for copying conditions. | ||
|
||
if [ -f /usr/lib/helper-scripts/pre.bsh ]; then | ||
source /usr/lib/helper-scripts/pre.bsh | ||
fi | ||
|
||
set -e | ||
|
||
true " | ||
##################################################################### | ||
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@ | ||
##################################################################### | ||
" | ||
|
||
## feature request: /etc/ld.so.preload.d drop-in configuration folder support | ||
## https://sourceware.org/bugzilla/show_bug.cgi?id=24913 | ||
|
||
create_hardened_malloc_kicksecure_enabled_status_file() { | ||
mkdir --parents /var/lib/hardened-malloc-kicksecure-enable | ||
touch /var/lib/hardened-malloc-kicksecure-enable/enabled | ||
} | ||
|
||
if test -r /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so ; then | ||
if grep -q /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so /etc/ld.so.preload ; then | ||
echo "INFO: $0: /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so already enabled in /etc/ld.so.preload, OK." | ||
create_hardened_malloc_kicksecure_enabled_status_file | ||
else | ||
if test -f /var/lib/hardened-malloc-kicksecure-enable/enabled ; then | ||
echo "INFO: $0: /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so was already previously enabled by this package, but currently is disabled. Leaving it as is, OK." | ||
elif echo "/usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so" | tee "/etc/ld.so.preload" >/dev/null ; then | ||
echo "INFO: $0: enabled /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so in /etc/ld.so.preload, OK." | ||
create_hardened_malloc_kicksecure_enabled_status_file | ||
else | ||
echo "ERROR: $0: could not write /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so to /etc/ld.so.preload." >&2 | ||
fi | ||
fi | ||
else | ||
echo "ERROR: $0: file /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so does not exist." >&2 | ||
fi | ||
|
||
true "INFO: debhelper beginning here." | ||
|
||
#DEBHELPER# | ||
|
||
true "INFO: Done with debhelper." | ||
|
||
true " | ||
##################################################################### | ||
## INFO: END : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@ | ||
##################################################################### | ||
" | ||
|
||
## Explicitly "exit 0", so eventually trapped errors can be ignored. | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
## Copyright (C) 2020 - 2020 ENCRYPTED SUPPORT LP <adrelanos@riseup.net> | ||
## See the file COPYING for copying conditions. | ||
|
||
if [ -f /usr/lib/helper-scripts/pre.bsh ]; then | ||
source /usr/lib/helper-scripts/pre.bsh | ||
fi | ||
|
||
set -e | ||
|
||
true " | ||
##################################################################### | ||
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@ | ||
##################################################################### | ||
" | ||
|
||
## feature request: /etc/ld.so.preload.d drop-in configuration folder support | ||
## https://sourceware.org/bugzilla/show_bug.cgi?id=24913 | ||
|
||
if [ "$1" = "purge" ] || [ "$1" = "remove" ]; then | ||
if test -r /etc/ld.so.preload ; then | ||
if grep -q /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so /etc/ld.so.preload ; then | ||
if str_replace /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so "" /etc/ld.so.preload >/dev/null ; then | ||
echo "INFO: $0: Removed /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so from /etc/ld.so.preload, OK." | ||
else | ||
echo "ERROR: $0: Removal of /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so from /etc/ld.so.preload failed." >&2 | ||
fi | ||
else | ||
echo "INFO: $0: /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so was already removed from /etc/ld.so.preload, OK." | ||
fi | ||
else | ||
echo "INFO: $0: /etc/ld.so.preload does not exist, therefore no need to remove /usr/lib/libhardened_malloc.so/libhardened_malloc_kicksecure.so, OK." | ||
fi | ||
|
||
rm -f /var/lib/hardened-malloc-kicksecure-enable/enabled | ||
fi | ||
|
||
true "INFO: debhelper beginning here." | ||
|
||
#DEBHELPER# | ||
|
||
true "INFO: Done with debhelper." | ||
|
||
true " | ||
##################################################################### | ||
## INFO: END : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@ | ||
##################################################################### | ||
" | ||
|
||
## Explicitly "exit 0", so eventually trapped errors can be ignored. | ||
exit 0 |