package hackers_git import ( "fmt" yaml "gopkg.in/yaml.v2" "io/ioutil" "nslcd_proto" "os" ) type yaml_user struct { username string fullname string shell string groups []string } func filename2uid(filename string) int32 { // TODO return 0 } func load_user_yaml(filename string) (ret nslcd_proto.Passwd, err error) { ret.UID = filename2uid(filename) if ret.UID < 0 { err = fmt.Errorf("Invalid user filename: %q", filename) return } file, err := os.Open(filename) if err != nil { return } contents, err := ioutil.ReadAll(file) if err != nil { return } var user yaml_user err = yaml.Unmarshal(contents, &user) ret.Name = user.username ret.Password = "x" ret.GID = name2gid("users") ret.GECOS = user.fullname ret.HomeDir = "/home/" + ret.Name ret.Shell = user.shell return } func load_user_password(filename string) string { // TODO return "!" }