package hackers_git import ( "inotify" "nslcd_proto" "nslcd_proto/util" "nslcd_systemd" "sd_daemon/logger" "sync" ) type user struct { passwd nslcd_proto.Passwd groups []string } type Config struct { Pam_password_prohibit_message string Yamldir string } type Hackers struct { util.NullBackend cfg Config lock sync.RWMutex users map[int32]user passwords map[int32]string in_fd *inotify.Inotify in_wd_home inotify.Cint in_wd_yaml inotify.Cint in_uid2wd map[int32]inotify.Cint in_wd2uid map[inotify.Cint]int32 } var _ nslcd_systemd.Backend = &Hackers{} var _ nslcd_proto.Backend = &Hackers{} func NewHackers(config Config) *Hackers { o := Hackers{ cfg: config, } err := o.Reload() if err != nil { return nil } go o.worker() return &o } func (o *Hackers) Close() { logger.Info("Closing hackers.git session") o.lock.Lock() defer o.lock.Unlock() o.close() } func (o *Hackers) Reload() error { logger.Info("Loading hackers.git session") o.lock.Lock() defer o.lock.Unlock() return o.reload() } func (o *Hackers) name2uid(name string) int32 { for uid, data := range o.users { if data.passwd.Name == name { return uid } } return -1 }