Files
dnscrypt-osxclient/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh
T
Frank Denis 0e9ebd325e Only chown/chmod the control dir if the permissions on the parent doesn't
match the current console owner.
If things go bad, it will make them even worse, but it avoids triggering
handle-control-change when not necessary.
2012-08-18 10:18:31 -07:00

24 lines
559 B
Bash
Executable File

#! /bin/sh
. ./common.inc
eval $(stat -s '/dev/console') || exit 1
wanted_uid="$st_uid"
if [ ! -d "$DNSCRYPT_VAR_BASE_DIR" ]; then
mkdir -p "$DNSCRYPT_VAR_BASE_DIR" || exit 1
chown -R 0:0 "$DNSCRYPT_VAR_BASE_DIR"
fi
mkdir -m 755 -p "$TICKETS_DIR" || exit 1
chown -R "${wanted_uid}:0" "$TICKETS_DIR"
eval $(stat -s "$CONTROL_DIR") || exit 1
if [ $? != 0 ]; then
mkdir -m 755 -p "$CONTROL_DIR" || exit 1
current_uid='nonexistent'
else
current_uid="$st_uid"
fi
[ x"$current_uid" != x"$wanted_uid" ] && \
chown -R "${wanted_uid}:0" "$CONTROL_DIR"