File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -1006,7 +1006,26 @@ send_stop() {
10061006write_config () {
10071007 local i=1
10081008
1009- if ! eval ' echo -n > "$STORE_CONFIG"' > /dev/null 2>&1 ; then
1009+ # If using pkexec, evaluate permissions before writing.
1010+ # However, the /etc/create_ap.conf
1011+ # location is excepted.
1012+ if [[ " $STORE_CONFIG " != " /etc/create_ap.conf" && $PKEXEC_UID ]]; then
1013+ if [ -e " $STORE_CONFIG " ]; then
1014+ if ! pkexec --user " $( id -nu $PKEXEC_UID ) " test -w " $STORE_CONFIG " ; then
1015+ echo " ERROR: 1 $( id -nu $PKEXEC_UID ) has insufficient permissions to write to config file $STORE_CONFIG "
1016+ exit 1
1017+ fi
1018+ elif ! pkexec --user " $( id -nu $PKEXEC_UID ) " test -w " $( dirname " $STORE_CONFIG " ) " ; then
1019+ echo " ERROR: 2 $( id -nu $PKEXEC_UID ) has insufficient permissions to write to config file $STORE_CONFIG "
1020+ exit 1
1021+ fi
1022+ # Assume that the user is making a conf file in a directory they normally
1023+ # have control over, and keep permissions strictly private. (i.e. they will
1024+ # need to run create_ap directly with sudo in order to write to, say, /etc/create_ap2.conf)
1025+ touch " $STORE_CONFIG "
1026+ chown " $( id -nu $PKEXEC_UID ) :$( id -ng $PKEXEC_GID ) " " $STORE_CONFIG "
1027+ chmod 600 " $STORE_CONFIG "
1028+ elif ! eval ' echo -n > "$STORE_CONFIG"' > /dev/null 2>&1 ; then
10101029 echo " ERROR: Unable to create config file $STORE_CONFIG " >&2
10111030 exit 1
10121031 fi
You can’t perform that action at this time.
0 commit comments