summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2007-03-01 03:07:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:17 -0500
commit85f769dbb425722c2246b8d98a529aac6849ab7d (patch)
treefe1ebd6bb38fa0e54421bd1d79a4db24fef02e33 /source3
parent1e7ddfccd95fe9e064757f9cbac8ac465ba727cf (diff)
downloadsamba-85f769dbb425722c2246b8d98a529aac6849ab7d.tar.gz
samba-85f769dbb425722c2246b8d98a529aac6849ab7d.tar.bz2
samba-85f769dbb425722c2246b8d98a529aac6849ab7d.zip
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)
Diffstat (limited to 'source3')
-rw-r--r--source3/nsswitch/winbind_nss_aix.c79
1 files changed, 66 insertions, 13 deletions
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 <usersec.h>
+/* 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; i<n; i++ ) {
+ attrlist_t *a = malloc(sizeof(attrlist_t));
+
+ if ( !a ) {
+ /* this is bad. Just bail */
+ return NULL;
+ }
+
+ a->al_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;
}