diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index de1c76d..4cde6e2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,18 @@ # Release Notes +## v0.22.1 +- Re-adding support for the `uid` and `gid` command line flags. +- Allowing the older use of mounting with `sudo`, although, this is discouraged. The new command: +``` +dxfuse MNT your_project +``` + +The older method: +``` +sudo dxfuse -uid $(id -u) -gid $(id -g) MNT your_project +``` + + ## v0.22 - Use github actions for continuous integration (CI/CD) - Eliminate the use of `sudo` for starting up the filesystem. Normal user permissions are now sufficient to start and stop the filesystem. This assumes that the fuse device (`/dev/fuse`) is open for read/write access to regular users. diff --git a/cli/main.go b/cli/main.go index 7ab7735..a9468e4 100644 --- a/cli/main.go +++ b/cli/main.go @@ -46,8 +46,10 @@ var ( debugFuseFlag = flag.Bool("debugFuse", false, "Tap into FUSE debugging information") daemon = flag.Bool("daemon", false, "An internal flag, do not use it") fsSync = flag.Bool("sync", false, "Sychronize the filesystem and exit") + gid = flag.Int("gid", -1, "User group id (gid)") help = flag.Bool("help", false, "display program options") readOnly = flag.Bool("readOnly", false, "mount the filesystem in read-only mode") + uid = flag.Int("uid", -1, "User id (uid)") verbose = flag.Int("verbose", 0, "Enable verbose debugging") version = flag.Bool("version", false, "Print the version and exit") ) @@ -80,6 +82,17 @@ func initLog(logFile string) *os.File { return f } +func getUser() user.User { + user, err := user.Current() + if err != nil { + panic(err) + } + if user == nil { + panic("asking the OS for the user returned nil") + } + return *user +} + // Mount the filesystem: // - setup the debug log to the FUSE kernel log (I think) func fsDaemon( @@ -99,6 +112,13 @@ func fsDaemon( logger.Printf("starting fsDaemon") mountOptions := make(map[string]string) + user := getUser() + if user.Uid == "0" { + // Allow users other than root to access the filesystem + logger.Printf("started the filesystem as root, allowing other users access") + mountOptions["allow_other"] = "" + } + // capture debug output from the FUSE subsystem var fuse_logger *log.Logger if *debugFuseFlag { @@ -168,21 +188,27 @@ func waitForReady(logFile string) string { // get the current user Uid and Gid func initUidGid() (uint32, uint32) { - user, err := user.Current() - if err != nil { - panic(err) - } - - // get the user ID - u, err := strconv.Atoi(user.Uid) - if err != nil { - panic(err) + user := getUser() + + // by default, use the user id specified on the command line + var err error + u := *uid + if u == -1 { + // get the user ID + u, err = strconv.Atoi(user.Uid) + if err != nil { + panic(err) + } } + // by default, use the group id specified on the command line // get the group ID - g, err := strconv.Atoi(user.Gid) - if err != nil { - panic(err) + g := *gid + if g == -1 { + g, err = strconv.Atoi(user.Gid) + if err != nil { + panic(err) + } } return uint32(u), uint32(g) } @@ -320,13 +346,20 @@ func buildDaemonCommandLine(cfg Config, fullManifestPath string) []string { if (*fsSync) { daemonArgs = append(daemonArgs, "-sync") } - + if (*gid != -1) { + args := []string { "-gid", strconv.FormatInt(int64(*gid), 10) } + daemonArgs = append(daemonArgs, args...) + } if (*readOnly) { daemonArgs = append(daemonArgs, "-readOnly") } + if (*uid != -1) { + args := []string { "-uid", strconv.FormatInt(int64(*uid), 10) } + daemonArgs = append(daemonArgs, args...) + } if (*verbose > 0) { - verboseArgs := []string { "-verbose", strconv.FormatInt(int64(*verbose), 10) } - daemonArgs = append(daemonArgs, verboseArgs...) + args := []string { "-verbose", strconv.FormatInt(int64(*verbose), 10) } + daemonArgs = append(daemonArgs, args...) } positionalArgs := []string{ cfg.mountpoint, fullManifestPath } @@ -403,6 +436,7 @@ func main() { validateConfig(cfg) logFile := dxfuse.MakeFSBaseDir() + "/" + dxfuse.LogFile + fmt.Printf("The log file is located at %s\n", logFile) if *daemon { // This will be true -only- in the child sub-process diff --git a/util.go b/util.go index 607cec4..3d5573f 100644 --- a/util.go +++ b/util.go @@ -29,7 +29,7 @@ const ( MaxDirSize = 10 * 1000 MaxNumFileHandles = 1000 * 1000 NumRetriesDefault = 3 - Version = "v0.22" + Version = "v0.22.1" ) const ( InodeInvalid = 0