mirror of
https://github.com/aclist/dztui.git
synced 2024-12-29 13:52:03 +01:00
fix: sudo escalation
This commit is contained in:
parent
9fee338ba4
commit
1e1f647eb7
1 changed files with 20 additions and 7 deletions
21
dzgui.sh
21
dzgui.sh
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o pipefail
|
||||
version=3.2.6
|
||||
version=3.2.7
|
||||
|
||||
aid=221100
|
||||
game="dayz"
|
||||
|
@ -1724,12 +1724,24 @@ setup(){
|
|||
check_map_count(){
|
||||
count=1048576
|
||||
echo "[DZGUI] Checking system map count"
|
||||
if [[ $(sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}') -lt $count ]]; then
|
||||
$steamsafe_zenity --question --width 500 --title="DZGUI" --text "System map count must be $count or higher to run DayZ with Wine.\nIncrease map count and make this change permanent? (will prompt for sudo password)" 2>/dev/null
|
||||
if [[ ! -f /etc/sysctl.d/dayz.conf ]]; then
|
||||
if [[ $parent != "bash" ]]; then
|
||||
$steamsafe_zenity --question --width 500 --title="DZGUI" --text "sudo password required to check system vm map count." 2>/dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
pass=$($steamsafe_zenity --password)
|
||||
sudo -S <<< "$pass" sh -c "echo 'vm.max_map_count=1048576' > /etc/sysctl.d/dayz.conf"
|
||||
local ct=$(sudo -S <<< "$pass" sh -c "sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}')")
|
||||
if [[ $ct -lt $count ]]; then
|
||||
sudo sysctl -p /etc/sysctl.d/dayz.conf
|
||||
pass=$($steamsafe_zenity --password)
|
||||
fi
|
||||
else
|
||||
return
|
||||
fi
|
||||
else
|
||||
if [[ $(sudo sysctl -q vm.max_map_count | awk -F"= " '{print $2}') -lt $count ]]; then
|
||||
sudo echo 'vm.max_map_count=1048576' > /etc/sysctl.d/dayz.conf
|
||||
sudo sysctl -p /etc/sysctl.d/dayz.conf
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -1827,4 +1839,5 @@ main(){
|
|||
#TODO: tech debt: cruddy handling for steam forking
|
||||
[[ $? -eq 1 ]] && pkill -f dzgui.sh
|
||||
}
|
||||
parent=$(cat /proc/$PPID/comm)
|
||||
main
|
||||
|
|
Loading…
Reference in a new issue