mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Merge pull request #795 from restic/fix-767
fuse: Add options --allow-other and --allow-root
This commit is contained in:
commit
4795a5c5d1
@ -32,7 +32,9 @@ read-only mount.
|
|||||||
|
|
||||||
// MountOptions collects all options for the mount command.
|
// MountOptions collects all options for the mount command.
|
||||||
type MountOptions struct {
|
type MountOptions struct {
|
||||||
OwnerRoot bool
|
OwnerRoot bool
|
||||||
|
AllowRoot bool
|
||||||
|
AllowOther bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var mountOptions MountOptions
|
var mountOptions MountOptions
|
||||||
@ -41,6 +43,8 @@ func init() {
|
|||||||
cmdRoot.AddCommand(cmdMount)
|
cmdRoot.AddCommand(cmdMount)
|
||||||
|
|
||||||
cmdMount.Flags().BoolVar(&mountOptions.OwnerRoot, "owner-root", false, "use 'root' as the owner of files and dirs")
|
cmdMount.Flags().BoolVar(&mountOptions.OwnerRoot, "owner-root", false, "use 'root' as the owner of files and dirs")
|
||||||
|
cmdMount.Flags().BoolVar(&mountOptions.AllowRoot, "allow-root", false, "allow root user to access the data in the mounted directory")
|
||||||
|
cmdMount.Flags().BoolVar(&mountOptions.AllowOther, "allow-other", false, "allow other users to access the data in the mounted directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
func mount(opts MountOptions, gopts GlobalOptions, mountpoint string) error {
|
func mount(opts MountOptions, gopts GlobalOptions, mountpoint string) error {
|
||||||
@ -64,11 +68,21 @@ func mount(opts MountOptions, gopts GlobalOptions, mountpoint string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c, err := systemFuse.Mount(
|
|
||||||
mountpoint,
|
mountOptions := []systemFuse.MountOption{
|
||||||
systemFuse.ReadOnly(),
|
systemFuse.ReadOnly(),
|
||||||
systemFuse.FSName("restic"),
|
systemFuse.FSName("restic"),
|
||||||
)
|
}
|
||||||
|
|
||||||
|
if opts.AllowRoot {
|
||||||
|
mountOptions = append(mountOptions, systemFuse.AllowRoot())
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.AllowOther {
|
||||||
|
mountOptions = append(mountOptions, systemFuse.AllowOther())
|
||||||
|
}
|
||||||
|
|
||||||
|
c, err := systemFuse.Mount(mountpoint, mountOptions...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user