From 0e9ebd325e7113c092df059e10b29efde44ebb60 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 18 Aug 2012 10:18:31 -0700 Subject: [PATCH] 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. --- .../extra/usr/scripts/handle-console-change.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh index 92761ea..9a12883 100755 --- a/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh +++ b/DNSCrypt-Preference-Pane/DNSCrypt/extra/usr/scripts/handle-console-change.sh @@ -8,8 +8,16 @@ 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 -p "$CONTROL_DIR" || exit 1 -mkdir -p "$TICKETS_DIR" || exit 1 -chown -R "${wanted_uid}:0" "$CONTROL_DIR" +mkdir -m 755 -p "$TICKETS_DIR" || exit 1 chown -R "${wanted_uid}:0" "$TICKETS_DIR" -find "$DNSCRYPT_VAR_BASE_DIR" -type d -exec chmod 755 {} \; + +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"