[security/cosmetic] Adjust permission for cpuinfo_cur_freq to be accesible by a normal user and adjusting htop configuration based on cpu count

This commit is contained in:
Igor Pecovnik 2018-10-14 18:07:12 +02:00
parent 1c4340b421
commit 277e6e6f65
3 changed files with 30 additions and 4 deletions

View File

@ -106,9 +106,6 @@ install_common()
# force change root password at first login
chroot $SDCARD /bin/bash -c "chage -d 0 root"
# copy predefined settings for root user
cp -R $SRC/packages/bsp/common/etc/skel/ $SDCARD/etc/
# display welcome message at first root login
touch $SDCARD/root/.not_logged_in_yet

View File

@ -15,6 +15,26 @@
case "$1" in
start)
# read number of cores needed below
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
# adjust custom htop initial configuration based on CPU count https://github.com/avafinger/htop-2.1.1_enhanced-version
right_meters="Tasks LoadAverage Uptime"
right_meter_modes="2 2 2"
x=1
until [ $x -gt $cpu_cores ]; do
right_meters=$right_meters" CpuFreq($x)"
right_meter_modes=$right_meter_modes" 2"
let x+=1
done
sed -i 's/header_margin=.*/header_margin=1/g' /etc/skel/.config/htop/htoprc
sed -i 's/left_meters=.*/left_meters=AllCPUs Memory Swap CpuTemp/g' /etc/skel/.config/htop/htoprc
sed -i 's/left_meter_modes=.*/left_meter_modes=1 1 1 2/g' /etc/skel/.config/htop/htoprc
sed -i "s/right_meters=.*/right_meters=$right_meters/g" /etc/skel/.config/htop/htoprc
sed -i "s/right_meter_modes=.*/right_meter_modes=$right_meter_modes/g" /etc/skel/.config/htop/htoprc
# copy predefined settings for root user
cp -R /etc/skel/.config /root/
# Run a q&d benchmark to be able to identify cards way too slow easily
echo -e "\n### quick iozone test:$(cd /root; iozone -e -I -a -s 1M -r 4k -i 0 -i 1 -i 2 | grep '^ 1024' | sed 's/ 1024 //')" >> $Log
@ -50,7 +70,6 @@ case "$1" in
[[ -f /etc/newt/palette ]] && sed -e 's/magenta/blue/g' -i /etc/newt/palette
# desktop tweaks - enable show windows content on stronger boards
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
if [[ ${cpu_cores} -gt 2 && -f /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml ]]; then
sed -i 's/<property name="box_move" type="bool" value=".*/<property name="box_move" type="bool" value="false"\/>/g' \
/etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml

View File

@ -51,6 +51,16 @@ prepare_board() {
sed -i "s/\/log.hdd\//\/log\//" /etc/logrotate.conf
fi
# unlock cpuinfo_cur_freq to be accesible by a normal user
prefix="/sys/devices/system/cpu/cpufreq"
for f in $(ls -1 $prefix 2> /dev/null)
do
[[ -f $prefix/$f/cpuinfo_cur_freq ]] && chmod +r $prefix/$f/cpuinfo_cur_freq 2> /dev/null
done
# older kernels
prefix="/sys/devices/system/cpu/cpu0/cpufreq/"
[[ -f $prefix/cpuinfo_cur_freq ]] && chmod +r $prefix/cpuinfo_cur_freq 2> /dev/null
# enable compression where not exists
find /etc/logrotate.d/. -type f | xargs grep -H -c 'compress' | grep 0$ | cut -d':' -f1 | xargs -L1 sed -i '/{/ a compress'
sed -i "s/#compress/compress/" /etc/logrotate.conf