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

Allow any command-line for caddy excutable path to allow Flatpak compatibility #56

Open
rugk opened this issue Jul 9, 2021 · 2 comments · May be fixed by #57
Open

Allow any command-line for caddy excutable path to allow Flatpak compatibility #56

rugk opened this issue Jul 9, 2021 · 2 comments · May be fixed by #57
Labels
🛠 type/feature request Requests or implements a new feature

Comments

@rugk
Copy link

rugk commented Jul 9, 2021

Is your request related to a problem?
I install VSCodium as a Flatpak from Flathub. As such, the application is sandboxed, but it has the flatpak-span --host command that you can use to escape the sandbox.

I'd like to do this, so I add this to caddyfile.executable:

flatpak spawn --host 'podman run --rm --name caddyformat -v $PWD/Caddyfile:/Caddyfile:z caddy caddy'

Yes in my example I use podman again on the host to check execute caddy as a container, actually.
Anyway, that does not matter and if I run the command on the host it also works:

$ podman run --rm --name caddyformat -v $PWD:/test:z caddy caddy fmt /test/Caddyfile

Describe the solution you would like
What is preventing me is this error that checks whether that is a path, it should allow any CLI command, actually.

Describe any alternatives you have considered
N/A

Screenshots
N/A

Additional Context
This is the error that needs to be removed:
https://github.com/matthewpi/vscode-caddyfile-support/blob/c86bb3527a303ec2d65249c6e4af560979aca198/src/formatter.ts#L30

@rugk rugk added the 🛠 type/feature request Requests or implements a new feature label Jul 9, 2021
rugk added a commit to rugk/vscode-caddyfile-support that referenced this issue Jul 9, 2021
Fixes caddyserver#56

**Untested**, and as far as I see the `spawn` thing likely makes it impossible to use, i.e. it does not work as I want, does it?

So just consider this as a first try/starter for you. (I have no experience in VS Code development.)
@rugk rugk linked a pull request Jul 9, 2021 that will close this issue
@matthewpi
Copy link
Member

Yes in my example I use podman again on the host to check execute caddy as a container, actually.
Anyway, that does not matter and if I run the command on the host it also works:

The one problem with your command is it does not use stdin, you might be able to run caddy fmt with a path, but you need it to read from stdin and print the result out. I am not sure if flatpak spawn will forward it's stdin to podman run, which might not forward it's stdin to caddy fmt. Using stdin for caddy fmt is required as VSCode needs to know what changes to make, not just update the file on disk (see #1).

Regardless of the problem above, I don't really see how your PR (#57) will solve this, as the spawn call won't use any arguments you set in the caddyfile.executable option, it will just attempt to use all the arguments as a path to an executable.

If I am reading the flatpak documentation correctly, flatpak-spawn will allow us to run a command sandboxed or unsandboxed on the host, but I don't believe the application has access, otherwise it would be able to escape whenever it wanted. Is it not possible to just add the caddy executable to where VSCodium is installed and setup the path to be within the sandboxed directories?

@rugk
Copy link
Author

rugk commented Jul 9, 2021

I am not sure if flatpak spawn will forward it's stdin to podman run, which might not forward it's stdin to caddy fmt.

Ah, I guess that's not a problem, that should work.

will allow us to run a command sandboxed or unsandboxed on the host, but I don't believe the application has access, otherwise it would be able to escape whenever it wanted.

It has, because of a special permission.
But you don't need to care about these details, it's up to my job to configure that command-line argument correctly… just the app should not insist on absolute paths, which makes this unnecessary complicated. (I could search for other extenjsions now that had the same issue… you'll eventually stumble upon flatpak spawn things, but AFAIK they just call the command-line.

Is it not possible to just add the caddy executable to where VSCodium is installed and setup the path to be within the sandboxed directories?

No, not really in any easy way I know. Though wel… you could do it in $HOME or so, where it has access, but that's also an ugly workaround. Then, yet again, I'd "like" to sandbox escape more, it feels less hackish. (and as said, is how other extensions do it, by just proving an arbitrary input for the user to overwrite that file path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠 type/feature request Requests or implements a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants