Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 02:19:08 +0000 (04:19 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 24 Oct 2008 02:19:08 +0000 (04:19 +0200)
12 files changed:
librpc/idl/krb5pac.idl
source3/include/includes.h
source3/include/proto.h
source3/include/rpc_svcctl.h
source3/include/services.h [new file with mode: 0644]
source3/lib/interface.c
source3/lib/netapi/tests/netgroup.c
source3/lib/netapi/tests/netuser.c
source3/librpc/gen_ndr/krb5pac.h
source3/librpc/gen_ndr/ndr_krb5pac.c
source3/rpc_server/srv_samr_nt.c
source3/winbindd/winbindd_cm.c

index a498b795f8e0ec384a69db2c8153b38936822ec6..24c55b8541a7a44ebce4775734cbfe953f6669ab 100644 (file)
@@ -25,7 +25,7 @@ interface krb5pac
                [flag(NDR_REMAINING)] DATA_BLOB signature;
        } PAC_SIGNATURE_DATA;
 
-       typedef [gensize] struct {
+       typedef struct {
                netr_SamInfo3 info3;
                dom_sid2 *res_group_dom_sid;
                samr_RidWithAttributeArray res_groups;
index 035d46fe0aa78e790f77f65b3a62729a6e172f16..24e33c172009a565d859624fe4f5353cc923c8c7 100644 (file)
@@ -659,6 +659,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
 #include "async_req.h"
 #include "async_smb.h"
 #include "async_sock.h"
+#include "services.h"
 
 #include "lib/smbconf/smbconf.h"
 
index 7a5cd3b07eb1130b70147102f240175d1c9d2a08..83cd740a788d1004997055ef4fe4ab2e4d5c0f63 100644 (file)
@@ -1507,7 +1507,7 @@ char *print_sockaddr(char *dest,
                        const struct sockaddr_storage *psa);
 char *print_canonical_sockaddr(TALLOC_CTX *ctx,
                        const struct sockaddr_storage *pss);
-void set_sockaddr_port(struct sockaddr_storage *psa, uint16 port);
+void set_sockaddr_port(struct sockaddr *psa, uint16_t port);
 const char *client_name(int fd);
 const char *client_addr(int fd, char *addr, size_t addrlen);
 const char *client_socket_addr(int fd, char *addr, size_t addr_len);
index 0e31a53e32456788d8e66e9d699736d08d540ba9..27858405e7c6f97ceeb1c9a7ab169d3fbec4c164 100644 (file)
 
 #define SVC_STATUS_PROCESS_INFO                 0x00000000
 
-/* where we assume the location of the service control scripts */
-#define SVCCTL_SCRIPT_DIR  "svcctl"
-
 /* utility structures for RPCs */
 
 /*
@@ -159,26 +156,6 @@ typedef struct {
         SC_ACTION *actions;
 } SERVICE_FAILURE_ACTIONS;
 
-/* 
- * dispatch table of functions to handle the =ServiceControl API
- */ 
-typedef struct {
-       /* functions for enumerating subkeys and values */      
-       WERROR  (*stop_service)( const char *service, SERVICE_STATUS *status );
-       WERROR  (*start_service) ( const char *service );
-       WERROR  (*service_status)( const char *service, SERVICE_STATUS *status );
-} SERVICE_CONTROL_OPS;
-
-/* structure to store the service handle information  */
-
-typedef struct _ServiceInfo {
-       uint8                   type;
-       char                    *name;
-       uint32                  access_granted;
-       SERVICE_CONTROL_OPS     *ops;
-} SERVICE_INFO;
-
 
 /* rpc structures */
 
diff --git a/source3/include/services.h b/source3/include/services.h
new file mode 100644 (file)
index 0000000..8c2a0cc
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+   Unix SMB/CIFS implementation.
+   SMB parameters and setup
+   Copyright (C) Andrew Tridgell              1992-1997,
+   Copyright (C) Gerald (Jerry) Carter        2005
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program 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 General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SERVICES_H /* _SERVICES_H */
+#define _SERVICES_H
+
+/* where we assume the location of the service control scripts */
+#define SVCCTL_SCRIPT_DIR  "svcctl"
+
+/*
+ * dispatch table of functions to handle the =ServiceControl API
+ */
+
+typedef struct {
+       /* functions for enumerating subkeys and values */
+       WERROR  (*stop_service)( const char *service, SERVICE_STATUS *status );
+       WERROR  (*start_service) ( const char *service );
+       WERROR  (*service_status)( const char *service, SERVICE_STATUS *status );
+} SERVICE_CONTROL_OPS;
+
+/* structure to store the service handle information  */
+
+typedef struct _ServiceInfo {
+       uint8                   type;
+       char                    *name;
+       uint32                  access_granted;
+       SERVICE_CONTROL_OPS     *ops;
+} SERVICE_INFO;
+
+#endif /* _SERICES_H */
+
index 4536990d284a61adfed58b3cd405e99cfe6913be..f533ec92c780bd1ae8f0039ff0fb4eff5c9813cd 100644 (file)
@@ -289,7 +289,7 @@ const struct sockaddr_storage *iface_ip(const struct sockaddr *ip)
 
 bool iface_local(const struct sockaddr *ip)
 {
-       return iface_find(ip, True) ? true : false;
+       return iface_find(ip, true) ? true : false;
 }
 
 /****************************************************************************
index 51a21b3bf58b88059a07b0e2cce1f443cfdd644a..e43520ad1ae39f300ed5e73d35b8f2717fe59350 100644 (file)
@@ -127,6 +127,152 @@ static NET_API_STATUS test_netgroupenum(const char *hostname,
        return 0;
 }
 
+static NET_API_STATUS test_netgroupgetusers(const char *hostname,
+                                           uint32_t level,
+                                           const char *groupname,
+                                           const char *username)
+{
+       NET_API_STATUS status;
+       uint32_t entries_read = 0;
+       uint32_t total_entries = 0;
+       uint32_t resume_handle = 0;
+       int found_user = 0;
+       const char *current_name = NULL;
+       uint8_t *buffer = NULL;
+       int i;
+
+       struct GROUP_USERS_INFO_0 *info0 = NULL;
+       struct GROUP_USERS_INFO_1 *info1 = NULL;
+
+       printf("testing NetGroupGetUsers level %d\n", level);
+
+       do {
+               status = NetGroupGetUsers(hostname,
+                                         groupname,
+                                         level,
+                                         &buffer,
+                                         (uint32_t)-1,
+                                         &entries_read,
+                                         &total_entries,
+                                         &resume_handle);
+               if (status == 0 || status == ERROR_MORE_DATA) {
+
+                       switch (level) {
+                               case 0:
+                                       info0 = (struct GROUP_USERS_INFO_0 *)buffer;
+                                       break;
+                               case 1:
+                                       info1 = (struct GROUP_USERS_INFO_1 *)buffer;
+                                       break;
+                               default:
+                                       break;
+                       }
+                       for (i=0; i<entries_read; i++) {
+                               switch (level) {
+                                       case 0:
+                                               current_name = info0->grui0_name;
+                                               break;
+                                       case 1:
+                                               current_name = info1->grui1_name;
+                                               break;
+                                       default:
+                                               break;
+                               }
+
+                               if (username && strcasecmp(current_name, username) == 0) {
+                                       found_user = 1;
+                               }
+
+                               switch (level) {
+                                       case 0:
+                                               info0++;
+                                               break;
+                                       case 1:
+                                               info1++;
+                                               break;
+                               }
+                       }
+                       NetApiBufferFree(buffer);
+               }
+       } while (status == ERROR_MORE_DATA);
+
+       if (status) {
+               return status;
+       }
+
+       if (username && !found_user) {
+               printf("failed to get user\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static NET_API_STATUS test_netgroupsetusers(const char *hostname,
+                                           const char *groupname,
+                                           uint32_t level,
+                                           size_t num_entries,
+                                           const char **names)
+{
+       NET_API_STATUS status;
+       uint8_t *buffer = NULL;
+       int i = 0;
+       size_t buf_size = 0;
+
+       struct GROUP_USERS_INFO_0 *g0 = NULL;
+       struct GROUP_USERS_INFO_1 *g1 = NULL;
+
+       printf("testing NetGroupSetUsers level %d\n", level);
+
+       switch (level) {
+               case 0:
+                       buf_size = sizeof(struct GROUP_USERS_INFO_0) * num_entries;
+
+                       status = NetApiBufferAllocate(buf_size, (void **)&g0);
+                       if (status) {
+                               goto out;
+                       }
+
+                       for (i=0; i<num_entries; i++) {
+                               g0[i].grui0_name = names[i];
+                       }
+
+                       buffer = (uint8_t *)g0;
+                       break;
+               case 1:
+                       buf_size = sizeof(struct GROUP_USERS_INFO_1) * num_entries;
+
+                       status = NetApiBufferAllocate(buf_size, (void **)&g1);
+                       if (status) {
+                               goto out;
+                       }
+
+                       for (i=0; i<num_entries; i++) {
+                               g1[i].grui1_name = names[i];
+                       }
+
+                       buffer = (uint8_t *)g1;
+                       break;
+               default:
+                       break;
+       }
+
+       /* NetGroupSetUsers */
+
+       status = NetGroupSetUsers(hostname,
+                                 groupname,
+                                 level,
+                                 buffer,
+                                 num_entries);
+       if (status) {
+               goto out;
+       }
+
+ out:
+       NetApiBufferFree(buffer);
+       return status;
+}
+
 NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
                                const char *hostname)
 {
@@ -137,6 +283,7 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
        uint32_t parm_err = 0;
        uint32_t levels[] = { 0, 1, 2, 3};
        uint32_t enum_levels[] = { 0, 1, 2, 3};
+       uint32_t getmem_levels[] = { 0, 1};
        int i;
 
        printf("NetGroup tests\n");
@@ -201,9 +348,16 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
        printf("testing NetGroupSetInfo level 0\n");
 
        status = NetGroupSetInfo(hostname, groupname, 0, (uint8_t *)&g0, &parm_err);
-       if (status) {
-               NETAPI_STATUS(ctx, status, "NetGroupSetInfo");
-               goto out;
+       switch (status) {
+               case 0:
+                       break;
+               case 50: /* not supported */
+               case 124: /* not implemented */
+                       groupname2 = groupname;
+                       goto skip_rename;
+               default:
+                       NETAPI_STATUS(ctx, status, "NetGroupSetInfo");
+                       goto out;
        }
 
        /* should not exist anymore */
@@ -214,6 +368,7 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
                goto out;
        }
 
+ skip_rename:
        /* query info */
 
        for (i=0; i<ARRAY_SIZE(levels); i++) {
@@ -233,6 +388,17 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
                goto out;
        }
 
+       /* should not be member */
+
+       for (i=0; i<ARRAY_SIZE(getmem_levels); i++) {
+
+               status = test_netgroupgetusers(hostname, getmem_levels[i], groupname2, NULL);
+               if (status) {
+                       NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+                       goto out;
+               }
+       }
+
        printf("testing NetGroupAddUser\n");
 
        status = NetGroupAddUser(hostname, groupname2, username);
@@ -241,6 +407,17 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
                goto out;
        }
 
+       /* should be member */
+
+       for (i=0; i<ARRAY_SIZE(getmem_levels); i++) {
+
+               status = test_netgroupgetusers(hostname, getmem_levels[i], groupname2, username);
+               if (status) {
+                       NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+                       goto out;
+               }
+       }
+
        printf("testing NetGroupDelUser\n");
 
        status = NetGroupDelUser(hostname, groupname2, username);
@@ -249,6 +426,46 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
                goto out;
        }
 
+       /* should not be member */
+
+       status = test_netgroupgetusers(hostname, 0, groupname2, NULL);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+               goto out;
+       }
+
+       /* set it again via exlicit member set */
+
+       status = test_netgroupsetusers(hostname, groupname2, 0, 1, &username);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetGroupSetUsers");
+               goto out;
+       }
+
+       /* should be member */
+
+       status = test_netgroupgetusers(hostname, 0, groupname2, username);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+               goto out;
+       }
+#if 0
+       /* wipe out member list */
+
+       status = test_netgroupsetusers(hostname, groupname2, 0, 0, NULL);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetGroupSetUsers");
+               goto out;
+       }
+
+       /* should not be member */
+
+       status = test_netgroupgetusers(hostname, 0, groupname2, NULL);
+       if (status) {
+               NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+               goto out;
+       }
+#endif
        status = NetUserDel(hostname, username);
        if (status) {
                NETAPI_STATUS(ctx, status, "NetUserDel");
index 7bbc5ca3479d245d5da63e9d2d9831fcebf70b80..41f794bf340b307b017a7f9f5b2777788dec425c 100644 (file)
@@ -449,6 +449,10 @@ NET_API_STATUS netapitest_user(struct libnetapi_ctx *ctx,
 
        printf("NetUser tests succeeded\n");
  out:
+       /* cleanup */
+       NetUserDel(hostname, username);
+       NetUserDel(hostname, username2);
+
        if (status != 0) {
                printf("NetUser testsuite failed with: %s\n",
                        libnetapi_get_error_string(ctx, status));
index 7ec3e95d70d386b8978b16dc5dbe0c7b777b114a..73bd0d95bb1fd97c1f62b6fd3853e4e5c210123e 100644 (file)
@@ -24,7 +24,7 @@ struct PAC_LOGON_INFO {
        struct netr_SamInfo3 info3;
        struct dom_sid2 *res_group_dom_sid;/* [unique] */
        struct samr_RidWithAttributeArray res_groups;
-}/* [gensize] */;
+};
 
 struct PAC_UNKNOWN_12 {
        uint16_t upn_size;/* [value(2*strlen_m(upn_name))] */
index f9e93e52102eae34b32c437929380ae9ebf7ed9f..125fb7eb77f67fab9834fb6d13a880f0ed1c8be0 100644 (file)
@@ -161,11 +161,6 @@ _PUBLIC_ void ndr_print_PAC_LOGON_INFO(struct ndr_print *ndr, const char *name,
        ndr->depth--;
 }
 
-static size_t ndr_size_PAC_LOGON_INFO(const struct PAC_LOGON_INFO *r, int flags)
-{
-       return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_PAC_LOGON_INFO);
-}
-
 _PUBLIC_ enum ndr_err_code ndr_push_PAC_LOGON_INFO_CTR(struct ndr_push *ndr, int ndr_flags, const struct PAC_LOGON_INFO_CTR *r)
 {
        if (ndr_flags & NDR_SCALARS) {
index 0f82675d3d963d27be29b6eb9ee41f5ec2febff1..386e081d4aa7de11a06f8fa76687fe8df583ec45 100644 (file)
@@ -1774,66 +1774,6 @@ NTSTATUS _samr_QueryAliasInfo(pipes_struct *p,
        return NT_STATUS_OK;
 }
 
-#if 0
-/*******************************************************************
- samr_reply_lookup_ids
- ********************************************************************/
-
- uint32 _samr_lookup_ids(pipes_struct *p, SAMR_Q_LOOKUP_IDS *q_u, SAMR_R_LOOKUP_IDS *r_u)
-{
-    uint32 rid[MAX_SAM_ENTRIES];
-    int num_rids = q_u->num_sids1;
-
-    r_u->status = NT_STATUS_OK;
-
-    DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__));
-
-    if (num_rids > MAX_SAM_ENTRIES) {
-        num_rids = MAX_SAM_ENTRIES;
-        DEBUG(5,("_samr_lookup_ids: truncating entries to %d\n", num_rids));
-    }
-
-#if 0
-    int i;
-    SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids);
-
-    for (i = 0; i < num_rids && status == 0; i++)
-    {
-        struct sam_passwd *sam_pass;
-        fstring user_name;
-
-
-        fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer,
-                                    q_u->uni_user_name[i].uni_str_len));
-
-        /* find the user account */
-        become_root();
-        sam_pass = get_smb21pwd_entry(user_name, 0);
-        unbecome_root();
-
-        if (sam_pass == NULL)
-        {
-            status = 0xC0000000 | NT_STATUS_NO_SUCH_USER;
-            rid[i] = 0;
-        }
-        else
-        {
-            rid[i] = sam_pass->user_rid;
-        }
-    }
-#endif
-
-    num_rids = 1;
-    rid[0] = BUILTIN_ALIAS_RID_USERS;
-
-    init_samr_r_lookup_ids(&r_u, num_rids, rid, NT_STATUS_OK);
-
-    DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__));
-
-    return r_u->status;
-}
-#endif
-
 /*******************************************************************
  _samr_LookupNames
  ********************************************************************/
@@ -5339,6 +5279,9 @@ NTSTATUS _samr_SetGroupInfo(pipes_struct *p,
                case 1:
                        fstrcpy(map.comment, r->in.info->all.description.string);
                        break;
+               case 2:
+                       /* group rename is not supported yet */
+                       return NT_STATUS_NOT_SUPPORTED;
                case 4:
                        fstrcpy(map.comment, r->in.info->description.string);
                        break;
index 05c39f8f2b6be8029540e1a96b31faf2ef8dcd27..9268542da6f71ff8829fb8d664a160773c2af4fa 100644 (file)
@@ -1064,7 +1064,7 @@ static bool add_sockaddr_to_array(TALLOC_CTX *mem_ctx,
        }
 
        (*addrs)[*num] = *pss;
-       set_sockaddr_port(&(*addrs)[*num], port);
+       set_sockaddr_port((struct sockaddr *)&(*addrs)[*num], port);
 
        *num += 1;
        return True;