aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorCharles Duffy2017-05-30 16:01:06 -0500
committerrfjakob2017-06-01 00:26:17 +0200
commitcf1ded5236157e2f9ec06eeea26023b67b40f16d (patch)
tree48c9926efd8c10a76b6f28943397f8b1ae5cc3da /main.go
parentfc2a5f5ab0149d48b5d45a9af96799b07d802ae6 (diff)
Implement force_owner option to display ownership as a specific user.
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/main.go b/main.go
index 8dada52..9b0e31b 100644
--- a/main.go
+++ b/main.go
@@ -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)