fix: Allow writing to files with group permission without chmod on Linux (#9297)

* feat: check electron config item disable-automatic-chmod

* added auto chmod toggle to advanced settings page for electron

* add default behavior when chmod config key doesn't exist

* added auto chmod description key to en.edn
pull/10175/head
Jack Case 2023-09-14 10:13:12 -04:00 committed by GitHub
parent 0f6266e331
commit 8ac30c1fd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View File

@ -97,6 +97,12 @@
(catch :default _e
false)))
(defn chmod-enabled?
[]
(if (= nil (cfgs/get-item :feature/enable-automatic-chmod?))
true
(cfgs/get-item :feature/enable-automatic-chmod?)))
(defmethod handle :copyFile [_window [_ _repo from-path to-path]]
(logger/info ::copy-file from-path to-path)
(fs-extra/copy from-path to-path))
@ -107,7 +113,7 @@
(.from Buf content)
content)]
(try
(when (and (fs/existsSync path) (not (writable? path)))
(when (and (chmod-enabled?) (fs/existsSync path) (not (writable? path)))
(fs/chmodSync path "644"))
(fs/writeFileSync path content)
(fs/statSync path)

View File

@ -601,6 +601,20 @@
{:left-label (t :settings-page/network-proxy)
:action (user-proxy-settings agent-opts)}))
(rum/defcs auto-chmod-row < rum/reactive
[state t]
(let [enabled? (if (= nil (state/sub [:electron/user-cfgs :feature/enable-automatic-chmod?]))
true
(state/sub [:electron/user-cfgs :feature/enable-automatic-chmod?]))]
(toggle
"automatic-chmod"
(t :settings-page/auto-chmod)
enabled?
#(do
(state/set-state! [:electron/user-cfgs :feature/enable-automatic-chmod?] (not enabled?))
(ipc/ipc :userAppCfgs :feature/enable-automatic-chmod? (not enabled?)))
[:span.text-sm.opacity-50 (t :settings-page/auto-chmod-desc)])))
(defn filename-format-row []
(row-with-button-action
{:left-label (t :settings-page/filename-format)
@ -709,6 +723,7 @@
(usage-diagnostics-row t instrument-disabled?)
(when-not (mobile-util/native-platform?) (developer-mode-row t developer-mode?))
(when (util/electron?) (https-user-agent-row https-agent-opts))
(when (util/electron?) (auto-chmod-row t))
(when (and (util/electron?) (not (config/demo-graph? current-repo))) (filename-format-row))
(clear-cache-row t)

View File

@ -351,6 +351,8 @@
:settings-page/update-error-2 " Please check out the "
:settings-permission/start-granting "Grant"
:settings-page/auto-chmod "Automatically change file permissions"
:settings-page/auto-chmod-desc "Disable to allow editing by multiple users with permissions granted by group membership."
:yes "Yes"
:submit "Submit"