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

[RFC] add Lchown #342

Closed
jxsl13 opened this issue Mar 1, 2022 · 0 comments
Closed

[RFC] add Lchown #342

jxsl13 opened this issue Mar 1, 2022 · 0 comments

Comments

@jxsl13
Copy link

jxsl13 commented Mar 1, 2022

Changing the owner of symlinks seems pretty useful to me.

I'd suggest the following method signature, same as LstatIfPossible.

type LinkOwner interface {
    LchownIfPossible(path string, uid, gid int) (bool, error)
}

The bool return value is true in case Lchown was used and false otherwise
This interface will most likely somehow require the Lstater interface to be implemented as well, as it's easiest to check whether the target path is a symlink and then decide based on that information whethe rto use LchownIfPossible or simply Chown

The Lstater interface implementation is not necessary for the OsFs but might be useful for other purposes down the line.

My use case is:

  • Installer that runs as root in order to create a software setup
  • Daemon that runs as technical user that should own all of the software written by the installer.

Discussion topics:

  • Is this interface added to the Symlinker interface?
  • Special error types needed?
  • ...

Looking at the other symlink related methods, the following interface seems to be the better option in addition to a custom PathError that is returned in case that the underlying implementation does not support this interface.

type LinkOwner interface {
    LchownIfPossible(path string, uid, gid int) error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant