Exemplo n.º 1
0
func updatePerms(dirPath, mockPath string) {
	if knf.GetS(ACCESS_USER) != "" || knf.GetS(ACCESS_GROUP) != "" {
		dirOwnerUID, dirOwnerGID, _ := fsutil.GetOwner(dirPath)
		mockOwnerUID, mockOwnerGID, _ := fsutil.GetOwner(mockPath)

		if knf.GetS(ACCESS_USER) != "" {
			userInfo, err := system.LookupUser(knf.GetS(ACCESS_USER))

			if err == nil {
				dirOwnerUID = userInfo.UID
				mockOwnerUID = userInfo.UID
			}
		}

		if knf.GetS(ACCESS_GROUP) != "" {
			groupInfo, err := system.LookupGroup(knf.GetS(ACCESS_GROUP))

			if err == nil {
				dirOwnerGID = groupInfo.GID
				mockOwnerGID = groupInfo.GID
			}
		}

		os.Chown(dirPath, dirOwnerUID, dirOwnerGID)
		os.Chown(mockPath, mockOwnerUID, mockOwnerGID)
	}

	os.Chmod(dirPath, knf.GetM(ACCESS_MOCK_DIR_PERMS))
	os.Chmod(mockPath, knf.GetM(ACCESS_MOCK_PERMS))
}
Exemplo n.º 2
0
func setupLog() {
	var err error

	if arg.GetB(ARG_DAEMON) {
		err = log.Set(knf.GetS(LOG_FILE), knf.GetM(LOG_PERMS, 0644))

		if err != nil {
			fmt.Printf("Can't setup logger: %v\n", err)
			os.Exit(1)
		}
	}

	err = log.MinLevel(knf.GetS(LOG_LEVEL, "info"))

	if err != nil {
		fmt.Printf("Can't set log level: %v\n", err)
	}
}