summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-03-31 11:58:37 +1100
committerAndrew Tridgell <tridge@samba.org>2009-03-31 11:58:37 +1100
commit631e688c821b78d09d77f5940074800525c554aa (patch)
tree74473f1727ea0afa27d9c15e50e4638c4d8faf28 /source3/lib
parent13be4d7ff42bd2b8bf5702a499c482404e5cd164 (diff)
parent4b8e4ea7286f045effb6feb4c7bf8c5ef4ed2f9b (diff)
downloadsamba-631e688c821b78d09d77f5940074800525c554aa.tar.gz
samba-631e688c821b78d09d77f5940074800525c554aa.tar.bz2
samba-631e688c821b78d09d77f5940074800525c554aa.zip
Merge branch 'master' into wspp-schema
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/avahi.c275
-rw-r--r--source3/lib/dbwrap.c27
-rw-r--r--source3/lib/display_sec.c317
-rw-r--r--source3/lib/netapi/cm.c5
-rw-r--r--source3/lib/netapi/group.c10
-rw-r--r--source3/lib/netapi/user.c36
-rw-r--r--source3/lib/util_file.c2
-rw-r--r--source3/lib/wbclient.c12
8 files changed, 335 insertions, 349 deletions
diff --git a/source3/lib/avahi.c b/source3/lib/avahi.c
new file mode 100644
index 0000000000..269b329e64
--- /dev/null
+++ b/source3/lib/avahi.c
@@ -0,0 +1,275 @@
+/*
+ Unix SMB/CIFS implementation.
+ Connect avahi to lib/tevents
+ Copyright (C) Volker Lendecke 2009
+
+ 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/>.
+*/
+
+#include "includes.h"
+
+#include <avahi-common/watch.h>
+
+struct avahi_poll_context {
+ struct tevent_context *ev;
+ AvahiWatch **watches;
+ AvahiTimeout **timeouts;
+};
+
+struct AvahiWatch {
+ struct avahi_poll_context *ctx;
+ struct tevent_fd *fde;
+ int fd;
+ AvahiWatchEvent latest_event;
+ AvahiWatchCallback callback;
+ void *userdata;
+};
+
+struct AvahiTimeout {
+ struct avahi_poll_context *ctx;
+ struct tevent_timer *te;
+ AvahiTimeoutCallback callback;
+ void *userdata;
+};
+
+static uint16_t avahi_flags_map_to_tevent(AvahiWatchEvent event)
+{
+ return ((event & AVAHI_WATCH_IN) ? TEVENT_FD_READ : 0)
+ | ((event & AVAHI_WATCH_OUT) ? TEVENT_FD_WRITE : 0);
+}
+
+static void avahi_fd_handler(struct tevent_context *ev,
+ struct tevent_fd *fde, uint16_t flags,
+ void *private_data);
+
+static AvahiWatch *avahi_watch_new(const AvahiPoll *api, int fd,
+ AvahiWatchEvent event,
+ AvahiWatchCallback callback,
+ void *userdata)
+{
+ struct avahi_poll_context *ctx = talloc_get_type_abort(
+ api->userdata, struct avahi_poll_context);
+ int num_watches = talloc_array_length(ctx->watches);
+ AvahiWatch **tmp, *watch_ctx;
+
+ tmp = talloc_realloc(ctx, ctx->watches, AvahiWatch *, num_watches + 1);
+ if (tmp == NULL) {
+ return NULL;
+ }
+ ctx->watches = tmp;
+
+ watch_ctx = talloc(tmp, AvahiWatch);
+ if (watch_ctx == NULL) {
+ goto fail;
+ }
+ ctx->watches[num_watches] = watch_ctx;
+
+ watch_ctx->ctx = ctx;
+ watch_ctx->fde = tevent_add_fd(ctx->ev, watch_ctx, fd,
+ avahi_flags_map_to_tevent(event),
+ avahi_fd_handler, watch_ctx);
+ if (watch_ctx->fde == NULL) {
+ goto fail;
+ }
+ watch_ctx->callback = callback;
+ watch_ctx->userdata = userdata;
+ return watch_ctx;
+
+ fail:
+ TALLOC_FREE(watch_ctx);
+ ctx->watches = talloc_realloc(ctx, ctx->watches, AvahiWatch *,
+ num_watches);
+ return NULL;
+}
+
+static void avahi_fd_handler(struct tevent_context *ev,
+ struct tevent_fd *fde, uint16_t flags,
+ void *private_data)
+{
+ AvahiWatch *watch_ctx = talloc_get_type_abort(private_data, AvahiWatch);
+
+ watch_ctx->latest_event =
+ ((flags & TEVENT_FD_READ) ? AVAHI_WATCH_IN : 0)
+ | ((flags & TEVENT_FD_WRITE) ? AVAHI_WATCH_OUT : 0);
+
+ watch_ctx->callback(watch_ctx, watch_ctx->fd, watch_ctx->latest_event,
+ watch_ctx->userdata);
+}
+
+static void avahi_watch_update(AvahiWatch *w, AvahiWatchEvent event)
+{
+ tevent_fd_set_flags(w->fde, avahi_flags_map_to_tevent(event));
+}
+
+static AvahiWatchEvent avahi_watch_get_events(AvahiWatch *w)
+{
+ return w->latest_event;
+}
+
+static void avahi_watch_free(AvahiWatch *w)
+{
+ int i, num_watches;
+ AvahiWatch **watches = w->ctx->watches;
+ struct avahi_poll_context *ctx;
+
+ num_watches = talloc_array_length(watches);
+
+ for (i=0; i<num_watches; i++) {
+ if (w == watches[i]) {
+ break;
+ }
+ }
+ if (i == num_watches) {
+ return;
+ }
+ ctx = w->ctx;
+ TALLOC_FREE(w);
+ memmove(&watches[i], &watches[i+1],
+ sizeof(*watches) * (num_watches - i - 1));
+ ctx->watches = talloc_realloc(ctx, watches, AvahiWatch *,
+ num_watches - 1);
+}
+
+static void avahi_timeout_handler(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data);
+
+static AvahiTimeout *avahi_timeout_new(const AvahiPoll *api,
+ const struct timeval *tv,
+ AvahiTimeoutCallback callback,
+ void *userdata)
+{
+ struct avahi_poll_context *ctx = talloc_get_type_abort(
+ api->userdata, struct avahi_poll_context);
+ int num_timeouts = talloc_array_length(ctx->timeouts);
+ AvahiTimeout **tmp, *timeout_ctx;
+
+ tmp = talloc_realloc(ctx, ctx->timeouts, AvahiTimeout *,
+ num_timeouts + 1);
+ if (tmp == NULL) {
+ return NULL;
+ }
+ ctx->timeouts = tmp;
+
+ timeout_ctx = talloc(tmp, AvahiTimeout);
+ if (timeout_ctx == NULL) {
+ goto fail;
+ }
+ ctx->timeouts[num_timeouts] = timeout_ctx;
+
+ timeout_ctx->ctx = ctx;
+ if (tv == NULL) {
+ timeout_ctx->te = NULL;
+ } else {
+ timeout_ctx->te = tevent_add_timer(ctx->ev, timeout_ctx,
+ *tv, avahi_timeout_handler,
+ timeout_ctx);
+ if (timeout_ctx->te == NULL) {
+ goto fail;
+ }
+ }
+ timeout_ctx->callback = callback;
+ timeout_ctx->userdata = userdata;
+ return timeout_ctx;
+
+ fail:
+ TALLOC_FREE(timeout_ctx);
+ ctx->timeouts = talloc_realloc(ctx, ctx->timeouts, AvahiTimeout *,
+ num_timeouts);
+ return NULL;
+}
+
+static void avahi_timeout_handler(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data)
+{
+ AvahiTimeout *timeout_ctx = talloc_get_type_abort(
+ private_data, AvahiTimeout);
+
+ TALLOC_FREE(timeout_ctx->te);
+ timeout_ctx->callback(timeout_ctx, timeout_ctx->userdata);
+}
+
+static void avahi_timeout_update(AvahiTimeout *t, const struct timeval *tv)
+{
+ TALLOC_FREE(t->te);
+
+ if (tv == NULL) {
+ /*
+ * Disable this timer
+ */
+ return;
+ }
+
+ t->te = tevent_add_timer(t->ctx->ev, t, *tv, avahi_timeout_handler, t);
+ /*
+ * No failure mode defined here
+ */
+ SMB_ASSERT(t->te != NULL);
+}
+
+static void avahi_timeout_free(AvahiTimeout *t)
+{
+ int i, num_timeouts;
+ AvahiTimeout **timeouts = t->ctx->timeouts;
+ struct avahi_poll_context *ctx;
+
+ num_timeouts = talloc_array_length(timeouts);
+
+ for (i=0; i<num_timeouts; i++) {
+ if (t == timeouts[i]) {
+ break;
+ }
+ }
+ if (i == num_timeouts) {
+ return;
+ }
+ ctx = t->ctx;
+ TALLOC_FREE(t);
+ memmove(&timeouts[i], &timeouts[i+1],
+ sizeof(*timeouts) * (num_timeouts - i - 1));
+ ctx->timeouts = talloc_realloc(ctx, timeouts, AvahiTimeout *,
+ num_timeouts - 1);
+}
+
+struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev)
+{
+ struct AvahiPoll *result;
+ struct avahi_poll_context *ctx;
+
+ result = talloc(mem_ctx, struct AvahiPoll);
+ if (result == NULL) {
+ return result;
+ }
+ ctx = talloc_zero(result, struct avahi_poll_context);
+ if (ctx == NULL) {
+ TALLOC_FREE(result);
+ return NULL;
+ }
+ ctx->ev = ev;
+
+ result->watch_new = avahi_watch_new;
+ result->watch_update = avahi_watch_update;
+ result->watch_get_events = avahi_watch_get_events;
+ result->watch_free = avahi_watch_free;
+ result->timeout_new = avahi_timeout_new;
+ result->timeout_update = avahi_timeout_update;
+ result->timeout_free = avahi_timeout_free;
+ result->userdata = ctx;
+
+ return result;
+}
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c
index 5e7ce6099f..67c08a6085 100644
--- a/source3/lib/dbwrap.c
+++ b/source3/lib/dbwrap.c
@@ -65,6 +65,33 @@ static int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
return res;
}
+bool db_is_local(const char *name)
+{
+#ifdef CLUSTER_SUPPORT
+ const char *sockname = lp_ctdbd_socket();
+
+ if(!sockname || !*sockname) {
+ sockname = CTDB_PATH;
+ }
+
+ if (lp_clustering() && socket_exist(sockname)) {
+ const char *partname;
+ /* ctdb only wants the file part of the name */
+ partname = strrchr(name, '/');
+ if (partname) {
+ partname++;
+ } else {
+ partname = name;
+ }
+ /* allow ctdb for individual databases to be disabled */
+ if (lp_parm_bool(-1, "ctdb", partname, True)) {
+ return false;
+ }
+ }
+#endif
+ return true;
+}
+
/**
* open a database
*/
diff --git a/source3/lib/display_sec.c b/source3/lib/display_sec.c
deleted file mode 100644
index fe1ae77edd..0000000000
--- a/source3/lib/display_sec.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Samba utility functions
- Copyright (C) Andrew Tridgell 1992-1999
- Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
-
- 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/>.
-*/
-
-#include "includes.h"
-
-/****************************************************************************
-convert a security permissions into a string
-****************************************************************************/
-
-char *get_sec_mask_str(TALLOC_CTX *ctx, uint32 type)
-{
- char *typestr = talloc_strdup(ctx, "");
-
- if (!typestr) {
- return NULL;
- }
-
- if (type & GENERIC_ALL_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "Generic all access ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & GENERIC_EXECUTE_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "Generic execute access");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & GENERIC_WRITE_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "Generic write access ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & GENERIC_READ_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "Generic read access ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & MAXIMUM_ALLOWED_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "MAXIMUM_ALLOWED_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & SYSTEM_SECURITY_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "SYSTEM_SECURITY_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & SYNCHRONIZE_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "SYNCHRONIZE_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & WRITE_OWNER_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "WRITE_OWNER_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & WRITE_DAC_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "WRITE_DAC_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & READ_CONTROL_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "READ_CONTROL_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
- if (type & DELETE_ACCESS) {
- typestr = talloc_asprintf_append(typestr,
- "DELETE_ACCESS ");
- if (!typestr) {
- return NULL;
- }
- }
-
- printf("\t\tSpecific bits: 0x%lx\n", (unsigned long)type&SPECIFIC_RIGHTS_MASK);
-
- return typestr;
-}
-
-/****************************************************************************
- display sec_access structure
- ****************************************************************************/
-void display_sec_access(uint32_t *info)
-{
- char *mask_str = get_sec_mask_str(NULL, *info);
- printf("\t\tPermissions: 0x%x: %s\n", *info, mask_str ? mask_str : "");
- TALLOC_FREE(mask_str);
-}
-
-/****************************************************************************
- display sec_ace flags
- ****************************************************************************/
-void display_sec_ace_flags(uint8_t flags)
-{
- if (flags & SEC_ACE_FLAG_OBJECT_INHERIT)
- printf("SEC_ACE_FLAG_OBJECT_INHERIT ");
- if (flags & SEC_ACE_FLAG_CONTAINER_INHERIT)
- printf(" SEC_ACE_FLAG_CONTAINER_INHERIT ");
- if (flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT)
- printf("SEC_ACE_FLAG_NO_PROPAGATE_INHERIT ");
- if (flags & SEC_ACE_FLAG_INHERIT_ONLY)
- printf("SEC_ACE_FLAG_INHERIT_ONLY ");
- if (flags & SEC_ACE_FLAG_INHERITED_ACE)
- printf("SEC_ACE_FLAG_INHERITED_ACE ");
-/* if (flags & SEC_ACE_FLAG_VALID_INHERIT)
- printf("SEC_ACE_FLAG_VALID_INHERIT "); */
- if (flags & SEC_ACE_FLAG_SUCCESSFUL_ACCESS)
- printf("SEC_ACE_FLAG_SUCCESSFUL_ACCESS ");
- if (flags & SEC_ACE_FLAG_FAILED_ACCESS)
- printf("SEC_ACE_FLAG_FAILED_ACCESS ");
-
- printf("\n");
-}
-
-/****************************************************************************
- display sec_ace object
- ****************************************************************************/
-static void disp_sec_ace_object(struct security_ace_object *object)
-{
- if (object->flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
- printf("Object type: SEC_ACE_OBJECT_TYPE_PRESENT\n");
- printf("Object GUID: %s\n", GUID_string(talloc_tos(),
- &object->type.type));
- }
- if (object->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
- printf("Object type: SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT\n");
- printf("Object GUID: %s\n", GUID_string(talloc_tos(),
- &object->inherited_type.inherited_type));
- }
-}
-
-/****************************************************************************
- display sec_ace structure
- ****************************************************************************/
-void display_sec_ace(SEC_ACE *ace)
-{
- fstring sid_str;
-
- printf("\tACE\n\t\ttype: ");
- switch (ace->type) {
- case SEC_ACE_TYPE_ACCESS_ALLOWED:
- printf("ACCESS ALLOWED");
- break;
- case SEC_ACE_TYPE_ACCESS_DENIED:
- printf("ACCESS DENIED");
- break;
- case SEC_ACE_TYPE_SYSTEM_AUDIT:
- printf("SYSTEM AUDIT");
- break;
- case SEC_ACE_TYPE_SYSTEM_ALARM:
- printf("SYSTEM ALARM");
- break;
- case SEC_ACE_TYPE_ALLOWED_COMPOUND:
- printf("SEC_ACE_TYPE_ALLOWED_COMPOUND");
- break;
- case SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT:
- printf("SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT");
- break;
- case SEC_ACE_TYPE_ACCESS_DENIED_OBJECT:
- printf("SEC_ACE_TYPE_ACCESS_DENIED_OBJECT");
- break;
- case SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT:
- printf("SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT");
- break;
- case SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT:
- printf("SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT");
- break;
- default:
- printf("????");
- break;
- }
-
- printf(" (%d) flags: 0x%02x ", ace->type, ace->flags);
- display_sec_ace_flags(ace->flags);
- display_sec_access(&ace->access_mask);
- sid_to_fstring(sid_str, &ace->trustee);
- printf("\t\tSID: %s\n\n", sid_str);
-
- if (sec_ace_object(ace->type)) {
- disp_sec_ace_object(&ace->object.object);
- }
-
-}
-
-/****************************************************************************
- display sec_acl structure
- ****************************************************************************/
-void display_sec_acl(SEC_ACL *sec_acl)
-{
- int i;
-
- printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
- printf("\t---\n");
-
- if (sec_acl->size != 0 && sec_acl->num_aces != 0) {
- for (i = 0; i < sec_acl->num_aces; i++) {
- display_sec_ace(&sec_acl->aces[i]);
- }
- }
-}
-
-void display_acl_type(uint16 type)
-{
- fstring typestr="";
-
- typestr[0] = 0;
-
- if (type & SEC_DESC_OWNER_DEFAULTED) /* 0x0001 */
- fstrcat(typestr, "SEC_DESC_OWNER_DEFAULTED ");
- if (type & SEC_DESC_GROUP_DEFAULTED) /* 0x0002 */
- fstrcat(typestr, "SEC_DESC_GROUP_DEFAULTED ");
- if (type & SEC_DESC_DACL_PRESENT) /* 0x0004 */
- fstrcat(typestr, "SEC_DESC_DACL_PRESENT ");
- if (type & SEC_DESC_DACL_DEFAULTED) /* 0x0008 */
- fstrcat(typestr, "SEC_DESC_DACL_DEFAULTED ");
- if (type & SEC_DESC_SACL_PRESENT) /* 0x0010 */
- fstrcat(typestr, "SEC_DESC_SACL_PRESENT ");
- if (type & SEC_DESC_SACL_DEFAULTED) /* 0x0020 */
- fstrcat(typestr, "SEC_DESC_SACL_DEFAULTED ");
- if (type & SEC_DESC_DACL_TRUSTED) /* 0x0040 */
- fstrcat(typestr, "SEC_DESC_DACL_TRUSTED ");
- if (type & SEC_DESC_SERVER_SECURITY) /* 0x0080 */
- fstrcat(typestr, "SEC_DESC_SERVER_SECURITY ");
- if (type & SEC_DESC_DACL_AUTO_INHERIT_REQ) /* 0x0100 */
- fstrcat(typestr, "SEC_DESC_DACL_AUTO_INHERIT_REQ ");
- if (type & SEC_DESC_SACL_AUTO_INHERIT_REQ) /* 0x0200 */
- fstrcat(typestr, "SEC_DESC_SACL_AUTO_INHERIT_REQ ");
- if (type & SEC_DESC_DACL_AUTO_INHERITED) /* 0x0400 */
- fstrcat(typestr, "SEC_DESC_DACL_AUTO_INHERITED ");
- if (type & SEC_DESC_SACL_AUTO_INHERITED) /* 0x0800 */
- fstrcat(typestr, "SEC_DESC_SACL_AUTO_INHERITED ");
- if (type & SEC_DESC_DACL_PROTECTED) /* 0x1000 */
- fstrcat(typestr, "SEC_DESC_DACL_PROTECTED ");
- if (type & SEC_DESC_SACL_PROTECTED) /* 0x2000 */
- fstrcat(typestr, "SEC_DESC_SACL_PROTECTED ");
- if (type & SEC_DESC_RM_CONTROL_VALID) /* 0x4000 */
- fstrcat(typestr, "SEC_DESC_RM_CONTROL_VALID ");
- if (type & SEC_DESC_SELF_RELATIVE) /* 0x8000 */
- fstrcat(typestr, "SEC_DESC_SELF_RELATIVE ");
-
- printf("type: 0x%04x: %s\n", type, typestr);
-}
-
-/****************************************************************************
- display sec_desc structure
- ****************************************************************************/
-void display_sec_desc(SEC_DESC *sec)
-{
- fstring sid_str;
-
- if (!sec) {
- printf("NULL\n");
- return;
- }
-
- printf("revision: %d\n", sec->revision);
- display_acl_type(sec->type);
-
- if (sec->sacl) {
- printf("SACL\n");
- display_sec_acl(sec->sacl);
- }
-
- if (sec->dacl) {
- printf("DACL\n");
- display_sec_acl(sec->dacl);
- }
-
- if (sec->owner_sid) {
- sid_to_fstring(sid_str, sec->owner_sid);
- printf("\tOwner SID:\t%s\n", sid_str);
- }
-
- if (sec->group_sid) {
- sid_to_fstring(sid_str, sec->group_sid);
- printf("\tGroup SID:\t%s\n", sid_str);
- }
-}
diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c
index b676ae63dd..d28b2b2126 100644
--- a/source3/lib/netapi/cm.c
+++ b/source3/lib/netapi/cm.c
@@ -57,6 +57,11 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx,
false, false,
PROTOCOL_NT1,
0, 0x20);
+ if (cli_ipc) {
+ cli_set_username(cli_ipc, ctx->username);
+ cli_set_password(cli_ipc, ctx->password);
+ cli_set_domain(cli_ipc, ctx->workgroup);
+ }
TALLOC_FREE(auth_info);
if (!cli_ipc) {
diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c
index 189902a78e..c09632a857 100644
--- a/source3/lib/netapi/group.c
+++ b/source3/lib/netapi/group.c
@@ -1276,6 +1276,7 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx,
*r->out.buffer = NULL;
*r->out.entries_read = 0;
+ *r->out.total_entries = 0;
switch (r->in.level) {
case 0:
@@ -1364,13 +1365,8 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx,
}
}
- if (r->out.entries_read) {
- *r->out.entries_read = entries_read;
- }
-
- if (r->out.total_entries) {
- *r->out.total_entries = entries_read;
- }
+ *r->out.entries_read = entries_read;
+ *r->out.total_entries = entries_read;
werr = WERR_OK;
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index 8cc65a6e9e..1cbb883169 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -1497,6 +1497,9 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx,
NTSTATUS status = NT_STATUS_OK;
WERROR werr;
+ WERROR werr_tmp;
+
+ *r->out.entries_read = 0;
ZERO_STRUCT(connect_handle);
ZERO_STRUCT(domain_handle);
@@ -1540,15 +1543,18 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx,
&total_size,
&returned_size,
&info);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = ntstatus_to_werror(status);
+ if (NT_STATUS_IS_ERR(status)) {
goto done;
}
- werr = convert_samr_dispinfo_to_NET_DISPLAY(ctx, &info,
- r->in.level,
- r->out.entries_read,
- r->out.buffer);
+ werr_tmp = convert_samr_dispinfo_to_NET_DISPLAY(ctx, &info,
+ r->in.level,
+ r->out.entries_read,
+ r->out.buffer);
+ if (!W_ERROR_IS_OK(werr_tmp)) {
+ werr = werr_tmp;
+ }
done:
/* if last query */
if (NT_STATUS_IS_OK(status) ||
@@ -2806,6 +2812,7 @@ WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx,
*r->out.buffer = NULL;
*r->out.entries_read = 0;
+ *r->out.total_entries = 0;
switch (r->in.level) {
case 0:
@@ -2899,12 +2906,8 @@ WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx,
}
}
- if (r->out.entries_read) {
- *r->out.entries_read = entries_read;
- }
- if (r->out.total_entries) {
- *r->out.total_entries = entries_read;
- }
+ *r->out.entries_read = entries_read;
+ *r->out.total_entries = entries_read;
done:
if (ctx->disable_policy_handle_cache) {
@@ -3242,6 +3245,7 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx,
*r->out.buffer = NULL;
*r->out.entries_read = 0;
+ *r->out.total_entries = 0;
switch (r->in.level) {
case 0:
@@ -3402,12 +3406,8 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx,
}
}
- if (r->out.entries_read) {
- *r->out.entries_read = entries_read;
- }
- if (r->out.total_entries) {
- *r->out.total_entries = entries_read;
- }
+ *r->out.entries_read = entries_read;
+ *r->out.total_entries = entries_read;
done:
if (ctx->disable_policy_handle_cache) {
diff --git a/source3/lib/util_file.c b/source3/lib/util_file.c
index c5a9b7c29a..50ff844762 100644
--- a/source3/lib/util_file.c
+++ b/source3/lib/util_file.c
@@ -39,7 +39,7 @@ static char *file_pload(const char *syscmd, size_t *size)
total = 0;
while ((n = read(fd, buf, sizeof(buf))) > 0) {
- p = (char *)SMB_REALLOC(p, total + n + 1);
+ p = talloc_realloc(NULL, p, char, total + n + 1);
if (!p) {
DEBUG(0,("file_pload: failed to expand buffer!\n"));
close(fd);
diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c
index 3cf992c7de..c22e168454 100644
--- a/source3/lib/wbclient.c
+++ b/source3/lib/wbclient.c
@@ -449,8 +449,8 @@ static void wb_open_pipe_connect_nonpriv_done(struct tevent_req *subreq)
ZERO_STRUCT(state->wb_req);
state->wb_req.cmd = WINBINDD_INTERFACE_VERSION;
- subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd,
- &state->wb_req);
+ subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->queue,
+ state->wb_ctx->fd, &state->wb_req);
if (tevent_req_nomem(subreq, req)) {
return;
}
@@ -480,8 +480,8 @@ static void wb_open_pipe_ping_done(struct tevent_req *subreq)
state->wb_req.cmd = WINBINDD_PRIV_PIPE_DIR;
- subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd,
- &state->wb_req);
+ subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->queue,
+ state->wb_ctx->fd, &state->wb_req);
if (tevent_req_nomem(subreq, req)) {
return;
}
@@ -673,8 +673,8 @@ static void wb_trans_connect_done(struct tevent_req *subreq)
return;
}
- subreq = wb_int_trans_send(state, state->ev, NULL, state->wb_ctx->fd,
- state->wb_req);
+ subreq = wb_int_trans_send(state, state->ev, state->wb_ctx->queue,
+ state->wb_ctx->fd, state->wb_req);
if (tevent_req_nomem(subreq, req)) {
return;
}