Skip to content

Commit 695acad

Browse files
committed
allow other users to write to mix_pubsub
1 parent 12b2004 commit 695acad

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/mix/lib/mix/sync/lock.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ defmodule Mix.Sync.Lock do
9797
opts = Keyword.validate!(opts, [:on_taken])
9898

9999
hash = key |> :erlang.md5() |> Base.url_encode64(padding: false)
100-
path = Path.join([System.tmp_dir!(), "mix_lock", hash])
100+
base_path = Path.join([System.tmp_dir!(), "mix_lock"])
101+
init_base_path(base_path)
102+
path = Path.join([base_path, hash])
101103

102104
pdict_key = {__MODULE__, path}
103105
has_lock? = Process.get(pdict_key, false)
@@ -119,6 +121,12 @@ defmodule Mix.Sync.Lock do
119121
end
120122
end
121123

124+
defp init_base_path(path) do
125+
File.mkdir_p!(path)
126+
# ensure other users can write to the directory
127+
_ = File.chmod(path, 0o777)
128+
end
129+
122130
defp lock_disabled?(), do: System.get_env("MIX_OS_CONCURRENCY_LOCK") in ~w(0 false)
123131

124132
defp lock(path, on_taken) do

lib/mix/lib/mix/sync/pubsub.ex

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ defmodule Mix.Sync.PubSub do
127127
@impl true
128128
def init({}) do
129129
state = %{port: nil, hash_to_pids: %{}}
130+
init_base_path()
130131
{:ok, state}
131132
end
132133

@@ -272,9 +273,20 @@ defmodule Mix.Sync.PubSub do
272273

273274
defp hash(key), do: :erlang.md5(key)
274275

276+
defp base_path do
277+
Path.join(System.tmp_dir!(), "mix_pubsub")
278+
end
279+
275280
defp path(hash) do
276281
hash = Base.url_encode64(hash, padding: false)
277-
Path.join([System.tmp_dir!(), "mix_pubsub", hash])
282+
Path.join([base_path(), hash])
283+
end
284+
285+
defp init_base_path do
286+
path = base_path()
287+
File.mkdir_p!(path)
288+
# ensure other users can write to the directory
289+
_ = File.chmod(path, 0o777)
278290
end
279291

280292
defp recv(socket, size, timeout \\ :infinity) do

0 commit comments

Comments
 (0)