Skip to content

Commit

Permalink
patches: add remove-modulebins
Browse files Browse the repository at this point in the history
  • Loading branch information
fda77 committed Mar 1, 2021
1 parent 8a49d96 commit dd5d730
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
12 changes: 12 additions & 0 deletions config/ui/patches.in
Expand Up @@ -23,6 +23,18 @@ config FREETZ_SELECT_HARDENING

comment "Removal patches ------------------------------------------"

config FREETZ_REMOVE_MODULE_BINS
bool "Remove module bins"
depends on !FREETZ_AVM_HAS_KMOD
depends on !(FREETZ_AVM_VERSION_07_2X_MIN && FREETZ_SYSTEM_TYPE_GRX5)
default n if FREETZ_AVM_VERSION_07_2X_MIN
default y
help
Removes these (unused) kernel files:
modules.dep.bin
modules.alias.bin
modules.symbols.bin

config FREETZ_REMOVE_MICROVOIP_DSL
bool "Remove microvoip-dsl.bin"
depends on \
Expand Down
10 changes: 1 addition & 9 deletions fwmod
Expand Up @@ -950,7 +950,7 @@ if [ "$DO_MOD" -gt 0 ]; then
[ -d "$LUA_MOD_DIR" ] && echo1 "LUA directory: ${LUA_MOD_DIR}" || FREETZ_AVM_HAS_ONLY_HTML=y

# Determine $MODULES_DIR in AVM image, eg: "${FILESYSTEM_MOD_DIR}/lib/modules/2.6.19.2
MODULES_DIR="$(find ${FILESYSTEM_MOD_DIR}/lib/modules/2.6.* ${FILESYSTEM_MOD_DIR}/lib/modules/[34].*.* -maxdepth 0 -type d 2>/dev/null)"
MODULES_DIR="$(find ${FILESYSTEM_MOD_DIR}/lib/modules/[2345].[0123456789]*.* -maxdepth 0 -type d 2>/dev/null)"
[ ! -d "$MODULES_DIR" ] && error 1 "Cannot find modules dir."
# Set $MODULES_SUBDIR relative to root dir in AVM image, eg: "lib/modules/2.6.19.2
MODULES_SUBDIR="${MODULES_DIR#${FILESYSTEM_MOD_DIR}/}"
Expand Down Expand Up @@ -1441,14 +1441,6 @@ if [ "$DO_MOD" -gt 0 ]; then
fi
fi

echo0 "processing modules"
for f in modules.dep.bin modules.alias.bin modules.symbols.bin; do
if [ -e "$MODULES_DIR/$f" ]; then
echo1 "removing (unused) $f"
rm -f "$MODULES_DIR/$f"
fi
done

kolinecnt="$(cat $MODULES_DIR/modules.dep | wc -l)"
kofilecnt="$(find $MODULES_DIR -type f -name '*.ko' | wc -l)"
echo1 "kernel modules installed: $kolinecnt entries in modules.dep and $kofilecnt .ko-files found."
Expand Down
9 changes: 9 additions & 0 deletions patches/scripts/760-remove_module_bins.sh
@@ -0,0 +1,9 @@
[ "$FREETZ_REMOVE_MODULE_BINS" == "y" ] || return 0
echo1 "removing module bins"

MODULES_DIR="$(find ${FILESYSTEM_MOD_DIR}/lib/modules/[2345].[0123456789]*.* -maxdepth 0 -type d)"
rm_files \
$MODULES_DIR/modules.dep.bin \
$MODULES_DIR/modules.alias.bin \
$MODULES_DIR/modules.symbols.bin

0 comments on commit dd5d730

Please sign in to comment.