Issue with Arc on Ubuntu

arc
file

#1

Hey I am having an issue with file saving.
On windows it works nicely, but then I am trying to run the project on Ubuntu it seems like the folders are not getting created for the uploaded stuff and the file itself is not getting saved.
How can this be fixed?


#2

ok managed to get an error:
# tried 10 times to create an uploaded file at /tmp/plug-1536 but failed. Set PLUG_TMPDIR to a directory with write permission


#3

if i manually add sudo chmod -R 777 on the folders that are required then it is working as intended


#4

Under which app does your phoenix application run and under which your reverse-proxy (if you use one)? Who owns the created temp-file/folder? With what permissions is it created originally?


#5

Hey I use nginx fro reverse proxy, and the app is started from the mix release command output.
well i assume root owns it, so my user cannot write and copy from it.
to make it worse the issue is back


#6

I logged out the conn too, and the part of it that has the data to update looks like this:

params: %{
    "_csrf_token" => "SHZoEW4jB1IaRC9uBAsUNTUKTh8QAAAA04+kETRcM3b4ujpZza70Ag==",
    "_method" => "put",
    "_utf8" => "✓",
    "id" => "2",
    "user" => %{
      "avatar" => %Plug.Upload{
        content_type: "image/jpeg",
        filename: "ConceptArt_SneakySneaky_011 (2).jpg",
        path: "/tmp/plug-1536/multipart-1536590148-521595600991125-4"
      },
      "name" => "bencepic",
      "password" => "",
      "role_id" => "1",
      "team_id" => ""
    }
  }

the questionable part here is the avatar since here is shows already that plug.upload, how could i log out the original request with the picture?


#7

other weird thing is that with the get request that gets executed before this is working nicely, doesnt complain about not being logged in - 401


#8

Hey the “solution” i said before seems to be only temporary, do you maybe know a better solution?


#9

Depends on the answers to my questions, which you haven’t given yet.

I’d prefer answers checked in the config or in the filesystem over assumptions.


#10

in the config of the elixir project?


#11
  • User and group the phoenix project does run under, shoulb be in your service file to start the service
  • User and group the reverse proxy runs under, should be in your service file to start the service
  • Owner of the temp folder, just check when its created, also write down permission bits
  • Do you run in a SE linux context? (getenforce and sestatus)

#12

hm sorry I do not understand much of this sadly, I am running it is on ubuntu 18 vps on google compute engine
on the vps i have nginx to reverse proxy the elixir app


#13

i start everything under my user, not root,
how can i see when is it created?


#14

Ok, so lets check first if your user is able to create temporary files at all, please try the following and paste the output (run these as your user please):

$ export TEMP_DIR_TEST=$(mktemp -d)
$ echo "test" > ${TEMP_DIR_TEST}/file.txt
$ cat ${TEMP_DIR_TEST}/file.txt
$ export TEMP_FILE_TEST=$(mktemp)
$ echo "testfile" > ${TEMP_FILE_TEST}
$ cat ${TEMP_FILE_TEST}
$ unset TEMP_DIR_TEST
$ unset TEMP_FILE_TEST

#15

i ran them 1by1 and this is how it went:

bence1204@instance-2:~$ export TEMP_DIR_TEST=$(mktemp -d)
bence1204@instance-2:~$ echo "test" > ${TEMP_DIR_TEST}/file.txt
bence1204@instance-2:~$ cat ${TEMP_DIR_TEST}/file.txt
test
bence1204@instance-2:~$ export TEMP_FILE_TEST=$(mktemp)
bence1204@instance-2:~$ echo "testfile" > ${TEMP_FILE_TEST}
bence1204@instance-2:~$ cat ${TEMP_FILE_TEST}
testfile
bence1204@instance-2:~$ unset TEMP_DIR_TEST
bence1204@instance-2:~$ unset TEMP_FILE_TEST
bence1204@instance-2:~$ export TEMP_DIR_TEST=$(mktemp -d)

sorry for the slow response, I am having some connection issues :sweat:
also just or the record i am usinf arc and arc_ecto if that matters


#16

So it seems as if you are able to create files and folders in the temporary area.

I’m not sure though why it doesn’t work for plug…

Can you please check the permissions of /tmp and give the output of the SE-linux commands I mentioned above?

Also, please check df -h /tmp to see what kind of filesystem we have for tmp.


#17

how do i check the permissions for /tmp?
that was the output of the commands that i ran, or what other command do you mean?

the

gives this :

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.6G 2.7G 7.0G 28% /


#18

Those commands:

And to check permissions of the folder do ls -ld /tmp.


#19

ok i missed those

getenforce and sestatus
Command ‘getenforce’ not found, but can be installed with:
apt install selinux-utils
Please ask your administrator.

Command ‘sestatus’ not found, but can be installed with:
apt install policycoreutils
Please ask your administrator.
so I am not running in se linux context, should i install those?

and

shows this:
drwxrwxrwt 15 root root 4096 Sep 14 15:48 /tmp


#20

No need. But I’m out of ideas now…