summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-02-25 12:49:37 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-02-25 12:49:37 +0100
commit258ae4cec596631b758fb17c170c4494e4db8a8e (patch)
tree5c9ef9246eef3af3b744e862d0e5314a4686304e
parentfff055f8e33a8f0bbb5e7cc5b77d6251bf37e0cf (diff)
parenta041d9061922b1a90e5b5047af77934d908afdd5 (diff)
downloadsamba-258ae4cec596631b758fb17c170c4494e4db8a8e.tar.gz
samba-258ae4cec596631b758fb17c170c4494e4db8a8e.tar.bz2
samba-258ae4cec596631b758fb17c170c4494e4db8a8e.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Conflicts: source4/scripting/python/samba/provision.py
-rw-r--r--WHATSNEW4.txt102
-rw-r--r--examples/VFS/skel_opaque.c6
-rw-r--r--examples/VFS/skel_transparent.c6
-rw-r--r--lib/async_req/async_sock.c583
-rw-r--r--lib/async_req/async_sock.h46
-rw-r--r--lib/replace/getifaddrs.c9
-rw-r--r--lib/tevent/tevent.h1
-rw-r--r--lib/util/become_daemon.c6
-rw-r--r--lib/util/system.c29
-rw-r--r--lib/util/tevent_unix.c46
-rw-r--r--lib/util/tevent_unix.h27
-rw-r--r--lib/util/util.h10
-rw-r--r--libcli/ldap/config.mk15
-rw-r--r--libcli/ldap/ldap_errors.h (renamed from source4/libcli/ldap/ldap_errors.h)2
-rw-r--r--libcli/ldap/ldap_message.c (renamed from source4/libcli/ldap/ldap.c)230
-rw-r--r--libcli/ldap/ldap_message.h (renamed from source3/include/smb_ldap.h)116
-rw-r--r--libcli/ldap/ldap_ndr.c (renamed from source4/libcli/ldap/ldap_ndr.c)2
-rw-r--r--libcli/ldap/ldap_ndr.h (renamed from source4/libcli/ldap/ldap_ndr.h)0
-rw-r--r--libcli/util/doserr.c1
-rw-r--r--librpc/gen_ndr/cli_spoolss.c2
-rw-r--r--librpc/gen_ndr/cli_spoolss.h2
-rw-r--r--librpc/gen_ndr/ndr_spoolss.c362
-rw-r--r--librpc/gen_ndr/ndr_spoolss.h31
-rw-r--r--librpc/gen_ndr/spoolss.h70
-rw-r--r--librpc/gen_ndr/srv_spoolss.c4
-rw-r--r--librpc/idl/spoolss.idl61
-rw-r--r--librpc/ndr/ndr_spoolss_buf.c478
-rw-r--r--librpc/ndr/ndr_spoolss_buf.h3
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm19
-rw-r--r--selftest/target/Samba4.pm59
-rw-r--r--source3/Makefile.in36
-rw-r--r--source3/auth/auth_wbc.c (renamed from source3/auth/auth_onefs_wb.c)32
-rw-r--r--source3/client/client.c6
-rw-r--r--source3/client/mount.cifs.c40
-rw-r--r--source3/configure.in8
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/proto.h106
-rw-r--r--source3/include/rpc_spoolss.h219
-rw-r--r--source3/include/smbprofile.h28
-rw-r--r--source3/lib/fault.c1
-rw-r--r--source3/lib/ldap_debug_handler.c4
-rw-r--r--source3/lib/secdesc.c63
-rw-r--r--source3/lib/smbldap.c2
-rw-r--r--source3/lib/system.c32
-rw-r--r--source3/lib/tdb_validate.c5
-rw-r--r--source3/lib/util.c99
-rw-r--r--source3/lib/util_sock.c29
-rw-r--r--source3/lib/wb_reqtrans.c401
-rw-r--r--source3/lib/wbclient.c62
-rw-r--r--source3/libsmb/cliconnect.c25
-rw-r--r--source3/libsmb/libsmb_dir.c2
-rw-r--r--source3/libsmb/nmblib.c15
-rw-r--r--source3/modules/onefs.h2
-rw-r--r--source3/modules/onefs_acl.c18
-rw-r--r--source3/modules/onefs_cbrl.c26
-rw-r--r--source3/modules/onefs_streams.c16
-rw-r--r--source3/modules/onefs_system.c42
-rw-r--r--source3/modules/vfs_extd_audit.c8
-rw-r--r--source3/nmbd/nmbd.c14
-rw-r--r--source3/passdb/pdb_wbc_sam.c (renamed from source3/passdb/pdb_onefs_sam.c)131
-rw-r--r--source3/printing/notify.c4
-rw-r--r--source3/printing/nt_printing.c80
-rw-r--r--source3/profile/profile.c7
-rw-r--r--source3/rpc_client/cli_spoolss.c408
-rw-r--r--source3/rpc_parse/parse_spoolss.c1286
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c38
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c127
-rw-r--r--source3/rpcclient/cmd_spoolss.c459
-rw-r--r--source3/smbd/open.c2
-rw-r--r--source3/smbd/oplock_onefs.c5
-rw-r--r--source3/smbd/posix_acls.c52
-rw-r--r--source3/smbd/server.c2
-rw-r--r--source3/smbd/sesssetup.c4
-rw-r--r--source3/smbd/trans2.c12
-rw-r--r--source3/utils/net_rpc_printer.c421
-rw-r--r--source3/utils/smbfilter.c11
-rw-r--r--source3/utils/smbget.c6
-rw-r--r--source3/winbindd/winbindd.c2
-rw-r--r--source3/winbindd/winbindd_cache.c18
-rw-r--r--source3/winbindd/winbindd_dual.c2
-rw-r--r--source4/build/m4/public.m47
-rw-r--r--source4/client/mount.cifs.c2
-rw-r--r--source4/headermap.txt4
-rw-r--r--source4/heimdal/kuser/kinit.c2
-rw-r--r--source4/heimdal/kuser/kuser_locl.h2
-rw-r--r--source4/heimdal/lib/krb5/context.c12
-rw-r--r--source4/heimdal/lib/krb5/krb5_locl.h2
-rw-r--r--source4/heimdal_build/internal.m49
-rw-r--r--source4/ldap_server/ldap_server.c4
-rw-r--r--source4/lib/tls/config.m42
-rw-r--r--source4/lib/tls/config.mk2
-rw-r--r--source4/libcli/cldap/cldap.c12
-rw-r--r--source4/libcli/ldap/config.mk16
-rw-r--r--source4/libcli/ldap/ldap.h191
-rw-r--r--source4/libcli/ldap/ldap_client.c4
-rw-r--r--source4/libcli/ldap/ldap_controls.c168
-rw-r--r--source4/libcli/ldap/ldap_msg.c87
-rw-r--r--source4/libcli/util/nterr.c2
-rw-r--r--source4/main.mk2
-rw-r--r--source4/rpc_server/netlogon/dcerpc_netlogon.c33
-rw-r--r--source4/scripting/python/samba/provision.py125
-rw-r--r--source4/setup/DB_CONFIG11
-rw-r--r--source4/setup/mmr_serverids.conf1
-rw-r--r--source4/setup/olc_acl.conf4
-rw-r--r--source4/setup/olc_mmr.conf3
-rw-r--r--source4/setup/olc_pass.conf3
-rw-r--r--source4/setup/olc_seed.ldif16
-rw-r--r--source4/setup/olc_serverid.conf1
-rw-r--r--source4/setup/olc_syncrepl.conf13
-rw-r--r--source4/setup/olc_syncrepl_seed.conf5
-rwxr-xr-xsource4/setup/provision-backend13
-rw-r--r--source4/setup/slapd.conf20
-rw-r--r--source4/torture/raw/streams.c119
-rw-r--r--source4/utils/net/net.c2
-rw-r--r--source4/utils/net/net_join.c2
115 files changed, 3659 insertions, 3990 deletions
diff --git a/WHATSNEW4.txt b/WHATSNEW4.txt
index 03cd72c518..7c637ccd66 100644
--- a/WHATSNEW4.txt
+++ b/WHATSNEW4.txt
@@ -1,4 +1,4 @@
-What's new in Samba 4 alpha6
+What's new in Samba 4 alpha7
============================
Samba 4 is the ambitious next version of the Samba suite that is being
@@ -6,13 +6,13 @@ developed in parallel to the stable 3.0 series. The main emphasis in
this branch is support for the Active Directory logon protocols used
by Windows 2000 and above.
-Samba4 alpha6 follows on from the alpha release series we have been
+Samba4 alpha7 follows on from the alpha release series we have been
publishing since September 2007
WARNINGS
========
-Samba4 alpha6 is not a final Samba release. That is more a reference
+Samba4 alpha7 is not a final Samba release. That is more a reference
to Samba4's lack of the features we expect you will need than a
statement of code quality, but clearly it hasn't seen a broad
deployment yet. If you were to upgrade Samba3 (or indeed Windows) to
@@ -62,85 +62,35 @@ working on modules to map between AD-like behaviours and this backend.
We are aiming for Samba 4 to be powerful frontend to large
directories.
-CHANGES SINCE Alpha5
+CHANGES SINCE alpha6
=====================
-In the time since Samba4 Alpha5 was released in June 2008, Samba has
+In the time since Samba4 alpha6 was released in Janurary 2009, Samba has
continued to evolve, but you may particularly notice these areas
(in no particular order):
- The source code for various libraries that are used by both Samba 3 and
- Samba 4 are now shared between the two rather than duplicated
- (and being slightly diverged).
+ Multi Master Replication (MMR) configuration can now be generated
+ for the OpenLDAP-Backend.
- The tevent library has been split out and is now usable on its own.
+ OpenLDAP-Online-Configuration (olc) can now be generated for the
+ OpenLDAP-Backend. (OpenLDAP-Versions >=2.4.15 required).
- Several crash bugs and memory leaks in the registry library have been fixed.
+ Support for Windows 7 beta as a member of the Samba4 domain
- The Python modules have been extended and are no longer generated using SWIG.
+ Issues with the nesting of LDB transactions have been fixed
- Stream renames are now supported.
+ A number of internal libraries (tevent, auth in particular has been
+ updated for easier use outside Samba4
- The provision script now has an interactive mode.
+ spoolss IDL updates to bring Samba3 to use PIDL code, and to merge
+ the corrected IDL back into Samba4
+
+ Fixes to allow use of C++ compilers and to increase portability
- The (broken) copy of CTDB has been removed.
-
- More work towards supporting an OpenLDAP backend.
-
- Initial work on using the Microsoft LDAP schema.
-
- The storage of schemas in LDB is now much more efficient.
-
- Support for extended DNs in LDB has been added.
-
- Incoming trusts are now supported.
-
- Compatibility of the registry server with several Windows versions has been
- improved.
-
- Improvements to LSA.idl for better functionality in the usrmgr.exe.
-
- Improved handling of non-standard characters in passwords.
-
- The embedded JavaScript library has been removed in favor of Python.
-
- The WMI implementation has been re-added, but does not completely work yet.
-
- xpress compression is now supported in the NDR layer.
-
- The main binary is now named "samba" rather than "smbd".
-
- A simple script for setting the expiration of a user was added.
-
- The LDB library is now completely asynchronous internally.
-
- Various unknowns and correctness issues in the drsblobs and drsuapi RPC
- interface implementations have been fixed.
-
- It is now possible to connect to an LDAP backend using SASL credentials.
-
- Multi-fragment NTtrans request support has been added.
-
- The DCE/RPC server can now listen on a separate pipe to allow DCE/RPC
- connections forwarded from Samba 3. The user credentials are provided
- by the client.
-
- A large number of bugs in the SMB2 implementation have been fixed.
-
- Auxiliary classes in LDAP schema conversion are now collapsed.
-
- Several tests have been added to the SMB testsuite.
-
- Object GUIDs in DCE/RPC connections are now dealt with properly.
-
- The correctness of the LSA and NETLOGON implementations has been
- improved.
-
- Multi Master Replication configuration can now be generated
- for OpenLDAP.
-
-These are just some of the highlights of the work done in the past few
-months. More details can be found in our GIT history.
+ Fixed TLS (SSL) support with modern versions of GnuTLS
+
+These are just some of the highlights of the work done in the past
+month. More details can be found in our GIT history.
CHANGES
@@ -163,17 +113,13 @@ KNOWN ISSUES
- Clock Synchronisation is critical. Many 'wrong password' errors are
actually due to Kerberos objecting to a clock skew between client
- and server. (The NTP work in the previous alpha is partly to assist
+ and server. (The NTP work in the previous alphas are partly to assist
with this problem).
-- Samba4 alpha6 is currently only portable to recent Linux
+- Samba4 alpha7 is currently only portable to recent Linux
distributions. Work to return support for other Unix varients is
- expected during the next alpha cycle
+ expected during the next alpha cycles
-- Samba4 alpha6 is incompatible with GnuTLS 2.0, found in Fedora 9 and
- recent Ubuntu releases. GnuTLS use may be disabled using the
- --disable-gnutls argument to ./configure. (otherwise 'make test' and
- LDAPS operations will hang).
RUNNING Samba4
==============
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 5845f62e34..118a5b9da7 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -85,9 +85,11 @@ static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle, const char *fnam
return vfswrap_opendir(NULL, fname, mask, attr);
}
-static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
+static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle,
+ SMB_STRUCT_DIR *dirp,
+ SMB_STRUCT_STAT *sbuf)
{
- return vfswrap_readdir(NULL, dirp);
+ return vfswrap_readdir(NULL, dirp, sbuf);
}
static void skel_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset)
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 7036c730dd..a95b5ae6cd 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -79,9 +79,11 @@ static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle, const char *fnam
return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
}
-static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
+static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle,
+ SMB_STRUCT_DIR *dirp,
+ SMB_STRUCT_STAT *sbuf)
{
- return SMB_VFS_NEXT_READDIR(handle, dirp);
+ return SMB_VFS_NEXT_READDIR(handle, dirp, sbuf);
}
static void skel_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset)
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 02ae880683..3563421e0e 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -22,6 +22,7 @@
#include "lib/tevent/tevent.h"
#include "lib/async_req/async_req.h"
#include "lib/async_req/async_sock.h"
+#include "lib/util/tevent_unix.h"
#include <fcntl.h>
#ifndef TALLOC_FREE
@@ -33,10 +34,7 @@
*/
enum async_syscall_type {
ASYNC_SYSCALL_SEND,
- ASYNC_SYSCALL_SENDALL,
ASYNC_SYSCALL_RECV,
- ASYNC_SYSCALL_RECVALL,
- ASYNC_SYSCALL_CONNECT
};
/**
@@ -54,36 +52,12 @@ struct async_syscall_state {
size_t length;
int flags;
} param_send;
- struct param_sendall {
- int fd;
- const void *buffer;
- size_t length;
- int flags;
- size_t sent;
- } param_sendall;
struct param_recv {
int fd;
void *buffer;
size_t length;
int flags;
} param_recv;
- struct param_recvall {
- int fd;
- void *buffer;
- size_t length;
- int flags;
- size_t received;
- } param_recvall;
- struct param_connect {
- /**
- * connect needs to be done on a nonblocking
- * socket. Keep the old flags around
- */
- long old_sockflags;
- int fd;
- const struct sockaddr *address;
- socklen_t address_len;
- } param_connect;
} param;
union {
@@ -337,109 +311,6 @@ struct async_req *async_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
}
/**
- * fde event handler for the "sendall" syscall group
- * @param[in] ev The event context that sent us here
- * @param[in] fde The file descriptor event associated with the send
- * @param[in] flags Can only be TEVENT_FD_WRITE here
- * @param[in] priv private data, "struct async_req *" in this case
- */
-
-static void async_sendall_callback(struct tevent_context *ev,
- struct tevent_fd *fde, uint16_t flags,
- void *priv)
-{
- struct async_req *req = talloc_get_type_abort(
- priv, struct async_req);
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
- struct param_sendall *p = &state->param.param_sendall;
-
- if (state->syscall_type != ASYNC_SYSCALL_SENDALL) {
- async_req_error(req, EIO);
- return;
- }
-
- state->result.result_ssize_t = send(p->fd,
- (const char *)p->buffer + p->sent,
- p->length - p->sent, p->flags);
- state->sys_errno = errno;
-
- if (state->result.result_ssize_t == -1) {
- async_req_error(req, state->sys_errno);
- return;
- }
-
- if (state->result.result_ssize_t == 0) {
- async_req_error(req, EOF);
- return;
- }
-
- p->sent += state->result.result_ssize_t;
- if (p->sent > p->length) {
- async_req_error(req, EIO);
- return;
- }
-
- if (p->sent == p->length) {
- TALLOC_FREE(state->fde);
- async_req_done(req);
- }
-}
-
-/**
- * @brief Send all bytes to a socket
- * @param[in] mem_ctx The memory context to hang the result off
- * @param[in] ev The event context to work from
- * @param[in] fd The socket to send to
- * @param[in] buffer The buffer to send
- * @param[in] length How many bytes to send
- * @param[in] flags flags passed to send(2)
- *
- * async_sendall calls send(2) as long as it is necessary to send all of the
- * "length" bytes
- */
-
-struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- int fd, const void *buffer, size_t length,
- int flags)
-{
- struct async_req *result;
- struct async_syscall_state *state;
-
- result = async_fde_syscall_new(
- mem_ctx, ev, ASYNC_SYSCALL_SENDALL,
- fd, TEVENT_FD_WRITE, async_sendall_callback,
- &state);
- if (result == NULL) {
- return NULL;
- }
-
- state->param.param_sendall.fd = fd;
- state->param.param_sendall.buffer = buffer;
- state->param.param_sendall.length = length;
- state->param.param_sendall.flags = flags;
- state->param.param_sendall.sent = 0;
-
- return result;
-}
-
-ssize_t sendall_recv(struct async_req *req, int *perr)
-{
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
- int err;
-
- err = async_req_simple_recv_errno(req);
-
- if (err != 0) {
- *perr = err;
- return -1;
- }
-
- return state->result.result_ssize_t;
-}
-
-/**
* fde event handler for the "recv" syscall
* @param[in] ev The event context that sent us here
* @param[in] fde The file descriptor event associated with the recv
@@ -507,106 +378,138 @@ struct async_req *async_recv(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
return result;
}
-/**
- * fde event handler for the "recvall" syscall group
- * @param[in] ev The event context that sent us here
- * @param[in] fde The file descriptor event associated with the recv
- * @param[in] flags Can only be TEVENT_FD_READ here
- * @param[in] priv private data, "struct async_req *" in this case
- */
+struct async_send_state {
+ int fd;
+ const void *buf;
+ size_t len;
+ int flags;
+ ssize_t sent;
+};
-static void async_recvall_callback(struct tevent_context *ev,
- struct tevent_fd *fde, uint16_t flags,
- void *priv)
+static void async_send_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data);
+
+struct tevent_req *async_send_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, const void *buf, size_t len,
+ int flags)
{
- struct async_req *req = talloc_get_type_abort(
- priv, struct async_req);
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
- struct param_recvall *p = &state->param.param_recvall;
+ struct tevent_req *result;
+ struct async_send_state *state;
+ struct tevent_fd *fde;
- if (state->syscall_type != ASYNC_SYSCALL_RECVALL) {
- async_req_error(req, EIO);
- return;
+ result = tevent_req_create(mem_ctx, &state, struct async_send_state);
+ if (result == NULL) {
+ return result;
}
+ state->fd = fd;
+ state->buf = buf;
+ state->len = len;
+ state->flags = flags;
- state->result.result_ssize_t = recv(p->fd,
- (char *)p->buffer + p->received,
- p->length - p->received, p->flags);
- state->sys_errno = errno;
-
- if (state->result.result_ssize_t == -1) {
- async_req_error(req, state->sys_errno);
- return;
+ fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, async_send_handler,
+ result);
+ if (fde == NULL) {
+ TALLOC_FREE(result);
+ return NULL;
}
+ return result;
+}
- if (state->result.result_ssize_t == 0) {
- async_req_error(req, EIO);
+static void async_send_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data)
+{
+ struct tevent_req *req = talloc_get_type_abort(
+ private_data, struct tevent_req);
+ struct async_send_state *state = talloc_get_type_abort(
+ req->private_state, struct async_send_state);
+
+ state->sent = send(state->fd, state->buf, state->len, state->flags);
+ if (state->sent == -1) {
+ tevent_req_error(req, errno);
return;
}
+ tevent_req_done(req);
+}
- p->received += state->result.result_ssize_t;
- if (p->received > p->length) {
- async_req_error(req, EIO);
- return;
- }
+ssize_t async_send_recv(struct tevent_req *req, int *perrno)
+{
+ struct async_send_state *state = talloc_get_type_abort(
+ req->private_state, struct async_send_state);
- if (p->received == p->length) {
- TALLOC_FREE(state->fde);
- async_req_done(req);
+ if (tevent_req_is_unix_error(req, perrno)) {
+ return -1;
}
+ return state->sent;
}
-/**
- * Receive a specified number of bytes from a socket
- * @param[in] mem_ctx The memory context to hang the result off
- * @param[in] ev The event context to work from
- * @param[in] fd The socket to recv from
- * @param[in] buffer The buffer to recv into
- * @param[in] length How many bytes to recv
- * @param[in] flags flags passed to recv(2)
- *
- * async_recvall will call recv(2) until "length" bytes are received
- */
+struct async_recv_state {
+ int fd;
+ void *buf;
+ size_t len;
+ int flags;
+ ssize_t received;
+};
-struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- int fd, void *buffer, size_t length,
- int flags)
+static void async_recv_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data);
+
+struct tevent_req *async_recv_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, void *buf, size_t len, int flags)
{
- struct async_req *result;
- struct async_syscall_state *state;
+ struct tevent_req *result;
+ struct async_recv_state *state;
+ struct tevent_fd *fde;
- result = async_fde_syscall_new(
- mem_ctx, ev, ASYNC_SYSCALL_RECVALL,
- fd, TEVENT_FD_READ, async_recvall_callback,
- &state);
+ result = tevent_req_create(mem_ctx, &state, struct async_recv_state);
if (result == NULL) {
- return NULL;
+ return result;
}
+ state->fd = fd;
+ state->buf = buf;
+ state->len = len;
+ state->flags = flags;
- state->param.param_recvall.fd = fd;
- state->param.param_recvall.buffer = buffer;
- state->param.param_recvall.length = length;
- state->param.param_recvall.flags = flags;
- state->param.param_recvall.received = 0;
-
+ fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, async_recv_handler,
+ result);
+ if (fde == NULL) {
+ TALLOC_FREE(result);
+ return NULL;
+ }
return result;
}
-ssize_t recvall_recv(struct async_req *req, int *perr)
+static void async_recv_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data)
{
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
- int err;
+ struct tevent_req *req = talloc_get_type_abort(
+ private_data, struct tevent_req);
+ struct async_recv_state *state = talloc_get_type_abort(
+ req->private_state, struct async_recv_state);
+
+ state->received = recv(state->fd, state->buf, state->len,
+ state->flags);
+ if (state->received == -1) {
+ tevent_req_error(req, errno);
+ return;
+ }
+ tevent_req_done(req);
+}
- err = async_req_simple_recv_errno(req);
+ssize_t async_recv_recv(struct tevent_req *req, int *perrno)
+{
+ struct async_recv_state *state = talloc_get_type_abort(
+ req->private_state, struct async_recv_state);
- if (err != 0) {
- *perr = err;
+ if (tevent_req_is_unix_error(req, perrno)) {
return -1;
}
-
- return state->result.result_ssize_t;
+ return state->received;
}
struct async_connect_state {
@@ -633,17 +536,18 @@ static void async_connect_connected(struct tevent_context *ev,
* connect in an async state. This will be reset when the request is finished.
*/
-struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- int fd, const struct sockaddr *address,
- socklen_t address_len)
+struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, const struct sockaddr *address,
+ socklen_t address_len)
{
- struct async_req *result;
+ struct tevent_req *result;
struct async_connect_state *state;
struct tevent_fd *fde;
- if (!async_req_setup(mem_ctx, &result, &state,
- struct async_connect_state)) {
+ result = tevent_req_create(
+ mem_ctx, &state, struct async_connect_state);
+ if (result == NULL) {
return NULL;
}
@@ -664,8 +568,8 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
state->result = connect(fd, address, address_len);
if (state->result == 0) {
- state->sys_errno = 0;
- goto post_status;
+ errno = 0;
+ goto post_errno;
}
/**
@@ -686,22 +590,20 @@ struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ | TEVENT_FD_WRITE,
async_connect_connected, result);
if (fde == NULL) {
- state->sys_errno = ENOMEM;
- goto post_status;
+ errno = ENOMEM;
+ goto post_errno;
}
return result;
post_errno:
state->sys_errno = errno;
- post_status:
fcntl(fd, F_SETFL, state->old_sockflags);
- if (!async_post_error(result, ev, state->sys_errno)) {
- goto fail;
+ if (state->sys_errno == 0) {
+ tevent_req_done(result);
+ } else {
+ tevent_req_error(result, state->sys_errno);
}
- return result;
- fail:
- TALLOC_FREE(result);
- return NULL;
+ return tevent_req_post(result, ev);
}
/**
@@ -716,10 +618,10 @@ static void async_connect_connected(struct tevent_context *ev,
struct tevent_fd *fde, uint16_t flags,
void *priv)
{
- struct async_req *req = talloc_get_type_abort(
- priv, struct async_req);
+ struct tevent_req *req = talloc_get_type_abort(
+ priv, struct tevent_req);
struct async_connect_state *state = talloc_get_type_abort(
- req->private_data, struct async_connect_state);
+ req->private_state, struct async_connect_state);
TALLOC_FREE(fde);
@@ -743,27 +645,27 @@ static void async_connect_connected(struct tevent_context *ev,
DEBUG(10, ("connect returned %s\n", strerror(errno)));
fcntl(state->fd, F_SETFL, state->old_sockflags);
- async_req_error(req, state->sys_errno);
+ tevent_req_error(req, state->sys_errno);
return;
}
state->sys_errno = 0;
- async_req_done(req);
+ tevent_req_done(req);
}
-int async_connect_recv(struct async_req *req, int *perrno)
+int async_connect_recv(struct tevent_req *req, int *perrno)
{
struct async_connect_state *state = talloc_get_type_abort(
- req->private_data, struct async_connect_state);
+ req->private_state, struct async_connect_state);
int err;
fcntl(state->fd, F_SETFL, state->old_sockflags);
-
- if (async_req_is_errno(req, &err)) {
+ if (tevent_req_is_unix_error(req, &err)) {
*perrno = err;
return -1;
}
+
if (state->sys_errno == 0) {
return 0;
}
@@ -771,3 +673,226 @@ int async_connect_recv(struct async_req *req, int *perrno)
*perrno = state->sys_errno;
return -1;
}
+
+struct writev_state {
+ struct tevent_context *ev;
+ int fd;
+ struct iovec *iov;
+ int count;
+ size_t total_size;
+};
+
+static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
+ uint16_t flags, void *private_data);
+
+struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ int fd, struct iovec *iov, int count)
+{
+ struct tevent_req *result;
+ struct writev_state *state;
+ struct tevent_fd *fde;
+
+ result = tevent_req_create(mem_ctx, &state, struct writev_state);
+ if (result == NULL) {
+ return NULL;
+ }
+ state->ev = ev;
+ state->fd = fd;
+ state->total_size = 0;
+ state->count = count;
+ state->iov = (struct iovec *)talloc_memdup(
+ state, iov, sizeof(struct iovec) * count);
+ if (state->iov == NULL) {
+ goto fail;
+ }
+
+ fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, writev_handler,
+ result);
+ if (fde == NULL) {
+ goto fail;
+ }
+ return result;
+
+ fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
+ uint16_t flags, void *private_data)
+{
+ struct tevent_req *req = talloc_get_type_abort(
+ private_data, struct tevent_req);
+ struct writev_state *state = talloc_get_type_abort(
+ req->private_state, struct writev_state);
+ size_t to_write, written;
+ int i;
+
+ to_write = 0;
+
+ for (i=0; i<state->count; i++) {
+ to_write += state->iov[i].iov_len;
+ }
+
+ written = sys_writev(state->fd, state->iov, state->count);
+ if (written == -1) {
+ tevent_req_error(req, errno);
+ return;
+ }
+ if (written == 0) {
+ tevent_req_error(req, EPIPE);
+ return;
+ }
+ state->total_size += written;
+
+ if (written == to_write) {
+ tevent_req_done(req);
+ return;
+ }
+
+ /*
+ * We've written less than we were asked to, drop stuff from
+ * state->iov.
+ */
+
+ while (written > 0) {
+ if (written < state->iov[0].iov_len) {
+ state->iov[0].iov_base =
+ (char *)state->iov[0].iov_base + written;
+ state->iov[0].iov_len -= written;
+ break;
+ }
+ written = state->iov[0].iov_len;
+ state->iov += 1;
+ state->count -= 1;
+ }
+}
+
+ssize_t writev_recv(struct tevent_req *req, int *perrno)
+{
+ struct writev_state *state = talloc_get_type_abort(
+ req->private_state, struct writev_state);
+
+ if (tevent_req_is_unix_error(req, perrno)) {
+ return -1;
+ }
+ return state->total_size;
+}
+
+struct read_packet_state {
+ int fd;
+ uint8_t *buf;
+ size_t nread;
+ ssize_t (*more)(uint8_t *buf, size_t buflen, void *private_data);
+ void *private_data;
+};
+
+static void read_packet_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data);
+
+struct tevent_req *read_packet_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, size_t initial,
+ ssize_t (*more)(uint8_t *buf,
+ size_t buflen,
+ void *private_data),
+ void *private_data)
+{
+ struct tevent_req *result;
+ struct read_packet_state *state;
+ struct tevent_fd *fde;
+
+ result = tevent_req_create(mem_ctx, &state, struct read_packet_state);
+ if (result == NULL) {
+ return NULL;
+ }
+ state->fd = fd;
+ state->nread = 0;
+ state->more = more;
+ state->private_data = private_data;
+
+ state->buf = talloc_array(state, uint8_t, initial);
+ if (state->buf == NULL) {
+ goto fail;
+ }
+
+ fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, read_packet_handler,
+ result);
+ if (fde == NULL) {
+ goto fail;
+ }
+ return result;
+ fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+static void read_packet_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags, void *private_data)
+{
+ struct tevent_req *req = talloc_get_type_abort(
+ private_data, struct tevent_req);
+ struct read_packet_state *state = talloc_get_type_abort(
+ req->private_state, struct read_packet_state);
+ size_t total = talloc_get_size(state->buf);
+ ssize_t nread, more;
+ uint8_t *tmp;
+
+ nread = read(state->fd, state->buf+state->nread, total-state->nread);
+ if (nread == -1) {
+ tevent_req_error(req, errno);
+ return;
+ }
+ if (nread == 0) {
+ tevent_req_error(req, EPIPE);
+ return;
+ }
+
+ state->nread += nread;
+ if (state->nread < total) {
+ /* Come back later */
+ return;
+ }
+
+ /*
+ * We got what was initially requested. See if "more" asks for -- more.
+ */
+ if (state->more == NULL) {
+ /* Nobody to ask, this is a async read_data */
+ tevent_req_done(req);
+ return;
+ }
+
+ more = state->more(state->buf, total, state->private_data);
+ if (more == -1) {
+ /* We got an invalid packet, tell the caller */
+ tevent_req_error(req, EIO);
+ return;
+ }
+ if (more == 0) {
+ /* We're done, full packet received */
+ tevent_req_done(req);
+ return;
+ }
+
+ tmp = TALLOC_REALLOC_ARRAY(state, state->buf, uint8_t, total+more);
+ if (tevent_req_nomem(tmp, req)) {
+ return;
+ }
+ state->buf = tmp;
+}
+
+ssize_t read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ uint8_t **pbuf, int *perrno)
+{
+ struct read_packet_state *state = talloc_get_type_abort(
+ req->private_state, struct read_packet_state);
+
+ if (tevent_req_is_unix_error(req, perrno)) {
+ return -1;
+ }
+ *pbuf = talloc_move(mem_ctx, &state->buf);
+ return talloc_get_size(*pbuf);
+}
diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h
index c8739e9ed6..bfc4346d39 100644
--- a/lib/async_req/async_sock.h
+++ b/lib/async_req/async_sock.h
@@ -35,20 +35,36 @@ struct async_req *async_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct async_req *async_recv(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
int fd, void *buffer, size_t length,
int flags);
-struct async_req *async_connect_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- int fd, const struct sockaddr *address,
- socklen_t address_len);
-int async_connect_recv(struct async_req *req, int *perrno);
-
-struct async_req *sendall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- int fd, const void *buffer, size_t length,
- int flags);
-ssize_t sendall_recv(struct async_req *req, int *perr);
-
-struct async_req *recvall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- int fd, void *buffer, size_t length,
- int flags);
-ssize_t recvall_recv(struct async_req *req, int *perr);
+
+struct tevent_req *async_send_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, const void *buf, size_t len,
+ int flags);
+ssize_t async_send_recv(struct tevent_req *req, int *perrno);
+
+struct tevent_req *async_recv_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, void *buf, size_t len, int flags);
+ssize_t async_recv_recv(struct tevent_req *req, int *perrno);
+
+struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, const struct sockaddr *address,
+ socklen_t address_len);
+int async_connect_recv(struct tevent_req *req, int *perrno);
+
+struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+ int fd, struct iovec *iov, int count);
+ssize_t writev_recv(struct tevent_req *req, int *perrno);
+
+struct tevent_req *read_packet_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ int fd, size_t initial,
+ ssize_t (*more)(uint8_t *buf,
+ size_t buflen,
+ void *private_data),
+ void *private_data);
+ssize_t read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+ uint8_t **pbuf, int *perrno);
#endif
diff --git a/lib/replace/getifaddrs.c b/lib/replace/getifaddrs.c
index f6f0ec080c..3a91bb40d2 100644
--- a/lib/replace/getifaddrs.c
+++ b/lib/replace/getifaddrs.c
@@ -84,9 +84,6 @@ int rep_getifaddrs(struct ifaddrs **ifap)
char buff[8192];
int fd, i, n;
struct ifreq *ifr=NULL;
- struct in_addr ipaddr;
- struct in_addr nmask;
- char *iname;
struct ifaddrs *curif;
struct ifaddrs *lastif = NULL;
@@ -164,9 +161,6 @@ int rep_getifaddrs(struct ifaddrs **ifap)
char buff[8192];
int fd, i, n;
struct ifreq *ifr=NULL;
- struct in_addr ipaddr;
- struct in_addr nmask;
- char *iname;
struct ifaddrs *curif;
struct ifaddrs *lastif = NULL;
@@ -265,9 +259,6 @@ int rep_getifaddrs(struct ifaddrs **ifap)
int fd, i;
struct ifconf ifc;
struct ifreq *ifr=NULL;
- struct in_addr ipaddr;
- struct in_addr nmask;
- char *iname;
struct ifaddrs *curif;
struct ifaddrs *lastif = NULL;
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 16fac7327f..b3d1c6d59a 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -31,6 +31,7 @@
#include <stdint.h>
#include <talloc.h>
#include <sys/time.h>
+#include <stdbool.h>
struct tevent_context;
struct tevent_ops;
diff --git a/lib/util/become_daemon.c b/lib/util/become_daemon.c
index 5a97b65407..3d06a4363d 100644
--- a/lib/util/become_daemon.c
+++ b/lib/util/become_daemon.c
@@ -66,10 +66,10 @@ _PUBLIC_ void close_low_fds(bool stderr_too)
Become a daemon, discarding the controlling terminal.
****************************************************************************/
-_PUBLIC_ void become_daemon(bool Fork, bool no_process_group)
+_PUBLIC_ void become_daemon(bool do_fork, bool no_process_group)
{
- if (Fork) {
- if (fork()) {
+ if (do_fork) {
+ if (sys_fork()) {
_exit(0);
}
}
diff --git a/lib/util/system.c b/lib/util/system.c
index 9bd1800233..9bf5de1a83 100644
--- a/lib/util/system.c
+++ b/lib/util/system.c
@@ -88,3 +88,32 @@ _PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host)
return in2;
}
+/**************************************************************************
+ Wrapper for fork. Ensures we clear our pid cache.
+****************************************************************************/
+
+static pid_t mypid = (pid_t)-1;
+
+_PUBLIC_ pid_t sys_fork(void)
+{
+ pid_t forkret = fork();
+
+ if (forkret == (pid_t)0) {
+ /* Child - reset mypid so sys_getpid does a system call. */
+ mypid = (pid_t) -1;
+ }
+
+ return forkret;
+}
+
+/**************************************************************************
+ Wrapper for getpid. Ensures we only do a system call *once*.
+****************************************************************************/
+
+_PUBLIC_ pid_t sys_getpid(void)
+{
+ if (mypid == (pid_t)-1)
+ mypid = getpid();
+
+ return mypid;
+}
diff --git a/lib/util/tevent_unix.c b/lib/util/tevent_unix.c
new file mode 100644
index 0000000000..b89d5cd4d4
--- /dev/null
+++ b/lib/util/tevent_unix.c
@@ -0,0 +1,46 @@
+/*
+ Unix SMB/CIFS implementation.
+ Wrap unix errno around tevent_req
+ 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 "tevent_unix.h"
+#include "../replace/replace.h"
+
+bool tevent_req_is_unix_error(struct tevent_req *req, int *perrno)
+{
+ enum tevent_req_state state;
+ uint64_t err;
+
+ if (!tevent_req_is_error(req, &state, &err)) {
+ return false;
+ }
+ switch (state) {
+ case TEVENT_REQ_TIMED_OUT:
+ *perrno = ETIMEDOUT;
+ break;
+ case TEVENT_REQ_NO_MEMORY:
+ *perrno = ENOMEM;
+ break;
+ case TEVENT_REQ_USER_ERROR:
+ *perrno = err;
+ break;
+ default:
+ *perrno = EINVAL;
+ break;
+ }
+ return true;
+}
diff --git a/lib/util/tevent_unix.h b/lib/util/tevent_unix.h
new file mode 100644
index 0000000000..dc3ffaef33
--- /dev/null
+++ b/lib/util/tevent_unix.h
@@ -0,0 +1,27 @@
+/*
+ Unix SMB/CIFS implementation.
+ Wrap unix errno around tevent_req
+ 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/>.
+*/
+
+#ifndef _TEVENT_UNIX_H
+#define _TEVENT_UNIX_H
+
+#include "../tevent/tevent.h"
+
+bool tevent_req_is_unix_error(struct tevent_req *req, int *perrno);
+
+#endif
diff --git a/lib/util/util.h b/lib/util/util.h
index d3e446f488..27f94cd685 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -134,6 +134,16 @@ apparent reason.
_PUBLIC_ struct hostent *sys_gethostbyname(const char *name);
_PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host);
+/**
+ * Wrapper for fork used to invalid pid cache.
+ **/
+_PUBLIC_ pid_t sys_fork(void);
+
+/**
+ * Wrapper for getpid. Ensures we only do a system call *once*.
+ **/
+_PUBLIC_ pid_t sys_getpid(void);
+
/* The following definitions come from lib/util/genrand.c */
/**
diff --git a/libcli/ldap/config.mk b/libcli/ldap/config.mk
new file mode 100644
index 0000000000..22cad8cfbc
--- /dev/null
+++ b/libcli/ldap/config.mk
@@ -0,0 +1,15 @@
+[SUBSYSTEM::LIBCLI_LDAP_MESSAGE]
+PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC LIBLDB
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL ASN1_UTIL
+
+LIBCLI_LDAP_MESSAGE_OBJ_FILES = $(addprefix ../libcli/ldap/, \
+ ldap_message.o)
+PUBLIC_HEADERS += ../libcli/ldap/ldap_message.h ../libcli/ldap/ldap_errors.h
+
+[SUBSYSTEM::LIBCLI_LDAP_NDR]
+PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTALLOC
+PRIVATE_DEPENDENCIES = LIBSAMBA-UTIL LIBLDB NDR_MISC NDR_SECURITY
+
+LIBCLI_LDAP_NDR_OBJ_FILES = ../libcli/ldap/ldap_ndr.o
+PUBLIC_HEADERS += ../libcli/ldap/ldap_ndr.h
+
diff --git a/source4/libcli/ldap/ldap_errors.h b/libcli/ldap/ldap_errors.h
index 17ac43814c..fa929c6936 100644
--- a/source4/libcli/ldap/ldap_errors.h
+++ b/libcli/ldap/ldap_errors.h
@@ -21,6 +21,7 @@
#ifndef _SMB_LDAP_ERRORS_H_
#define _SMB_LDAP_ERRORS_H_
+#ifndef LDAP_SUCCESS
enum ldap_result_code {
LDAP_SUCCESS = 0,
LDAP_OPERATIONS_ERROR = 1,
@@ -62,5 +63,6 @@ enum ldap_result_code {
LDAP_AFFECTS_MULTIPLE_DSAS = 71,
LDAP_OTHER = 80
};
+#endif
#endif /* _SMB_LDAP_ERRORS_H_ */
diff --git a/source4/libcli/ldap/ldap.c b/libcli/ldap/ldap_message.c
index 7a65cc5c27..9b00d0188d 100644
--- a/source4/libcli/ldap/ldap.c
+++ b/libcli/ldap/ldap_message.c
@@ -24,9 +24,197 @@
#include "includes.h"
#include "../lib/util/asn1.h"
-#include "libcli/ldap/ldap.h"
-#include "libcli/ldap/ldap_proto.h"
+#include "../libcli/ldap/ldap_message.h"
+_PUBLIC_ struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx)
+{
+ return talloc_zero(mem_ctx, struct ldap_message);
+}
+
+
+static bool add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
+ struct ldb_message_element *attrib)
+{
+ attrib->values = talloc_realloc(mem_ctx,
+ attrib->values,
+ DATA_BLOB,
+ attrib->num_values+1);
+ if (attrib->values == NULL)
+ return false;
+
+ attrib->values[attrib->num_values].data = talloc_steal(attrib->values,
+ value->data);
+ attrib->values[attrib->num_values].length = value->length;
+ attrib->num_values += 1;
+ return true;
+}
+
+static bool add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
+ const struct ldb_message_element *attrib,
+ struct ldb_message_element **attribs,
+ int *num_attribs)
+{
+ *attribs = talloc_realloc(mem_ctx,
+ *attribs,
+ struct ldb_message_element,
+ *num_attribs+1);
+
+ if (*attribs == NULL)
+ return false;
+
+ (*attribs)[*num_attribs] = *attrib;
+ talloc_steal(*attribs, attrib->values);
+ talloc_steal(*attribs, attrib->name);
+ *num_attribs += 1;
+ return true;
+}
+
+static bool add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
+ struct ldap_mod *mod,
+ struct ldap_mod **mods,
+ int *num_mods)
+{
+ *mods = talloc_realloc(mem_ctx, *mods, struct ldap_mod, (*num_mods)+1);
+
+ if (*mods == NULL)
+ return false;
+
+ (*mods)[*num_mods] = *mod;
+ *num_mods += 1;
+ return true;
+}
+
+static bool ldap_decode_control_value(void *mem_ctx, DATA_BLOB value,
+ const struct ldap_control_handler *handlers,
+ struct ldb_control *ctrl)
+{
+ int i;
+
+ if (!handlers) {
+ return true;
+ }
+
+ for (i = 0; handlers[i].oid != NULL; i++) {
+ if (strcmp(handlers[i].oid, ctrl->oid) == 0) {
+ if (!handlers[i].decode || !handlers[i].decode(mem_ctx, value, &ctrl->data)) {
+ return false;
+ }
+ break;
+ }
+ }
+ if (handlers[i].oid == NULL) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data,
+ struct ldb_control *ctrl, DATA_BLOB *value)
+{
+ DATA_BLOB oid;
+
+ if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
+ return false;
+ }
+
+ if (!asn1_read_OctetString(data, mem_ctx, &oid)) {
+ return false;
+ }
+ ctrl->oid = talloc_strndup(mem_ctx, (char *)oid.data, oid.length);
+ if (!ctrl->oid) {
+ return false;
+ }
+
+ if (asn1_peek_tag(data, ASN1_BOOLEAN)) {
+ bool critical;
+ if (!asn1_read_BOOLEAN(data, &critical)) {
+ return false;
+ }
+ ctrl->critical = critical;
+ } else {
+ ctrl->critical = false;
+ }
+
+ ctrl->data = NULL;
+
+ if (!asn1_peek_tag(data, ASN1_OCTET_STRING)) {
+ *value = data_blob(NULL, 0);
+ goto end_tag;
+ }
+
+ if (!asn1_read_OctetString(data, mem_ctx, value)) {
+ return false;
+ }
+
+end_tag:
+ if (!asn1_end_tag(data)) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool ldap_encode_control(void *mem_ctx, struct asn1_data *data,
+ const struct ldap_control_handler *handlers,
+ struct ldb_control *ctrl)
+{
+ DATA_BLOB value;
+ int i;
+
+ if (!handlers) {
+ return false;
+ }
+
+ for (i = 0; handlers[i].oid != NULL; i++) {
+ if (strcmp(handlers[i].oid, ctrl->oid) == 0) {
+ if (!handlers[i].encode) {
+ if (ctrl->critical) {
+ return false;
+ } else {
+ /* not encoding this control */
+ return true;
+ }
+ }
+ if (!handlers[i].encode(mem_ctx, ctrl->data, &value)) {
+ return false;
+ }
+ break;
+ }
+ }
+ if (handlers[i].oid == NULL) {
+ return false;
+ }
+
+ if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
+ return false;
+ }
+
+ if (!asn1_write_OctetString(data, ctrl->oid, strlen(ctrl->oid))) {
+ return false;
+ }
+
+ if (ctrl->critical) {
+ if (!asn1_write_BOOLEAN(data, ctrl->critical)) {
+ return false;
+ }
+ }
+
+ if (!ctrl->data) {
+ goto pop_tag;
+ }
+
+ if (!asn1_write_OctetString(data, value.data, value.length)) {
+ return false;
+ }
+
+pop_tag:
+ if (!asn1_pop_tag(data)) {
+ return false;
+ }
+
+ return true;
+}
static bool ldap_push_filter(struct asn1_data *data, struct ldb_parse_tree *tree)
{
@@ -188,7 +376,9 @@ static void ldap_encode_response(struct asn1_data *data, struct ldap_Result *res
}
}
-_PUBLIC_ bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx)
+_PUBLIC_ bool ldap_encode(struct ldap_message *msg,
+ const struct ldap_control_handler *control_handlers,
+ DATA_BLOB *result, TALLOC_CTX *mem_ctx)
{
struct asn1_data *data = asn1_init(mem_ctx);
int i, j;
@@ -475,7 +665,9 @@ _PUBLIC_ bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CT
asn1_push_tag(data, ASN1_CONTEXT(0));
for (i = 0; msg->controls[i] != NULL; i++) {
- if (!ldap_encode_control(mem_ctx, data, msg->controls[i])) {
+ if (!ldap_encode_control(mem_ctx, data,
+ control_handlers,
+ msg->controls[i])) {
return false;
}
}
@@ -867,13 +1059,13 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx,
ret->u.extended.attr = talloc_strdup(ret, "*");
}
ret->u.extended.rule_id = talloc_steal(ret, oid);
- ret->u.extended.value.data = talloc_steal(ret, value);
+ ret->u.extended.value.data = (uint8_t *)talloc_steal(ret, value);
ret->u.extended.value.length = strlen(value);
ret->u.extended.dnAttributes = dnAttributes;
} else {
ret->operation = LDB_OP_EQUALITY;
ret->u.equality.attr = talloc_steal(ret, attr);
- ret->u.equality.value.data = talloc_steal(ret, value);
+ ret->u.equality.value.data = (uint8_t *)talloc_steal(ret, value);
ret->u.equality.value.length = strlen(value);
}
if (!asn1_end_tag(data)) {
@@ -883,7 +1075,6 @@ static struct ldb_parse_tree *ldap_decode_filter_tree(TALLOC_CTX *mem_ctx,
}
default:
- DEBUG(0,("Unsupported LDAP filter operation 0x%x\n", filter_tag));
goto failed;
}
@@ -926,9 +1117,9 @@ void ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data,
}
/* Decode a set of LDAP attributes, as found in a search entry */
-void ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data,
- struct ldb_message_element **attributes,
- int *num_attributes)
+static void ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data,
+ struct ldb_message_element **attributes,
+ int *num_attributes)
{
asn1_start_tag(data, ASN1_SEQUENCE(0));
ldap_decode_attribs_bare(mem_ctx, data,
@@ -938,7 +1129,9 @@ void ldap_decode_attribs(TALLOC_CTX *mem_ctx, struct asn1_data *data,
/* This routine returns LDAP status codes */
-_PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
+_PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data,
+ const struct ldap_control_handler *control_handlers,
+ struct ldap_message *msg)
{
uint8_t tag;
@@ -1032,13 +1225,17 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
case ASN1_APPLICATION(LDAP_TAG_SearchRequest): {
struct ldap_SearchRequest *r = &msg->r.SearchRequest;
+ int sizelimit, timelimit;
+ const char **attrs = NULL;
msg->type = LDAP_TAG_SearchRequest;
asn1_start_tag(data, tag);
asn1_read_OctetString_talloc(msg, data, &r->basedn);
asn1_read_enumerated(data, (int *)&(r->scope));
asn1_read_enumerated(data, (int *)&(r->deref));
- asn1_read_Integer(data, &r->sizelimit);
- asn1_read_Integer(data, &r->timelimit);
+ asn1_read_Integer(data, &sizelimit);
+ r->sizelimit = sizelimit;
+ asn1_read_Integer(data, &timelimit);
+ r->timelimit = timelimit;
asn1_read_BOOLEAN(data, &r->attributesonly);
r->tree = ldap_decode_filter_tree(msg, data);
@@ -1058,10 +1255,11 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
&attr))
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
if (!add_string_to_array(msg, attr,
- &r->attributes,
+ &attrs,
&r->num_attributes))
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
+ r->attributes = attrs;
asn1_end_tag(data);
asn1_end_tag(data);
@@ -1368,7 +1566,9 @@ _PUBLIC_ NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg)
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
- if (!ldap_decode_control_value(ctrl, value, ctrl[i])) {
+ if (!ldap_decode_control_value(ctrl, value,
+ control_handlers,
+ ctrl[i])) {
if (ctrl[i]->critical) {
ctrl[i]->data = NULL;
decoded[i] = false;
diff --git a/source3/include/smb_ldap.h b/libcli/ldap/ldap_message.h
index a3c270d95c..c50018465c 100644
--- a/source3/include/smb_ldap.h
+++ b/libcli/ldap/ldap_message.h
@@ -18,8 +18,11 @@
*/
-#ifndef _SMB_LDAP_H
-#define _SMB_LDAP_H
+#ifndef _LIBCLI_LDAP_MESSAGE_H_
+#define _LIBCLI_LDAP_MESSAGE_H_
+
+#include "../libcli/ldap/ldap_errors.h"
+#include "lib/ldb/include/ldb.h"
enum ldap_request_tag {
LDAP_TAG_BindRequest = 0,
@@ -49,15 +52,6 @@ enum ldap_auth_mechanism {
LDAP_AUTH_MECH_SASL = 3
};
-#ifndef LDAP_SUCCESS
-enum ldap_result_code {
- LDAP_SUCCESS = 0,
- LDAP_SASL_BIND_IN_PROGRESS = 0x0e,
- LDAP_INVALID_CREDENTIALS = 0x31,
- LDAP_OTHER = 0x50
-};
-#endif /* LDAP_SUCCESS */
-
struct ldap_Result {
int resultcode;
const char *dn;
@@ -65,12 +59,6 @@ struct ldap_Result {
const char *referral;
};
-struct ldap_attribute {
- const char *name;
- int num_values;
- DATA_BLOB *values;
-};
-
struct ldap_BindRequest {
int version;
const char *dn;
@@ -79,7 +67,7 @@ struct ldap_BindRequest {
const char *password;
struct {
const char *mechanism;
- DATA_BLOB secblob;
+ DATA_BLOB *secblob;/* optional */
} SASL;
} creds;
};
@@ -87,12 +75,12 @@ struct ldap_BindRequest {
struct ldap_BindResponse {
struct ldap_Result response;
union {
- DATA_BLOB secblob;
+ DATA_BLOB *secblob;/* optional */
} SASL;
};
struct ldap_UnbindRequest {
- uint8 __dummy;
+ uint8_t __dummy;
};
enum ldap_scope {
@@ -112,23 +100,22 @@ struct ldap_SearchRequest {
const char *basedn;
enum ldap_scope scope;
enum ldap_deref deref;
- uint32 timelimit;
- uint32 sizelimit;
+ uint32_t timelimit;
+ uint32_t sizelimit;
bool attributesonly;
- char *filter;
+ struct ldb_parse_tree *tree;
int num_attributes;
- const char **attributes;
+ const char * const *attributes;
};
struct ldap_SearchResEntry {
const char *dn;
int num_attributes;
- struct ldap_attribute *attributes;
+ struct ldb_message_element *attributes;
};
struct ldap_SearchResRef {
- int num_referrals;
- const char **referrals;
+ const char *referral;
};
enum ldap_modify_type {
@@ -140,7 +127,7 @@ enum ldap_modify_type {
struct ldap_mod {
enum ldap_modify_type type;
- struct ldap_attribute attrib;
+ struct ldb_message_element attrib;
};
struct ldap_ModifyRequest {
@@ -152,7 +139,7 @@ struct ldap_ModifyRequest {
struct ldap_AddRequest {
const char *dn;
int num_attributes;
- struct ldap_attribute *attributes;
+ struct ldb_message_element *attributes;
};
struct ldap_DelRequest {
@@ -163,31 +150,32 @@ struct ldap_ModifyDNRequest {
const char *dn;
const char *newrdn;
bool deleteolddn;
- const char *newsuperior;
+ const char *newsuperior;/* optional */
};
struct ldap_CompareRequest {
const char *dn;
const char *attribute;
- const char *value;
+ DATA_BLOB value;
};
struct ldap_AbandonRequest {
- uint32 messageid;
+ int messageid;
};
struct ldap_ExtendedRequest {
const char *oid;
- DATA_BLOB value;
+ DATA_BLOB *value;/* optional */
};
struct ldap_ExtendedResponse {
struct ldap_Result response;
- const char *name;
- DATA_BLOB value;
+ const char *oid;/* optional */
+ DATA_BLOB *value;/* optional */
};
union ldap_Request {
+ struct ldap_Result GeneralResult;
struct ldap_BindRequest BindRequest;
struct ldap_BindResponse BindResponse;
struct ldap_UnbindRequest UnbindRequest;
@@ -210,46 +198,38 @@ union ldap_Request {
struct ldap_ExtendedResponse ExtendedResponse;
};
-struct ldap_Control {
- const char *oid;
- bool critical;
- DATA_BLOB value;
-};
struct ldap_message {
- TALLOC_CTX *mem_ctx;
- uint32 messageid;
- uint8 type;
- union ldap_Request r;
- int num_controls;
- struct ldap_Control *controls;
+ int messageid;
+ enum ldap_request_tag type;
+ union ldap_Request r;
+ struct ldb_control **controls;
+ bool *controls_decoded;
};
-struct ldap_queue_entry {
- struct ldap_queue_entry *next, *prev;
- int msgid;
- struct ldap_message *msg;
+struct ldap_control_handler {
+ const char *oid;
+ bool (*decode)(void *mem_ctx, DATA_BLOB in, void *_out);
+ bool (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
};
-struct ldap_connection {
- TALLOC_CTX *mem_ctx;
- int sock;
- int next_msgid;
- char *host;
- uint16 port;
- bool ldaps;
-
- const char *auth_dn;
- const char *simple_pw;
+struct asn1_data;
- /* Current outstanding search entry */
- int searchid;
+struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx);
+NTSTATUS ldap_decode(struct asn1_data *data,
+ const struct ldap_control_handler *control_handlers,
+ struct ldap_message *msg);
+bool ldap_encode(struct ldap_message *msg,
+ const struct ldap_control_handler *control_handlers,
+ DATA_BLOB *result, TALLOC_CTX *mem_ctx);
+NTSTATUS ldap_full_packet(void *private_data, DATA_BLOB blob, size_t *packet_size);
- /* List for incoming search entries */
- struct ldap_queue_entry *search_entries;
+bool asn1_read_OctetString_talloc(TALLOC_CTX *mem_ctx,
+ struct asn1_data *data,
+ const char **result);
- /* Outstanding LDAP requests that have not yet been replied to */
- struct ldap_queue_entry *outstanding;
-};
+void ldap_decode_attribs_bare(TALLOC_CTX *mem_ctx, struct asn1_data *data,
+ struct ldb_message_element **attributes,
+ int *num_attributes);
-#endif
+#endif
diff --git a/source4/libcli/ldap/ldap_ndr.c b/libcli/ldap/ldap_ndr.c
index f0a11ba41f..dd820ff8d5 100644
--- a/source4/libcli/ldap/ldap_ndr.c
+++ b/libcli/ldap/ldap_ndr.c
@@ -21,7 +21,7 @@
*/
#include "includes.h"
-#include "libcli/ldap/ldap.h"
+#include "lib/ldb/include/ldb.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "libcli/ldap/ldap_ndr.h"
diff --git a/source4/libcli/ldap/ldap_ndr.h b/libcli/ldap/ldap_ndr.h
index ee1f702c78..ee1f702c78 100644
--- a/source4/libcli/ldap/ldap_ndr.h
+++ b/libcli/ldap/ldap_ndr.h
diff --git a/libcli/util/doserr.c b/libcli/util/doserr.c
index 226c2f950d..1044ab351a 100644
--- a/libcli/util/doserr.c
+++ b/libcli/util/doserr.c
@@ -169,6 +169,7 @@ static const struct werror_code_struct dos_errs[] =
{ "WERR_SERVICE_NEVER_STARTED", WERR_SERVICE_NEVER_STARTED },
{ "WERR_PASSWORD_MUST_CHANGE", WERR_PASSWORD_MUST_CHANGE },
{ "WERR_ACCOUNT_LOCKED_OUT", WERR_ACCOUNT_LOCKED_OUT },
+ { "WERR_UNKNOWN_PRINT_MONITOR", WERR_UNKNOWN_PRINT_MONITOR },
{ NULL, W_ERROR(0) }
};
diff --git a/librpc/gen_ndr/cli_spoolss.c b/librpc/gen_ndr/cli_spoolss.c
index 02a05b94ff..2aa42b93bf 100644
--- a/librpc/gen_ndr/cli_spoolss.c
+++ b/librpc/gen_ndr/cli_spoolss.c
@@ -2540,7 +2540,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDriver2(struct rpc_pipe_client *cli,
uint32_t offered /* [in] */,
uint32_t client_major_version /* [in] */,
uint32_t client_minor_version /* [in] */,
- DATA_BLOB *info /* [out] [unique] */,
+ union spoolss_DriverInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
uint32_t *needed /* [out] [ref] */,
uint32_t *server_major_version /* [out] [ref] */,
uint32_t *server_minor_version /* [out] [ref] */,
diff --git a/librpc/gen_ndr/cli_spoolss.h b/librpc/gen_ndr/cli_spoolss.h
index bb38d59cfb..83b2e28729 100644
--- a/librpc/gen_ndr/cli_spoolss.h
+++ b/librpc/gen_ndr/cli_spoolss.h
@@ -331,7 +331,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDriver2(struct rpc_pipe_client *cli,
uint32_t offered /* [in] */,
uint32_t client_major_version /* [in] */,
uint32_t client_minor_version /* [in] */,
- DATA_BLOB *info /* [out] [unique] */,
+ union spoolss_DriverInfo *info /* [out] [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */,
uint32_t *needed /* [out] [ref] */,
uint32_t *server_major_version /* [out] [ref] */,
uint32_t *server_minor_version /* [out] [ref] */,
diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c
index 242041fb8d..fdafa2582b 100644
--- a/librpc/gen_ndr/ndr_spoolss.c
+++ b/librpc/gen_ndr/ndr_spoolss.c
@@ -3867,36 +3867,20 @@ static enum ndr_err_code ndr_push_spoolss_SetPrinterInfo3(struct ndr_push *ndr,
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
- NDR_CHECK(ndr_push_unique_ptr(ndr, r->secdesc));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->sec_desc_ptr));
}
if (ndr_flags & NDR_BUFFERS) {
- if (r->secdesc) {
- NDR_CHECK(ndr_push_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, r->secdesc));
- }
}
return NDR_ERR_SUCCESS;
}
static enum ndr_err_code ndr_pull_spoolss_SetPrinterInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_SetPrinterInfo3 *r)
{
- uint32_t _ptr_secdesc;
- TALLOC_CTX *_mem_save_secdesc_0;
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_pull_align(ndr, 4));
- NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_secdesc));
- if (_ptr_secdesc) {
- NDR_PULL_ALLOC(ndr, r->secdesc);
- } else {
- r->secdesc = NULL;
- }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->sec_desc_ptr));
}
if (ndr_flags & NDR_BUFFERS) {
- if (r->secdesc) {
- _mem_save_secdesc_0 = NDR_PULL_GET_MEM_CTX(ndr);
- NDR_PULL_SET_MEM_CTX(ndr, r->secdesc, 0);
- NDR_CHECK(ndr_pull_security_descriptor(ndr, NDR_SCALARS|NDR_BUFFERS, r->secdesc));
- NDR_PULL_SET_MEM_CTX(ndr, _mem_save_secdesc_0, 0);
- }
}
return NDR_ERR_SUCCESS;
}
@@ -3905,12 +3889,7 @@ _PUBLIC_ void ndr_print_spoolss_SetPrinterInfo3(struct ndr_print *ndr, const cha
{
ndr_print_struct(ndr, name, "spoolss_SetPrinterInfo3");
ndr->depth++;
- ndr_print_ptr(ndr, "secdesc", r->secdesc);
- ndr->depth++;
- if (r->secdesc) {
- ndr_print_security_descriptor(ndr, "secdesc", r->secdesc);
- }
- ndr->depth--;
+ ndr_print_uint32(ndr, "sec_desc_ptr", r->sec_desc_ptr);
ndr->depth--;
}
@@ -4279,7 +4258,7 @@ static enum ndr_err_code ndr_push_spoolss_SetPrinterInfo(struct ndr_push *ndr, i
case 3:
if (r->info3) {
- NDR_CHECK(ndr_push_spoolss_SetPrinterInfo3(ndr, NDR_SCALARS|NDR_BUFFERS, r->info3));
+ NDR_CHECK(ndr_push_spoolss_SetPrinterInfo3(ndr, NDR_SCALARS, r->info3));
}
break;
@@ -4486,7 +4465,7 @@ static enum ndr_err_code ndr_pull_spoolss_SetPrinterInfo(struct ndr_pull *ndr, i
if (r->info3) {
_mem_save_info3_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->info3, 0);
- NDR_CHECK(ndr_pull_spoolss_SetPrinterInfo3(ndr, NDR_SCALARS|NDR_BUFFERS, r->info3));
+ NDR_CHECK(ndr_pull_spoolss_SetPrinterInfo3(ndr, NDR_SCALARS, r->info3));
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info3_0, 0);
}
break;
@@ -4796,13 +4775,13 @@ _PUBLIC_ void ndr_print_spoolss_AddDriverInfo1(struct ndr_print *ndr, const char
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverOSVersion(struct ndr_push *ndr, int ndr_flags, enum spoolss_DriverOSVersion r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverOSVersion(struct ndr_push *ndr, int ndr_flags, enum spoolss_DriverOSVersion r)
{
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverOSVersion(struct ndr_pull *ndr, int ndr_flags, enum spoolss_DriverOSVersion *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverOSVersion(struct ndr_pull *ndr, int ndr_flags, enum spoolss_DriverOSVersion *r)
{
uint32_t v;
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
@@ -5704,7 +5683,7 @@ static enum ndr_err_code ndr_push_spoolss_AddDriverInfo6(struct ndr_push *ndr, i
NDR_CHECK(ndr_push_unique_ptr(ndr, r->dependent_files));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ((ndr_size_spoolss_StringArray(r->previous_names, ndr->iconv_convenience, ndr->flags) - 4) / 2)));
NDR_CHECK(ndr_push_unique_ptr(ndr, r->previous_names));
- NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_data));
+ NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_date));
NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version));
NDR_CHECK(ndr_push_unique_ptr(ndr, r->manufacturer_name));
NDR_CHECK(ndr_push_unique_ptr(ndr, r->manufacturer_url));
@@ -5889,7 +5868,7 @@ static enum ndr_err_code ndr_pull_spoolss_AddDriverInfo6(struct ndr_pull *ndr, i
} else {
r->previous_names = NULL;
}
- NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_data));
+ NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_date));
NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version));
NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_name));
if (_ptr_manufacturer_name) {
@@ -6144,7 +6123,7 @@ _PUBLIC_ void ndr_print_spoolss_AddDriverInfo6(struct ndr_print *ndr, const char
ndr_print_spoolss_StringArray(ndr, "previous_names", r->previous_names);
}
ndr->depth--;
- ndr_print_NTTIME(ndr, "driver_data", r->driver_data);
+ ndr_print_NTTIME(ndr, "driver_date", r->driver_date);
ndr_print_hyper(ndr, "driver_version", r->driver_version);
ndr_print_ptr(ndr, "manufacturer_name", r->manufacturer_name);
ndr->depth++;
@@ -6190,7 +6169,7 @@ static enum ndr_err_code ndr_push_spoolss_AddDriverInfo8(struct ndr_push *ndr, i
NDR_CHECK(ndr_push_unique_ptr(ndr, r->dependent_files));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ((ndr_size_spoolss_StringArray(r->previous_names, ndr->iconv_convenience, ndr->flags) - 4) / 2)));
NDR_CHECK(ndr_push_unique_ptr(ndr, r->previous_names));
- NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_data));
+ NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_date));
NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version));
NDR_CHECK(ndr_push_unique_ptr(ndr, r->manufacturer_name));
NDR_CHECK(ndr_push_unique_ptr(ndr, r->manufacturer_url));
@@ -6419,7 +6398,7 @@ static enum ndr_err_code ndr_pull_spoolss_AddDriverInfo8(struct ndr_pull *ndr, i
} else {
r->previous_names = NULL;
}
- NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_data));
+ NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_date));
NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version));
NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_name));
if (_ptr_manufacturer_name) {
@@ -6757,7 +6736,7 @@ _PUBLIC_ void ndr_print_spoolss_AddDriverInfo8(struct ndr_print *ndr, const char
ndr_print_spoolss_StringArray(ndr, "previous_names", r->previous_names);
}
ndr->depth--;
- ndr_print_NTTIME(ndr, "driver_data", r->driver_data);
+ ndr_print_NTTIME(ndr, "driver_date", r->driver_date);
ndr_print_hyper(ndr, "driver_version", r->driver_version);
ndr_print_ptr(ndr, "manufacturer_name", r->manufacturer_name);
ndr->depth++;
@@ -7148,7 +7127,7 @@ _PUBLIC_ void ndr_print_spoolss_AddDriverInfoCtr(struct ndr_print *ndr, const ch
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo1 *r)
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo1 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
@@ -7173,7 +7152,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo1(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo1 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo1 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -7225,7 +7204,12 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo1(struct ndr_print *ndr, const char *n
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo2 *r)
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo1(const struct spoolss_DriverInfo1 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo1, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo2 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
@@ -7311,7 +7295,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo2(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo2 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo2 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -7505,7 +7489,12 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo2(struct ndr_print *ndr, const char *n
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo3 *r)
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo2(const struct spoolss_DriverInfo2 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo2, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo3 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
@@ -7651,7 +7640,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo3(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo3 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo3 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -7985,7 +7974,12 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo3(struct ndr_print *ndr, const char *n
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo4 *r)
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo3(const struct spoolss_DriverInfo3 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo3, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo4 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
@@ -8146,7 +8140,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo4(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo4 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo4 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -8515,7 +8509,12 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo4(struct ndr_print *ndr, const char *n
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo5 *r)
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo4(const struct spoolss_DriverInfo4 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo4, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo5 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 4));
@@ -8604,7 +8603,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo5(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo5 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo5 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -8804,7 +8803,12 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo5(struct ndr_print *ndr, const char *n
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo6 *r)
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo5(const struct spoolss_DriverInfo5 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo5, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo6 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 8));
@@ -8869,7 +8873,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo6(struct ndr_push *ndr, int
NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous_names));
ndr->flags = _flags_save_string_array;
}
- NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_data));
+ NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_date));
NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version));
{
uint32_t _flags_save_string = ndr->flags;
@@ -9027,7 +9031,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo6(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo6 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo6 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -9180,7 +9184,7 @@ static enum ndr_err_code ndr_pull_spoolss_DriverInfo6(struct ndr_pull *ndr, int
}
ndr->flags = _flags_save_string_array;
}
- NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_data));
+ NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_date));
NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version));
{
uint32_t _flags_save_string = ndr->flags;
@@ -9511,7 +9515,7 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo6(struct ndr_print *ndr, const char *n
ndr_print_string_array(ndr, "previous_names", r->previous_names);
}
ndr->depth--;
- ndr_print_NTTIME(ndr, "driver_data", r->driver_data);
+ ndr_print_NTTIME(ndr, "driver_date", r->driver_date);
ndr_print_hyper(ndr, "driver_version", r->driver_version);
ndr_print_ptr(ndr, "manufacturer_name", r->manufacturer_name);
ndr->depth++;
@@ -9540,7 +9544,12 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo6(struct ndr_print *ndr, const char *n
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_DriverInfo8(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo8 *r)
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo6(const struct spoolss_DriverInfo6 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo6, ic);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo8(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo8 *r)
{
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_push_align(ndr, 8));
@@ -9605,7 +9614,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo8(struct ndr_push *ndr, int
NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous_names));
ndr->flags = _flags_save_string_array;
}
- NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_data));
+ NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_date));
NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version));
{
uint32_t _flags_save_string = ndr->flags;
@@ -9841,7 +9850,7 @@ static enum ndr_err_code ndr_push_spoolss_DriverInfo8(struct ndr_push *ndr, int
return NDR_ERR_SUCCESS;
}
-static enum ndr_err_code ndr_pull_spoolss_DriverInfo8(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo8 *r)
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo8(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo8 *r)
{
uint32_t _ptr_driver_name;
TALLOC_CTX *_mem_save_driver_name_0;
@@ -10004,7 +10013,7 @@ static enum ndr_err_code ndr_pull_spoolss_DriverInfo8(struct ndr_pull *ndr, int
}
ndr->flags = _flags_save_string_array;
}
- NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_data));
+ NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_date));
NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version));
{
uint32_t _flags_save_string = ndr->flags;
@@ -10473,7 +10482,7 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo8(struct ndr_print *ndr, const char *n
ndr_print_string_array(ndr, "previous_names", r->previous_names);
}
ndr->depth--;
- ndr_print_NTTIME(ndr, "driver_data", r->driver_data);
+ ndr_print_NTTIME(ndr, "driver_date", r->driver_date);
ndr_print_hyper(ndr, "driver_version", r->driver_version);
ndr_print_ptr(ndr, "manufacturer_name", r->manufacturer_name);
ndr->depth++;
@@ -10535,6 +10544,208 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo8(struct ndr_print *ndr, const char *n
ndr->depth--;
}
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo8(const struct spoolss_DriverInfo8 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo8, ic);
+}
+
+static enum ndr_err_code ndr_push_spoolss_DriverFileType(struct ndr_push *ndr, int ndr_flags, enum spoolss_DriverFileType r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_DriverFileType(struct ndr_pull *ndr, int ndr_flags, enum spoolss_DriverFileType *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_DriverFileType(struct ndr_print *ndr, const char *name, enum spoolss_DriverFileType r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case SPOOLSS_DRIVER_FILE_TYPE_RENDERING: val = "SPOOLSS_DRIVER_FILE_TYPE_RENDERING"; break;
+ case SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION: val = "SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION"; break;
+ case SPOOLSS_DRIVER_FILE_TYPE_DATA: val = "SPOOLSS_DRIVER_FILE_TYPE_DATA"; break;
+ case SPOOLSS_DRIVER_FILE_TYPE_HELP: val = "SPOOLSS_DRIVER_FILE_TYPE_HELP"; break;
+ case SPOOLSS_DRIVER_FILE_TYPE_OTHER: val = "SPOOLSS_DRIVER_FILE_TYPE_OTHER"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverFileInfo(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverFileInfo *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->file_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_spoolss_DriverFileType(ndr, NDR_SCALARS, r->file_type));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->file_version));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->file_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->file_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->file_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverFileInfo(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverFileInfo *r)
+{
+ uint32_t _ptr_file_name;
+ TALLOC_CTX *_mem_save_file_name_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_file_name));
+ if (_ptr_file_name) {
+ NDR_PULL_ALLOC(ndr, r->file_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->file_name, _ptr_file_name));
+ } else {
+ r->file_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_spoolss_DriverFileType(ndr, NDR_SCALARS, &r->file_type));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->file_version));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->file_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->file_name));
+ _mem_save_file_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->file_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->file_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_name_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_DriverFileInfo(struct ndr_print *ndr, const char *name, const struct spoolss_DriverFileInfo *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_DriverFileInfo");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "file_name", r->file_name);
+ ndr->depth++;
+ if (r->file_name) {
+ ndr_print_string(ndr, "file_name", r->file_name);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_DriverFileType(ndr, "file_type", r->file_type);
+ ndr_print_uint32(ndr, "file_version", r->file_version);
+ ndr->depth--;
+}
+
+_PUBLIC_ void ndr_print_spoolss_DriverInfo101(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo101 *r)
+{
+ uint32_t cntr_file_info_1;
+ ndr_print_struct(ndr, name, "spoolss_DriverInfo101");
+ ndr->depth++;
+ ndr_print_spoolss_DriverOSVersion(ndr, "version", r->version);
+ ndr_print_ptr(ndr, "driver_name", r->driver_name);
+ ndr->depth++;
+ if (r->driver_name) {
+ ndr_print_string(ndr, "driver_name", r->driver_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "architecture", r->architecture);
+ ndr->depth++;
+ if (r->architecture) {
+ ndr_print_string(ndr, "architecture", r->architecture);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "file_info", r->file_info);
+ ndr->depth++;
+ if (r->file_info) {
+ ndr->print(ndr, "%s: ARRAY(%d)", "file_info", (int)r->file_count);
+ ndr->depth++;
+ for (cntr_file_info_1=0;cntr_file_info_1<r->file_count;cntr_file_info_1++) {
+ char *idx_1=NULL;
+ if (asprintf(&idx_1, "[%d]", cntr_file_info_1) != -1) {
+ ndr_print_spoolss_DriverFileInfo(ndr, "file_info", &r->file_info[cntr_file_info_1]);
+ free(idx_1);
+ }
+ }
+ ndr->depth--;
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "file_count", r->file_count);
+ ndr_print_ptr(ndr, "monitor_name", r->monitor_name);
+ ndr->depth++;
+ if (r->monitor_name) {
+ ndr_print_string(ndr, "monitor_name", r->monitor_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "default_datatype", r->default_datatype);
+ ndr->depth++;
+ if (r->default_datatype) {
+ ndr_print_string(ndr, "default_datatype", r->default_datatype);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "previous_names", r->previous_names);
+ ndr->depth++;
+ if (r->previous_names) {
+ ndr_print_string_array(ndr, "previous_names", r->previous_names);
+ }
+ ndr->depth--;
+ ndr_print_NTTIME(ndr, "driver_date", r->driver_date);
+ ndr_print_hyper(ndr, "driver_version", r->driver_version);
+ ndr_print_ptr(ndr, "manufacturer_name", r->manufacturer_name);
+ ndr->depth++;
+ if (r->manufacturer_name) {
+ ndr_print_string(ndr, "manufacturer_name", r->manufacturer_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "manufacturer_url", r->manufacturer_url);
+ ndr->depth++;
+ if (r->manufacturer_url) {
+ ndr_print_string(ndr, "manufacturer_url", r->manufacturer_url);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "hardware_id", r->hardware_id);
+ ndr->depth++;
+ if (r->hardware_id) {
+ ndr_print_string(ndr, "hardware_id", r->hardware_id);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "provider", r->provider);
+ ndr->depth++;
+ if (r->provider) {
+ ndr_print_string(ndr, "provider", r->provider);
+ }
+ ndr->depth--;
+ ndr->depth--;
+}
+
+_PUBLIC_ size_t ndr_size_spoolss_DriverInfo101(const struct spoolss_DriverInfo101 *r, struct smb_iconv_convenience *ic, int flags)
+{
+ return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_DriverInfo101, ic);
+}
+
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverInfo *r)
{
uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);
@@ -10583,6 +10794,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int
NDR_CHECK(ndr_push_spoolss_DriverInfo8(ndr, NDR_SCALARS, &r->info8));
break; }
+ case 101: {
+ NDR_CHECK(ndr_push_align(ndr, 8));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_DriverInfo101(ndr, NDR_SCALARS, &r->info101));
+ break; }
+
default: {
break; }
@@ -10620,6 +10837,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int
NDR_CHECK(ndr_push_spoolss_DriverInfo8(ndr, NDR_BUFFERS, &r->info8));
break;
+ case 101:
+ NDR_CHECK(ndr_push_spoolss_DriverInfo101(ndr, NDR_BUFFERS, &r->info101));
+ break;
+
default:
break;
@@ -10678,6 +10899,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo(struct ndr_pull *ndr, int
NDR_CHECK(ndr_pull_spoolss_DriverInfo8(ndr, NDR_SCALARS, &r->info8));
break; }
+ case 101: {
+ NDR_CHECK(ndr_pull_align(ndr, 8));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_DriverInfo101(ndr, NDR_SCALARS, &r->info101));
+ break; }
+
default: {
break; }
@@ -10714,6 +10941,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo(struct ndr_pull *ndr, int
NDR_CHECK(ndr_pull_spoolss_DriverInfo8(ndr, NDR_BUFFERS, &r->info8));
break;
+ case 101:
+ NDR_CHECK(ndr_pull_spoolss_DriverInfo101(ndr, NDR_BUFFERS, &r->info101));
+ break;
+
default:
break;
@@ -10757,6 +10988,10 @@ _PUBLIC_ void ndr_print_spoolss_DriverInfo(struct ndr_print *ndr, const char *na
ndr_print_spoolss_DriverInfo8(ndr, "info8", &r->info8);
break;
+ case 101:
+ ndr_print_spoolss_DriverInfo101(ndr, "info101", &r->info101);
+ break;
+
default:
break;
@@ -19840,7 +20075,13 @@ static enum ndr_err_code ndr_push_spoolss_GetPrinterDriver2(struct ndr_push *ndr
if (flags & NDR_OUT) {
NDR_CHECK(ndr_push_unique_ptr(ndr, r->out.info));
if (r->out.info) {
- NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.info));
+ {
+ struct ndr_push *_ndr_info;
+ NDR_CHECK(ndr_push_subcontext_start(ndr, &_ndr_info, 4, r->in.offered));
+ NDR_CHECK(ndr_push_set_switch_value(_ndr_info, r->out.info, r->in.level));
+ NDR_CHECK(ndr_push_spoolss_DriverInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 4, r->in.offered));
+ }
}
if (r->out.needed == NULL) {
return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
@@ -19932,7 +20173,13 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDriver2(struct ndr_pull *ndr
if (r->out.info) {
_mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
NDR_PULL_SET_MEM_CTX(ndr, r->out.info, 0);
- NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.info));
+ {
+ struct ndr_pull *_ndr_info;
+ NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_info, 4, r->in.offered));
+ NDR_CHECK(ndr_pull_set_switch_value(_ndr_info, r->out.info, r->in.level));
+ NDR_CHECK(ndr_pull_spoolss_DriverInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_info, 4, r->in.offered));
+ }
NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
}
if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
@@ -19999,7 +20246,8 @@ _PUBLIC_ void ndr_print_spoolss_GetPrinterDriver2(struct ndr_print *ndr, const c
ndr_print_ptr(ndr, "info", r->out.info);
ndr->depth++;
if (r->out.info) {
- ndr_print_DATA_BLOB(ndr, "info", *r->out.info);
+ ndr_print_set_switch_value(ndr, r->out.info, r->in.level);
+ ndr_print_spoolss_DriverInfo(ndr, "info", r->out.info);
}
ndr->depth--;
ndr_print_ptr(ndr, "needed", r->out.needed);
diff --git a/librpc/gen_ndr/ndr_spoolss.h b/librpc/gen_ndr/ndr_spoolss.h
index b9a533ab38..5b32d510c0 100644
--- a/librpc/gen_ndr/ndr_spoolss.h
+++ b/librpc/gen_ndr/ndr_spoolss.h
@@ -256,6 +256,8 @@ enum ndr_err_code ndr_push_spoolss_StringArray(struct ndr_push *ndr, int ndr_fla
enum ndr_err_code ndr_pull_spoolss_StringArray(struct ndr_pull *ndr, int ndr_flags, struct spoolss_StringArray *r);
void ndr_print_spoolss_StringArray(struct ndr_print *ndr, const char *name, const struct spoolss_StringArray *r);
void ndr_print_spoolss_AddDriverInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_AddDriverInfo1 *r);
+enum ndr_err_code ndr_push_spoolss_DriverOSVersion(struct ndr_push *ndr, int ndr_flags, enum spoolss_DriverOSVersion r);
+enum ndr_err_code ndr_pull_spoolss_DriverOSVersion(struct ndr_pull *ndr, int ndr_flags, enum spoolss_DriverOSVersion *r);
void ndr_print_spoolss_DriverOSVersion(struct ndr_print *ndr, const char *name, enum spoolss_DriverOSVersion r);
void ndr_print_spoolss_AddDriverInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_AddDriverInfo2 *r);
void ndr_print_spoolss_AddDriverInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_AddDriverInfo3 *r);
@@ -264,13 +266,42 @@ void ndr_print_spoolss_AddDriverInfo6(struct ndr_print *ndr, const char *name, c
void ndr_print_spoolss_AddDriverInfo8(struct ndr_print *ndr, const char *name, const struct spoolss_AddDriverInfo8 *r);
void ndr_print_spoolss_AddDriverInfo(struct ndr_print *ndr, const char *name, const union spoolss_AddDriverInfo *r);
void ndr_print_spoolss_AddDriverInfoCtr(struct ndr_print *ndr, const char *name, const struct spoolss_AddDriverInfoCtr *r);
+enum ndr_err_code ndr_push_spoolss_DriverInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo1 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo1 *r);
void ndr_print_spoolss_DriverInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo1 *r);
+size_t ndr_size_spoolss_DriverInfo1(const struct spoolss_DriverInfo1 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_DriverInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo2 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo2 *r);
void ndr_print_spoolss_DriverInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo2 *r);
+size_t ndr_size_spoolss_DriverInfo2(const struct spoolss_DriverInfo2 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_DriverInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo3 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo3 *r);
void ndr_print_spoolss_DriverInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo3 *r);
+size_t ndr_size_spoolss_DriverInfo3(const struct spoolss_DriverInfo3 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_DriverInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo4 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo4 *r);
void ndr_print_spoolss_DriverInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo4 *r);
+size_t ndr_size_spoolss_DriverInfo4(const struct spoolss_DriverInfo4 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_DriverInfo5(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo5 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo5(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo5 *r);
void ndr_print_spoolss_DriverInfo5(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo5 *r);
+size_t ndr_size_spoolss_DriverInfo5(const struct spoolss_DriverInfo5 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_DriverInfo6(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo6 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo6(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo6 *r);
void ndr_print_spoolss_DriverInfo6(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo6 *r);
+size_t ndr_size_spoolss_DriverInfo6(const struct spoolss_DriverInfo6 *r, struct smb_iconv_convenience *ic, int flags);
+enum ndr_err_code ndr_push_spoolss_DriverInfo8(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo8 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo8(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo8 *r);
void ndr_print_spoolss_DriverInfo8(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo8 *r);
+size_t ndr_size_spoolss_DriverInfo8(const struct spoolss_DriverInfo8 *r, struct smb_iconv_convenience *ic, int flags);
+void ndr_print_spoolss_DriverFileType(struct ndr_print *ndr, const char *name, enum spoolss_DriverFileType r);
+enum ndr_err_code ndr_push_spoolss_DriverFileInfo(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverFileInfo *r);
+enum ndr_err_code ndr_pull_spoolss_DriverFileInfo(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverFileInfo *r);
+void ndr_print_spoolss_DriverFileInfo(struct ndr_print *ndr, const char *name, const struct spoolss_DriverFileInfo *r);
+enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r);
+enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r);
+void ndr_print_spoolss_DriverInfo101(struct ndr_print *ndr, const char *name, const struct spoolss_DriverInfo101 *r);
+size_t ndr_size_spoolss_DriverInfo101(const struct spoolss_DriverInfo101 *r, struct smb_iconv_convenience *ic, int flags);
enum ndr_err_code ndr_push_spoolss_DriverInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_DriverInfo *r);
enum ndr_err_code ndr_pull_spoolss_DriverInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_DriverInfo *r);
void ndr_print_spoolss_DriverInfo(struct ndr_print *ndr, const char *name, const union spoolss_DriverInfo *r);
diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h
index 150bf04d6f..ad4554dbe5 100644
--- a/librpc/gen_ndr/spoolss.h
+++ b/librpc/gen_ndr/spoolss.h
@@ -10,6 +10,7 @@
#define PRINTER_ENUM_ICONMASK ( (PRINTER_ENUM_ICON1|PRINTER_ENUM_ICON2|PRINTER_ENUM_ICON3|PRINTER_ENUM_ICON4|PRINTER_ENUM_ICON5|PRINTER_ENUM_ICON6|PRINTER_ENUM_ICON7|PRINTER_ENUM_ICON8) )
#define SPOOLSS_ARCHITECTURE_NT_X86 ( "Windows NT x86" )
+#define SPOOLSS_DEFAULT_SERVER_PATH ( "C:\\WINDOWS\\system32\\spool" )
#define PRINTER_CHANGE_PRINTER ( 0x000000FF )
#define PRINTER_CHANGE_JOB ( 0x0000FF00 )
#define PRINTER_CHANGE_FORM ( (PRINTER_CHANGE_ADD_FORM|PRINTER_CHANGE_SET_FORM|PRINTER_CHANGE_DELETE_FORM) )
@@ -500,7 +501,7 @@ struct spoolss_SetPrinterInfo2 {
};
struct spoolss_SetPrinterInfo3 {
- struct security_descriptor *secdesc;/* [unique] */
+ uint32_t sec_desc_ptr;
};
struct spoolss_SetPrinterInfo4 {
@@ -635,7 +636,7 @@ struct spoolss_AddDriverInfo6 {
struct spoolss_StringArray *dependent_files;/* [unique] */
uint32_t _ndr_size_previous_names;/* [value(((ndr_size_spoolss_StringArray(previous_names,ndr->iconv_convenience,ndr->flags)-4)/2))] */
struct spoolss_StringArray *previous_names;/* [unique] */
- NTTIME driver_data;
+ NTTIME driver_date;
uint64_t driver_version;
const char *manufacturer_name;/* [unique,charset(UTF16)] */
const char *manufacturer_url;/* [unique,charset(UTF16)] */
@@ -657,7 +658,7 @@ struct spoolss_AddDriverInfo8 {
struct spoolss_StringArray *dependent_files;/* [unique] */
uint32_t _ndr_size_previous_names;/* [value(((ndr_size_spoolss_StringArray(previous_names,ndr->iconv_convenience,ndr->flags)-4)/2))] */
struct spoolss_StringArray *previous_names;/* [unique] */
- NTTIME driver_data;
+ NTTIME driver_date;
uint64_t driver_version;
const char *manufacturer_name;/* [unique,charset(UTF16)] */
const char *manufacturer_url;/* [unique,charset(UTF16)] */
@@ -691,7 +692,7 @@ struct spoolss_AddDriverInfoCtr {
struct spoolss_DriverInfo1 {
const char * driver_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
-};
+}/* [gensize,public] */;
struct spoolss_DriverInfo2 {
enum spoolss_DriverOSVersion version;
@@ -700,7 +701,7 @@ struct spoolss_DriverInfo2 {
const char * driver_path;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * data_file;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * config_file;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
-};
+}/* [gensize,public] */;
struct spoolss_DriverInfo3 {
enum spoolss_DriverOSVersion version;
@@ -713,7 +714,7 @@ struct spoolss_DriverInfo3 {
const char ** dependent_files;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * monitor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * default_datatype;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
-};
+}/* [gensize,public] */;
struct spoolss_DriverInfo4 {
enum spoolss_DriverOSVersion version;
@@ -727,7 +728,7 @@ struct spoolss_DriverInfo4 {
const char * monitor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * default_datatype;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char ** previous_names;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
-};
+}/* [gensize,public] */;
struct spoolss_DriverInfo5 {
enum spoolss_DriverOSVersion version;
@@ -739,7 +740,7 @@ struct spoolss_DriverInfo5 {
uint32_t driver_attributes;
uint32_t config_version;
uint32_t driver_version;
-};
+}/* [gensize,public] */;
struct spoolss_DriverInfo6 {
enum spoolss_DriverOSVersion version;
@@ -753,13 +754,13 @@ struct spoolss_DriverInfo6 {
const char * monitor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * default_datatype;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char ** previous_names;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
- NTTIME driver_data;
+ NTTIME driver_date;
uint64_t driver_version;
const char * manufacturer_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * manufacturer_url;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * hardware_id;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * provider;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
-};
+}/* [gensize,public] */;
struct spoolss_DriverInfo8 {
enum spoolss_DriverOSVersion version;
@@ -773,7 +774,7 @@ struct spoolss_DriverInfo8 {
const char * default_datatype;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char ** dependent_files;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char ** previous_names;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
- NTTIME driver_data;
+ NTTIME driver_date;
uint64_t driver_version;
const char * manufacturer_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * manufacturer_url;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
@@ -787,7 +788,49 @@ struct spoolss_DriverInfo8 {
const char ** core_driver_dependencies;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
NTTIME min_inbox_driver_ver_date;
uint64_t min_inbox_driver_ver_version;
-};
+}/* [gensize,public] */;
+
+enum spoolss_DriverFileType
+#ifndef USE_UINT_ENUMS
+ {
+ SPOOLSS_DRIVER_FILE_TYPE_RENDERING=0x00000000,
+ SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION=0x00000001,
+ SPOOLSS_DRIVER_FILE_TYPE_DATA=0x00000002,
+ SPOOLSS_DRIVER_FILE_TYPE_HELP=0x00000003,
+ SPOOLSS_DRIVER_FILE_TYPE_OTHER=0x00000004
+}
+#else
+ { __donnot_use_enum_spoolss_DriverFileType=0x7FFFFFFF}
+#define SPOOLSS_DRIVER_FILE_TYPE_RENDERING ( 0x00000000 )
+#define SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION ( 0x00000001 )
+#define SPOOLSS_DRIVER_FILE_TYPE_DATA ( 0x00000002 )
+#define SPOOLSS_DRIVER_FILE_TYPE_HELP ( 0x00000003 )
+#define SPOOLSS_DRIVER_FILE_TYPE_OTHER ( 0x00000004 )
+#endif
+;
+
+struct spoolss_DriverFileInfo {
+ const char * file_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ enum spoolss_DriverFileType file_type;
+ uint32_t file_version;
+}/* [public] */;
+
+struct spoolss_DriverInfo101 {
+ enum spoolss_DriverOSVersion version;
+ const char * driver_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * architecture;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct spoolss_DriverFileInfo *file_info;/* [relative,size_is(file_count)] */
+ uint32_t file_count;
+ const char * monitor_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * default_datatype;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char ** previous_names;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ NTTIME driver_date;
+ uint64_t driver_version;
+ const char * manufacturer_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * manufacturer_url;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * hardware_id;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * provider;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+}/* [gensize,nopush,public,nopull] */;
union spoolss_DriverInfo {
struct spoolss_DriverInfo1 info1;/* [case] */
@@ -797,6 +840,7 @@ union spoolss_DriverInfo {
struct spoolss_DriverInfo5 info5;/* [case(5)] */
struct spoolss_DriverInfo6 info6;/* [case(6)] */
struct spoolss_DriverInfo8 info8;/* [case(8)] */
+ struct spoolss_DriverInfo101 info101;/* [case(101)] */
}/* [relative_base,nodiscriminant,public] */;
struct spoolss_DriverDirectoryInfo1 {
@@ -2239,7 +2283,7 @@ struct spoolss_GetPrinterDriver2 {
} in;
struct {
- DATA_BLOB *info;/* [unique] */
+ union spoolss_DriverInfo *info;/* [unique,subcontext_size(offered),subcontext(4),switch_is(level)] */
uint32_t *needed;/* [ref] */
uint32_t *server_major_version;/* [ref] */
uint32_t *server_minor_version;/* [ref] */
diff --git a/librpc/gen_ndr/srv_spoolss.c b/librpc/gen_ndr/srv_spoolss.c
index f6c17cb1fa..891be85376 100644
--- a/librpc/gen_ndr/srv_spoolss.c
+++ b/librpc/gen_ndr/srv_spoolss.c
@@ -4169,7 +4169,7 @@ static bool api_spoolss_GetPrinterDriver2(pipes_struct *p)
}
ZERO_STRUCT(r->out);
- r->out.info = talloc_zero(r, DATA_BLOB);
+ r->out.info = talloc_zero(r, union spoolss_DriverInfo);
if (r->out.info == NULL) {
talloc_free(r);
return false;
@@ -8080,7 +8080,7 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
case NDR_SPOOLSS_GETPRINTERDRIVER2: {
struct spoolss_GetPrinterDriver2 *r = (struct spoolss_GetPrinterDriver2 *)_r;
ZERO_STRUCT(r->out);
- r->out.info = talloc_zero(mem_ctx, DATA_BLOB);
+ r->out.info = talloc_zero(mem_ctx, union spoolss_DriverInfo);
if (r->out.info == NULL) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl
index 17d480261a..3e35399f8d 100644
--- a/librpc/idl/spoolss.idl
+++ b/librpc/idl/spoolss.idl
@@ -552,7 +552,7 @@ import "misc.idl", "security.idl", "winreg.idl";
} spoolss_SetPrinterInfo2;
typedef struct {
- security_descriptor *secdesc;
+ uint32 sec_desc_ptr;
} spoolss_SetPrinterInfo3;
typedef struct {
@@ -628,7 +628,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[string,charset(UTF16)] uint16 *driver_name;
} spoolss_AddDriverInfo1;
- typedef [v1_enum] enum {
+ typedef [v1_enum,public] enum {
SPOOLSS_DRIVER_VERSION_9X = 0,
SPOOLSS_DRIVER_VERSION_NT35 = 1,
SPOOLSS_DRIVER_VERSION_NT4 = 2,
@@ -700,7 +700,7 @@ import "misc.idl", "security.idl", "winreg.idl";
spoolss_StringArray *dependent_files;
[value(((ndr_size_spoolss_StringArray(previous_names, ndr->iconv_convenience, ndr->flags)-4)/2))] uint32 _ndr_size_previous_names;
spoolss_StringArray *previous_names;
- NTTIME driver_data;
+ NTTIME driver_date;
hyper driver_version;
[string,charset(UTF16)] uint16 *manufacturer_name;
[string,charset(UTF16)] uint16 *manufacturer_url;
@@ -722,7 +722,7 @@ import "misc.idl", "security.idl", "winreg.idl";
spoolss_StringArray *dependent_files;
[value(((ndr_size_spoolss_StringArray(previous_names, ndr->iconv_convenience, ndr->flags)-4)/2))] uint32 _ndr_size_previous_names;
spoolss_StringArray *previous_names;
- NTTIME driver_data;
+ NTTIME driver_date;
hyper driver_version;
[string,charset(UTF16)] uint16 *manufacturer_name;
[string,charset(UTF16)] uint16 *manufacturer_url;
@@ -759,11 +759,11 @@ import "misc.idl", "security.idl", "winreg.idl";
[in,ref] spoolss_AddDriverInfoCtr *info_ctr
);
- typedef struct {
+ typedef [public,gensize] struct {
[relative] nstring *driver_name;
} spoolss_DriverInfo1;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_DriverOSVersion version;
[relative] nstring *driver_name;
[relative] nstring *architecture;
@@ -772,7 +772,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *config_file;
} spoolss_DriverInfo2;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_DriverOSVersion version;
[relative] nstring *driver_name;
[relative] nstring *architecture;
@@ -785,7 +785,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *default_datatype;
} spoolss_DriverInfo3;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_DriverOSVersion version;
[relative] nstring *driver_name;
[relative] nstring *architecture;
@@ -799,7 +799,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring_array *previous_names;
} spoolss_DriverInfo4;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_DriverOSVersion version;
[relative] nstring *driver_name;
[relative] nstring *architecture;
@@ -811,7 +811,7 @@ import "misc.idl", "security.idl", "winreg.idl";
uint32 driver_version;
} spoolss_DriverInfo5;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_DriverOSVersion version;
[relative] nstring *driver_name;
[relative] nstring *architecture;
@@ -823,7 +823,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *monitor_name;
[relative] nstring *default_datatype;
[relative] nstring_array *previous_names;
- NTTIME driver_data;
+ NTTIME driver_date;
hyper driver_version;
[relative] nstring *manufacturer_name;
[relative] nstring *manufacturer_url;
@@ -831,7 +831,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *provider;
} spoolss_DriverInfo6;
- typedef struct {
+ typedef [public,gensize] struct {
spoolss_DriverOSVersion version;
[relative] nstring *driver_name;
[relative] nstring *architecture;
@@ -843,7 +843,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *default_datatype;
[relative] nstring_array *dependent_files;
[relative] nstring_array *previous_names;
- NTTIME driver_data;
+ NTTIME driver_date;
hyper driver_version;
[relative] nstring *manufacturer_name;
[relative] nstring *manufacturer_url;
@@ -859,6 +859,37 @@ import "misc.idl", "security.idl", "winreg.idl";
hyper min_inbox_driver_ver_version;
} spoolss_DriverInfo8;
+ typedef [v1_enum] enum {
+ SPOOLSS_DRIVER_FILE_TYPE_RENDERING = 0x00000000,
+ SPOOLSS_DRIVER_FILE_TYPE_CONFIGURATION = 0x00000001,
+ SPOOLSS_DRIVER_FILE_TYPE_DATA = 0x00000002,
+ SPOOLSS_DRIVER_FILE_TYPE_HELP = 0x00000003,
+ SPOOLSS_DRIVER_FILE_TYPE_OTHER = 0x00000004
+ } spoolss_DriverFileType;
+
+ typedef [public] struct {
+ [relative] nstring *file_name;
+ spoolss_DriverFileType file_type;
+ uint32 file_version;
+ } spoolss_DriverFileInfo;
+
+ typedef [public,gensize,nopush,nopull] struct {
+ spoolss_DriverOSVersion version;
+ [relative] nstring *driver_name;
+ [relative] nstring *architecture;
+ [relative] [size_is(file_count)] spoolss_DriverFileInfo *file_info;
+ uint32 file_count;
+ [relative] nstring *monitor_name;
+ [relative] nstring *default_datatype;
+ [relative] nstring_array *previous_names;
+ NTTIME driver_date;
+ hyper driver_version;
+ [relative] nstring *manufacturer_name;
+ [relative] nstring *manufacturer_url;
+ [relative] nstring *hardware_id;
+ [relative] nstring *provider;
+ } spoolss_DriverInfo101;
+
typedef [nodiscriminant,relative_base,public] union {
[case(1)] spoolss_DriverInfo1 info1;
[case(2)] spoolss_DriverInfo2 info2;
@@ -867,6 +898,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[case(5)] spoolss_DriverInfo5 info5;
[case(6)] spoolss_DriverInfo6 info6;
[case(8)] spoolss_DriverInfo8 info8;
+ [case(101)] spoolss_DriverInfo101 info101;
[default];
} spoolss_DriverInfo;
@@ -1086,6 +1118,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x1a */
const string SPOOLSS_ARCHITECTURE_NT_X86 = "Windows NT x86";
+ const string SPOOLSS_DEFAULT_SERVER_PATH = "C:\\WINDOWS\\system32\\spool";
typedef [public,gensize] struct {
[value(ndr_size_spoolss_OSVersion(r,ndr->iconv_convenience,ndr->flags))] uint32 _ndr_size;
@@ -1472,7 +1505,7 @@ import "misc.idl", "security.idl", "winreg.idl";
[in] uint32 offered,
[in] uint32 client_major_version,
[in] uint32 client_minor_version,
- [out,unique] DATA_BLOB *info,
+ [out,unique,subcontext(4),subcontext_size(offered),switch_is(level)] spoolss_DriverInfo *info,
[out,ref] uint32 *needed,
[out,ref] uint32 *server_major_version,
[out,ref] uint32 *server_minor_version
diff --git a/librpc/ndr/ndr_spoolss_buf.c b/librpc/ndr/ndr_spoolss_buf.c
index d7e28ccf0e..afc06be4e0 100644
--- a/librpc/ndr/ndr_spoolss_buf.c
+++ b/librpc/ndr/ndr_spoolss_buf.c
@@ -544,3 +544,481 @@ _PUBLIC_ size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r
return ndr_size_struct(r, flags, (ndr_push_flags_fn_t)ndr_push_spoolss_StringArray, ic);
}
+/* hand marshall as pidl cannot (yet) generate a relative pointer to a fixed array of
+ * structs */
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r)
+{
+ uint32_t cntr_file_info_1;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 8));
+ NDR_CHECK(ndr_push_spoolss_DriverOSVersion(ndr, NDR_SCALARS, r->version));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->driver_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->architecture));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->file_info));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->file_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->monitor_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->default_datatype));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string_array = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->previous_names));
+ ndr->flags = _flags_save_string_array;
+ }
+ NDR_CHECK(ndr_push_NTTIME(ndr, NDR_SCALARS, r->driver_date));
+ NDR_CHECK(ndr_push_hyper(ndr, NDR_SCALARS, r->driver_version));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->manufacturer_name));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->manufacturer_url));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->hardware_id));
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->provider));
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->driver_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->driver_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->driver_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->architecture) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->architecture));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->architecture));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->file_info) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->file_info));
+#if 0
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->file_count));
+#endif
+ for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
+ NDR_CHECK(ndr_push_spoolss_DriverFileInfo(ndr, NDR_SCALARS, &r->file_info[cntr_file_info_1]));
+ }
+ for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
+ NDR_CHECK(ndr_push_spoolss_DriverFileInfo(ndr, NDR_BUFFERS, &r->file_info[cntr_file_info_1]));
+ }
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->monitor_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->monitor_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->monitor_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->default_datatype) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->default_datatype));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->default_datatype));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string_array = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->previous_names) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->previous_names));
+ NDR_CHECK(ndr_push_string_array(ndr, NDR_SCALARS, r->previous_names));
+ }
+ ndr->flags = _flags_save_string_array;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->manufacturer_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->manufacturer_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->manufacturer_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->manufacturer_url) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->manufacturer_url));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->manufacturer_url));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->hardware_id) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->hardware_id));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->hardware_id));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->provider) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->provider));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->provider));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r)
+{
+ uint32_t _ptr_driver_name;
+ TALLOC_CTX *_mem_save_driver_name_0;
+ uint32_t _ptr_architecture;
+ TALLOC_CTX *_mem_save_architecture_0;
+ uint32_t _ptr_file_info;
+ uint32_t cntr_file_info_1;
+ TALLOC_CTX *_mem_save_file_info_0;
+ TALLOC_CTX *_mem_save_file_info_1;
+ uint32_t _ptr_monitor_name;
+ TALLOC_CTX *_mem_save_monitor_name_0;
+ uint32_t _ptr_default_datatype;
+ TALLOC_CTX *_mem_save_default_datatype_0;
+ uint32_t _ptr_previous_names;
+ TALLOC_CTX *_mem_save_previous_names_0;
+ uint32_t _ptr_manufacturer_name;
+ TALLOC_CTX *_mem_save_manufacturer_name_0;
+ uint32_t _ptr_manufacturer_url;
+ TALLOC_CTX *_mem_save_manufacturer_url_0;
+ uint32_t _ptr_hardware_id;
+ TALLOC_CTX *_mem_save_hardware_id_0;
+ uint32_t _ptr_provider;
+ TALLOC_CTX *_mem_save_provider_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 8));
+ NDR_CHECK(ndr_pull_spoolss_DriverOSVersion(ndr, NDR_SCALARS, &r->version));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name));
+ if (_ptr_driver_name) {
+ NDR_PULL_ALLOC(ndr, r->driver_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->driver_name, _ptr_driver_name));
+ } else {
+ r->driver_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_architecture));
+ if (_ptr_architecture) {
+ NDR_PULL_ALLOC(ndr, r->architecture);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->architecture, _ptr_architecture));
+ } else {
+ r->architecture = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_file_info));
+ if (_ptr_file_info) {
+ NDR_PULL_ALLOC(ndr, r->file_info);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->file_info, _ptr_file_info));
+ } else {
+ r->file_info = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->file_count));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_monitor_name));
+ if (_ptr_monitor_name) {
+ NDR_PULL_ALLOC(ndr, r->monitor_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->monitor_name, _ptr_monitor_name));
+ } else {
+ r->monitor_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_default_datatype));
+ if (_ptr_default_datatype) {
+ NDR_PULL_ALLOC(ndr, r->default_datatype);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->default_datatype, _ptr_default_datatype));
+ } else {
+ r->default_datatype = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string_array = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_previous_names));
+ if (_ptr_previous_names) {
+ NDR_PULL_ALLOC(ndr, r->previous_names);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->previous_names, _ptr_previous_names));
+ } else {
+ r->previous_names = NULL;
+ }
+ ndr->flags = _flags_save_string_array;
+ }
+ NDR_CHECK(ndr_pull_NTTIME(ndr, NDR_SCALARS, &r->driver_date));
+ NDR_CHECK(ndr_pull_hyper(ndr, NDR_SCALARS, &r->driver_version));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_name));
+ if (_ptr_manufacturer_name) {
+ NDR_PULL_ALLOC(ndr, r->manufacturer_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->manufacturer_name, _ptr_manufacturer_name));
+ } else {
+ r->manufacturer_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_manufacturer_url));
+ if (_ptr_manufacturer_url) {
+ NDR_PULL_ALLOC(ndr, r->manufacturer_url);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->manufacturer_url, _ptr_manufacturer_url));
+ } else {
+ r->manufacturer_url = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_hardware_id));
+ if (_ptr_hardware_id) {
+ NDR_PULL_ALLOC(ndr, r->hardware_id);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->hardware_id, _ptr_hardware_id));
+ } else {
+ r->hardware_id = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_provider));
+ if (_ptr_provider) {
+ NDR_PULL_ALLOC(ndr, r->provider);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->provider, _ptr_provider));
+ } else {
+ r->provider = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->driver_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->driver_name));
+ _mem_save_driver_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->driver_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->driver_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_name_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->architecture) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->architecture));
+ _mem_save_architecture_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->architecture, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->architecture));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_architecture_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->file_info) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->file_info));
+ _mem_save_file_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->file_info, 0);
+#if 0
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->file_info));
+#else
+ NDR_CHECK(ndr_token_store(ndr, &ndr->array_size_list, &r->file_info, r->file_count));
+#endif
+ NDR_PULL_ALLOC_N(ndr, r->file_info, ndr_get_array_size(ndr, &r->file_info));
+ _mem_save_file_info_1 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->file_info, 0);
+ for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
+ NDR_CHECK(ndr_pull_spoolss_DriverFileInfo(ndr, NDR_SCALARS, &r->file_info[cntr_file_info_1]));
+ }
+ for (cntr_file_info_1 = 0; cntr_file_info_1 < r->file_count; cntr_file_info_1++) {
+ NDR_CHECK(ndr_pull_spoolss_DriverFileInfo(ndr, NDR_BUFFERS, &r->file_info[cntr_file_info_1]));
+ }
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_1, 0);
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_file_info_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->monitor_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->monitor_name));
+ _mem_save_monitor_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->monitor_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->monitor_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_monitor_name_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->default_datatype) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->default_datatype));
+ _mem_save_default_datatype_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->default_datatype, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->default_datatype));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_default_datatype_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string_array = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->previous_names) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->previous_names));
+ _mem_save_previous_names_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->previous_names, 0);
+ NDR_CHECK(ndr_pull_string_array(ndr, NDR_SCALARS, &r->previous_names));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_previous_names_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string_array;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->manufacturer_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->manufacturer_name));
+ _mem_save_manufacturer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->manufacturer_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_name_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->manufacturer_url) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->manufacturer_url));
+ _mem_save_manufacturer_url_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->manufacturer_url, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->manufacturer_url));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_manufacturer_url_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->hardware_id) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->hardware_id));
+ _mem_save_hardware_id_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->hardware_id, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->hardware_id));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_hardware_id_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->provider) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->provider));
+ _mem_save_provider_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->provider, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->provider));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_provider_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->file_info) {
+ NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->file_info, r->file_count));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
diff --git a/librpc/ndr/ndr_spoolss_buf.h b/librpc/ndr/ndr_spoolss_buf.h
index 801737610f..5ed848d7e0 100644
--- a/librpc/ndr/ndr_spoolss_buf.h
+++ b/librpc/ndr/ndr_spoolss_buf.h
@@ -39,6 +39,9 @@ enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flag
enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r);
uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags);
size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags);
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_DriverInfo101(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DriverInfo101 *r);
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DriverInfo101 *r);
+
#undef _PRINTF_ATTRIBUTE
#define _PRINTF_ATTRIBUTE(a1, a2)
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 48785f5b0a..6099fe5cae 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -275,7 +275,24 @@ sub PythonStruct($$$$$$)
$self->pidl("if (!PyArg_ParseTuple(args, \"s#:__ndr_unpack__\", &blob.data, &blob.length))");
$self->pidl("\treturn NULL;");
$self->pidl("");
- $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
+
+ # This disgusting hack works around the fact that ndr_pull_struct_blob_all will always fail on structures with relative pointers.
+ # So, map ndr_unpack to ndr_pull_struct_blob_all only if we don't have any relative pointers in this
+ my $got_relative = 0;
+ if ($#{$d->{ELEMENTS}} > -1) {
+ foreach my $e (@{$d->{ELEMENTS}}) {
+ my $l = $e->{LEVELS}[0];
+ if ($l->{TYPE} eq "POINTER" and ($l->{POINTER_TYPE} eq "relative")) {
+ $got_relative = 1;
+ last;
+ }
+ }
+ }
+ if ($got_relative == 0) {
+ $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
+ } else {
+ $self->pidl("err = ndr_pull_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, (ndr_pull_flags_fn_t)ndr_pull_$name);");
+ }
$self->pidl("if (err != NDR_ERR_SUCCESS) {");
$self->indent;
$self->pidl("PyErr_SetNdrError(err);");
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 09138cf0aa..71dddf6939 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -242,77 +242,32 @@ sub mk_openldap($$$)
$ENV{PATH} = "$olpath/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
unlink($modconf);
- open(CONF, ">$modconf"); close(CONF);
- if (system("slaptest -u -f $slapd_conf >&2") != 0) {
- open(CONF, ">$modconf");
- # enable slapd modules
- print CONF "
-modulepath $olroot/libexec/openldap
-moduleload syncprov
-moduleload memberof
-moduleload refint
-";
- close(CONF);
- }
- if (system("slaptest -u -f $slapd_conf >&2") != 0) {
- open(CONF, ">$modconf");
- # enable slapd modules
- print CONF "
-modulepath $olroot/libexec/openldap
-moduleload back_hdb
-moduleload syncprov
-moduleload memberof
-moduleload refint
-";
- close(CONF);
- }
+ #This code tries to guess what modules we need to load (if any) by trying different combinations in the modules.conf
- if (system("slaptest -u -f $slapd_conf >&2") != 0) {
- open(CONF, ">$modconf");
- # enable slapd modules
- print CONF "
-moduleload back_hdb
-moduleload syncprov
-moduleload memberof
-moduleload refint
-";
- close(CONF);
- }
+ # Try without any slapd modules
+ open(CONF, ">$modconf"); close(CONF);
if (system("slaptest -u -f $slapd_conf >&2") != 0) {
open(CONF, ">$modconf");
# enable slapd modules
print CONF "
-modulepath /usr/lib/ldap
-moduleload back_hdb
moduleload syncprov
moduleload memberof
moduleload refint
+moduleload deref
";
close(CONF);
}
-
if (system("slaptest -u -f $slapd_conf >&2") != 0) {
open(CONF, ">$modconf");
- # enable slapd modules (Fedora layout)
+ # enable slapd modules, and the module for back_hdb
print CONF "
-modulepath /usr/lib/openldap
-moduleload syncprov
-moduleload memberof
-moduleload refint
-";
- close(CONF);
- }
-
- if (system("slaptest -u -f $slapd_conf >&2") != 0) {
- open(CONF, ">$modconf");
- # enable slapd modules (Fedora x86_64 layout)
- print CONF "
-modulepath /usr/lib64/openldap
+moduleload back_hdb
moduleload syncprov
moduleload memberof
moduleload refint
+moduleload deref
";
close(CONF);
}
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 7564659dd3..8f1d1a5b77 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -339,7 +339,8 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
../lib/util/util.o ../lib/util/fsusage.o \
../lib/util/params.o ../lib/util/talloc_stack.o \
../lib/util/genrand.o ../lib/util/util_net.o \
- ../lib/util/become_daemon.o
+ ../lib/util/become_daemon.o ../lib/util/system.o \
+ ../lib/util/tevent_unix.o
CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
@@ -444,7 +445,10 @@ LIBSMB_OBJ0 = \
LIBSAMBA_OBJ = $(LIBSMB_OBJ0) \
$(LIBSMB_ERR_OBJ)
-CLDAP_OBJ = libads/cldap.o
+LIBCLI_LDAP_MESSAGE_OBJ = ../libcli/ldap/ldap_message.o
+LIBCLI_LDAP_NDR_OBJ = ../libcli/ldap/ldap_ndr.o
+
+CLDAP_OBJ = libads/cldap.o $(LIBCLI_LDAP_MESSAGE_OBJ) $(LIBCLI_LDAP_NDR_OBJ)
LIBSMB_OBJ = libsmb/clientgen.o libsmb/cliconnect.o libsmb/clifile.o \
libsmb/clikrb5.o libsmb/clispnego.o ../lib/util/asn1.o \
@@ -685,7 +689,7 @@ AUTH_SAM_OBJ = auth/auth_sam.o
AUTH_SERVER_OBJ = auth/auth_server.o
AUTH_UNIX_OBJ = auth/auth_unix.o
AUTH_WINBIND_OBJ = auth/auth_winbind.o
-AUTH_ONEFS_WB_OBJ = auth/auth_onefs_wb.o
+AUTH_WBC_OBJ = auth/auth_wbc.o
AUTH_SCRIPT_OBJ = auth/auth_script.o
AUTH_NETLOGOND_OBJ = auth/auth_netlogond.o
@@ -756,7 +760,7 @@ NMBD_OBJ1 = nmbd/asyncdns.o nmbd/nmbd.o nmbd/nmbd_become_dmb.o \
nmbd/nmbd_subnetdb.o nmbd/nmbd_winsproxy.o nmbd/nmbd_winsserver.o \
nmbd/nmbd_workgroupdb.o nmbd/nmbd_synclists.o smbd/connection.o
-NMBD_OBJ = $(NMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
+NMBD_OBJ = $(NMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) \
$(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
$(LIBNDR_GEN_OBJ0)
@@ -935,7 +939,7 @@ NET_OBJ = $(NET_OBJ1) \
$(PRIVILEGES_BASIC_OBJ) @LIBLUA_STATIC@ \
$(LIB_EVENTLOG_OBJ)
-CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
+CUPS_OBJ = client/smbspool.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \
$(LIBNDR_GEN_OBJ0)
@@ -952,24 +956,24 @@ SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/uta
torture/denytest.o torture/mangle_test.o
SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) \
- $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \
+ $(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \
lib/wb_reqtrans.o lib/wbclient.o \
@LIBWBCLIENT_STATIC@ \
$(LIBNDR_GEN_OBJ0)
-MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
+MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) \
$(LIB_NONSMBD_OBJ) \
$(LIBNDR_GEN_OBJ0)
-MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
+MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) \
$(LIB_NONSMBD_OBJ) \
$(LIBNDR_GEN_OBJ0)
LOCKTEST_OBJ = torture/locktest.o $(PARAM_OBJ) $(LOCKING_OBJ) $(KRBCLIENT_OBJ) \
- $(LIBSMB_OBJ) $(LIB_NONSMBD_OBJ) \
+ $(LIBSMB_OBJ) $(LDB_OBJ) $(LIB_NONSMBD_OBJ) \
$(LIBNDR_GEN_OBJ0)
-NSSTEST_OBJ = torture/nsstest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \
+NSSTEST_OBJ = torture/nsstest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) $(KRBCLIENT_OBJ) \
$(LIB_NONSMBD_OBJ) \
$(LIBNDR_GEN_OBJ0)
@@ -984,7 +988,7 @@ SMBICONV_OBJ = $(PARAM_OBJ) torture/smbiconv.o $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ
LOG2PCAP_OBJ = utils/log2pcaphex.o
-LOCKTEST2_OBJ = torture/locktest2.o $(PARAM_OBJ) $(LOCKING_OBJ) $(LIBSMB_OBJ) \
+LOCKTEST2_OBJ = torture/locktest2.o $(PARAM_OBJ) $(LOCKING_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) \
$(KRBCLIENT_OBJ) $(LIB_NONSMBD_OBJ) \
$(LIBNDR_GEN_OBJ0)
@@ -1024,7 +1028,7 @@ REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \
DEBUG2HTML_OBJ = utils/debug2html.o utils/debugparse.o
-SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) \
+SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(LDB_OBJ) \
$(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \
$(LIBNDR_GEN_OBJ0)
@@ -2351,9 +2355,9 @@ bin/winbind.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_WINBIND_OBJ)
@echo "Building plugin $@"
@$(SHLD_MODULE) $(AUTH_WINBIND_OBJ)
-bin/onefs_wb.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_ONEFS_WB_OBJ)
+bin/wbc.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_WBC_OBJ)
@echo "Building plugin $@"
- @$(SHLD_MODULE) $(AUTH_ONEFS_WB_OBJ)
+ @$(SHLD_MODULE) $(AUTH_WBC_OBJ)
bin/unix.@SHLIBEXT@: $(BINARY_PREREQS) $(AUTH_UNIX_OBJ)
@echo "Building plugin $@"
@@ -2371,9 +2375,9 @@ bin/tdbsam.@SHLIBEXT@: $(BINARY_PREREQS) passdb/pdb_tdb.o
@echo "Building plugin $@"
@$(SHLD_MODULE) passdb/pdb_tdb.o
-bin/onefs_sam.@SHLIBEXT@: $(BINARY_PREREQS) passdb/pdb_onefs_sam.o
+bin/wbc_sam.@SHLIBEXT@: $(BINARY_PREREQS) passdb/pdb_wbc_sam.o
@echo "Building plugin $@"
- @$(SHLD_MODULE) passdb/pdb_onefs_sam.o
+ @$(SHLD_MODULE) passdb/pdb_wbc_sam.o
bin/smbpasswd.@SHLIBEXT@: $(BINARY_PREREQS) passdb/pdb_smbpasswd.o
@echo "Building plugin $@"
diff --git a/source3/auth/auth_onefs_wb.c b/source3/auth/auth_wbc.c
index 49de6966b0..580c8b550d 100644
--- a/source3/auth/auth_onefs_wb.c
+++ b/source3/auth/auth_wbc.c
@@ -1,7 +1,8 @@
/*
Unix SMB/CIFS implementation.
- Winbind authentication mechnism, customized for onefs
+ Winbind client authentication mechanism designed to defer all
+ authentication to the winbind daemon.
Copyright (C) Tim Potter 2000
Copyright (C) Andrew Bartlett 2001 - 2002
@@ -21,6 +22,21 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* This auth module is very similar to auth_winbind with 3 distinct
+ * differences.
+ *
+ * 1) Does not fallback to another auth module if winbindd is unavailable
+ * 2) Does not validate the domain of the user
+ * 3) Handles unencrypted passwords
+ *
+ * The purpose of this module is to defer all authentication decisions (ie:
+ * local user vs NIS vs LDAP vs AD; encrypted vs plaintext) to the wbc
+ * compatible daemon. This centeralizes all authentication decisions to a
+ * single provider.
+ *
+ * This auth backend is most useful when used in conjunction with pdb_wbc_sam.
+ */
+
#include "includes.h"
#undef DBGC_CLASS
@@ -28,7 +44,7 @@
/* Authenticate a user with a challenge/response */
-static NTSTATUS check_onefs_wb_security(const struct auth_context *auth_context,
+static NTSTATUS check_wbc_security(const struct auth_context *auth_context,
void *my_private_data,
TALLOC_CTX *mem_ctx,
const auth_usersupplied_info *user_info,
@@ -58,7 +74,7 @@ static NTSTATUS check_onefs_wb_security(const struct auth_context *auth_context,
user_info->internal_username));
params.level = WBC_AUTH_USER_LEVEL_PLAIN;
- params.password.plaintext = user_info->plaintext_password.data;
+ params.password.plaintext = (char *)user_info->plaintext_password.data;
} else {
DEBUG(3,("Checking encrypted password for %s.\n",
user_info->internal_username));
@@ -116,19 +132,19 @@ static NTSTATUS check_onefs_wb_security(const struct auth_context *auth_context,
}
/* module initialisation */
-static NTSTATUS auth_init_onefs_wb(struct auth_context *auth_context, const char *param, auth_methods **auth_method)
+static NTSTATUS auth_init_wbc(struct auth_context *auth_context, const char *param, auth_methods **auth_method)
{
if (!make_auth_methods(auth_context, auth_method)) {
return NT_STATUS_NO_MEMORY;
}
- (*auth_method)->name = "onefs_wb";
- (*auth_method)->auth = check_onefs_wb_security;
+ (*auth_method)->name = "wbc";
+ (*auth_method)->auth = check_wbc_security;
return NT_STATUS_OK;
}
-NTSTATUS auth_onefs_wb_init(void)
+NTSTATUS auth_wbc_init(void)
{
- return smb_register_auth(AUTH_INTERFACE_VERSION, "onefs_wb", auth_init_onefs_wb);
+ return smb_register_auth(AUTH_INTERFACE_VERSION, "wbc", auth_init_wbc);
}
diff --git a/source3/client/client.c b/source3/client/client.c
index 2f9e3c0d49..aaa9e35d96 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1784,13 +1784,13 @@ static struct file_list {
Free a file_list structure.
****************************************************************************/
-static void free_file_list (struct file_list *list_head)
+static void free_file_list (struct file_list *l_head)
{
struct file_list *list, *next;
- for (list = list_head; list; list = next) {
+ for (list = l_head; list; list = next) {
next = list->next;
- DLIST_REMOVE(list_head, list);
+ DLIST_REMOVE(l_head, list);
SAFE_FREE(list->file_path);
SAFE_FREE(list);
}
diff --git a/source3/client/mount.cifs.c b/source3/client/mount.cifs.c
index a736609580..8623d3c04b 100644
--- a/source3/client/mount.cifs.c
+++ b/source3/client/mount.cifs.c
@@ -179,7 +179,6 @@ static void mount_cifs_usage(void)
printf("\n\t%s -V\n",thisprogram);
SAFE_FREE(mountpassword);
- exit(EX_USAGE);
}
/* caller frees username if necessary */
@@ -650,7 +649,9 @@ static int parse_options(char ** optionsp, int * filesys_flags)
} else if (strncmp(data, "exec", 4) == 0) {
*filesys_flags &= ~MS_NOEXEC;
} else if (strncmp(data, "guest", 5) == 0) {
- got_password=1;
+ user_name = (char *)calloc(1, 1);
+ got_user = 1;
+ got_password = 1;
} else if (strncmp(data, "ro", 2) == 0) {
*filesys_flags |= MS_RDONLY;
} else if (strncmp(data, "rw", 2) == 0) {
@@ -1017,6 +1018,14 @@ uppercase_string(char *string)
return 1;
}
+static void print_cifs_mount_version(void)
+{
+ printf("mount.cifs version: %s.%s%s\n",
+ MOUNT_CIFS_VERSION_MAJOR,
+ MOUNT_CIFS_VERSION_MINOR,
+ MOUNT_CIFS_VENDOR_SUFFIX);
+}
+
int main(int argc, char ** argv)
{
int c;
@@ -1078,6 +1087,24 @@ int main(int argc, char ** argv)
exit(EX_SYSERR);
}
mountpoint = argv[2];
+ } else if (argc == 2) {
+ if ((strcmp(argv[1], "-V") == 0) ||
+ (strcmp(argv[1], "--version") == 0))
+ {
+ print_cifs_mount_version();
+ exit(0);
+ }
+
+ if ((strcmp(argv[1], "-h") == 0) ||
+ (strcmp(argv[1], "-?") == 0) ||
+ (strcmp(argv[1], "--help") == 0))
+ {
+ mount_cifs_usage();
+ exit(0);
+ }
+
+ mount_cifs_usage();
+ exit(EX_USAGE);
} else {
mount_cifs_usage();
exit(EX_USAGE);
@@ -1102,7 +1129,7 @@ int main(int argc, char ** argv)
case '?':
case 'h': /* help */
mount_cifs_usage ();
- exit(EX_USAGE);
+ exit(0);
case 'n':
++nomtab;
break;
@@ -1134,11 +1161,8 @@ int main(int argc, char ** argv)
case 'v':
++verboseflag;
break;
- case 'V':
- printf ("mount.cifs version: %s.%s%s\n",
- MOUNT_CIFS_VERSION_MAJOR,
- MOUNT_CIFS_VERSION_MINOR,
- MOUNT_CIFS_VENDOR_SUFFIX);
+ case 'V':
+ print_cifs_mount_version();
exit (0);
case 'w':
flags &= ~MS_RDONLY;
diff --git a/source3/configure.in b/source3/configure.in
index bd3d4af40b..d67feccb9b 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -414,7 +414,7 @@ AC_SUBST(DYNEXP)
dnl Add modules that have to be built by default here
dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss2 rpc_eventlog auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template"
+default_static_modules="pdb_smbpasswd pdb_tdbsam pdb_wbc_sam rpc_lsarpc rpc_samr rpc_winreg rpc_initshutdown rpc_dssetup rpc_wkssvc rpc_svcctl rpc_ntsvcs rpc_netlogon rpc_netdfs rpc_srvsvc rpc_spoolss2 rpc_eventlog auth_sam auth_unix auth_winbind auth_wbc auth_server auth_domain auth_builtin auth_netlogond vfs_default nss_info_template"
dnl These are preferably build shared, and static if dlopen() is not available
default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_xattr_tdb vfs_streams_xattr vfs_streams_depot vfs_acl_xattr vfs_acl_tdb vfs_smb_traffic_analyzer"
@@ -1088,7 +1088,7 @@ echo $samba_cv_HAVE_ONEFS
if test x"$samba_cv_HAVE_ONEFS" = x"yes"; then
AC_DEFINE(HAVE_ONEFS,1,[Whether building on Isilon OneFS])
default_shared_modules="$default_shared_modules vfs_onefs vfs_onefs_shadow_copy perfcount_onefs"
- default_static_modules="$default_static_modules auth_onefs_wb pdb_onefs_sam"
+ default_static_modules="$default_static_modules"
ONEFS_LIBS="-lisi_acl -lisi_ecs -lisi_event -lisi_util"
# Need to also add general libs for oplocks support
save_LIBS="$save_LIBS -lisi_ecs -lisi_event -lisi_util -ldevstat"
@@ -6130,7 +6130,7 @@ SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o passdb/pdb_nds.o, "bin/ldapsam.$SHLIBEXT"
[ PASSDB_LIBS="$PASSDB_LIBS $LDAP_LIBS" ] )
SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, "bin/smbpasswd.$SHLIBEXT", PDB)
SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, "bin/tdbsam.$SHLIBEXT", PDB)
-SMB_MODULE(pdb_onefs_sam, passdb/pdb_onefs_sam.o, "bin/onefs_sam.$SHLIBEXT", PDB)
+SMB_MODULE(pdb_wbc_sam, passdb/pdb_wbc_sam.o, "bin/wbc_sam.$SHLIBEXT", PDB)
SMB_SUBSYSTEM(PDB,passdb/pdb_interface.o)
@@ -6173,7 +6173,7 @@ SMB_SUBSYSTEM(CHARSET,lib/iconv.o)
SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), "bin/sam.$SHLIBEXT", AUTH)
SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), "bin/unix.$SHLIBEXT", AUTH)
SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), "bin/winbind.$SHLIBEXT", AUTH)
-SMB_MODULE(auth_onefs_wb, \$(AUTH_ONEFS_WB_OBJ), "bin/onefs_wb.$SHLIBEXT", AUTH)
+SMB_MODULE(auth_wbc, \$(AUTH_WBC_OBJ), "bin/wbc.$SHLIBEXT", AUTH)
SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), "bin/smbserver.$SHLIBEXT", AUTH)
SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), "bin/domain.$SHLIBEXT", AUTH)
SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), "bin/builtin.$SHLIBEXT", AUTH)
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 5ab5564e47..80d7bfc6cf 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -677,8 +677,6 @@ struct printjob;
#include "smbldap.h"
-#include "smb_ldap.h"
-
/*
* Reasons for cache flush.
*/
diff --git a/source3/include/proto.h b/source3/include/proto.h
index faf47d3844..8084111145 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -695,8 +695,13 @@ SEC_DESC *dup_sec_desc(TALLOC_CTX *ctx, const SEC_DESC *src);
NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
struct security_descriptor *secdesc,
uint8 **data, size_t *len);
+NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
+ struct sec_desc_buf *secdesc_buf,
+ uint8_t **data, size_t *len);
NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
struct security_descriptor **psecdesc);
+NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
+ struct sec_desc_buf **psecdesc_buf);
SEC_DESC *make_standard_sec_desc(TALLOC_CTX *ctx, const DOM_SID *owner_sid, const DOM_SID *grp_sid,
SEC_ACL *dacl, size_t *sd_size);
SEC_DESC_BUF *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, SEC_DESC *sec_desc);
@@ -972,8 +977,6 @@ struct passwd *sys_getpwnam(const char *name);
struct passwd *sys_getpwuid(uid_t uid);
struct group *sys_getgrnam(const char *name);
struct group *sys_getgrgid(gid_t gid);
-pid_t sys_fork(void);
-pid_t sys_getpid(void);
int sys_popen(const char *command);
int sys_pclose(int fd);
ssize_t sys_getxattr (const char *path, const char *name, void *value, size_t size);
@@ -1240,15 +1243,6 @@ bool is_valid_policy_hnd(const POLICY_HND *hnd);
bool policy_hnd_equal(const struct policy_handle *hnd1,
const struct policy_handle *hnd2);
const char *strip_hostname(const char *s);
-struct async_req *read_pkt_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- int fd, size_t initial,
- ssize_t (*more)(uint8_t *buf, size_t buflen,
- void *priv),
- void *priv);
-ssize_t read_pkt_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
- uint8_t **pbuf, int *perr);
-
/* The following definitions come from lib/util_file.c */
@@ -3114,7 +3108,7 @@ struct packet_struct *receive_dgram_packet(int fd, int t,
bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
void sort_query_replies(char *data, int n, struct in_addr ip);
-int name_mangle( char *In, char *Out, char name_type );
+char *name_mangle(TALLOC_CTX *mem_ctx, char *In, char name_type);
int name_extract(char *buf,int ofs, fstring name);
int name_len(char *s1);
@@ -5471,31 +5465,36 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
const char *printername,
uint32_t access_desired,
struct policy_handle *handle);
+WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ const char *architecture,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t client_major_version,
+ uint32_t client_minor_version,
+ union spoolss_DriverInfo *info,
+ uint32_t *server_major_version,
+ uint32_t *server_minor_version);
+WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct spoolss_SetPrinterInfoCtr *info_ctr);
+WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t level,
+ uint32_t offered,
+ union spoolss_PrinterInfo *info);
WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
char *name, uint32 flags, uint32 level,
uint32 *num_printers, PRINTER_INFO_CTR *ctr);
WERROR rpccli_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
uint32 level, uint32 *num_ports, PORT_INFO_CTR *ctr);
-WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 level,
- PRINTER_INFO_CTR *ctr);
-WERROR rpccli_spoolss_setprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 level,
- PRINTER_INFO_CTR *ctr, uint32 command);
-WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 level,
- const char *env, int version, PRINTER_DRIVER_CTR *ctr);
WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 level, const char *env,
uint32 *num_drivers,
PRINTER_DRIVER_CTR *ctr);
-WERROR rpccli_spoolss_addprinterdriver (struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, uint32 level,
- PRINTER_DRIVER_CTR *ctr);
-WERROR rpccli_spoolss_addprinterex (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- uint32 level, PRINTER_INFO_CTR*ctr);
WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *handle, int level, uint32 *num_forms,
FORM_1 **forms);
@@ -5806,17 +5805,7 @@ bool sec_io_desc_buf(const char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int
bool spoolss_io_system_time(const char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime);
bool make_systemtime(SYSTEMTIME *systime, struct tm *unixtime);
-bool spool_io_user_level_1( const char *desc, prs_struct *ps, int depth, SPOOL_USER_1 *q_u );
bool spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode);
-bool make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u,
- const char *srv_name, const char* clientname, const char* user_name,
- uint32 level, PRINTER_INFO_CTR *ctr);
-bool make_spoolss_printer_info_2(TALLOC_CTX *ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
- PRINTER_INFO_2 *info);
-bool make_spoolss_printer_info_3(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3 **spool_info3,
- PRINTER_INFO_3 *info);
-bool make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7,
- PRINTER_INFO_7 *info);
bool make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
const POLICY_HND *handle,
const char *valuename, uint32 size);
@@ -5869,11 +5858,6 @@ uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info);
uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p);
uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info);
uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info);
-bool make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
- const POLICY_HND *hnd,
- const fstring architecture,
- uint32 level, uint32 clientmajor, uint32 clientminor,
- RPC_BUFFER *buffer, uint32 offered);
bool spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth);
bool make_spoolss_q_enumprinters(
@@ -5891,19 +5875,6 @@ bool spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_
bool spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth);
bool spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth);
-bool make_spoolss_q_getprinter(
- TALLOC_CTX *mem_ctx,
- SPOOL_Q_GETPRINTER *q_u,
- const POLICY_HND *hnd,
- uint32 level,
- RPC_BUFFER *buffer,
- uint32 offered
-);
-bool make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
- const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
- uint32 command);
-bool spoolss_io_r_setprinter(const char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth);
-bool spoolss_io_q_setprinter(const char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth);
bool make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
uint32 firstjob,
@@ -5923,31 +5894,7 @@ bool spoolss_io_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct
bool spoolss_io_r_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth);
-bool spool_io_printer_info_level_1(const char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth);
-bool spool_io_printer_info_level_3(const char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth);
-bool spool_io_printer_info_level_2(const char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth);
-bool spool_io_printer_info_level_7(const char *desc, SPOOL_PRINTER_INFO_LEVEL_7 *il, prs_struct *ps, int depth);
-bool spool_io_printer_info_level(const char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth);
-bool spoolss_io_q_addprinterex(const char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_addprinterex(const char *desc, SPOOL_R_ADDPRINTEREX *r_u,
- prs_struct *ps, int depth);
-bool spool_io_printer_driver_info_level_3(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
- prs_struct *ps, int depth);
-bool spool_io_printer_driver_info_level_6(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
- prs_struct *ps, int depth);
-bool smb_io_unibuffer(const char *desc, UNISTR2 *buffer, prs_struct *ps, int depth);
-bool spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth);
-bool make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
- SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
- uint32 level, PRINTER_DRIVER_CTR *info);
-bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
- DRIVER_INFO_3 *info3);
bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src);
-bool spoolss_io_q_addprinterdriver(const char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth);
-bool spoolss_io_r_addprinterdriver(const char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth);
-bool uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
- NT_PRINTER_INFO_LEVEL_2 *d);
bool spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth);
bool spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth);
bool spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth);
@@ -6238,7 +6185,6 @@ bool init_service_op_table( void );
/* The following definitions come from rpcclient/cmd_spoolss.c */
-void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch);
/* The following definitions come from rpcclient/cmd_srvsvc.c */
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 504cfea70b..c494fdd6bf 100644
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -261,25 +261,6 @@ PRINTER_MESSAGE_INFO;
#define DRIVER_MAX_VERSION 4
-/* this struct is undocumented */
-/* thanks to the ddk ... */
-typedef struct {
- uint32 size; /* length of user_name & client_name + 2? */
- UNISTR2 *client_name;
- UNISTR2 *user_name;
- uint32 build;
- uint32 major;
- uint32 minor;
- uint32 processor;
-} SPOOL_USER_1;
-
-typedef struct {
- uint32 level;
- union {
- SPOOL_USER_1 *user1;
- } user;
-} SPOOL_USER_CTR;
-
/*
* Devicemode structure
*/
@@ -872,208 +853,8 @@ typedef struct spool_r_enumforms
}
SPOOL_R_ENUMFORMS;
-typedef struct spool_printer_info_level_1
-{
- uint32 flags;
- uint32 description_ptr;
- uint32 name_ptr;
- uint32 comment_ptr;
- UNISTR2 description;
- UNISTR2 name;
- UNISTR2 comment;
-} SPOOL_PRINTER_INFO_LEVEL_1;
-
-typedef struct spool_printer_info_level_2
-{
- uint32 servername_ptr;
- uint32 printername_ptr;
- uint32 sharename_ptr;
- uint32 portname_ptr;
- uint32 drivername_ptr;
- uint32 comment_ptr;
- uint32 location_ptr;
- uint32 devmode_ptr;
- uint32 sepfile_ptr;
- uint32 printprocessor_ptr;
- uint32 datatype_ptr;
- uint32 parameters_ptr;
- uint32 secdesc_ptr;
- uint32 attributes;
- uint32 priority;
- uint32 default_priority;
- uint32 starttime;
- uint32 untiltime;
- uint32 status;
- uint32 cjobs;
- uint32 averageppm;
- UNISTR2 servername;
- UNISTR2 printername;
- UNISTR2 sharename;
- UNISTR2 portname;
- UNISTR2 drivername;
- UNISTR2 comment;
- UNISTR2 location;
- UNISTR2 sepfile;
- UNISTR2 printprocessor;
- UNISTR2 datatype;
- UNISTR2 parameters;
-}
-SPOOL_PRINTER_INFO_LEVEL_2;
-
-typedef struct spool_printer_info_level_3
-{
- uint32 secdesc_ptr;
-}
-SPOOL_PRINTER_INFO_LEVEL_3;
-
-typedef struct spool_printer_info_level_7
-{
- uint32 guid_ptr;
- uint32 action;
- UNISTR2 guid;
-}
-SPOOL_PRINTER_INFO_LEVEL_7;
-
-typedef struct spool_printer_info_level
-{
- uint32 level;
- uint32 info_ptr;
- SPOOL_PRINTER_INFO_LEVEL_1 *info_1;
- SPOOL_PRINTER_INFO_LEVEL_2 *info_2;
- SPOOL_PRINTER_INFO_LEVEL_3 *info_3;
- SPOOL_PRINTER_INFO_LEVEL_7 *info_7;
-}
-SPOOL_PRINTER_INFO_LEVEL;
-
-typedef struct spool_printer_driver_info_level_3
-{
- uint32 cversion;
- uint32 name_ptr;
- uint32 environment_ptr;
- uint32 driverpath_ptr;
- uint32 datafile_ptr;
- uint32 configfile_ptr;
- uint32 helpfile_ptr;
- uint32 monitorname_ptr;
- uint32 defaultdatatype_ptr;
- uint32 dependentfilessize;
- uint32 dependentfiles_ptr;
-
- UNISTR2 name;
- UNISTR2 environment;
- UNISTR2 driverpath;
- UNISTR2 datafile;
- UNISTR2 configfile;
- UNISTR2 helpfile;
- UNISTR2 monitorname;
- UNISTR2 defaultdatatype;
- BUFFER5 dependentfiles;
-
-}
-SPOOL_PRINTER_DRIVER_INFO_LEVEL_3;
-
-/* SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure */
-typedef struct {
- uint32 version;
- uint32 name_ptr;
- uint32 environment_ptr;
- uint32 driverpath_ptr;
- uint32 datafile_ptr;
- uint32 configfile_ptr;
- uint32 helpfile_ptr;
- uint32 monitorname_ptr;
- uint32 defaultdatatype_ptr;
- uint32 dependentfiles_len;
- uint32 dependentfiles_ptr;
- uint32 previousnames_len;
- uint32 previousnames_ptr;
- NTTIME driverdate;
- uint64 driverversion;
- uint32 dummy4;
- uint32 mfgname_ptr;
- uint32 oemurl_ptr;
- uint32 hardwareid_ptr;
- uint32 provider_ptr;
- UNISTR2 name;
- UNISTR2 environment;
- UNISTR2 driverpath;
- UNISTR2 datafile;
- UNISTR2 configfile;
- UNISTR2 helpfile;
- UNISTR2 monitorname;
- UNISTR2 defaultdatatype;
- BUFFER5 dependentfiles;
- BUFFER5 previousnames;
- UNISTR2 mfgname;
- UNISTR2 oemurl;
- UNISTR2 hardwareid;
- UNISTR2 provider;
-} SPOOL_PRINTER_DRIVER_INFO_LEVEL_6;
-
-
-typedef struct spool_printer_driver_info_level
-{
- uint32 level;
- uint32 ptr;
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *info_3;
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *info_6;
-}
-SPOOL_PRINTER_DRIVER_INFO_LEVEL;
-
-
-typedef struct spool_q_setprinter
-{
- POLICY_HND handle;
- uint32 level;
- SPOOL_PRINTER_INFO_LEVEL info;
- SEC_DESC_BUF *secdesc_ctr;
- DEVMODE_CTR devmode_ctr;
-
- uint32 command;
-
-}
-SPOOL_Q_SETPRINTER;
-
-typedef struct spool_r_setprinter
-{
- WERROR status;
-}
-SPOOL_R_SETPRINTER;
-
-/********************************************/
-
-typedef struct {
- UNISTR2 *server_name;
- uint32 level;
- SPOOL_PRINTER_INFO_LEVEL info;
- DEVMODE_CTR devmode_ctr;
- SEC_DESC_BUF *secdesc_ctr;
- uint32 user_switch;
- SPOOL_USER_CTR user_ctr;
-} SPOOL_Q_ADDPRINTEREX;
-
-typedef struct {
- POLICY_HND handle;
- WERROR status;
-} SPOOL_R_ADDPRINTEREX;
-
/********************************************/
-typedef struct spool_q_addprinterdriver
-{
- uint32 server_name_ptr;
- UNISTR2 server_name;
- uint32 level;
- SPOOL_PRINTER_DRIVER_INFO_LEVEL info;
-}
-SPOOL_Q_ADDPRINTERDRIVER;
-
-typedef struct spool_r_addprinterdriver
-{
- WERROR status;
-}
-SPOOL_R_ADDPRINTERDRIVER;
-
typedef struct spool_q_enumprintprocessors
{
uint32 name_ptr;
diff --git a/source3/include/smbprofile.h b/source3/include/smbprofile.h
index 131416b685..f9a0436546 100644
--- a/source3/include/smbprofile.h
+++ b/source3/include/smbprofile.h
@@ -75,6 +75,10 @@ enum profile_stats_values
#define syscall_open_count __profile_stats_value(PR_VALUE_SYSCALL_OPEN, count)
#define syscall_open_time __profile_stats_value(PR_VALUE_SYSCALL_OPEN, time)
+ PR_VALUE_SYSCALL_CREATEFILE,
+#define syscall_createfile_count __profile_stats_value(PR_VALUE_SYSCALL_CREATEFILE, count)
+#define syscall_createfile_time __profile_stats_value(PR_VALUE_SYSCALL_CREATEFILE, time)
+
PR_VALUE_SYSCALL_CLOSE,
#define syscall_close_count __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, count)
#define syscall_close_time __profile_stats_value(PR_VALUE_SYSCALL_CLOSE, time)
@@ -111,6 +115,10 @@ enum profile_stats_values
#define syscall_rename_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME, count)
#define syscall_rename_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME, time)
+ PR_VALUE_SYSCALL_RENAME_AT,
+#define syscall_rename_at_count __profile_stats_value(PR_VALUE_SYSCALL_RENAME_AT, count)
+#define syscall_rename_at_time __profile_stats_value(PR_VALUE_SYSCALL_RENAME_AT, time)
+
PR_VALUE_SYSCALL_FSYNC,
#define syscall_fsync_count __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, count)
#define syscall_fsync_time __profile_stats_value(PR_VALUE_SYSCALL_FSYNC, time)
@@ -215,6 +223,26 @@ enum profile_stats_values
#define syscall_set_quota_count __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, count)
#define syscall_set_quota_time __profile_stats_value(PR_VALUE_SYSCALL_SET_QUOTA, time)
+ PR_VALUE_SYSCALL_GET_SD,
+#define syscall_get_sd_count __profile_stats_value(PR_VALUE_SYSCALL_GET_SD, count)
+#define syscall_get_sd_time __profile_stats_value(PR_VALUE_SYSCALL_GET_SD, time)
+
+ PR_VALUE_SYSCALL_SET_SD,
+#define syscall_set_sd_count __profile_stats_value(PR_VALUE_SYSCALL_SET_SD, count)
+#define syscall_set_sd_time __profile_stats_value(PR_VALUE_SYSCALL_SET_SD, time)
+
+ PR_VALUE_SYSCALL_BRL_LOCK,
+#define syscall_brl_lock_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_LOCK, count)
+#define syscall_brl_lock_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_LOCK, time)
+
+ PR_VALUE_SYSCALL_BRL_UNLOCK,
+#define syscall_brl_unlock_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_UNLOCK, count)
+#define syscall_brl_unlock_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_UNLOCK, time)
+
+ PR_VALUE_SYSCALL_BRL_CANCEL,
+#define syscall_brl_cancel_count __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, count)
+#define syscall_brl_cancel_time __profile_stats_value(PR_VALUE_SYSCALL_BRL_CANCEL, time)
+
/* counters for individual SMB types */
PR_VALUE_SMBMKDIR,
#define SMBmkdir_count __profile_stats_value(PR_VALUE_SMBMKDIR, count)
diff --git a/source3/lib/fault.c b/source3/lib/fault.c
index a1530987f3..8c4a45bbc9 100644
--- a/source3/lib/fault.c
+++ b/source3/lib/fault.c
@@ -157,7 +157,6 @@ void dump_core_setup(const char *progname)
return;
}
- SAFE_FREE(corepath);
SAFE_FREE(logbase);
#ifdef HAVE_GETRLIMIT
diff --git a/source3/lib/ldap_debug_handler.c b/source3/lib/ldap_debug_handler.c
index 2181ff014d..98623d1985 100644
--- a/source3/lib/ldap_debug_handler.c
+++ b/source3/lib/ldap_debug_handler.c
@@ -19,13 +19,11 @@
#include "includes.h"
-#if HAVE_LDAP
-
+#if defined(HAVE_LDAP) && defined(HAVE_LBER_LOG_PRINT_FN)
static void samba_ldap_log_print_fn(LDAP_CONST char *data)
{
DEBUG(lp_ldap_debug_threshold(), ("[LDAP] %s", data));
}
-
#endif
void init_ldap_debugging(void)
diff --git a/source3/lib/secdesc.c b/source3/lib/secdesc.c
index 232bbca43c..a81c4ae82a 100644
--- a/source3/lib/secdesc.c
+++ b/source3/lib/secdesc.c
@@ -291,6 +291,32 @@ NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
}
/*******************************************************************
+ Convert a secdesc_buf into a byte stream
+********************************************************************/
+
+NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
+ struct sec_desc_buf *secdesc_buf,
+ uint8_t **data, size_t *len)
+{
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+
+ ndr_err = ndr_push_struct_blob(
+ &blob, mem_ctx, NULL, secdesc_buf,
+ (ndr_push_flags_fn_t)ndr_push_sec_desc_buf);
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(0, ("ndr_push_sec_desc_buf failed: %s\n",
+ ndr_errstr(ndr_err)));
+ return ndr_map_error2ntstatus(ndr_err);;
+ }
+
+ *data = blob.data;
+ *len = blob.length;
+ return NT_STATUS_OK;
+}
+
+/*******************************************************************
Parse a byte stream into a secdesc
********************************************************************/
NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
@@ -327,6 +353,43 @@ NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8 *data, size_t len,
}
/*******************************************************************
+ Parse a byte stream into a sec_desc_buf
+********************************************************************/
+
+NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
+ struct sec_desc_buf **psecdesc_buf)
+{
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+ struct sec_desc_buf *result;
+
+ if ((data == NULL) || (len == 0)) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ result = TALLOC_ZERO_P(mem_ctx, struct sec_desc_buf);
+ if (result == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ blob = data_blob_const(data, len);
+
+ ndr_err = ndr_pull_struct_blob(
+ &blob, result, NULL, result,
+ (ndr_pull_flags_fn_t)ndr_pull_sec_desc_buf);
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(0, ("ndr_pull_sec_desc_buf failed: %s\n",
+ ndr_errstr(ndr_err)));
+ TALLOC_FREE(result);
+ return ndr_map_error2ntstatus(ndr_err);;
+ }
+
+ *psecdesc_buf = result;
+ return NT_STATUS_OK;
+}
+
+/*******************************************************************
Creates a SEC_DESC structure with typical defaults.
********************************************************************/
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index f0561a5081..e24d35818c 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -581,7 +581,9 @@ static void smbldap_store_state(LDAP *ld, struct smbldap_state *smbldap_state)
int smb_ldap_start_tls(LDAP *ldap_struct, int version)
{
+#ifdef LDAP_OPT_X_TLS
int rc;
+#endif
if (lp_ldap_ssl() != LDAP_SSL_START_TLS) {
return LDAP_SUCCESS;
diff --git a/source3/lib/system.c b/source3/lib/system.c
index ed66666ddb..10b55f662d 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1043,35 +1043,6 @@ static char **extract_args(TALLOC_CTX *mem_ctx, const char *command)
}
/**************************************************************************
- Wrapper for fork. Ensures that mypid is reset. Used so we can write
- a sys_getpid() that only does a system call *once*.
-****************************************************************************/
-
-static pid_t mypid = (pid_t)-1;
-
-pid_t sys_fork(void)
-{
- pid_t forkret = fork();
-
- if (forkret == (pid_t)0) /* Child - reset mypid so sys_getpid does a system call. */
- mypid = (pid_t) -1;
-
- return forkret;
-}
-
-/**************************************************************************
- Wrapper for getpid. Ensures we only do a system call *once*.
-****************************************************************************/
-
-pid_t sys_getpid(void)
-{
- if (mypid == (pid_t)-1)
- mypid = getpid();
-
- return mypid;
-}
-
-/**************************************************************************
Wrapper for popen. Safer as it doesn't search a path.
Modified from the glibc sources.
modified by tridge to return a file descriptor. We must kick our FILE* habit
@@ -2008,7 +1979,6 @@ static ssize_t solaris_read_xattr(int attrfd, void *value, size_t size)
static ssize_t solaris_list_xattr(int attrdirfd, char *list, size_t size)
{
ssize_t len = 0;
- int stop = 0;
DIR *dirp;
struct dirent *de;
int newfd = dup(attrdirfd);
@@ -2080,7 +2050,7 @@ static int solaris_openat(int fildes, const char *path, int oflag, mode_t mode)
{
int filedes = openat(fildes, path, oflag, mode);
if (filedes == -1) {
- DEBUG(10,("openat FAILED: fd: %s, path: %s, errno: %s\n",filedes,path,strerror(errno)));
+ DEBUG(10,("openat FAILED: fd: %d, path: %s, errno: %s\n",filedes,path,strerror(errno)));
if (errno == EINVAL) {
errno = ENOTSUP;
} else {
diff --git a/source3/lib/tdb_validate.c b/source3/lib/tdb_validate.c
index 1f5dfe4d25..092546e3eb 100644
--- a/source3/lib/tdb_validate.c
+++ b/source3/lib/tdb_validate.c
@@ -118,7 +118,8 @@ int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn)
/* parent */
- DEBUG(10, ("tdb_validate: fork succeeded, child PID = %d\n",child_pid));
+ DEBUG(10, ("tdb_validate: fork succeeded, child PID = %u\n",
+ (unsigned int)child_pid));
DEBUG(10, ("tdb_validate: waiting for child to finish...\n"));
while ((wait_pid = sys_waitpid(child_pid, &child_status, 0)) < 0) {
@@ -134,7 +135,7 @@ int tdb_validate(struct tdb_context *tdb, tdb_validate_data_func validate_fn)
}
if (wait_pid != child_pid) {
DEBUG(1, ("tdb_validate: waitpid returned pid %d, "
- "but %d was expected\n", wait_pid, child_pid));
+ "but %u was expected\n", wait_pid, (unsigned int)child_pid));
goto done;
}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index cda1fb474d..89f7be8e6c 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3145,102 +3145,3 @@ const char *strip_hostname(const char *s)
return s;
}
-
-struct read_pkt_state {
- struct event_context *ev;
- int fd;
- uint8_t *buf;
- ssize_t (*more)(uint8_t *buf, size_t buflen, void *priv);
- void *priv;
-};
-
-static void read_pkt_done(struct async_req *subreq);
-
-struct async_req *read_pkt_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- int fd, size_t initial,
- ssize_t (*more)(uint8_t *buf, size_t buflen,
- void *priv),
- void *priv)
-{
- struct async_req *result, *subreq;
- struct read_pkt_state *state;
-
- if (!async_req_setup(mem_ctx, &result, &state,
- struct read_pkt_state)) {
- return NULL;
- }
- state->ev = ev;
- state->fd = fd;
- state->more = more;
-
- state->buf = talloc_array(state, uint8_t, initial);
- if (state->buf == NULL) {
- goto fail;
- }
- subreq = recvall_send(state, ev, fd, state->buf, initial, 0);
- if (subreq == NULL) {
- goto fail;
- }
- subreq->async.fn = read_pkt_done;
- subreq->async.priv = result;
- return result;
- fail:
- TALLOC_FREE(result);
- return NULL;
-}
-
-static void read_pkt_done(struct async_req *subreq)
-{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- struct read_pkt_state *state = talloc_get_type_abort(
- req->private_data, struct read_pkt_state);
- size_t current_size;
- ssize_t received;
- ssize_t more;
- int err;
-
- received = recvall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (received == -1) {
- async_req_error(req, err);
- return;
- }
- current_size = talloc_get_size(state->buf);
-
- more = state->more(state->buf, current_size, state->priv);
- if (more < 0) {
- async_req_error(req, EIO);
- return;
- }
- if (more == 0) {
- async_req_done(req);
- return;
- }
- state->buf = TALLOC_REALLOC_ARRAY(state, state->buf, uint8_t,
- current_size + more);
- if (async_req_nomem(state->buf, req)) {
- return;
- }
- subreq = recvall_send(state, state->ev, state->fd,
- state->buf + current_size, more, 0);
- if (async_req_nomem(subreq, req)) {
- return;
- }
- subreq->async.fn = read_pkt_done;
- subreq->async.priv = req;
-}
-
-ssize_t read_pkt_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
- uint8_t **pbuf, int *perr)
-{
- struct read_pkt_state *state = talloc_get_type_abort(
- req->private_data, struct read_pkt_state);
-
- if (async_req_is_errno(req, perr)) {
- return -1;
- }
- *pbuf = talloc_move(mem_ctx, &state->buf);
- return talloc_get_size(*pbuf);
-}
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index c46aa2ac49..83e8a9d355 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -953,7 +953,7 @@ struct open_socket_out_state {
int wait_nsec;
};
-static void open_socket_out_connected(struct async_req *subreq);
+static void open_socket_out_connected(struct tevent_req *subreq);
static int open_socket_out_state_destructor(struct open_socket_out_state *s)
{
@@ -974,7 +974,8 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
int timeout)
{
char addr[INET6_ADDRSTRLEN];
- struct async_req *result, *subreq;
+ struct async_req *result;
+ struct tevent_req *subreq;
struct open_socket_out_state *state;
NTSTATUS status;
@@ -1026,13 +1027,14 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
(struct sockaddr *)&state->ss,
state->salen);
if ((subreq == NULL)
- || !async_req_set_timeout(subreq, state->ev,
- timeval_set(0, state->wait_nsec))) {
+ || !tevent_req_set_endtime(
+ subreq, state->ev,
+ timeval_current_ofs(0, state->wait_nsec))) {
status = NT_STATUS_NO_MEMORY;
goto post_status;
}
subreq->async.fn = open_socket_out_connected;
- subreq->async.priv = result;
+ subreq->async.private_data = result;
return result;
post_status:
@@ -1045,18 +1047,18 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
return NULL;
}
-static void open_socket_out_connected(struct async_req *subreq)
+static void open_socket_out_connected(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ subreq->async.private_data, struct async_req);
struct open_socket_out_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_state);
- int err;
+ int ret;
int sys_errno;
- err = async_connect_recv(subreq, &sys_errno);
+ ret = async_connect_recv(subreq, &sys_errno);
TALLOC_FREE(subreq);
- if (err == 0) {
+ if (ret == 0) {
async_req_done(req);
return;
}
@@ -1083,13 +1085,14 @@ static void open_socket_out_connected(struct async_req *subreq)
if (async_req_nomem(subreq, req)) {
return;
}
- if (!async_req_set_timeout(subreq, state->ev,
- timeval_set(0, state->wait_nsec))) {
+ if (!tevent_req_set_endtime(
+ subreq, state->ev,
+ timeval_current_ofs(0, state->wait_nsec))) {
async_req_error(req, ENOMEM);
return;
}
subreq->async.fn = open_socket_out_connected;
- subreq->async.priv = req;
+ subreq->async.private_data = req;
return;
}
diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c
index 9bf6f29105..a5adf8f108 100644
--- a/source3/lib/wb_reqtrans.c
+++ b/source3/lib/wb_reqtrans.c
@@ -27,9 +27,7 @@
struct req_read_state {
struct winbindd_request *wb_req;
- struct tevent_context *ev;
size_t max_extra_data;
- int fd;
};
bool async_req_is_wbcerr(struct async_req *req, wbcErr *pwbc_err)
@@ -83,145 +81,91 @@ wbcErr async_req_simple_recv_wbcerr(struct async_req *req)
return WBC_ERR_SUCCESS;
}
-static void wb_req_read_len(struct async_req *subreq);
-static void wb_req_read_main(struct async_req *subreq);
-static void wb_req_read_extra(struct async_req *subreq);
+static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data);
+static void wb_req_read_done(struct tevent_req *subreq);
struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
int fd, size_t max_extra_data)
{
- struct async_req *result, *subreq;
+ struct async_req *result;
+ struct tevent_req *subreq;
struct req_read_state *state;
if (!async_req_setup(mem_ctx, &result, &state,
struct req_read_state)) {
return NULL;
}
- state->fd = fd;
- state->ev = ev;
state->max_extra_data = max_extra_data;
- state->wb_req = talloc(state, struct winbindd_request);
- if (state->wb_req == NULL) {
- goto nomem;
- }
- subreq = recvall_send(state, ev, state->fd, &(state->wb_req->length),
- sizeof(state->wb_req->length), 0);
+ subreq = read_packet_send(state, ev, fd, 4, wb_req_more, state);
if (subreq == NULL) {
goto nomem;
}
- subreq->async.fn = wb_req_read_len;
- subreq->async.priv = result;
+ subreq->async.fn = wb_req_read_done;
+ subreq->async.private_data = result;
return result;
-
nomem:
TALLOC_FREE(result);
return NULL;
}
-static void wb_req_read_len(struct async_req *subreq)
+static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
struct req_read_state *state = talloc_get_type_abort(
- req->private_data, struct req_read_state);
- int err;
- ssize_t ret;
-
- ret = recvall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (ret < 0) {
- async_req_error(req, map_wbc_err_from_errno(err));
- return;
- }
+ private_data, struct req_read_state);
+ struct winbindd_request *req = (struct winbindd_request *)buf;
- if (state->wb_req->length != sizeof(struct winbindd_request)) {
- DEBUG(0, ("wb_req_read_len: Invalid request size received: "
- "%d (expected %d)\n", (int)state->wb_req->length,
- (int)sizeof(struct winbindd_request)));
- async_req_error(req, WBC_ERR_INVALID_RESPONSE);
- return;
+ if (buflen == 4) {
+ if (req->length != sizeof(struct winbindd_request)) {
+ DEBUG(0, ("wb_req_read_len: Invalid request size "
+ "received: %d (expected %d)\n",
+ (int)req->length,
+ (int)sizeof(struct winbindd_request)));
+ return -1;
+ }
+ return sizeof(struct winbindd_request) - 4;
}
- subreq = recvall_send(
- req, state->ev, state->fd, (uint32 *)(state->wb_req)+1,
- sizeof(struct winbindd_request) - sizeof(uint32), 0);
- if (async_req_nomem(subreq, req)) {
- return;
+ if ((state->max_extra_data != 0)
+ && (req->extra_len > state->max_extra_data)) {
+ DEBUG(3, ("Got request with %d bytes extra data on "
+ "unprivileged socket\n", (int)req->extra_len));
+ return -1;
}
- subreq->async.fn = wb_req_read_main;
- subreq->async.priv = req;
+ return req->extra_len;
}
-static void wb_req_read_main(struct async_req *subreq)
+static void wb_req_read_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ subreq->async.private_data, struct async_req);
struct req_read_state *state = talloc_get_type_abort(
req->private_data, struct req_read_state);
int err;
ssize_t ret;
+ uint8_t *buf;
- ret = recvall_recv(subreq, &err);
+ ret = read_packet_recv(subreq, state, &buf, &err);
TALLOC_FREE(subreq);
- if (ret < 0) {
+ if (ret == -1) {
async_req_error(req, map_wbc_err_from_errno(err));
return;
}
- if ((state->max_extra_data != 0)
- && (state->wb_req->extra_len > state->max_extra_data)) {
- DEBUG(3, ("Got request with %d bytes extra data on "
- "unprivileged socket\n",
- (int)state->wb_req->extra_len));
- async_req_error(req, WBC_ERR_INVALID_RESPONSE);
- return;
- }
-
- if (state->wb_req->extra_len == 0) {
- async_req_done(req);
- return;
- }
-
- state->wb_req->extra_data.data = TALLOC_ARRAY(
- state->wb_req, char, state->wb_req->extra_len + 1);
- if (async_req_nomem(state->wb_req->extra_data.data, req)) {
- return;
- }
-
- state->wb_req->extra_data.data[state->wb_req->extra_len] = 0;
-
- subreq = recvall_send(
- req, state->ev, state->fd, state->wb_req->extra_data.data,
- state->wb_req->extra_len, 0);
- if (async_req_nomem(subreq, req)) {
- return;
- }
-
- subreq->async.fn = wb_req_read_extra;
- subreq->async.priv = req;
-}
-
-static void wb_req_read_extra(struct async_req *subreq)
-{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- int err;
- ssize_t ret;
+ state->wb_req = (struct winbindd_request *)buf;
- ret = recvall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (ret < 0) {
- async_req_error(req, map_wbc_err_from_errno(err));
- return;
+ if (state->wb_req->extra_len != 0) {
+ state->wb_req->extra_data.data =
+ (char *)buf + sizeof(struct winbindd_request);
+ } else {
+ state->wb_req->extra_data.data = NULL;
}
async_req_done(req);
}
-
wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
struct winbindd_request **preq)
{
@@ -237,90 +181,60 @@ wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
}
struct req_write_state {
- struct winbindd_request *wb_req;
- struct tevent_context *ev;
- int fd;
+ struct iovec iov[2];
};
-static void wb_req_write_main(struct async_req *subreq);
-static void wb_req_write_extra(struct async_req *subreq);
+static void wb_req_write_done(struct tevent_req *subreq);
struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev, int fd,
struct winbindd_request *wb_req)
{
- struct async_req *result, *subreq;
+ struct async_req *result;
+ struct tevent_req *subreq;
struct req_write_state *state;
+ int count = 1;
if (!async_req_setup(mem_ctx, &result, &state,
struct req_write_state)) {
return NULL;
}
- state->fd = fd;
- state->ev = ev;
- state->wb_req = wb_req;
- subreq = sendall_send(state, state->ev, state->fd, state->wb_req,
- sizeof(struct winbindd_request), 0);
- if (subreq == NULL) {
- goto nomem;
+ state->iov[0].iov_base = wb_req;
+ state->iov[0].iov_len = sizeof(struct winbindd_request);
+
+ if (wb_req->extra_len != 0) {
+ state->iov[1].iov_base = wb_req->extra_data.data;
+ state->iov[1].iov_len = wb_req->extra_len;
+ count = 2;
}
- subreq->async.fn = wb_req_write_main;
- subreq->async.priv = result;
+ subreq = writev_send(state, ev, fd, state->iov, count);
+ if (subreq == NULL) {
+ goto fail;
+ }
+ subreq->async.fn = wb_req_write_done;
+ subreq->async.private_data = result;
return result;
- nomem:
+ fail:
TALLOC_FREE(result);
return NULL;
}
-static void wb_req_write_main(struct async_req *subreq)
-{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- struct req_write_state *state = talloc_get_type_abort(
- req->private_data, struct req_write_state);
- int err;
- ssize_t ret;
-
- ret = sendall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (ret < 0) {
- async_req_error(req, map_wbc_err_from_errno(err));
- return;
- }
-
- if (state->wb_req->extra_len == 0) {
- async_req_done(req);
- return;
- }
-
- subreq = sendall_send(state, state->ev, state->fd,
- state->wb_req->extra_data.data,
- state->wb_req->extra_len, 0);
- if (async_req_nomem(subreq, req)) {
- return;
- }
-
- subreq->async.fn = wb_req_write_extra;
- subreq->async.priv = req;
-}
-
-static void wb_req_write_extra(struct async_req *subreq)
+static void wb_req_write_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ subreq->async.private_data, struct async_req);
int err;
ssize_t ret;
- ret = sendall_recv(subreq, &err);
+ ret = writev_recv(subreq, &err);
TALLOC_FREE(subreq);
if (ret < 0) {
async_req_error(req, map_wbc_err_from_errno(err));
return;
}
-
async_req_done(req);
}
@@ -331,40 +245,29 @@ wbcErr wb_req_write_recv(struct async_req *req)
struct resp_read_state {
struct winbindd_response *wb_resp;
- struct tevent_context *ev;
- size_t max_extra_data;
- int fd;
};
-static void wb_resp_read_len(struct async_req *subreq);
-static void wb_resp_read_main(struct async_req *subreq);
-static void wb_resp_read_extra(struct async_req *subreq);
+static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data);
+static void wb_resp_read_done(struct tevent_req *subreq);
struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev, int fd)
{
- struct async_req *result, *subreq;
+ struct async_req *result;
+ struct tevent_req *subreq;
struct resp_read_state *state;
if (!async_req_setup(mem_ctx, &result, &state,
struct resp_read_state)) {
return NULL;
}
- state->fd = fd;
- state->ev = ev;
- state->wb_resp = talloc(state, struct winbindd_response);
- if (state->wb_resp == NULL) {
- goto nomem;
- }
- subreq = recvall_send(state, ev, state->fd, &(state->wb_resp->length),
- sizeof(state->wb_resp->length), 0);
+ subreq = read_packet_send(state, ev, fd, 4, wb_resp_more, state);
if (subreq == NULL) {
goto nomem;
}
-
- subreq->async.fn = wb_resp_read_len;
- subreq->async.priv = result;
+ subreq->async.fn = wb_resp_read_done;
+ subreq->async.private_data = result;
return result;
nomem:
@@ -372,100 +275,50 @@ struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
return NULL;
}
-static void wb_resp_read_len(struct async_req *subreq)
+static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- struct resp_read_state *state = talloc_get_type_abort(
- req->private_data, struct resp_read_state);
- int err;
- ssize_t ret;
-
- ret = recvall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (ret < 0) {
- async_req_error(req, map_wbc_err_from_errno(err));
- return;
- }
-
- if (state->wb_resp->length < sizeof(struct winbindd_response)) {
- DEBUG(0, ("wb_resp_read_len: Invalid response size received: "
- "%d (expected at least%d)\n",
- (int)state->wb_resp->length,
- (int)sizeof(struct winbindd_response)));
- async_req_error(req, WBC_ERR_INVALID_RESPONSE);
- return;
- }
-
- subreq = recvall_send(
- req, state->ev, state->fd, (uint32 *)(state->wb_resp)+1,
- sizeof(struct winbindd_response) - sizeof(uint32), 0);
- if (async_req_nomem(subreq, req)) {
- return;
- }
-
- subreq->async.fn = wb_resp_read_main;
- subreq->async.priv = req;
+ struct winbindd_response *resp = (struct winbindd_response *)buf;
+
+ if (buflen == 4) {
+ if (resp->length < sizeof(struct winbindd_response)) {
+ DEBUG(0, ("wb_resp_read_len: Invalid response size "
+ "received: %d (expected at least%d)\n",
+ (int)resp->length,
+ (int)sizeof(struct winbindd_response)));
+ return -1;
+ }
+ }
+ return resp->length - 4;
}
-static void wb_resp_read_main(struct async_req *subreq)
+static void wb_resp_read_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ subreq->async.private_data, struct async_req);
struct resp_read_state *state = talloc_get_type_abort(
req->private_data, struct resp_read_state);
+ uint8_t *buf;
int err;
ssize_t ret;
- size_t extra_len;
- ret = recvall_recv(subreq, &err);
+ ret = read_packet_recv(subreq, state, &buf, &err);
TALLOC_FREE(subreq);
- if (ret < 0) {
+ if (ret == -1) {
async_req_error(req, map_wbc_err_from_errno(err));
return;
}
- extra_len = state->wb_resp->length - sizeof(struct winbindd_response);
- if (extra_len == 0) {
- async_req_done(req);
- return;
- }
-
- state->wb_resp->extra_data.data = TALLOC_ARRAY(
- state->wb_resp, char, extra_len+1);
- if (async_req_nomem(state->wb_resp->extra_data.data, req)) {
- return;
- }
- ((char *)state->wb_resp->extra_data.data)[extra_len] = 0;
-
- subreq = recvall_send(
- req, state->ev, state->fd, state->wb_resp->extra_data.data,
- extra_len, 0);
- if (async_req_nomem(subreq, req)) {
- return;
- }
-
- subreq->async.fn = wb_resp_read_extra;
- subreq->async.priv = req;
-}
-
-static void wb_resp_read_extra(struct async_req *subreq)
-{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- int err;
- ssize_t ret;
+ state->wb_resp = (struct winbindd_response *)buf;
- ret = recvall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (ret < 0) {
- async_req_error(req, map_wbc_err_from_errno(err));
- return;
+ if (state->wb_resp->length > sizeof(struct winbindd_response)) {
+ state->wb_resp->extra_data.data =
+ (char *)buf + sizeof(struct winbindd_response);
+ } else {
+ state->wb_resp->extra_data.data = NULL;
}
async_req_done(req);
}
-
wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
struct winbindd_response **presp)
{
@@ -481,91 +334,61 @@ wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
}
struct resp_write_state {
- struct winbindd_response *wb_resp;
- struct tevent_context *ev;
- int fd;
+ struct iovec iov[2];
};
-static void wb_resp_write_main(struct async_req *subreq);
-static void wb_resp_write_extra(struct async_req *subreq);
+static void wb_resp_write_done(struct tevent_req *subreq);
struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev, int fd,
struct winbindd_response *wb_resp)
{
- struct async_req *result, *subreq;
+ struct async_req *result;
+ struct tevent_req *subreq;
struct resp_write_state *state;
+ int count = 1;
if (!async_req_setup(mem_ctx, &result, &state,
struct resp_write_state)) {
return NULL;
}
- state->fd = fd;
- state->ev = ev;
- state->wb_resp = wb_resp;
- subreq = sendall_send(state, state->ev, state->fd, state->wb_resp,
- sizeof(struct winbindd_response), 0);
- if (subreq == NULL) {
- goto nomem;
+ state->iov[0].iov_base = wb_resp;
+ state->iov[0].iov_len = sizeof(struct winbindd_response);
+
+ if (wb_resp->length > sizeof(struct winbindd_response)) {
+ state->iov[1].iov_base = wb_resp->extra_data.data;
+ state->iov[1].iov_len =
+ wb_resp->length - sizeof(struct winbindd_response);
+ count = 2;
}
- subreq->async.fn = wb_resp_write_main;
- subreq->async.priv = result;
+ subreq = writev_send(state, ev, fd, state->iov, count);
+ if (subreq == NULL) {
+ goto fail;
+ }
+ subreq->async.fn = wb_resp_write_done;
+ subreq->async.private_data = result;
return result;
- nomem:
+ fail:
TALLOC_FREE(result);
return NULL;
}
-static void wb_resp_write_main(struct async_req *subreq)
+static void wb_resp_write_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- struct resp_write_state *state = talloc_get_type_abort(
- req->private_data, struct resp_write_state);
+ subreq->async.private_data, struct async_req);
int err;
ssize_t ret;
- ret = sendall_recv(subreq, &err);
+ ret = writev_recv(subreq, &err);
TALLOC_FREE(subreq);
if (ret < 0) {
async_req_error(req, map_wbc_err_from_errno(err));
return;
}
-
- if (state->wb_resp->length == sizeof(struct winbindd_response)) {
- async_req_done(req);
- return;
- }
-
- subreq = sendall_send(
- state, state->ev, state->fd,
- state->wb_resp->extra_data.data,
- state->wb_resp->length - sizeof(struct winbindd_response), 0);
- if (async_req_nomem(subreq, req)) {
- return;
- }
-
- subreq->async.fn = wb_resp_write_extra;
- subreq->async.priv = req;
-}
-
-static void wb_resp_write_extra(struct async_req *subreq)
-{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
- int err;
- ssize_t ret;
-
- ret = sendall_recv(subreq, &err);
- TALLOC_FREE(subreq);
- if (err < 0) {
- async_req_error(req, map_wbc_err_from_errno(err));
- return;
- }
-
async_req_done(req);
}
diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c
index 4d3a609530..b8d55a944a 100644
--- a/source3/lib/wbclient.c
+++ b/source3/lib/wbclient.c
@@ -147,17 +147,30 @@ struct wb_context *wb_context_init(TALLOC_CTX *mem_ctx)
return result;
}
+struct wb_connect_state {
+ int dummy;
+};
+
+static void wbc_connect_connected(struct tevent_req *subreq);
+
static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct wb_context *wb_ctx,
- const char *dir)
+ struct tevent_context *ev,
+ struct wb_context *wb_ctx,
+ const char *dir)
{
- struct async_req *req;
+ struct async_req *result;
+ struct tevent_req *subreq;
+ struct wb_connect_state *state;
struct sockaddr_un sunaddr;
struct stat st;
char *path = NULL;
wbcErr wbc_err;
+ if (!async_req_setup(mem_ctx, &result, &state,
+ struct wb_connect_state)) {
+ return NULL;
+ }
+
if (wb_ctx->fd != -1) {
close(wb_ctx->fd);
wb_ctx->fd = -1;
@@ -205,33 +218,46 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
goto post_status;
}
- req = async_connect_send(mem_ctx, ev, wb_ctx->fd,
- (struct sockaddr *)&sunaddr,
- sizeof(sunaddr));
- if (req == NULL) {
+ subreq = async_connect_send(mem_ctx, ev, wb_ctx->fd,
+ (struct sockaddr *)&sunaddr,
+ sizeof(sunaddr));
+ if (subreq == NULL) {
goto nomem;
}
- if (!async_req_set_timeout(req, ev, timeval_set(30, 0))) {
- TALLOC_FREE(req);
+ subreq->async.fn = wbc_connect_connected;
+ subreq->async.private_data = result;
+
+ if (!tevent_req_set_endtime(subreq, ev, timeval_current_ofs(30, 0))) {
goto nomem;
}
- return req;
+ return result;
nomem:
wbc_err = WBC_ERR_NO_MEMORY;
post_status:
- req = async_req_new(mem_ctx);
- if (req == NULL) {
- return NULL;
- }
- if (async_post_error(req, ev, wbc_err)) {
- return req;
+ if (async_post_error(result, ev, wbc_err)) {
+ return result;
}
- TALLOC_FREE(req);
+ TALLOC_FREE(result);
return NULL;
}
+static void wbc_connect_connected(struct tevent_req *subreq)
+{
+ struct async_req *req = talloc_get_type_abort(
+ subreq->async.private_data, struct async_req);
+ int res, err;
+
+ res = async_connect_recv(subreq, &err);
+ TALLOC_FREE(subreq);
+ if (res == -1) {
+ async_req_error(req, map_wbc_err_from_errno(err));
+ return;
+ }
+ async_req_done(req);
+}
+
static wbcErr wb_connect_recv(struct async_req *req)
{
return async_req_simple_recv_wbcerr(req);
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index dabfc398ce..ad11ee0ed4 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1642,6 +1642,7 @@ bool cli_session_request(struct cli_state *cli,
{
char *p;
int len = 4;
+ char *tmp;
/* 445 doesn't have session request */
if (cli->port == 445)
@@ -1651,14 +1652,30 @@ bool cli_session_request(struct cli_state *cli,
memcpy(&(cli->called ), called , sizeof(*called ));
/* put in the destination name */
+
+ tmp = name_mangle(talloc_tos(), cli->called.name,
+ cli->called.name_type);
+ if (tmp == NULL) {
+ return false;
+ }
+
p = cli->outbuf+len;
- name_mangle(cli->called .name, p, cli->called .name_type);
- len += name_len(p);
+ memcpy(p, tmp, name_len(tmp));
+ len += name_len(tmp);
+ TALLOC_FREE(tmp);
/* and my name */
+
+ tmp = name_mangle(talloc_tos(), cli->calling.name,
+ cli->calling.name_type);
+ if (tmp == NULL) {
+ return false;
+ }
+
p = cli->outbuf+len;
- name_mangle(cli->calling.name, p, cli->calling.name_type);
- len += name_len(p);
+ memcpy(p, tmp, name_len(tmp));
+ len += name_len(tmp);
+ TALLOC_FREE(tmp);
/* send a session request (RFC 1002) */
/* setup the packet length
diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c
index 1843fe262f..56661af70b 100644
--- a/source3/libsmb/libsmb_dir.c
+++ b/source3/libsmb/libsmb_dir.c
@@ -1519,7 +1519,7 @@ SMBC_chmod_ctx(SMBCCTX *context,
return -1;
}
- DEBUG(4, ("smbc_chmod(%s, 0%3o)\n", fname, newmode));
+ DEBUG(4, ("smbc_chmod(%s, 0%3o)\n", fname, (unsigned int)newmode));
if (SMBC_parse_path(frame,
context,
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 02b13ae63e..5f3eda44fe 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -1279,12 +1279,19 @@ static int name_interpret(char *in, fstring name)
Note: <Out> must be (33 + strlen(scope) + 2) bytes long, at minimum.
****************************************************************************/
-int name_mangle( char *In, char *Out, char name_type )
+char *name_mangle(TALLOC_CTX *mem_ctx, char *In, char name_type)
{
int i;
int len;
nstring buf;
- char *p = Out;
+ char *result;
+ char *p;
+
+ result = talloc_array(mem_ctx, char, 33 + strlen(global_scope()) + 2);
+ if (result == NULL) {
+ return NULL;
+ }
+ p = result;
/* Safely copy the input string, In, into buf[]. */
if (strcmp(In,"*") == 0)
@@ -1321,7 +1328,7 @@ int name_mangle( char *In, char *Out, char name_type )
p[0] = len;
if( len > 0 )
p[len+1] = 0;
- return( name_len(Out) );
+ return result;
case '.':
p[0] = len;
p += (len + 1);
@@ -1333,7 +1340,7 @@ int name_mangle( char *In, char *Out, char name_type )
}
}
- return( name_len(Out) );
+ return result;
}
/****************************************************************************
diff --git a/source3/modules/onefs.h b/source3/modules/onefs.h
index a70664bbf3..418e13d9d2 100644
--- a/source3/modules/onefs.h
+++ b/source3/modules/onefs.h
@@ -41,6 +41,8 @@ enum onefs_acl_wire_format
#define PARM_ONEFS_TYPE "onefs"
#define PARM_ACL_WIRE_FORMAT "acl wire format"
#define PARM_ACL_WIRE_FORMAT_DEFAULT ACL_FORMAT_WINDOWS_SD
+#define PARM_ALLOW_EXECUTE_ALWAYS "allow execute always"
+#define PARM_ALLOW_EXECUTE_ALWAYS_DEFAULT false
#define PARM_ATIME_NOW "atime now files"
#define PARM_ATIME_NOW_DEFAULT NULL
#define PARM_ATIME_STATIC "atime static files"
diff --git a/source3/modules/onefs_acl.c b/source3/modules/onefs_acl.c
index 7bc4a1728f..a1bfa6e121 100644
--- a/source3/modules/onefs_acl.c
+++ b/source3/modules/onefs_acl.c
@@ -273,9 +273,6 @@ onefs_samba_acl_to_acl(SEC_ACL *samba_acl, struct ifs_security_acl **acl,
if (aclu_initialize_acl(acl, aces, num_aces))
goto err_free;
- if (aclu_initialize_acl(acl, aces, num_aces))
- goto err_free;
-
/* Currently aclu_initialize_acl should copy the aces over, allowing
* us to immediately free */
free(aces);
@@ -614,6 +611,8 @@ onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
bool fopened = false;
NTSTATUS status = NT_STATUS_OK;
+ START_PROFILE(syscall_get_sd);
+
*ppdesc = NULL;
DEBUG(5, ("Getting sd for file %s. security_info=%u\n",
@@ -753,6 +752,9 @@ onefs_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
DEBUG(5, ("Finished retrieving/canonicalizing SD!\n"));
/* FALLTHROUGH */
out:
+
+ END_PROFILE(syscall_get_sd);
+
if (alloced && sd) {
if (new_aces_alloced && sd->dacl->aces)
SAFE_FREE(sd->dacl->aces);
@@ -888,18 +890,20 @@ onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
uint32 security_info_sent, SEC_DESC *psd)
{
struct ifs_security_descriptor sd = {};
- int fd;
+ int fd = -1;
bool fopened = false;
NTSTATUS status;
+ START_PROFILE(syscall_set_sd);
+
DEBUG(5,("Setting SD on file %s.\n", fsp->fsp_name ));
status = onefs_samba_sd_to_sd(security_info_sent, psd, &sd,
SNUM(handle->conn));
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("SD initialization failure: %s", nt_errstr(status)));
- return status;
+ DEBUG(3, ("SD initialization failure: %s\n", nt_errstr(status)));
+ goto out;
}
fd = fsp->fh->fd;
@@ -938,6 +942,8 @@ onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
/* FALLTHROUGH */
out:
+ END_PROFILE(syscall_set_sd);
+
if (fopened)
close(fd);
diff --git a/source3/modules/onefs_cbrl.c b/source3/modules/onefs_cbrl.c
index a860023764..2c5e39c359 100644
--- a/source3/modules/onefs_cbrl.c
+++ b/source3/modules/onefs_cbrl.c
@@ -255,6 +255,8 @@ NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
struct onefs_cbrl_blr_state *bs;
NTSTATUS status;
+ START_PROFILE(syscall_brl_lock);
+
SMB_ASSERT(plock->lock_flav == WINDOWS_LOCK);
SMB_ASSERT(plock->lock_type != UNLOCK_LOCK);
@@ -301,10 +303,13 @@ NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
/* ASYNC still in progress: The process_* calls will keep
* calling even if we haven't gotten the lock. Keep erroring
* without calling ifs_cbrl, or getting/setting an id. */
- if (bs->state == ONEFS_CBRL_ASYNC)
+ if (bs->state == ONEFS_CBRL_ASYNC) {
goto failure;
- else if (bs->state == ONEFS_CBRL_ERROR)
+ }
+ else if (bs->state == ONEFS_CBRL_ERROR) {
+ END_PROFILE(syscall_brl_lock);
return NT_STATUS_NO_MEMORY;
+ }
SMB_ASSERT(bs->state == ONEFS_CBRL_NONE);
async = true;
@@ -343,6 +348,9 @@ NTSTATUS onefs_brl_lock_windows(vfs_handle_struct *handle,
}
failure:
+
+ END_PROFILE(syscall_brl_lock);
+
/* Failure - error or async. */
plock->context.smbpid = (uint32) ONEFS_BLOCKING_PID;
@@ -355,6 +363,9 @@ failure:
return status;
success:
+
+ END_PROFILE(syscall_brl_lock);
+
/* Success. */
onefs_cbrl_enumerate_blq("onefs_brl_unlock_windows");
DEBUG(10, ("returning NT_STATUS_OK.\n"));
@@ -371,6 +382,8 @@ bool onefs_brl_unlock_windows(vfs_handle_struct *handle,
int error;
int fd = br_lck->fsp->fh->fd;
+ START_PROFILE(syscall_brl_unlock);
+
SMB_ASSERT(plock->lock_flav == WINDOWS_LOCK);
SMB_ASSERT(plock->lock_type == UNLOCK_LOCK);
@@ -378,6 +391,9 @@ bool onefs_brl_unlock_windows(vfs_handle_struct *handle,
error = ifs_cbrl(fd, CBRL_OP_UNLOCK, CBRL_NOTYPE,
plock->start, plock->size, CBRL_NOTYPE, 0, plock->context.smbpid,
plock->context.tid, plock->fnum);
+
+ END_PROFILE(syscall_brl_unlock);
+
if (error) {
DEBUG(10, ("returning false.\n"));
return false;
@@ -404,6 +420,8 @@ bool onefs_brl_cancel_windows(vfs_handle_struct *handle,
int fd = br_lck->fsp->fh->fd;
struct onefs_cbrl_blr_state *bs;
+ START_PROFILE(syscall_brl_cancel);
+
SMB_ASSERT(plock);
SMB_ASSERT(plock->lock_flav == WINDOWS_LOCK);
SMB_ASSERT(blr);
@@ -416,6 +434,7 @@ bool onefs_brl_cancel_windows(vfs_handle_struct *handle,
if (bs->state == ONEFS_CBRL_DONE) {
/* No-op. */
DEBUG(10, ("State=DONE, returning true\n"));
+ END_PROFILE(syscall_brl_cancel);
return true;
}
@@ -427,6 +446,9 @@ bool onefs_brl_cancel_windows(vfs_handle_struct *handle,
error = ifs_cbrl(fd, CBRL_OP_CANCEL, CBRL_NOTYPE, plock->start,
plock->size, CBRL_NOTYPE, bs->id, plock->context.smbpid,
plock->context.tid, plock->fnum);
+
+ END_PROFILE(syscall_brl_cancel);
+
if (error) {
DEBUG(10, ("returning false\n"));
bs->state = ONEFS_CBRL_ERROR;
diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c
index 9616ca48d5..2dcd8891eb 100644
--- a/source3/modules/onefs_streams.c
+++ b/source3/modules/onefs_streams.c
@@ -160,18 +160,26 @@ int onefs_rename(vfs_handle_struct *handle, const char *oldname,
char *nbase = NULL;
char *nsname = NULL;
+ START_PROFILE(syscall_rename_at);
+
frame = talloc_stackframe();
ret = onefs_is_stream(oldname, &obase, &osname, &old_is_stream);
- if (ret)
+ if (ret) {
+ END_PROFILE(syscall_rename_at);
return ret;
+ }
ret = onefs_is_stream(newname, &nbase, &nsname, &new_is_stream);
- if (ret)
+ if (ret) {
+ END_PROFILE(syscall_rename_at);
return ret;
+ }
if (!old_is_stream && !new_is_stream) {
- return SMB_VFS_NEXT_RENAME(handle, oldname, newname);
+ ret = SMB_VFS_NEXT_RENAME(handle, oldname, newname);
+ END_PROFILE(syscall_rename_at);
+ return ret;
}
dir_fd = get_stream_dir_fd(handle->conn, obase, NULL);
@@ -192,6 +200,8 @@ int onefs_rename(vfs_handle_struct *handle, const char *oldname,
}
done:
+ END_PROFILE(syscall_rename_at);
+
saved_errno = errno;
if (dir_fd >= 0) {
close(dir_fd);
diff --git a/source3/modules/onefs_system.c b/source3/modules/onefs_system.c
index 10802895cd..518a398154 100644
--- a/source3/modules/onefs_system.c
+++ b/source3/modules/onefs_system.c
@@ -95,6 +95,8 @@ int onefs_sys_create_file(connection_struct *conn,
uint32_t onefs_dos_attributes;
struct ifs_createfile_flags cf_flags = CF_FLAGS_NONE;
+ START_PROFILE(syscall_createfile);
+
/* Setup security descriptor and get secinfo. */
if (sd != NULL) {
NTSTATUS status;
@@ -132,6 +134,30 @@ int onefs_sys_create_file(connection_struct *conn,
if (lp_nt_acl_support(SNUM(conn)) && !lp_inherit_perms(SNUM(conn)))
cf_flags = cf_flags_or(cf_flags, CF_FLAGS_DEFAULT_ACL);
+ /*
+ * Some customer workflows require the execute bit to be ignored.
+ */
+ if (lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+ PARM_ALLOW_EXECUTE_ALWAYS,
+ PARM_ALLOW_EXECUTE_ALWAYS_DEFAULT) &&
+ (open_access_mask & FILE_EXECUTE)) {
+
+ DEBUG(3, ("Stripping execute bit from %s: (0x%x)\n", path,
+ open_access_mask));
+
+ /* Strip execute. */
+ open_access_mask &= ~FILE_EXECUTE;
+
+ /*
+ * Add READ_DATA, so we're not left with desired_access=0. An
+ * execute call should imply the client will read the data.
+ */
+ open_access_mask |= FILE_READ_DATA;
+
+ DEBUGADD(3, ("New stripped access mask: 0x%x\n",
+ open_access_mask));
+ }
+
DEBUG(10,("onefs_sys_create_file: base_fd = %d, "
"open_access_mask = 0x%x, flags = 0x%x, mode = 0%o, "
"desired_oplock = %s, id = 0x%x, secinfo = 0x%x, sd = %p, "
@@ -172,6 +198,7 @@ int onefs_sys_create_file(connection_struct *conn,
}
out:
+ END_PROFILE(syscall_createfile);
aclu_free_sd(pifs_sd, false);
return ret_fd;
@@ -283,6 +310,8 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
bool atomic = false;
ssize_t ret = 0;
+ START_PROFILE_BYTES(syscall_sendfile, count);
+
if (lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
PARM_ATOMIC_SENDFILE,
PARM_ATOMIC_SENDFILE_DEFAULT)) {
@@ -296,6 +325,7 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
/* If the sendfile wasn't atomic, we're done. */
if (!atomic) {
DEBUG(10, ("non-atomic sendfile read %ul bytes", ret));
+ END_PROFILE(syscall_sendfile);
return ret;
}
@@ -367,6 +397,7 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
/* Handle case 1: short read -> truncated file. */
if (ret == 0) {
+ END_PROFILE(syscall_sendfile);
return ret;
}
@@ -378,6 +409,7 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
PARM_SENDFILE_LARGE_READS_DEFAULT)) {
DEBUG(3, ("Not attempting non-atomic large sendfile: "
"%lu bytes\n", count));
+ END_PROFILE(syscall_sendfile);
return 0;
}
@@ -397,6 +429,7 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
DEBUG(1, ("error on non-atomic large sendfile "
"(%lu bytes): %s\n", count,
strerror(errno)));
+ END_PROFILE(syscall_sendfile);
return ret;
}
@@ -415,9 +448,11 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
if (lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
PARM_SENDFILE_SAFE,
PARM_SENDFILE_SAFE_DEFAULT)) {
+ END_PROFILE(syscall_sendfile);
return -1;
}
+ END_PROFILE(syscall_sendfile);
return ret;
}
@@ -431,6 +466,7 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
count, strerror(errno)));
}
+ END_PROFILE(syscall_sendfile);
return ret;
}
@@ -485,10 +521,13 @@ ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset,
off_t rbytes;
off_t wbytes;
+ START_PROFILE_BYTES(syscall_recvfile, count);
+
DEBUG(10,("onefs_recvfile: from = %d, to = %d, offset=%llu, count = "
"%lu\n", fromfd, tofd, offset, count));
if (count == 0) {
+ END_PROFILE(syscall_recvfile);
return 0;
}
@@ -600,6 +639,9 @@ ssize_t onefs_sys_recvfile(int fromfd, int tofd, SMB_OFF_T offset,
ret = total_wbytes;
out:
+
+ END_PROFILE(syscall_recvfile);
+
/* Make sure we always try to drain the socket. */
if (!socket_drained && count - total_rbytes) {
int saved_errno = errno;
diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c
index d7c9d39c5e..b59a780f52 100644
--- a/source3/modules/vfs_extd_audit.c
+++ b/source3/modules/vfs_extd_audit.c
@@ -310,7 +310,7 @@ static int audit_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
(result < 0) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: chmod %s mode 0x%x %s %s\n",
- path, mode,
+ path, (unsigned int)mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
@@ -330,7 +330,7 @@ static int audit_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t m
(result < 0) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: chmod_acl %s mode 0x%x %s %s\n",
- path, mode,
+ path, (unsigned int)mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
@@ -350,7 +350,7 @@ static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mod
(result < 0) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: fchmod %s mode 0x%x %s %s",
- fsp->fsp_name, mode,
+ fsp->fsp_name, (unsigned int)mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
@@ -370,7 +370,7 @@ static int audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fsp, mode_t
(result < 0) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: fchmod_acl %s mode 0x%x %s %s",
- fsp->fsp_name, mode,
+ fsp->fsp_name, (unsigned int)mode,
(result < 0) ? "failed: " : "",
(result < 0) ? strerror(errno) : ""));
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index adefb7d94f..3279466602 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -412,18 +412,18 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
const struct sockaddr_storage *pss;
const struct in_addr *local_ip;
- DEBUG(10, ("Received send_packet from %d\n", procid_to_pid(&src)));
+ DEBUG(10, ("Received send_packet from %u\n", (unsigned int)procid_to_pid(&src)));
if (data->length != sizeof(struct packet_struct)) {
- DEBUG(2, ("Discarding invalid packet length from %d\n",
- procid_to_pid(&src)));
+ DEBUG(2, ("Discarding invalid packet length from %u\n",
+ (unsigned int)procid_to_pid(&src)));
return;
}
if ((p->packet_type != NMB_PACKET) &&
(p->packet_type != DGRAM_PACKET)) {
- DEBUG(2, ("Discarding invalid packet type from %d: %d\n",
- procid_to_pid(&src), p->packet_type));
+ DEBUG(2, ("Discarding invalid packet type from %u: %d\n",
+ (unsigned int)procid_to_pid(&src), p->packet_type));
return;
}
@@ -431,8 +431,8 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
pss = iface_ip((struct sockaddr *)&ss);
if (pss == NULL) {
- DEBUG(2, ("Could not find ip for packet from %d\n",
- procid_to_pid(&src)));
+ DEBUG(2, ("Could not find ip for packet from %u\n",
+ (unsigned int)procid_to_pid(&src)));
return;
}
diff --git a/source3/passdb/pdb_onefs_sam.c b/source3/passdb/pdb_wbc_sam.c
index 51b8618aad..33dc03fe4c 100644
--- a/source3/passdb/pdb_onefs_sam.c
+++ b/source3/passdb/pdb_wbc_sam.c
@@ -1,6 +1,8 @@
/*
Unix SMB/CIFS implementation.
- Password and authentication handling for wbclient
+
+ Password and authentication handling by wbclient
+
Copyright (C) Andrew Bartlett 2002
Copyright (C) Jelmer Vernooij 2002
Copyright (C) Simo Sorce 2003
@@ -21,12 +23,25 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/* This passdb module retrieves full passdb information for local users and
+ * groups from a wbclient compatible daemon.
+ *
+ * The purpose of this module is to defer all SAM authorization information
+ * storage and retrieval to a wbc compatible daemon.
+ *
+ * This passdb backend is most useful when used in conjunction with auth_wbc.
+ *
+ * A few current limitations of this module are:
+ * - read only interface
+ * - no privileges
+ */
+
#include "includes.h"
/***************************************************************************
Default implementations of some functions.
****************************************************************************/
-static NTSTATUS _pdb_onefs_sam_getsampw(struct pdb_methods *methods,
+static NTSTATUS _pdb_wbc_sam_getsampw(struct pdb_methods *methods,
struct samu *user,
const struct passwd *pwd)
{
@@ -44,29 +59,29 @@ static NTSTATUS _pdb_onefs_sam_getsampw(struct pdb_methods *methods,
return result;
}
-static NTSTATUS pdb_onefs_sam_getsampwnam(struct pdb_methods *methods, struct samu *user, const char *sname)
+static NTSTATUS pdb_wbc_sam_getsampwnam(struct pdb_methods *methods, struct samu *user, const char *sname)
{
- return _pdb_onefs_sam_getsampw(methods, user, winbind_getpwnam(sname));
+ return _pdb_wbc_sam_getsampw(methods, user, winbind_getpwnam(sname));
}
-static NTSTATUS pdb_onefs_sam_getsampwsid(struct pdb_methods *methods, struct samu *user, const DOM_SID *sid)
+static NTSTATUS pdb_wbc_sam_getsampwsid(struct pdb_methods *methods, struct samu *user, const DOM_SID *sid)
{
- return _pdb_onefs_sam_getsampw(methods, user, winbind_getpwsid(sid));
+ return _pdb_wbc_sam_getsampw(methods, user, winbind_getpwsid(sid));
}
-static bool pdb_onefs_sam_uid_to_sid(struct pdb_methods *methods, uid_t uid,
+static bool pdb_wbc_sam_uid_to_sid(struct pdb_methods *methods, uid_t uid,
DOM_SID *sid)
{
return winbind_uid_to_sid(sid, uid);
}
-static bool pdb_onefs_sam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
+static bool pdb_wbc_sam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
DOM_SID *sid)
{
return winbind_gid_to_sid(sid, gid);
}
-static bool pdb_onefs_sam_sid_to_id(struct pdb_methods *methods,
+static bool pdb_wbc_sam_sid_to_id(struct pdb_methods *methods,
const DOM_SID *sid,
union unid_t *id, enum lsa_SidType *type)
{
@@ -82,7 +97,7 @@ static bool pdb_onefs_sam_sid_to_id(struct pdb_methods *methods,
return true;
}
-static NTSTATUS pdb_onefs_sam_enum_group_members(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_enum_group_members(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
const DOM_SID *group,
uint32 **pp_member_rids,
@@ -91,7 +106,7 @@ static NTSTATUS pdb_onefs_sam_enum_group_members(struct pdb_methods *methods,
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_onefs_sam_enum_group_memberships(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_enum_group_memberships(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
struct samu *user,
DOM_SID **pp_sids,
@@ -123,7 +138,7 @@ static NTSTATUS pdb_onefs_sam_enum_group_memberships(struct pdb_methods *methods
return NT_STATUS_OK;
}
-static NTSTATUS pdb_onefs_sam_lookup_rids(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_lookup_rids(struct pdb_methods *methods,
const DOM_SID *domain_sid,
int num_rids,
uint32 *rids,
@@ -164,23 +179,23 @@ done:
return result;
}
-static NTSTATUS pdb_onefs_sam_get_account_policy(struct pdb_methods *methods, int policy_index, uint32 *value)
+static NTSTATUS pdb_wbc_sam_get_account_policy(struct pdb_methods *methods, int policy_index, uint32 *value)
{
return NT_STATUS_UNSUCCESSFUL;
}
-static NTSTATUS pdb_onefs_sam_set_account_policy(struct pdb_methods *methods, int policy_index, uint32 value)
+static NTSTATUS pdb_wbc_sam_set_account_policy(struct pdb_methods *methods, int policy_index, uint32 value)
{
return NT_STATUS_UNSUCCESSFUL;
}
-static bool pdb_onefs_sam_search_groups(struct pdb_methods *methods,
+static bool pdb_wbc_sam_search_groups(struct pdb_methods *methods,
struct pdb_search *search)
{
return false;
}
-static bool pdb_onefs_sam_search_aliases(struct pdb_methods *methods,
+static bool pdb_wbc_sam_search_aliases(struct pdb_methods *methods,
struct pdb_search *search,
const DOM_SID *sid)
{
@@ -188,7 +203,7 @@ static bool pdb_onefs_sam_search_aliases(struct pdb_methods *methods,
return false;
}
-static bool pdb_onefs_sam_get_trusteddom_pw(struct pdb_methods *methods,
+static bool pdb_wbc_sam_get_trusteddom_pw(struct pdb_methods *methods,
const char *domain,
char **pwd,
DOM_SID *sid,
@@ -198,7 +213,7 @@ static bool pdb_onefs_sam_get_trusteddom_pw(struct pdb_methods *methods,
}
-static bool pdb_onefs_sam_set_trusteddom_pw(struct pdb_methods *methods,
+static bool pdb_wbc_sam_set_trusteddom_pw(struct pdb_methods *methods,
const char *domain,
const char *pwd,
const DOM_SID *sid)
@@ -206,13 +221,13 @@ static bool pdb_onefs_sam_set_trusteddom_pw(struct pdb_methods *methods,
return false;
}
-static bool pdb_onefs_sam_del_trusteddom_pw(struct pdb_methods *methods,
+static bool pdb_wbc_sam_del_trusteddom_pw(struct pdb_methods *methods,
const char *domain)
{
return false;
}
-static NTSTATUS pdb_onefs_sam_enum_trusteddoms(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_enum_trusteddoms(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
uint32 *num_domains,
struct trustdom_info ***domains)
@@ -230,7 +245,7 @@ static bool _make_group_map(struct pdb_methods *methods, const char *domain, con
return true;
}
-static NTSTATUS pdb_onefs_sam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
+static NTSTATUS pdb_wbc_sam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
DOM_SID sid)
{
NTSTATUS result = NT_STATUS_OK;
@@ -269,7 +284,7 @@ done:
return result;
}
-static NTSTATUS pdb_onefs_sam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
+static NTSTATUS pdb_wbc_sam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
gid_t gid)
{
NTSTATUS result = NT_STATUS_OK;
@@ -309,7 +324,7 @@ done:
return result;
}
-static NTSTATUS pdb_onefs_sam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
+static NTSTATUS pdb_wbc_sam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
const char *name)
{
NTSTATUS result = NT_STATUS_OK;
@@ -347,7 +362,7 @@ done:
return result;
}
-static NTSTATUS pdb_onefs_sam_enum_group_mapping(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_enum_group_mapping(struct pdb_methods *methods,
const DOM_SID *sid, enum lsa_SidType sid_name_use,
GROUP_MAP **pp_rmap, size_t *p_num_entries,
bool unix_only)
@@ -355,21 +370,21 @@ static NTSTATUS pdb_onefs_sam_enum_group_mapping(struct pdb_methods *methods,
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_onefs_sam_get_aliasinfo(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_get_aliasinfo(struct pdb_methods *methods,
const DOM_SID *sid,
struct acct_info *info)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_onefs_sam_enum_aliasmem(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_enum_aliasmem(struct pdb_methods *methods,
const DOM_SID *alias, DOM_SID **pp_members,
size_t *p_num_members)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_onefs_sam_alias_memberships(struct pdb_methods *methods,
+static NTSTATUS pdb_wbc_sam_alias_memberships(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
const DOM_SID *domain_sid,
const DOM_SID *members,
@@ -384,7 +399,7 @@ static NTSTATUS pdb_onefs_sam_alias_memberships(struct pdb_methods *methods,
return NT_STATUS_OK;
}
-static NTSTATUS pdb_init_onefs_sam(struct pdb_methods **pdb_method, const char *location)
+static NTSTATUS pdb_init_wbc_sam(struct pdb_methods **pdb_method, const char *location)
{
NTSTATUS result;
@@ -392,34 +407,34 @@ static NTSTATUS pdb_init_onefs_sam(struct pdb_methods **pdb_method, const char *
return result;
}
- (*pdb_method)->name = "onefs_sam";
-
- (*pdb_method)->getsampwnam = pdb_onefs_sam_getsampwnam;
- (*pdb_method)->getsampwsid = pdb_onefs_sam_getsampwsid;
-
- (*pdb_method)->getgrsid = pdb_onefs_sam_getgrsid;
- (*pdb_method)->getgrgid = pdb_onefs_sam_getgrgid;
- (*pdb_method)->getgrnam = pdb_onefs_sam_getgrnam;
- (*pdb_method)->enum_group_mapping = pdb_onefs_sam_enum_group_mapping;
- (*pdb_method)->enum_group_members = pdb_onefs_sam_enum_group_members;
- (*pdb_method)->enum_group_memberships = pdb_onefs_sam_enum_group_memberships;
- (*pdb_method)->get_aliasinfo = pdb_onefs_sam_get_aliasinfo;
- (*pdb_method)->enum_aliasmem = pdb_onefs_sam_enum_aliasmem;
- (*pdb_method)->enum_alias_memberships = pdb_onefs_sam_alias_memberships;
- (*pdb_method)->lookup_rids = pdb_onefs_sam_lookup_rids;
- (*pdb_method)->get_account_policy = pdb_onefs_sam_get_account_policy;
- (*pdb_method)->set_account_policy = pdb_onefs_sam_set_account_policy;
- (*pdb_method)->uid_to_sid = pdb_onefs_sam_uid_to_sid;
- (*pdb_method)->gid_to_sid = pdb_onefs_sam_gid_to_sid;
- (*pdb_method)->sid_to_id = pdb_onefs_sam_sid_to_id;
-
- (*pdb_method)->search_groups = pdb_onefs_sam_search_groups;
- (*pdb_method)->search_aliases = pdb_onefs_sam_search_aliases;
-
- (*pdb_method)->get_trusteddom_pw = pdb_onefs_sam_get_trusteddom_pw;
- (*pdb_method)->set_trusteddom_pw = pdb_onefs_sam_set_trusteddom_pw;
- (*pdb_method)->del_trusteddom_pw = pdb_onefs_sam_del_trusteddom_pw;
- (*pdb_method)->enum_trusteddoms = pdb_onefs_sam_enum_trusteddoms;
+ (*pdb_method)->name = "wbc_sam";
+
+ (*pdb_method)->getsampwnam = pdb_wbc_sam_getsampwnam;
+ (*pdb_method)->getsampwsid = pdb_wbc_sam_getsampwsid;
+
+ (*pdb_method)->getgrsid = pdb_wbc_sam_getgrsid;
+ (*pdb_method)->getgrgid = pdb_wbc_sam_getgrgid;
+ (*pdb_method)->getgrnam = pdb_wbc_sam_getgrnam;
+ (*pdb_method)->enum_group_mapping = pdb_wbc_sam_enum_group_mapping;
+ (*pdb_method)->enum_group_members = pdb_wbc_sam_enum_group_members;
+ (*pdb_method)->enum_group_memberships = pdb_wbc_sam_enum_group_memberships;
+ (*pdb_method)->get_aliasinfo = pdb_wbc_sam_get_aliasinfo;
+ (*pdb_method)->enum_aliasmem = pdb_wbc_sam_enum_aliasmem;
+ (*pdb_method)->enum_alias_memberships = pdb_wbc_sam_alias_memberships;
+ (*pdb_method)->lookup_rids = pdb_wbc_sam_lookup_rids;
+ (*pdb_method)->get_account_policy = pdb_wbc_sam_get_account_policy;
+ (*pdb_method)->set_account_policy = pdb_wbc_sam_set_account_policy;
+ (*pdb_method)->uid_to_sid = pdb_wbc_sam_uid_to_sid;
+ (*pdb_method)->gid_to_sid = pdb_wbc_sam_gid_to_sid;
+ (*pdb_method)->sid_to_id = pdb_wbc_sam_sid_to_id;
+
+ (*pdb_method)->search_groups = pdb_wbc_sam_search_groups;
+ (*pdb_method)->search_aliases = pdb_wbc_sam_search_aliases;
+
+ (*pdb_method)->get_trusteddom_pw = pdb_wbc_sam_get_trusteddom_pw;
+ (*pdb_method)->set_trusteddom_pw = pdb_wbc_sam_set_trusteddom_pw;
+ (*pdb_method)->del_trusteddom_pw = pdb_wbc_sam_del_trusteddom_pw;
+ (*pdb_method)->enum_trusteddoms = pdb_wbc_sam_enum_trusteddoms;
(*pdb_method)->private_data = NULL;
(*pdb_method)->free_private_data = NULL;
@@ -427,7 +442,7 @@ static NTSTATUS pdb_init_onefs_sam(struct pdb_methods **pdb_method, const char *
return NT_STATUS_OK;
}
-NTSTATUS pdb_onefs_sam_init(void)
+NTSTATUS pdb_wbc_sam_init(void)
{
- return smb_register_passdb(PASSDB_INTERFACE_VERSION, "onefs_sam", pdb_init_onefs_sam);
+ return smb_register_passdb(PASSDB_INTERFACE_VERSION, "wbc_sam", pdb_init_wbc_sam);
}
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index d478b86f91..e19212eea8 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -397,8 +397,10 @@ void notify_printer_status_byname(const char *sharename, uint32 status)
{
/* Printer status stored in value1 */
+ int snum = print_queue_snum(sharename);
+
send_notify_field_values(sharename, PRINTER_NOTIFY_TYPE,
- PRINTER_NOTIFY_STATUS, 0,
+ PRINTER_NOTIFY_STATUS, snum,
status, 0, 0);
}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index ad3a95826a..bbe8ebc2bc 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -5408,11 +5408,12 @@ WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr)
{
SEC_DESC_BUF *new_secdesc_ctr = NULL;
SEC_DESC_BUF *old_secdesc_ctr = NULL;
- prs_struct ps;
- bool prs_init_done = false;
TALLOC_CTX *mem_ctx = NULL;
TDB_DATA kbuf;
+ TDB_DATA dbuf;
+ DATA_BLOB blob;
WERROR status;
+ NTSTATUS nt_status;
mem_ctx = talloc_init("nt_printing_setsec");
if (mem_ctx == NULL)
@@ -5474,26 +5475,19 @@ WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr)
/* Store the security descriptor in a tdb */
- if (!prs_init(&ps,
- (uint32_t)ndr_size_security_descriptor(new_secdesc_ctr->sd,
- NULL, 0)
- + sizeof(SEC_DESC_BUF), mem_ctx, MARSHALL) ) {
- status = WERR_NOMEM;
- goto out;
- }
-
-
- prs_init_done = true;
-
- if (!sec_io_desc_buf("nt_printing_setsec", &new_secdesc_ctr,
- &ps, 1)) {
- status = WERR_BADFUNC;
+ nt_status = marshall_sec_desc_buf(mem_ctx, new_secdesc_ctr,
+ &blob.data, &blob.length);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ status = ntstatus_to_werror(nt_status);
goto out;
}
kbuf = make_printers_secdesc_tdbkey(mem_ctx, sharename );
- if (tdb_prs_store(tdb_printers, kbuf, &ps)==0) {
+ dbuf.dptr = (unsigned char *)blob.data;
+ dbuf.dsize = blob.length;
+
+ if (tdb_trans_store(tdb_printers, kbuf, dbuf, TDB_REPLACE)==0) {
status = WERR_OK;
} else {
DEBUG(1,("Failed to store secdesc for %s\n", sharename));
@@ -5501,12 +5495,10 @@ WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr)
}
/* Free malloc'ed memory */
+ talloc_free(blob.data);
out:
- if (prs_init_done) {
- prs_mem_free(&ps);
- }
if (mem_ctx)
talloc_destroy(mem_ctx);
return status;
@@ -5602,47 +5594,45 @@ static SEC_DESC_BUF *construct_default_printer_sdb(TALLOC_CTX *ctx)
bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **secdesc_ctr)
{
- prs_struct ps;
TDB_DATA kbuf;
+ TDB_DATA dbuf;
+ DATA_BLOB blob;
char *temp;
+ NTSTATUS status;
if (strlen(sharename) > 2 && (temp = strchr(sharename + 2, '\\'))) {
sharename = temp + 1;
}
- ZERO_STRUCT(ps);
-
/* Fetch security descriptor from tdb */
- kbuf = make_printers_secdesc_tdbkey(ctx, sharename );
-
- if (tdb_prs_fetch(tdb_printers, kbuf, &ps, ctx)!=0 ||
- !sec_io_desc_buf("nt_printing_getsec", secdesc_ctr, &ps, 1)) {
-
- prs_mem_free(&ps);
-
- DEBUG(4,("using default secdesc for %s\n", sharename));
+ kbuf = make_printers_secdesc_tdbkey(ctx, sharename);
- if (!(*secdesc_ctr = construct_default_printer_sdb(ctx))) {
- return False;
- }
-
- /* Save default security descriptor for later */
+ dbuf = tdb_fetch(tdb_printers, kbuf);
+ if (dbuf.dptr) {
- if (!prs_init(&ps, (uint32_t)ndr_size_security_descriptor((*secdesc_ctr)->sd, NULL, 0) +
- sizeof(SEC_DESC_BUF), ctx, MARSHALL))
- return False;
+ status = unmarshall_sec_desc_buf(ctx, dbuf.dptr, dbuf.dsize,
+ secdesc_ctr);
+ SAFE_FREE(dbuf.dptr);
- if (sec_io_desc_buf("nt_printing_getsec", secdesc_ctr, &ps, 1)) {
- tdb_prs_store(tdb_printers, kbuf, &ps);
+ if (NT_STATUS_IS_OK(status)) {
+ return true;
}
+ }
- prs_mem_free(&ps);
-
- return True;
+ *secdesc_ctr = construct_default_printer_sdb(ctx);
+ if (!*secdesc_ctr) {
+ return false;
}
- prs_mem_free(&ps);
+ status = marshall_sec_desc_buf(ctx, *secdesc_ctr,
+ &blob.data, &blob.length);
+ if (NT_STATUS_IS_OK(status)) {
+ dbuf.dptr = (unsigned char *)blob.data;
+ dbuf.dsize = blob.length;
+ tdb_trans_store(tdb_printers, kbuf, dbuf, TDB_REPLACE);
+ talloc_free(blob.data);
+ }
/* If security descriptor is owned by S-1-1-0 and winbindd is up,
this security descriptor has been created when winbindd was
diff --git a/source3/profile/profile.c b/source3/profile/profile.c
index bdbd805718..6d2d5ae06d 100644
--- a/source3/profile/profile.c
+++ b/source3/profile/profile.c
@@ -290,6 +290,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
"syscall_rmdir", /* PR_VALUE_SYSCALL_RMDIR */
"syscall_closedir", /* PR_VALUE_SYSCALL_CLOSEDIR */
"syscall_open", /* PR_VALUE_SYSCALL_OPEN */
+ "syscall_createfile", /* PR_VALUE_SYSCALL_CREATEFILE */
"syscall_close", /* PR_VALUE_SYSCALL_CLOSE */
"syscall_read", /* PR_VALUE_SYSCALL_READ */
"syscall_pread", /* PR_VALUE_SYSCALL_PREAD */
@@ -299,6 +300,7 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
"syscall_sendfile", /* PR_VALUE_SYSCALL_SENDFILE */
"syscall_recvfile", /* PR_VALUE_SYSCALL_RECVFILE */
"syscall_rename", /* PR_VALUE_SYSCALL_RENAME */
+ "syscall_rename_at", /* PR_VALUE_SYSCALL_RENAME_AT */
"syscall_fsync", /* PR_VALUE_SYSCALL_FSYNC */
"syscall_stat", /* PR_VALUE_SYSCALL_STAT */
"syscall_fstat", /* PR_VALUE_SYSCALL_FSTAT */
@@ -323,6 +325,11 @@ bool profile_setup(struct messaging_context *msg_ctx, bool rdonly)
"syscall_realpath", /* PR_VALUE_SYSCALL_REALPATH */
"syscall_get_quota", /* PR_VALUE_SYSCALL_GET_QUOTA */
"syscall_set_quota", /* PR_VALUE_SYSCALL_SET_QUOTA */
+ "syscall_get_sd", /* PR_VALUE_SYSCALL_GET_SD */
+ "syscall_set_sd", /* PR_VALUE_SYSCALL_SET_SD */
+ "syscall_brl_lock", /* PR_VALUE_SYSCALL_BRL_LOCK */
+ "syscall_brl_unlock", /* PR_VALUE_SYSCALL_BRL_UNLOCK */
+ "syscall_brl_cancel", /* PR_VALUE_SYSCALL_BRL_CANCEL */
"SMBmkdir", /* PR_VALUE_SMBMKDIR */
"SMBrmdir", /* PR_VALUE_SMBRMDIR */
"SMBopen", /* PR_VALUE_SMBOPEN */
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 6ad3af1f4e..c9d23efdf2 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -75,6 +75,159 @@ WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
return WERR_OK;
}
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_GetPrinterDriver2
+**********************************************************************/
+
+WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ const char *architecture,
+ uint32_t level,
+ uint32_t offered,
+ uint32_t client_major_version,
+ uint32_t client_minor_version,
+ union spoolss_DriverInfo *info,
+ uint32_t *server_major_version,
+ uint32_t *server_minor_version)
+{
+ NTSTATUS status;
+ WERROR werror;
+ uint32_t needed;
+ DATA_BLOB buffer;
+
+ if (offered > 0) {
+ buffer = data_blob_talloc_zero(mem_ctx, offered);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
+ }
+
+ status = rpccli_spoolss_GetPrinterDriver2(cli, mem_ctx,
+ handle,
+ architecture,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ client_major_version,
+ client_minor_version,
+ info,
+ &needed,
+ server_major_version,
+ server_minor_version,
+ &werror);
+ if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+ offered = needed;
+ buffer = data_blob_talloc_zero(mem_ctx, needed);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
+
+ status = rpccli_spoolss_GetPrinterDriver2(cli, mem_ctx,
+ handle,
+ architecture,
+ level,
+ &buffer,
+ offered,
+ client_major_version,
+ client_minor_version,
+ info,
+ &needed,
+ server_major_version,
+ server_minor_version,
+ &werror);
+ }
+
+ return werror;
+}
+
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_AddPrinterEx
+**********************************************************************/
+
+WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct spoolss_SetPrinterInfoCtr *info_ctr)
+{
+ WERROR result;
+ NTSTATUS status;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
+ struct spoolss_UserLevelCtr userlevel_ctr;
+ struct spoolss_UserLevel1 level1;
+ struct policy_handle handle;
+
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
+
+ level1.size = 28;
+ level1.build = 1381;
+ level1.major = 2;
+ level1.minor = 0;
+ level1.processor = 0;
+ level1.client = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+ W_ERROR_HAVE_NO_MEMORY(level1.client);
+ level1.user = cli->auth->user_name;
+
+ userlevel_ctr.level = 1;
+ userlevel_ctr.user_info.level1 = &level1;
+
+ status = rpccli_spoolss_AddPrinterEx(cli, mem_ctx,
+ cli->srv_name_slash,
+ info_ctr,
+ &devmode_ctr,
+ &secdesc_ctr,
+ &userlevel_ctr,
+ &handle,
+ &result);
+ return result;
+}
+
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_GetPrinter
+**********************************************************************/
+
+WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t level,
+ uint32_t offered,
+ union spoolss_PrinterInfo *info)
+{
+ NTSTATUS status;
+ WERROR werror;
+ DATA_BLOB buffer;
+ uint32_t needed;
+
+ if (offered > 0) {
+ buffer = data_blob_talloc_zero(mem_ctx, offered);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
+ }
+
+ status = rpccli_spoolss_GetPrinter(cli, mem_ctx,
+ handle,
+ level,
+ (offered > 0) ? &buffer : NULL,
+ offered,
+ info,
+ &needed,
+ &werror);
+
+ if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+
+ offered = needed;
+ buffer = data_blob_talloc_zero(mem_ctx, offered);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
+
+ status = rpccli_spoolss_GetPrinter(cli, mem_ctx,
+ handle,
+ level,
+ &buffer,
+ offered,
+ info,
+ &needed,
+ &werror);
+ }
+
+ return werror;
+}
+
/*********************************************************************
Decode various spoolss rpc's and info levels
********************************************************************/
@@ -629,195 +782,6 @@ WERROR rpccli_spoolss_enum_ports(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ct
/**********************************************************************
**********************************************************************/
-WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 level,
- PRINTER_INFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_GETPRINTER in;
- SPOOL_R_GETPRINTER out;
- RPC_BUFFER buffer;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- /* Initialise input parameters */
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_getprinter( mem_ctx, &in, pol, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_GETPRINTER,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_getprinter,
- spoolss_io_r_getprinter,
- WERR_GENERAL_FAILURE );
-
- if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_getprinter( mem_ctx, &in, pol, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_GETPRINTER,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_getprinter,
- spoolss_io_r_getprinter,
- WERR_GENERAL_FAILURE );
- }
-
- if ( !W_ERROR_IS_OK(out.status) )
- return out.status;
-
- switch (level) {
- case 0:
- if (!decode_printer_info_0(mem_ctx, out.buffer, 1, &ctr->printers_0)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 1:
- if (!decode_printer_info_1(mem_ctx, out.buffer, 1, &ctr->printers_1)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 2:
- if (!decode_printer_info_2(mem_ctx, out.buffer, 1, &ctr->printers_2)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 3:
- if (!decode_printer_info_3(mem_ctx, out.buffer, 1, &ctr->printers_3)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 7:
- if (!decode_printer_info_7(mem_ctx, out.buffer, 1, &ctr->printers_7)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- default:
- return WERR_UNKNOWN_LEVEL;
- }
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-WERROR rpccli_spoolss_setprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 level,
- PRINTER_INFO_CTR *ctr, uint32 command)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_SETPRINTER in;
- SPOOL_R_SETPRINTER out;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- make_spoolss_q_setprinter( mem_ctx, &in, pol, level, ctr, command );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_SETPRINTER,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_setprinter,
- spoolss_io_r_setprinter,
- WERR_GENERAL_FAILURE );
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx,
- POLICY_HND *pol, uint32 level,
- const char *env, int version, PRINTER_DRIVER_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_GETPRINTERDRIVER2 in;
- SPOOL_R_GETPRINTERDRIVER2 out;
- RPC_BUFFER buffer;
- fstring server;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- fstrcpy(server, cli->desthost);
- strupper_m(server);
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_getprinterdriver2( &in, pol, env, level,
- version, 2, &buffer, offered);
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_GETPRINTERDRIVER2,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_getprinterdriver2,
- spoolss_io_r_getprinterdriver2,
- WERR_GENERAL_FAILURE );
-
- if ( W_ERROR_EQUAL( out.status, WERR_INSUFFICIENT_BUFFER ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_getprinterdriver2( &in, pol, env, level,
- version, 2, &buffer, offered);
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_GETPRINTERDRIVER2,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_getprinterdriver2,
- spoolss_io_r_getprinterdriver2,
- WERR_GENERAL_FAILURE );
- }
-
- if ( !W_ERROR_IS_OK(out.status) )
- return out.status;
-
- switch (level) {
- case 1:
- if (!decode_printer_driver_1(mem_ctx, out.buffer, 1, &ctr->info1)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 2:
- if (!decode_printer_driver_2(mem_ctx, out.buffer, 1, &ctr->info2)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 3:
- if (!decode_printer_driver_3(mem_ctx, out.buffer, 1, &ctr->info3)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- default:
- return WERR_UNKNOWN_LEVEL;
- }
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 level, const char *env,
@@ -903,71 +867,6 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
/**********************************************************************
**********************************************************************/
-WERROR rpccli_spoolss_addprinterdriver (struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, uint32 level,
- PRINTER_DRIVER_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ADDPRINTERDRIVER in;
- SPOOL_R_ADDPRINTERDRIVER out;
- fstring server;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
- strupper_m(server);
-
- make_spoolss_q_addprinterdriver( mem_ctx, &in, server, level, ctr );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ADDPRINTERDRIVER,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_addprinterdriver,
- spoolss_io_r_addprinterdriver,
- WERR_GENERAL_FAILURE );
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
-WERROR rpccli_spoolss_addprinterex (struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- uint32 level, PRINTER_INFO_CTR*ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_ADDPRINTEREX in;
- SPOOL_R_ADDPRINTEREX out;
- fstring server, client, user;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- slprintf(client, sizeof(fstring)-1, "\\\\%s", global_myname());
- slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
-
- strupper_m(client);
- strupper_m(server);
-
- fstrcpy (user, cli->auth->user_name);
-
- make_spoolss_q_addprinterex( mem_ctx, &in, server, client,
- user, level, ctr);
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_ADDPRINTEREX,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_addprinterex,
- spoolss_io_r_addprinterex,
- WERR_GENERAL_FAILURE );
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *handle, int level, uint32 *num_forms,
FORM_1 **forms)
@@ -1406,5 +1305,4 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *me
return out.status;
}
-
/** @} **/
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 435bb1bd80..c9c897253a 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -71,78 +71,6 @@ bool make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
}
/*******************************************************************
-********************************************************************/
-
-bool spool_io_user_level_1( const char *desc, prs_struct *ps, int depth, SPOOL_USER_1 *q_u )
-{
- prs_debug(ps, depth, desc, "");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("size", ps, depth, &q_u->size))
- return False;
-
- if (!prs_io_unistr2_p("", ps, depth, &q_u->client_name))
- return False;
- if (!prs_io_unistr2_p("", ps, depth, &q_u->user_name))
- return False;
-
- if (!prs_uint32("build", ps, depth, &q_u->build))
- return False;
- if (!prs_uint32("major", ps, depth, &q_u->major))
- return False;
- if (!prs_uint32("minor", ps, depth, &q_u->minor))
- return False;
- if (!prs_uint32("processor", ps, depth, &q_u->processor))
- return False;
-
- if (!prs_io_unistr2("", ps, depth, q_u->client_name))
- return False;
- if (!prs_align(ps))
- return False;
-
- if (!prs_io_unistr2("", ps, depth, q_u->user_name))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-static bool spool_io_user_level(const char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth)
-{
- if (q_u==NULL)
- return False;
-
- prs_debug(ps, depth, desc, "spool_io_user_level");
- depth++;
-
- if (!prs_align(ps))
- return False;
-
- if (!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- switch ( q_u->level )
- {
- case 1:
- if ( !prs_pointer( "" , ps, depth, (void*)&q_u->user.user1,
- sizeof(SPOOL_USER_1), (PRS_POINTER_CAST)spool_io_user_level_1 ))
- {
- return False;
- }
- break;
- default:
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
* read or write a DEVICEMODE struct.
* on reading allocate memory for the private member
********************************************************************/
@@ -331,220 +259,6 @@ bool spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE
}
/*******************************************************************
- Read or write a DEVICEMODE container
-********************************************************************/
-
-static bool spoolss_io_devmode_cont(const char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth)
-{
- if (dm_c==NULL)
- return False;
-
- prs_debug(ps, depth, desc, "spoolss_io_devmode_cont");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if (!prs_uint32("size", ps, depth, &dm_c->size))
- return False;
-
- if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr))
- return False;
-
- if (dm_c->size==0 || dm_c->devmode_ptr==0) {
- if (UNMARSHALLING(ps))
- /* if while reading there is no DEVMODE ... */
- dm_c->devmode=NULL;
- return True;
- }
-
- /* so we have a DEVICEMODE to follow */
- if (UNMARSHALLING(ps)) {
- DEBUG(9,("Allocating memory for spoolss_io_devmode\n"));
- dm_c->devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1);
- if(dm_c->devmode == NULL)
- return False;
- }
-
- /* this is bad code, shouldn't be there */
- if (!prs_uint32("size", ps, depth, &dm_c->size))
- return False;
-
- if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- * init a structure.
- ********************************************************************/
-
-bool make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u,
- const char *srv_name, const char* clientname, const char* user_name,
- uint32 level, PRINTER_INFO_CTR *ctr)
-{
- DEBUG(5,("make_spoolss_q_addprinterex\n"));
-
- if (!ctr || !ctr->printers_2)
- return False;
-
- ZERO_STRUCTP(q_u);
-
- q_u->server_name = TALLOC_P( mem_ctx, UNISTR2 );
- if (!q_u->server_name) {
- return False;
- }
- init_unistr2(q_u->server_name, srv_name, UNI_FLAGS_NONE);
-
- q_u->level = level;
-
- q_u->info.level = level;
- q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0;
- switch (level) {
- case 2:
- /* init q_u->info.info2 from *info */
- if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) {
- DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n"));
- return False;
- }
- break;
- default :
- break;
- }
-
- q_u->user_switch=1;
-
- q_u->user_ctr.level = 1;
- q_u->user_ctr.user.user1 = TALLOC_P( talloc_tos(), SPOOL_USER_1 );
- if (!q_u->user_ctr.user.user1) {
- return False;
- }
- q_u->user_ctr.user.user1->build = 1381;
- q_u->user_ctr.user.user1->major = 2;
- q_u->user_ctr.user.user1->minor = 0;
- q_u->user_ctr.user.user1->processor = 0;
-
- q_u->user_ctr.user.user1->client_name = TALLOC_P( mem_ctx, UNISTR2 );
- if (!q_u->user_ctr.user.user1->client_name) {
- return False;
- }
- q_u->user_ctr.user.user1->user_name = TALLOC_P( mem_ctx, UNISTR2 );
- if (!q_u->user_ctr.user.user1->user_name) {
- return False;
- }
- init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE);
- init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE);
-
- q_u->user_ctr.user.user1->size = q_u->user_ctr.user.user1->user_name->uni_str_len +
- q_u->user_ctr.user.user1->client_name->uni_str_len + 2;
-
- return True;
-}
-
-/*******************************************************************
-create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct
-*******************************************************************/
-
-bool make_spoolss_printer_info_2(TALLOC_CTX *ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2,
- PRINTER_INFO_2 *info)
-{
-
- SPOOL_PRINTER_INFO_LEVEL_2 *inf;
-
- /* allocate the necessary memory */
- if (!(inf=TALLOC_P(ctx, SPOOL_PRINTER_INFO_LEVEL_2))) {
- DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n"));
- return False;
- }
-
- inf->servername_ptr = (info->servername.buffer!=NULL)?1:0;
- inf->printername_ptr = (info->printername.buffer!=NULL)?1:0;
- inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0;
- inf->portname_ptr = (info->portname.buffer!=NULL)?1:0;
- inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0;
- inf->comment_ptr = (info->comment.buffer!=NULL)?1:0;
- inf->location_ptr = (info->location.buffer!=NULL)?1:0;
- inf->devmode_ptr = (info->devmode!=NULL)?1:0;
- inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0;
- inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0;
- inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0;
- inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0;
- inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
- inf->attributes = info->attributes;
- inf->priority = info->priority;
- inf->default_priority = info->defaultpriority;
- inf->starttime = info->starttime;
- inf->untiltime = info->untiltime;
- inf->cjobs = info->cjobs;
- inf->averageppm = info->averageppm;
- init_unistr2_from_unistr(inf, &inf->servername, &info->servername);
- init_unistr2_from_unistr(inf, &inf->printername, &info->printername);
- init_unistr2_from_unistr(inf, &inf->sharename, &info->sharename);
- init_unistr2_from_unistr(inf, &inf->portname, &info->portname);
- init_unistr2_from_unistr(inf, &inf->drivername, &info->drivername);
- init_unistr2_from_unistr(inf, &inf->comment, &info->comment);
- init_unistr2_from_unistr(inf, &inf->location, &info->location);
- init_unistr2_from_unistr(inf, &inf->sepfile, &info->sepfile);
- init_unistr2_from_unistr(inf, &inf->printprocessor, &info->printprocessor);
- init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
- init_unistr2_from_unistr(inf, &inf->parameters, &info->parameters);
- init_unistr2_from_unistr(inf, &inf->datatype, &info->datatype);
-
- *spool_info2 = inf;
-
- return True;
-}
-
-/*******************************************************************
-create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct
-*******************************************************************/
-
-bool make_spoolss_printer_info_3(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3 **spool_info3,
- PRINTER_INFO_3 *info)
-{
-
- SPOOL_PRINTER_INFO_LEVEL_3 *inf;
-
- /* allocate the necessary memory */
- if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3))) {
- DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n"));
- return False;
- }
-
- inf->secdesc_ptr = (info->secdesc!=NULL)?1:0;
-
- *spool_info3 = inf;
-
- return True;
-}
-
-/*******************************************************************
-create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
-*******************************************************************/
-
-bool make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7,
- PRINTER_INFO_7 *info)
-{
-
- SPOOL_PRINTER_INFO_LEVEL_7 *inf;
-
- /* allocate the necessary memory */
- if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7))) {
- DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
- return False;
- }
-
- inf->guid_ptr = (info->guid.buffer!=NULL)?1:0;
- inf->action = info->action;
- init_unistr2_from_unistr(inf, &inf->guid, &info->guid);
-
- *spool_info7 = inf;
-
- return True;
-}
-
-/*******************************************************************
* make a structure.
********************************************************************/
@@ -2051,33 +1765,6 @@ uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info)
}
/*******************************************************************
- * init a structure.
- ********************************************************************/
-
-bool make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u,
- const POLICY_HND *hnd,
- const fstring architecture,
- uint32 level, uint32 clientmajor, uint32 clientminor,
- RPC_BUFFER *buffer, uint32 offered)
-{
- if (q_u == NULL)
- return False;
-
- memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
-
- init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture);
-
- q_u->level=level;
- q_u->clientmajorversion=clientmajor;
- q_u->clientminorversion=clientminor;
-
- q_u->buffer=buffer;
- q_u->offered=offered;
-
- return True;
-}
-
-/*******************************************************************
* read a structure.
* called from spoolss_getprinterdriver2 (srv_spoolss.c)
********************************************************************/
@@ -2318,211 +2005,6 @@ bool spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_stru
}
/*******************************************************************
- * init a structure.
- ********************************************************************/
-
-bool make_spoolss_q_getprinter(
- TALLOC_CTX *mem_ctx,
- SPOOL_Q_GETPRINTER *q_u,
- const POLICY_HND *hnd,
- uint32 level,
- RPC_BUFFER *buffer,
- uint32 offered
-)
-{
- if (q_u == NULL)
- {
- return False;
- }
- memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
-
- q_u->level=level;
- q_u->buffer=buffer;
- q_u->offered=offered;
-
- return True;
-}
-
-/*******************************************************************
- * init a structure.
- ********************************************************************/
-bool make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u,
- const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info,
- uint32 command)
-{
- SEC_DESC *secdesc;
- DEVICEMODE *devmode;
-
- if (!q_u || !info)
- return False;
-
- memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
-
- q_u->level = level;
- q_u->info.level = level;
- q_u->info.info_ptr = 1; /* Info is != NULL, see above */
- switch (level) {
-
- /* There's no such thing as a setprinter level 1 */
-
- case 2:
- secdesc = info->printers_2->secdesc;
- devmode = info->printers_2->devmode;
-
- make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2);
-#if 1 /* JERRY TEST */
- q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
- if (!q_u->secdesc_ctr)
- return False;
- q_u->secdesc_ctr->sd = secdesc;
- q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
-
- q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0;
- q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0;
- q_u->devmode_ctr.devmode = devmode;
-#else
- q_u->secdesc_ctr = NULL;
-
- q_u->devmode_ctr.devmode_ptr = 0;
- q_u->devmode_ctr.size = 0;
- q_u->devmode_ctr.devmode = NULL;
-#endif
- break;
- case 3:
- secdesc = info->printers_3->secdesc;
-
- make_spoolss_printer_info_3 (mem_ctx, &q_u->info.info_3, info->printers_3);
-
- q_u->secdesc_ctr = SMB_MALLOC_P(SEC_DESC_BUF);
- if (!q_u->secdesc_ctr)
- return False;
- q_u->secdesc_ctr->sd_size = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0;
- q_u->secdesc_ctr->sd = secdesc;
-
- break;
- case 7:
- make_spoolss_printer_info_7 (mem_ctx, &q_u->info.info_7, info->printers_7);
- break;
-
- default:
- DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
- break;
- }
-
-
- q_u->command = command;
-
- return True;
-}
-
-
-/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_r_setprinter(const char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_setprinter");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Marshall/unmarshall a SPOOL_Q_SETPRINTER struct.
-********************************************************************/
-
-bool spoolss_io_q_setprinter(const char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth)
-{
- uint32 ptr_sec_desc = 0;
-
- prs_debug(ps, depth, desc, "spoolss_io_q_setprinter");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth))
- return False;
- if(!prs_uint32("level", ps, depth, &q_u->level))
- return False;
-
- /* check for supported levels and structures we know about */
-
- switch ( q_u->level ) {
- case 0:
- case 2:
- case 3:
- case 7:
- /* supported levels */
- break;
- default:
- DEBUG(0,("spoolss_io_q_setprinter: unsupported printer info level [%d]\n",
- q_u->level));
- return True;
- }
-
-
- if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
- return False;
-
- if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- switch (q_u->level)
- {
- case 2:
- {
- ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
- break;
- }
- case 3:
- {
- /* FIXME ! Our parsing here is wrong I think,
- * but for a level3 it makes no sense for
- * ptr_sec_desc to be NULL. JRA. Based on
- * a Vista sniff from Martin Zielinski <mz@seh.de>.
- */
- if (UNMARSHALLING(ps)) {
- ptr_sec_desc = 1;
- } else {
- ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
- }
- break;
- }
- }
- if (ptr_sec_desc)
- {
- if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
- return False;
- } else {
- uint32 dummy = 0;
-
- /* Parse a NULL security descriptor. This should really
- happen inside the sec_io_desc_buf() function. */
-
- prs_debug(ps, depth, "", "sec_io_desc_buf");
- if (!prs_uint32("size", ps, depth + 1, &dummy))
- return False;
- if (!prs_uint32("ptr", ps, depth + 1, &dummy))
- return False;
- }
-
- if(!prs_uint32("command", ps, depth, &q_u->command))
- return False;
-
- return True;
-}
-
-/*******************************************************************
********************************************************************/
bool spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth)
@@ -2818,701 +2300,6 @@ bool spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct
}
/*******************************************************************
- Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure.
-********************************************************************/
-
-bool spool_io_printer_info_level_1(const char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spool_io_printer_info_level_1");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("flags", ps, depth, &il->flags))
- return False;
- if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr))
- return False;
- if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr))
- return False;
- if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
- return False;
-
- if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure.
-********************************************************************/
-
-bool spool_io_printer_info_level_3(const char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spool_io_printer_info_level_3");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure.
-********************************************************************/
-
-bool spool_io_printer_info_level_2(const char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spool_io_printer_info_level_2");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr))
- return False;
- if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr))
- return False;
- if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr))
- return False;
- if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr))
- return False;
-
- if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr))
- return False;
- if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr))
- return False;
- if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr))
- return False;
- if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr))
- return False;
- if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr))
- return False;
- if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr))
- return False;
- if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr))
- return False;
- if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr))
- return False;
- if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr))
- return False;
-
- if(!prs_uint32("attributes", ps, depth, &il->attributes))
- return False;
- if(!prs_uint32("priority", ps, depth, &il->priority))
- return False;
- if(!prs_uint32("default_priority", ps, depth, &il->default_priority))
- return False;
- if(!prs_uint32("starttime", ps, depth, &il->starttime))
- return False;
- if(!prs_uint32("untiltime", ps, depth, &il->untiltime))
- return False;
- if(!prs_uint32("status", ps, depth, &il->status))
- return False;
- if(!prs_uint32("cjobs", ps, depth, &il->cjobs))
- return False;
- if(!prs_uint32("averageppm", ps, depth, &il->averageppm))
- return False;
-
- if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth))
- return False;
-
- return True;
-}
-
-bool spool_io_printer_info_level_7(const char *desc, SPOOL_PRINTER_INFO_LEVEL_7 *il, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spool_io_printer_info_level_7");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("guid_ptr", ps, depth, &il->guid_ptr))
- return False;
- if(!prs_uint32("action", ps, depth, &il->action))
- return False;
-
- if(!smb_io_unistr2("servername", &il->guid, il->guid_ptr, ps, depth))
- return False;
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spool_io_printer_info_level(const char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spool_io_printer_info_level");
- depth++;
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("level", ps, depth, &il->level))
- return False;
- if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr))
- return False;
-
- /* if no struct inside just return */
- if (il->info_ptr==0) {
- if (UNMARSHALLING(ps)) {
- il->info_1=NULL;
- il->info_2=NULL;
- }
- return True;
- }
-
- switch (il->level) {
- /*
- * level 0 is used by setprinter when managing the queue
- * (hold, stop, start a queue)
- */
- case 0:
- break;
- /* DOCUMENT ME!!! What is level 1 used for? */
- case 1:
- {
- if (UNMARSHALLING(ps)) {
- if ((il->info_1=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_1,1)) == NULL)
- return False;
- }
- if (!spool_io_printer_info_level_1("", il->info_1, ps, depth))
- return False;
- break;
- }
- /*
- * level 2 is used by addprinter
- * and by setprinter when updating printer's info
- */
- case 2:
- if (UNMARSHALLING(ps)) {
- if ((il->info_2=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_2,1)) == NULL)
- return False;
- }
- if (!spool_io_printer_info_level_2("", il->info_2, ps, depth))
- return False;
- break;
- /* DOCUMENT ME!!! What is level 3 used for? */
- case 3:
- {
- if (UNMARSHALLING(ps)) {
- if ((il->info_3=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_3,1)) == NULL)
- return False;
- }
- if (!spool_io_printer_info_level_3("", il->info_3, ps, depth))
- return False;
- break;
- }
- case 7:
- if (UNMARSHALLING(ps))
- if ((il->info_7=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_INFO_LEVEL_7,1)) == NULL)
- return False;
- if (!spool_io_printer_info_level_7("", il->info_7, ps, depth))
- return False;
- break;
- }
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_q_addprinterex(const char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth)
-{
- uint32 ptr_sec_desc = 0;
-
- prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->server_name))
- return False;
- if (!prs_io_unistr2("servername", ps, depth, q_u->server_name))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("info_level", ps, depth, &q_u->level))
- return False;
-
- if(!spool_io_printer_info_level("", &q_u->info, ps, depth))
- return False;
-
- if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- switch (q_u->level) {
- case 2:
- ptr_sec_desc = q_u->info.info_2->secdesc_ptr;
- break;
- case 3:
- ptr_sec_desc = q_u->info.info_3->secdesc_ptr;
- break;
- }
- if (ptr_sec_desc) {
- if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth))
- return False;
- } else {
- uint32 dummy = 0;
-
- /* Parse a NULL security descriptor. This should really
- happen inside the sec_io_desc_buf() function. */
-
- prs_debug(ps, depth, "", "sec_io_desc_buf");
- if (!prs_uint32("size", ps, depth + 1, &dummy))
- return False;
- if (!prs_uint32("ptr", ps, depth + 1, &dummy))
- return False;
- }
-
- if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch))
- return False;
- if(!spool_io_user_level("", &q_u->user_ctr, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_r_addprinterex(const char *desc, SPOOL_R_ADDPRINTEREX *r_u,
- prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex");
- depth++;
-
- if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth))
- return False;
-
- if(!prs_werror("status", ps, depth, &r_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spool_io_printer_driver_info_level_3(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u,
- prs_struct *ps, int depth)
-{
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il;
-
- prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3");
- depth++;
-
- /* reading */
- if (UNMARSHALLING(ps)) {
- il=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_DRIVER_INFO_LEVEL_3,1);
- if(il == NULL)
- return False;
- *q_u=il;
- }
- else {
- il=*q_u;
- }
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("cversion", ps, depth, &il->cversion))
- return False;
- if(!prs_uint32("name", ps, depth, &il->name_ptr))
- return False;
- if(!prs_uint32("environment", ps, depth, &il->environment_ptr))
- return False;
- if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr))
- return False;
- if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr))
- return False;
- if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr))
- return False;
- if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr))
- return False;
- if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr))
- return False;
- if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
- return False;
- if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize))
- return False;
- if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
- return False;
- if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
-
- if (il->dependentfiles_ptr)
- smb_io_buffer5("", &il->dependentfiles, ps, depth);
-
- return True;
-}
-
-/*******************************************************************
-parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure
-********************************************************************/
-
-bool spool_io_printer_driver_info_level_6(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u,
- prs_struct *ps, int depth)
-{
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il;
-
- prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6");
- depth++;
-
- /* reading */
- if (UNMARSHALLING(ps)) {
- il=PRS_ALLOC_MEM(ps,SPOOL_PRINTER_DRIVER_INFO_LEVEL_6,1);
- if(il == NULL)
- return False;
- *q_u=il;
- }
- else {
- il=*q_u;
- }
-
- if(!prs_align(ps))
- return False;
-
- /*
- * I know this seems weird, but I have no other explanation.
- * This is observed behavior on both NT4 and 2K servers.
- * --jerry
- */
-
- if (!prs_align_uint64(ps))
- return False;
-
- /* parse the main elements the packet */
-
- if(!prs_uint32("cversion ", ps, depth, &il->version))
- return False;
- if(!prs_uint32("name ", ps, depth, &il->name_ptr))
- return False;
- if(!prs_uint32("environment ", ps, depth, &il->environment_ptr))
- return False;
- if(!prs_uint32("driverpath ", ps, depth, &il->driverpath_ptr))
- return False;
- if(!prs_uint32("datafile ", ps, depth, &il->datafile_ptr))
- return False;
- if(!prs_uint32("configfile ", ps, depth, &il->configfile_ptr))
- return False;
- if(!prs_uint32("helpfile ", ps, depth, &il->helpfile_ptr))
- return False;
- if(!prs_uint32("monitorname ", ps, depth, &il->monitorname_ptr))
- return False;
- if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr))
- return False;
- if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_len))
- return False;
- if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_ptr))
- return False;
- if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_len))
- return False;
- if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_ptr))
- return False;
- if(!smb_io_time("driverdate ", &il->driverdate, ps, depth))
- return False;
- if(!prs_uint32("dummy4 ", ps, depth, &il->dummy4))
- return False;
- if(!prs_uint64("driverversion ", ps, depth, &il->driverversion))
- return False;
- if(!prs_uint32("mfgname ", ps, depth, &il->mfgname_ptr))
- return False;
- if(!prs_uint32("oemurl ", ps, depth, &il->oemurl_ptr))
- return False;
- if(!prs_uint32("hardwareid ", ps, depth, &il->hardwareid_ptr))
- return False;
- if(!prs_uint32("provider ", ps, depth, &il->provider_ptr))
- return False;
-
- /* parse the structures in the packet */
-
- if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
-
- if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- if (il->dependentfiles_ptr) {
- if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- }
- if (il->previousnames_ptr) {
- if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- }
- if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth))
- return False;
- if(!prs_align(ps))
- return False;
- if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- read a UNICODE array with null terminated strings
- and null terminated array
- and size of array at beginning
-********************************************************************/
-
-bool smb_io_unibuffer(const char *desc, UNISTR2 *buffer, prs_struct *ps, int depth)
-{
- if (buffer==NULL) return False;
-
- buffer->offset=0;
- buffer->uni_str_len=buffer->uni_max_len;
-
- if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
- return False;
-
- if(!prs_unistr2(True, "buffer ", ps, depth, buffer))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level");
- depth++;
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("level", ps, depth, &il->level))
- return False;
- if(!prs_uint32("ptr", ps, depth, &il->ptr))
- return False;
-
- if (il->ptr==0)
- return True;
-
- switch (il->level) {
- case 3:
- if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth))
- return False;
- break;
- case 6:
- if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth))
- return False;
- break;
- default:
- return False;
- }
-
- return True;
-}
-
-/*******************************************************************
- init a SPOOL_Q_ADDPRINTERDRIVER struct
- ******************************************************************/
-
-bool make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
- SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name,
- uint32 level, PRINTER_DRIVER_CTR *info)
-{
- DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
-
- if (!srv_name || !info) {
- return False;
- }
-
- q_u->server_name_ptr = 1; /* srv_name is != NULL, see above */
- init_unistr2(&q_u->server_name, srv_name, UNI_STR_TERMINATE);
-
- q_u->level = level;
-
- q_u->info.level = level;
- q_u->info.ptr = 1; /* Info is != NULL, see above */
- switch (level)
- {
- /* info level 3 is supported by Windows 95/98, WinNT and Win2k */
- case 3 :
- make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3);
- break;
-
- default:
- DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level));
- break;
- }
-
- return True;
-}
-
-bool make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx,
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info,
- DRIVER_INFO_3 *info3)
-{
- uint32 len = 0;
- SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf;
-
- if (!(inf=TALLOC_ZERO_P(mem_ctx, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)))
- return False;
-
- inf->cversion = info3->version;
- inf->name_ptr = (info3->name.buffer!=NULL)?1:0;
- inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0;
- inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0;
- inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0;
- inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0;
- inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0;
- inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0;
- inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0;
-
- init_unistr2_from_unistr(inf, &inf->name, &info3->name);
- init_unistr2_from_unistr(inf, &inf->environment, &info3->architecture);
- init_unistr2_from_unistr(inf, &inf->driverpath, &info3->driverpath);
- init_unistr2_from_unistr(inf, &inf->datafile, &info3->datafile);
- init_unistr2_from_unistr(inf, &inf->configfile, &info3->configfile);
- init_unistr2_from_unistr(inf, &inf->helpfile, &info3->helpfile);
- init_unistr2_from_unistr(inf, &inf->monitorname, &info3->monitorname);
- init_unistr2_from_unistr(inf, &inf->defaultdatatype, &info3->defaultdatatype);
-
- if (info3->dependentfiles) {
- bool done = False;
- bool null_char = False;
- uint16 *ptr = info3->dependentfiles;
-
- while (!done) {
- switch (*ptr) {
- case 0:
- /* the null_char bool is used to help locate
- two '\0's back to back */
- if (null_char) {
- done = True;
- } else {
- null_char = True;
- }
- break;
-
- default:
- null_char = False;
- break;
- }
- len++;
- ptr++;
- }
- }
-
- inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0;
- inf->dependentfilessize = (info3->dependentfiles != NULL) ? len : 0;
- if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles)) {
- SAFE_FREE(inf);
- return False;
- }
-
- *spool_drv_info = inf;
-
- return True;
-}
-
-/*******************************************************************
make a BUFFER5 struct from a uint16*
******************************************************************/
@@ -3537,79 +2324,6 @@ bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16
}
/*******************************************************************
- fill in the prs_struct for a ADDPRINTERDRIVER request PDU
- ********************************************************************/
-
-bool spoolss_io_q_addprinterdriver(const char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr))
- return False;
- if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth))
- return False;
-
- if(!prs_align(ps))
- return False;
- if(!prs_uint32("info_level", ps, depth, &q_u->level))
- return False;
-
- if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-********************************************************************/
-
-bool spoolss_io_r_addprinterdriver(const char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth)
-{
- prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver");
- depth++;
-
- if(!prs_werror("status", ps, depth, &q_u->status))
- return False;
-
- return True;
-}
-
-/*******************************************************************
- ********************************************************************/
-
-bool uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni,
- NT_PRINTER_INFO_LEVEL_2 *d)
-{
- DEBUG(7,("Converting from UNICODE to ASCII\n"));
-
- d->attributes=uni->attributes;
- d->priority=uni->priority;
- d->default_priority=uni->default_priority;
- d->starttime=uni->starttime;
- d->untiltime=uni->untiltime;
- d->status=uni->status;
- d->cjobs=uni->cjobs;
-
- unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername));
- unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername));
- unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename));
- unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname));
- unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername));
- unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment));
- unistr2_to_ascii(d->location, &uni->location, sizeof(d->location));
- unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile));
- unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor));
- unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype));
- unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters));
-
- return True;
-}
-
-/*******************************************************************
********************************************************************/
bool spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth)
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 6dead2d264..33e89c8acb 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -1171,13 +1171,12 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
struct np_write_state {
struct event_context *ev;
struct np_proxy_state *p;
- const uint8_t *data;
- size_t len;
+ struct iovec iov;
ssize_t nwritten;
};
static void np_write_trigger(struct async_req *req);
-static void np_write_done(struct async_req *subreq);
+static void np_write_done(struct tevent_req *subreq);
struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct fake_file_handle *handle,
@@ -1218,8 +1217,8 @@ struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
state->ev = ev;
state->p = p;
- state->data = data;
- state->len = len;
+ state->iov.iov_base = CONST_DISCARD(void *, data);
+ state->iov.iov_len = len;
if (!async_req_enqueue(p->write_queue, ev, result,
np_write_trigger)) {
@@ -1242,27 +1241,26 @@ static void np_write_trigger(struct async_req *req)
{
struct np_write_state *state = talloc_get_type_abort(
req->private_data, struct np_write_state);
- struct async_req *subreq;
+ struct tevent_req *subreq;
- subreq = sendall_send(state, state->ev, state->p->fd, state->data,
- state->len, 0);
+ subreq = writev_send(state, state->ev, state->p->fd, &state->iov, 1);
if (async_req_nomem(subreq, req)) {
return;
}
subreq->async.fn = np_write_done;
- subreq->async.priv = req;
+ subreq->async.private_data = req;
}
-static void np_write_done(struct async_req *subreq)
+static void np_write_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ subreq->async.private_data, struct async_req);
struct np_write_state *state = talloc_get_type_abort(
req->private_data, struct np_write_state);
ssize_t received;
int err;
- received = sendall_recv(subreq, &err);
+ received = writev_recv(subreq, &err);
if (received < 0) {
async_req_nterror(req, map_nt_error_from_unix(err));
return;
@@ -1316,7 +1314,7 @@ struct np_read_state {
};
static void np_read_trigger(struct async_req *req);
-static void np_read_done(struct async_req *subreq);
+static void np_read_done(struct tevent_req *subreq);
struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct fake_file_handle *handle,
@@ -1393,28 +1391,28 @@ static void np_read_trigger(struct async_req *req)
{
struct np_read_state *state = talloc_get_type_abort(
req->private_data, struct np_read_state);
- struct async_req *subreq;
+ struct tevent_req *subreq;
- subreq = read_pkt_send(state, state->ev, state->p->fd, RPC_HEADER_LEN,
- rpc_frag_more_fn, NULL);
+ subreq = read_packet_send(state, state->ev, state->p->fd,
+ RPC_HEADER_LEN, rpc_frag_more_fn, NULL);
if (async_req_nomem(subreq, req)) {
return;
}
subreq->async.fn = np_read_done;
- subreq->async.priv = req;
+ subreq->async.private_data = req;
}
-static void np_read_done(struct async_req *subreq)
+static void np_read_done(struct tevent_req *subreq)
{
struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ subreq->async.private_data, struct async_req);
struct np_read_state *state = talloc_get_type_abort(
req->private_data, struct np_read_state);
ssize_t received;
size_t thistime;
int err;
- received = read_pkt_recv(subreq, state->p, &state->p->msg, &err);
+ received = read_packet_recv(subreq, state->p, &state->p->msg, &err);
TALLOC_FREE(subreq);
if (received == -1) {
async_req_nterror(req, map_nt_error_from_unix(err));
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index a4679eb717..62301c001b 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -8059,45 +8059,106 @@ WERROR _spoolss_AddPrinterDriverEx(pipes_struct *p,
/****************************************************************************
****************************************************************************/
-static WERROR getprinterdriverdir_level_1(TALLOC_CTX *mem_ctx,
+struct _spoolss_paths {
+ int type;
+ const char *share;
+ const char *dir;
+};
+
+enum { SPOOLSS_DRIVER_PATH, SPOOLSS_PRTPROCS_PATH };
+
+static const struct _spoolss_paths spoolss_paths[]= {
+ { SPOOLSS_DRIVER_PATH, "print$", "DRIVERS" },
+ { SPOOLSS_PRTPROCS_PATH, "prnproc$", "PRTPROCS" }
+};
+
+static WERROR compose_spoolss_server_path(TALLOC_CTX *mem_ctx,
const char *servername,
const char *environment,
- struct spoolss_DriverDirectoryInfo1 *info1,
- uint32_t offered,
- uint32_t *needed)
+ int component,
+ char **path)
{
- char *path = NULL;
const char *pservername = NULL;
const char *long_archi = SPOOLSS_ARCHITECTURE_NT_X86;
const char *short_archi;
- if (environment) {
+ *path = NULL;
+
+ /* environment may be empty */
+ if (environment && strlen(environment)) {
long_archi = environment;
}
- pservername = canon_servername(servername);
+ /* servername may be empty */
+ if (servername && strlen(servername)) {
+ pservername = canon_servername(servername);
- if ( !is_myname_or_ipaddr(pservername))
- return WERR_INVALID_PARAM;
+ if (!is_myname_or_ipaddr(pservername)) {
+ return WERR_INVALID_PARAM;
+ }
+ }
- if (!(short_archi = get_short_archi(long_archi)))
+ if (!(short_archi = get_short_archi(long_archi))) {
return WERR_INVALID_ENVIRONMENT;
+ }
- path = talloc_asprintf(mem_ctx,
- "\\\\%s\\print$\\%s", pservername, short_archi);
- if (!path) {
+ switch (component) {
+ case SPOOLSS_PRTPROCS_PATH:
+ case SPOOLSS_DRIVER_PATH:
+ if (pservername) {
+ *path = talloc_asprintf(mem_ctx,
+ "\\\\%s\\%s\\%s",
+ pservername,
+ spoolss_paths[component].share,
+ short_archi);
+ } else {
+ *path = talloc_asprintf(mem_ctx, "%s\\%s\\%s",
+ SPOOLSS_DEFAULT_SERVER_PATH,
+ spoolss_paths[component].dir,
+ short_archi);
+ }
+ break;
+ default:
+ return WERR_INVALID_PARAM;
+ }
+
+ if (!*path) {
return WERR_NOMEM;
}
+ return WERR_OK;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static WERROR getprinterdriverdir_level_1(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *environment,
+ struct spoolss_DriverDirectoryInfo1 *r,
+ uint32_t offered,
+ uint32_t *needed)
+{
+ WERROR werr;
+ char *path = NULL;
+
+ werr = compose_spoolss_server_path(mem_ctx,
+ servername,
+ environment,
+ SPOOLSS_DRIVER_PATH,
+ &path);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
+ }
+
DEBUG(4,("printer driver directory: [%s]\n", path));
- info1->directory_name = path;
+ r->directory_name = path;
- *needed += ndr_size_spoolss_DriverDirectoryInfo1(info1, NULL, 0);
+ *needed += ndr_size_spoolss_DriverDirectoryInfo1(r, NULL, 0);
if (*needed > offered) {
talloc_free(path);
- ZERO_STRUCTP(info1);
return WERR_INSUFFICIENT_BUFFER;
}
@@ -9728,36 +9789,30 @@ done:
static WERROR getprintprocessordirectory_level_1(TALLOC_CTX *mem_ctx,
const char *servername,
const char *environment,
- struct spoolss_PrintProcessorDirectoryInfo1 *info1,
+ struct spoolss_PrintProcessorDirectoryInfo1 *r,
uint32_t offered,
uint32_t *needed)
{
- const char *long_archi = SPOOLSS_ARCHITECTURE_NT_X86;
- const char *short_archi;
-
- if (environment) {
- long_archi = environment;
- }
+ WERROR werr;
+ char *path = NULL;
- short_archi = get_short_archi(long_archi);
- if (!short_archi) {
- return WERR_INVALID_ENVIRONMENT;
+ werr = compose_spoolss_server_path(mem_ctx,
+ servername,
+ environment,
+ SPOOLSS_PRTPROCS_PATH,
+ &path);
+ if (!W_ERROR_IS_OK(werr)) {
+ return werr;
}
- /* I think this should look like this - gd
- info1->directory_name = talloc_asprintf(mem_ctx,
- "C:\\WINNT\\System32\\spool\\PRTPROCS\\%s", short_archi);
- */
- info1->directory_name = talloc_strdup(mem_ctx,
- "C:\\WINNT\\System32\\spool\\PRTPROCS\\W32X86");
+ DEBUG(4,("print processor directory: [%s]\n", path));
- if (!info1->directory_name) {
- return WERR_NOMEM;
- }
+ r->directory_name = path;
- *needed += ndr_size_spoolss_PrintProcessorDirectoryInfo1(info1, NULL, 0);
+ *needed += ndr_size_spoolss_PrintProcessorDirectoryInfo1(r, NULL, 0);
if (*needed > offered) {
+ talloc_free(path);
return WERR_INSUFFICIENT_BUFFER;
}
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index bb9d0e6d6c..fe2554e02d 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -283,12 +283,10 @@ static void display_print_info_3(PRINTER_INFO_3 *i3)
/****************************************************************************
****************************************************************************/
-static void display_print_info_7(PRINTER_INFO_7 *i7)
+static void display_print_info7(struct spoolss_PrinterInfo7 *r)
{
- fstring guid = "";
- rpcstr_pull(guid, i7->guid.buffer,sizeof(guid), -1, STR_TERMINATE);
- printf("\tguid:[%s]\n", guid);
- printf("\taction:[0x%x]\n", i7->action);
+ printf("\tguid:[%s]\n", r->guid);
+ printf("\taction:[0x%x]\n", r->action);
}
@@ -469,10 +467,13 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
WERROR result;
+ NTSTATUS status;
uint32 info_level = 2;
- bool opened_hnd = False;
- PRINTER_INFO_CTR ctr;
+ union spoolss_PrinterInfo info;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
const char *printername, *comment = NULL;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
if (argc == 1 || argc > 3) {
printf("Usage: %s printername comment\n", argv[0]);
@@ -485,6 +486,9 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
comment = argv[2];
}
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
+
RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
/* get a printer handle */
@@ -495,26 +499,34 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
/* Get printer info */
- result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr);
-
+ result = rpccli_spoolss_getprinter(cli, mem_ctx,
+ &pol,
+ info_level,
+ 0,
+ &info);
if (!W_ERROR_IS_OK(result))
goto done;
/* Modify the comment. */
- init_unistr(&ctr.printers_2->comment, comment);
- ctr.printers_2->devmode = NULL;
- ctr.printers_2->secdesc = NULL;
+ info.info2.comment = comment;
- result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0);
+ info_ctr.level = 2;
+ info_ctr.info.info2 = (struct spoolss_SetPrinterInfo2 *)&info.info2;
+
+ status = rpccli_spoolss_SetPrinter(cli, mem_ctx,
+ &pol,
+ &info_ctr,
+ &devmode_ctr,
+ &secdesc_ctr,
+ 0, /* command */
+ &result);
if (W_ERROR_IS_OK(result))
printf("Success in setting comment.\n");
done:
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -529,11 +541,17 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
WERROR result;
+ NTSTATUS status;
uint32 info_level = 2;
- bool opened_hnd = False;
- PRINTER_INFO_CTR ctr;
+ union spoolss_PrinterInfo info;
const char *printername,
*new_printername = NULL;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
+
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
if (argc == 1 || argc > 3) {
printf("Usage: %s printername new_printername\n", argv[0]);
@@ -556,25 +574,35 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
/* Get printer info */
- result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr);
-
+ result = rpccli_spoolss_getprinter(cli, mem_ctx,
+ &pol,
+ info_level,
+ 0,
+ &info);
if (!W_ERROR_IS_OK(result))
goto done;
/* Modify the printername. */
- init_unistr(&ctr.printers_2->printername, new_printername);
- ctr.printers_2->devmode = NULL;
- ctr.printers_2->secdesc = NULL;
-
- result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0);
+ info.info2.printername = new_printername;
+ info.info2.devmode = NULL;
+ info.info2.secdesc = NULL;
+
+ info_ctr.level = info_level;
+ info_ctr.info.info2 = (struct spoolss_SetPrinterInfo2 *)&info.info2;
+
+ status = rpccli_spoolss_SetPrinter(cli, mem_ctx,
+ &pol,
+ &info_ctr,
+ &devmode_ctr,
+ &secdesc_ctr,
+ 0, /* command */
+ &result);
if (W_ERROR_IS_OK(result))
printf("Success in setting printername.\n");
done:
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -590,9 +618,8 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
POLICY_HND pol;
WERROR result;
uint32 info_level = 1;
- bool opened_hnd = False;
- PRINTER_INFO_CTR ctr;
const char *printername;
+ union spoolss_PrinterInfo info;
if (argc == 1 || argc > 3) {
printf("Usage: %s <printername> [level]\n", argv[0]);
@@ -615,18 +642,19 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
/* Get printer info */
- result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, info_level, &ctr);
-
+ result = rpccli_spoolss_getprinter(cli, mem_ctx,
+ &pol,
+ info_level,
+ 0,
+ &info);
if (!W_ERROR_IS_OK(result))
goto done;
/* Display printer info */
-
switch (info_level) {
+#if 0 /* FIXME GD */
case 0:
display_print_info_0(ctr.printers_0);
break;
@@ -639,16 +667,16 @@ static WERROR cmd_spoolss_getprinter(struct rpc_pipe_client *cli,
case 3:
display_print_info_3(ctr.printers_3);
break;
+#endif
case 7:
- display_print_info_7(ctr.printers_7);
+ display_print_info7(&info.info7);
break;
default:
printf("unknown info level %d\n", info_level);
break;
}
-
done:
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -724,7 +752,6 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
WERROR result;
- bool opened_hnd = False;
fstring printername;
const char *valuename;
REGISTRY_VALUE value;
@@ -753,8 +780,6 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
/* Get printer info */
result = rpccli_spoolss_getprinterdata(cli, mem_ctx, &pol, valuename, &value);
@@ -769,7 +794,7 @@ static WERROR cmd_spoolss_getprinterdata(struct rpc_pipe_client *cli,
done:
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -785,7 +810,6 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
POLICY_HND pol;
WERROR result;
NTSTATUS status;
- bool opened_hnd = False;
fstring printername;
const char *valuename, *keyname;
REGISTRY_VALUE value;
@@ -821,8 +845,6 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
/* Get printer info */
status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx,
@@ -870,7 +892,7 @@ static WERROR cmd_spoolss_getprinterdataex(struct rpc_pipe_client *cli,
display_reg_value(value);
done:
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -989,6 +1011,68 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1)
/****************************************************************************
****************************************************************************/
+static void display_print_driver1(struct spoolss_DriverInfo1 *r)
+{
+ if (!r) {
+ return;
+ }
+
+ printf("Printer Driver Info 1:\n");
+ printf("\tDriver Name: [%s]\n\n", r->driver_name);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static void display_print_driver2(struct spoolss_DriverInfo2 *r)
+{
+ if (!r) {
+ return;
+ }
+
+ printf("Printer Driver Info 2:\n");
+ printf("\tVersion: [%x]\n", r->version);
+ printf("\tDriver Name: [%s]\n", r->driver_name);
+ printf("\tArchitecture: [%s]\n", r->architecture);
+ printf("\tDriver Path: [%s]\n", r->driver_path);
+ printf("\tDatafile: [%s]\n", r->data_file);
+ printf("\tConfigfile: [%s]\n\n", r->config_file);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static void display_print_driver3(struct spoolss_DriverInfo3 *r)
+{
+ int i;
+
+ if (!r) {
+ return;
+ }
+
+ printf("Printer Driver Info 3:\n");
+ printf("\tVersion: [%x]\n", r->version);
+ printf("\tDriver Name: [%s]\n", r->driver_name);
+ printf("\tArchitecture: [%s]\n", r->architecture);
+ printf("\tDriver Path: [%s]\n", r->driver_path);
+ printf("\tDatafile: [%s]\n", r->data_file);
+ printf("\tConfigfile: [%s]\n\n", r->config_file);
+ printf("\tHelpfile: [%s]\n\n", r->help_file);
+
+ for (i=0; r->dependent_files[i] != NULL; i++) {
+ printf("\tDependentfiles: [%s]\n", r->dependent_files[i]);
+ }
+
+ printf("\n");
+
+ printf("\tMonitorname: [%s]\n", r->monitor_name);
+ printf("\tDefaultdatatype: [%s]\n\n", r->default_datatype);
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
int argc, const char **argv)
@@ -996,11 +1080,12 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
POLICY_HND pol;
WERROR werror;
uint32 info_level = 3;
- bool opened_hnd = False;
- PRINTER_DRIVER_CTR ctr;
const char *printername;
uint32 i;
bool success = False;
+ union spoolss_DriverInfo info;
+ uint32_t server_major_version;
+ uint32_t server_minor_version;
if ((argc == 1) || (argc > 3))
{
@@ -1026,16 +1111,20 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
return werror;
}
- opened_hnd = True;
-
/* loop through and print driver info level for each architecture */
for (i=0; archi_table[i].long_archi!=NULL; i++) {
- werror = rpccli_spoolss_getprinterdriver( cli, mem_ctx, &pol, info_level,
- archi_table[i].long_archi, archi_table[i].version,
- &ctr);
-
+ werror = rpccli_spoolss_getprinterdriver2(cli, mem_ctx,
+ &pol,
+ archi_table[i].long_archi,
+ info_level,
+ 0, /* offered */
+ archi_table[i].version,
+ 2,
+ &info,
+ &server_major_version,
+ &server_minor_version);
if (!W_ERROR_IS_OK(werror))
continue;
@@ -1047,13 +1136,13 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
switch (info_level) {
case 1:
- display_print_driver_1 (ctr.info1);
+ display_print_driver1(&info.info1);
break;
case 2:
- display_print_driver_2 (ctr.info2);
+ display_print_driver2(&info.info2);
break;
case 3:
- display_print_driver_3 (ctr.info3);
+ display_print_driver3(&info.info3);
break;
default:
printf("unknown info level %d\n", info_level);
@@ -1063,7 +1152,7 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
/* Cleanup */
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
if ( success )
@@ -1219,7 +1308,9 @@ static WERROR cmd_spoolss_getdriverdir(struct rpc_pipe_client *cli,
/****************************************************************************
****************************************************************************/
-void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch)
+static void set_drv_info_3_env(TALLOC_CTX *mem_ctx,
+ struct spoolss_AddDriverInfo3 *info,
+ const char *arch)
{
int i;
@@ -1229,7 +1320,7 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch)
if (strcmp(arch, archi_table[i].short_archi) == 0)
{
info->version = archi_table[i].version;
- init_unistr (&info->architecture, archi_table[i].long_archi);
+ info->architecture = talloc_strdup(mem_ctx, archi_table[i].long_archi);
break;
}
}
@@ -1248,8 +1339,9 @@ void set_drv_info_3_env (DRIVER_INFO_3 *info, const char *arch)
Needed to handle the empty parameter string denoted by "NULL"
*************************************************************************/
-static char* get_driver_3_param (char* str, const char* delim, UNISTR* dest,
- char **saveptr)
+static char *get_driver_3_param(TALLOC_CTX *mem_ctx, char *str,
+ const char *delim, const char **dest,
+ char **saveptr)
{
char *ptr;
@@ -1260,70 +1352,80 @@ static char* get_driver_3_param (char* str, const char* delim, UNISTR* dest,
parameter because two consecutive delimiters
will not return an empty string. See man strtok(3)
for details */
- if (ptr && (StrCaseCmp(ptr, "NULL") == 0))
+ if (ptr && (StrCaseCmp(ptr, "NULL") == 0)) {
ptr = NULL;
+ }
- if (dest != NULL)
- init_unistr(dest, ptr);
+ if (dest != NULL) {
+ *dest = talloc_strdup(mem_ctx, ptr);
+ }
return ptr;
}
/********************************************************************************
- fill in the members of a DRIVER_INFO_3 struct using a character
+ fill in the members of a spoolss_AddDriverInfo3 struct using a character
string in the form of
<Long Printer Name>:<Driver File Name>:<Data File Name>:\
<Config File Name>:<Help File Name>:<Language Monitor Name>:\
<Default Data Type>:<Comma Separated list of Files>
*******************************************************************************/
-static bool init_drv_info_3_members ( TALLOC_CTX *mem_ctx, DRIVER_INFO_3 *info,
- char *args )
+
+static bool init_drv_info_3_members(TALLOC_CTX *mem_ctx, struct spoolss_AddDriverInfo3 *r,
+ char *args)
{
char *str, *str2;
- uint32 len, i;
+ int count = 0;
char *saveptr = NULL;
+ struct spoolss_StringArray *deps;
+ const char **file_array = NULL;
+ int i;
/* fill in the UNISTR fields */
- str = get_driver_3_param (args, ":", &info->name, &saveptr);
- str = get_driver_3_param (NULL, ":", &info->driverpath, &saveptr);
- str = get_driver_3_param (NULL, ":", &info->datafile, &saveptr);
- str = get_driver_3_param (NULL, ":", &info->configfile, &saveptr);
- str = get_driver_3_param (NULL, ":", &info->helpfile, &saveptr);
- str = get_driver_3_param (NULL, ":", &info->monitorname, &saveptr);
- str = get_driver_3_param (NULL, ":", &info->defaultdatatype, &saveptr);
+ str = get_driver_3_param(mem_ctx, args, ":", &r->driver_name, &saveptr);
+ str = get_driver_3_param(mem_ctx, NULL, ":", &r->driver_path, &saveptr);
+ str = get_driver_3_param(mem_ctx, NULL, ":", &r->data_file, &saveptr);
+ str = get_driver_3_param(mem_ctx, NULL, ":", &r->config_file, &saveptr);
+ str = get_driver_3_param(mem_ctx, NULL, ":", &r->help_file, &saveptr);
+ str = get_driver_3_param(mem_ctx, NULL, ":", &r->monitor_name, &saveptr);
+ str = get_driver_3_param(mem_ctx, NULL, ":", &r->default_datatype, &saveptr);
/* <Comma Separated List of Dependent Files> */
/* save the beginning of the string */
- str2 = get_driver_3_param (NULL, ":", NULL, &saveptr);
+ str2 = get_driver_3_param(mem_ctx, NULL, ":", NULL, &saveptr);
str = str2;
/* begin to strip out each filename */
str = strtok_r(str, ",", &saveptr);
- len = 0;
- while (str != NULL)
- {
- /* keep a cumlative count of the str lengths */
- len += strlen(str)+1;
+
+ /* no dependent files, we are done */
+ if (!str) {
+ return true;
+ }
+
+ deps = talloc_zero(mem_ctx, struct spoolss_StringArray);
+ if (!deps) {
+ return false;
+ }
+
+ while (str != NULL) {
+ add_string_to_array(deps, str, &file_array, &count);
str = strtok_r(NULL, ",", &saveptr);
}
- /* allocate the space; add one extra slot for a terminating NULL.
- Each filename is NULL terminated and the end contains a double
- NULL */
- if ((info->dependentfiles=TALLOC_ARRAY(mem_ctx, uint16, len+1)) == NULL)
- {
- DEBUG(0,("init_drv_info_3_members: Unable to malloc memory for dependenfiles\n"));
- return False;
+ deps->string = talloc_zero_array(deps, const char *, count + 1);
+ if (!deps->string) {
+ return false;
}
- for (i=0; i<len; i++)
- {
- SSVAL(&info->dependentfiles[i], 0, str2[i]);
+
+ for (i=0; i < count; i++) {
+ deps->string[i] = file_array[i];
}
- info->dependentfiles[len] = '\0';
- return True;
-}
+ r->dependent_files = deps;
+ return true;
+}
/****************************************************************************
****************************************************************************/
@@ -1333,11 +1435,11 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
WERROR result;
+ NTSTATUS status;
uint32 level = 3;
- PRINTER_DRIVER_CTR ctr;
- DRIVER_INFO_3 info3;
+ struct spoolss_AddDriverInfoCtr info_ctr;
+ struct spoolss_AddDriverInfo3 info3;
const char *arch;
- fstring driver_name;
char *driver_args;
/* parse the command arguments */
@@ -1352,15 +1454,16 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli,
return WERR_OK;
}
- /* Fill in the DRIVER_INFO_3 struct */
+ /* Fill in the spoolss_AddDriverInfo3 struct */
ZERO_STRUCT(info3);
- if (!(arch = cmd_spoolss_get_short_archi(argv[1])))
- {
+
+ arch = cmd_spoolss_get_short_archi(argv[1]);
+ if (!arch) {
printf ("Error Unknown architechture [%s]\n", argv[1]);
return WERR_INVALID_PARAM;
}
- else
- set_drv_info_3_env(&info3, arch);
+
+ set_drv_info_3_env(mem_ctx, &info3, arch);
driver_args = talloc_strdup( mem_ctx, argv[2] );
if (!init_drv_info_3_members(mem_ctx, &info3, driver_args ))
@@ -1378,14 +1481,19 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli,
}
- ctr.info3 = &info3;
- result = rpccli_spoolss_addprinterdriver (cli, mem_ctx, level, &ctr);
+ info_ctr.level = level;
+ info_ctr.info.info3 = &info3;
+ status = rpccli_spoolss_AddPrinterDriver(cli, mem_ctx,
+ cli->srv_name_slash,
+ &info_ctr,
+ &result);
+ if (!NT_STATUS_IS_OK(status)) {
+ return ntstatus_to_werror(status);
+ }
if (W_ERROR_IS_OK(result)) {
- rpcstr_pull(driver_name, info3.name.buffer,
- sizeof(driver_name), -1, STR_TERMINATE);
printf ("Printer Driver %s successfully installed.\n",
- driver_name);
+ info3.driver_name);
}
return result;
@@ -1400,14 +1508,8 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
int argc, const char **argv)
{
WERROR result;
- NTSTATUS status;
struct spoolss_SetPrinterInfoCtr info_ctr;
struct spoolss_SetPrinterInfo2 info2;
- struct policy_handle handle;
- struct spoolss_DevmodeContainer devmode_ctr;
- struct sec_desc_buf sd;
- struct spoolss_UserLevelCtr userlevel_ctr;
- struct spoolss_UserLevel1 level1;
/* parse the command arguments */
if (argc != 5)
@@ -1417,9 +1519,7 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
}
/* Fill in the DRIVER_INFO_2 struct */
- ZERO_STRUCT(devmode_ctr);
ZERO_STRUCT(info2);
- ZERO_STRUCT(sd);
info2.printername = argv[1];
info2.drivername = argv[3];
@@ -1447,25 +1547,8 @@ static WERROR cmd_spoolss_addprinterex(struct rpc_pipe_client *cli,
info_ctr.level = 2;
info_ctr.info.info2 = &info2;
- level1.size = 28; /* wild guess */
- level1.build = 1381;
- level1.major = 2;
- level1.minor = 0;
- level1.processor = 0;
- level1.client = global_myname();
- level1.user = cli->auth->user_name;
-
- userlevel_ctr.level = 1;
- userlevel_ctr.user_info.level1 = &level1;
-
- status = rpccli_spoolss_AddPrinterEx(cli, mem_ctx,
- cli->srv_name_slash,
- &info_ctr,
- &devmode_ctr,
- &sd,
- &userlevel_ctr,
- &handle,
- &result);
+ result = rpccli_spoolss_addprinterex(cli, mem_ctx,
+ &info_ctr);
if (W_ERROR_IS_OK(result))
printf ("Printer %s successfully installed.\n", argv[1]);
@@ -1481,11 +1564,16 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
{
POLICY_HND pol;
WERROR result;
+ NTSTATUS status;
uint32 level = 2;
- bool opened_hnd = False;
- PRINTER_INFO_CTR ctr;
- PRINTER_INFO_2 info2;
const char *printername;
+ union spoolss_PrinterInfo info;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
+
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
/* parse the command arguments */
if (argc != 3)
@@ -1505,15 +1593,13 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
/* Get printer info */
- ZERO_STRUCT (info2);
- ctr.printers_2 = &info2;
-
- result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, level, &ctr);
-
+ result = rpccli_spoolss_getprinter(cli, mem_ctx,
+ &pol,
+ level,
+ 0,
+ &info);
if (!W_ERROR_IS_OK(result)) {
printf ("Unable to retrieve printer information!\n");
goto done;
@@ -1521,10 +1607,17 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
/* Set the printer driver */
- init_unistr(&ctr.printers_2->drivername, argv[2]);
-
- result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, level, &ctr, 0);
-
+ info.info2.drivername = argv[2];
+ info_ctr.level = 2;
+ info_ctr.info.info2 = (struct spoolss_SetPrinterInfo2 *)&info.info2;
+
+ status = rpccli_spoolss_SetPrinter(cli, mem_ctx,
+ &pol,
+ &info_ctr,
+ &devmode_ctr,
+ &secdesc_ctr,
+ 0, /* command */
+ &result);
if (!W_ERROR_IS_OK(result)) {
printf("SetPrinter call failed!\n");
goto done;;
@@ -1535,7 +1628,7 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
done:
/* Cleanup */
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -2077,9 +2170,7 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
WERROR result;
const char *printername;
POLICY_HND pol;
- bool opened_hnd = False;
- PRINTER_INFO_CTR ctr;
- PRINTER_INFO_0 info;
+ union spoolss_PrinterInfo info;
REGISTRY_VALUE value;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
@@ -2127,17 +2218,16 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- opened_hnd = True;
-
- ctr.printers_0 = &info;
-
- result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, 0, &ctr);
-
+ result = rpccli_spoolss_getprinter(cli, mem_ctx,
+ &pol,
+ 0,
+ 0,
+ &info);
if (!W_ERROR_IS_OK(result))
goto done;
printf("%s\n", current_timestring(tmp_ctx, True));
- printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id);
+ printf("\tchange_id (before set)\t:[0x%x]\n", info.info0.change_id);
/* Set the printer data */
@@ -2217,18 +2307,21 @@ static WERROR cmd_spoolss_setprinterdata(struct rpc_pipe_client *cli,
}
printf("\tSetPrinterData succeeded [%s: %s]\n", argv[3], argv[4]);
- result = rpccli_spoolss_getprinter(cli, mem_ctx, &pol, 0, &ctr);
-
+ result = rpccli_spoolss_getprinter(cli, mem_ctx,
+ &pol,
+ 0,
+ 0,
+ &info);
if (!W_ERROR_IS_OK(result))
goto done;
printf("%s\n", current_timestring(tmp_ctx, True));
- printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id);
+ printf("\tchange_id (after set)\t:[0x%x]\n", info.info0.change_id);
done:
/* cleanup */
TALLOC_FREE(tmp_ctx);
- if (opened_hnd)
+ if (is_valid_policy_hnd(&pol))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
return result;
@@ -2617,12 +2710,16 @@ done:
static bool compare_printer( struct rpc_pipe_client *cli1, POLICY_HND *hnd1,
struct rpc_pipe_client *cli2, POLICY_HND *hnd2 )
{
- PRINTER_INFO_CTR ctr1, ctr2;
+ union spoolss_PrinterInfo info1, info2;
WERROR werror;
TALLOC_CTX *mem_ctx = talloc_init("compare_printer");
printf("Retrieving printer propertiesfor %s...", cli1->desthost);
- werror = rpccli_spoolss_getprinter( cli1, mem_ctx, hnd1, 2, &ctr1);
+ werror = rpccli_spoolss_getprinter(cli1, mem_ctx,
+ hnd1,
+ 2,
+ 0,
+ &info1);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
talloc_destroy(mem_ctx);
@@ -2631,7 +2728,11 @@ static bool compare_printer( struct rpc_pipe_client *cli1, POLICY_HND *hnd1,
printf("ok\n");
printf("Retrieving printer properties for %s...", cli2->desthost);
- werror = rpccli_spoolss_getprinter( cli2, mem_ctx, hnd2, 2, &ctr2);
+ werror = rpccli_spoolss_getprinter(cli2, mem_ctx,
+ hnd2,
+ 2,
+ 0,
+ &info2);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
talloc_destroy(mem_ctx);
@@ -2650,7 +2751,7 @@ static bool compare_printer( struct rpc_pipe_client *cli1, POLICY_HND *hnd1,
static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *hnd1,
struct rpc_pipe_client *cli2, POLICY_HND *hnd2 )
{
- PRINTER_INFO_CTR ctr1, ctr2;
+ union spoolss_PrinterInfo info1, info2;
WERROR werror;
TALLOC_CTX *mem_ctx = talloc_init("compare_printer_secdesc");
SEC_DESC *sd1, *sd2;
@@ -2658,7 +2759,11 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *h
printf("Retrieving printer security for %s...", cli1->desthost);
- werror = rpccli_spoolss_getprinter( cli1, mem_ctx, hnd1, 3, &ctr1);
+ werror = rpccli_spoolss_getprinter(cli1, mem_ctx,
+ hnd1,
+ 3,
+ 0,
+ &info1);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
result = False;
@@ -2667,7 +2772,11 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *h
printf("ok\n");
printf("Retrieving printer security for %s...", cli2->desthost);
- werror = rpccli_spoolss_getprinter( cli2, mem_ctx, hnd2, 3, &ctr2);
+ werror = rpccli_spoolss_getprinter(cli2, mem_ctx,
+ hnd2,
+ 3,
+ 0,
+ &info2);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
result = False;
@@ -2678,14 +2787,8 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, POLICY_HND *h
printf("++ ");
- if ( (ctr1.printers_3 != ctr2.printers_3) && (!ctr1.printers_3 || !ctr2.printers_3) ) {
- printf("NULL PRINTER_INFO_3!\n");
- result = False;
- goto done;
- }
-
- sd1 = ctr1.printers_3->secdesc;
- sd2 = ctr2.printers_3->secdesc;
+ sd1 = info1.info3.secdesc;
+ sd2 = info2.info3.secdesc;
if ( (sd1 != sd2) && ( !sd1 || !sd2 ) ) {
printf("NULL secdesc!\n");
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index ac7c35c240..a42705adb6 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1440,7 +1440,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
"create_disposition = 0x%x create_options=0x%x "
"unix mode=0%o oplock_request=%d\n",
fname, new_dos_attributes, access_mask, share_access,
- create_disposition, create_options, unx_mode,
+ create_disposition, create_options, (unsigned int)unx_mode,
oplock_request));
if ((req == NULL) && ((oplock_request & INTERNAL_OPEN_ONLY) == 0)) {
diff --git a/source3/smbd/oplock_onefs.c b/source3/smbd/oplock_onefs.c
index 0908ce4386..d4f181fc47 100644
--- a/source3/smbd/oplock_onefs.c
+++ b/source3/smbd/oplock_onefs.c
@@ -744,13 +744,13 @@ struct kernel_oplocks *onefs_init_kernel_oplocks(TALLOC_CTX *mem_ctx)
po.po_flags_on |= P_NON_BLOCKING_SEMLOCK;
if (setprocoptions(&po) != 0) {
DEBUG(0, ("setprocoptions failed: %s.\n", strerror(errno)));
- goto err_out;
+ return NULL;
}
/* Setup the oplock contexts */
_ctx = talloc_zero(mem_ctx, struct kernel_oplocks);
if (!_ctx) {
- goto err_out;
+ return NULL;
}
ctx = talloc_zero(_ctx, struct onefs_oplocks_context);
@@ -788,7 +788,6 @@ struct kernel_oplocks *onefs_init_kernel_oplocks(TALLOC_CTX *mem_ctx)
err_out:
talloc_free(_ctx);
- talloc_free(ctx);
return NULL;
}
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index e9b581efe8..2f84a831c6 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -719,12 +719,12 @@ static struct pai_val *load_inherited_info(const struct connection_struct *conn,
Count a linked list of canonical ACE entries.
****************************************************************************/
-static size_t count_canon_ace_list( canon_ace *list_head )
+static size_t count_canon_ace_list( canon_ace *l_head )
{
size_t count = 0;
canon_ace *ace;
- for (ace = list_head; ace; ace = ace->next)
+ for (ace = l_head; ace; ace = ace->next)
count++;
return count;
@@ -734,13 +734,13 @@ static size_t count_canon_ace_list( canon_ace *list_head )
Free a linked list of canonical ACE entries.
****************************************************************************/
-static void free_canon_ace_list( canon_ace *list_head )
+static void free_canon_ace_list( canon_ace *l_head )
{
canon_ace *list, *next;
- for (list = list_head; list; list = next) {
+ for (list = l_head; list; list = next) {
next = list->next;
- DLIST_REMOVE(list_head, list);
+ DLIST_REMOVE(l_head, list);
SAFE_FREE(list);
}
}
@@ -916,7 +916,7 @@ static bool identity_in_ace_equal(canon_ace *ace1, canon_ace *ace2)
static void merge_aces( canon_ace **pp_list_head )
{
- canon_ace *list_head = *pp_list_head;
+ canon_ace *l_head = *pp_list_head;
canon_ace *curr_ace_outer;
canon_ace *curr_ace_outer_next;
@@ -925,7 +925,7 @@ static void merge_aces( canon_ace **pp_list_head )
* with identical SIDs.
*/
- for (curr_ace_outer = list_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
+ for (curr_ace_outer = l_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
canon_ace *curr_ace;
canon_ace *curr_ace_next;
@@ -947,7 +947,7 @@ static void merge_aces( canon_ace **pp_list_head )
/* Merge two allow or two deny ACE's. */
curr_ace_outer->perms |= curr_ace->perms;
- DLIST_REMOVE(list_head, curr_ace);
+ DLIST_REMOVE(l_head, curr_ace);
SAFE_FREE(curr_ace);
curr_ace_outer_next = curr_ace_outer->next; /* We may have deleted the link. */
}
@@ -960,7 +960,7 @@ static void merge_aces( canon_ace **pp_list_head )
* appears only once in the list.
*/
- for (curr_ace_outer = list_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
+ for (curr_ace_outer = l_head; curr_ace_outer; curr_ace_outer = curr_ace_outer_next) {
canon_ace *curr_ace;
canon_ace *curr_ace_next;
@@ -992,7 +992,7 @@ static void merge_aces( canon_ace **pp_list_head )
* The deny overrides the allow. Remove the allow.
*/
- DLIST_REMOVE(list_head, curr_ace);
+ DLIST_REMOVE(l_head, curr_ace);
SAFE_FREE(curr_ace);
curr_ace_outer_next = curr_ace_outer->next; /* We may have deleted the link. */
@@ -1008,7 +1008,7 @@ static void merge_aces( canon_ace **pp_list_head )
* before we can get to an allow ace.
*/
- DLIST_REMOVE(list_head, curr_ace_outer);
+ DLIST_REMOVE(l_head, curr_ace_outer);
SAFE_FREE(curr_ace_outer);
break;
}
@@ -1019,7 +1019,7 @@ static void merge_aces( canon_ace **pp_list_head )
/* We may have modified the list. */
- *pp_list_head = list_head;
+ *pp_list_head = l_head;
}
/****************************************************************************
@@ -2305,12 +2305,12 @@ static bool unpack_canon_ace(files_struct *fsp,
static void arrange_posix_perms(const char *filename, canon_ace **pp_list_head)
{
- canon_ace *list_head = *pp_list_head;
+ canon_ace *l_head = *pp_list_head;
canon_ace *owner_ace = NULL;
canon_ace *other_ace = NULL;
canon_ace *ace = NULL;
- for (ace = list_head; ace; ace = ace->next) {
+ for (ace = l_head; ace; ace = ace->next) {
if (ace->type == SMB_ACL_USER_OBJ)
owner_ace = ace;
else if (ace->type == SMB_ACL_OTHER) {
@@ -2331,16 +2331,16 @@ static void arrange_posix_perms(const char *filename, canon_ace **pp_list_head)
*/
if (owner_ace) {
- DLIST_PROMOTE(list_head, owner_ace);
+ DLIST_PROMOTE(l_head, owner_ace);
}
if (other_ace) {
- DLIST_DEMOTE(list_head, other_ace, canon_ace *);
+ DLIST_DEMOTE(l_head, other_ace, canon_ace *);
}
/* We have probably changed the head of the list. */
- *pp_list_head = list_head;
+ *pp_list_head = l_head;
}
/****************************************************************************
@@ -2353,7 +2353,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
const DOM_SID *powner, const DOM_SID *pgroup, struct pai_val *pal, SMB_ACL_TYPE_T the_acl_type)
{
mode_t acl_mask = (S_IRUSR|S_IWUSR|S_IXUSR);
- canon_ace *list_head = NULL;
+ canon_ace *l_head = NULL;
canon_ace *ace = NULL;
canon_ace *next_ace = NULL;
int entry_id = SMB_ACL_FIRST_ENTRY;
@@ -2457,14 +2457,14 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
ace->owner_type = owner_type;
ace->ace_flags = get_pai_flags(pal, ace, (the_acl_type == SMB_ACL_TYPE_DEFAULT));
- DLIST_ADD(list_head, ace);
+ DLIST_ADD(l_head, ace);
}
/*
* This next call will ensure we have at least a user/group/world set.
*/
- if (!ensure_canon_entry_valid(&list_head, conn->params,
+ if (!ensure_canon_entry_valid(&l_head, conn->params,
S_ISDIR(psbuf->st_mode), powner, pgroup,
psbuf, False))
goto fail;
@@ -2476,7 +2476,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
DEBUG(10,("canonicalise_acl: %s ace entries before arrange :\n", the_acl_type == SMB_ACL_TYPE_ACCESS ? "Access" : "Default" ));
- for ( ace_count = 0, ace = list_head; ace; ace = next_ace, ace_count++) {
+ for ( ace_count = 0, ace = l_head; ace; ace = next_ace, ace_count++) {
next_ace = ace->next;
/* Masks are only applied to entries other than USER_OBJ and OTHER. */
@@ -2484,7 +2484,7 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
ace->perms &= acl_mask;
if (ace->perms == 0) {
- DLIST_PROMOTE(list_head, ace);
+ DLIST_PROMOTE(l_head, ace);
}
if( DEBUGLVL( 10 ) ) {
@@ -2492,15 +2492,15 @@ static canon_ace *canonicalise_acl(struct connection_struct *conn,
}
}
- arrange_posix_perms(fname,&list_head );
+ arrange_posix_perms(fname,&l_head );
- print_canon_ace_list( "canonicalise_acl: ace entries after arrange", list_head );
+ print_canon_ace_list( "canonicalise_acl: ace entries after arrange", l_head );
- return list_head;
+ return l_head;
fail:
- free_canon_ace_list(list_head);
+ free_canon_ace_list(l_head);
return NULL;
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 49995d8901..346e8973de 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -212,7 +212,7 @@ static void remove_child_pid(pid_t pid, bool unclean_shutdown)
/* a child terminated uncleanly so tickle all processes to see
if they can grab any of the pending locks
*/
- DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", pid));
+ DEBUG(3,(__location__ " Unclean shutdown of pid %u\n", (unsigned int)pid));
messaging_send_buf(smbd_messaging_context(), procid_self(),
MSG_SMB_BRL_VALIDATE, NULL, 0);
message_send_all(smbd_messaging_context(),
diff --git a/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 8a09ed39a9..2c29192220 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/smbd/sesssetup.c
@@ -1352,8 +1352,8 @@ static int shutdown_other_smbds(struct db_record *rec,
return 0;
}
- DEBUG(0,("shutdown_other_smbds: shutting down pid %d "
- "(IP %s)\n", procid_to_pid(&crec->pid), ip));
+ DEBUG(0,("shutdown_other_smbds: shutting down pid %u "
+ "(IP %s)\n", (unsigned int)procid_to_pid(&crec->pid), ip));
messaging_send(smbd_messaging_context(), crec->pid, MSG_SHUTDOWN,
&data_blob_null);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 759e520866..433b8a008d 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -4972,6 +4972,7 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
****************************************************************************/
static NTSTATUS smb_set_file_dosmode(connection_struct *conn,
+ files_struct *fsp,
const char *fname,
SMB_STRUCT_STAT *psbuf,
uint32 dosmode)
@@ -4980,6 +4981,14 @@ static NTSTATUS smb_set_file_dosmode(connection_struct *conn,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
+ if (fsp) {
+ if (fsp->base_fsp) {
+ fname = fsp->base_fsp->fsp_name;
+ } else {
+ fname = fsp->fsp_name;
+ }
+ }
+
if (dosmode) {
if (S_ISDIR(psbuf->st_mode)) {
dosmode |= aDIR;
@@ -5723,12 +5732,11 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
/* Set the attributes */
dosmode = IVAL(pdata,32);
- status = smb_set_file_dosmode(conn, fname, psbuf, dosmode);
+ status = smb_set_file_dosmode(conn, fsp, fname, psbuf, dosmode);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
-
/* access time */
ft.atime = interpret_long_date(pdata+8);
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index bb8747ede3..99012ddf2d 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -50,6 +50,33 @@ static const struct table_node archi_table[]= {
Printer info level 3 display function.
****************************************************************************/
+static void display_print_driver3(struct spoolss_DriverInfo3 *r)
+{
+ int i;
+
+ if (!r) {
+ return;
+ }
+
+ printf("Printer Driver Info 3:\n");
+ printf("\tVersion: [%x]\n", r->version);
+ printf("\tDriver Name: [%s]\n", r->driver_name);
+ printf("\tArchitecture: [%s]\n", r->architecture);
+ printf("\tDriver Path: [%s]\n", r->driver_path);
+ printf("\tDatafile: [%s]\n", r->data_file);
+ printf("\tConfigfile: [%s]\n\n", r->config_file);
+ printf("\tHelpfile: [%s]\n\n", r->help_file);
+
+ for (i=0; r->dependent_files[i] != NULL; i++) {
+ printf("\tDependentfiles: [%s]\n", r->dependent_files[i]);
+ }
+
+ printf("\n");
+
+ printf("\tMonitorname: [%s]\n", r->monitor_name);
+ printf("\tDefaultdatatype: [%s]\n\n", r->default_datatype);
+}
+
static void display_print_driver_3(DRIVER_INFO_3 *i1)
{
fstring name = "";
@@ -513,7 +540,7 @@ static NTSTATUS net_copy_driverfile(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
- char *file, const char *short_archi) {
+ const char *file, const char *short_archi) {
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
const char *p;
@@ -523,6 +550,10 @@ static NTSTATUS net_copy_driverfile(struct net_context *c,
char *filename;
char *tok;
+ if (!file) {
+ return NT_STATUS_OK;
+ }
+
/* scroll through the file until we have the part
beyond archi_table.short_archi */
p = file;
@@ -617,67 +648,47 @@ static NTSTATUS copy_print_driver_3(struct net_context *c,
TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
- const char *short_archi, DRIVER_INFO_3 *i1)
+ const char *short_archi,
+ struct spoolss_DriverInfo3 *r)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- int length = 0;
- bool valid = true;
-
- fstring name = "";
- fstring driverpath = "";
- fstring datafile = "";
- fstring configfile = "";
- fstring helpfile = "";
- fstring dependentfiles = "";
+ int i;
- if (i1 == NULL)
+ if (r == NULL) {
return nt_status;
-
- rpcstr_pull(name, i1->name.buffer, sizeof(name), -1, STR_TERMINATE);
- rpcstr_pull(driverpath, i1->driverpath.buffer, sizeof(driverpath), -1, STR_TERMINATE);
- rpcstr_pull(datafile, i1->datafile.buffer, sizeof(datafile), -1, STR_TERMINATE);
- rpcstr_pull(configfile, i1->configfile.buffer, sizeof(configfile), -1, STR_TERMINATE);
- rpcstr_pull(helpfile, i1->helpfile.buffer, sizeof(helpfile), -1, STR_TERMINATE);
-
+ }
if (c->opt_verbose)
d_printf("copying driver: [%s], for architecture: [%s], version: [%d]\n",
- name, short_archi, i1->version);
+ r->driver_name, short_archi, r->version);
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
- driverpath, short_archi);
+ r->driver_path, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
- datafile, short_archi);
+ r->data_file, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
- configfile, short_archi);
+ r->config_file, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
- helpfile, short_archi);
+ r->help_file, short_archi);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
- while (valid) {
-
- rpcstr_pull(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles), -1, STR_TERMINATE);
- length += strlen(dependentfiles)+1;
+ for (i=0; r->dependent_files[i] != NULL; i++) {
- if (strlen(dependentfiles) > 0) {
-
- nt_status = net_copy_driverfile(c, mem_ctx,
- cli_share_src, cli_share_dst,
- dependentfiles, short_archi);
- if (!NT_STATUS_IS_OK(nt_status))
- return nt_status;
- } else {
- valid = false;
+ nt_status = net_copy_driverfile(c, mem_ctx,
+ cli_share_src, cli_share_dst,
+ r->dependent_files[i], short_archi);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ return nt_status;
}
}
@@ -764,13 +775,16 @@ static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd,
uint32 level,
- PRINTER_INFO_CTR *ctr)
+ union spoolss_PrinterInfo *info)
{
WERROR result;
/* getprinter call */
- result = rpccli_spoolss_getprinter(pipe_hnd, mem_ctx, hnd, level, ctr);
-
+ result = rpccli_spoolss_getprinter(pipe_hnd, mem_ctx,
+ hnd,
+ level,
+ 0, /* offered */
+ info);
if (!W_ERROR_IS_OK(result)) {
printf("cannot get printer-info: %s\n", win_errstr(result));
return false;
@@ -783,12 +797,64 @@ static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd,
uint32 level,
- PRINTER_INFO_CTR *ctr)
+ union spoolss_PrinterInfo *info)
{
WERROR result;
+ NTSTATUS status;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
+
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
/* setprinter call */
- result = rpccli_spoolss_setprinter(pipe_hnd, mem_ctx, hnd, level, ctr, 0);
+
+ info_ctr.level = level;
+ switch (level) {
+ case 0:
+ info_ctr.info.info0 = (struct spoolss_SetPrinterInfo0 *)&info->info0;
+ break;
+ case 1:
+ info_ctr.info.info1 = (struct spoolss_SetPrinterInfo1 *)&info->info1;
+ break;
+ case 2:
+ info_ctr.info.info2 = (struct spoolss_SetPrinterInfo2 *)&info->info2;
+ break;
+ case 3:
+ info_ctr.info.info3 = (struct spoolss_SetPrinterInfo3 *)&info->info3;
+ break;
+ case 4:
+ info_ctr.info.info4 = (struct spoolss_SetPrinterInfo4 *)&info->info4;
+ break;
+ case 5:
+ info_ctr.info.info5 = (struct spoolss_SetPrinterInfo5 *)&info->info5;
+ break;
+ case 6:
+ info_ctr.info.info6 = (struct spoolss_SetPrinterInfo6 *)&info->info6;
+ break;
+ case 7:
+ info_ctr.info.info7 = (struct spoolss_SetPrinterInfo7 *)&info->info7;
+ break;
+#if 0 /* FIXME GD */
+ case 8:
+ info_ctr.info.info8 = (struct spoolss_SetPrinterInfo8 *)&info->info8;
+ break;
+ case 9:
+ info_ctr.info.info9 = (struct spoolss_SetPrinterInfo9 *)&info->info9;
+ break;
+#endif
+ default:
+ break; /* FIXME */
+ }
+
+ status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
+ hnd,
+ &info_ctr,
+ &devmode_ctr,
+ &secdesc_ctr,
+ 0, /* command */
+ &result);
if (!W_ERROR_IS_OK(result)) {
printf("cannot set printer-info: %s\n", win_errstr(result));
@@ -930,15 +996,23 @@ static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, uint32 level,
const char *env, int version,
- PRINTER_DRIVER_CTR *ctr)
+ union spoolss_DriverInfo *info)
{
WERROR result;
+ uint32_t server_major_version;
+ uint32_t server_minor_version;
/* getprinterdriver call */
- result = rpccli_spoolss_getprinterdriver(
- pipe_hnd, mem_ctx, hnd, level,
- env, version, ctr);
-
+ result = rpccli_spoolss_getprinterdriver2(pipe_hnd, mem_ctx,
+ hnd,
+ env,
+ level,
+ 0,
+ version,
+ 2,
+ info,
+ &server_major_version,
+ &server_minor_version);
if (!W_ERROR_IS_OK(result)) {
DEBUG(1,("cannot get driver (for architecture: %s): %s\n",
env, win_errstr(result)));
@@ -955,13 +1029,31 @@ static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx, uint32 level,
- PRINTER_DRIVER_CTR *ctr)
+ union spoolss_DriverInfo *info)
{
WERROR result;
+ NTSTATUS status;
+ struct spoolss_AddDriverInfoCtr info_ctr;
- /* addprinterdriver call */
- result = rpccli_spoolss_addprinterdriver(pipe_hnd, mem_ctx, level, ctr);
+ info_ctr.level = level;
+
+ switch (level) {
+ case 2:
+ info_ctr.info.info2 = (struct spoolss_AddDriverInfo2 *)&info->info2;
+ break;
+ case 3:
+ info_ctr.info.info3 = (struct spoolss_AddDriverInfo3 *)&info->info3;
+ break;
+ default:
+ printf("unsupported info level: %d\n", level);
+ return false;
+ }
+ /* addprinterdriver call */
+ status = rpccli_spoolss_AddPrinterDriver(pipe_hnd, mem_ctx,
+ pipe_hnd->srv_name_slash,
+ &info_ctr,
+ &result);
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
printf("You are not allowed to add drivers\n");
@@ -990,6 +1082,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
{
POLICY_HND hnd;
+ union spoolss_PrinterInfo info;
/* no arguments given, enumerate all printers */
if (argc == 0) {
@@ -1002,6 +1095,8 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
goto out;
}
+ /* FIXME GD */
+ return false;
/* argument given, get a single printer by name */
if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0],
@@ -1010,7 +1105,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
&hnd))
return false;
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) {
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
return false;
}
@@ -1179,9 +1274,12 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
uint32 i, num_printers;
uint32 level = 7;
char *printername, *sharename;
- PRINTER_INFO_CTR ctr, ctr_pub;
+ PRINTER_INFO_CTR ctr;
+ union spoolss_PrinterInfo info;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
POLICY_HND hnd;
- bool got_hnd = false;
WERROR result;
const char *action_str;
@@ -1209,10 +1307,8 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
PRINTER_ALL_ACCESS, pipe_hnd->auth->user_name, &hnd))
goto done;
- got_hnd = true;
-
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info))
goto done;
/* check action and set string */
@@ -1232,9 +1328,21 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
break;
}
- ctr_pub.printers_7->action = action;
+ info.info7.action = action;
+ info_ctr.level = 7;
+ info_ctr.info.info7 = (struct spoolss_SetPrinterInfo7 *)&info.info7;
+
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
+
+ nt_status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
+ &hnd,
+ &info_ctr,
+ &devmode_ctr,
+ &secdesc_ctr,
+ 0, /* command */
+ &result);
- result = rpccli_spoolss_setprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub, 0);
if (!W_ERROR_IS_OK(result) && (W_ERROR_V(result) != W_ERROR_V(WERR_IO_PENDING))) {
printf("cannot set printer-info: %s\n", win_errstr(result));
goto done;
@@ -1246,7 +1354,7 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
nt_status = NT_STATUS_OK;
done:
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
return nt_status;
@@ -1318,10 +1426,9 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
uint32 i, num_printers;
uint32 level = 7;
char *printername, *sharename;
- char *guid;
PRINTER_INFO_CTR ctr, ctr_pub;
+ union spoolss_PrinterInfo info;
POLICY_HND hnd;
- bool got_hnd = false;
int state;
if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr))
@@ -1350,26 +1457,19 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli->user_name, &hnd))
goto done;
- got_hnd = true;
-
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info))
goto done;
- rpcstr_pull_talloc(mem_ctx,
- &guid,
- ctr_pub.printers_7->guid.buffer,
- -1,
- STR_TERMINATE);
- if (!guid) {
+ if (!info.info7.guid) {
goto done;
}
- state = ctr_pub.printers_7->action;
+ state = info.info7.action;
switch (state) {
case SPOOL_DS_PUBLISH:
printf("printer [%s] is published", sharename);
if (c->opt_verbose)
- printf(", guid: %s", guid);
+ printf(", guid: %s", info.info7.guid);
printf("\n");
break;
case SPOOL_DS_UNPUBLISH:
@@ -1387,7 +1487,7 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
nt_status = NT_STATUS_OK;
done:
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
return nt_status;
@@ -1427,12 +1527,11 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
uint32 num_printers;
uint32 level = 2;
char *printername, *sharename;
- bool got_hnd_src = false;
- bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
- PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
+ PRINTER_INFO_CTR ctr_src, ctr_enum;
struct cli_state *cli_dst = NULL;
+ union spoolss_PrinterInfo info_src, info_dst;
ZERO_STRUCT(ctr_src);
@@ -1493,47 +1592,41 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
- got_hnd_src = true;
-
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
- got_hnd_dst = true;
-
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst))
goto done;
/* check for existing src printer */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &ctr_src))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &info_src))
goto done;
/* Copy Security Descriptor */
/* copy secdesc (info level 2) */
- ctr_dst.printers_2->devmode = NULL;
- ctr_dst.printers_2->secdesc = dup_sec_desc(mem_ctx, ctr_src.printers_3->secdesc);
+ info_dst.info2.devmode = NULL;
+ info_dst.info2.secdesc = dup_sec_desc(mem_ctx, info_src.info3.secdesc);
if (c->opt_verbose)
- display_sec_desc(ctr_dst.printers_2->secdesc);
+ display_sec_desc(info_dst.info2.secdesc);
- if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst))
goto done;
DEBUGADD(1,("\tSetPrinter of SECDESC succeeded\n"));
/* close printer handles here */
- if (got_hnd_src) {
+ if (is_valid_policy_hnd(&hnd_src)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- got_hnd_src = false;
}
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
- got_hnd_dst = false;
}
}
@@ -1542,11 +1635,11 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
done:
- if (got_hnd_src) {
+ if (is_valid_policy_hnd(&hnd_src)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
}
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
}
@@ -1588,11 +1681,10 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
uint32 num_printers;
uint32 level = 1;
char *printername, *sharename;
- bool got_hnd_src = false;
- bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
- PRINTER_INFO_CTR ctr_enum, ctr_dst;
+ PRINTER_INFO_CTR ctr_enum;
+ union spoolss_PrinterInfo info_dst;
uint32 num_forms;
FORM_1 *forms;
struct cli_state *cli_dst = NULL;
@@ -1649,19 +1741,13 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
- got_hnd_src = true;
-
-
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
- got_hnd_dst = true;
-
-
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst))
goto done;
/* finally migrate forms */
@@ -1721,14 +1807,12 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
/* close printer handles here */
- if (got_hnd_src) {
+ if (is_valid_policy_hnd(&hnd_src)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- got_hnd_src = false;
}
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
- got_hnd_dst = false;
}
}
@@ -1736,10 +1820,10 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
done:
- if (got_hnd_src)
+ if (is_valid_policy_hnd(&hnd_src))
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- if (got_hnd_dst)
+ if (is_valid_policy_hnd(&hnd_dst))
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
if (cli_dst) {
@@ -1779,21 +1863,18 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
uint32 num_printers;
uint32 level = 3;
char *printername, *sharename;
- bool got_hnd_src = false;
- bool got_hnd_dst = false;
bool got_src_driver_share = false;
bool got_dst_driver_share = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
- PRINTER_DRIVER_CTR drv_ctr_src, drv_ctr_dst;
+ union spoolss_DriverInfo drv_info_src;
PRINTER_INFO_CTR info_ctr_enum, info_ctr_dst;
+ union spoolss_PrinterInfo info_dst;
struct cli_state *cli_dst = NULL;
struct cli_state *cli_share_src = NULL;
struct cli_state *cli_share_dst = NULL;
- fstring drivername = "";
+ const char *drivername = NULL;
- ZERO_STRUCT(drv_ctr_src);
- ZERO_STRUCT(drv_ctr_dst);
ZERO_STRUCT(info_ctr_enum);
ZERO_STRUCT(info_ctr_dst);
@@ -1865,10 +1946,8 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
- got_hnd_dst = true;
-
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst))
goto done;
@@ -1879,9 +1958,6 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
&hnd_src))
goto done;
- got_hnd_src = true;
-
-
/* in a first step call getdriver for each shared printer (per arch)
to get a list of all files that have to be copied */
@@ -1890,15 +1966,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
/* getdriver src */
if (!net_spoolss_getprinterdriver(pipe_hnd, mem_ctx, &hnd_src,
level, archi_table[i].long_archi,
- archi_table[i].version, &drv_ctr_src))
+ archi_table[i].version, &drv_info_src))
continue;
- rpcstr_pull(drivername, drv_ctr_src.info3->name.buffer,
- sizeof(drivername), -1, STR_TERMINATE);
+ drivername = drv_info_src.info3.driver_name;
if (c->opt_verbose)
- display_print_driver_3(drv_ctr_src.info3);
-
+ display_print_driver3(&drv_info_src.info3);
/* check arch dir */
nt_status = check_arch_dir(cli_share_dst, archi_table[i].short_archi);
@@ -1909,13 +1983,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
/* copy driver-files */
nt_status = copy_print_driver_3(c, mem_ctx, cli_share_src, cli_share_dst,
archi_table[i].short_archi,
- drv_ctr_src.info3);
+ &drv_info_src.info3);
if (!NT_STATUS_IS_OK(nt_status))
goto done;
/* adddriver dst */
- if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_ctr_src)) {
+ if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_info_src)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@@ -1932,9 +2006,9 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
}
/* setdriver dst */
- init_unistr(&info_ctr_dst.printers_2->drivername, drivername);
+ info_dst.info2.drivername = drivername;
- if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) {
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@@ -1943,15 +2017,13 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
drivername, printername));
/* close dst */
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
- got_hnd_dst = false;
}
/* close src */
- if (got_hnd_src) {
+ if (is_valid_policy_hnd(&hnd_src)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- got_hnd_src = false;
}
}
@@ -1959,10 +2031,10 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
done:
- if (got_hnd_src)
+ if (is_valid_policy_hnd(&hnd_src))
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- if (got_hnd_dst)
+ if (is_valid_policy_hnd(&hnd_dst))
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
if (cli_dst) {
@@ -2010,13 +2082,13 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i = 0, num_printers;
uint32 level = 2;
- PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
+ PRINTER_INFO_CTR ctr_enum;
+ union spoolss_PrinterInfo info_dst, info_src;
struct cli_state *cli_dst = NULL;
POLICY_HND hnd_dst, hnd_src;
char *printername, *sharename;
- bool got_hnd_src = false;
- bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
+ struct spoolss_SetPrinterInfoCtr info_ctr;
DEBUG(3,("copying printers\n"));
@@ -2067,19 +2139,16 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) {
DEBUG(1,("could not open printer: %s\n", sharename));
- } else {
- got_hnd_dst = true;
}
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst)) {
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst)) {
printf ("could not get printer, creating printer.\n");
} else {
DEBUG(1,("printer already exists: %s\n", sharename));
/* close printer handle here - dst only, not got src yet. */
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
- got_hnd_dst = false;
}
continue;
}
@@ -2092,16 +2161,20 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
- got_hnd_src = true;
-
/* getprinter on the src server */
- if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &info_src))
goto done;
/* copy each src printer to a dst printer 1:1,
maybe some values have to be changed though */
d_printf("creating printer: %s\n", printername);
- result = rpccli_spoolss_addprinterex (pipe_hnd_dst, mem_ctx, level, &ctr_src);
+
+ info_ctr.level = level;
+ info_ctr.info.info2 = (struct spoolss_SetPrinterInfo2 *)&info_src.info2;
+
+ result = rpccli_spoolss_addprinterex(pipe_hnd_dst,
+ mem_ctx,
+ &info_ctr);
if (W_ERROR_IS_OK(result))
d_printf ("printer [%s] successfully added.\n", printername);
@@ -2113,24 +2186,22 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
}
/* close printer handles here */
- if (got_hnd_src) {
+ if (is_valid_policy_hnd(&hnd_src)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- got_hnd_src = false;
}
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
- got_hnd_dst = false;
}
}
nt_status = NT_STATUS_OK;
done:
- if (got_hnd_src)
+ if (is_valid_policy_hnd(&hnd_src))
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- if (got_hnd_dst)
+ if (is_valid_policy_hnd(&hnd_dst))
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
if (cli_dst) {
@@ -2175,11 +2246,10 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
uint32 num_printers, val_needed, data_needed;
uint32 level = 2;
char *printername, *sharename;
- bool got_hnd_src = false;
- bool got_hnd_dst = false;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
- PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish;
+ PRINTER_INFO_CTR ctr_enum;
+ union spoolss_PrinterInfo info_dst_publish, info_dst;
REGVAL_CTR *reg_ctr;
struct cli_state *cli_dst = NULL;
char *devicename = NULL, *unc_name = NULL, *url = NULL;
@@ -2188,6 +2258,8 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
uint16 *keylist = NULL, *curkey;
ZERO_STRUCT(ctr_enum);
+ /* FIXME GD */
+ ZERO_STRUCT(info_dst_publish);
DEBUG(3,("copying printer settings\n"));
@@ -2247,44 +2319,39 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
- got_hnd_src = true;
-
-
/* open dst printer handle */
if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
- got_hnd_dst = true;
-
-
/* check for existing dst printer */
if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
- level, &ctr_dst))
+ level, &info_dst))
goto done;
+#if 0 /* FIXME GD */
/* STEP 1: COPY DEVICE-MODE and other
PRINTER_INFO_2-attributes
*/
- ctr_dst.printers_2 = &ctr_enum.printers_2[i];
+ info_dst.info2 = &ctr_enum.printers_2[i];
/* why is the port always disconnected when the printer
is correctly installed (incl. driver ???) */
- init_unistr( &ctr_dst.printers_2->portname, SAMBA_PRINTER_PORT_NAME);
+ info_dst.info2.portname = SAMBA_PRINTER_PORT_NAME;
/* check if printer is published */
if (ctr_enum.printers_2[i].attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
/* check for existing dst printer */
- if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &info_dst_publish))
goto done;
- ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH;
+ info_dst_publish.info7.action = SPOOL_DS_PUBLISH;
/* ignore false from setprinter due to WERR_IO_PENDING */
- net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
+ net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &info_dst_publish);
DEBUG(3,("republished printer\n"));
}
@@ -2292,14 +2359,14 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
if (ctr_enum.printers_2[i].devmode != NULL) {
/* copy devmode (info level 2) */
- ctr_dst.printers_2->devmode = (DEVICEMODE *)
+ info_dst.info2.devmode = (DEVICEMODE *)
TALLOC_MEMDUP(mem_ctx,
ctr_enum.printers_2[i].devmode,
sizeof(DEVICEMODE));
/* do not copy security descriptor (we have another
* command for that) */
- ctr_dst.printers_2->secdesc = NULL;
+ info_dst.info2.secdesc = NULL;
#if 0
if (asprintf(&devicename, "\\\\%s\\%s", longname,
@@ -2312,12 +2379,12 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
devicename);
#endif
if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
- level, &ctr_dst))
+ level, &info_dst))
goto done;
DEBUGADD(1,("\tSetPrinter of DEVICEMODE succeeded\n"));
}
-
+#endif
/* STEP 2: COPY REGISTRY VALUES */
/* please keep in mind that samba parse_spools gives horribly
@@ -2496,14 +2563,12 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
SAFE_FREE(keylist);
/* close printer handles here */
- if (got_hnd_src) {
+ if (is_valid_policy_hnd(&hnd_src)) {
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- got_hnd_src = false;
}
- if (got_hnd_dst) {
+ if (is_valid_policy_hnd(&hnd_dst)) {
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
- got_hnd_dst = false;
}
}
@@ -2515,10 +2580,10 @@ done:
SAFE_FREE(url);
SAFE_FREE(unc_name);
- if (got_hnd_src)
+ if (is_valid_policy_hnd(&hnd_src))
rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
- if (got_hnd_dst)
+ if (is_valid_policy_hnd(&hnd_dst))
rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
if (cli_dst) {
diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
index 1fdea818d6..39a264011e 100644
--- a/source3/utils/smbfilter.c
+++ b/source3/utils/smbfilter.c
@@ -91,8 +91,15 @@ static void filter_request(char *buf)
d_printf("sesion_request: %s -> %s\n",
name1, name2);
if (netbiosname) {
- /* replace the destination netbios name */
- name_mangle(netbiosname, buf+4, 0x20);
+ char *mangled = name_mangle(
+ talloc_tos(), netbiosname, 0x20);
+ if (mangled != NULL) {
+ /* replace the destination netbios
+ * name */
+ memcpy(buf+4, mangled,
+ name_len(mangled));
+ TALLOC_FREE(mangled);
+ }
}
}
return;
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 7c01f5db3a..042f3a98f7 100644
--- a/source3/utils/smbget.c
+++ b/source3/utils/smbget.c
@@ -194,7 +194,8 @@ static int smb_download_dir(const char *base, const char *name, int resume)
}
if(chmod(relname, remotestat.st_mode) < 0) {
- fprintf(stderr, "Unable to change mode of local dir %s to %o\n", relname, remotestat.st_mode);
+ fprintf(stderr, "Unable to change mode of local dir %s to %o\n", relname,
+ (unsigned int)remotestat.st_mode);
smbc_closedir(dirhandle);
return 0;
}
@@ -471,7 +472,8 @@ static int smb_download_file(const char *base, const char *name, int recursive,
if(keep_permissions && !send_stdout) {
if(fchmod(localhandle, remotestat.st_mode) < 0) {
- fprintf(stderr, "Unable to change mode of local file %s to %o\n", path, remotestat.st_mode);
+ fprintf(stderr, "Unable to change mode of local file %s to %o\n", path,
+ (unsigned int)remotestat.st_mode);
smbc_close(remotehandle);
close(localhandle);
return 0;
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index be91611bfb..dbe83152dd 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -386,7 +386,7 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
if (child_pid != 0) {
/* parent */
DEBUG(5, ("winbind_msg_validate_cache: child created with "
- "pid %d.\n", child_pid));
+ "pid %d.\n", (int)child_pid));
return;
}
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index 8326aba40a..02d0b5bc4e 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -2625,9 +2625,9 @@ void cache_store_response(pid_t pid, struct winbindd_response *response)
return;
DEBUG(10, ("Storing response for pid %d, len %d\n",
- pid, response->length));
+ (int)pid, response->length));
- fstr_sprintf(key_str, "DR/%d", pid);
+ fstr_sprintf(key_str, "DR/%d", (int)pid);
if (tdb_store(wcache->tdb, string_tdb_data(key_str),
make_tdb_data((uint8 *)response, sizeof(*response)),
TDB_REPLACE) == -1)
@@ -2641,7 +2641,7 @@ void cache_store_response(pid_t pid, struct winbindd_response *response)
DEBUG(10, ("Storing extra data: len=%d\n",
(int)(response->length - sizeof(*response))));
- fstr_sprintf(key_str, "DE/%d", pid);
+ fstr_sprintf(key_str, "DE/%d", (int)pid);
if (tdb_store(wcache->tdb, string_tdb_data(key_str),
make_tdb_data((uint8 *)response->extra_data.data,
response->length - sizeof(*response)),
@@ -2651,7 +2651,7 @@ void cache_store_response(pid_t pid, struct winbindd_response *response)
/* We could not store the extra data, make sure the tdb does not
* contain a main record with wrong dangling extra data */
- fstr_sprintf(key_str, "DR/%d", pid);
+ fstr_sprintf(key_str, "DR/%d", (int)pid);
tdb_delete(wcache->tdb, string_tdb_data(key_str));
return;
@@ -2665,9 +2665,9 @@ bool cache_retrieve_response(pid_t pid, struct winbindd_response * response)
if (!init_wcache())
return false;
- DEBUG(10, ("Retrieving response for pid %d\n", pid));
+ DEBUG(10, ("Retrieving response for pid %d\n", (int)pid));
- fstr_sprintf(key_str, "DR/%d", pid);
+ fstr_sprintf(key_str, "DR/%d", (int)pid);
data = tdb_fetch(wcache->tdb, string_tdb_data(key_str));
if (data.dptr == NULL)
@@ -2689,7 +2689,7 @@ bool cache_retrieve_response(pid_t pid, struct winbindd_response * response)
DEBUG(10, ("Retrieving extra data length=%d\n",
(int)(response->length - sizeof(*response))));
- fstr_sprintf(key_str, "DE/%d", pid);
+ fstr_sprintf(key_str, "DE/%d", (int)pid);
data = tdb_fetch(wcache->tdb, string_tdb_data(key_str));
if (data.dptr == NULL) {
@@ -2716,10 +2716,10 @@ void cache_cleanup_response(pid_t pid)
if (!init_wcache())
return;
- fstr_sprintf(key_str, "DR/%d", pid);
+ fstr_sprintf(key_str, "DR/%d", (int)pid);
tdb_delete(wcache->tdb, string_tdb_data(key_str));
- fstr_sprintf(key_str, "DE/%d", pid);
+ fstr_sprintf(key_str, "DE/%d", (int)pid);
tdb_delete(wcache->tdb, string_tdb_data(key_str));
return;
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index d40bab94ef..f56a63faa0 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -183,7 +183,7 @@ static void async_request_timeout_handler(struct event_context *ctx,
DEBUG(0,("async_request_timeout_handler: child pid %u is not responding. "
"Closing connection to it.\n",
- state->child_pid ));
+ (unsigned int)state->child_pid ));
/* Deal with the reply - set to error. */
async_reply_recv(private_data, False);
diff --git a/source4/build/m4/public.m4 b/source4/build/m4/public.m4
index 1927e9977f..ffdf92f784 100644
--- a/source4/build/m4/public.m4
+++ b/source4/build/m4/public.m4
@@ -157,6 +157,13 @@ mkinclude $1
"
])
+dnl
+dnl SMB_EXT_LIB() just specifies the details of the library.
+dnl Note: the library isn't enabled by default.
+dnl You need to enable it with SMB_ENABLE(name) if configure
+dnl find it should be used. E.g. it should not be enabled
+dnl if the library is present, but the header file is missing.
+dnl
dnl SMB_EXT_LIB(name,libs,cflags,cppflags,ldflags)
AC_DEFUN([SMB_EXT_LIB],
[
diff --git a/source4/client/mount.cifs.c b/source4/client/mount.cifs.c
index 7167859d7b..899c90cefd 100644
--- a/source4/client/mount.cifs.c
+++ b/source4/client/mount.cifs.c
@@ -313,8 +313,10 @@ int main(int argc, char ** argv)
FILE * pmntfile;
/* setlocale(LC_ALL, "");
+#if defined(LOCALEDIR)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE); */
+#endif
if(argc && argv) {
thisprogram = argv[0];
diff --git a/source4/headermap.txt b/source4/headermap.txt
index 8f3749a3b5..8287044622 100644
--- a/source4/headermap.txt
+++ b/source4/headermap.txt
@@ -49,7 +49,9 @@ param/share.h: share.h
../lib/util/util_tdb.h: util_tdb.h
../lib/util/util_ldb.h: util_ldb.h
../lib/util/wrap_xattr.h: wrap_xattr.h
-libcli/ldap/ldap_ndr.h: ldap_ndr.h
+../libcli/ldap/ldap_message.h: ldap_message.h
+../libcli/ldap/ldap_errors.h: ldap_errors.h
+../libcli/ldap/ldap_ndr.h: ldap_ndr.h
../lib/tevent/tevent.h: tevent.h
../lib/tevent/tevent_internal.h: tevent_internal.h
auth/session.h: samba/session.h
diff --git a/source4/heimdal/kuser/kinit.c b/source4/heimdal/kuser/kinit.c
index d1ef776716..fbb2d2287b 100644
--- a/source4/heimdal/kuser/kinit.c
+++ b/source4/heimdal/kuser/kinit.c
@@ -726,8 +726,10 @@ main (int argc, char **argv)
setprogname (argv[0]);
setlocale (LC_ALL, "");
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain ("heimdal_kuser", HEIMDAL_LOCALEDIR);
textdomain("heimdal_kuser");
+#endif
ret = krb5_init_context (&context);
if (ret == KRB5_CONFIG_BADFORMAT)
diff --git a/source4/heimdal/kuser/kuser_locl.h b/source4/heimdal/kuser/kuser_locl.h
index 21e9776975..eed9e00af6 100644
--- a/source4/heimdal/kuser/kuser_locl.h
+++ b/source4/heimdal/kuser/kuser_locl.h
@@ -88,7 +88,7 @@
#include <locale.h>
#endif
-#ifdef LIBINTL
+#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#define N_(x,y) gettext(x)
#define NP_(x,y) (x)
diff --git a/source4/heimdal/lib/krb5/context.c b/source4/heimdal/lib/krb5/context.c
index aa35a184c0..127dfa117d 100644
--- a/source4/heimdal/lib/krb5/context.c
+++ b/source4/heimdal/lib/krb5/context.c
@@ -295,7 +295,9 @@ krb5_init_context(krb5_context *context)
*context = NULL;
/* should have a run_once */
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain(HEIMDAL_TEXTDOMAIN, HEIMDAL_LOCALEDIR);
+#endif
p = calloc(1, sizeof(*p));
if(!p)
@@ -836,21 +838,31 @@ krb5_init_ets(krb5_context context)
{
if(context->et_list == NULL){
krb5_add_et_list(context, initialize_krb5_error_table_r);
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain(COM_ERR_BINDDOMAIN_krb5, HEIMDAL_LOCALEDIR);
+#endif
krb5_add_et_list(context, initialize_asn1_error_table_r);
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain(COM_ERR_BINDDOMAIN_asn1, HEIMDAL_LOCALEDIR);
+#endif
krb5_add_et_list(context, initialize_heim_error_table_r);
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain(COM_ERR_BINDDOMAIN_heim, HEIMDAL_LOCALEDIR);
+#endif
krb5_add_et_list(context, initialize_k524_error_table_r);
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain(COM_ERR_BINDDOMAIN_k524, HEIMDAL_LOCALEDIR);
+#endif
#ifdef PKINIT
krb5_add_et_list(context, initialize_hx_error_table_r);
+#if defined(HEIMDAL_LOCALEDIR)
bindtextdomain(COM_ERR_BINDDOMAIN_hx, HEIMDAL_LOCALEDIR);
#endif
+#endif
}
}
diff --git a/source4/heimdal/lib/krb5/krb5_locl.h b/source4/heimdal/lib/krb5/krb5_locl.h
index 1a490392a9..ced722f2d9 100644
--- a/source4/heimdal/lib/krb5/krb5_locl.h
+++ b/source4/heimdal/lib/krb5/krb5_locl.h
@@ -118,7 +118,7 @@ struct sockaddr_dl;
#define HEIMDAL_TEXTDOMAIN "heimdal_krb5"
-#ifdef LIBINTL
+#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#define N_(x,y) dgettext(HEIMDAL_TEXTDOMAIN, x)
#else
diff --git a/source4/heimdal_build/internal.m4 b/source4/heimdal_build/internal.m4
index b2f64a6825..a48777fab1 100644
--- a/source4/heimdal_build/internal.m4
+++ b/source4/heimdal_build/internal.m4
@@ -69,7 +69,8 @@ AC_CHECK_HEADERS([ \
ttyname.h \
netinet/in.h \
netinet/in6.h \
- netinet6/in6.h
+ netinet6/in6.h \
+ libintl.h
])
AC_CHECK_FUNCS([ \
@@ -169,6 +170,12 @@ SMB_ENABLE(OPENPTY,YES)
SMB_EXT_LIB(OPENPTY,[${OPENPTY_LIBS}],[${OPENPTY_CFLAGS}],[${OPENPTY_CPPFLAGS}],[${OPENPTY_LDFLAGS}])
+AC_CHECK_LIB_EXT(intl, INTL_LIBS, gettext)
+
+SMB_ENABLE(INTL,YES)
+
+SMB_EXT_LIB(INTL, $INTL_LIBS)
+
smb_save_LIBS=$LIBS
RESOLV_LIBS=""
LIBS=""
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index da44c02aa8..a924024160 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -104,7 +104,7 @@ static void ldapsrv_process_message(struct ldapsrv_connection *conn,
bool ret;
msg = call->replies->msg;
- if (!ldap_encode(msg, &b, call)) {
+ if (!ldap_encode(msg, samba_ldap_control_handlers(), &b, call)) {
DEBUG(0,("Failed to encode ldap reply of type %d\n", msg->type));
talloc_free(call);
return;
@@ -150,7 +150,7 @@ static NTSTATUS ldapsrv_decode(void *private_data, DATA_BLOB blob)
return NT_STATUS_NO_MEMORY;
}
- status = ldap_decode(asn1, msg);
+ status = ldap_decode(asn1, samba_ldap_control_handlers(), msg);
if (!NT_STATUS_IS_OK(status)) {
asn1_free(asn1);
return status;
diff --git a/source4/lib/tls/config.m4 b/source4/lib/tls/config.m4
index 0bafc5ddf1..c46a009e3d 100644
--- a/source4/lib/tls/config.m4
+++ b/source4/lib/tls/config.m4
@@ -40,4 +40,6 @@ if test x$use_gnutls = xyes; then
AC_CHECK_TYPES([gnutls_datum_t],,,[#include "gnutls/gnutls.h"])
AC_DEFINE(ENABLE_GNUTLS,1,[Whether we have gnutls support (SSL)])
AC_CHECK_HEADERS(gcrypt.h)
+ AC_CHECK_LIB_EXT(gcrypt, GCRYPT_LIBS, gcry_control)
+ SMB_EXT_LIB(GCRYPT, $GCRYPT_LIBS)
fi
diff --git a/source4/lib/tls/config.mk b/source4/lib/tls/config.mk
index ff1eedfd5d..0e1978cc1b 100644
--- a/source4/lib/tls/config.mk
+++ b/source4/lib/tls/config.mk
@@ -1,5 +1,5 @@
[SUBSYSTEM::LIBTLS]
PUBLIC_DEPENDENCIES = \
- LIBTALLOC GNUTLS LIBSAMBA-HOSTCONFIG samba_socket
+ LIBTALLOC GNUTLS GCRYPT LIBSAMBA-HOSTCONFIG samba_socket
LIBTLS_OBJ_FILES = $(addprefix $(libtlssrcdir)/, tls.o tlscert.o)
diff --git a/source4/libcli/cldap/cldap.c b/source4/libcli/cldap/cldap.c
index 8d2e2e374c..b18ba12b1f 100644
--- a/source4/libcli/cldap/cldap.c
+++ b/source4/libcli/cldap/cldap.c
@@ -108,7 +108,7 @@ static void cldap_socket_recv(struct cldap_socket *cldap)
}
/* this initial decode is used to find the message id */
- status = ldap_decode(asn1, ldap_msg);
+ status = ldap_decode(asn1, NULL, ldap_msg);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to decode ldap message: %s\n", nt_errstr(status)));
talloc_free(tmp_ctx);
@@ -343,7 +343,7 @@ struct cldap_request *cldap_search_send(struct cldap_socket *cldap,
goto failed;
}
- if (!ldap_encode(msg, &req->encoded, req)) {
+ if (!ldap_encode(msg, NULL, &req->encoded, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest->addr, req->dest->port));
goto failed;
@@ -396,7 +396,7 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
msg->type = LDAP_TAG_SearchResultEntry;
msg->r.SearchResultEntry = *io->response;
- if (!ldap_encode(msg, &blob1, req)) {
+ if (!ldap_encode(msg, NULL, &blob1, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest->addr, req->dest->port));
status = NT_STATUS_INVALID_PARAMETER;
@@ -409,7 +409,7 @@ NTSTATUS cldap_reply_send(struct cldap_socket *cldap, struct cldap_reply *io)
msg->type = LDAP_TAG_SearchResultDone;
msg->r.SearchResultDone = *io->result;
- if (!ldap_encode(msg, &blob2, req)) {
+ if (!ldap_encode(msg, NULL, &blob2, req)) {
DEBUG(0,("Failed to encode cldap message to %s:%d\n",
req->dest->addr, req->dest->port));
status = NT_STATUS_INVALID_PARAMETER;
@@ -463,7 +463,7 @@ NTSTATUS cldap_search_recv(struct cldap_request *req,
ldap_msg = talloc(mem_ctx, struct ldap_message);
NT_STATUS_HAVE_NO_MEMORY(ldap_msg);
- status = ldap_decode(req->asn1, ldap_msg);
+ status = ldap_decode(req->asn1, NULL, ldap_msg);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to decode cldap search reply: %s\n", nt_errstr(status)));
talloc_free(req);
@@ -479,7 +479,7 @@ NTSTATUS cldap_search_recv(struct cldap_request *req,
*io->out.response = ldap_msg->r.SearchResultEntry;
/* decode the 2nd part */
- status = ldap_decode(req->asn1, ldap_msg);
+ status = ldap_decode(req->asn1, NULL, ldap_msg);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(2,("Failed to decode cldap search result entry: %s\n", nt_errstr(status)));
talloc_free(req);
diff --git a/source4/libcli/ldap/config.mk b/source4/libcli/ldap/config.mk
index 2708c66b68..f0c0f5295d 100644
--- a/source4/libcli/ldap/config.mk
+++ b/source4/libcli/ldap/config.mk
@@ -1,18 +1,12 @@
[SUBSYSTEM::LIBCLI_LDAP]
PUBLIC_DEPENDENCIES = LIBSAMBA-ERRORS LIBTEVENT LIBPACKET
-PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE samba_socket NDR_SAMR LIBTLS ASN1_UTIL \
- LDAP_ENCODE LIBNDR LP_RESOLVE gensec
+PRIVATE_DEPENDENCIES = LIBCLI_COMPOSITE samba_socket NDR_SAMR LIBTLS \
+ LIBCLI_LDAP_NDR LIBNDR LP_RESOLVE gensec LIBCLI_LDAP_MESSAGE
LIBCLI_LDAP_OBJ_FILES = $(addprefix $(libclisrcdir)/ldap/, \
- ldap.o ldap_client.o ldap_bind.o \
- ldap_msg.o ldap_ildap.o ldap_controls.o)
-
-
-PUBLIC_HEADERS += $(libclisrcdir)/ldap/ldap.h $(libclisrcdir)/ldap/ldap_ndr.h
+ ldap_client.o ldap_bind.o \
+ ldap_ildap.o ldap_controls.o)
+PUBLIC_HEADERS += $(libclisrcdir)/ldap/ldap.h
$(eval $(call proto_header_template,$(libclisrcdir)/ldap/ldap_proto.h,$(LIBCLI_LDAP_OBJ_FILES:.o=.c)))
-[SUBSYSTEM::LDAP_ENCODE]
-PRIVATE_DEPENDENCIES = LIBLDB
-
-LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o
diff --git a/source4/libcli/ldap/ldap.h b/source4/libcli/ldap/ldap.h
index 3d99d6f47d..79cfef2128 100644
--- a/source4/libcli/ldap/ldap.h
+++ b/source4/libcli/ldap/ldap.h
@@ -21,200 +21,11 @@
#ifndef _SMB_LDAP_H_
#define _SMB_LDAP_H_
-#include "libcli/ldap/ldap_errors.h"
-#include "lib/ldb/include/ldb.h"
+#include "../libcli/ldap/ldap_message.h"
#include "librpc/gen_ndr/misc.h"
-enum ldap_request_tag {
- LDAP_TAG_BindRequest = 0,
- LDAP_TAG_BindResponse = 1,
- LDAP_TAG_UnbindRequest = 2,
- LDAP_TAG_SearchRequest = 3,
- LDAP_TAG_SearchResultEntry = 4,
- LDAP_TAG_SearchResultDone = 5,
- LDAP_TAG_ModifyRequest = 6,
- LDAP_TAG_ModifyResponse = 7,
- LDAP_TAG_AddRequest = 8,
- LDAP_TAG_AddResponse = 9,
- LDAP_TAG_DelRequest = 10,
- LDAP_TAG_DelResponse = 11,
- LDAP_TAG_ModifyDNRequest = 12,
- LDAP_TAG_ModifyDNResponse = 13,
- LDAP_TAG_CompareRequest = 14,
- LDAP_TAG_CompareResponse = 15,
- LDAP_TAG_AbandonRequest = 16,
- LDAP_TAG_SearchResultReference = 19,
- LDAP_TAG_ExtendedRequest = 23,
- LDAP_TAG_ExtendedResponse = 24
-};
-
-enum ldap_auth_mechanism {
- LDAP_AUTH_MECH_SIMPLE = 0,
- LDAP_AUTH_MECH_SASL = 3
-};
-
-struct ldap_Result {
- int resultcode;
- const char *dn;
- const char *errormessage;
- const char *referral;
-};
-
-struct ldap_BindRequest {
- int version;
- const char *dn;
- enum ldap_auth_mechanism mechanism;
- union {
- const char *password;
- struct {
- const char *mechanism;
- DATA_BLOB *secblob;/* optional */
- } SASL;
- } creds;
-};
-
-struct ldap_BindResponse {
- struct ldap_Result response;
- union {
- DATA_BLOB *secblob;/* optional */
- } SASL;
-};
-
-struct ldap_UnbindRequest {
- uint8_t __dummy;
-};
-
-enum ldap_scope {
- LDAP_SEARCH_SCOPE_BASE = 0,
- LDAP_SEARCH_SCOPE_SINGLE = 1,
- LDAP_SEARCH_SCOPE_SUB = 2
-};
-
-enum ldap_deref {
- LDAP_DEREFERENCE_NEVER = 0,
- LDAP_DEREFERENCE_IN_SEARCHING = 1,
- LDAP_DEREFERENCE_FINDING_BASE = 2,
- LDAP_DEREFERENCE_ALWAYS
-};
-
-struct ldap_SearchRequest {
- const char *basedn;
- enum ldap_scope scope;
- enum ldap_deref deref;
- uint32_t timelimit;
- uint32_t sizelimit;
- bool attributesonly;
- struct ldb_parse_tree *tree;
- int num_attributes;
- const char * const *attributes;
-};
-
-struct ldap_SearchResEntry {
- const char *dn;
- int num_attributes;
- struct ldb_message_element *attributes;
-};
-
-struct ldap_SearchResRef {
- const char *referral;
-};
-
-enum ldap_modify_type {
- LDAP_MODIFY_NONE = -1,
- LDAP_MODIFY_ADD = 0,
- LDAP_MODIFY_DELETE = 1,
- LDAP_MODIFY_REPLACE = 2
-};
-
-struct ldap_mod {
- enum ldap_modify_type type;
- struct ldb_message_element attrib;
-};
-
-struct ldap_ModifyRequest {
- const char *dn;
- int num_mods;
- struct ldap_mod *mods;
-};
-
-struct ldap_AddRequest {
- const char *dn;
- int num_attributes;
- struct ldb_message_element *attributes;
-};
-
-struct ldap_DelRequest {
- const char *dn;
-};
-
-struct ldap_ModifyDNRequest {
- const char *dn;
- const char *newrdn;
- bool deleteolddn;
- const char *newsuperior;/* optional */
-};
-
-struct ldap_CompareRequest {
- const char *dn;
- const char *attribute;
- DATA_BLOB value;
-};
-
-struct ldap_AbandonRequest {
- uint32_t messageid;
-};
-
-struct ldap_ExtendedRequest {
- const char *oid;
- DATA_BLOB *value;/* optional */
-};
-
-struct ldap_ExtendedResponse {
- struct ldap_Result response;
- const char *oid;/* optional */
- DATA_BLOB *value;/* optional */
-};
-
-union ldap_Request {
- struct ldap_Result GeneralResult;
- struct ldap_BindRequest BindRequest;
- struct ldap_BindResponse BindResponse;
- struct ldap_UnbindRequest UnbindRequest;
- struct ldap_SearchRequest SearchRequest;
- struct ldap_SearchResEntry SearchResultEntry;
- struct ldap_Result SearchResultDone;
- struct ldap_SearchResRef SearchResultReference;
- struct ldap_ModifyRequest ModifyRequest;
- struct ldap_Result ModifyResponse;
- struct ldap_AddRequest AddRequest;
- struct ldap_Result AddResponse;
- struct ldap_DelRequest DelRequest;
- struct ldap_Result DelResponse;
- struct ldap_ModifyDNRequest ModifyDNRequest;
- struct ldap_Result ModifyDNResponse;
- struct ldap_CompareRequest CompareRequest;
- struct ldap_Result CompareResponse;
- struct ldap_AbandonRequest AbandonRequest;
- struct ldap_ExtendedRequest ExtendedRequest;
- struct ldap_ExtendedResponse ExtendedResponse;
-};
-
-
-struct ldap_message {
- int messageid;
- enum ldap_request_tag type;
- union ldap_Request r;
- struct ldb_control **controls;
- bool *controls_decoded;
-};
-
struct tevent_context;
struct cli_credentials;
struct dom_sid;
-struct asn1_data;
-
-struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx);
-NTSTATUS ldap_decode(struct asn1_data *data, struct ldap_message *msg);
-bool ldap_encode(struct ldap_message *msg, DATA_BLOB *result, TALLOC_CTX *mem_ctx);
#endif
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 3e54d7fff0..304a2e1253 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -200,7 +200,7 @@ static NTSTATUS ldap_recv_handler(void *private_data, DATA_BLOB blob)
return NT_STATUS_LDAP(LDAP_PROTOCOL_ERROR);
}
- status = ldap_decode(asn1, msg);
+ status = ldap_decode(asn1, samba_ldap_control_handlers(), msg);
if (!NT_STATUS_IS_OK(status)) {
asn1_free(asn1);
return status;
@@ -608,7 +608,7 @@ _PUBLIC_ struct ldap_request *ldap_request_send(struct ldap_connection *conn,
msg->messageid = req->messageid;
- if (!ldap_encode(msg, &req->data, req)) {
+ if (!ldap_encode(msg, samba_ldap_control_handlers(), &req->data, req)) {
status = NT_STATUS_INTERNAL_ERROR;
goto failed;
}
diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c
index 109837c2bf..7949758a80 100644
--- a/source4/libcli/ldap/ldap_controls.c
+++ b/source4/libcli/ldap/ldap_controls.c
@@ -26,14 +26,9 @@
#include "libcli/ldap/ldap_proto.h"
#include "dsdb/samdb/samdb.h"
-struct control_handler {
- const char *oid;
- bool (*decode)(void *mem_ctx, DATA_BLOB in, void **out);
- bool (*encode)(void *mem_ctx, void *in, DATA_BLOB *out);
-};
-
-static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB attr;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_sort_resp_control *lsrc;
@@ -77,8 +72,9 @@ static bool decode_server_sort_response(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB attr;
DATA_BLOB rule;
struct asn1_data *data = asn1_init(mem_ctx);
@@ -156,8 +152,9 @@ static bool decode_server_sort_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
struct asn1_data *data;
struct ldb_extended_dn_control *ledc;
@@ -196,8 +193,9 @@ static bool decode_extended_dn_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_sd_flags_control *lsdfc;
@@ -229,8 +227,9 @@ static bool decode_sd_flags_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_search_options_control *lsoc;
@@ -262,8 +261,9 @@ static bool decode_search_options_request(void *mem_ctx, DATA_BLOB in, void **ou
return true;
}
-static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB cookie;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_paged_control *lprc;
@@ -310,8 +310,9 @@ static bool decode_paged_results_request(void *mem_ctx, DATA_BLOB in, void **out
return true;
}
-static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB cookie;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_dirsync_control *ldc;
@@ -365,8 +366,9 @@ static bool decode_dirsync_request(void *mem_ctx, DATA_BLOB in, void **out)
/* seem that this controls has 2 forms one in case it is used with
* a Search Request and another when used ina Search Response
*/
-static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB source_attribute;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_asq_control *lac;
@@ -425,7 +427,7 @@ static bool decode_asq_control(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
if (in.length != 0) {
return false;
@@ -434,7 +436,7 @@ static bool decode_domain_scope_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_notification_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_notification_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
if (in.length != 0) {
return false;
@@ -443,7 +445,7 @@ static bool decode_notification_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
if (in.length != 0) {
return false;
@@ -452,7 +454,7 @@ static bool decode_show_deleted_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
if (in.length != 0) {
return false;
@@ -461,7 +463,7 @@ static bool decode_permissive_modify_request(void *mem_ctx, DATA_BLOB in, void *
return true;
}
-static bool decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
if (in.length != 0) {
return false;
@@ -470,8 +472,9 @@ static bool decode_manageDSAIT_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB assertion_value, context_id;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_vlv_req_control *lvrc;
@@ -582,8 +585,9 @@ static bool decode_vlv_request(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_vlv_response(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
DATA_BLOB context_id;
struct asn1_data *data = asn1_init(mem_ctx);
struct ldb_vlv_resp_control *lvrc;
@@ -1132,8 +1136,9 @@ static bool encode_openldap_dereference(void *mem_ctx, void *in, DATA_BLOB *out)
return true;
}
-static bool decode_openldap_dereference(void *mem_ctx, DATA_BLOB in, void **out)
+static bool decode_openldap_dereference(void *mem_ctx, DATA_BLOB in, void *_out)
{
+ void **out = (void **)_out;
struct asn1_data *data = asn1_init(mem_ctx);
struct dsdb_openldap_dereference_result_control *control;
struct dsdb_openldap_dereference_result **r = NULL;
@@ -1201,7 +1206,7 @@ static bool decode_openldap_dereference(void *mem_ctx, DATA_BLOB in, void **out)
return true;
}
-struct control_handler ldap_known_controls[] = {
+static const struct ldap_control_handler ldap_known_controls[] = {
{ "1.2.840.113556.1.4.319", decode_paged_results_request, encode_paged_results_request },
{ "1.2.840.113556.1.4.529", decode_extended_dn_request, encode_extended_dn_request },
{ "1.2.840.113556.1.4.473", decode_server_sort_request, encode_server_sort_request },
@@ -1225,121 +1230,8 @@ struct control_handler ldap_known_controls[] = {
{ NULL, NULL, NULL }
};
-bool ldap_decode_control_value(void *mem_ctx, DATA_BLOB value, struct ldb_control *ctrl)
+const struct ldap_control_handler *samba_ldap_control_handlers(void)
{
- int i;
-
- for (i = 0; ldap_known_controls[i].oid != NULL; i++) {
- if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
- if (!ldap_known_controls[i].decode || !ldap_known_controls[i].decode(mem_ctx, value, &ctrl->data)) {
- return false;
- }
- break;
- }
- }
- if (ldap_known_controls[i].oid == NULL) {
- return false;
- }
-
- return true;
+ return ldap_known_controls;
}
-bool ldap_decode_control_wrapper(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl, DATA_BLOB *value)
-{
- DATA_BLOB oid;
-
- if (!asn1_start_tag(data, ASN1_SEQUENCE(0))) {
- return false;
- }
-
- if (!asn1_read_OctetString(data, mem_ctx, &oid)) {
- return false;
- }
- ctrl->oid = talloc_strndup(mem_ctx, (char *)oid.data, oid.length);
- if (!ctrl->oid) {
- return false;
- }
-
- if (asn1_peek_tag(data, ASN1_BOOLEAN)) {
- bool critical;
- if (!asn1_read_BOOLEAN(data, &critical)) {
- return false;
- }
- ctrl->critical = critical;
- } else {
- ctrl->critical = false;
- }
-
- ctrl->data = NULL;
-
- if (!asn1_peek_tag(data, ASN1_OCTET_STRING)) {
- *value = data_blob(NULL, 0);
- goto end_tag;
- }
-
- if (!asn1_read_OctetString(data, mem_ctx, value)) {
- return false;
- }
-
-end_tag:
- if (!asn1_end_tag(data)) {
- return false;
- }
-
- return true;
-}
-
-bool ldap_encode_control(void *mem_ctx, struct asn1_data *data, struct ldb_control *ctrl)
-{
- DATA_BLOB value;
- int i;
-
- for (i = 0; ldap_known_controls[i].oid != NULL; i++) {
- if (strcmp(ldap_known_controls[i].oid, ctrl->oid) == 0) {
- if (!ldap_known_controls[i].encode) {
- if (ctrl->critical) {
- return false;
- } else {
- /* not encoding this control */
- return true;
- }
- }
- if (!ldap_known_controls[i].encode(mem_ctx, ctrl->data, &value)) {
- return false;
- }
- break;
- }
- }
- if (ldap_known_controls[i].oid == NULL) {
- return false;
- }
-
- if (!asn1_push_tag(data, ASN1_SEQUENCE(0))) {
- return false;
- }
-
- if (!asn1_write_OctetString(data, ctrl->oid, strlen(ctrl->oid))) {
- return false;
- }
-
- if (ctrl->critical) {
- if (!asn1_write_BOOLEAN(data, ctrl->critical)) {
- return false;
- }
- }
-
- if (!ctrl->data) {
- goto pop_tag;
- }
-
- if (!asn1_write_OctetString(data, value.data, value.length)) {
- return false;
- }
-
-pop_tag:
- if (!asn1_pop_tag(data)) {
- return false;
- }
-
- return true;
-}
diff --git a/source4/libcli/ldap/ldap_msg.c b/source4/libcli/ldap/ldap_msg.c
deleted file mode 100644
index e45213c004..0000000000
--- a/source4/libcli/ldap/ldap_msg.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Unix SMB/CIFS mplementation.
-
- LDAP protocol helper functions for SAMBA
-
- Copyright (C) Andrew Tridgell 2005
- Copyright (C) Volker Lendecke 2004
-
- 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 "libcli/ldap/ldap.h"
-#include "libcli/ldap/ldap_client.h"
-#include "libcli/ldap/ldap_proto.h"
-
-
-_PUBLIC_ struct ldap_message *new_ldap_message(TALLOC_CTX *mem_ctx)
-{
- return talloc_zero(mem_ctx, struct ldap_message);
-}
-
-
-bool add_value_to_attrib(TALLOC_CTX *mem_ctx, struct ldb_val *value,
- struct ldb_message_element *attrib)
-{
- attrib->values = talloc_realloc(mem_ctx,
- attrib->values,
- DATA_BLOB,
- attrib->num_values+1);
- if (attrib->values == NULL)
- return false;
-
- attrib->values[attrib->num_values].data = talloc_steal(attrib->values,
- value->data);
- attrib->values[attrib->num_values].length = value->length;
- attrib->num_values += 1;
- return true;
-}
-
-bool add_attrib_to_array_talloc(TALLOC_CTX *mem_ctx,
- const struct ldb_message_element *attrib,
- struct ldb_message_element **attribs,
- int *num_attribs)
-{
- *attribs = talloc_realloc(mem_ctx,
- *attribs,
- struct ldb_message_element,
- *num_attribs+1);
-
- if (*attribs == NULL)
- return false;
-
- (*attribs)[*num_attribs] = *attrib;
- talloc_steal(*attribs, attrib->values);
- talloc_steal(*attribs, attrib->name);
- *num_attribs += 1;
- return true;
-}
-
-bool add_mod_to_array_talloc(TALLOC_CTX *mem_ctx,
- struct ldap_mod *mod,
- struct ldap_mod **mods,
- int *num_mods)
-{
- *mods = talloc_realloc(mem_ctx, *mods, struct ldap_mod, (*num_mods)+1);
-
- if (*mods == NULL)
- return false;
-
- (*mods)[*num_mods] = *mod;
- *num_mods += 1;
- return true;
-}
-
diff --git a/source4/libcli/util/nterr.c b/source4/libcli/util/nterr.c
index 8371837dcb..4e7cdf5c3a 100644
--- a/source4/libcli/util/nterr.c
+++ b/source4/libcli/util/nterr.c
@@ -20,7 +20,7 @@
/* NT error codes. please read nterr.h */
#include "includes.h"
-#include "libcli/ldap/ldap_errors.h"
+#include "../libcli/ldap/ldap_errors.h"
#undef strcasecmp
typedef struct
diff --git a/source4/main.mk b/source4/main.mk
index 04f7a36a5f..ee2018fb69 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -50,3 +50,5 @@ mkinclude kdc/config.mk
mkinclude ../lib/smbconf/config.mk
mkinclude ../lib/async_req/config.mk
mkinclude ../libcli/security/config.mk
+mkinclude ../libcli/ldap/config.mk
+
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index 0fa638e863..f1c063ed90 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -47,7 +47,8 @@ struct server_pipe_state {
static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct netr_ServerReqChallenge *r)
{
- struct server_pipe_state *pipe_state = dce_call->context->private_data;
+ struct server_pipe_state *pipe_state =
+ (struct server_pipe_state *)dce_call->context->private_data;
ZERO_STRUCTP(r->out.return_credentials);
@@ -76,7 +77,8 @@ static NTSTATUS dcesrv_netr_ServerReqChallenge(struct dcesrv_call_state *dce_cal
static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct netr_ServerAuthenticate3 *r)
{
- struct server_pipe_state *pipe_state = dce_call->context->private_data;
+ struct server_pipe_state *pipe_state =
+ (struct server_pipe_state *)dce_call->context->private_data;
struct creds_CredentialState *creds;
void *sam_ctx;
struct samr_Password *mach_pwd;
@@ -148,7 +150,9 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
}
/* pull the user attributes */
- num_records = gendb_search(sam_ctx, mem_ctx, NULL, &msgs, trust_dom_attrs,
+ num_records = gendb_search((struct ldb_context *)sam_ctx,
+ mem_ctx, NULL, &msgs,
+ trust_dom_attrs,
"(&(trustPartner=%s)(objectclass=trustedDomain))",
encoded_account);
@@ -179,7 +183,8 @@ static NTSTATUS dcesrv_netr_ServerAuthenticate3(struct dcesrv_call_state *dce_ca
}
/* pull the user attributes */
- num_records = gendb_search(sam_ctx, mem_ctx, NULL, &msgs, attrs,
+ num_records = gendb_search((struct ldb_context *)sam_ctx, mem_ctx,
+ NULL, &msgs, attrs,
"(&(sAMAccountName=%s)(objectclass=user))",
ldb_binary_encode_string(mem_ctx, account_name));
@@ -848,13 +853,14 @@ static WERROR dcesrv_netr_GetDcName(struct dcesrv_call_state *dce_call, TALLOC_C
return WERR_DS_SERVICE_UNAVAILABLE;
}
- domain_dn = samdb_domain_to_dn(sam_ctx, mem_ctx,
+ domain_dn = samdb_domain_to_dn((struct ldb_context *)sam_ctx, mem_ctx,
r->in.domainname);
if (domain_dn == NULL) {
return WERR_DS_SERVICE_UNAVAILABLE;
}
- ret = gendb_search_dn(sam_ctx, mem_ctx, domain_dn, &res, attrs);
+ ret = gendb_search_dn((struct ldb_context *)sam_ctx, mem_ctx,
+ domain_dn, &res, attrs);
if (ret != 1) {
return WERR_NO_SUCH_DOMAIN;
}
@@ -1218,13 +1224,15 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
r->in.domain_name = lp_realm(dce_call->conn->dce_ctx->lp_ctx);
}
- domain_dn = samdb_dns_domain_to_dn(sam_ctx, mem_ctx,
+ domain_dn = samdb_dns_domain_to_dn((struct ldb_context *)sam_ctx,
+ mem_ctx,
r->in.domain_name);
if (domain_dn == NULL) {
return WERR_DS_SERVICE_UNAVAILABLE;
}
- ret = gendb_search_dn(sam_ctx, mem_ctx, domain_dn, &res, attrs);
+ ret = gendb_search_dn((struct ldb_context *)sam_ctx, mem_ctx,
+ domain_dn, &res, attrs);
if (ret != 1) {
return WERR_NO_SUCH_DOMAIN;
}
@@ -1377,9 +1385,11 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
return WERR_GENERAL_FAILURE;
}
- partitions_basedn = samdb_partitions_dn(sam_ctx, mem_ctx);
+ partitions_basedn = samdb_partitions_dn((struct ldb_context *)sam_ctx,
+ mem_ctx);
- ret = gendb_search_dn(sam_ctx, mem_ctx, NULL, &dom_res, dom_attrs);
+ ret = gendb_search_dn((struct ldb_context *)sam_ctx, mem_ctx, NULL,
+ &dom_res, dom_attrs);
if (ret == -1) {
return WERR_GENERAL_FAILURE;
}
@@ -1387,7 +1397,8 @@ static WERROR dcesrv_netr_DsrEnumerateDomainTrusts(struct dcesrv_call_state *dce
return WERR_GENERAL_FAILURE;
}
- ret = gendb_search(sam_ctx, mem_ctx, partitions_basedn, &ref_res, ref_attrs,
+ ret = gendb_search((struct ldb_context *)sam_ctx, mem_ctx,
+ partitions_basedn, &ref_res, ref_attrs,
"(&(objectClass=crossRef)(ncName=%s))",
ldb_dn_get_linearized(dom_res[0]->dn));
if (ret == -1) {
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 5bcb23a5d4..0aa84ec6db 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -4,6 +4,7 @@
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
# Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
+# Copyright (C) Oliver Liebel <oliver@itc.li> 2008-2009
#
# Based on the original in EJS:
# Copyright (C) Andrew Tridgell <tridge@samba.org> 2005
@@ -26,6 +27,7 @@
from base64 import b64encode
import os
+import sys
import pwd
import grp
import time
@@ -96,6 +98,9 @@ class ProvisionPaths(object):
self.olmmron = None
self.olmmrserveridsconf = None
self.olmmrsyncreplconf = None
+ self.olcdir = None
+ self.olslaptest = None
+ self.olcseedldif = None
class ProvisionNames(object):
@@ -268,6 +273,10 @@ def provision_paths_from_lp(lp, dnsdomain):
"mmr_serverids.conf")
paths.olmmrsyncreplconf = os.path.join(paths.ldapdir,
"mmr_syncrepl.conf")
+ paths.olcdir = os.path.join(paths.ldapdir,
+ "slapd.d")
+ paths.olcseedldif = os.path.join(paths.ldapdir,
+ "olc_seed.ldif")
paths.hklm = "hklm.ldb"
paths.hkcr = "hkcr.ldb"
paths.hkcu = "hkcu.ldb"
@@ -1178,7 +1187,7 @@ def provision_backend(setup_dir=None, message=None,
rootdn=None, domaindn=None, schemadn=None, configdn=None,
domain=None, hostname=None, adminpass=None, root=None, serverrole=None,
ldap_backend_type=None, ldap_backend_port=None,
- ol_mmr_urls=None):
+ ol_mmr_urls=None,ol_olc=None,ol_slaptest=None):
def setup_path(file):
return os.path.join(setup_dir, file)
@@ -1205,6 +1214,19 @@ def provision_backend(setup_dir=None, message=None,
make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole,
targetdir)
+ # openldap-online-configuration: validation of olc and slaptest
+ if ol_olc == "yes" and ol_slaptest is None:
+ sys.exit("Warning: OpenLDAP-Online-Configuration cant be setup without path to slaptest-Binary!")
+
+ if ol_olc == "yes" and ol_slaptest is not None:
+ ol_slaptest = ol_slaptest + "/slaptest"
+ if not os.path.exists(ol_slaptest):
+ message (ol_slaptest)
+ sys.exit("Warning: Given Path to slaptest-Binary does not exist!")
+ ###
+
+
+
lp = param.LoadParm()
lp.load(smbconf)
@@ -1306,19 +1328,20 @@ def provision_backend(setup_dir=None, message=None,
mmr_syncrepl_schema_config = ""
mmr_syncrepl_config_config = ""
mmr_syncrepl_user_config = ""
-
+
+
if ol_mmr_urls is not None:
# For now, make these equal
mmr_pass = adminpass
- url_list=filter(None,ol_mmr_urls.split(' '))
+ url_list=filter(None,ol_mmr_urls.split(' '))
if (len(url_list) == 1):
url_list=filter(None,ol_mmr_urls.split(','))
mmr_on_config = "MirrorMode On"
mmr_replicator_acl = " by dn=cn=replicator,cn=samba read"
- serverid=0
+ serverid=0
for url in url_list:
serverid=serverid+1
mmr_serverids_config += read_and_sub_file(setup_path("mmr_serverids.conf"),
@@ -1327,25 +1350,67 @@ def provision_backend(setup_dir=None, message=None,
rid=serverid*10
rid=rid+1
mmr_syncrepl_schema_config += read_and_sub_file(setup_path("mmr_syncrepl.conf"),
- { "RID" : str(rid),
- "MMRDN": names.schemadn,
- "LDAPSERVER" : url,
+ { "RID" : str(rid),
+ "MMRDN": names.schemadn,
+ "LDAPSERVER" : url,
"MMR_PASSWORD": mmr_pass})
rid=rid+1
mmr_syncrepl_config_config += read_and_sub_file(setup_path("mmr_syncrepl.conf"),
- { "RID" : str(rid),
- "MMRDN": names.configdn,
- "LDAPSERVER" : url,
+ { "RID" : str(rid),
+ "MMRDN": names.configdn,
+ "LDAPSERVER" : url,
"MMR_PASSWORD": mmr_pass})
rid=rid+1
mmr_syncrepl_user_config += read_and_sub_file(setup_path("mmr_syncrepl.conf"),
- { "RID" : str(rid),
- "MMRDN": names.domaindn,
- "LDAPSERVER" : url,
+ { "RID" : str(rid),
+ "MMRDN": names.domaindn,
+ "LDAPSERVER" : url,
"MMR_PASSWORD": mmr_pass })
+ # olc = yes?
+ olc_config_pass = ""
+ olc_config_acl = ""
+ olc_syncrepl_config = ""
+ olc_mmr_config = ""
+ if ol_olc == "yes":
+ olc_config_pass += read_and_sub_file(setup_path("olc_pass.conf"),
+ { "OLC_PW": adminpass })
+ olc_config_acl += read_and_sub_file(setup_path("olc_acl.conf"),{})
+
+ # if olc = yes + mmr = yes, generate cn=config-replication directives
+ # and olc_seed.lif for the other mmr-servers
+ if ol_olc == "yes" and ol_mmr_urls is not None:
+ serverid=0
+ olc_serverids_config = ""
+ olc_syncrepl_config = ""
+ olc_syncrepl_seed_config = ""
+ olc_mmr_config = ""
+ olc_mmr_config += read_and_sub_file(setup_path("olc_mmr.conf"),{})
+ rid=1000
+ for url in url_list:
+ serverid=serverid+1
+ olc_serverids_config += read_and_sub_file(setup_path("olc_serverid.conf"),
+ { "SERVERID" : str(serverid),
+ "LDAPSERVER" : url })
+
+ rid=rid+1
+ olc_syncrepl_config += read_and_sub_file(setup_path("olc_syncrepl.conf"),
+ { "RID" : str(rid),
+ "LDAPSERVER" : url,
+ "MMR_PASSWORD": adminpass})
+
+ olc_syncrepl_seed_config += read_and_sub_file(setup_path("olc_syncrepl_seed.conf"),
+ { "RID" : str(rid),
+ "LDAPSERVER" : url})
+
+ setup_file(setup_path("olc_seed.ldif"), paths.olcseedldif,
+ {"OLC_SERVER_ID_CONF": olc_serverids_config,
+ "OLC_PW": adminpass,
+ "OLC_SYNCREPL_CONF": olc_syncrepl_seed_config})
+
+ # end olc
setup_file(setup_path("slapd.conf"), paths.slapdconf,
{"DNSDOMAIN": names.dnsdomain,
@@ -1360,6 +1425,10 @@ def provision_backend(setup_dir=None, message=None,
"MMR_SYNCREPL_SCHEMA_CONFIG": mmr_syncrepl_schema_config,
"MMR_SYNCREPL_CONFIG_CONFIG": mmr_syncrepl_config_config,
"MMR_SYNCREPL_USER_CONFIG": mmr_syncrepl_user_config,
+ "OLC_CONFIG_PASS": olc_config_pass,
+ "OLC_SYNCREPL_CONFIG": olc_syncrepl_config,
+ "OLC_CONFIG_ACL": olc_config_acl,
+ "OLC_MMR_CONFIG": olc_mmr_config,
"REFINT_CONFIG": refint_config})
setup_file(setup_path("modules.conf"), paths.modulesconf,
{"REALM": names.realm})
@@ -1382,14 +1451,13 @@ def provision_backend(setup_dir=None, message=None,
"LDAPTIME": timestring(int(time.time()))} )
if ol_mmr_urls is not None:
- setup_file(setup_path("cn=replicator.ldif"),
+ setup_file(setup_path("cn=replicator.ldif"),
os.path.join(paths.ldapdir, "db", "samba", "cn=samba", "cn=replicator.ldif"),
{"MMR_PASSWORD_B64": b64encode(mmr_pass),
"UUID": str(uuid.uuid4()),
"LDAPTIME": timestring(int(time.time()))} )
-
mapping = "schema-map-openldap-2.3"
backend_schema = "backend-schema.schema"
@@ -1399,7 +1467,18 @@ def provision_backend(setup_dir=None, message=None,
else:
server_port_string = ""
- slapdcommand="Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri + server_port_string
+ if ol_olc != "yes" and ol_mmr_urls is None:
+ slapdcommand="Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h " + ldapi_uri + server_port_string
+
+ if ol_olc == "yes" and ol_mmr_urls is None:
+ slapdcommand="Start slapd with: slapd -F " + paths.olcdir + " -h \"" + ldapi_uri + " ldap://<FQHN>:<PORT>\""
+
+ if ol_olc != "yes" and ol_mmr_urls is not None:
+ slapdcommand="Start slapd with: slapd -f " + paths.ldapdir + "/slapd.conf -h \"" + ldapi_uri + " ldap://<FQHN>:<PORT>\""
+
+ if ol_olc == "yes" and ol_mmr_urls is not None:
+ slapdcommand="Start slapd with: slapd -F " + paths.olcdir + " -h \"" + ldapi_uri + " ldap://<FQHN>:<PORT>\""
+
ldapuser = "--username=samba-admin"
@@ -1421,6 +1500,8 @@ def provision_backend(setup_dir=None, message=None,
message("LDAP admin password: %s" % adminpass)
message(slapdcommand)
+ if ol_olc == "yes" or ol_mmr_urls is not None:
+ message("Attention to slapd-Port: <PORT> must be different than 389!")
assert isinstance(ldap_backend_type, str)
assert isinstance(ldapuser, str)
assert isinstance(adminpass, str)
@@ -1437,6 +1518,18 @@ def provision_backend(setup_dir=None, message=None,
message("Run provision with: " + " ".join(args))
+ # if --ol-olc=yes, generate online-configuration in ../private/ldap/slapd.d
+ if ol_olc == "yes":
+ if not os.path.isdir(paths.olcdir):
+ os.makedirs(paths.olcdir, 0770)
+ paths.olslaptest = str(ol_slaptest)
+ olc_command = paths.olslaptest + " -f" + paths.slapdconf + " -F" + paths.olcdir + " >/dev/null 2>&1"
+ os.system(olc_command)
+ os.remove(paths.slapdconf)
+ # use line below for debugging during olc-conversion with slaptest, instead of olc_command above
+ #olc_command = paths.olslaptest + " -f" + paths.slapdconf + " -F" + paths.olcdir"
+
+
def create_phpldapadmin_config(path, setup_path, ldapi_uri):
"""Create a PHP LDAP admin configuration file.
diff --git a/source4/setup/DB_CONFIG b/source4/setup/DB_CONFIG
index b4d2bfa868..74bb09d800 100644
--- a/source4/setup/DB_CONFIG
+++ b/source4/setup/DB_CONFIG
@@ -1,17 +1,6 @@
-#
-# Set the database in memory cache size.
-#
set_cachesize 0 524288 0
-
-#
-# Set log values.
-#
set_lg_regionmax 104857
set_lg_max 1048576
set_lg_bsize 209715
set_lg_dir ${LDAPDBDIR}/bdb-logs
-
-#
-# Set temporary file creation directory.
-#
set_tmp_dir ${LDAPDBDIR}/tmp
diff --git a/source4/setup/mmr_serverids.conf b/source4/setup/mmr_serverids.conf
index c6d14010b4..e4daf2028a 100644
--- a/source4/setup/mmr_serverids.conf
+++ b/source4/setup/mmr_serverids.conf
@@ -1,2 +1 @@
-# Generated from template mmr_serverids.conf
ServerID ${SERVERID} "${LDAPSERVER}"
diff --git a/source4/setup/olc_acl.conf b/source4/setup/olc_acl.conf
new file mode 100644
index 0000000000..c248b30fb5
--- /dev/null
+++ b/source4/setup/olc_acl.conf
@@ -0,0 +1,4 @@
+access to dn.sub="cn=config"
+ by dn="cn=samba-admin,cn=samba" write
+ by dn="cn=replicator,cn=samba" read
+
diff --git a/source4/setup/olc_mmr.conf b/source4/setup/olc_mmr.conf
new file mode 100644
index 0000000000..2f60df1421
--- /dev/null
+++ b/source4/setup/olc_mmr.conf
@@ -0,0 +1,3 @@
+overlay syncprov
+MirrorMode on
+
diff --git a/source4/setup/olc_pass.conf b/source4/setup/olc_pass.conf
new file mode 100644
index 0000000000..4c66c1c43f
--- /dev/null
+++ b/source4/setup/olc_pass.conf
@@ -0,0 +1,3 @@
+database config
+rootdn cn=config
+
diff --git a/source4/setup/olc_seed.ldif b/source4/setup/olc_seed.ldif
new file mode 100644
index 0000000000..afc3abe5a0
--- /dev/null
+++ b/source4/setup/olc_seed.ldif
@@ -0,0 +1,16 @@
+dn: cn=config
+objectClass: olcGlobal
+cn: config
+${OLC_SERVER_ID_CONF}
+
+dn: olcDatabase={0}config,cn=config
+objectClass: olcDatabaseConfig
+olcDatabase: {0}config
+olcRootDN: cn=config
+olcRootPW: ${OLC_PW}
+${OLC_SYNCREPL_CONF}olcMirrorMode: TRUE
+
+dn: olcOverlay=syncprov,olcDatabase={0}config,cn=config
+objectClass: olcSyncProvConfig
+olcOverlay: syncprov
+
diff --git a/source4/setup/olc_serverid.conf b/source4/setup/olc_serverid.conf
new file mode 100644
index 0000000000..3d28acbfb4
--- /dev/null
+++ b/source4/setup/olc_serverid.conf
@@ -0,0 +1 @@
+olcServerID: ${SERVERID} "${LDAPSERVER}"
diff --git a/source4/setup/olc_syncrepl.conf b/source4/setup/olc_syncrepl.conf
new file mode 100644
index 0000000000..fd7a58d03b
--- /dev/null
+++ b/source4/setup/olc_syncrepl.conf
@@ -0,0 +1,13 @@
+# Generated from template olc_syncrepl.conf
+
+syncrepl rid=${RID}
+ provider="${LDAPSERVER}"
+ searchbase="cn=config"
+ filter="(!(olcDatabase={0}config))"
+ type=refreshAndPersist
+ retry="10 +"
+ bindmethod=sasl
+ saslmech=DIGEST-MD5
+ authcid="replicator"
+ credentials="${MMR_PASSWORD}"
+
diff --git a/source4/setup/olc_syncrepl_seed.conf b/source4/setup/olc_syncrepl_seed.conf
new file mode 100644
index 0000000000..1833fb9228
--- /dev/null
+++ b/source4/setup/olc_syncrepl_seed.conf
@@ -0,0 +1,5 @@
+olcSyncRepl: rid=${RID} provider="${LDAPSERVER}"
+ binddn="cn=config" bindmethod=sasl saslmech=DIGEST-MD5
+ authcid="replicator" credentials="linux"
+ searchbase="cn=config" filter="(!(olcDatabase={0}config))"
+ type=refreshAndPersist retry="10 +"
diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend
index eca209cb18..28e73ae302 100755
--- a/source4/setup/provision-backend
+++ b/source4/setup/provision-backend
@@ -4,6 +4,7 @@
# provision a Samba4 server
# Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2007-2008
# Copyright (C) Andrew Bartlett <abartlet@samba.org> 2008
+# Copyright (C) Oliver Liebel <oliver@itc.li> 2008-2009
#
# Based on the original in EJS:
# Copyright (C) Andrew Tridgell 2005
@@ -65,8 +66,12 @@ parser.add_option("--server-role", type="choice", metavar="ROLE",
parser.add_option("--targetdir", type="string", metavar="DIR",
help="Set target directory")
parser.add_option("--ol-mmr-urls", type="string", metavar="LDAPSERVER",
- help="List of LDAP-URLS [ ldap://<FQDN>:port/ (where port != 389) ] separated with whitespaces for use with OpenLDAP-MMR")
-
+ help="List of LDAP-URLS [ ldap://<FQHN>:<PORT>/ (where <PORT> has to be different from 389!) ] separated with whitespaces for use with OpenLDAP-MMR (Multi-Master-Replication)")
+parser.add_option("--ol-olc", type="choice", metavar="OPENLDAP-OLC",
+ help="To setup OpenLDAP-Backend with Online-Configuration [slapd.d] choose 'yes'. Note: Only OpenLDAP-Versions greater or equal 2.4.15 should be used!",
+ choices=["yes", "no"])
+parser.add_option("--ol-slaptest", type="string", metavar="SLAPTEST-PATH",
+ help="Path to slaptest-binary [e.g.:'/usr/local/sbin']. Only for use with --ol-olc='yes'")
opts = parser.parse_args()[0]
@@ -103,5 +108,7 @@ provision_backend(setup_dir=setup_dir, message=message, smbconf=smbconf, targetd
root=opts.root, serverrole=server_role,
ldap_backend_type=opts.ldap_backend_type,
ldap_backend_port=opts.ldap_backend_port,
- ol_mmr_urls=opts.ol_mmr_urls)
+ ol_mmr_urls=opts.ol_mmr_urls,
+ ol_olc=opts.ol_olc,
+ ol_slaptest=opts.ol_slaptest)
diff --git a/source4/setup/slapd.conf b/source4/setup/slapd.conf
index 506dc504b4..09dffbbfa3 100644
--- a/source4/setup/slapd.conf
+++ b/source4/setup/slapd.conf
@@ -7,7 +7,6 @@ sizelimit unlimited
${MMR_SERVERIDS_CONFIG}
-
include ${LDAPDIR}/backend-schema.schema
pidfile ${LDAPDIR}/slapd.pid
@@ -63,6 +62,13 @@ directory ${LDAPDIR}/db/samba
rootdn cn=Manager,cn=Samba
########################################
+## olc - configuration ###
+${OLC_CONFIG_PASS}
+${OLC_SYNCREPL_CONFIG}
+${OLC_MMR_CONFIG}
+${OLC_CONFIG_ACL}
+
+########################################
### cn=schema ###
database hdb
suffix ${SCHEMADN}
@@ -78,10 +84,10 @@ index cn eq
index entryUUID,entryCSN eq
#syncprov is stable in OpenLDAP 2.3, and available in 2.2.
-#We only need this for the contextCSN attribute anyway....
+#We need this for the contextCSN attribute and mmr.
overlay syncprov
syncprov-sessionlog 100
-# syncprov-checkpoint 100 10
+syncprov-checkpoint 100 10
### Multimaster-Replication of cn=schema Subcontext ###
@@ -107,10 +113,10 @@ index cn eq
index entryUUID,entryCSN eq
#syncprov is stable in OpenLDAP 2.3, and available in 2.2.
-#We only need this for the contextCSN attribute anyway....
+#We need this for the contextCSN attribute and mmr.
overlay syncprov
syncprov-sessionlog 100
-# syncprov-checkpoint 100 10
+syncprov-checkpoint 100 10
### Multimaster-Replication of cn=config Subcontext ###
${MMR_SYNCREPL_CONFIG_CONFIG}
@@ -139,10 +145,10 @@ index cn eq
index entryUUID,entryCSN eq
#syncprov is stable in OpenLDAP 2.3, and available in 2.2.
-#We only need this for the contextCSN attribute anyway....
+#We need this for the contextCSN attribute and mmr.
overlay syncprov
syncprov-sessionlog 100
-# syncprov-checkpoint 100 10
+syncprov-checkpoint 100 10
### Multimaster-Replication of cn=user/base-dn context ###
${MMR_SYNCREPL_USER_CONFIG}
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 0622e0809d..bf87bd224f 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -1535,6 +1535,121 @@ static bool test_stream_large_streaminfo(struct torture_context *tctx,
return ret;
}
+/* Test the effect of setting attributes on a stream. */
+static bool test_stream_attributes(struct torture_context *tctx,
+ struct smbcli_state *cli,
+ TALLOC_CTX *mem_ctx)
+{
+ bool ret = true;
+ NTSTATUS status;
+ union smb_open io;
+ const char *fname = BASEDIR "\\stream_attr.txt";
+ const char *stream = "Stream One:$DATA";
+ const char *fname_stream;
+ int fnum = -1;
+ union smb_fileinfo finfo;
+ union smb_setfileinfo sfinfo;
+ time_t basetime = (time(NULL) - 86400) & ~1;
+
+ printf ("(%s) testing attribute setting on stream\n", __location__);
+
+ fname_stream = talloc_asprintf(mem_ctx, "%s:%s", fname, stream);
+
+ /* Create a file with a stream with attribute FILE_ATTRIBUTE_ARCHIVE. */
+ ret = create_file_with_stream(tctx, cli, mem_ctx, fname,
+ fname_stream);
+ if (!ret) {
+ goto done;
+ }
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_BASIC_INFO;
+ finfo.generic.in.file.path = fname;
+ status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ if (finfo.basic_info.out.attrib != FILE_ATTRIBUTE_ARCHIVE) {
+ printf("(%s) Incorrect attrib %x - should be %x\n", \
+ __location__, (unsigned int)finfo.basic_info.out.attrib,
+ (unsigned int)FILE_ATTRIBUTE_ARCHIVE);
+ ret = false;
+ goto done;
+ }
+
+ /* Now open the stream name. */
+
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.access_mask = (SEC_FILE_READ_DATA|SEC_FILE_WRITE_DATA|
+ SEC_FILE_APPEND_DATA|SEC_STD_READ_CONTROL|SEC_FILE_WRITE_ATTRIBUTE);
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.file_attr = 0;
+ io.ntcreatex.in.share_access = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname_stream;
+
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ fnum = io.ntcreatex.out.file.fnum;
+
+ /* Change the attributes + time on the stream fnum. */
+ ZERO_STRUCT(sfinfo);
+ sfinfo.basic_info.in.attrib = FILE_ATTRIBUTE_READONLY;
+ unix_to_nt_time(&sfinfo.basic_info.in.write_time, basetime);
+
+ sfinfo.generic.level = RAW_SFILEINFO_BASIC_INFORMATION;
+ sfinfo.generic.in.file.fnum = fnum;
+ status = smb_raw_setfileinfo(cli->tree, &sfinfo);
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_OK)) {
+ printf("(%s) %s - %s (should be %s)\n", __location__, "SETATTR",
+ nt_errstr(status), nt_errstr(NT_STATUS_OK));
+ ret = false;
+ goto done;
+ }
+
+ smbcli_close(cli->tree, fnum);
+ fnum = -1;
+
+ ZERO_STRUCT(finfo);
+ finfo.generic.level = RAW_FILEINFO_ALL_INFO;
+ finfo.generic.in.file.path = fname;
+ status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("(%s) %s pathinfo - %s\n", __location__, "SETATTRE", nt_errstr(status));
+ ret = false;
+ goto done;
+ }
+
+ if (finfo.all_info.out.attrib != FILE_ATTRIBUTE_READONLY) {
+ printf("(%s) attrib incorrect. Was 0x%x, should be 0x%x\n",
+ __location__,
+ (unsigned int)finfo.all_info.out.attrib,
+ (unsigned int)FILE_ATTRIBUTE_READONLY);
+ ret = false;
+ goto done;
+ }
+
+ if (nt_time_to_unix(finfo.all_info.out.write_time) != basetime) {
+ printf("(%s) time incorrect.\n",
+ __location__);
+ ret = false;
+ goto done;
+ }
+
+ done:
+
+ if (fnum != -1) {
+ smbcli_close(cli->tree, fnum);
+ }
+ smbcli_unlink(cli->tree, fname);
+ return ret;
+}
+
/*
basic testing of streams calls
*/
@@ -1566,6 +1681,10 @@ bool torture_raw_streams(struct torture_context *torture,
smb_raw_exit(cli->session);
ret &= test_stream_create_disposition(torture, cli, torture);
smb_raw_exit(cli->session);
+
+ ret &= test_stream_attributes(torture, cli, torture);
+ smb_raw_exit(cli->session);
+
/* ret &= test_stream_large_streaminfo(torture, cli, torture); */
/* smb_raw_exit(cli->session); */
diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c
index ba5296fd97..d934403ade 100644
--- a/source4/utils/net/net.c
+++ b/source4/utils/net/net.c
@@ -107,7 +107,7 @@ static const struct net_functable net_functable[] = {
{"vampire", "join and syncronise an AD domain onto the local server\n", net_vampire, net_vampire_usage},
{"samsync", "synchronise into the local ldb the sam of an NT4 domain\n", net_samsync_ldb, net_samsync_ldb_usage},
{"user", "manage user accounts\n", net_user, net_user_usage},
- {"machinepw", "Get a machine password out of our SAM", net_machinepw,
+ {"machinepw", "Get a machine password out of our SAM\n", net_machinepw,
net_machinepw_usage},
{NULL, NULL, NULL, NULL}
};
diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c
index ad63340089..b0a25bb7c0 100644
--- a/source4/utils/net/net_join.c
+++ b/source4/utils/net/net_join.c
@@ -126,7 +126,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv)
domain_name = tmp;
- libnetctx = libnet_context_init(NULL, ctx->lp_ctx);
+ libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
if (!libnetctx) {
return -1;
}