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

Add support for a flag to disable symlink checking / no-symlink enforcement #9842

Closed
lewish opened this issue Apr 28, 2022 · 9 comments
Closed

Comments

@lewish
Copy link

lewish commented Apr 28, 2022

Current version of hugo checks for symlinks in a number of folders and throws an error: Unsupported symlink found when it does so.

This was done for security reasons, AIUI - #6225 for context.

This makes hugo practically impossible to use with Bazel, which we and it seems some others would like to do so.

I would like to propose a command line flag to disable the symlink checking, that a user may use at their own risk, e.g:

hugo --allowSymlinks

I have this working on my own fork with Bazel, and as a proof of concept this all appears to work fine. Would the team be open to this CLI option?

@bep
Copy link
Member

bep commented Apr 28, 2022

This was done for security reasons

There are currently two areas which currently does not support

  1. The static file system, as the library used to sync those folders does not support symlinks.
  2. Themes/theme components -- for security reasons.

I suspect that we could improve the first one (as in, remove the NewNoSymlinkFs wrapper that throws these errors).

This makes hugo practically impossible to use with Bazel.

It is not clear why this is, but Bazel is an open source project, have you reached out to that project and asked them to make adjustments?

@trygvis
Copy link

trygvis commented May 4, 2022

@lewish I just ran into the same issue. I ended up making a temporary directory, copying everything over while resolving symlinks and ran hugo on the result. Cumbersome but my site is quite small so it's ok.

@bep I doubt that Bazel will change, they use the symlinks to create restricted environments for builds. The environments only include what has been explicitly declared as files/targets that they consume as a technique to make as reproducible builds as possible.

@autumnull
Copy link

I am also running into this problem while trying to set up a site on a server with divisions of the site managed by different users.

I was hoping (given #1857) that a partial workaround would be to use the staticDir to set a few of the top-level static directories to be symlinks (but not contain any), but it turns out this also throws an error:

Error: add site dependencies: create deps: create PathSpec: build filesystems: create main fs: symlinks not allowed in this filesystem

Is there a way that a temporary fix could be made to expand the "resolving symlinks when they're the top-level folder" feature to include multiple staticDirs?

@bep bep removed the NeedsTriage label May 27, 2022
@bep bep modified the milestones: v0.100.0, v0.101.0 May 27, 2022
@bep bep modified the milestones: v0.101.0, v0.102.0 Jun 16, 2022
@bep bep modified the milestones: v0.102.0, v0.103.0 Aug 28, 2022
@bep bep modified the milestones: v0.103.0, v0.104.0 Sep 15, 2022
@bep bep modified the milestones: v0.104.0, v0.105.0 Sep 23, 2022
@bep bep modified the milestones: v0.105.0, v0.106.0 Oct 26, 2022
@bep bep modified the milestones: v0.106.0, v0.107.0 Nov 18, 2022
@bep bep modified the milestones: v0.107.0, v0.108.0 Dec 3, 2022
@viperML
Copy link

viperML commented Dec 9, 2022

I just ran into this problem when using Hugo in nix which (ab)uses symlinks. I have no idea why this is a security concern, if you can get around it easily

@bep bep modified the milestones: v0.108.0, v0.109.0 Dec 14, 2022
@bep bep modified the milestones: v0.109.0, v0.111.0, v0.110.0 Jan 26, 2023
@bep bep added this to the v0.115.0 milestone Jun 13, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@yuraic
Copy link

yuraic commented Aug 31, 2023

Agree as well that having such an option would be very valuable. I need symlinks in the static subfolder and want to avoid manually copying files into it every time anything changes to rebuild the website.

@jmooring
Copy link
Member

@yuraic The idiomatic way to handle this is with mounts, but perhaps your situation is different.

[[module.mounts]]
source = 'static'
target = 'static'

[[module.mounts]]
source = '/home/user/foo'
target = 'static'

@yuraic
Copy link

yuraic commented Aug 31, 2023

@yuraic The idiomatic way to handle this is with mounts, but perhaps your situation is different.

[[module.mounts]]
source = 'static'
target = 'static'

[[module.mounts]]
source = '/home/user/foo'
target = 'static'

This works, indeed! And it solves my problem. Thank you, @jmooring :)

@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 5, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@jmooring
Copy link
Member

This is no longer relevant. We removed symlink support in v0.123.0. Use mounts instead.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants