winbind_nss_aix: use WBFLAG_FROM_NSS
authorBjörn Jacke <bj@sernet.de>
Sat, 22 Dec 2018 01:39:00 +0000 (02:39 +0100)
committerBjoern Jacke <bj@sernet.de>
Sat, 22 Dec 2018 02:11:14 +0000 (03:11 +0100)
Signed-off-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
nsswitch/winbind_nss_aix.c

index 459269c496c97717562329a6760eb034ad845c31..6ccd386d3ad62062ede9849ee6ffb53e8d6d1ebd 100644 (file)
@@ -269,16 +269,17 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem)
 /* take a group id and return a filled struct group */
 static struct group *wb_aix_getgrgid(gid_t gid)
 {
 /* take a group id and return a filled struct group */
 static struct group *wb_aix_getgrgid(gid_t gid)
 {
-       struct winbindd_response response;
-       struct winbindd_request request;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        struct group *grp;
        NSS_STATUS ret;
 
        logit("getgrgid %d\n", gid);
 
        struct group *grp;
        NSS_STATUS ret;
 
        logit("getgrgid %d\n", gid);
 
-       ZERO_STRUCT(response);
-       ZERO_STRUCT(request);
-
        request.data.gid = gid;
 
        ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
        request.data.gid = gid;
 
        ret = winbindd_request_response(NULL, WINBINDD_GETGRGID,
@@ -298,8 +299,12 @@ static struct group *wb_aix_getgrgid(gid_t gid)
 /* take a group name and return a filled struct group */
 static struct group *wb_aix_getgrnam(const char *name)
 {
 /* take a group name and return a filled struct group */
 static struct group *wb_aix_getgrnam(const char *name)
 {
-       struct winbindd_response response;
-       struct winbindd_request request;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        NSS_STATUS ret;
        struct group *grp;
 
        NSS_STATUS ret;
        struct group *grp;
 
@@ -309,9 +314,6 @@ static struct group *wb_aix_getgrnam(const char *name)
 
        logit("getgrnam '%s'\n", name);
 
 
        logit("getgrnam '%s'\n", name);
 
-       ZERO_STRUCT(response);
-       ZERO_STRUCT(request);
-
        STRCPY_RETNULL(request.data.groupname, name);
 
        ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
        STRCPY_RETNULL(request.data.groupname, name);
 
        ret = winbindd_request_response(NULL, WINBINDD_GETGRNAM,
@@ -346,8 +348,12 @@ static struct group *wb_aix_getgracct(void *id, int type)
    list of group id numbers to which the user belongs */
 static char *wb_aix_getgrset(char *user)
 {
    list of group id numbers to which the user belongs */
 static char *wb_aix_getgrset(char *user)
 {
-       struct winbindd_response response;
-       struct winbindd_request request;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        NSS_STATUS ret;
        int i, idx;
        char *tmpbuf;
        NSS_STATUS ret;
        int i, idx;
        char *tmpbuf;
@@ -365,9 +371,6 @@ static char *wb_aix_getgrset(char *user)
 
        logit("getgrset '%s'\n", r_user);
 
 
        logit("getgrset '%s'\n", r_user);
 
-        ZERO_STRUCT(response);
-        ZERO_STRUCT(request);
-
        STRCPY_RETNULL(request.data.username, r_user);
 
        if (*user == WB_AIX_ENCODED) {
        STRCPY_RETNULL(request.data.username, r_user);
 
        if (*user == WB_AIX_ENCODED) {
@@ -402,16 +405,17 @@ static char *wb_aix_getgrset(char *user)
 /* take a uid and return a filled struct passwd */
 static struct passwd *wb_aix_getpwuid(uid_t uid)
 {
 /* take a uid and return a filled struct passwd */
 static struct passwd *wb_aix_getpwuid(uid_t uid)
 {
-       struct winbindd_response response;
-       struct winbindd_request request;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        NSS_STATUS ret;
        struct passwd *pwd;
 
        logit("getpwuid '%d'\n", uid);
 
        NSS_STATUS ret;
        struct passwd *pwd;
 
        logit("getpwuid '%d'\n", uid);
 
-       ZERO_STRUCT(response);
-       ZERO_STRUCT(request);
-
        request.data.uid = uid;
 
        ret = winbindd_request_response(NULL, WINBINDD_GETPWUID,
        request.data.uid = uid;
 
        ret = winbindd_request_response(NULL, WINBINDD_GETPWUID,
@@ -432,8 +436,12 @@ static struct passwd *wb_aix_getpwuid(uid_t uid)
 /* take a username and return a filled struct passwd */
 static struct passwd *wb_aix_getpwnam(const char *name)
 {
 /* take a username and return a filled struct passwd */
 static struct passwd *wb_aix_getpwnam(const char *name)
 {
-       struct winbindd_response response;
-       struct winbindd_request request;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        NSS_STATUS ret;
        struct passwd *pwd;
 
        NSS_STATUS ret;
        struct passwd *pwd;
 
@@ -443,9 +451,6 @@ static struct passwd *wb_aix_getpwnam(const char *name)
 
        logit("getpwnam '%s'\n", name);
 
 
        logit("getpwnam '%s'\n", name);
 
-       ZERO_STRUCT(response);
-       ZERO_STRUCT(request);
-
        STRCPY_RETNULL(request.data.username, name);
 
        ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM,
        STRCPY_RETNULL(request.data.username, name);
 
        ret = winbindd_request_response(NULL, WINBINDD_GETPWNAM,
@@ -468,8 +473,12 @@ static struct passwd *wb_aix_getpwnam(const char *name)
 static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
 {
        NSS_STATUS ret;
 static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
 {
        NSS_STATUS ret;
-       struct winbindd_request request;
-       struct winbindd_response response;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        int len;
        char *s;
 
        int len;
        char *s;
 
@@ -479,9 +488,6 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
                return -1;
        }
 
                return -1;
        }
 
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
        ret = winbindd_request_response(NULL, WINBINDD_LIST_USERS,
                                        &request, &response);
        if (ret != 0) {
        ret = winbindd_request_response(NULL, WINBINDD_LIST_USERS,
                                        &request, &response);
        if (ret != 0) {
@@ -517,8 +523,12 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size)
 static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
 {
        NSS_STATUS ret;
 static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
 {
        NSS_STATUS ret;
-       struct winbindd_request request;
-       struct winbindd_response response;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
        int len;
        char *s;
 
        int len;
        char *s;
 
@@ -528,9 +538,6 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size)
                return -1;
        }
 
                return -1;
        }
 
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
        ret = winbindd_request_response(NULL, WINBINDD_LIST_GROUPS,
                                        &request, &response);
        if (ret != 0) {
        ret = winbindd_request_response(NULL, WINBINDD_LIST_GROUPS,
                                        &request, &response);
        if (ret != 0) {
@@ -625,6 +632,7 @@ static attrval_t pwd_to_sid(struct passwd *pwd)
        }
 
        request = (struct winbindd_request) {
        }
 
        request = (struct winbindd_request) {
+               .wb_flags = WBFLAG_FROM_NSS,
                .extra_data.data = buf,
                .extra_len = strlen(buf)+1,
        };
                .extra_data.data = buf,
                .extra_len = strlen(buf)+1,
        };
@@ -893,8 +901,12 @@ static int wb_aix_normalize(char *longname, char *shortname)
 static int wb_aix_authenticate(char *user, char *pass,
                               int *reenter, char **message)
 {
 static int wb_aix_authenticate(char *user, char *pass,
                               int *reenter, char **message)
 {
-       struct winbindd_request request;
-       struct winbindd_response response;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
         NSS_STATUS result;
        char *r_user = user;
 
         NSS_STATUS result;
        char *r_user = user;
 
@@ -904,9 +916,6 @@ static int wb_aix_authenticate(char *user, char *pass,
        *message = NULL;
 
        /* Send off request */
        *message = NULL;
 
        /* Send off request */
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
        if (*user == WB_AIX_ENCODED) {
                r_user = decode_user(r_user);
                if (!r_user) {
        if (*user == WB_AIX_ENCODED) {
                r_user = decode_user(r_user);
                if (!r_user) {
@@ -942,8 +951,12 @@ static int wb_aix_authenticate(char *user, char *pass,
 */
 static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **message)
 {
 */
 static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **message)
 {
-       struct winbindd_request request;
-       struct winbindd_response response;
+       struct winbindd_request request = {
+               .wb_flags = WBFLAG_FROM_NSS,
+       };
+       struct winbindd_response response = {
+               .length = 0,
+       };
         NSS_STATUS result;
        char *r_user = user;
 
         NSS_STATUS result;
        char *r_user = user;
 
@@ -960,9 +973,6 @@ static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **messag
        *message = NULL;
 
        /* Send off request */
        *message = NULL;
 
        /* Send off request */
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
        STRCPY_RET(request.data.chauthtok.user, r_user);
        STRCPY_RET(request.data.chauthtok.oldpass, oldpass);
        STRCPY_RET(request.data.chauthtok.newpass, newpass);
        STRCPY_RET(request.data.chauthtok.user, r_user);
        STRCPY_RET(request.data.chauthtok.oldpass, oldpass);
        STRCPY_RET(request.data.chauthtok.newpass, newpass);