Exemple #1
0
func main() {
	unix.Umask(0)
	_, err := os.Create("foo")
	if err != nil {
		fmt.Println("Create Error")
	}
	unix.Umask(unix.S_IRGRP | unix.S_IWGRP | unix.S_IROTH | unix.S_IWOTH)
	_, err2 := os.Create("bar")

	if err2 != nil {
		fmt.Println("Create Error")
	}
}
Exemple #2
0
func initPlatformSpecific() {
	scope0.DefineBuiltin("_umask_", func(t *Task, args Cell) bool {
		nmask := int64(0)
		if args != Null {
			nmask = Car(args).(Atom).Int()
		}

		omask := unix.Umask(int(nmask))

		if nmask == 0 {
			unix.Umask(omask)
		}

		return t.Return(NewInteger(int64(omask)))
	})
}
Exemple #3
0
func init() {
	umask = unix.Umask(0) // read the umask
	unix.Umask(umask)     // set it back to what it was
	cmd.Root.AddCommand(commandDefintion)
	commandDefintion.Flags().BoolVarP(&noModTime, "no-modtime", "", noModTime, "Don't read the modification time (can speed things up).")
	commandDefintion.Flags().BoolVarP(&debugFUSE, "debug-fuse", "", debugFUSE, "Debug the FUSE internals - needs -v.")
	commandDefintion.Flags().BoolVarP(&noSeek, "no-seek", "", noSeek, "Don't allow seeking in files.")
	commandDefintion.Flags().DurationVarP(&dirCacheTime, "dir-cache-time", "", dirCacheTime, "Time to cache directory entries for.")
	// mount options
	commandDefintion.Flags().BoolVarP(&readOnly, "read-only", "", readOnly, "Mount read-only.")
	commandDefintion.Flags().BoolVarP(&allowNonEmpty, "allow-non-empty", "", allowNonEmpty, "Allow mounting over a non-empty directory.")
	commandDefintion.Flags().BoolVarP(&allowRoot, "allow-root", "", allowRoot, "Allow access to root user.")
	commandDefintion.Flags().BoolVarP(&allowOther, "allow-other", "", allowOther, "Allow access to other users.")
	commandDefintion.Flags().BoolVarP(&defaultPermissions, "default-permissions", "", defaultPermissions, "Makes kernel enforce access control based on the file mode.")
	commandDefintion.Flags().BoolVarP(&writebackCache, "write-back-cache", "", writebackCache, "Makes kernel buffer writes before sending them to rclone. Without this, writethrough caching is used.")
	commandDefintion.Flags().VarP(&maxReadAhead, "max-read-ahead", "", "The number of bytes that can be prefetched for sequential reads.")
	commandDefintion.Flags().IntVarP(&umask, "umask", "", umask, "Override the permission bits set by the filesystem.")
	commandDefintion.Flags().Uint32VarP(&uid, "uid", "", uid, "Override the uid field set by the filesystem.")
	commandDefintion.Flags().Uint32VarP(&gid, "gid", "", gid, "Override the gid field set by the filesystem.")
	//commandDefintion.Flags().BoolVarP(&foreground, "foreground", "", foreground, "Do not detach.")
}
Exemple #4
0
Fichier : main.go Projet : rudle/p2
func main() {
	kingpin.Version(version.VERSION)
	kingpin.Parse()

	if *umask != umaskDefault {
		effectiveUmask, err := strconv.ParseInt(*umask, 8, 0)
		if err != nil {
			log.Fatalf("umask not expressed in octal notation. %v\n", err)
		}
		unix.Umask(int(effectiveUmask))
	}

	if *clearEnv {
		os.Clearenv()
	}

	for _, dir := range *envDir {
		err := loadEnvDir(dir)
		if err != nil {
			log.Fatal(err)
		}
	}

	if *nolim {
		err := nolimit()
		if err != nil {
			log.Fatal(err)
		}
	}

	if *launchableName == "" && *cgroupName != "" {
		log.Fatalf("Specified cgroup name %q, but no launchable name was specified", *cgroupName)
	}
	if *launchableName != "" && *cgroupName == "" {
		log.Fatalf("Specified launchable name %q, but no cgroup name was specified", *launchableName)
	}
	if *launchableName != "" && *cgroupName != "" {
		if platconf := os.Getenv("PLATFORM_CONFIG_PATH"); platconf != "" {
			err := cgEnter(platconf, *launchableName, *cgroupName)
			if err != nil {
				log.Fatal(err)
			}
		} else {
			log.Fatal("No PLATFORM_CONFIG_PATH, cannot determine cgroup")
		}
	}

	if *username != "" {
		err := changeUser(*username)
		if err != nil {
			log.Fatal(err)
		}
	}

	if *workDir != "" {
		err := os.Chdir(*workDir)
		if err != nil {
			log.Fatal(err)
		}
	}

	binPath, err := exec.LookPath((*cmd)[0])
	if err != nil {
		log.Fatal(err)
	}
	err = syscall.Exec(binPath, *cmd, os.Environ())
	// should never be reached
	if err != nil {
		log.Fatalf("Error executing command %q: %s", *cmd, err)
	}
}