mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-01-12 07:59:36 -05:00
Optimize hardenDefconfig
This commit is contained in:
parent
7e093e0500
commit
ba07cfb300
@ -637,6 +637,7 @@ export -f changeDefaultDNS;
|
||||
editKernelLocalversion() {
|
||||
local defconfigPath=$(getDefconfig)
|
||||
sed -i 's/CONFIG_LOCALVERSION=".*"/CONFIG_LOCALVERSION="'"$1"'"/' $defconfigPath &>/dev/null || true;
|
||||
sed -zi '/CONFIG_LOCALVERSION="'"$1"'"/!s/$/\nCONFIG_LOCALVERSION="'"$1"'"/' $defconfigPath &>/dev/null;
|
||||
}
|
||||
export -f editKernelLocalversion;
|
||||
|
||||
@ -769,12 +770,11 @@ hardenDefconfig() {
|
||||
|
||||
for option in "${optionsYes[@]}"
|
||||
do
|
||||
sed -i 's/# '"CONFIG_$option"' is not set/'"CONFIG_$option"'=y/' $defconfigPath &>/dev/null || true;
|
||||
#Some defconfigs are very minimal/not-autogenerated, so lets add the rest. Obviously most won't have any affect as they aren't supported.
|
||||
#If the option is disabled, enable it
|
||||
sed -i 's/# CONFIG_'"$option"' is not set/CONFIG_'"$option"'=y/' $defconfigPath &>/dev/null || true;
|
||||
if [[ "$1" != *"kernel/oneplus/msm8996"* ]]; then
|
||||
if ! grep -q "CONFIG_$option=y" $defconfigPath &>/dev/null; then
|
||||
echo "CONFIG_$option=y" | tee -a $defconfigPath &>/dev/null || true;
|
||||
fi;
|
||||
#If the option isn't present, add it enabled
|
||||
sed -zi '/CONFIG_'"$option"'=y/!s/$/\nCONFIG_'"$option"'=y/' $defconfigPath &>/dev/null || true;
|
||||
fi;
|
||||
done
|
||||
#Disable supported options
|
||||
@ -787,19 +787,19 @@ hardenDefconfig() {
|
||||
|
||||
for option in "${optionsNo[@]}"
|
||||
do
|
||||
sed -i 's/'"CONFIG_$option"'=y/# '"CONFIG_$option"' is not set/' $defconfigPath &>/dev/null || true;
|
||||
#sed -i 's/'"CONFIG_$option"'=y/'"CONFIG_$option"'=n/' $defconfigPath &>/dev/null || true;
|
||||
#Some defconfigs are very minimal/not-autogenerated, so lets add the rest. Obviously most won't have any affect as they aren't supported.
|
||||
if ! grep -q "CONFIG_$option=n" $defconfigPath &>/dev/null; then
|
||||
echo "CONFIG_$option=n" | tee -a $defconfigPath &>/dev/null || true;
|
||||
fi;
|
||||
#If the option is enabled, disable it
|
||||
sed -i 's/CONFIG_'"$option"'=y/CONFIG_'"$option"'=n/' $defconfigPath &>/dev/null || true;
|
||||
#If the option isn't present, add it disabled
|
||||
sed -zi '/CONFIG_'"$option"'=n/!s/$/\nCONFIG_'"$option"'=n/' $defconfigPath &>/dev/null || true;
|
||||
done
|
||||
|
||||
#Extras
|
||||
sed -i 's/CONFIG_ARCH_MMAP_RND_BITS=8/CONFIG_ARCH_MMAP_RND_BITS=16/' $defconfigPath &>/dev/null || true;
|
||||
sed -i 's/CONFIG_ARCH_MMAP_RND_BITS=18/CONFIG_ARCH_MMAP_RND_BITS=24/' $defconfigPath &>/dev/null || true;
|
||||
sed -i 's/CONFIG_DEFAULT_MMAP_MIN_ADDR=4096/CONFIG_DEFAULT_MMAP_MIN_ADDR=32768/' $defconfigPath &>/dev/null || true;
|
||||
sed -zi '/CONFIG_DEFAULT_MMAP_MIN_ADDR/!s/$/\nCONFIG_DEFAULT_MMAP_MIN_ADDR=32768/' $defconfigPath &>/dev/null || true;
|
||||
sed -i 's/CONFIG_LSM_MMAP_MIN_ADDR=4096/CONFIG_LSM_MMAP_MIN_ADDR=32768/' $defconfigPath &>/dev/null || true;
|
||||
sed -zi '/CONFIG_LSM_MMAP_MIN_ADDR/!s/$/\nCONFIG_LSM_MMAP_MIN_ADDR=32768/' $defconfigPath &>/dev/null || true;
|
||||
|
||||
editKernelLocalversion "-dos";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user