From 2f79b170c827f3c7f0fab05fba7d90d6a1b30949 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 31 Mar 2003 05:47:59 +0000 Subject: Placeholder for winbind aix client. (This used to be commit 872b2ba35bbe9f4312530368615e99808b3a7756) --- source3/nsswitch/winbind_nss_aix.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 source3/nsswitch/winbind_nss_aix.c (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c new file mode 100644 index 0000000000..e69de29bb2 -- cgit From 759179b1902d2847cce199e2efa1f830ec675427 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 2 Apr 2003 06:16:15 +0000 Subject: Merge of winbind nss library cleanup from HEAD. (This used to be commit a4b5f2c01bae049edc4f385cb0441bbde4fb443b) --- source3/nsswitch/winbind_nss_aix.c | 370 +++++++++++++++++++++++++++++++++++++ 1 file changed, 370 insertions(+) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index e69de29bb2..c06fbc7d4b 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -0,0 +1,370 @@ + +#include +#include +#include +#include + +#include "winbind_client.h" + +#define MAX_GETPWENT_USERS 250 +#define MAX_GETGRENT_USERS 250 + +BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize) +{ + char *s; + BOOL quoted; + size_t len=1; + + if (!ptr) return(False); + + s = *ptr; + + /* default to simple separators */ + if (!sep) sep = " \t\n\r"; + + /* find the first non sep char */ + while (*s && strchr(sep,*s)) s++; + + /* nothing left? */ + if (! *s) return(False); + + /* copy over the token */ + for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) { + if (*s == '\"') { + quoted = !quoted; + } else { + len++; + *buff++ = *s; + } + } + + *ptr = (*s) ? s+1 : s; + *buff = 0; + + return(True); +} + +static struct passwd *fill_pwent(struct winbindd_pw *pw) +{ + struct passwd *result; + + if (!(result = malloc(sizeof(struct passwd)))) { + return NULL; + } + memset(result, 0, sizeof(struct passwd)); + + /* User name */ + + if ((result->pw_name = malloc(strlen(pw->pw_name) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->pw_name, pw->pw_name); + + /* Password */ + + if ((result->pw_passwd = malloc(strlen(pw->pw_passwd) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->pw_passwd, pw->pw_passwd); + + /* [ug]id */ + + result->pw_uid = pw->pw_uid; + result->pw_gid = pw->pw_gid; + + /* GECOS */ + + if ((result->pw_gecos = malloc(strlen(pw->pw_gecos) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->pw_gecos, pw->pw_gecos); + + /* Home directory */ + + if ((result->pw_dir = malloc(strlen(pw->pw_dir) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->pw_dir, pw->pw_dir); + + /* Logon shell */ + + if ((result->pw_shell = malloc(strlen(pw->pw_shell) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->pw_shell, pw->pw_shell); + + return result; +} + +static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) +{ + fstring name; + int i; + char *tst; + struct group *result; + + if (!(result = malloc(sizeof(struct group)))) { + return NULL; + } + memset(result, 0, sizeof(struct group)); + + /* Group name */ + + if ((result->gr_name = malloc(strlen(gr->gr_name) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->gr_name, gr->gr_name); + + /* Password */ + + if ((result->gr_passwd = malloc(strlen(gr->gr_passwd) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy(result->gr_passwd, gr->gr_passwd); + + /* gid */ + + result->gr_gid = gr->gr_gid; + + /* Group membership */ + + if ((gr->num_gr_mem < 0) || !gr_mem) { + gr->num_gr_mem = 0; + } + + if (gr->num_gr_mem == 0) { + + /* Group is empty */ + + *(result->gr_mem) = NULL; + return result; + } + + if ((tst = malloc(((gr->num_gr_mem + 1) * sizeof(char *)))) == NULL) { + + /* Out of memory */ + + return NULL; + } + result->gr_mem = (char **)tst; + + /* Start looking at extra data */ + + i = 0; + + while(next_token((char **)&gr_mem, name, ",", sizeof(fstring))) { + + /* Allocate space for member */ + + if (((result->gr_mem)[i] = + malloc(strlen(name) + 1)) == NULL) { + + /* Out of memory */ + + return NULL; + } + + strcpy((result->gr_mem)[i], name); + i++; + } + + /* Terminate list */ + + (result->gr_mem)[i] = NULL; + + return result; +} + + + +static struct group * +wb_aix_getgrgid (gid_t gid) +{ +/* take a group id and return a filled struct group */ + + NSS_STATUS ret; + struct winbindd_response response; + struct winbindd_request request; + + ZERO_STRUCT(response); + ZERO_STRUCT(request); + + request.data.gid = gid; + + ret = winbindd_request(WINBINDD_GETGRGID, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { + return fill_grent(&response.data.gr, response.extra_data); + } + return NULL; +} + +static struct group * +wb_aix_getgrnam (const char *name) +{ +/* take a group name and return a filled struct group */ + + NSS_STATUS ret; + struct winbindd_response response; + struct winbindd_request request; + + ZERO_STRUCT(response); + ZERO_STRUCT(request); + + strncpy(request.data.groupname, name, + sizeof(request.data.groupname)); + request.data.groupname + [sizeof(request.data.groupname) - 1] = '\0'; + + ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { + return fill_grent(&response.data.gr, response.extra_data); + } + return NULL; +} + +static char * +wb_aix_getgrset (const char *user) +{ +/* take a username and return a string containing a comma-separated list of + group id numbers to which the user belongs */ + + NSS_STATUS ret; + struct winbindd_response response; + struct winbindd_request request; + + char *tmpbuf, *result; + int i, idx = 0; + + strncpy(request.data.username, user, + sizeof(request.data.username) - 1); + request.data.username + [sizeof(request.data.username) - 1] = '\0'; + + ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { + int num_gids = response.data.num_entries; + gid_t *gid_list = (gid_t *)response.extra_data; + + /* allocate a space large enough to contruct the string */ + if (!(tmpbuf = malloc(num_gids*12))) { + return NULL; + } + idx += sprintf(tmpbuf, "%d", gid_list[0]); + for (i = 1; i < num_gids; i++) { + tmpbuf[idx++] = ','; + idx += sprintf(tmpbuf+idx, "%d", gid_list[i]); + } + tmpbuf[idx] = '\0'; + if (!(result = malloc(idx+1))) { + /* allocate a string the right size to return, but + if that fails may as well return our working buffer + because it contains the same thing */ + return tmpbuf; + } + strcpy(result, tmpbuf); + free(tmpbuf); + return result; + } + return NULL; +} + +static struct passwd * +wb_aix_getpwuid (uid_t uid) +{ +/* take a uid and return a filled struct passwd */ + + NSS_STATUS ret; + struct winbindd_response response; + struct winbindd_request request; + + ZERO_STRUCT(response); + ZERO_STRUCT(request); + + request.data.uid = uid; + + ret = winbindd_request(WINBINDD_GETPWUID, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { + return fill_pwent(&response.data.pw); + } + return NULL; +} + +static struct passwd * +wb_aix_getpwnam (const char *name) +{ +/* take a username and return a filled struct passwd */ + + NSS_STATUS ret; + struct winbindd_response response; + struct winbindd_request request; + + ZERO_STRUCT(response); + ZERO_STRUCT(request); + + strncpy(request.data.username, name, + sizeof(request.data.username) - 1); + request.data.username + [sizeof(request.data.username) - 1] = '\0'; + + ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { + return fill_pwent(&response.data.pw); + } + return NULL; +} + +int +wb_aix_init (struct secmethod_table *methods) +{ + memset(methods, 0, sizeof(*methods)); + + /* identification methods */ + + methods->method_getgrgid = wb_aix_getgrgid; + methods->method_getgrnam = wb_aix_getgrnam; + methods->method_getgrset = wb_aix_getgrset; + methods->method_getpwnam = wb_aix_getpwnam; + methods->method_getpwuid = wb_aix_getpwuid; + + /* support methods + methods->method_open = wb_aix_open; + methods->method_close = wb_aix_close; + */ + + return AUTH_SUCCESS; +} + + -- cgit From 448fbda49693f2575ba9683bd1fee3d535ed5036 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 14 Apr 2003 03:49:45 +0000 Subject: Syncup new HEAD version. (This used to be commit 396bcf0cf6dfc7a36be0c4e774386b266439c3af) --- source3/nsswitch/winbind_nss_aix.c | 297 +++++++++++++++++++++---------------- 1 file changed, 169 insertions(+), 128 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index c06fbc7d4b..ba5332bf98 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -1,3 +1,27 @@ +/* + Unix SMB/CIFS implementation. + + AIX loadable authentication mmodule, providing identification + routines against Samba winbind/Windows NT Domain + + Copyright (C) Tim Potter 2003 + Copyright (C) Steve Roylance 2003 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ #include #include @@ -8,70 +32,28 @@ #define MAX_GETPWENT_USERS 250 #define MAX_GETGRENT_USERS 250 - -BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize) -{ - char *s; - BOOL quoted; - size_t len=1; - - if (!ptr) return(False); - - s = *ptr; - - /* default to simple separators */ - if (!sep) sep = " \t\n\r"; - - /* find the first non sep char */ - while (*s && strchr(sep,*s)) s++; - - /* nothing left? */ - if (! *s) return(False); - - /* copy over the token */ - for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) { - if (*s == '\"') { - quoted = !quoted; - } else { - len++; - *buff++ = *s; - } - } - - *ptr = (*s) ? s+1 : s; - *buff = 0; - - return(True); -} +/* #define WB_AIX_DEBUG */ static struct passwd *fill_pwent(struct winbindd_pw *pw) { struct passwd *result; - if (!(result = malloc(sizeof(struct passwd)))) { - return NULL; - } - memset(result, 0, sizeof(struct passwd)); + if (!(result = malloc(sizeof(struct passwd)))) + goto out; + + ZERO_STRUCTP(result); /* User name */ - if ((result->pw_name = malloc(strlen(pw->pw_name) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((result->pw_name = malloc(strlen(pw->pw_name) + 1)) == NULL) + goto out; strcpy(result->pw_name, pw->pw_name); /* Password */ - if ((result->pw_passwd = malloc(strlen(pw->pw_passwd) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((result->pw_passwd = malloc(strlen(pw->pw_passwd) + 1)) == NULL) + goto out; strcpy(result->pw_passwd, pw->pw_passwd); @@ -82,38 +64,75 @@ static struct passwd *fill_pwent(struct winbindd_pw *pw) /* GECOS */ - if ((result->pw_gecos = malloc(strlen(pw->pw_gecos) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((result->pw_gecos = malloc(strlen(pw->pw_gecos) + 1)) == NULL) + goto out; strcpy(result->pw_gecos, pw->pw_gecos); /* Home directory */ - if ((result->pw_dir = malloc(strlen(pw->pw_dir) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((result->pw_dir = malloc(strlen(pw->pw_dir) + 1)) == NULL) + goto out; strcpy(result->pw_dir, pw->pw_dir); /* Logon shell */ - if ((result->pw_shell = malloc(strlen(pw->pw_shell) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((result->pw_shell = malloc(strlen(pw->pw_shell) + 1)) == NULL) + goto out; strcpy(result->pw_shell, pw->pw_shell); - +#ifdef WB_AIX_DEBUG + printf("wb_aix - returning filled pwent %s, %d\n", result->pw_name, result->pw_uid); +#endif return result; + + /* A memory allocation failed, undo succesfull allocations and + return NULL */ + +out: + SAFE_FREE(result->pw_dir); + SAFE_FREE(result->pw_gecos); + SAFE_FREE(result->pw_passwd); + SAFE_FREE(result->pw_name); + SAFE_FREE(result); + + return NULL; +} + +static BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize) +{ + char *s; + BOOL quoted; + size_t len=1; + + if (!ptr) return(False); + + s = *ptr; + + /* default to simple separators */ + if (!sep) sep = " \t\n\r"; + + /* find the first non sep char */ + while (*s && strchr(sep,*s)) s++; + + /* nothing left? */ + if (! *s) return(False); + + /* copy over the token */ + for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) { + if (*s == '\"') { + quoted = !quoted; + } else { + len++; + *buff++ = *s; + } + } + + *ptr = (*s) ? s+1 : s; + *buff = 0; + + return(True); } static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) @@ -123,30 +142,22 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) char *tst; struct group *result; - if (!(result = malloc(sizeof(struct group)))) { - return NULL; - } - memset(result, 0, sizeof(struct group)); + if (!(result = malloc(sizeof(struct group)))) + goto out; - /* Group name */ - - if ((result->gr_name = malloc(strlen(gr->gr_name) + 1)) == NULL) { + ZERO_STRUCTP(result); - /* Out of memory */ + /* Group name */ - return NULL; - } + if ((result->gr_name = malloc(strlen(gr->gr_name) + 1)) == NULL) + goto out; strcpy(result->gr_name, gr->gr_name); /* Password */ - if ((result->gr_passwd = malloc(strlen(gr->gr_passwd) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((result->gr_passwd = malloc(strlen(gr->gr_passwd) + 1)) == NULL) + goto out; strcpy(result->gr_passwd, gr->gr_passwd); @@ -168,12 +179,9 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) return result; } - if ((tst = malloc(((gr->num_gr_mem + 1) * sizeof(char *)))) == NULL) { - - /* Out of memory */ - - return NULL; - } + if ((tst = malloc(((gr->num_gr_mem + 1) * sizeof(char *)))) == NULL) + goto out; + result->gr_mem = (char **)tst; /* Start looking at extra data */ @@ -186,10 +194,10 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) if (((result->gr_mem)[i] = malloc(strlen(name) + 1)) == NULL) { - - /* Out of memory */ - - return NULL; + for ( i -= 1; i >= 0; i--) + SAFE_FREE((result->gr_mem)[i]); + goto out; + } strcpy((result->gr_mem)[i], name); @@ -200,7 +208,21 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) (result->gr_mem)[i] = NULL; +#ifdef WB_AIX_DEBUG + printf("wb_aix - returning filled grent %s, %d\n", result->gr_name, result->gr_gid); +#endif return result; + + /* A memory allocation failed, undo succesfull allocations and + return NULL */ + +out: + SAFE_FREE(tst); + SAFE_FREE(result->gr_passwd); + SAFE_FREE(result->gr_name); + SAFE_FREE(result); + + return NULL; } @@ -210,20 +232,25 @@ wb_aix_getgrgid (gid_t gid) { /* take a group id and return a filled struct group */ - NSS_STATUS ret; struct winbindd_response response; struct winbindd_request request; ZERO_STRUCT(response); ZERO_STRUCT(request); +#ifdef WB_AIX_DEBUG + printf("wb_aix - getgrid for %d\n", gid); +#endif request.data.gid = gid; - ret = winbindd_request(WINBINDD_GETGRGID, &request, &response); - - if (ret == NSS_STATUS_SUCCESS) { + if (winbindd_request(WINBINDD_GETGRGID, &request, &response) + == NSS_STATUS_SUCCESS) { +#ifdef WB_AIX_DEBUG + printf("wb_aix - returned from winbind_request\n"); +#endif return fill_grent(&response.data.gr, response.extra_data); } + return NULL; } @@ -232,23 +259,29 @@ wb_aix_getgrnam (const char *name) { /* take a group name and return a filled struct group */ - NSS_STATUS ret; struct winbindd_response response; struct winbindd_request request; ZERO_STRUCT(response); ZERO_STRUCT(request); +#ifdef WB_AIX_DEBUG + printf("wb_aix - getgrnam for %s\n", name); +#endif + strncpy(request.data.groupname, name, sizeof(request.data.groupname)); request.data.groupname [sizeof(request.data.groupname) - 1] = '\0'; - ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response); - if (ret == NSS_STATUS_SUCCESS) { + if (winbindd_request(WINBINDD_GETGRNAM, &request, &response) + == NSS_STATUS_SUCCESS) { +#ifdef WB_AIX_DEBUG + printf("wb_aix - returned from winbind_request\n"); +#endif return fill_grent(&response.data.gr, response.extra_data); - } + } return NULL; } @@ -258,23 +291,28 @@ wb_aix_getgrset (const char *user) /* take a username and return a string containing a comma-separated list of group id numbers to which the user belongs */ - NSS_STATUS ret; struct winbindd_response response; struct winbindd_request request; char *tmpbuf, *result; int i, idx = 0; - + +#ifdef WB_AIX_DEBUG + printf("wb_aix - getgrset for %s\n", user); +#endif strncpy(request.data.username, user, sizeof(request.data.username) - 1); request.data.username [sizeof(request.data.username) - 1] = '\0'; - ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response); - if (ret == NSS_STATUS_SUCCESS) { + if (winbindd_request(WINBINDD_GETGROUPS, &request, &response) + == NSS_STATUS_SUCCESS) { int num_gids = response.data.num_entries; gid_t *gid_list = (gid_t *)response.extra_data; +#ifdef WB_AIX_DEBUG + printf("wb_aix - returned from winbind_request\n"); +#endif /* allocate a space large enough to contruct the string */ if (!(tmpbuf = malloc(num_gids*12))) { @@ -293,7 +331,7 @@ wb_aix_getgrset (const char *user) return tmpbuf; } strcpy(result, tmpbuf); - free(tmpbuf); + SAFE_FREE(tmpbuf); return result; } return NULL; @@ -304,18 +342,23 @@ wb_aix_getpwuid (uid_t uid) { /* take a uid and return a filled struct passwd */ - NSS_STATUS ret; struct winbindd_response response; struct winbindd_request request; ZERO_STRUCT(response); ZERO_STRUCT(request); + +#ifdef WB_AIX_DEBUG + printf("wb_aix - getpwid for %d\n", uid); +#endif request.data.uid = uid; - - ret = winbindd_request(WINBINDD_GETPWUID, &request, &response); - - if (ret == NSS_STATUS_SUCCESS) { + + if (winbindd_request(WINBINDD_GETPWUID, &request, &response) + == NSS_STATUS_SUCCESS) { +#ifdef WB_AIX_DEBUG + printf("wb_aix - returned from winbind_request\n"); +#endif return fill_pwent(&response.data.pw); } return NULL; @@ -326,22 +369,26 @@ wb_aix_getpwnam (const char *name) { /* take a username and return a filled struct passwd */ - NSS_STATUS ret; struct winbindd_response response; struct winbindd_request request; ZERO_STRUCT(response); ZERO_STRUCT(request); - +#ifdef WB_AIX_DEBUG + printf("wb_aix - getpwnam for %s\n", name); +#endif strncpy(request.data.username, name, sizeof(request.data.username) - 1); request.data.username [sizeof(request.data.username) - 1] = '\0'; - ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); - if (ret == NSS_STATUS_SUCCESS) { - return fill_pwent(&response.data.pw); + if (winbindd_request(WINBINDD_GETPWNAM, &request, &response) + == NSS_STATUS_SUCCESS) { +#ifdef WB_AIX_DEBUG + printf("wb_aix - returned from winbind_request\n"); +#endif + return fill_pwent(&response.data.pw); } return NULL; } @@ -351,20 +398,14 @@ wb_aix_init (struct secmethod_table *methods) { memset(methods, 0, sizeof(*methods)); - /* identification methods */ + /* identification methods, this is the minimum requried for a + working module */ methods->method_getgrgid = wb_aix_getgrgid; methods->method_getgrnam = wb_aix_getgrnam; methods->method_getgrset = wb_aix_getgrset; methods->method_getpwnam = wb_aix_getpwnam; methods->method_getpwuid = wb_aix_getpwuid; - - /* support methods - methods->method_open = wb_aix_open; - methods->method_close = wb_aix_close; - */ - + return AUTH_SUCCESS; } - - -- cgit From 2927ab13da5ccc0ebe25b30c25989c87c76b924e Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 19 May 2003 00:42:28 +0000 Subject: Updates for AIX winbind client from Stephen Roylance. (This used to be commit 3983f3a1f30deae8d66c1f4c099bb56eabe3586b) --- source3/nsswitch/winbind_nss_aix.c | 120 ++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 62 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index ba5332bf98..8b5bc7a50c 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. - AIX loadable authentication mmodule, providing identification + AIX loadable authentication module, providing identification routines against Samba winbind/Windows NT Domain Copyright (C) Tim Potter 2003 @@ -32,7 +32,6 @@ #define MAX_GETPWENT_USERS 250 #define MAX_GETGRENT_USERS 250 -/* #define WB_AIX_DEBUG */ static struct passwd *fill_pwent(struct winbindd_pw *pw) { @@ -82,15 +81,14 @@ static struct passwd *fill_pwent(struct winbindd_pw *pw) goto out; strcpy(result->pw_shell, pw->pw_shell); -#ifdef WB_AIX_DEBUG - printf("wb_aix - returning filled pwent %s, %d\n", result->pw_name, result->pw_uid); -#endif + return result; /* A memory allocation failed, undo succesfull allocations and return NULL */ out: + errno = ENOMEM; SAFE_FREE(result->pw_dir); SAFE_FREE(result->pw_gecos); SAFE_FREE(result->pw_passwd); @@ -205,18 +203,15 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) } /* Terminate list */ - (result->gr_mem)[i] = NULL; -#ifdef WB_AIX_DEBUG - printf("wb_aix - returning filled grent %s, %d\n", result->gr_name, result->gr_gid); -#endif return result; /* A memory allocation failed, undo succesfull allocations and return NULL */ out: + errno = ENOMEM; SAFE_FREE(tst); SAFE_FREE(result->gr_passwd); SAFE_FREE(result->gr_name); @@ -234,24 +229,24 @@ wb_aix_getgrgid (gid_t gid) struct winbindd_response response; struct winbindd_request request; + NSS_STATUS ret; ZERO_STRUCT(response); ZERO_STRUCT(request); -#ifdef WB_AIX_DEBUG - printf("wb_aix - getgrid for %d\n", gid); -#endif request.data.gid = gid; - if (winbindd_request(WINBINDD_GETGRGID, &request, &response) - == NSS_STATUS_SUCCESS) { -#ifdef WB_AIX_DEBUG - printf("wb_aix - returned from winbind_request\n"); -#endif + ret = winbindd_request(WINBINDD_GETGRGID, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { return fill_grent(&response.data.gr, response.extra_data); + } else if (ret == NSS_STATUS_NOTFOUND) { + errno = ENOENT; + } else { + errno = EIO; } - return NULL; + return NULL; } static struct group * @@ -261,28 +256,27 @@ wb_aix_getgrnam (const char *name) struct winbindd_response response; struct winbindd_request request; + NSS_STATUS ret; ZERO_STRUCT(response); ZERO_STRUCT(request); -#ifdef WB_AIX_DEBUG - printf("wb_aix - getgrnam for %s\n", name); -#endif - strncpy(request.data.groupname, name, sizeof(request.data.groupname)); request.data.groupname [sizeof(request.data.groupname) - 1] = '\0'; - - if (winbindd_request(WINBINDD_GETGRNAM, &request, &response) - == NSS_STATUS_SUCCESS) { -#ifdef WB_AIX_DEBUG - printf("wb_aix - returned from winbind_request\n"); -#endif + ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response); + + if (ret == NSS_STATUS_SUCCESS) { return fill_grent(&response.data.gr, response.extra_data); - } - return NULL; + } else if (ret == NSS_STATUS_NOTFOUND) { + errno = ENOENT; + } else { + errno = EIO; + } + + return NULL; } static char * @@ -293,29 +287,25 @@ wb_aix_getgrset (const char *user) struct winbindd_response response; struct winbindd_request request; - - char *tmpbuf, *result; - int i, idx = 0; + NSS_STATUS ret; -#ifdef WB_AIX_DEBUG - printf("wb_aix - getgrset for %s\n", user); -#endif strncpy(request.data.username, user, sizeof(request.data.username) - 1); request.data.username [sizeof(request.data.username) - 1] = '\0'; - - if (winbindd_request(WINBINDD_GETGROUPS, &request, &response) - == NSS_STATUS_SUCCESS) { + ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response); + if (ret == NSS_STATUS_SUCCESS ) { + int i, idx = 0; + char *tmpbuf, *result; + int num_gids = response.data.num_entries; gid_t *gid_list = (gid_t *)response.extra_data; -#ifdef WB_AIX_DEBUG - printf("wb_aix - returned from winbind_request\n"); -#endif + /* allocate a space large enough to contruct the string */ if (!(tmpbuf = malloc(num_gids*12))) { + errno = ENOMEM; return NULL; } idx += sprintf(tmpbuf, "%d", gid_list[0]); @@ -333,7 +323,12 @@ wb_aix_getgrset (const char *user) strcpy(result, tmpbuf); SAFE_FREE(tmpbuf); return result; + } else if (ret == NSS_STATUS_NOTFOUND) { + errno = ENOENT; + } else { + errno = EIO; } + return NULL; } @@ -344,24 +339,24 @@ wb_aix_getpwuid (uid_t uid) struct winbindd_response response; struct winbindd_request request; + NSS_STATUS ret; ZERO_STRUCT(response); ZERO_STRUCT(request); - -#ifdef WB_AIX_DEBUG - printf("wb_aix - getpwid for %d\n", uid); -#endif request.data.uid = uid; + + ret = winbindd_request(WINBINDD_GETPWUID, &request, &response); - if (winbindd_request(WINBINDD_GETPWUID, &request, &response) - == NSS_STATUS_SUCCESS) { -#ifdef WB_AIX_DEBUG - printf("wb_aix - returned from winbind_request\n"); -#endif + if (ret == NSS_STATUS_SUCCESS) { return fill_pwent(&response.data.pw); + } else if (ret == NSS_STATUS_NOTFOUND ) { + errno = ENOENT; + } else { + errno = EIO; } - return NULL; + + return NULL; } static struct passwd * @@ -371,25 +366,26 @@ wb_aix_getpwnam (const char *name) struct winbindd_response response; struct winbindd_request request; + NSS_STATUS ret; ZERO_STRUCT(response); ZERO_STRUCT(request); -#ifdef WB_AIX_DEBUG - printf("wb_aix - getpwnam for %s\n", name); -#endif + strncpy(request.data.username, name, sizeof(request.data.username) - 1); request.data.username [sizeof(request.data.username) - 1] = '\0'; - - if (winbindd_request(WINBINDD_GETPWNAM, &request, &response) - == NSS_STATUS_SUCCESS) { -#ifdef WB_AIX_DEBUG - printf("wb_aix - returned from winbind_request\n"); -#endif - return fill_pwent(&response.data.pw); + ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); + + if (ret == NSS_STATUS_SUCCESS ) { + return fill_pwent(&response.data.pw); + } else if (ret == NSS_STATUS_NOTFOUND) { + errno = ENOENT; + } else { + errno = EIO; } + return NULL; } -- cgit From 7c6c6b66280d717a8c8efd9fa2a7aa39240b151f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Oct 2003 12:18:08 +0000 Subject: fixed a number of bugs and memory leaks in the AIX winbind shim (This used to be commit f0a0771c02404c91cd64961f85622022a4e56b2f) --- source3/nsswitch/winbind_nss_aix.c | 480 ++++++++++++++++++------------------- 1 file changed, 231 insertions(+), 249 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 8b5bc7a50c..3d2f01b93c 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -6,6 +6,7 @@ Copyright (C) Tim Potter 2003 Copyright (C) Steve Roylance 2003 + Copyright (C) Andrew Tridgell 2003 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -23,182 +24,188 @@ Boston, MA 02111-1307, USA. */ +/* + see + http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/kernextc/sec_load_mod.htm + for information in the interface that this module implements +*/ + #include #include #include #include +#include #include "winbind_client.h" -#define MAX_GETPWENT_USERS 250 -#define MAX_GETGRENT_USERS 250 - -static struct passwd *fill_pwent(struct winbindd_pw *pw) -{ - struct passwd *result; - - if (!(result = malloc(sizeof(struct passwd)))) - goto out; - - ZERO_STRUCTP(result); - - /* User name */ +/* + the documentation doesn't say so, but experimentation shows that all + of the functions need to return static data, and the area can be + freed only when the same function is called again, or the close + method is called on the module. Note that this matches the standard + behaviour of functions like getpwnam(). + + The most puzzling thing about this AIX interface is that it seems to + offer no way of providing a user or group enumeration method. You + can find out any amount of detail about a user or group once you + know the name, but you can't obtain a list of those names. If anyone + does find out how to do this then please let me know (yes, I should + be able to find out as I work for IBM, and this is an IBM interface, + but finding the right person to ask is a mammoth task!) + + tridge@samba.org October 2003 +*/ - if ((result->pw_name = malloc(strlen(pw->pw_name) + 1)) == NULL) - goto out; - - strcpy(result->pw_name, pw->pw_name); - /* Password */ +/* + each function uses one of the following lists of memory, declared + static in each backend method. This allows the function to destroy + the memory when that backend is called next time +*/ +struct mem_list { + struct mem_list *next, *prev; + void *p; +}; - if ((result->pw_passwd = malloc(strlen(pw->pw_passwd) + 1)) == NULL) - goto out; - - strcpy(result->pw_passwd, pw->pw_passwd); - - /* [ug]id */ - result->pw_uid = pw->pw_uid; - result->pw_gid = pw->pw_gid; +/* allocate some memory on a mem_list */ +static void *list_alloc(struct mem_list **list, size_t size) +{ + struct mem_list *m; + m = malloc(sizeof(*m)); + if (!m) { + errno = ENOMEM; + return NULL; + } + m->p = malloc(size); + if (!m->p) { + errno = ENOMEM; + free(m); + return NULL; + } + m->next = *list; + m->prev = NULL; + if (*list) { + (*list)->prev = m; + } + (*list) = m; + return m->p; +} - /* GECOS */ +/* duplicate a string using list_alloc() */ +static char *list_strdup(struct mem_list **list, const char *s) +{ + char *ret = list_alloc(list, strlen(s)+1); + if (!ret) return NULL; + strcpy(ret, s); + return ret; +} - if ((result->pw_gecos = malloc(strlen(pw->pw_gecos) + 1)) == NULL) - goto out; +/* destroy a mem_list */ +static void list_destory(struct mem_list **list) +{ + struct mem_list *m, *next; + for (m=*list; m; m=next) { + next = m->next; + free(m->p); + free(m); + } + (*list) = NULL; +} - strcpy(result->pw_gecos, pw->pw_gecos); - - /* Home directory */ - - if ((result->pw_dir = malloc(strlen(pw->pw_dir) + 1)) == NULL) - goto out; - strcpy(result->pw_dir, pw->pw_dir); +#define HANDLE_ERRORS(ret) do { \ + if ((ret) == NSS_STATUS_NOTFOUND) { \ + errno = ENOENT; \ + return NULL; \ + } else if ((ret) != NSS_STATUS_SUCCESS) { \ + errno = EIO; \ + return NULL; \ + } \ +} while (0) - /* Logon shell */ - - if ((result->pw_shell = malloc(strlen(pw->pw_shell) + 1)) == NULL) - goto out; - - strcpy(result->pw_shell, pw->pw_shell); - - return result; - - /* A memory allocation failed, undo succesfull allocations and - return NULL */ - -out: - errno = ENOMEM; - SAFE_FREE(result->pw_dir); - SAFE_FREE(result->pw_gecos); - SAFE_FREE(result->pw_passwd); - SAFE_FREE(result->pw_name); - SAFE_FREE(result); - - return NULL; -} - -static BOOL next_token(char **ptr,char *buff,char *sep, size_t bufsize) +/* + fill a struct passwd from a winbindd_pw struct, using memory from a mem_list +*/ +static struct passwd *fill_pwent(struct mem_list **list, struct winbindd_pw *pw) { - char *s; - BOOL quoted; - size_t len=1; + struct passwd *result; - if (!ptr) return(False); + if (!(result = list_alloc(list, sizeof(struct passwd)))) { + return NULL; + } - s = *ptr; + ZERO_STRUCTP(result); - /* default to simple separators */ - if (!sep) sep = " \t\n\r"; + result->pw_uid = pw->pw_uid; + result->pw_gid = pw->pw_gid; - /* find the first non sep char */ - while (*s && strchr(sep,*s)) s++; - - /* nothing left? */ - if (! *s) return(False); - - /* copy over the token */ - for (quoted = False; len < bufsize && *s && (quoted || !strchr(sep,*s)); s++) { - if (*s == '\"') { - quoted = !quoted; - } else { - len++; - *buff++ = *s; - } + /* strings */ + if ((result->pw_name = list_strdup(list, pw->pw_name)) == NULL || + (result->pw_passwd = list_strdup(list, pw->pw_passwd)) == NULL || + (result->pw_gecos = list_strdup(list, pw->pw_gecos)) == NULL || + (result->pw_dir = list_strdup(list, pw->pw_dir)) == NULL || + (result->pw_shell = list_strdup(list, pw->pw_shell)) == NULL) { + return NULL; } - *ptr = (*s) ? s+1 : s; - *buff = 0; - - return(True); + return result; } -static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) + +/* + fill a struct group from a winbindd_pw struct, using memory from a mem_list +*/ +static struct group *fill_grent(struct mem_list **list, struct winbindd_gr *gr, char *gr_mem) { - fstring name; int i; char *tst; struct group *result; - - if (!(result = malloc(sizeof(struct group)))) - goto out; + char *name, *p; - ZERO_STRUCTP(result); - - /* Group name */ - - if ((result->gr_name = malloc(strlen(gr->gr_name) + 1)) == NULL) - goto out; - - strcpy(result->gr_name, gr->gr_name); - - /* Password */ - - if ((result->gr_passwd = malloc(strlen(gr->gr_passwd) + 1)) == NULL) - goto out; - - strcpy(result->gr_passwd, gr->gr_passwd); + if (!(result = list_alloc(list, sizeof(struct group)))) { + return NULL; + } - /* gid */ + ZERO_STRUCTP(result); result->gr_gid = gr->gr_gid; - /* Group membership */ + /* Group name */ + if ((result->gr_name = list_strdup(list, gr->gr_name)) == NULL || + (result->gr_passwd = list_strdup(list, gr->gr_passwd)) == NULL) { + return NULL; + } + /* Group membership */ if ((gr->num_gr_mem < 0) || !gr_mem) { gr->num_gr_mem = 0; } if (gr->num_gr_mem == 0) { - - /* Group is empty */ - - *(result->gr_mem) = NULL; + /* Group is empty */ return result; } - if ((tst = malloc(((gr->num_gr_mem + 1) * sizeof(char *)))) == NULL) - goto out; + tst = list_alloc(list, (gr->num_gr_mem + 1) * sizeof(char *)); + if (!tst) { + return NULL; + } result->gr_mem = (char **)tst; /* Start looking at extra data */ - - i = 0; - - while(next_token((char **)&gr_mem, name, ",", sizeof(fstring))) { - - /* Allocate space for member */ - - if (((result->gr_mem)[i] = - malloc(strlen(name) + 1)) == NULL) { - for ( i -= 1; i >= 0; i--) - SAFE_FREE((result->gr_mem)[i]); - goto out; - - } - - strcpy((result->gr_mem)[i], name); + i=0; + for (name = strtok_r(gr_mem, ",", &p); + name; + name = strtok_r(NULL, ",", &p)) { + if (i >= gr->num_gr_mem) { + return NULL; + } + (result->gr_mem)[i] = list_strdup(list, name); + if ((result->gr_mem)[i] == NULL) { + return NULL; + } i++; } @@ -206,140 +213,123 @@ static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) (result->gr_mem)[i] = NULL; return result; - - /* A memory allocation failed, undo succesfull allocations and - return NULL */ - -out: - errno = ENOMEM; - SAFE_FREE(tst); - SAFE_FREE(result->gr_passwd); - SAFE_FREE(result->gr_name); - SAFE_FREE(result); - - return NULL; } -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) { -/* take a group id and return a filled struct group */ - + static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; + struct group *grp; NSS_STATUS ret; + list_destory(&list); + ZERO_STRUCT(response); ZERO_STRUCT(request); request.data.gid = gid; ret = winbindd_request(WINBINDD_GETGRGID, &request, &response); - - if (ret == NSS_STATUS_SUCCESS) { - return fill_grent(&response.data.gr, response.extra_data); - } else if (ret == NSS_STATUS_NOTFOUND) { - errno = ENOENT; - } else { - errno = EIO; - } - - return NULL; + + HANDLE_ERRORS(ret); + + grp = fill_grent(&list, &response.data.gr, response.extra_data); + + free_response(&response); + + return grp; } -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) +{ + static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; - + struct group *grp; + + list_destory(&list); + ZERO_STRUCT(response); ZERO_STRUCT(request); - strncpy(request.data.groupname, name, - sizeof(request.data.groupname)); - request.data.groupname - [sizeof(request.data.groupname) - 1] = '\0'; + if (strlen(name)+1 > sizeof(request.data.groupname)) { + errno = EINVAL; + return NULL; + } + strcpy(request.data.groupname, name); ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response); - if (ret == NSS_STATUS_SUCCESS) { - return fill_grent(&response.data.gr, response.extra_data); - } else if (ret == NSS_STATUS_NOTFOUND) { - errno = ENOENT; - } else { - errno = EIO; - } - - return NULL; + HANDLE_ERRORS(ret); + + grp = fill_grent(&list, &response.data.gr, response.extra_data); + + free_response(&response); + + return grp; } -static char * -wb_aix_getgrset (const char *user) + +/* take a username and return a string containing a comma-separated + list of group id numbers to which the user belongs */ +static char *wb_aix_getgrset(char *user) { -/* take a username and return a string containing a comma-separated list of - group id numbers to which the user belongs */ - + static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; + int i, idx; + char *tmpbuf; + int num_gids; + gid_t *gid_list; - strncpy(request.data.username, user, - sizeof(request.data.username) - 1); - request.data.username - [sizeof(request.data.username) - 1] = '\0'; + list_destory(&list); + + if (strlen(user)+1 > sizeof(request.data.username)) { + errno = EINVAL; + return NULL; + } + strcpy(request.data.username, user); ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response); - if (ret == NSS_STATUS_SUCCESS ) { - int i, idx = 0; - char *tmpbuf, *result; - - int num_gids = response.data.num_entries; - gid_t *gid_list = (gid_t *)response.extra_data; + HANDLE_ERRORS(ret); + + num_gids = response.data.num_entries; + gid_list = (gid_t *)response.extra_data; - /* allocate a space large enough to contruct the string */ - if (!(tmpbuf = malloc(num_gids*12))) { - errno = ENOMEM; - return NULL; - } - idx += sprintf(tmpbuf, "%d", gid_list[0]); - for (i = 1; i < num_gids; i++) { - tmpbuf[idx++] = ','; - idx += sprintf(tmpbuf+idx, "%d", gid_list[i]); - } - tmpbuf[idx] = '\0'; - if (!(result = malloc(idx+1))) { - /* allocate a string the right size to return, but - if that fails may as well return our working buffer - because it contains the same thing */ - return tmpbuf; - } - strcpy(result, tmpbuf); - SAFE_FREE(tmpbuf); - return result; - } else if (ret == NSS_STATUS_NOTFOUND) { - errno = ENOENT; - } else { - errno = EIO; + /* allocate a space large enough to contruct the string */ + tmpbuf = list_alloc(&list, num_gids*12); + if (!tmpbuf) { + return NULL; } - - return NULL; + + for (idx=i=0; i < num_gids-1; i++) { + idx += sprintf(tmpbuf+idx, "%u,", gid_list[i]); + } + idx += sprintf(tmpbuf+idx, "%u", gid_list[i]); + + free_response(&response); + + return tmpbuf; } -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) { -/* take a uid and return a filled struct passwd */ - + static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; + + list_destory(&list); ZERO_STRUCT(response); ZERO_STRUCT(request); @@ -347,55 +337,46 @@ wb_aix_getpwuid (uid_t uid) request.data.uid = uid; ret = winbindd_request(WINBINDD_GETPWUID, &request, &response); - - if (ret == NSS_STATUS_SUCCESS) { - return fill_pwent(&response.data.pw); - } else if (ret == NSS_STATUS_NOTFOUND ) { - errno = ENOENT; - } else { - errno = EIO; - } - - return NULL; + + HANDLE_ERRORS(ret); + + return fill_pwent(&list, &response.data.pw); } -static struct passwd * -wb_aix_getpwnam (const char *name) -{ -/* take a username and return a filled struct passwd */ +/* take a username and return a filled struct passwd */ +static struct passwd *wb_aix_getpwnam(const char *name) +{ + static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; + + list_destory(&list); ZERO_STRUCT(response); ZERO_STRUCT(request); - strncpy(request.data.username, name, - sizeof(request.data.username) - 1); - request.data.username - [sizeof(request.data.username) - 1] = '\0'; + if (strlen(name)+1 > sizeof(request.data.username)) { + errno = EINVAL; + return NULL; + } + + strcpy(request.data.username, name); ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); + + HANDLE_ERRORS(ret); - if (ret == NSS_STATUS_SUCCESS ) { - return fill_pwent(&response.data.pw); - } else if (ret == NSS_STATUS_NOTFOUND) { - errno = ENOENT; - } else { - errno = EIO; - } - - return NULL; + return fill_pwent(&list, &response.data.pw); } -int -wb_aix_init (struct secmethod_table *methods) +int wb_aix_init(struct secmethod_table *methods) { - memset(methods, 0, sizeof(*methods)); + ZERO_STRUCTP(methods); /* identification methods, this is the minimum requried for a - working module */ + working module */ methods->method_getgrgid = wb_aix_getgrgid; methods->method_getgrnam = wb_aix_getgrnam; @@ -405,3 +386,4 @@ wb_aix_init (struct secmethod_table *methods) return AUTH_SUCCESS; } + -- cgit From a2b533c9f98fed00f0d740aefc2320a634f66749 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 29 Jan 2004 06:14:13 +0000 Subject: completely rewrote the AIX UESS backend (UESS is the AIX equivalent of NSS). This time I think I've actually got it right. I wrote a fairly good test suite for UESS modules (similar to nsstest.c) that allowed me to explore how the modules supplied with AIX actually work. This new module also incorporates authentication features, so you don't need a PAM module at all. Just install this UESS module and authentication will "just work". It also handles password change, so /usr/bin/passwd can be used to change windows password. (This used to be commit d62cb9454e310d2baeea0077dad4ba9382ba06cd) --- source3/nsswitch/winbind_nss_aix.c | 926 +++++++++++++++++++++++++++++++------ 1 file changed, 778 insertions(+), 148 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 3d2f01b93c..3e00e54e5c 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -1,12 +1,12 @@ /* Unix SMB/CIFS implementation. - AIX loadable authentication module, providing identification - routines against Samba winbind/Windows NT Domain + AIX loadable authentication module, providing identification and + authentication routines against Samba winbind/Windows NT Domain Copyright (C) Tim Potter 2003 Copyright (C) Steve Roylance 2003 - Copyright (C) Andrew Tridgell 2003 + Copyright (C) Andrew Tridgell 2003-2004 This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public @@ -25,9 +25,24 @@ */ /* + + To install this module copy nsswitch/WINBIND to /usr/lib/security and add + "WINBIND" in /usr/lib/security/methods.cfg and /etc/security/user + + Note that this module also provides authentication and password + changing routines, so you do not need to install the winbind PAM + module. + see http://publib16.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/kernextc/sec_load_mod.htm - for information in the interface that this module implements + for some information in the interface that this module implements + + Many thanks to Julianne Haugh for explaining some of the finer + details of this interface. + + To debug this module use uess_test.c (which you can get from tridge) + or set "options=debug" in /usr/lib/security/methods.cfg + */ #include @@ -38,79 +53,24 @@ #include "winbind_client.h" -/* - the documentation doesn't say so, but experimentation shows that all - of the functions need to return static data, and the area can be - freed only when the same function is called again, or the close - method is called on the module. Note that this matches the standard - behaviour of functions like getpwnam(). - - The most puzzling thing about this AIX interface is that it seems to - offer no way of providing a user or group enumeration method. You - can find out any amount of detail about a user or group once you - know the name, but you can't obtain a list of those names. If anyone - does find out how to do this then please let me know (yes, I should - be able to find out as I work for IBM, and this is an IBM interface, - but finding the right person to ask is a mammoth task!) - - tridge@samba.org October 2003 -*/ - +#define WB_AIX_ENCODED '_' -/* - each function uses one of the following lists of memory, declared - static in each backend method. This allows the function to destroy - the memory when that backend is called next time -*/ -struct mem_list { - struct mem_list *next, *prev; - void *p; -}; +static int debug_enabled; -/* allocate some memory on a mem_list */ -static void *list_alloc(struct mem_list **list, size_t size) +static void logit(const char *format, ...) { - struct mem_list *m; - m = malloc(sizeof(*m)); - if (!m) { - errno = ENOMEM; - return NULL; - } - m->p = malloc(size); - if (!m->p) { - errno = ENOMEM; - free(m); - return NULL; - } - m->next = *list; - m->prev = NULL; - if (*list) { - (*list)->prev = m; + va_list ap; + FILE *f; + if (!debug_enabled) { + return; } - (*list) = m; - return m->p; -} - -/* duplicate a string using list_alloc() */ -static char *list_strdup(struct mem_list **list, const char *s) -{ - char *ret = list_alloc(list, strlen(s)+1); - if (!ret) return NULL; - strcpy(ret, s); - return ret; -} - -/* destroy a mem_list */ -static void list_destory(struct mem_list **list) -{ - struct mem_list *m, *next; - for (m=*list; m; m=next) { - next = m->next; - free(m->p); - free(m); - } - (*list) = NULL; + f = fopen("/tmp/WINBIND_DEBUG.log", "a"); + if (!f) return; + va_start(ap, format); + vfprintf(f, format, ap); + va_end(ap); + fclose(f); } @@ -124,58 +84,147 @@ static void list_destory(struct mem_list **list) } \ } while (0) -/* - fill a struct passwd from a winbindd_pw struct, using memory from a mem_list +#define STRCPY_RET(dest, src) \ +do { \ + if (strlen(src)+1 > sizeof(dest)) { errno = EINVAL; return -1; } \ + strcpy(dest, src); \ +} while (0) + +#define STRCPY_RETNULL(dest, src) \ +do { \ + if (strlen(src)+1 > sizeof(dest)) { errno = EINVAL; return NULL; } \ + strcpy(dest, src); \ +} while (0) + + +/* free a passwd structure */ +static void free_pwd(struct passwd *pwd) +{ + free(pwd->pw_name); + free(pwd->pw_passwd); + free(pwd->pw_gecos); + free(pwd->pw_dir); + free(pwd->pw_shell); + free(pwd); +} + +/* free a group structure */ +static void free_grp(struct group *grp) +{ + int i; + + free(grp->gr_name); + free(grp->gr_passwd); + + if (!grp->gr_mem) { + free(grp); + return; + } + + for (i=0; grp->gr_mem[i]; i++) { + free(grp->gr_mem[i]); + } + + free(grp->gr_mem); + free(grp); +} + + +/* replace commas with nulls, and null terminate */ +static void replace_commas(char *s) +{ + char *p, *p0=s; + for (p=strchr(s, ','); p; p = strchr(p+1, ',')) { + *p=0; + p0 = p+1; + } + + p0[strlen(p0)+1] = 0; +} + + +/* the decode_*() routines are used to cope with the fact that AIX 5.2 + and below cannot handle user or group names longer than 8 + characters in some interfaces. We use the normalize method to + provide a mapping to a username that fits, by using the form '_UID' + or '_GID'. + + this only works if you can guarantee that the WB_AIX_ENCODED char + is not used as the first char of any other username */ -static struct passwd *fill_pwent(struct mem_list **list, struct winbindd_pw *pw) +static unsigned decode_id(const char *name) { - struct passwd *result; + unsigned id; + sscanf(name+1, "%u", &id); + return id; +} - if (!(result = list_alloc(list, sizeof(struct passwd)))) { +static char *decode_user(const char *name) +{ + struct passwd *pwd; + unsigned id; + char *ret; + static struct passwd *wb_aix_getpwuid(uid_t uid); + + sscanf(name+1, "%u", &id); + pwd = wb_aix_getpwuid(id); + if (!pwd) { return NULL; } + ret = strdup(pwd->pw_name); - ZERO_STRUCTP(result); + free_pwd(pwd); + + logit("decoded '%s' -> '%s'\n", name, ret); + + return ret; +} - result->pw_uid = pw->pw_uid; - result->pw_gid = pw->pw_gid; - /* strings */ - if ((result->pw_name = list_strdup(list, pw->pw_name)) == NULL || - (result->pw_passwd = list_strdup(list, pw->pw_passwd)) == NULL || - (result->pw_gecos = list_strdup(list, pw->pw_gecos)) == NULL || - (result->pw_dir = list_strdup(list, pw->pw_dir)) == NULL || - (result->pw_shell = list_strdup(list, pw->pw_shell)) == NULL) { +/* + fill a struct passwd from a winbindd_pw struct, allocating as a single block +*/ +static struct passwd *fill_pwent(struct winbindd_pw *pw) +{ + struct passwd *result; + + result = calloc(1, sizeof(struct passwd)); + if (!result) { + errno = ENOMEM; return NULL; } + + result->pw_uid = pw->pw_uid; + result->pw_gid = pw->pw_gid; + result->pw_name = strdup(pw->pw_name); + result->pw_passwd = strdup(pw->pw_passwd); + result->pw_gecos = strdup(pw->pw_gecos); + result->pw_dir = strdup(pw->pw_dir); + result->pw_shell = strdup(pw->pw_shell); return result; } /* - fill a struct group from a winbindd_pw struct, using memory from a mem_list + fill a struct group from a winbindd_pw struct, allocating as a single block */ -static struct group *fill_grent(struct mem_list **list, struct winbindd_gr *gr, char *gr_mem) +static struct group *fill_grent(struct winbindd_gr *gr, char *gr_mem) { int i; - char *tst; struct group *result; - char *name, *p; + char *p, *name; - if (!(result = list_alloc(list, sizeof(struct group)))) { + result = calloc(1, sizeof(struct group)); + if (!result) { + errno = ENOMEM; return NULL; } - ZERO_STRUCTP(result); - result->gr_gid = gr->gr_gid; - /* Group name */ - if ((result->gr_name = list_strdup(list, gr->gr_name)) == NULL || - (result->gr_passwd = list_strdup(list, gr->gr_passwd)) == NULL) { - return NULL; - } + result->gr_name = strdup(gr->gr_name); + result->gr_passwd = strdup(gr->gr_passwd); /* Group membership */ if ((gr->num_gr_mem < 0) || !gr_mem) { @@ -187,30 +236,26 @@ static struct group *fill_grent(struct mem_list **list, struct winbindd_gr *gr, return result; } - tst = list_alloc(list, (gr->num_gr_mem + 1) * sizeof(char *)); - if (!tst) { + result->gr_mem = (char **)malloc(sizeof(char *) * (gr->num_gr_mem+1)); + if (!result->gr_mem) { + errno = ENOMEM; return NULL; } - - result->gr_mem = (char **)tst; /* Start looking at extra data */ i=0; for (name = strtok_r(gr_mem, ",", &p); name; name = strtok_r(NULL, ",", &p)) { - if (i >= gr->num_gr_mem) { - return NULL; - } - (result->gr_mem)[i] = list_strdup(list, name); - if ((result->gr_mem)[i] == NULL) { - return NULL; + if (i == gr->num_gr_mem) { + break; } + result->gr_mem[i] = strdup(name); i++; } /* Terminate list */ - (result->gr_mem)[i] = NULL; + result->gr_mem[i] = NULL; return result; } @@ -220,13 +265,12 @@ static struct group *fill_grent(struct mem_list **list, struct winbindd_gr *gr, /* take a group id and return a filled struct group */ static struct group *wb_aix_getgrgid(gid_t gid) { - static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; struct group *grp; NSS_STATUS ret; - list_destory(&list); + logit("getgrgid %d\n", gid); ZERO_STRUCT(response); ZERO_STRUCT(request); @@ -235,9 +279,11 @@ static struct group *wb_aix_getgrgid(gid_t gid) ret = winbindd_request(WINBINDD_GETGRGID, &request, &response); + logit("getgrgid ret=%d\n", ret); + HANDLE_ERRORS(ret); - grp = fill_grent(&list, &response.data.gr, response.extra_data); + grp = fill_grent(&response.data.gr, response.extra_data); free_response(&response); @@ -247,28 +293,27 @@ 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) { - static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; struct group *grp; - list_destory(&list); + if (*name == WB_AIX_ENCODED) { + return wb_aix_getgrgid(decode_id(name)); + } + + logit("getgrnam '%s'\n", name); ZERO_STRUCT(response); ZERO_STRUCT(request); - if (strlen(name)+1 > sizeof(request.data.groupname)) { - errno = EINVAL; - return NULL; - } - strcpy(request.data.groupname, name); + STRCPY_RETNULL(request.data.groupname, name); ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response); HANDLE_ERRORS(ret); - grp = fill_grent(&list, &response.data.gr, response.extra_data); + grp = fill_grent(&response.data.gr, response.extra_data); free_response(&response); @@ -276,11 +321,25 @@ static struct group *wb_aix_getgrnam(const char *name) } +/* this call doesn't have to fill in the gr_mem, but we do anyway + for simplicity */ +static struct group *wb_aix_getgracct(void *id, int type) +{ + if (type == 1) { + return wb_aix_getgrnam((char *)id); + } + if (type == 0) { + return wb_aix_getgrgid(*(int *)id); + } + errno = EINVAL; + return NULL; +} + + /* take a username and return a string containing a comma-separated list of group id numbers to which the user belongs */ static char *wb_aix_getgrset(char *user) { - static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; @@ -288,14 +347,23 @@ static char *wb_aix_getgrset(char *user) char *tmpbuf; int num_gids; gid_t *gid_list; + char *r_user = user; - list_destory(&list); + if (*user == WB_AIX_ENCODED) { + r_user = decode_user(r_user); + if (!r_user) { + errno = ENOENT; + return NULL; + } + } - if (strlen(user)+1 > sizeof(request.data.username)) { - errno = EINVAL; - return NULL; + logit("getgrset '%s'\n", r_user); + + STRCPY_RETNULL(request.data.username, r_user); + + if (*user == WB_AIX_ENCODED) { + free(r_user); } - strcpy(request.data.username, user); ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response); @@ -305,7 +373,7 @@ static char *wb_aix_getgrset(char *user) gid_list = (gid_t *)response.extra_data; /* allocate a space large enough to contruct the string */ - tmpbuf = list_alloc(&list, num_gids*12); + tmpbuf = malloc(num_gids*12); if (!tmpbuf) { return NULL; } @@ -324,13 +392,13 @@ 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) { - static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; + struct passwd *pwd; + + logit("getpwuid '%d'\n", uid); - list_destory(&list); - ZERO_STRUCT(response); ZERO_STRUCT(request); @@ -340,49 +408,611 @@ static struct passwd *wb_aix_getpwuid(uid_t uid) HANDLE_ERRORS(ret); - return fill_pwent(&list, &response.data.pw); + pwd = fill_pwent(&response.data.pw); + + free_response(&response); + + logit("getpwuid gave ptr %p\n", pwd); + + return pwd; } /* take a username and return a filled struct passwd */ static struct passwd *wb_aix_getpwnam(const char *name) { - static struct mem_list *list; struct winbindd_response response; struct winbindd_request request; NSS_STATUS ret; + struct passwd *pwd; + + if (*name == WB_AIX_ENCODED) { + return wb_aix_getpwuid(decode_id(name)); + } + + logit("getpwnam '%s'\n", name); - list_destory(&list); - ZERO_STRUCT(response); ZERO_STRUCT(request); - if (strlen(name)+1 > sizeof(request.data.username)) { + STRCPY_RETNULL(request.data.username, name); + + ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); + + HANDLE_ERRORS(ret); + + pwd = fill_pwent(&response.data.pw); + + free_response(&response); + + logit("getpwnam gave ptr %p\n", pwd); + + return pwd; +} + +/* + list users +*/ +static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) +{ + NSS_STATUS ret; + struct winbindd_request request; + struct winbindd_response response; + int len; + char *s; + + if (size != 1 || strcmp(attributes[0], S_USERS) != 0) { + logit("invalid lsuser op\n"); errno = EINVAL; - return NULL; + return -1; } - strcpy(request.data.username, name); + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + ret = winbindd_request(WINBINDD_LIST_USERS, &request, &response); + if (ret != 0) { + errno = EINVAL; + return -1; + } - ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); + len = strlen(response.extra_data); - HANDLE_ERRORS(ret); + s = malloc(len+2); + if (!s) { + free_response(&response); + errno = ENOMEM; + return -1; + } + + memcpy(s, response.extra_data, len+1); + + replace_commas(s); + + results[0].attr_un.au_char = s; + results[0].attr_flag = 0; + + free_response(&response); + + return 0; +} + + +/* + list groups +*/ +static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) +{ + NSS_STATUS ret; + struct winbindd_request request; + struct winbindd_response response; + int len; + char *s; + + if (size != 1 || strcmp(attributes[0], S_GROUPS) != 0) { + logit("invalid lsgroup op\n"); + errno = EINVAL; + return -1; + } + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + ret = winbindd_request(WINBINDD_LIST_GROUPS, &request, &response); + if (ret != 0) { + errno = EINVAL; + return -1; + } + + len = strlen(response.extra_data); + + s = malloc(len+2); + if (!s) { + free_response(&response); + errno = ENOMEM; + return -1; + } + + memcpy(s, response.extra_data, len+1); + + replace_commas(s); + + results[0].attr_un.au_char = s; + results[0].attr_flag = 0; + + free_response(&response); - return fill_pwent(&list, &response.data.pw); + return 0; +} + + +static attrval_t pwd_to_group(struct passwd *pwd) +{ + attrval_t r; + struct group *grp = wb_aix_getgrgid(pwd->pw_gid); + + if (!grp) { + r.attr_flag = EINVAL; + } else { + r.attr_flag = 0; + r.attr_un.au_char = strdup(grp->gr_name); + free_grp(grp); + } + + return r; +} + +static attrval_t pwd_to_groupsids(struct passwd *pwd) +{ + attrval_t r; + char *s, *p; + + s = wb_aix_getgrset(pwd->pw_name); + if (!s) { + r.attr_flag = EINVAL; + return r; + } + + p = malloc(strlen(s)+2); + if (!p) { + r.attr_flag = ENOMEM; + return r; + } + + strcpy(p, s); + replace_commas(p); + free(s); + + r.attr_un.au_char = p; + + return r; +} + +static attrval_t pwd_to_sid(struct passwd *pwd) +{ + struct winbindd_request request; + struct winbindd_response response; + attrval_t r; + + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + request.data.uid = pwd->pw_uid; + + if (winbindd_request(WINBINDD_UID_TO_SID, &request, &response) != + NSS_STATUS_SUCCESS) { + r.attr_flag = ENOENT; + } else { + r.attr_flag = 0; + r.attr_un.au_char = strdup(response.data.sid.sid); + } + + return r; +} + +static int wb_aix_user_attrib(const char *key, char *attributes[], + attrval_t results[], int size) +{ + struct passwd *pwd; + int i; + + pwd = wb_aix_getpwnam(key); + if (!pwd) { + errno = ENOENT; + return -1; + } + + for (i=0;ipw_uid; + } else if (strcmp(attributes[i], S_PWD) == 0) { + results[i].attr_un.au_char = strdup(pwd->pw_passwd); + } else if (strcmp(attributes[i], S_HOME) == 0) { + results[i].attr_un.au_char = strdup(pwd->pw_dir); + } else if (strcmp(attributes[0], S_SHELL) == 0) { + results[i].attr_un.au_char = strdup(pwd->pw_shell); + } else if (strcmp(attributes[0], S_REGISTRY) == 0) { + results[i].attr_un.au_char = strdup("WINBIND"); + } else if (strcmp(attributes[0], S_GECOS) == 0) { + results[i].attr_un.au_char = strdup(pwd->pw_gecos); + } else if (strcmp(attributes[0], S_PGRP) == 0) { + results[i] = pwd_to_group(pwd); + } else if (strcmp(attributes[0], S_GECOS) == 0) { + results[i].attr_un.au_char = strdup(pwd->pw_gecos); + } else if (strcmp(attributes[0], S_GROUPSIDS) == 0) { + results[i] = pwd_to_groupsids(pwd); + } else if (strcmp(attributes[0], "SID") == 0) { + results[i] = pwd_to_sid(pwd); + } else { + logit("Unknown user attribute '%s'\n", attributes[i]); + results[i].attr_flag = EINVAL; + } + } + + free_pwd(pwd); + + return 0; +} + +static int wb_aix_group_attrib(const char *key, char *attributes[], + attrval_t results[], int size) +{ + struct group *grp; + int i; + + grp = wb_aix_getgrnam(key); + if (!grp) { + errno = ENOENT; + return -1; + } + + for (i=0;igr_passwd); + } else if (strcmp(attributes[i], S_ID) == 0) { + results[i].attr_un.au_int = grp->gr_gid; + } else { + logit("Unknown group attribute '%s'\n", attributes[i]); + results[i].attr_flag = EINVAL; + } + } + + free_grp(grp); + + return 0; } + +/* + called for user/group enumerations +*/ +static int wb_aix_getentry(char *key, char *table, char *attributes[], + attrval_t results[], int size) +{ + logit("Got getentry with key='%s' table='%s' size=%d attributes[0]='%s'\n", + key, table, size, attributes[0]); + + if (strcmp(key, "ALL") == 0 && + strcmp(table, "user") == 0) { + return wb_aix_lsuser(attributes, results, size); + } + + if (strcmp(key, "ALL") == 0 && + strcmp(table, "group") == 0) { + return wb_aix_lsgroup(attributes, results, size); + } + + if (strcmp(table, "user") == 0) { + return wb_aix_user_attrib(key, attributes, results, size); + } + + if (strcmp(table, "group") == 0) { + return wb_aix_group_attrib(key, attributes, results, size); + } + + logit("Unknown getentry operation key='%s' table='%s'\n", key, table); + + errno = ENOSYS; + return -1; +} + + + +/* + called to start the backend +*/ +static void *wb_aix_open(const char *name, const char *domain, int mode, char *options) +{ + if (strstr(options, "debug")) { + debug_enabled = 1; + } + logit("open name='%s' mode=%d domain='%s' options='%s'\n", name, domain, + mode, options); + return NULL; +} + +static void wb_aix_close(void *token) +{ + logit("close\n"); + return; +} + +/* + return a list of additional attributes supported by the backend +*/ +static attrlist_t **wb_aix_attrlist(void) +{ + attrlist_t **ret; + logit("method attrlist called\n"); + ret = malloc(2*sizeof(attrlist_t *) + sizeof(attrlist_t)); + if (!ret) { + errno = ENOMEM; + return NULL; + } + + ret[0] = (attrlist_t *)(ret+2); + + /* just one extra attribute - the windows SID */ + ret[0]->al_name = strdup("SID"); + ret[0]->al_flags = AL_USERATTR; + ret[0]->al_type = SEC_CHAR; + ret[1] = NULL; + + return ret; +} + + +/* + turn a long username into a short one. Needed to cope with the 8 char + username limit in AIX 5.2 and below +*/ +static int wb_aix_normalize(char *longname, char *shortname) +{ + struct passwd *pwd; + + logit("normalize '%s'\n", longname); + + /* automatically cope with AIX 5.3 with longer usernames + when it comes out */ + if (S_NAMELEN > strlen(longname)) { + strcpy(shortname, longname); + return 1; + } + + pwd = wb_aix_getpwnam(longname); + if (!pwd) { + errno = ENOENT; + return 0; + } + + sprintf(shortname, "%c%07u", WB_AIX_ENCODED, pwd->pw_uid); + + free_pwd(pwd); + + return 1; +} + + +/* + authenticate a user + */ +static int wb_aix_authenticate(char *user, char *pass, + int *reenter, char **message) +{ + struct winbindd_request request; + struct winbindd_response response; + NSS_STATUS result; + char *r_user = user; + + logit("authenticate '%s' response='%s'\n", user, pass); + + *reenter = 0; + *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) { + return AUTH_NOTFOUND; + } + } + + STRCPY_RET(request.data.auth.user, r_user); + STRCPY_RET(request.data.auth.pass, pass); + + if (*user == WB_AIX_ENCODED) { + free(r_user); + } + + result = winbindd_request(WINBINDD_PAM_AUTH, &request, &response); + + free_response(&response); + + logit("auth result %d for '%s'\n", result, user); + + if (result == NSS_STATUS_SUCCESS) { + errno = 0; + return AUTH_SUCCESS; + } + + return AUTH_FAILURE; +} + + +/* + change a user password +*/ +static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **message) +{ + struct winbindd_request request; + struct winbindd_response response; + NSS_STATUS result; + char *r_user = user; + + if (*user == WB_AIX_ENCODED) { + r_user = decode_user(r_user); + if (!r_user) { + errno = ENOENT; + return -1; + } + } + + logit("chpass '%s' old='%s' new='%s'\n", r_user, oldpass, newpass); + + *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); + + if (*user == WB_AIX_ENCODED) { + free(r_user); + } + + result = winbindd_request(WINBINDD_PAM_CHAUTHTOK, &request, &response); + + free_response(&response); + + if (result == NSS_STATUS_SUCCESS) { + errno = 0; + return 0; + } + + errno = EINVAL; + return -1; +} + +/* + don't do any password strength testing for now +*/ +static int wb_aix_passwdrestrictions(char *user, char *newpass, char *oldpass, + char **message) +{ + logit("passwdresrictions called for '%s'\n", user); + return 0; +} + + +static int wb_aix_passwdexpired(char *user, char **message) +{ + logit("passwdexpired '%s'\n", user); + /* we should check the account bits here */ + return 0; +} + + +/* + we can't return a crypt() password +*/ +static char *wb_aix_getpasswd(char *user) +{ + logit("getpasswd '%s'\n", user); + errno = ENOSYS; + return NULL; +} + +/* + this is called to update things like the last login time. We don't + currently pass this onto the DC +*/ +static int wb_aix_putentry(char *key, char *table, char *attributes[], + attrval_t values[], int size) +{ + logit("putentry key='%s' table='%s' attrib='%s'\n", + key, table, size>=1?attributes[0]:""); + errno = ENOSYS; + return -1; +} + +static int wb_aix_commit(char *key, char *table) +{ + logit("commit key='%s' table='%s'\n"); + errno = ENOSYS; + return -1; +} + +static int wb_aix_getgrusers(char *group, void *result, int type, int *size) +{ + logit("getgrusers group='%s'\n", group); + errno = ENOSYS; + return -1; +} + + +#define DECL_METHOD(x) \ +int method_ ## x(void) \ +{ \ + logit("UNIMPLEMENTED METHOD '%s'\n", #x); \ + errno = EINVAL; \ + return -1; \ +} + +#if LOG_UNIMPLEMENTED_CALLS +DECL_METHOD(delgroup); +DECL_METHOD(deluser); +DECL_METHOD(newgroup); +DECL_METHOD(newuser); +DECL_METHOD(putgrent); +DECL_METHOD(putgrusers); +DECL_METHOD(putpwent); +DECL_METHOD(lock); +DECL_METHOD(unlock); +DECL_METHOD(getcred); +DECL_METHOD(setcred); +DECL_METHOD(deletecred); +#endif + int wb_aix_init(struct secmethod_table *methods) { ZERO_STRUCTP(methods); - /* identification methods, this is the minimum requried for a - working module */ - - methods->method_getgrgid = wb_aix_getgrgid; - methods->method_getgrnam = wb_aix_getgrnam; - methods->method_getgrset = wb_aix_getgrset; - methods->method_getpwnam = wb_aix_getpwnam; - methods->method_getpwuid = wb_aix_getpwuid; + methods->method_version = SECMETHOD_VERSION_520; + + methods->method_getgrgid = wb_aix_getgrgid; + methods->method_getgrnam = wb_aix_getgrnam; + methods->method_getgrset = wb_aix_getgrset; + methods->method_getpwnam = wb_aix_getpwnam; + methods->method_getpwuid = wb_aix_getpwuid; + methods->method_getentry = wb_aix_getentry; + methods->method_open = wb_aix_open; + methods->method_close = wb_aix_close; + methods->method_normalize = wb_aix_normalize; + methods->method_passwdexpired = wb_aix_passwdexpired; + methods->method_putentry = wb_aix_putentry; + methods->method_getpasswd = wb_aix_getpasswd; + methods->method_authenticate = wb_aix_authenticate; + methods->method_commit = wb_aix_commit; + methods->method_chpass = wb_aix_chpass; + methods->method_passwdrestrictions = wb_aix_passwdrestrictions; + methods->method_getgracct = wb_aix_getgracct; + methods->method_getgrusers = wb_aix_getgrusers; + methods->method_attrlist = wb_aix_attrlist; + +#if LOG_UNIMPLEMENTED_CALLS + methods->method_delgroup = method_delgroup; + methods->method_deluser = method_deluser; + methods->method_newgroup = method_newgroup; + methods->method_newuser = method_newuser; + methods->method_putgrent = method_putgrent; + methods->method_putgrusers = method_putgrusers; + methods->method_putpwent = method_putpwent; + methods->method_lock = method_lock; + methods->method_unlock = method_unlock; + methods->method_getcred = method_getcred; + methods->method_setcred = method_setcred; + methods->method_deletecred = method_deletecred; +#endif return AUTH_SUCCESS; } -- cgit From 02c9b46fab46ab401a3cf6bb74c8260801c41032 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 1 Oct 2004 02:57:10 +0000 Subject: r2759: Fix for winbindd on AIX 5.1. Apparently it doesn't have as many methods in struct secmethod_table as AIX 5.2. Patch from The Written Word. (This used to be commit 4f8496ad626478c31e9372e07652d50f581256d0) --- source3/nsswitch/winbind_nss_aix.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 3e00e54e5c..a1bffccc66 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -741,6 +741,7 @@ static void wb_aix_close(void *token) return; } +#ifdef HAVE_STRUCT_SECMETHOD_TABLE_METHOD_ATTRLIST /* return a list of additional attributes supported by the backend */ @@ -764,6 +765,7 @@ static attrlist_t **wb_aix_attrlist(void) return ret; } +#endif /* @@ -977,7 +979,9 @@ int wb_aix_init(struct secmethod_table *methods) { ZERO_STRUCTP(methods); +#ifdef HAVE_STRUCT_SECMETHOD_TABLE_METHOD_VERSION methods->method_version = SECMETHOD_VERSION_520; +#endif methods->method_getgrgid = wb_aix_getgrgid; methods->method_getgrnam = wb_aix_getgrnam; @@ -997,7 +1001,9 @@ int wb_aix_init(struct secmethod_table *methods) methods->method_passwdrestrictions = wb_aix_passwdrestrictions; methods->method_getgracct = wb_aix_getgracct; methods->method_getgrusers = wb_aix_getgrusers; +#ifdef HAVE_STRUCT_SECMETHOD_TABLE_METHOD_ATTRLIST methods->method_attrlist = wb_aix_attrlist; +#endif #if LOG_UNIMPLEMENTED_CALLS methods->method_delgroup = method_delgroup; -- cgit From 301513531493cd0f14571df96d1eaeac53eee237 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 1 Oct 2004 02:59:43 +0000 Subject: r2760: Another patch from The Written Word. Don't declare function prototypes inside a function. Bugzilla #1762. (This used to be commit 002cdd4a5b34611983a32018248f9fe122c4111a) --- source3/nsswitch/winbind_nss_aix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index a1bffccc66..c90dc2f3f1 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -159,12 +159,13 @@ static unsigned decode_id(const char *name) return id; } +static struct passwd *wb_aix_getpwuid(uid_t uid); + static char *decode_user(const char *name) { struct passwd *pwd; unsigned id; char *ret; - static struct passwd *wb_aix_getpwuid(uid_t uid); sscanf(name+1, "%u", &id); pwd = wb_aix_getpwuid(id); -- cgit From 40de272fe6f0be1b1451f4ecd58c5c77d39d8d12 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 25 Jun 2005 10:13:07 +0000 Subject: r7903: Attempt to fix the AIX build (This used to be commit bb884b0bf96899bf3cf477bfe2220cdfc7aa596d) --- source3/nsswitch/winbind_nss_aix.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index c90dc2f3f1..0a8bef736c 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -278,7 +278,7 @@ static struct group *wb_aix_getgrgid(gid_t gid) request.data.gid = gid; - ret = winbindd_request(WINBINDD_GETGRGID, &request, &response); + ret = winbindd_request_response(WINBINDD_GETGRGID, &request, &response); logit("getgrgid ret=%d\n", ret); @@ -310,7 +310,7 @@ static struct group *wb_aix_getgrnam(const char *name) STRCPY_RETNULL(request.data.groupname, name); - ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response); + ret = winbindd_request_response(WINBINDD_GETGRNAM, &request, &response); HANDLE_ERRORS(ret); @@ -366,7 +366,7 @@ static char *wb_aix_getgrset(char *user) free(r_user); } - ret = winbindd_request(WINBINDD_GETGROUPS, &request, &response); + ret = winbindd_request_response(WINBINDD_GETGROUPS, &request, &response); HANDLE_ERRORS(ret); @@ -405,7 +405,7 @@ static struct passwd *wb_aix_getpwuid(uid_t uid) request.data.uid = uid; - ret = winbindd_request(WINBINDD_GETPWUID, &request, &response); + ret = winbindd_request_response(WINBINDD_GETPWUID, &request, &response); HANDLE_ERRORS(ret); @@ -438,7 +438,7 @@ static struct passwd *wb_aix_getpwnam(const char *name) STRCPY_RETNULL(request.data.username, name); - ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response); + ret = winbindd_request_response(WINBINDD_GETPWNAM, &request, &response); HANDLE_ERRORS(ret); @@ -471,7 +471,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) ZERO_STRUCT(request); ZERO_STRUCT(response); - ret = winbindd_request(WINBINDD_LIST_USERS, &request, &response); + ret = winbindd_request_response(WINBINDD_LIST_USERS, &request, &response); if (ret != 0) { errno = EINVAL; return -1; @@ -519,7 +519,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) ZERO_STRUCT(request); ZERO_STRUCT(response); - ret = winbindd_request(WINBINDD_LIST_GROUPS, &request, &response); + ret = winbindd_request_response(WINBINDD_LIST_GROUPS, &request, &response); if (ret != 0) { errno = EINVAL; return -1; @@ -600,7 +600,7 @@ static attrval_t pwd_to_sid(struct passwd *pwd) request.data.uid = pwd->pw_uid; - if (winbindd_request(WINBINDD_UID_TO_SID, &request, &response) != + if (winbindd_request_response(WINBINDD_UID_TO_SID, &request, &response) != NSS_STATUS_SUCCESS) { r.attr_flag = ENOENT; } else { @@ -834,7 +834,7 @@ static int wb_aix_authenticate(char *user, char *pass, free(r_user); } - result = winbindd_request(WINBINDD_PAM_AUTH, &request, &response); + result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response); free_response(&response); @@ -883,7 +883,7 @@ static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **messag free(r_user); } - result = winbindd_request(WINBINDD_PAM_CHAUTHTOK, &request, &response); + result = winbindd_request_response(WINBINDD_PAM_CHAUTHTOK, &request, &response); free_response(&response); -- cgit From 8c9eb7631eecbe3f9bda30aff4b5d97d5e2a8737 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 12 Apr 2006 14:10:39 +0000 Subject: r15053: fix portabilities issues between 32-bit winbind clients and a 64-bit winbindd server (This used to be commit a95d11345e76948b147bbc1f29a05c978d99a47a) --- source3/nsswitch/winbind_nss_aix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 0a8bef736c..b898e3c3af 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -284,7 +284,7 @@ static struct group *wb_aix_getgrgid(gid_t gid) HANDLE_ERRORS(ret); - grp = fill_grent(&response.data.gr, response.extra_data); + grp = fill_grent(&response.data.gr, response.extra_data.data); free_response(&response); @@ -314,7 +314,7 @@ static struct group *wb_aix_getgrnam(const char *name) HANDLE_ERRORS(ret); - grp = fill_grent(&response.data.gr, response.extra_data); + grp = fill_grent(&response.data.gr, response.extra_data.data); free_response(&response); @@ -371,7 +371,7 @@ static char *wb_aix_getgrset(char *user) HANDLE_ERRORS(ret); num_gids = response.data.num_entries; - gid_list = (gid_t *)response.extra_data; + gid_list = (gid_t *)response.extra_data.data; /* allocate a space large enough to contruct the string */ tmpbuf = malloc(num_gids*12); @@ -477,7 +477,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) return -1; } - len = strlen(response.extra_data); + len = strlen(response.extra_data.data); s = malloc(len+2); if (!s) { @@ -486,7 +486,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) return -1; } - memcpy(s, response.extra_data, len+1); + memcpy(s, response.extra_data.data, len+1); replace_commas(s); @@ -525,7 +525,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) return -1; } - len = strlen(response.extra_data); + len = strlen(response.extra_data.data); s = malloc(len+2); if (!s) { @@ -534,7 +534,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) return -1; } - memcpy(s, response.extra_data, len+1); + memcpy(s, response.extra_data.data, len+1); replace_commas(s); -- cgit From ad1fcb7b15f9ea4208d746073c5a00216290a33b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 22 Apr 2006 01:59:23 +0000 Subject: r15160: Fix from William Jojo I thought had already been added (but hadn't). Jeremy. (This used to be commit dcbece8254e5de861d04b691d733616fc25cd585) --- source3/nsswitch/winbind_nss_aix.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index b898e3c3af..c5d98dad06 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -632,19 +632,17 @@ static int wb_aix_user_attrib(const char *key, char *attributes[], results[i].attr_un.au_char = strdup(pwd->pw_passwd); } else if (strcmp(attributes[i], S_HOME) == 0) { results[i].attr_un.au_char = strdup(pwd->pw_dir); - } else if (strcmp(attributes[0], S_SHELL) == 0) { + } else if (strcmp(attributes[i], S_SHELL) == 0) { results[i].attr_un.au_char = strdup(pwd->pw_shell); - } else if (strcmp(attributes[0], S_REGISTRY) == 0) { + } else if (strcmp(attributes[i], S_REGISTRY) == 0) { results[i].attr_un.au_char = strdup("WINBIND"); - } else if (strcmp(attributes[0], S_GECOS) == 0) { + } else if (strcmp(attributes[i], S_GECOS) == 0) { results[i].attr_un.au_char = strdup(pwd->pw_gecos); - } else if (strcmp(attributes[0], S_PGRP) == 0) { + } else if (strcmp(attributes[i], S_PGRP) == 0) { results[i] = pwd_to_group(pwd); - } else if (strcmp(attributes[0], S_GECOS) == 0) { - results[i].attr_un.au_char = strdup(pwd->pw_gecos); - } else if (strcmp(attributes[0], S_GROUPSIDS) == 0) { + } else if (strcmp(attributes[i], S_GROUPS) == 0) { results[i] = pwd_to_groupsids(pwd); - } else if (strcmp(attributes[0], "SID") == 0) { + } else if (strcmp(attributes[i], "SID") == 0) { results[i] = pwd_to_sid(pwd); } else { logit("Unknown user attribute '%s'\n", attributes[i]); -- cgit From 511f1cef23beb297061f7c59ccc0e17a2275ea1b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 19 May 2006 07:01:53 +0000 Subject: r15705: Fix bug number 3788. Thanks to Jeff Wright. Volker (This used to be commit e4a2cb4b9143394a54ae1de91e59722c11a0b2e4) --- source3/nsswitch/winbind_nss_aix.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index c5d98dad06..5b3aaeb8d7 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -360,6 +360,9 @@ static char *wb_aix_getgrset(char *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) { -- cgit From a734e98b516aec012ee2a9c866eb6debe663d14e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 21 Sep 2006 22:24:53 +0000 Subject: r18798: use libreplace headers in pam and nss modules this hopefully fixes the build on AIX metze (This used to be commit ef1001f5a269f3d6a66f40e3fb01eccc807dcd7e) --- source3/nsswitch/winbind_nss_aix.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 5b3aaeb8d7..6a39b4b7c4 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -45,13 +45,8 @@ */ -#include -#include -#include -#include -#include - #include "winbind_client.h" +#include #define WB_AIX_ENCODED '_' -- cgit From 85f769dbb425722c2246b8d98a529aac6849ab7d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 1 Mar 2007 03:07:57 +0000 Subject: r21611: I'm not entirely sure about this patch but it is working. su - DOM\user was unable to set the process crendentials without listing the "id" and other attributes in the attrlist[]. More fixes to come, but I didn't want this to get lost. (This used to be commit 4c53d300fa3516a4c5113bc94dfd07413c46b038) --- source3/nsswitch/winbind_nss_aix.c | 79 +++++++++++++++++++++++++++++++------- 1 file changed, 66 insertions(+), 13 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 6a39b4b7c4..bc0f252d79 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -48,6 +48,11 @@ #include "winbind_client.h" #include +/* enable this to log which entry points have not been + completed yet */ +#define LOG_UNIMPLEMENTED_CALLS 0 + + #define WB_AIX_ENCODED '_' static int debug_enabled; @@ -566,14 +571,12 @@ static attrval_t pwd_to_groupsids(struct passwd *pwd) attrval_t r; char *s, *p; - s = wb_aix_getgrset(pwd->pw_name); - if (!s) { + if ( (s = wb_aix_getgrset(pwd->pw_name)) == NULL ) { r.attr_flag = EINVAL; return r; } - p = malloc(strlen(s)+2); - if (!p) { + if ( (p = malloc(strlen(s)+2)) == NULL ) { r.attr_flag = ENOMEM; return r; } @@ -626,6 +629,8 @@ static int wb_aix_user_attrib(const char *key, char *attributes[], if (strcmp(attributes[i], S_ID) == 0) { results[i].attr_un.au_int = pwd->pw_uid; + } else if (strcmp(attributes[i], S_PGID) == 0) { + results[i].attr_un.au_int = pwd->pw_gid; } else if (strcmp(attributes[i], S_PWD) == 0) { results[i].attr_un.au_char = strdup(pwd->pw_passwd); } else if (strcmp(attributes[i], S_HOME) == 0) { @@ -744,21 +749,69 @@ static void wb_aix_close(void *token) */ static attrlist_t **wb_aix_attrlist(void) { - attrlist_t **ret; + /* pretty confusing but we are allocating the array of pointers + and the structures we'll be pointing to all at once. So + you need N+1 pointers and N structures. */ + + attrlist_t **ret = NULL; + attrlist_t *offset = NULL; + int i; + int n; + size_t size; + + struct attr_types { + const char *name; + int flags; + int type; + } attr_list[] = { + /* user attributes */ + {S_ID, AL_USERATTR, SEC_INT}, + {S_PGRP, AL_USERATTR, SEC_CHAR}, + {S_HOME, AL_USERATTR, SEC_CHAR}, + {S_SHELL, AL_USERATTR, SEC_CHAR}, + {S_PGID, AL_USERATTR, SEC_INT}, + {S_GECOS, AL_USERATTR, SEC_CHAR}, + {S_SHELL, AL_USERATTR, SEC_CHAR}, + {S_PGRP, AL_USERATTR, SEC_CHAR}, + {S_GROUPS, AL_USERATTR, SEC_LIST}, + {"SID", AL_USERATTR, SEC_CHAR}, + + /* group attributes */ + {S_ID, AL_GROUPATTR, SEC_INT} + }; + logit("method attrlist called\n"); - ret = malloc(2*sizeof(attrlist_t *) + sizeof(attrlist_t)); - if (!ret) { + + n = sizeof(attr_list) / sizeof(struct attr_types); + size = (n*sizeof(attrlist_t *)); + + if ( (ret = malloc( size )) == NULL ) { errno = ENOMEM; return NULL; } - ret[0] = (attrlist_t *)(ret+2); + /* offset to where the structures start in the buffer */ - /* just one extra attribute - the windows SID */ - ret[0]->al_name = strdup("SID"); - ret[0]->al_flags = AL_USERATTR; - ret[0]->al_type = SEC_CHAR; - ret[1] = NULL; + offset = (attrlist_t *)(ret + n); + + /* now loop over the user_attr_list[] array and add + all the members */ + + for ( i=0; ial_name = strdup(attr_list[i].name); + a->al_flags = attr_list[i].flags; + a->al_type = attr_list[i].type; + + ret[i] = a; + } + ret[n] = NULL; return ret; } -- cgit From 06ec19e2fb0e5e761c2ea7460bb71bc0cb5e66da Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 4 Apr 2007 04:28:28 +0000 Subject: r22069: BUG 4447: Fix compile failure on AIX 5.2 (patch from William Jojo ) (This used to be commit c1cb6d059b2a8539bc8a05ea4467d136bbb2ff38) --- source3/nsswitch/winbind_nss_aix.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index bc0f252d79..92d4bee005 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -629,8 +629,10 @@ static int wb_aix_user_attrib(const char *key, char *attributes[], if (strcmp(attributes[i], S_ID) == 0) { results[i].attr_un.au_int = pwd->pw_uid; +#ifdef _AIXVERSION_530 } else if (strcmp(attributes[i], S_PGID) == 0) { results[i].attr_un.au_int = pwd->pw_gid; +#endif } else if (strcmp(attributes[i], S_PWD) == 0) { results[i].attr_un.au_char = strdup(pwd->pw_passwd); } else if (strcmp(attributes[i], S_HOME) == 0) { @@ -769,7 +771,9 @@ static attrlist_t **wb_aix_attrlist(void) {S_PGRP, AL_USERATTR, SEC_CHAR}, {S_HOME, AL_USERATTR, SEC_CHAR}, {S_SHELL, AL_USERATTR, SEC_CHAR}, +#ifdef _AIXVERSION_530 {S_PGID, AL_USERATTR, SEC_INT}, +#endif {S_GECOS, AL_USERATTR, SEC_CHAR}, {S_SHELL, AL_USERATTR, SEC_CHAR}, {S_PGRP, AL_USERATTR, SEC_CHAR}, -- cgit From fd881dad3fb03888b79cc84f287c093d163475c7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:31:50 +0000 Subject: r23794: convert more code from LGPLv2+ to LGPLv3+ (This used to be commit f3df6cd87e1927f41e95af51d750a71278282e15) --- source3/nsswitch/winbind_nss_aix.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 92d4bee005..c47f9f1ef9 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -11,17 +11,15 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + You should have received a copy of the GNU Library General Public License + along with this program. If not, see . */ /* -- cgit From 28b9d61076912adbc0c6571c71688aa6831506bf Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 04:04:46 +0000 Subject: r23800: LGPL is now called GNU Lesser General Public License not GNU Library General Public License (This used to be commit 727a6cf2cba8da6b40610409b264e86e6908eb0c) --- source3/nsswitch/winbind_nss_aix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index c47f9f1ef9..0ddd6de53f 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -9,7 +9,7 @@ Copyright (C) Andrew Tridgell 2003-2004 This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public + modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. @@ -18,7 +18,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - You should have received a copy of the GNU Library General Public License + You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -- cgit From 28d076d20f9ce8afbee9a5de157ec0c9e308c9cf Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Sep 2007 07:07:59 +0000 Subject: r25143: rename public functions from winbind_client.h init_request => winbindd_init_request free_response => winbindd_free_response read_reply => winbindd_read_reply write_sock => winbind_write_sock read_sock => winbind_read_sock close_sock => winbind_close_sock(void) metze (This used to be commit 8a95d7a7edcfa5e45bccc6eda5c45d9c308cb95d) --- source3/nsswitch/winbind_nss_aix.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source3/nsswitch/winbind_nss_aix.c') diff --git a/source3/nsswitch/winbind_nss_aix.c b/source3/nsswitch/winbind_nss_aix.c index 0ddd6de53f..9c84e5f8aa 100644 --- a/source3/nsswitch/winbind_nss_aix.c +++ b/source3/nsswitch/winbind_nss_aix.c @@ -284,7 +284,7 @@ static struct group *wb_aix_getgrgid(gid_t gid) grp = fill_grent(&response.data.gr, response.extra_data.data); - free_response(&response); + winbindd_free_response(&response); return grp; } @@ -314,7 +314,7 @@ static struct group *wb_aix_getgrnam(const char *name) grp = fill_grent(&response.data.gr, response.extra_data.data); - free_response(&response); + winbindd_free_response(&response); return grp; } @@ -385,7 +385,7 @@ static char *wb_aix_getgrset(char *user) } idx += sprintf(tmpbuf+idx, "%u", gid_list[i]); - free_response(&response); + winbindd_free_response(&response); return tmpbuf; } @@ -412,7 +412,7 @@ static struct passwd *wb_aix_getpwuid(uid_t uid) pwd = fill_pwent(&response.data.pw); - free_response(&response); + winbindd_free_response(&response); logit("getpwuid gave ptr %p\n", pwd); @@ -445,7 +445,7 @@ static struct passwd *wb_aix_getpwnam(const char *name) pwd = fill_pwent(&response.data.pw); - free_response(&response); + winbindd_free_response(&response); logit("getpwnam gave ptr %p\n", pwd); @@ -482,7 +482,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) s = malloc(len+2); if (!s) { - free_response(&response); + winbindd_free_response(&response); errno = ENOMEM; return -1; } @@ -494,7 +494,7 @@ static int wb_aix_lsuser(char *attributes[], attrval_t results[], int size) results[0].attr_un.au_char = s; results[0].attr_flag = 0; - free_response(&response); + winbindd_free_response(&response); return 0; } @@ -530,7 +530,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) s = malloc(len+2); if (!s) { - free_response(&response); + winbindd_free_response(&response); errno = ENOMEM; return -1; } @@ -542,7 +542,7 @@ static int wb_aix_lsgroup(char *attributes[], attrval_t results[], int size) results[0].attr_un.au_char = s; results[0].attr_flag = 0; - free_response(&response); + winbindd_free_response(&response); return 0; } @@ -887,7 +887,7 @@ static int wb_aix_authenticate(char *user, char *pass, result = winbindd_request_response(WINBINDD_PAM_AUTH, &request, &response); - free_response(&response); + winbindd_free_response(&response); logit("auth result %d for '%s'\n", result, user); @@ -936,7 +936,7 @@ static int wb_aix_chpass(char *user, char *oldpass, char *newpass, char **messag result = winbindd_request_response(WINBINDD_PAM_CHAUTHTOK, &request, &response); - free_response(&response); + winbindd_free_response(&response); if (result == NSS_STATUS_SUCCESS) { errno = 0; -- cgit