Esempio n. 1
0
func (r UserMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*User, error) {
	sysres := sys.NewUser(sr, sys, config)
	res, err := NewUser(sysres, config)
	if err != nil {
		return nil, err
	}
	r[res.ID()] = res
	return res, nil
}
Esempio n. 2
0
func (r UserMap) AppendSysResourceIfExists(sr string, sys *system.System) (*User, system.User, bool) {
	sysres := sys.NewUser(sr, sys)
	res := NewUser(sysres)
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Esempio n. 3
0
func (r UserMap) AppendSysResourceIfExists(sr string, sys *system.System) (*User, system.User, bool) {
	sysres := sys.NewUser(sr, sys, util.Config{})
	// FIXME: Do we want to be silent about errors?
	res, _ := NewUser(sysres, util.Config{})
	if e, _ := sysres.Exists(); e != true {
		return res, sysres, false
	}
	r[res.ID()] = res
	return res, sysres, true
}
Esempio n. 4
0
func (r UserMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*User, error) {
	sysres := sys.NewUser(sr, sys, config)
	res, err := NewUser(sysres, config)
	if err != nil {
		return nil, err
	}
	if old_res, ok := r[res.ID()]; ok {
		res.Title = old_res.Title
		res.Meta = old_res.Meta
	}
	r[res.ID()] = res
	return res, nil
}
Esempio n. 5
0
File: user.go Progetto: postfix/goss
func (s *User) Validate(sys *system.System) []TestResult {
	sysuser := sys.NewUser(s.Username, sys)

	var results []TestResult

	results = append(results, ValidateValue(s.Username, "exists", s.Exists, sysuser.Exists))
	if !s.Exists {
		return results
	}
	results = append(results, ValidateValue(s.Username, "uid", s.UID, sysuser.UID))
	results = append(results, ValidateValue(s.Username, "gid", s.Gid, sysuser.Gid))
	results = append(results, ValidateValue(s.Username, "home", s.Home, sysuser.Home))
	results = append(results, ValidateValues(s.Username, "groups", s.Groups, sysuser.Groups))

	return results
}
Esempio n. 6
0
File: user.go Progetto: ryancox/goss
func (u *User) Validate(sys *system.System) []TestResult {
	sysuser := sys.NewUser(u.Username, sys, util.Config{})

	var results []TestResult

	results = append(results, ValidateValue(u, "exists", u.Exists, sysuser.Exists))

	if u.UID != "" {
		results = append(results, ValidateValue(u, "uid", u.UID, sysuser.UID))
	}
	if u.GID != "" {
		results = append(results, ValidateValue(u, "gid", u.GID, sysuser.GID))
	}
	if u.Home != "" {
		results = append(results, ValidateValue(u, "home", u.Home, sysuser.Home))
	}
	if len(u.Groups) > 0 {
		results = append(results, ValidateValues(u, "groups", u.Groups, sysuser.Groups))
	}

	return results
}
Esempio n. 7
0
func (r UserMap) AppendSysResource(sr string, sys *system.System) (*User, system.User) {
	sysres := sys.NewUser(sr, sys)
	res := NewUser(sysres)
	r[res.ID()] = res
	return res, sysres
}