diff options
-rw-r--r-- | src/nshd/hackers_git/db_config.go | 32 | ||||
-rw-r--r-- | src/nshd/hackers_git/db_group.go | 129 | ||||
-rw-r--r-- | src/nshd/hackers_git/db_pam.go | 104 | ||||
-rw-r--r-- | src/nshd/hackers_git/db_passwd.go | 108 | ||||
-rw-r--r-- | src/nshd/hackers_git/db_shadow.go | 111 | ||||
-rw-r--r-- | src/nslcd_proto/.gitignore | 2 | ||||
-rw-r--r-- | src/nslcd_proto/Makefile | 12 | ||||
-rw-r--r-- | src/nslcd_proto/enumerator@T.got | 8 | ||||
-rwxr-xr-x | src/nslcd_proto/func_handlerequest.go.sh | 25 | ||||
-rwxr-xr-x | src/nslcd_proto/interface_backend.go.sh | 4 | ||||
-rw-r--r-- | src/nslcd_proto/util/enumerator@T.got | 45 | ||||
-rwxr-xr-x | src/nslcd_proto/util/struct_null_backend.go.sh | 2 |
12 files changed, 227 insertions, 355 deletions
diff --git a/src/nshd/hackers_git/db_config.go b/src/nshd/hackers_git/db_config.go index fde16b3..7e96059 100644 --- a/src/nshd/hackers_git/db_config.go +++ b/src/nshd/hackers_git/db_config.go @@ -1,26 +1,20 @@ package hackers_git -import ( - p "nslcd_proto" - "nslcd_proto/util" -) +import p "nslcd_proto" -func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) p.Config_Enumerator { +func (o *Hackers) Config_Get(cred p.Ucred, req p.Request_Config_Get) <-chan p.Config { o.lock.RLock() - defer o.lock.RUnlock() + ret := make(chan p.Config) + go func() { + defer o.lock.RUnlock() + defer close(ret) - var val *string = nil - - switch req.Key { - case p.NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE: - if o.Cfg.Pam_password_prohibit_message != "" { - val = &o.Cfg.Pam_password_prohibit_message + switch req.Key { + case p.NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE: + if o.Cfg.Pam_password_prohibit_message != "" { + ret <- p.Config{Value: o.Cfg.Pam_password_prohibit_message} + } } - } - - if val != nil { - return util.New_Config_List([]p.Config{p.Config{Value: *val}}) - } else { - return util.Config_Ø{} - } + }() + return ret } diff --git a/src/nshd/hackers_git/db_group.go b/src/nshd/hackers_git/db_group.go index 63a9fe4..3122bd2 100644 --- a/src/nshd/hackers_git/db_group.go +++ b/src/nshd/hackers_git/db_group.go @@ -1,9 +1,6 @@ package hackers_git -import ( - p "nslcd_proto" - "nslcd_proto/util" -) +import p "nslcd_proto" func (o *Hackers) groupByName(name string, users bool) p.Group { members_set, found := o.groups[name] @@ -51,85 +48,73 @@ func (o *Hackers) groupByGid(gid int32, users bool) p.Group { } } -func (o *Hackers) Group_ByName(cred p.Ucred, req p.Request_Group_ByName) p.Group_Enumerator { +func (o *Hackers) Group_ByName(cred p.Ucred, req p.Request_Group_ByName) <-chan p.Group { o.lock.RLock() - defer o.lock.RUnlock() - group := o.groupByName(req.Name, true) - if group.ID < 0 { - return util.Group_Ø{} - } - return util.New_Group_List([]p.Group{group}) -} + ret := make(chan p.Group) + go func() { + defer o.lock.RUnlock() + defer close(ret) -func (o *Hackers) Group_ByGid(cred p.Ucred, req p.Request_Group_ByGid) p.Group_Enumerator { - o.lock.RLock() - defer o.lock.RUnlock() - group := o.groupByGid(req.Gid, true) - if group.ID < 0 { - return util.Group_Ø{} - } - return util.New_Group_List([]p.Group{group}) + group := o.groupByName(req.Name, true) + if group.ID < 0 { + return + } + ret <- group + }() + return ret } -type groupEnumerator struct { - groups []string - users bool - backend *Hackers - done bool -} +func (o *Hackers) Group_ByGid(cred p.Ucred, req p.Request_Group_ByGid) <-chan p.Group { + o.lock.RLock() + ret := make(chan p.Group) + go func() { + defer o.lock.RUnlock() + defer close(ret) -func (e *groupEnumerator) GetNext() (*p.Group, error) { - for len(e.groups) > 0 { - name := e.groups[0] - group := e.backend.groupByName(name, e.users) - e.groups = e.groups[1:] - if group.ID >= 0 { - return &group, nil + group := o.groupByGid(req.Gid, true) + if group.ID < 0 { + return } - } - if !e.done { - e.done = true - e.backend.lock.RUnlock() - } - return nil, nil -} - -func (o *groupEnumerator) GenericGetNext() (n *interface{}, err error) { - a, err := o.GetNext() - if a != nil { - b := (interface{})(*a) - n = &b - } - return + ret <- group + }() + return ret } // note that the BYMEMBER call returns an empty members list -func (o *Hackers) Group_ByMember(cred p.Ucred, req p.Request_Group_ByMember) p.Group_Enumerator { +func (o *Hackers) Group_ByMember(cred p.Ucred, req p.Request_Group_ByMember) <-chan p.Group { o.lock.RLock() - uid := o.name2uid(req.Member) - if uid < 0 { - return util.Group_Ø{} - } - return &groupEnumerator{ - groups: o.users[uid].groups, - users: false, - backend: o, - done: false, - } + ret := make(chan p.Group) + go func() { + defer o.lock.RUnlock() + defer close(ret) + + uid := o.name2uid(req.Member) + if uid < 0 { + return + } + for _, name := range o.users[uid].groups { + group := o.groupByName(name, false) + if group.ID >= 0 { + ret <- group + } + } + }() + return ret } -func (o *Hackers) Group_All(cred p.Ucred, req p.Request_Group_All) p.Group_Enumerator { +func (o *Hackers) Group_All(cred p.Ucred, req p.Request_Group_All) <-chan p.Group { o.lock.RLock() - e := groupEnumerator{ - groups: make([]string, len(o.groups)), - users: true, - backend: o, - done: false, - } - i := uint(0) - for group, _ := range o.groups { - e.groups[i] = group - i++ - } - return &e + ret := make(chan p.Group) + go func() { + defer o.lock.RUnlock() + defer close(ret) + + for name, _ := range o.groups { + group := o.groupByName(name, false) + if group.ID >= 0 { + ret <- group + } + } + }() + return ret } diff --git a/src/nshd/hackers_git/db_pam.go b/src/nshd/hackers_git/db_pam.go index d4df99a..126c403 100644 --- a/src/nshd/hackers_git/db_pam.go +++ b/src/nshd/hackers_git/db_pam.go @@ -4,70 +4,80 @@ import ( "crypto/rand" "math/big" p "nslcd_proto" - "nslcd_proto/util" ) -func (o *Hackers) PAM_Authentication(cred p.Ucred, req p.Request_PAM_Authentication) p.PAM_Authentication_Enumerator { +func (o *Hackers) PAM_Authentication(cred p.Ucred, req p.Request_PAM_Authentication) <-chan p.PAM_Authentication { o.lock.RLock() - defer o.lock.RUnlock() + ret := make(chan p.PAM_Authentication) + go func() { + defer o.lock.RUnlock() + defer close(ret) - uid := o.name2uid(req.UserName) - if uid < 0 { - return util.PAM_Authentication_Ø{} - } - - user := o.users[uid] - ret := p.PAM_Authentication{ - AuthenticationResult: p.NSLCD_PAM_AUTH_ERR, - UserName: "", - AuthorizationResult: p.NSLCD_PAM_AUTH_ERR, - AuthorizationError: "", - } - if check_password(req.Password, user.passwd.PwHash) { - ret.AuthenticationResult = p.NSLCD_PAM_SUCCESS - ret.AuthorizationResult = ret.AuthenticationResult - ret.UserName = user.passwd.Name - } + uid := o.name2uid(req.UserName) + if uid < 0 { + return + } - return util.New_PAM_Authentication_List([]p.PAM_Authentication{ret}) + user := o.users[uid] + obj := p.PAM_Authentication{ + AuthenticationResult: p.NSLCD_PAM_AUTH_ERR, + UserName: "", + AuthorizationResult: p.NSLCD_PAM_AUTH_ERR, + AuthorizationError: "", + } + if check_password(req.Password, user.passwd.PwHash) { + obj.AuthenticationResult = p.NSLCD_PAM_SUCCESS + obj.AuthorizationResult = obj.AuthenticationResult + obj.UserName = user.passwd.Name + } + ret <- obj + }() + return ret } -func (o *Hackers) PAM_Authorization(cred p.Ucred, req p.Request_PAM_Authorization) p.PAM_Authorization_Enumerator { +func (o *Hackers) PAM_Authorization(cred p.Ucred, req p.Request_PAM_Authorization) <-chan p.PAM_Authorization { o.lock.RLock() - defer o.lock.RUnlock() - - uid := o.name2uid(req.UserName) - if uid < 0 { - return util.PAM_Authorization_Ø{} - } - ret := p.PAM_Authorization{ - Result: p.NSLCD_PAM_SUCCESS, - Error: "", - } + ret := make(chan p.PAM_Authorization) + go func() { + defer o.lock.RUnlock() + defer close(ret) - return util.New_PAM_Authorization_List([]p.PAM_Authorization{ret}) + uid := o.name2uid(req.UserName) + if uid < 0 { + return + } + ret <- p.PAM_Authorization{ + Result: p.NSLCD_PAM_SUCCESS, + Error: "", + } + }() + return ret } const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890" var alphabet_len = big.NewInt(int64(len(alphabet))) -func (o *Hackers) PAM_SessionOpen(cred p.Ucred, req p.Request_PAM_SessionOpen) p.PAM_SessionOpen_Enumerator { - var sessionid [24]byte +func (o *Hackers) PAM_SessionOpen(cred p.Ucred, req p.Request_PAM_SessionOpen) <-chan p.PAM_SessionOpen { + ret := make(chan p.PAM_SessionOpen) + go func() { + defer close(ret) - for i := 0; i < len(sessionid); i++ { - bigint, err := rand.Int(rand.Reader, alphabet_len) - if err != nil { - return util.PAM_SessionOpen_Ø{} + var sessionid [24]byte + for i := 0; i < len(sessionid); i++ { + bigint, err := rand.Int(rand.Reader, alphabet_len) + if err != nil { + return + } + sessionid[i] = alphabet[bigint.Int64()] } - sessionid[i] = alphabet[bigint.Int64()] - } - - ret := p.PAM_SessionOpen{SessionID: string(sessionid[:])} - - return util.New_PAM_SessionOpen_List([]p.PAM_SessionOpen{ret}) + ret <- p.PAM_SessionOpen{SessionID: string(sessionid[:])} + }() + return ret } -func (o *Hackers) PAM_SessionClose(cred p.Ucred, req p.Request_PAM_SessionClose) p.PAM_SessionClose_Enumerator { - return util.PAM_SessionClose_Ø{} +func (o *Hackers) PAM_SessionClose(cred p.Ucred, req p.Request_PAM_SessionClose) <-chan p.PAM_SessionClose { + ret := make(chan p.PAM_SessionClose) + go close(ret) + return ret } diff --git a/src/nshd/hackers_git/db_passwd.go b/src/nshd/hackers_git/db_passwd.go index 32570fb..cc8c711 100644 --- a/src/nshd/hackers_git/db_passwd.go +++ b/src/nshd/hackers_git/db_passwd.go @@ -1,9 +1,6 @@ package hackers_git -import ( - p "nslcd_proto" - "nslcd_proto/util" -) +import p "nslcd_proto" /* Note that the output password hash value should be one of: <empty> - no password set, allow login without password @@ -12,73 +9,54 @@ import ( often used to indicate that the password is defined elsewhere other - encrypted password, in crypt(3) format */ -func (o *Hackers) Passwd_ByName(cred p.Ucred, req p.Request_Passwd_ByName) p.Passwd_Enumerator { +func (o *Hackers) Passwd_ByName(cred p.Ucred, req p.Request_Passwd_ByName) <-chan p.Passwd { o.lock.RLock() - defer o.lock.RUnlock() - - uid := o.name2uid(req.Name) - if uid < 0 { - return util.Passwd_Ø{} - } - passwd := o.users[uid].passwd - passwd.PwHash = "x" // only put actual hashes in the Shadow DB - - return util.New_Passwd_List([]p.Passwd{passwd}) + ret := make(chan p.Passwd) + go func() { + defer o.lock.RUnlock() + defer close(ret) + + uid := o.name2uid(req.Name) + if uid < 0 { + return + } + passwd := o.users[uid].passwd + passwd.PwHash = "x" // only put actual hashes in the Shadow DB + ret <- passwd + }() + return ret } -func (o *Hackers) Passwd_ByUID(cred p.Ucred, req p.Request_Passwd_ByUID) p.Passwd_Enumerator { +func (o *Hackers) Passwd_ByUID(cred p.Ucred, req p.Request_Passwd_ByUID) <-chan p.Passwd { o.lock.RLock() - defer o.lock.RUnlock() - - user, found := o.users[req.UID] - if !found { - return util.Passwd_Ø{} - } - passwd := user.passwd - passwd.PwHash = "x" // only put actual hashes in the Shadow DB - - return util.New_Passwd_List([]p.Passwd{passwd}) -} - -type allPasswdEnumerator struct { - uids []int32 - backend *Hackers - done bool -} - -func (e *allPasswdEnumerator) GetNext() (*p.Passwd, error) { - if len(e.uids) > 0 { - passwd := e.backend.users[e.uids[0]].passwd + ret := make(chan p.Passwd) + go func() { + defer o.lock.RUnlock() + defer close(ret) + + user, found := o.users[req.UID] + if !found { + return + } + passwd := user.passwd passwd.PwHash = "x" // only put actual hashes in the Shadow DB - e.uids = e.uids[1:] - return &passwd, nil - } else if !e.done { - e.done = true - e.backend.lock.RUnlock() - } - return nil, nil -} - -func (o *allPasswdEnumerator) GenericGetNext() (n *interface{}, err error) { - a, err := o.GetNext() - if a != nil { - b := (interface{})(*a) - n = &b - } - return + ret <- passwd + }() + return ret } -func (o *Hackers) Passwd_All(cred p.Ucred, req p.Request_Passwd_All) p.Passwd_Enumerator { +func (o *Hackers) Passwd_All(cred p.Ucred, req p.Request_Passwd_All) <-chan p.Passwd { o.lock.RLock() - e := allPasswdEnumerator{ - uids: make([]int32, len(o.users)), - backend: o, - done: false, - } - i := uint(0) - for uid, _ := range o.users { - e.uids[i] = uid - i++ - } - return &e + ret := make(chan p.Passwd) + go func() { + defer o.lock.RUnlock() + defer close(ret) + + for _, user := range o.users { + passwd := user.passwd + passwd.PwHash = "x" // only put actual hashes in the Shadow DB + ret <- passwd + } + }() + return ret } diff --git a/src/nshd/hackers_git/db_shadow.go b/src/nshd/hackers_git/db_shadow.go index fecb9f8..594e7a1 100644 --- a/src/nshd/hackers_git/db_shadow.go +++ b/src/nshd/hackers_git/db_shadow.go @@ -1,46 +1,22 @@ package hackers_git -import ( - p "nslcd_proto" - "nslcd_proto/util" -) +import p "nslcd_proto" -func (o *Hackers) Shadow_ByName(cred p.Ucred, req p.Request_Shadow_ByName) p.Shadow_Enumerator { +func (o *Hackers) Shadow_ByName(cred p.Ucred, req p.Request_Shadow_ByName) <-chan p.Shadow { o.lock.RLock() - defer o.lock.RUnlock() + ret := make(chan p.Shadow) + go func() { + defer o.lock.RUnlock() + defer close(ret) - if cred.Uid != 0 { - return util.Shadow_Ø{} - } - uid := o.name2uid(req.Name) - passwd := o.users[uid].passwd - shadow := p.Shadow{ - Name: passwd.Name, - PwHash: passwd.PwHash, - LastChangeDate: -1, - MinDays: -1, - MaxDays: -1, - WarnDays: -1, - InactDays: -1, - ExpireDate: -1, - Flag: -1, - } - - return util.New_Shadow_List([]p.Shadow{shadow}) -} - -type allShadowEnumerator struct { - uids []int32 - backend *Hackers - done bool -} - -func (e *allShadowEnumerator) GetNext() (*p.Shadow, error) { - if len(e.uids) > 0 { - passwd := e.backend.users[e.uids[0]].passwd - shadow := p.Shadow{ - Name: passwd.Name, - PwHash: passwd.PwHash, + if cred.Uid != 0 { + return + } + uid := o.name2uid(req.Name) + user := o.users[uid] + ret <- p.Shadow{ + Name: user.passwd.Name, + PwHash: user.passwd.PwHash, LastChangeDate: -1, MinDays: -1, MaxDays: -1, @@ -49,39 +25,34 @@ func (e *allShadowEnumerator) GetNext() (*p.Shadow, error) { ExpireDate: -1, Flag: -1, } - e.uids = e.uids[1:] - return &shadow, nil - } - if len(e.uids) == 0 && !e.done { - e.done = true - e.backend.lock.RUnlock() - } - return nil, nil + }() + return ret } -func (o *allShadowEnumerator) GenericGetNext() (n *interface{}, err error) { - a, err := o.GetNext() - if a != nil { - b := (interface{})(*a) - n = &b - } - return -} - -func (o *Hackers) Shadow_All(cred p.Ucred, req p.Request_Shadow_All) p.Shadow_Enumerator { - if cred.Uid != 0 { - return util.Shadow_Ø{} - } +func (o *Hackers) Shadow_All(cred p.Ucred, req p.Request_Shadow_All) <-chan p.Shadow { o.lock.RLock() - e := allShadowEnumerator{ - uids: make([]int32, len(o.users)), - backend: o, - done: false, - } - i := uint(0) - for uid, _ := range o.users { - e.uids[i] = uid - i++ - } - return &e + ret := make(chan p.Shadow) + go func() { + defer o.lock.RUnlock() + defer close(ret) + + if cred.Uid != 0 { + return + } + + for _, user := range o.users { + ret <- p.Shadow{ + Name: user.passwd.Name, + PwHash: user.passwd.PwHash, + LastChangeDate: -1, + MinDays: -1, + MaxDays: -1, + WarnDays: -1, + InactDays: -1, + ExpireDate: -1, + Flag: -1, + } + } + }() + return ret } diff --git a/src/nslcd_proto/.gitignore b/src/nslcd_proto/.gitignore index 86bd764..0915898 100644 --- a/src/nslcd_proto/.gitignore +++ b/src/nslcd_proto/.gitignore @@ -3,5 +3,3 @@ /func_handlerequest.go /requests.txt /responses.txt -/enumerator-list.mk -*@*.go diff --git a/src/nslcd_proto/Makefile b/src/nslcd_proto/Makefile index 52e58f5..9e3ba4e 100644 --- a/src/nslcd_proto/Makefile +++ b/src/nslcd_proto/Makefile @@ -2,7 +2,7 @@ _ := $(MAKEFILE_LIST) d := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) generate := $(generate) $d/interface_backend.go $d/func_handlerequest.go $d/util/struct_null_backend.go -secondary := $(secondary) $d/enumerator-list.mk $d/requests.txt $d/responses.txt $d/*@*.go $d/util/*@*.go +secondary := $d/requests.txt ifeq (,$(filter clean,$(MAKECMDGOALS))) -include $d/enumerator-list.mk @@ -25,18 +25,8 @@ clean: endif -$d/enumerator@%.go: $d/enumerator@T.got - < $< sed 's/<T>/$*/g' > $@ -$d/util/enumerator@%.go: $d/util/enumerator@T.got - < $< sed 's/<T>/$*/g' > $@ - -$d/enumerator-list.mk: $d/responses.txt $d/Makefile - < $< sed -rn 's|.*|generate += $$d/enumerator@&.go $$d/util/enumerator@&.go|p' > $@ - $d/requests.txt: $d/nslcd_h.go $d/Makefile < $< grep -Eo '\btype Request_([^_ ]+)(_\S+)?' | sed 's/^type Request_//' > $@ -$d/responses.txt: $d/interface_backend.go $d/Makefile - < $< sed -rn 's/.* (\S+)_Enumerator$$/\1/p' | sort -u > $@ %.go: %.go.sh ./$^ > $@ diff --git a/src/nslcd_proto/enumerator@T.got b/src/nslcd_proto/enumerator@T.got deleted file mode 100644 index cad54fa..0000000 --- a/src/nslcd_proto/enumerator@T.got +++ /dev/null @@ -1,8 +0,0 @@ -package nslcd_proto - -type <T>_Enumerator interface { - GetNext() (n *<T>, err error) - GenericGetNext() (n *interface{}, err error) -} - -// -*- Mode: Go -*- diff --git a/src/nslcd_proto/func_handlerequest.go.sh b/src/nslcd_proto/func_handlerequest.go.sh index 45e0ed6..de9a6b7 100755 --- a/src/nslcd_proto/func_handlerequest.go.sh +++ b/src/nslcd_proto/func_handlerequest.go.sh @@ -9,10 +9,6 @@ import ( "io" ) -type enumerator interface { - GenericGetNext() (n *interface{}, err error) -} - func handleRequest(backend Backend, in io.Reader, out io.Writer, cred Ucred) { var version int32 read(in, &version) @@ -22,7 +18,7 @@ func handleRequest(backend Backend, in io.Reader, out io.Writer, cred Ucred) { var action int32 read(in, &action) - var res enumerator = nil + res := make(chan interface{}) switch action { $( while read -r request; do @@ -31,7 +27,15 @@ while read -r request; do var req Request_${request} read(in, &req) fmt.Printf("request: %#v\n", req) - res = backend.${request}(cred, req) + _res := backend.${request}(cred, req) + go func() { + o, ok := <-_res + if ok { + res <- o + } else { + close(res) + } + }() EOT done < "$requests" ) @@ -44,14 +48,9 @@ done < "$requests" write(out, NSLCD_VERSION) write(out, action) - var result *interface{} - var err error - for result, err = res.GenericGetNext(); (result != nil) && (err == nil); result, err = res.GenericGetNext() { + for result, ok := <-res; ok; result, ok = <-res { write(out, NSLCD_RESULT_BEGIN) - write(out, *result) - } - if err != nil { - panic(err) + write(out, result) } write(out, NSLCD_RESULT_END) } diff --git a/src/nslcd_proto/interface_backend.go.sh b/src/nslcd_proto/interface_backend.go.sh index 9e812ee..a5b76a4 100755 --- a/src/nslcd_proto/interface_backend.go.sh +++ b/src/nslcd_proto/interface_backend.go.sh @@ -9,7 +9,7 @@ import "syscall" type Ucred syscall.Ucred type Backend interface { - $(sed -rn 's/([^_]+)(.*)/\1\2(Ucred, Request_\1\2) \1_Enumerator/p' "$requests" | grep -v PAM) - $(sed -rn 's/(PAM)(.*)/\1\2(Ucred, Request_\1\2) \1\2_Enumerator/p' "$requests") + $(sed -rn 's/([^_]+)(.*)/\1\2(Ucred, Request_\1\2) <-chan \1/p' "$requests" | grep -v PAM) + $(sed -rn 's/(PAM)(.*)/\1\2(Ucred, Request_\1\2) <-chan \1\2/p' "$requests") } EOF diff --git a/src/nslcd_proto/util/enumerator@T.got b/src/nslcd_proto/util/enumerator@T.got deleted file mode 100644 index 5ce5cb5..0000000 --- a/src/nslcd_proto/util/enumerator@T.got +++ /dev/null @@ -1,45 +0,0 @@ -package util - -import "nslcd_proto" - -type <T>_List struct { - dat []nslcd_proto.<T> - i int -} - -var _ nslcd_proto.<T>_Enumerator = &<T>_List{} - -func New_<T>_List(ary []nslcd_proto.<T>) *<T>_List { - return &<T>_List{ary, 0} -} - -func (o *<T>_List) GetNext() (n *nslcd_proto.<T>, err error) { - if o.i < len(o.dat) { - n = &o.dat[o.i] - o.i++ - } - err = nil - return -} - -func (o *<T>_List) GenericGetNext() (n *interface{}, err error) { - a, err := o.GetNext() - if a != nil { - b := (interface{})(*a) - n = &b - } - return -} - -type <T>_Ø struct{} - -var _ nslcd_proto.<T>_Enumerator = <T>_Ø{} - -func (o <T>_Ø) GetNext() (*nslcd_proto.<T>, error) { - return nil, nil -} -func (o <T>_Ø) GenericGetNext() (*interface{}, error) { - return nil, nil -} - -// -*- Mode: Go -*- diff --git a/src/nslcd_proto/util/struct_null_backend.go.sh b/src/nslcd_proto/util/struct_null_backend.go.sh index 9d1c1b0..1714e9a 100755 --- a/src/nslcd_proto/util/struct_null_backend.go.sh +++ b/src/nslcd_proto/util/struct_null_backend.go.sh @@ -8,7 +8,7 @@ import p "nslcd_proto" type NullBackend struct{} -$(< "$interface" sed -rn 's/^\t([^(]+)\(Ucred, ([^)]+)\) (\S+)_Enumerator$/func (o NullBackend) \1(p.Ucred, p.\2) p.\3_Enumerator { return \3_Ø{} }/p') +$(< "$interface" sed -rn 's/^\t([^(]+)\(Ucred, ([^)]+)\) <-chan (\S+)$/func (o NullBackend) \1(p.Ucred, p.\2) <-chan p.\3 { r := make(chan p.\3); close(r); return r }/p') var _ p.Backend = NullBackend{} EOF |