diff options
author | Charles Duffy | 2017-05-30 16:01:06 -0500 |
---|---|---|
committer | rfjakob | 2017-06-01 00:26:17 +0200 |
commit | cf1ded5236157e2f9ec06eeea26023b67b40f16d (patch) | |
tree | 48c9926efd8c10a76b6f28943397f8b1ae5cc3da /main.go | |
parent | fc2a5f5ab0149d48b5d45a9af96799b07d802ae6 (diff) |
Implement force_owner option to display ownership as a specific user.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -8,6 +8,7 @@ import ( "runtime" "runtime/pprof" "strconv" + "strings" "time" "github.com/rfjakob/gocryptfs/internal/configfile" @@ -17,6 +18,7 @@ import ( "github.com/rfjakob/gocryptfs/internal/speed" "github.com/rfjakob/gocryptfs/internal/stupidgcm" "github.com/rfjakob/gocryptfs/internal/tlog" + "github.com/hanwen/go-fuse/fuse" ) // GitVersion is the gocryptfs version according to git, set by build.bash @@ -190,6 +192,26 @@ func main() { pprof.StartCPUProfile(f) defer pprof.StopCPUProfile() } + // "-force_owner" + if args.force_owner != "" { + var uidNum, gidNum int64 + ownerPieces := strings.SplitN(args.force_owner, ":", 2) + if len(ownerPieces) != 2 { + tlog.Fatal.Printf("force_owner must be in form UID:GID") + os.Exit(exitcodes.Usage) + } + uidNum, err = strconv.ParseInt(ownerPieces[0], 0, 32) + if err != nil || uidNum < 0 { + tlog.Fatal.Printf("force_owner: Unable to parse UID %v as positive integer", ownerPieces[0]) + os.Exit(exitcodes.Usage) + } + gidNum, err = strconv.ParseInt(ownerPieces[1], 0, 32) + if err != nil || gidNum < 0 { + tlog.Fatal.Printf("force_owner: Unable to parse GID %v as positive integer", ownerPieces[1]) + os.Exit(exitcodes.Usage) + } + args._forceOwner = &fuse.Owner{Uid: uint32(uidNum), Gid: uint32(gidNum)} + } // "-memprofile" if args.memprofile != "" { tlog.Info.Printf("Writing mem profile to %s", args.memprofile) |