Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission denied running post-finish hook #921

Closed
ccarabine opened this issue Mar 20, 2023 · 8 comments
Closed

Permission denied running post-finish hook #921

ccarabine opened this issue Mar 20, 2023 · 8 comments
Labels

Comments

@ccarabine
Copy link

When i upload a file, i get a permission denied when the post-finish hook executes

i have a simple post-finish script just to check things are working
image

when i upload a file i get
image

permission denied.
if i try and run that file from the directory i get permission denied
image

i've ensured it is executable by running chmod -x post-finish etc
To Reproduce
Steps to reproduce the behavior:
have tus running as a container, activate hooks, put a post-finish file in the /srv/hooks folder
make it executable chmod +x post-finish

upload a file in the browser and then log out "hello" at the moment but will want the $TUS_ID and to change the file name

Expected behavior
the script to execute,
next stage is to rename the file from id to original filename with ext

How do you log info to the logs? of course echo isn't the cmd to use
and want to use the $TUS_ID var

@Acconut
Copy link
Member

Acconut commented Mar 20, 2023

i've ensured it is executable by running chmod -x post-finish etc

I hope you mean chmod +x post-finish. Otherwise, you would remove the executable bit. However, looking at your last screenshot, the file seems to have the correct permissions set.

Can you execute post-finish on its own, i.e. without tusd: /srv/tus-hooks/post-finish? If that does not work, then it is not a problem with tusd but the file or your setup.

Also, I noticed in your first output that there is a space after the hashbang (#!). Try removing it because I do not know if this is allows there.

@ccarabine
Copy link
Author

  • "Can you execute post-finish on its own, i.e. without tusd: /srv/tus-hooks/post-finish? If that does not work, then it is not a problem with tusd but the file or your setup." so the answer is no
  • deleteing the space in the hashbag doesn't change anything

Appreciate your help

i have a couple of different setups -

  1. ORGINAL SETUP WITH MASTER TUS CONTAINER tusproject/tusd
    just ran a new instance and tried to create post-finish file and getting
    image

added a blind mount volume to mount the local hooks folder so it puts it in the srv/tusd-hooks folder
and getting the orginal error permission denied when uploading a file
image

and if i try to run the file
image
image

if i put sh before it and run sh ./post-finish it executes

2)Custom tus container- i've create-giving tusd sudo permissions, adding nano

i've tried to run it on its own. in the srv/tus-hooks dir running ./post-finish and getting the follow error
image

if i put sh before it and run sh ./post-finish it executes

when i upload a file in the browser see logs and don't get an error, but nothing in the hook executes??
image

How do i log out a message to the logs??

@Acconut
Copy link
Member

Acconut commented Mar 20, 2023

Ok, I can reproduce the first issue:

~/workspace/tus $ docker run --rm -it --entrypoint=/bin/sh tusproject/tusd
/srv/tusd-data $ ls ..
tusd-data   tusd-hooks
/srv/tusd-data $ cd ../tusd-hooks/
/srv/tusd-hooks $ touch post-finish
touch: post-finish: Permission denied
/srv/tusd-hooks $ 

Let's see what we can do.

@Acconut
Copy link
Member

Acconut commented Mar 20, 2023

Maybe the problem is that /srv/tusd-hooks is owned by root, not the tusd user:

/srv/tusd-hooks $ whoami
tusd
/srv/tusd-hooks $ ls -l ..
total 8
drwxr-xr-x    1 tusd     tusd          4096 Jan 18 12:05 tusd-data
drwxr-xr-x    2 root     root          4096 Jan 18 12:05 tusd-hooks
/srv/tusd-hooks $ touch ../tusd-data/foo
/srv/tusd-hooks $ 

@Acconut
Copy link
Member

Acconut commented Mar 20, 2023

I am no Docker expert, so I don't really know where to go from here. Maybe @thirsch can help, who worked on the Docker image in the past.

@ccarabine
Copy link
Author

should probably stay on the first setup with the tusproject/tusd image and get that working
the post-finish hook i got is owned by tusd

@ccarabine
Copy link
Author

My collegue managed to fix this by mapping the post-finish file (on the vm) to srv/tusd-hooks/post-finish ( in the tusd container) previously we were mapping the tusd-hooks directory . This fixed all the problems
image

@Acconut
Copy link
Member

Acconut commented Mar 21, 2023

It's great to hear that you found a solution!

@Acconut Acconut closed this as completed Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants