afero
afero copied to clipboard
[RFC] add Lchown
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
}