| 1 | try |
|---|
| 2 | |
|---|
| 3 | set userID to do shell script "stat -f '%Su' $HOME" |
|---|
| 4 | |
|---|
| 5 | end try |
|---|
| 6 | |
|---|
| 7 | set kdedirID to "" |
|---|
| 8 | set ICEauthorityID to "" |
|---|
| 9 | set XauthorityID to "" |
|---|
| 10 | |
|---|
| 11 | set kdeDir to (POSIX path of (path to home folder) & ".kde/" as string) |
|---|
| 12 | set ICEauthority to (POSIX path of (path to home folder) & ".ICEauthority" as string) |
|---|
| 13 | set Xauthority to (POSIX path of (path to home folder) & ".Xauthority" as string) |
|---|
| 14 | |
|---|
| 15 | set kdeDirMessage to "" |
|---|
| 16 | |
|---|
| 17 | try |
|---|
| 18 | |
|---|
| 19 | POSIX file kdeDir as alias |
|---|
| 20 | set kdedirID to do shell script "stat -f '%Su' $HOME/.kde" |
|---|
| 21 | |
|---|
| 22 | end try |
|---|
| 23 | |
|---|
| 24 | try |
|---|
| 25 | |
|---|
| 26 | POSIX file ICEauthority as alias |
|---|
| 27 | set ICEauthorityID to do shell script "stat -f '%Su' $HOME/.ICEauthority" |
|---|
| 28 | |
|---|
| 29 | end try |
|---|
| 30 | |
|---|
| 31 | try |
|---|
| 32 | |
|---|
| 33 | POSIX file Xauthority as alias |
|---|
| 34 | set XauthorityID to do shell script "stat -f '%Su' $HOME/.Xauthority" |
|---|
| 35 | |
|---|
| 36 | end try |
|---|
| 37 | |
|---|
| 38 | if ((not kdedirID is equal to "") and not kdedirID = userID) or not ICEauthorityID = userID or not XauthorityID = userID then |
|---|
| 39 | |
|---|
| 40 | if (not kdedirID is equal to "") then set kdeDirMessage to (kdeDir & return & " is owned by " & kdedirID & return & return) |
|---|
| 41 | |
|---|
| 42 | set fixPermissions to button returned of  |
|---|
| 43 | (display dialog (kdeDirMessage  |
|---|
| 44 | & ICEauthority & return & " is owned by " & ICEauthorityID & return & return  |
|---|
| 45 | & Xauthority & return & " is owned by " & XauthorityID & return & return  |
|---|
| 46 | & "They should be owned by " & userID & " for KMyMoney to run properly!") buttons {"Cancel", "Fix"} default button {"Fix"} with icon 2) |
|---|
| 47 | |
|---|
| 48 | if fixPermissions = "Fix" then |
|---|
| 49 | |
|---|
| 50 | if (not kdedirID is equal to "") then do shell script "chown -R " & userID & " " & kdeDir with administrator privileges |
|---|
| 51 | do shell script "chown " & userID & " " & ICEauthority with administrator privileges |
|---|
| 52 | do shell script "chown " & userID & " " & Xauthority with administrator privileges |
|---|
| 53 | |
|---|
| 54 | end if |
|---|
| 55 | |
|---|
| 56 | end if |
|---|
| 57 | |
|---|
| 58 | set results to do shell script "cd ~; PATH=$PATH:/opt/local/bin; export PATH; source .profile; /opt/local/bin/kmymoney > /dev/null 2>&1 &" |
|---|