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

webhook snap can't execute command #530

Open
bakwc opened this issue Apr 29, 2021 · 13 comments
Open

webhook snap can't execute command #530

bakwc opened this issue Apr 29, 2021 · 13 comments
Labels

Comments

@bakwc
Copy link

bakwc commented Apr 29, 2021

I have a script with following content:

#!/bin/bash

git pull

Script doesn't work, and there is an error in logs:

line 3: git: command not found

Webhook is running under the same user, standalone script launch is 100% working, git command present in bash.

Why opensource usage is such a pain?

@fbartels
Copy link

It appears you are running webhook in an environment where it does not inherit the environment variables from your user/process and therefore $PATH is undefined. So you either need to define it, or give the full path to the binary.

Why opensource usage is such a pain?

There is a saying that goes "What goes around, comes around". Maybe you are just the one that is painful to work with? ;-)

@bakwc
Copy link
Author

bakwc commented Apr 29, 2021

$PATH is defined, I made "echo $PATH > log.txt" and everything exists in path.

@moorereason
Copy link
Collaborator

If you use the full path to the git binary, does it work?

@bakwc
Copy link
Author

bakwc commented Apr 29, 2021

No, it gives:

/usr/bin/git: No such file or directory

I already tried with passing working directory and without passing anything, nothing works.

@moorereason
Copy link
Collaborator

What version of webhook and how did you install it?

Check your file permissions. Does the user running the webhook service have access to execute the git binary? Are you using selinux or anything would prevent the webhook service from execution git?

@bakwc
Copy link
Author

bakwc commented Apr 29, 2021

Version: 2.8.0
Installed and run via snap:

fippo@mainserver:~/koding/myapp/server$ snap run webhook -port 1111 -hooks /home/fippo/webhooks/hooks.json -verbose
[webhook] 2021/04/29 22:30:17 version 2.8.0 starting
[webhook] 2021/04/29 22:30:17 setting up os signal watcher
[webhook] 2021/04/29 22:30:17 attempting to load hooks from /home/fippo/webhooks/hooks.json
[webhook] 2021/04/29 22:30:17 found 1 hook(s) in file
[webhook] 2021/04/29 22:30:17 	loaded: myapp
[webhook] 2021/04/29 22:30:17 serving hooks on http://0.0.0.0:1111/hooks/{id}
[webhook] 2021/04/29 22:30:17 os signal watcher ready
[webhook] 2021/04/29 22:30:50 [7e2a2d] incoming HTTP GET request from 172.28.0.1:61274
[webhook] 2021/04/29 22:30:50 [7e2a2d] myapp got matched
[webhook] 2021/04/29 22:30:50 [7e2a2d] error parsing body payload due to unsupported content type header:
[webhook] 2021/04/29 22:30:50 [7e2a2d] myapp hook triggered successfully
[webhook] 2021/04/29 22:30:50 [7e2a2d] 200 | 8 B | 428.822µs | 123.1.1.1:1111 | GET /hooks/myapp
[webhook] 2021/04/29 22:30:50 [7e2a2d] executing /home/fippo/koding/myapp/server/deploy.sh (/home/fippo/koding/myapp/server/deploy.sh) with arguments ["/home/fippo/koding/myapp/server/deploy.sh"] and environment [] using  as cwd
[webhook] 2021/04/29 22:30:50 [7e2a2d] command output: /bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
/home/fippo/koding/myapp/server/deploy.sh: line 3: /usr/bin/git: No such file or directory
/home/fippo/koding/myapp/server/deploy.sh: line 5: docker: command not found
/home/fippo/koding/myapp/server/deploy.sh: line 6: docker: command not found
/home/fippo/koding/myapp/server/deploy.sh: line 7: docker: command not found
/home/fippo/koding/myapp/server/deploy.sh: line 8: docker: command not found

Does the user running the webhook service have access to execute the git binary

Sure

Are you using selinux or anything would prevent the webhook service from execution git?

Nothing, just regular ubuntu (slightly old, 16.04).

@moorereason
Copy link
Collaborator

I don't use snaps, but I'm assuming that's the problem.

Cc: @adnanh

@moorereason moorereason changed the title BUG: line 3: git: command not found webhook snap can't execute command Apr 29, 2021
@slntopp
Copy link

slntopp commented Jul 15, 2021

there are no configuration hooks and vars in snap, so I'd assume it won't work from snap

@bakwc
Copy link
Author

bakwc commented Jul 15, 2021

May be it is a good idea at least to mention in README.md that snap version have some limitations?

@slntopp
Copy link

slntopp commented Jul 15, 2021

Pretty much indeed🤷‍♂️

@atika
Copy link

atika commented Dec 7, 2021

I don't know how snap works and I wanted to give it a try by installing the latest version of webhook. I did not find any information for the configuration, how to edit the service or where I have to put the configuration file.
I think the app is sandboxed like apps on macOS. Webhook is installed in strict mode. I think you can't execute /usr/bin/git because you are not allowed to do that, but you can run deploy.sh because it's in your home directory.
With snap interfaces we see that webhook have :network :network-bind and home.
Confinement could be great for this app, but as Webhook executes shell scripts that probably use a lot of binaries and directories outside the home folder, maybe it's not suitable for snapd...

@vallemar
Copy link

+1, I have the same behavior in centos

@nsg
Copy link

nsg commented Mar 10, 2022

I have some knowledge about snaps. There are various interfaces and tools to poke holes in the sandbox, but I agree that with a tool like this the sandbox make little sense. My suggestion it make it a "classic snap" with is a snap package without a sandbox. A classic snap needs to be manually approved by Canonical, I think this tool have a good case why it should be approved.

It can still be useful to use the snap store for discoverability and ease of installation for users. If not, I suggest that you merge #566 and unpublish the snap from the store.

Let me know if you need any help.

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

7 participants