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

[BUG] Multiple symlinks cannot be made to point to the same destination #489

Open
1 task done
pmengelbert opened this issue Jan 6, 2025 · 4 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@pmengelbert
Copy link
Contributor

pmengelbert commented Jan 6, 2025

Expected Behavior

You should be able to create multiple symlinks that point to the same location. For example:

image:
  post:
    symlinks:
      - oldpath: /bin/busybox
        newpath: /usr/bin/sh
      - oldpath: /bin/busybox
         newpath: /usr/bin/test

Actual Behavior

The spec format requires:

image:
  post:
    symlinks:
      /bin/busybox:
        path: /usr/bin/sh
      /bin/busybox:
         path: /usr/bin/test

This causes a yaml parsing error at best, and silently overwrites the /bin/busybox map key at worst.

Steps To Reproduce

n/a, see above.

Are you willing to submit PRs to contribute to this bug fix?

  • Yes, I am willing to implement it.
@pmengelbert pmengelbert added the bug Something isn't working label Jan 6, 2025
@cpuguy83
Copy link
Member

cpuguy83 commented Jan 6, 2025

Note, we already have a type for this in the artifact section:

dalec/artifacts.go

Lines 49 to 57 in 08d2e6c

type ArtifactSymlinkConfig struct {
// Source is the path that is being linked to
// Example:
// If you want a symlink in /usr/bin/foo that is linking to /usr/bin/foo/foo
// then the `Source` is `/usr/bin/foo/foo`
Source string `yaml:"source,omitempty" json:"source,omitempty"`
// Dest is the path where the symlink will be installed
Dest string `yaml:"dest,omitempty" json:"dest,omitempty"`
}

The case for symlinks in the image-post is a slightly different one though (really a hack so we don't need to create multiple packages).

@cpuguy83
Copy link
Member

cpuguy83 commented Jan 6, 2025

I think we could change

dalec/spec.go

Lines 131 to 134 in 08d2e6c

type SymlinkTarget struct {
// Path is the path where the symlink should be placed
Path string `yaml:"path" json:"path" jsonschema:"required"`
}
to include a paths field that would be muttually exclusive with path (so specify one or the other, not both) which is a []string

@pmengelbert
Copy link
Contributor Author

Note, we already have a type for this in the artifact section:

dalec/artifacts.go

Lines 49 to 57 in 08d2e6c

type ArtifactSymlinkConfig struct {
// Source is the path that is being linked to
// Example:
// If you want a symlink in /usr/bin/foo that is linking to /usr/bin/foo/foo
// then the Source is /usr/bin/foo/foo
Source string yaml:"source,omitempty" json:"source,omitempty"
// Dest is the path where the symlink will be installed
Dest string yaml:"dest,omitempty" json:"dest,omitempty"
}
The case for symlinks in the image-post is a slightly different one though (really a hack so we don't need to create multiple packages).

Can these symlinks be placed in arbitrary locations? Or are they intended for linking stuff nested under, for example, /usr/bin?

@pmengelbert
Copy link
Contributor Author

I think we could change

dalec/spec.go

Lines 131 to 134 in 08d2e6c

type SymlinkTarget struct {
// Path is the path where the symlink should be placed
Path string yaml:"path" json:"path" jsonschema:"required"
}
to include a paths field that would be muttually exclusive with path (so specify one or the other, not both) which is a []string

Sounds like a good approach. I will implement this prior to #494.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants