|
63 | 63 | $recursive = get('writable_recursive') ? '-R' : ''; |
64 | 64 | $sudo = get('writable_use_sudo') ? 'sudo' : ''; |
65 | 65 |
|
| 66 | + $remoteUser = get('remote_user', false); |
| 67 | + if (empty($remoteUser)) { |
| 68 | + $remoteUser = run('whoami'); |
| 69 | + } |
| 70 | + |
66 | 71 | if (empty($dirs)) { |
67 | 72 | return; |
68 | 73 | } |
|
88 | 93 | run("$sudo chgrp -H $recursive {{http_group}} $dirs"); |
89 | 94 | run("$sudo chmod g+rwx $dirs"); |
90 | 95 | } catch (RunException $exception) { |
91 | | - warning("Make sure `{{remote_user}}` is in `{{http_group}}` group: `usermod -a -G {{http_group}} {{remote_user}}`"); |
| 96 | + warning("Make sure `$remoteUser` is in `{{http_group}}` group: `usermod -a -G {{http_group}} $remoteUser`"); |
92 | 97 | throw $exception; |
93 | 98 | } |
94 | 99 | } elseif ($mode === 'chmod') { |
|
99 | 104 | // Try OS-X specific setting of access-rights |
100 | 105 |
|
101 | 106 | run("$sudo chmod +a \"$httpUser allow delete,write,append,file_inherit,directory_inherit\" $dirs"); |
102 | | - run("$sudo chmod +a \"{{remote_user}} allow delete,write,append,file_inherit,directory_inherit\" $dirs"); |
| 107 | + run("$sudo chmod +a \"$remoteUser allow delete,write,append,file_inherit,directory_inherit\" $dirs"); |
103 | 108 | } elseif (commandExist('setfacl')) { |
104 | 109 | if (empty($sudo)) { |
105 | 110 | // When running without sudo, exception may be thrown |
|
112 | 117 | $hasfacl = run("getfacl -p $dir | grep \"^user:$httpUser:.*w\" | wc -l"); |
113 | 118 | // Set ACL for directory if it has not been set before |
114 | 119 | if (!$hasfacl) { |
115 | | - run("setfacl -L $recursive -m u:\"$httpUser\":rwX -m u:{{remote_user}}:rwX $dir"); |
116 | | - run("setfacl -dL $recursive -m u:\"$httpUser\":rwX -m u:{{remote_user}}:rwX $dir"); |
| 120 | + run("setfacl -L $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dir"); |
| 121 | + run("setfacl -dL $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dir"); |
117 | 122 | } |
118 | 123 | } |
119 | 124 | } else { |
120 | | - run("$sudo setfacl -L $recursive -m u:\"$httpUser\":rwX -m u:{{remote_user}}:rwX $dirs"); |
121 | | - run("$sudo setfacl -dL $recursive -m u:\"$httpUser\":rwX -m u:{{remote_user}}:rwX $dirs"); |
| 125 | + run("$sudo setfacl -L $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dirs"); |
| 126 | + run("$sudo setfacl -dL $recursive -m u:\"$httpUser\":rwX -m u:$remoteUser:rwX $dirs"); |
122 | 127 | } |
123 | 128 | } else { |
124 | 129 | $alias = currentHost()->getAlias(); |
|
0 commit comments