From 955e8e2dc4bd7865f2b21139d61424a168e5a041 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 5 Sep 2015 00:43:54 -0600 Subject: The way nslcd_proto's GenericGetNext was designed, nil checks didn't work --- src/nshd/hackers_git/db_passwd.go | 9 +++++++-- src/nshd/hackers_git/db_shadow.go | 9 +++++++-- src/nslcd_proto/enumerator@T.got | 2 +- src/nslcd_proto/func_handlerequest.go.sh | 6 +++--- src/nslcd_proto/util/enumerator@T.got | 11 ++++++++--- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/nshd/hackers_git/db_passwd.go b/src/nshd/hackers_git/db_passwd.go index 8aad45e..2cfaccd 100644 --- a/src/nshd/hackers_git/db_passwd.go +++ b/src/nshd/hackers_git/db_passwd.go @@ -60,8 +60,13 @@ func (e *allPasswdEnumerator) GetNext() (*p.Passwd, error) { return nil, nil } -func (e *allPasswdEnumerator) GenericGetNext() (interface{}, error) { - return e.GetNext() +func (o *allPasswdEnumerator) GenericGetNext() (n *interface{}, err error) { + a, err := o.GetNext() + if a != nil { + b := (interface{})(*a) + n = &b + } + return } func (o *Hackers) newAllPasswdEnumerator() *allPasswdEnumerator { diff --git a/src/nshd/hackers_git/db_shadow.go b/src/nshd/hackers_git/db_shadow.go index 468f79d..97af6e9 100644 --- a/src/nshd/hackers_git/db_shadow.go +++ b/src/nshd/hackers_git/db_shadow.go @@ -59,8 +59,13 @@ func (e *allShadowEnumerator) GetNext() (*p.Shadow, error) { return nil, nil } -func (e *allShadowEnumerator) GenericGetNext() (interface{}, error) { - return e.GetNext() +func (o *allShadowEnumerator) GenericGetNext() (n *interface{}, err error) { + a, err := o.GetNext() + if a != nil { + b := (interface{})(*a) + n = &b + } + return } func (o *Hackers) newAllShadowEnumerator() *allShadowEnumerator { diff --git a/src/nslcd_proto/enumerator@T.got b/src/nslcd_proto/enumerator@T.got index 023c774..cad54fa 100644 --- a/src/nslcd_proto/enumerator@T.got +++ b/src/nslcd_proto/enumerator@T.got @@ -2,7 +2,7 @@ package nslcd_proto type _Enumerator interface { GetNext() (n *, err error) - GenericGetNext() (n interface{}, 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 8034594..45e0ed6 100755 --- a/src/nslcd_proto/func_handlerequest.go.sh +++ b/src/nslcd_proto/func_handlerequest.go.sh @@ -10,7 +10,7 @@ import ( ) type enumerator interface { - GenericGetNext() (n interface{}, err error) + GenericGetNext() (n *interface{}, err error) } func handleRequest(backend Backend, in io.Reader, out io.Writer, cred Ucred) { @@ -44,11 +44,11 @@ done < "$requests" write(out, NSLCD_VERSION) write(out, action) - var result interface{} + var result *interface{} var err error for result, err = res.GenericGetNext(); (result != nil) && (err == nil); result, err = res.GenericGetNext() { write(out, NSLCD_RESULT_BEGIN) - write(out, result) + write(out, *result) } if err != nil { panic(err) diff --git a/src/nslcd_proto/util/enumerator@T.got b/src/nslcd_proto/util/enumerator@T.got index e1dd2ae..5ce5cb5 100644 --- a/src/nslcd_proto/util/enumerator@T.got +++ b/src/nslcd_proto/util/enumerator@T.got @@ -22,8 +22,13 @@ func (o *_List) GetNext() (n *nslcd_proto., err error) { return } -func (o *_List) GenericGetNext() (n interface{}, err error) { - return o.GetNext() +func (o *_List) GenericGetNext() (n *interface{}, err error) { + a, err := o.GetNext() + if a != nil { + b := (interface{})(*a) + n = &b + } + return } type _Ø struct{} @@ -33,7 +38,7 @@ var _ nslcd_proto._Enumerator = _Ø{} func (o _Ø) GetNext() (*nslcd_proto., error) { return nil, nil } -func (o _Ø) GenericGetNext() (interface{}, error) { +func (o _Ø) GenericGetNext() (*interface{}, error) { return nil, nil } -- cgit v1.2.3-54-g00ecf