summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--WHATSNEW4.txt102
-rw-r--r--docs-xml/smbdotconf/security/clientlanmanauth.xml2
-rw-r--r--lib/async_req/async_sock.c355
-rw-r--r--lib/async_req/async_sock.h11
-rw-r--r--lib/replace/system/network.h6
-rw-r--r--lib/smbconf/smbconf.c43
-rw-r--r--lib/smbconf/smbconf.h4
-rw-r--r--lib/smbconf/smbconf_private.h3
-rw-r--r--lib/smbconf/smbconf_txt.c17
-rw-r--r--lib/socket_wrapper/socket_wrapper.c569
-rw-r--r--lib/talloc/configure.ac2
-rw-r--r--lib/talloc/talloc.c24
-rw-r--r--lib/talloc/talloc.h2
-rw-r--r--lib/tdb/common/open.c5
-rw-r--r--lib/tevent/libtevent.m42
-rw-r--r--lib/tevent/pytevent.c4
-rw-r--r--lib/tevent/tevent.h124
-rw-r--r--lib/tevent/tevent_internal.h93
-rw-r--r--lib/tevent/tevent_queue.c198
-rw-r--r--lib/tevent/tevent_req.c84
-rw-r--r--lib/torture/config.mk4
-rw-r--r--lib/util/charset/charcnv.c45
-rw-r--r--lib/util/charset/charset.h130
-rw-r--r--lib/util/charset/iconv.c30
-rw-r--r--lib/util/charset/tests/iconv.c11
-rw-r--r--lib/util/charset/util_unistr.c57
-rw-r--r--lib/util/tevent_ntstatus.c51
-rw-r--r--lib/util/tevent_ntstatus.h32
-rw-r--r--lib/util/util.c115
-rw-r--r--lib/util/util.h22
-rw-r--r--libcli/security/dom_sid.h2
-rw-r--r--libcli/security/secace.c (renamed from source3/lib/secace.c)90
-rw-r--r--libcli/security/secace.h39
-rw-r--r--libcli/security/secacl.c (renamed from source3/lib/secacl.c)35
-rw-r--r--libcli/security/secacl.h33
-rw-r--r--libcli/util/doserr.c1
-rw-r--r--libcli/util/werror.h13
-rw-r--r--librpc/gen_ndr/dfs.h2
-rw-r--r--librpc/gen_ndr/drsblobs.h2
-rw-r--r--librpc/gen_ndr/drsuapi.h2
-rw-r--r--librpc/gen_ndr/dssetup.h2
-rw-r--r--librpc/gen_ndr/echo.h2
-rw-r--r--librpc/gen_ndr/epmapper.h2
-rw-r--r--librpc/gen_ndr/eventlog.h2
-rw-r--r--librpc/gen_ndr/initshutdown.h2
-rw-r--r--librpc/gen_ndr/krb5pac.h2
-rw-r--r--librpc/gen_ndr/lsa.h2
-rw-r--r--librpc/gen_ndr/misc.h2
-rw-r--r--librpc/gen_ndr/named_pipe_auth.h2
-rw-r--r--librpc/gen_ndr/nbt.h2
-rw-r--r--librpc/gen_ndr/ndr_drsblobs.c6
-rw-r--r--librpc/gen_ndr/ndr_spoolss.c3517
-rw-r--r--librpc/gen_ndr/ndr_spoolss.h19
-rw-r--r--librpc/gen_ndr/netlogon.h2
-rw-r--r--librpc/gen_ndr/ntsvcs.h2
-rw-r--r--librpc/gen_ndr/samr.h2
-rw-r--r--librpc/gen_ndr/security.h2
-rw-r--r--librpc/gen_ndr/spoolss.h318
-rw-r--r--librpc/gen_ndr/srvsvc.h2
-rw-r--r--librpc/gen_ndr/svcctl.h2
-rw-r--r--librpc/gen_ndr/winreg.h2
-rw-r--r--librpc/gen_ndr/wkssvc.h2
-rw-r--r--librpc/gen_ndr/xattr.h2
-rw-r--r--librpc/idl/spoolss.idl309
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Header.pm3
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm2
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm12
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm19
-rw-r--r--source3/Makefile.in25
-rw-r--r--source3/auth/auth_util.c14
-rw-r--r--source3/auth/auth_wbc.c (renamed from source3/auth/auth_onefs_wb.c)32
-rw-r--r--source3/client/mount.cifs.c4
-rw-r--r--source3/configure.in37
-rw-r--r--source3/include/charset.h128
-rw-r--r--source3/include/dbwrap.h4
-rw-r--r--source3/include/includes.h10
-rw-r--r--source3/include/proto.h146
-rw-r--r--source3/include/reg_db.h1
-rw-r--r--source3/include/reg_objects.h16
-rw-r--r--source3/include/regfio.h2
-rw-r--r--source3/include/rpc_secdes.h5
-rw-r--r--source3/include/rpc_spoolss.h175
-rw-r--r--source3/include/smb.h24
-rw-r--r--source3/include/smbprofile.h28
-rw-r--r--source3/lib/charcnv.c2
-rw-r--r--source3/lib/dbwrap.c26
-rw-r--r--source3/lib/dbwrap_ctdb.c12
-rw-r--r--source3/lib/dbwrap_rbt.c8
-rw-r--r--source3/lib/dbwrap_tdb.c12
-rw-r--r--source3/lib/display_sec.c8
-rw-r--r--source3/lib/events.c7
-rw-r--r--source3/lib/fault.c173
-rw-r--r--source3/lib/iconv.c4
-rw-r--r--source3/lib/smbconf/smbconf_reg.c174
-rw-r--r--source3/lib/util.c7
-rw-r--r--source3/lib/util_nttoken.c16
-rw-r--r--source3/lib/util_reg_api.c2
-rw-r--r--source3/lib/util_sock.c92
-rw-r--r--source3/lib/util_str.c112
-rw-r--r--source3/lib/wb_reqtrans.c30
-rw-r--r--source3/lib/wbclient.c7
-rw-r--r--source3/libads/disp_sec.c8
-rw-r--r--source3/libgpo/gpo_ini.c2
-rw-r--r--source3/libgpo/gpo_sec.c4
-rw-r--r--source3/libnet/libnet_join.c6
-rw-r--r--source3/modules/gpfs.c6
-rw-r--r--source3/modules/onefs.h110
-rw-r--r--source3/modules/onefs_acl.c21
-rw-r--r--source3/modules/onefs_cbrl.c27
-rw-r--r--source3/modules/onefs_config.c276
-rw-r--r--source3/modules/onefs_config.h160
-rw-r--r--source3/modules/onefs_dir.c2
-rw-r--r--source3/modules/onefs_notify.c1
-rw-r--r--source3/modules/onefs_open.c5
-rw-r--r--source3/modules/onefs_streams.c28
-rw-r--r--source3/modules/onefs_system.c22
-rw-r--r--source3/modules/vfs_acl_tdb.c89
-rw-r--r--source3/modules/vfs_acl_xattr.c12
-rw-r--r--source3/modules/vfs_gpfs.c5
-rw-r--r--source3/modules/vfs_onefs.c122
-rw-r--r--source3/modules/vfs_streams_depot.c14
-rw-r--r--source3/modules/vfs_streams_xattr.c15
-rw-r--r--source3/param/loadparm.c4
-rw-r--r--source3/passdb/lookup_sid.c38
-rw-r--r--source3/passdb/pdb_wbc_sam.c (renamed from source3/passdb/pdb_onefs_sam.c)135
-rw-r--r--source3/printing/nt_printing.c18
-rw-r--r--source3/printing/printfsp.c3
-rw-r--r--source3/printing/printing.c6
-rw-r--r--source3/profile/profile.c7
-rw-r--r--source3/registry/reg_api.c183
-rw-r--r--source3/registry/reg_backend_current_version.c2
-rw-r--r--source3/registry/reg_backend_db.c651
-rw-r--r--source3/registry/reg_backend_hkpt_params.c2
-rw-r--r--source3/registry/reg_backend_netlogon_params.c2
-rw-r--r--source3/registry/reg_backend_perflib.c2
-rw-r--r--source3/registry/reg_backend_printing.c20
-rw-r--r--source3/registry/reg_backend_prod_options.c2
-rw-r--r--source3/registry/reg_backend_shares.c4
-rw-r--r--source3/registry/reg_backend_smbconf.c16
-rw-r--r--source3/registry/reg_backend_tcpip_params.c2
-rw-r--r--source3/registry/reg_dispatcher.c39
-rw-r--r--source3/registry/reg_eventlog.c18
-rw-r--r--source3/registry/reg_objects.c175
-rw-r--r--source3/registry/regfio.c2
-rw-r--r--source3/rpc_client/cli_spoolss.c388
-rw-r--r--source3/rpc_client/rpc_transport_sock.c108
-rw-r--r--source3/rpc_parse/parse_sec.c4
-rw-r--r--source3/rpc_parse/parse_spoolss.c849
-rw-r--r--source3/rpc_server/srv_eventlog_lib.c2
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c14
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c75
-rw-r--r--source3/rpcclient/cmd_netlogon.c44
-rw-r--r--source3/rpcclient/cmd_samr.c32
-rw-r--r--source3/rpcclient/cmd_spoolss.c525
-rw-r--r--source3/services/services_db.c12
-rw-r--r--source3/smbd/close.c22
-rw-r--r--source3/smbd/conn.c1
-rw-r--r--source3/smbd/file_access.c5
-rw-r--r--source3/smbd/fileio.c3
-rw-r--r--source3/smbd/files.c43
-rw-r--r--source3/smbd/open.c28
-rw-r--r--source3/smbd/reply.c12
-rw-r--r--source3/smbd/server.c2
-rw-r--r--source3/smbd/service.c8
-rw-r--r--source3/smbd/trans2.c14
-rw-r--r--source3/smbd/uid.c11
-rw-r--r--source3/utils/net_conf.c58
-rw-r--r--source3/utils/net_rpc_printer.c294
-rw-r--r--source3/utils/net_rpc_registry.c11
-rw-r--r--source3/utils/profiles.c8
-rw-r--r--source3/winbindd/idmap_ad.c10
-rw-r--r--source3/winbindd/idmap_adex/idmap_adex.c10
-rw-r--r--source3/winbindd/idmap_hash/idmap_hash.c10
-rw-r--r--source3/winbindd/idmap_ldap.c8
-rw-r--r--source3/winbindd/idmap_nss.c10
-rw-r--r--source3/winbindd/idmap_rid.c10
-rw-r--r--source3/winbindd/idmap_tdb.c10
-rw-r--r--source3/winbindd/idmap_tdb2.c10
-rw-r--r--source4/Makefile2
-rw-r--r--source4/VERSION2
-rw-r--r--source4/auth/ntlm/ntlm_check.c2
-rw-r--r--source4/auth/ntlmssp/ntlmssp_parse.c36
-rw-r--r--source4/build/m4/public.m47
-rw-r--r--source4/configure.ac2
-rw-r--r--source4/dsdb/common/util.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/password_hash.c17
-rw-r--r--source4/dsdb/schema/schema_init.c54
-rw-r--r--source4/dsdb/schema/schema_syntax.c24
-rw-r--r--source4/heimdal_build/internal.m417
-rw-r--r--source4/heimdal_build/internal.mk52
-rw-r--r--source4/kdc/kpasswdd.c18
-rw-r--r--source4/lib/events/tevent_s4.c2
-rw-r--r--source4/lib/ldb/include/ldb.h11
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map.c1
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_inbound.c1
-rw-r--r--source4/lib/ldb/ldb_map/ldb_map_outbound.c1
-rw-r--r--source4/lib/ldb/tools/cmdline.h1
-rw-r--r--source4/lib/registry/ldb.c8
-rw-r--r--source4/lib/registry/tests/generic.c12
-rw-r--r--source4/lib/registry/util.c6
-rw-r--r--source4/lib/tdr/tdr.c12
-rw-r--r--source4/libcli/auth/smbencrypt.c32
-rw-r--r--source4/libcli/raw/rawfileinfo.c8
-rw-r--r--source4/libcli/raw/rawrequest.c32
-rw-r--r--source4/libcli/security/config.mk4
-rw-r--r--source4/libcli/security/security.h3
-rw-r--r--source4/libcli/smb2/request.c18
-rw-r--r--source4/libnet/libnet_samdump.c4
-rw-r--r--source4/librpc/ndr/ndr_string.c56
-rw-r--r--source4/ntptr/ntptr.h3
-rw-r--r--source4/ntptr/ntptr_interface.c9
-rw-r--r--source4/ntptr/simple_ldb/ntptr_simple_ldb.c43
-rw-r--r--source4/param/provision.c8
-rw-r--r--source4/param/util.c2
-rw-r--r--source4/rpc_server/netlogon/dcerpc_netlogon.c2
-rw-r--r--source4/rpc_server/samr/samr_password.c15
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c20
-rwxr-xr-xsource4/script/installman.sh2
-rwxr-xr-xsource4/script/uninstallman.sh2
-rw-r--r--source4/scripting/python/samba/__init__.py2
-rw-r--r--source4/scripting/python/samba/provision.py7
-rw-r--r--source4/scripting/python/samba/samdb.py10
-rw-r--r--source4/scripting/python/samba/tests/__init__.py4
-rw-r--r--source4/scripting/python/samba/tests/dcerpc/rpcecho.py2
-rw-r--r--source4/scripting/python/samba/tests/provision.py2
-rwxr-xr-xsource4/selftest/tests.sh10
-rw-r--r--source4/smb_server/smb/request.c12
-rw-r--r--source4/torture/basic/charset.c5
-rw-r--r--source4/torture/basic/utable.c13
-rw-r--r--source4/torture/raw/rename.c86
-rw-r--r--source4/torture/raw/streams.c121
-rw-r--r--source4/torture/rpc/samba3rpc.c2
-rw-r--r--source4/torture/rpc/samlogon.c10
-rw-r--r--source4/torture/rpc/spoolss.c167
-rw-r--r--source4/torture/rpc/spoolss_win.c2
-rw-r--r--source4/torture/rpc/wkssvc.c2
-rwxr-xr-xtestprogs/blackbox/test_ldb.sh2
237 files changed, 9499 insertions, 4382 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/docs-xml/smbdotconf/security/clientlanmanauth.xml b/docs-xml/smbdotconf/security/clientlanmanauth.xml
index 967eacf85b..9c61dedeb9 100644
--- a/docs-xml/smbdotconf/security/clientlanmanauth.xml
+++ b/docs-xml/smbdotconf/security/clientlanmanauth.xml
@@ -17,7 +17,7 @@
this option. </para>
<para>Disabling this option will also disable the <command
- moreinfo="none">client plaintext auth</command> option</para>
+ moreinfo="none">client plaintext auth</command> option.</para>
<para>Likewise, if the <command moreinfo="none">client ntlmv2
auth</command> parameter is enabled, then only NTLMv2 logins will be
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index 3563421e0e..424da952eb 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -30,45 +30,6 @@
#endif
/**
- * Discriminator for async_syscall_state
- */
-enum async_syscall_type {
- ASYNC_SYSCALL_SEND,
- ASYNC_SYSCALL_RECV,
-};
-
-/**
- * Holder for syscall arguments and the result
- */
-
-struct async_syscall_state {
- enum async_syscall_type syscall_type;
- struct tevent_fd *fde;
-
- union {
- struct param_send {
- int fd;
- const void *buffer;
- size_t length;
- int flags;
- } param_send;
- struct param_recv {
- int fd;
- void *buffer;
- size_t length;
- int flags;
- } param_recv;
- } param;
-
- union {
- ssize_t result_ssize_t;
- size_t result_size_t;
- int result_int;
- } result;
- int sys_errno;
-};
-
-/**
* @brief Map async_req states to unix-style errnos
* @param[in] req The async req to get the state from
* @param[out] err Pointer to take the unix-style errno
@@ -117,267 +78,6 @@ int async_req_simple_recv_errno(struct async_req *req)
return 0;
}
-/**
- * @brief Create a new async syscall req
- * @param[in] mem_ctx The memory context to hang the result off
- * @param[in] ev The event context to work from
- * @param[in] type Which syscall will this be
- * @param[in] pstate Where to put the newly created private_data state
- * @retval The new request
- *
- * This is a helper function to prepare a new struct async_req with an
- * associated struct async_syscall_state. The async_syscall_state will be put
- * into the async_req as private_data.
- */
-
-static struct async_req *async_syscall_new(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- enum async_syscall_type type,
- struct async_syscall_state **pstate)
-{
- struct async_req *result;
- struct async_syscall_state *state;
-
- if (!async_req_setup(mem_ctx, &result, &state,
- struct async_syscall_state)) {
- return NULL;
- }
- state->syscall_type = type;
-
- result->private_data = state;
-
- *pstate = state;
-
- return result;
-}
-
-/**
- * @brief Create a new async syscall req based on a fd
- * @param[in] mem_ctx The memory context to hang the result off
- * @param[in] ev The event context to work from
- * @param[in] type Which syscall will this be
- * @param[in] fd The file descriptor we work on
- * @param[in] fde_flags TEVENT_FD_READ/WRITE -- what are we interested in?
- * @param[in] fde_cb The callback function for the file descriptor event
- * @param[in] pstate Where to put the newly created private_data state
- * @retval The new request
- *
- * This is a helper function to prepare a new struct async_req with an
- * associated struct async_syscall_state and an associated file descriptor
- * event.
- */
-
-static struct async_req *async_fde_syscall_new(
- TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- enum async_syscall_type type,
- int fd,
- uint16_t fde_flags,
- void (*fde_cb)(struct tevent_context *ev,
- struct tevent_fd *fde, uint16_t flags,
- void *priv),
- struct async_syscall_state **pstate)
-{
- struct async_req *result;
- struct async_syscall_state *state;
-
- result = async_syscall_new(mem_ctx, ev, type, &state);
- if (result == NULL) {
- return NULL;
- }
-
- state->fde = tevent_add_fd(ev, state, fd, fde_flags, fde_cb, result);
- if (state->fde == NULL) {
- TALLOC_FREE(result);
- return NULL;
- }
- *pstate = state;
- return result;
-}
-
-/**
- * Retrieve a ssize_t typed result from an async syscall
- * @param[in] req The syscall that has just finished
- * @param[out] perrno Where to put the syscall's errno
- * @retval The return value from the asynchronously called syscall
- */
-
-ssize_t async_syscall_result_ssize_t(struct async_req *req, int *perrno)
-{
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
-
- *perrno = state->sys_errno;
- return state->result.result_ssize_t;
-}
-
-/**
- * Retrieve a size_t typed result from an async syscall
- * @param[in] req The syscall that has just finished
- * @param[out] perrno Where to put the syscall's errno
- * @retval The return value from the asynchronously called syscall
- */
-
-size_t async_syscall_result_size_t(struct async_req *req, int *perrno)
-{
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
-
- *perrno = state->sys_errno;
- return state->result.result_size_t;
-}
-
-/**
- * Retrieve a int typed result from an async syscall
- * @param[in] req The syscall that has just finished
- * @param[out] perrno Where to put the syscall's errno
- * @retval The return value from the asynchronously called syscall
- */
-
-int async_syscall_result_int(struct async_req *req, int *perrno)
-{
- struct async_syscall_state *state = talloc_get_type_abort(
- req->private_data, struct async_syscall_state);
-
- *perrno = state->sys_errno;
- return state->result.result_int;
-}
-
-/**
- * fde event handler for the "send" syscall
- * @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_send_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_send *p = &state->param.param_send;
-
- if (state->syscall_type != ASYNC_SYSCALL_SEND) {
- async_req_error(req, EIO);
- return;
- }
-
- state->result.result_ssize_t = send(p->fd, p->buffer, p->length,
- p->flags);
- state->sys_errno = errno;
-
- TALLOC_FREE(state->fde);
-
- async_req_done(req);
-}
-
-/**
- * Async version of send(2)
- * @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)
- *
- * This function is a direct counterpart of send(2)
- */
-
-struct async_req *async_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_SEND,
- fd, TEVENT_FD_WRITE, async_send_callback,
- &state);
- if (result == NULL) {
- return NULL;
- }
-
- state->param.param_send.fd = fd;
- state->param.param_send.buffer = buffer;
- state->param.param_send.length = length;
- state->param.param_send.flags = flags;
-
- return result;
-}
-
-/**
- * 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
- * @param[in] flags Can only be TEVENT_FD_READ here
- * @param[in] priv private data, "struct async_req *" in this case
- */
-
-static void async_recv_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_recv *p = &state->param.param_recv;
-
- if (state->syscall_type != ASYNC_SYSCALL_RECV) {
- async_req_error(req, EIO);
- return;
- }
-
- state->result.result_ssize_t = recv(p->fd, p->buffer, p->length,
- p->flags);
- state->sys_errno = errno;
-
- TALLOC_FREE(state->fde);
-
- async_req_done(req);
-}
-
-/**
- * Async version of recv(2)
- * @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)
- *
- * This function is a direct counterpart of recv(2)
- */
-
-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 *result;
- struct async_syscall_state *state;
-
- result = async_fde_syscall_new(
- mem_ctx, ev, ASYNC_SYSCALL_RECV,
- fd, TEVENT_FD_READ, async_recv_callback,
- &state);
-
- if (result == NULL) {
- return NULL;
- }
-
- state->param.param_recv.fd = fd;
- state->param.param_recv.buffer = buffer;
- state->param.param_recv.length = length;
- state->param.param_recv.flags = flags;
-
- return result;
-}
-
struct async_send_state {
int fd;
const void *buf;
@@ -423,8 +123,8 @@ static void async_send_handler(struct tevent_context *ev,
{
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);
+ struct async_send_state *state =
+ tevent_req_data(req, struct async_send_state);
state->sent = send(state->fd, state->buf, state->len, state->flags);
if (state->sent == -1) {
@@ -436,8 +136,8 @@ static void async_send_handler(struct tevent_context *ev,
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);
+ struct async_send_state *state =
+ tevent_req_data(req, struct async_send_state);
if (tevent_req_is_unix_error(req, perrno)) {
return -1;
@@ -489,8 +189,8 @@ static void async_recv_handler(struct tevent_context *ev,
{
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);
+ struct async_recv_state *state =
+ tevent_req_data(req, struct async_recv_state);
state->received = recv(state->fd, state->buf, state->len,
state->flags);
@@ -503,8 +203,8 @@ static void async_recv_handler(struct tevent_context *ev,
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);
+ struct async_recv_state *state =
+ tevent_req_data(req, struct async_recv_state);
if (tevent_req_is_unix_error(req, perrno)) {
return -1;
@@ -568,8 +268,8 @@ struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx,
state->result = connect(fd, address, address_len);
if (state->result == 0) {
- errno = 0;
- goto post_errno;
+ tevent_req_done(result);
+ goto done;
}
/**
@@ -584,25 +284,22 @@ struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx,
errno == EISCONN ||
#endif
errno == EAGAIN || errno == EINTR)) {
+ state->sys_errno = errno;
goto post_errno;
}
fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ | TEVENT_FD_WRITE,
async_connect_connected, result);
if (fde == NULL) {
- errno = ENOMEM;
+ state->sys_errno = ENOMEM;
goto post_errno;
}
return result;
post_errno:
- state->sys_errno = errno;
+ tevent_req_error(result, state->sys_errno);
+ done:
fcntl(fd, F_SETFL, state->old_sockflags);
- if (state->sys_errno == 0) {
- tevent_req_done(result);
- } else {
- tevent_req_error(result, state->sys_errno);
- }
return tevent_req_post(result, ev);
}
@@ -620,8 +317,8 @@ static void async_connect_connected(struct tevent_context *ev,
{
struct tevent_req *req = talloc_get_type_abort(
priv, struct tevent_req);
- struct async_connect_state *state = talloc_get_type_abort(
- req->private_state, struct async_connect_state);
+ struct async_connect_state *state =
+ tevent_req_data(req, struct async_connect_state);
TALLOC_FREE(fde);
@@ -655,8 +352,8 @@ static void async_connect_connected(struct tevent_context *ev,
int async_connect_recv(struct tevent_req *req, int *perrno)
{
- struct async_connect_state *state = talloc_get_type_abort(
- req->private_state, struct async_connect_state);
+ struct async_connect_state *state =
+ tevent_req_data(req, struct async_connect_state);
int err;
fcntl(state->fd, F_SETFL, state->old_sockflags);
@@ -723,8 +420,8 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
{
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);
+ struct writev_state *state =
+ tevent_req_data(req, struct writev_state);
size_t to_write, written;
int i;
@@ -770,8 +467,8 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde,
ssize_t writev_recv(struct tevent_req *req, int *perrno)
{
- struct writev_state *state = talloc_get_type_abort(
- req->private_state, struct writev_state);
+ struct writev_state *state =
+ tevent_req_data(req, struct writev_state);
if (tevent_req_is_unix_error(req, perrno)) {
return -1;
@@ -834,8 +531,8 @@ static void read_packet_handler(struct tevent_context *ev,
{
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);
+ struct read_packet_state *state =
+ tevent_req_data(req, struct read_packet_state);
size_t total = talloc_get_size(state->buf);
ssize_t nread, more;
uint8_t *tmp;
@@ -887,8 +584,8 @@ static void read_packet_handler(struct tevent_context *ev,
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);
+ struct read_packet_state *state =
+ tevent_req_data(req, struct read_packet_state);
if (tevent_req_is_unix_error(req, perrno)) {
return -1;
diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h
index bfc4346d39..e001709d27 100644
--- a/lib/async_req/async_sock.h
+++ b/lib/async_req/async_sock.h
@@ -25,17 +25,6 @@
bool async_req_is_errno(struct async_req *req, int *err);
int async_req_simple_recv_errno(struct async_req *req);
-ssize_t async_syscall_result_ssize_t(struct async_req *req, int *perrno);
-size_t async_syscall_result_size_t(struct async_req *req, int *perrno);
-int async_syscall_result_int(struct async_req *req, int *perrno);
-
-struct async_req *async_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- int fd, const void *buffer, size_t length,
- int flags);
-struct async_req *async_recv(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
- int fd, void *buffer, size_t length,
- int flags);
-
struct tevent_req *async_send_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
int fd, const void *buf, size_t len,
diff --git a/lib/replace/system/network.h b/lib/replace/system/network.h
index 40d20db2d4..f135d175d4 100644
--- a/lib/replace/system/network.h
+++ b/lib/replace/system/network.h
@@ -327,10 +327,12 @@ struct addrinfo {
#endif
#ifdef SOCKET_WRAPPER
+#ifndef SOCKET_WRAPPER_DISABLE
#ifndef SOCKET_WRAPPER_NOT_REPLACE
#define SOCKET_WRAPPER_REPLACE
-#endif
+#endif /* SOCKET_WRAPPER_NOT_REPLACE */
#include "../socket_wrapper/socket_wrapper.h"
-#endif
+#endif /* SOCKET_WRAPPER_DISABLE */
+#endif /* SOCKET_WRAPPER */
#endif
diff --git a/lib/smbconf/smbconf.c b/lib/smbconf/smbconf.c
index bcab0b97cd..80fe9aac37 100644
--- a/lib/smbconf/smbconf.c
+++ b/lib/smbconf/smbconf.c
@@ -203,10 +203,6 @@ WERROR smbconf_get_share(struct smbconf_ctx *ctx,
const char *servicename,
struct smbconf_service **service)
{
- if (!smbconf_share_exists(ctx, servicename)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->get_share(ctx, mem_ctx, servicename, service);
}
@@ -230,10 +226,6 @@ WERROR smbconf_set_parameter(struct smbconf_ctx *ctx,
const char *param,
const char *valstr)
{
- if (!smbconf_share_exists(ctx, service)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->set_parameter(ctx, service, param, valstr);
}
@@ -269,10 +261,6 @@ WERROR smbconf_get_parameter(struct smbconf_ctx *ctx,
return WERR_INVALID_PARAM;
}
- if (!smbconf_share_exists(ctx, service)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr);
}
@@ -303,10 +291,6 @@ WERROR smbconf_get_global_parameter(struct smbconf_ctx *ctx,
WERROR smbconf_delete_parameter(struct smbconf_ctx *ctx,
const char *service, const char *param)
{
- if (!smbconf_share_exists(ctx, service)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->delete_parameter(ctx, service, param);
}
@@ -333,10 +317,6 @@ WERROR smbconf_get_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t *num_includes, char ***includes)
{
- if (!smbconf_share_exists(ctx, service)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->get_includes(ctx, mem_ctx, service, num_includes,
includes);
}
@@ -360,10 +340,6 @@ WERROR smbconf_set_includes(struct smbconf_ctx *ctx,
const char *service,
uint32_t num_includes, const char **includes)
{
- if (!smbconf_share_exists(ctx, service)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->set_includes(ctx, service, num_includes, includes);
}
@@ -385,10 +361,6 @@ WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
{
- if (!smbconf_share_exists(ctx, service)) {
- return WERR_NO_SUCH_SERVICE;
- }
-
return ctx->ops->delete_includes(ctx, service);
}
@@ -403,3 +375,18 @@ WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx)
return werr;
}
+
+WERROR smbconf_transaction_start(struct smbconf_ctx *ctx)
+{
+ return ctx->ops->transaction_start(ctx);
+}
+
+WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx)
+{
+ return ctx->ops->transaction_commit(ctx);
+}
+
+WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx)
+{
+ return ctx->ops->transaction_cancel(ctx);
+}
diff --git a/lib/smbconf/smbconf.h b/lib/smbconf/smbconf.h
index 106fae6431..517302ac88 100644
--- a/lib/smbconf/smbconf.h
+++ b/lib/smbconf/smbconf.h
@@ -94,4 +94,8 @@ WERROR smbconf_set_global_includes(struct smbconf_ctx *ctx,
WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service);
WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx);
+WERROR smbconf_transaction_start(struct smbconf_ctx *ctx);
+WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx);
+WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx);
+
#endif /* _LIBSMBCONF_H_ */
diff --git a/lib/smbconf/smbconf_private.h b/lib/smbconf/smbconf_private.h
index c9e44181c6..e6998ad639 100644
--- a/lib/smbconf/smbconf_private.h
+++ b/lib/smbconf/smbconf_private.h
@@ -68,6 +68,9 @@ struct smbconf_ops {
uint32_t num_includes, const char **includes);
WERROR (*delete_includes)(struct smbconf_ctx *ctx,
const char *service);
+ WERROR (*transaction_start)(struct smbconf_ctx *ctx);
+ WERROR (*transaction_commit)(struct smbconf_ctx *ctx);
+ WERROR (*transaction_cancel)(struct smbconf_ctx *ctx);
};
struct smbconf_ctx {
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 1df4a9fdb7..501382cc5f 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -612,6 +612,20 @@ static WERROR smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
+static WERROR smbconf_txt_transaction_start(struct smbconf_ctx *ctx)
+{
+ return WERR_OK;
+}
+
+static WERROR smbconf_txt_transaction_commit(struct smbconf_ctx *ctx)
+{
+ return WERR_OK;
+}
+
+static WERROR smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)
+{
+ return WERR_OK;
+}
static struct smbconf_ops smbconf_ops_txt = {
.init = smbconf_txt_init,
@@ -633,6 +647,9 @@ static struct smbconf_ops smbconf_ops_txt = {
.get_includes = smbconf_txt_get_includes,
.set_includes = smbconf_txt_set_includes,
.delete_includes = smbconf_txt_delete_includes,
+ .transaction_start = smbconf_txt_transaction_start,
+ .transaction_commit = smbconf_txt_transaction_commit,
+ .transaction_cancel = smbconf_txt_transaction_cancel,
};
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 1e3927705b..8ad9e1d93e 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -145,7 +145,16 @@
#define MAX_WRAPPED_INTERFACES 16
-#define SW_IPV6_ADDRESS 1
+#ifdef HAVE_IPV6
+/*
+ * FD00::5357:5FXX
+ */
+static const struct in6_addr swrap_ipv6 =
+{ { {
+0xFD,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+0x00,0x00,0x00,0x00,0x53,0x57,0x5F,0x00
+} } };
+#endif
static struct sockaddr *sockaddr_dup(const void *data, socklen_t len)
{
@@ -295,7 +304,8 @@ static int convert_un_in(const struct sockaddr_un *un, struct sockaddr *in, sock
memset(in2, 0, sizeof(*in2));
in2->sin6_family = AF_INET6;
- in2->sin6_addr.s6_addr[0] = SW_IPV6_ADDRESS;
+ in2->sin6_addr = swrap_ipv6;
+ in2->sin6_addr.s6_addr[15] = iface;
in2->sin6_port = htons(prt);
*len = sizeof(*in2);
@@ -367,6 +377,7 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
case AF_INET6: {
const struct sockaddr_in6 *in =
(const struct sockaddr_in6 *)inaddr;
+ struct in6_addr cmp;
switch (si->type) {
case SOCK_STREAM:
@@ -380,8 +391,16 @@ static int convert_in_un_remote(struct socket_info *si, const struct sockaddr *i
/* XXX no multicast/broadcast */
prt = ntohs(in->sin6_port);
- iface = SW_IPV6_ADDRESS;
-
+
+ cmp = in->sin6_addr;
+ cmp.s6_addr[15] = 0;
+ if (IN6_ARE_ADDR_EQUAL(&swrap_ipv6, &cmp)) {
+ iface = in->sin6_addr.s6_addr[15];
+ } else {
+ errno = ENETUNREACH;
+ return -1;
+ }
+
break;
}
#endif
@@ -474,6 +493,7 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
case AF_INET6: {
const struct sockaddr_in6 *in =
(const struct sockaddr_in6 *)inaddr;
+ struct in6_addr cmp;
switch (si->type) {
case SOCK_STREAM:
@@ -487,13 +507,21 @@ static int convert_in_un_alloc(struct socket_info *si, const struct sockaddr *in
/* XXX no multicast/broadcast */
prt = ntohs(in->sin6_port);
- iface = SW_IPV6_ADDRESS;
-
+
+ cmp = in->sin6_addr;
+ cmp.s6_addr[15] = 0;
+ if (IN6_ARE_ADDR_EQUAL(&swrap_ipv6, &cmp)) {
+ iface = in->sin6_addr.s6_addr[15];
+ } else {
+ errno = EADDRNOTAVAIL;
+ return -1;
+ }
+
break;
}
#endif
default:
- errno = ENETUNREACH;
+ errno = EADDRNOTAVAIL;
return -1;
}
@@ -636,69 +664,93 @@ struct swrap_file_hdr {
};
#define SWRAP_FILE_HDR_SIZE 24
-struct swrap_packet {
+struct swrap_packet_frame {
+ uint32_t seconds;
+ uint32_t micro_seconds;
+ uint32_t recorded_length;
+ uint32_t full_length;
+};
+#define SWRAP_PACKET_FRAME_SIZE 16
+
+union swrap_packet_ip {
+ struct {
+ uint8_t ver_hdrlen;
+ uint8_t tos;
+ uint16_t packet_length;
+ uint16_t identification;
+ uint8_t flags;
+ uint8_t fragment;
+ uint8_t ttl;
+ uint8_t protocol;
+ uint16_t hdr_checksum;
+ uint32_t src_addr;
+ uint32_t dest_addr;
+ } v4;
+#define SWRAP_PACKET_IP_V4_SIZE 20
struct {
- uint32_t seconds;
- uint32_t micro_seconds;
- uint32_t recorded_length;
- uint32_t full_length;
- } frame;
-#define SWRAP_PACKET__FRAME_SIZE 16
+ uint8_t ver_prio;
+ uint8_t flow_label_high;
+ uint16_t flow_label_low;
+ uint16_t payload_length;
+ uint8_t next_header;
+ uint8_t hop_limit;
+ uint8_t src_addr[16];
+ uint8_t dest_addr[16];
+ } v6;
+#define SWRAP_PACKET_IP_V6_SIZE 40
+};
+#define SWRAP_PACKET_IP_SIZE 40
+union swrap_packet_payload {
+ struct {
+ uint16_t source_port;
+ uint16_t dest_port;
+ uint32_t seq_num;
+ uint32_t ack_num;
+ uint8_t hdr_length;
+ uint8_t control;
+ uint16_t window;
+ uint16_t checksum;
+ uint16_t urg;
+ } tcp;
+#define SWRAP_PACKET_PAYLOAD_TCP_SIZE 20
struct {
- struct {
- uint8_t ver_hdrlen;
- uint8_t tos;
- uint16_t packet_length;
- uint16_t identification;
- uint8_t flags;
- uint8_t fragment;
- uint8_t ttl;
- uint8_t protocol;
- uint16_t hdr_checksum;
- uint32_t src_addr;
- uint32_t dest_addr;
- } hdr;
-#define SWRAP_PACKET__IP_HDR_SIZE 20
-
- union {
- struct {
- uint16_t source_port;
- uint16_t dest_port;
- uint32_t seq_num;
- uint32_t ack_num;
- uint8_t hdr_length;
- uint8_t control;
- uint16_t window;
- uint16_t checksum;
- uint16_t urg;
- } tcp;
-#define SWRAP_PACKET__IP_P_TCP_SIZE 20
- struct {
- uint16_t source_port;
- uint16_t dest_port;
- uint16_t length;
- uint16_t checksum;
- } udp;
-#define SWRAP_PACKET__IP_P_UDP_SIZE 8
- struct {
- uint8_t type;
- uint8_t code;
- uint16_t checksum;
- uint32_t unused;
- } icmp;
-#define SWRAP_PACKET__IP_P_ICMP_SIZE 8
- } p;
- } ip;
+ uint16_t source_port;
+ uint16_t dest_port;
+ uint16_t length;
+ uint16_t checksum;
+ } udp;
+#define SWRAP_PACKET_PAYLOAD_UDP_SIZE 8
+ struct {
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ uint32_t unused;
+ } icmp4;
+#define SWRAP_PACKET_PAYLOAD_ICMP4_SIZE 8
+ struct {
+ uint8_t type;
+ uint8_t code;
+ uint16_t checksum;
+ uint32_t unused;
+ } icmp6;
+#define SWRAP_PACKET_PAYLOAD_ICMP6_SIZE 8
};
-#define SWRAP_PACKET_SIZE 56
+#define SWRAP_PACKET_PAYLOAD_SIZE 20
+
+#define SWRAP_PACKET_MIN_ALLOC \
+ (SWRAP_PACKET_FRAME_SIZE + \
+ SWRAP_PACKET_IP_SIZE + \
+ SWRAP_PACKET_PAYLOAD_SIZE)
static const char *socket_wrapper_pcap_file(void)
{
static int initialized = 0;
static const char *s = NULL;
- static const struct swrap_file_hdr h = { 0, };
- static const struct swrap_packet p = { { 0, }, { { 0, }, { { 0, } } } };
+ static const struct swrap_file_hdr h;
+ static const struct swrap_packet_frame f;
+ static const union swrap_packet_ip i;
+ static const union swrap_packet_payload p;
if (initialized == 1) {
return s;
@@ -715,22 +767,31 @@ static const char *socket_wrapper_pcap_file(void)
if (sizeof(h) != SWRAP_FILE_HDR_SIZE) {
return NULL;
}
- if (sizeof(p) != SWRAP_PACKET_SIZE) {
+ if (sizeof(f) != SWRAP_PACKET_FRAME_SIZE) {
+ return NULL;
+ }
+ if (sizeof(i) != SWRAP_PACKET_IP_SIZE) {
return NULL;
}
- if (sizeof(p.frame) != SWRAP_PACKET__FRAME_SIZE) {
+ if (sizeof(i.v4) != SWRAP_PACKET_IP_V4_SIZE) {
return NULL;
}
- if (sizeof(p.ip.hdr) != SWRAP_PACKET__IP_HDR_SIZE) {
+ if (sizeof(i.v6) != SWRAP_PACKET_IP_V6_SIZE) {
return NULL;
}
- if (sizeof(p.ip.p.tcp) != SWRAP_PACKET__IP_P_TCP_SIZE) {
+ if (sizeof(p) != SWRAP_PACKET_PAYLOAD_SIZE) {
return NULL;
}
- if (sizeof(p.ip.p.udp) != SWRAP_PACKET__IP_P_UDP_SIZE) {
+ if (sizeof(p.tcp) != SWRAP_PACKET_PAYLOAD_TCP_SIZE) {
return NULL;
}
- if (sizeof(p.ip.p.icmp) != SWRAP_PACKET__IP_P_ICMP_SIZE) {
+ if (sizeof(p.udp) != SWRAP_PACKET_PAYLOAD_UDP_SIZE) {
+ return NULL;
+ }
+ if (sizeof(p.icmp4) != SWRAP_PACKET_PAYLOAD_ICMP4_SIZE) {
+ return NULL;
+ }
+ if (sizeof(p.icmp6) != SWRAP_PACKET_PAYLOAD_ICMP6_SIZE) {
return NULL;
}
@@ -744,41 +805,72 @@ static const char *socket_wrapper_pcap_file(void)
return s;
}
-static struct swrap_packet *swrap_packet_init(struct timeval *tval,
- const struct sockaddr_in *src_addr,
- const struct sockaddr_in *dest_addr,
- int socket_type,
- const unsigned char *payload,
- size_t payload_len,
- unsigned long tcp_seqno,
- unsigned long tcp_ack,
- unsigned char tcp_ctl,
- int unreachable,
- size_t *_packet_len)
+static uint8_t *swrap_packet_init(struct timeval *tval,
+ const struct sockaddr *src,
+ const struct sockaddr *dest,
+ int socket_type,
+ const uint8_t *payload,
+ size_t payload_len,
+ unsigned long tcp_seqno,
+ unsigned long tcp_ack,
+ unsigned char tcp_ctl,
+ int unreachable,
+ size_t *_packet_len)
{
- struct swrap_packet *ret;
- struct swrap_packet *packet;
+ uint8_t *base;
+ uint8_t *buf;
+ struct swrap_packet_frame *frame;
+ union swrap_packet_ip *ip;
+ union swrap_packet_payload *pay;
size_t packet_len;
size_t alloc_len;
- size_t nonwire_len = sizeof(packet->frame);
+ size_t nonwire_len = sizeof(*frame);
size_t wire_hdr_len = 0;
size_t wire_len = 0;
+ size_t ip_hdr_len = 0;
size_t icmp_hdr_len = 0;
size_t icmp_truncate_len = 0;
- unsigned char protocol = 0, icmp_protocol = 0;
- unsigned short src_port = src_addr->sin_port;
- unsigned short dest_port = dest_addr->sin_port;
+ uint8_t protocol = 0, icmp_protocol = 0;
+ const struct sockaddr_in *src_in = NULL;
+ const struct sockaddr_in *dest_in = NULL;
+#ifdef HAVE_IPV6
+ const struct sockaddr_in6 *src_in6 = NULL;
+ const struct sockaddr_in6 *dest_in6 = NULL;
+#endif
+ uint16_t src_port;
+ uint16_t dest_port;
+
+ switch (src->sa_family) {
+ case AF_INET:
+ src_in = (const struct sockaddr_in *)src;
+ dest_in = (const struct sockaddr_in *)dest;
+ src_port = src_in->sin_port;
+ dest_port = dest_in->sin_port;
+ ip_hdr_len = sizeof(ip->v4);
+ break;
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ src_in6 = (const struct sockaddr_in6 *)src;
+ dest_in6 = (const struct sockaddr_in6 *)dest;
+ src_port = src_in6->sin6_port;
+ dest_port = dest_in6->sin6_port;
+ ip_hdr_len = sizeof(ip->v6);
+ break;
+#endif
+ default:
+ return NULL;
+ }
switch (socket_type) {
case SOCK_STREAM:
protocol = 0x06; /* TCP */
- wire_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.tcp);
+ wire_hdr_len = ip_hdr_len + sizeof(pay->tcp);
wire_len = wire_hdr_len + payload_len;
break;
case SOCK_DGRAM:
protocol = 0x11; /* UDP */
- wire_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.udp);
+ wire_hdr_len = ip_hdr_len + sizeof(pay->udp);
wire_len = wire_hdr_len + payload_len;
break;
@@ -788,98 +880,160 @@ static struct swrap_packet *swrap_packet_init(struct timeval *tval,
if (unreachable) {
icmp_protocol = protocol;
- protocol = 0x01; /* ICMP */
+ switch (src->sa_family) {
+ case AF_INET:
+ protocol = 0x01; /* ICMPv4 */
+ icmp_hdr_len = ip_hdr_len + sizeof(pay->icmp4);
+ break;
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ protocol = 0x3A; /* ICMPv6 */
+ icmp_hdr_len = ip_hdr_len + sizeof(pay->icmp6);
+ break;
+#endif
+ }
if (wire_len > 64 ) {
icmp_truncate_len = wire_len - 64;
}
- icmp_hdr_len = sizeof(packet->ip.hdr) + sizeof(packet->ip.p.icmp);
wire_hdr_len += icmp_hdr_len;
wire_len += icmp_hdr_len;
}
packet_len = nonwire_len + wire_len;
alloc_len = packet_len;
- if (alloc_len < sizeof(struct swrap_packet)) {
- alloc_len = sizeof(struct swrap_packet);
- }
- ret = (struct swrap_packet *)malloc(alloc_len);
- if (!ret) return NULL;
-
- packet = ret;
-
- packet->frame.seconds = tval->tv_sec;
- packet->frame.micro_seconds = tval->tv_usec;
- packet->frame.recorded_length = wire_len - icmp_truncate_len;
- packet->frame.full_length = wire_len - icmp_truncate_len;
-
- packet->ip.hdr.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
- packet->ip.hdr.tos = 0x00;
- packet->ip.hdr.packet_length = htons(wire_len - icmp_truncate_len);
- packet->ip.hdr.identification = htons(0xFFFF);
- packet->ip.hdr.flags = 0x40; /* BIT 1 set - means don't fraqment */
- packet->ip.hdr.fragment = htons(0x0000);
- packet->ip.hdr.ttl = 0xFF;
- packet->ip.hdr.protocol = protocol;
- packet->ip.hdr.hdr_checksum = htons(0x0000);
- packet->ip.hdr.src_addr = src_addr->sin_addr.s_addr;
- packet->ip.hdr.dest_addr = dest_addr->sin_addr.s_addr;
+ if (alloc_len < SWRAP_PACKET_MIN_ALLOC) {
+ alloc_len = SWRAP_PACKET_MIN_ALLOC;
+ }
+
+ base = (uint8_t *)malloc(alloc_len);
+ if (!base) return NULL;
+
+ buf = base;
+
+ frame = (struct swrap_packet_frame *)buf;
+ frame->seconds = tval->tv_sec;
+ frame->micro_seconds = tval->tv_usec;
+ frame->recorded_length = wire_len - icmp_truncate_len;
+ frame->full_length = wire_len - icmp_truncate_len;
+ buf += SWRAP_PACKET_FRAME_SIZE;
+
+ ip = (union swrap_packet_ip *)buf;
+ switch (src->sa_family) {
+ case AF_INET:
+ ip->v4.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
+ ip->v4.tos = 0x00;
+ ip->v4.packet_length = htons(wire_len - icmp_truncate_len);
+ ip->v4.identification = htons(0xFFFF);
+ ip->v4.flags = 0x40; /* BIT 1 set - means don't fraqment */
+ ip->v4.fragment = htons(0x0000);
+ ip->v4.ttl = 0xFF;
+ ip->v4.protocol = protocol;
+ ip->v4.hdr_checksum = htons(0x0000);
+ ip->v4.src_addr = src_in->sin_addr.s_addr;
+ ip->v4.dest_addr = dest_in->sin_addr.s_addr;
+ buf += SWRAP_PACKET_IP_V4_SIZE;
+ break;
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ ip->v6.ver_prio = 0x60; /* version 4 and 5 * 32 bit words */
+ ip->v6.flow_label_high = 0x00;
+ ip->v6.flow_label_low = 0x0000;
+ ip->v6.payload_length = htons(wire_len - icmp_truncate_len);//TODO
+ ip->v6.next_header = protocol;
+ memcpy(ip->v6.src_addr, src_in6->sin6_addr.s6_addr, 16);
+ memcpy(ip->v6.dest_addr, dest_in6->sin6_addr.s6_addr, 16);
+ buf += SWRAP_PACKET_IP_V6_SIZE;
+ break;
+#endif
+ }
if (unreachable) {
- packet->ip.p.icmp.type = 0x03; /* destination unreachable */
- packet->ip.p.icmp.code = 0x01; /* host unreachable */
- packet->ip.p.icmp.checksum = htons(0x0000);
- packet->ip.p.icmp.unused = htonl(0x00000000);
-
- /* set the ip header in the ICMP payload */
- packet = (struct swrap_packet *)(((unsigned char *)ret) + icmp_hdr_len);
- packet->ip.hdr.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
- packet->ip.hdr.tos = 0x00;
- packet->ip.hdr.packet_length = htons(wire_len - icmp_hdr_len);
- packet->ip.hdr.identification = htons(0xFFFF);
- packet->ip.hdr.flags = 0x40; /* BIT 1 set - means don't fraqment */
- packet->ip.hdr.fragment = htons(0x0000);
- packet->ip.hdr.ttl = 0xFF;
- packet->ip.hdr.protocol = icmp_protocol;
- packet->ip.hdr.hdr_checksum = htons(0x0000);
- packet->ip.hdr.src_addr = dest_addr->sin_addr.s_addr;
- packet->ip.hdr.dest_addr = src_addr->sin_addr.s_addr;
-
- src_port = dest_addr->sin_port;
- dest_port = src_addr->sin_port;
+ pay = (union swrap_packet_payload *)buf;
+ switch (src->sa_family) {
+ case AF_INET:
+ pay->icmp4.type = 0x03; /* destination unreachable */
+ pay->icmp4.code = 0x01; /* host unreachable */
+ pay->icmp4.checksum = htons(0x0000);
+ pay->icmp4.unused = htonl(0x00000000);
+ buf += SWRAP_PACKET_PAYLOAD_ICMP4_SIZE;
+
+ /* set the ip header in the ICMP payload */
+ ip = (union swrap_packet_ip *)buf;
+ ip->v4.ver_hdrlen = 0x45; /* version 4 and 5 * 32 bit words */
+ ip->v4.tos = 0x00;
+ ip->v4.packet_length = htons(wire_len - icmp_hdr_len);
+ ip->v4.identification = htons(0xFFFF);
+ ip->v4.flags = 0x40; /* BIT 1 set - means don't fraqment */
+ ip->v4.fragment = htons(0x0000);
+ ip->v4.ttl = 0xFF;
+ ip->v4.protocol = icmp_protocol;
+ ip->v4.hdr_checksum = htons(0x0000);
+ ip->v4.src_addr = dest_in->sin_addr.s_addr;
+ ip->v4.dest_addr = src_in->sin_addr.s_addr;
+ buf += SWRAP_PACKET_IP_V4_SIZE;
+
+ src_port = dest_in->sin_port;
+ dest_port = src_in->sin_port;
+ break;
+#ifdef HAVE_IPV6
+ case AF_INET6:
+ pay->icmp6.type = 0x01; /* destination unreachable */
+ pay->icmp6.code = 0x03; /* address unreachable */
+ pay->icmp6.checksum = htons(0x0000);
+ pay->icmp6.unused = htonl(0x00000000);
+ buf += SWRAP_PACKET_PAYLOAD_ICMP6_SIZE;
+
+ /* set the ip header in the ICMP payload */
+ ip = (union swrap_packet_ip *)buf;
+ ip->v6.ver_prio = 0x60; /* version 4 and 5 * 32 bit words */
+ ip->v6.flow_label_high = 0x00;
+ ip->v6.flow_label_low = 0x0000;
+ ip->v6.payload_length = htons(wire_len - icmp_truncate_len);//TODO
+ ip->v6.next_header = protocol;
+ memcpy(ip->v6.src_addr, dest_in6->sin6_addr.s6_addr, 16);
+ memcpy(ip->v6.dest_addr, src_in6->sin6_addr.s6_addr, 16);
+ buf += SWRAP_PACKET_IP_V6_SIZE;
+
+ src_port = dest_in6->sin6_port;
+ dest_port = src_in6->sin6_port;
+ break;
+#endif
+ }
}
+ pay = (union swrap_packet_payload *)buf;
+
switch (socket_type) {
case SOCK_STREAM:
- packet->ip.p.tcp.source_port = src_port;
- packet->ip.p.tcp.dest_port = dest_port;
- packet->ip.p.tcp.seq_num = htonl(tcp_seqno);
- packet->ip.p.tcp.ack_num = htonl(tcp_ack);
- packet->ip.p.tcp.hdr_length = 0x50; /* 5 * 32 bit words */
- packet->ip.p.tcp.control = tcp_ctl;
- packet->ip.p.tcp.window = htons(0x7FFF);
- packet->ip.p.tcp.checksum = htons(0x0000);
- packet->ip.p.tcp.urg = htons(0x0000);
+ pay->tcp.source_port = src_port;
+ pay->tcp.dest_port = dest_port;
+ pay->tcp.seq_num = htonl(tcp_seqno);
+ pay->tcp.ack_num = htonl(tcp_ack);
+ pay->tcp.hdr_length = 0x50; /* 5 * 32 bit words */
+ pay->tcp.control = tcp_ctl;
+ pay->tcp.window = htons(0x7FFF);
+ pay->tcp.checksum = htons(0x0000);
+ pay->tcp.urg = htons(0x0000);
+ buf += SWRAP_PACKET_PAYLOAD_TCP_SIZE;
break;
case SOCK_DGRAM:
- packet->ip.p.udp.source_port = src_addr->sin_port;
- packet->ip.p.udp.dest_port = dest_addr->sin_port;
- packet->ip.p.udp.length = htons(8 + payload_len);
- packet->ip.p.udp.checksum = htons(0x0000);
+ pay->udp.source_port = src_port;
+ pay->udp.dest_port = dest_port;
+ pay->udp.length = htons(8 + payload_len);
+ pay->udp.checksum = htons(0x0000);
+ buf += SWRAP_PACKET_PAYLOAD_UDP_SIZE;
break;
}
if (payload && payload_len > 0) {
- unsigned char *p = (unsigned char *)ret;
- p += nonwire_len;
- p += wire_hdr_len;
- memcpy(p, payload, payload_len);
+ memcpy(buf, payload, payload_len);
}
*_packet_len = packet_len - icmp_truncate_len;
- return ret;
+ return base;
}
static int swrap_get_pcap_fd(const char *fname)
@@ -911,14 +1065,14 @@ static int swrap_get_pcap_fd(const char *fname)
return fd;
}
-static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
- const struct sockaddr *addr,
- enum swrap_packet_type type,
- const void *buf, size_t len,
- size_t *packet_len)
+static uint8_t *swrap_marshall_packet(struct socket_info *si,
+ const struct sockaddr *addr,
+ enum swrap_packet_type type,
+ const void *buf, size_t len,
+ size_t *packet_len)
{
- const struct sockaddr_in *src_addr;
- const struct sockaddr_in *dest_addr;
+ const struct sockaddr *src_addr;
+ const struct sockaddr *dest_addr;
unsigned long tcp_seqno = 0;
unsigned long tcp_ack = 0;
unsigned char tcp_ctl = 0;
@@ -929,6 +1083,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
switch (si->family) {
case AF_INET:
break;
+ case AF_INET6:
+ break;
default:
return NULL;
}
@@ -937,8 +1093,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CONNECT_SEND:
if (si->type != SOCK_STREAM) return NULL;
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
+ src_addr = si->myname;
+ dest_addr = addr;
tcp_seqno = si->io.pck_snd;
tcp_ack = si->io.pck_rcv;
@@ -951,8 +1107,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CONNECT_RECV:
if (si->type != SOCK_STREAM) return NULL;
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
+ dest_addr = si->myname;
+ src_addr = addr;
tcp_seqno = si->io.pck_rcv;
tcp_ack = si->io.pck_snd;
@@ -965,8 +1121,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CONNECT_UNREACH:
if (si->type != SOCK_STREAM) return NULL;
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
+ dest_addr = si->myname;
+ src_addr = addr;
/* Unreachable: resend the data of SWRAP_CONNECT_SEND */
tcp_seqno = si->io.pck_snd - 1;
@@ -979,8 +1135,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CONNECT_ACK:
if (si->type != SOCK_STREAM) return NULL;
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
+ src_addr = si->myname;
+ dest_addr = addr;
tcp_seqno = si->io.pck_snd;
tcp_ack = si->io.pck_rcv;
@@ -991,8 +1147,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_ACCEPT_SEND:
if (si->type != SOCK_STREAM) return NULL;
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
+ dest_addr = si->myname;
+ src_addr = addr;
tcp_seqno = si->io.pck_rcv;
tcp_ack = si->io.pck_snd;
@@ -1005,8 +1161,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_ACCEPT_RECV:
if (si->type != SOCK_STREAM) return NULL;
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
+ src_addr = si->myname;
+ dest_addr = addr;
tcp_seqno = si->io.pck_snd;
tcp_ack = si->io.pck_rcv;
@@ -1019,8 +1175,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_ACCEPT_ACK:
if (si->type != SOCK_STREAM) return NULL;
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
+ dest_addr = si->myname;
+ src_addr = addr;
tcp_seqno = si->io.pck_rcv;
tcp_ack = si->io.pck_snd;
@@ -1029,8 +1185,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
break;
case SWRAP_SEND:
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)si->peername;
+ src_addr = si->myname;
+ dest_addr = si->peername;
tcp_seqno = si->io.pck_snd;
tcp_ack = si->io.pck_rcv;
@@ -1041,8 +1197,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
break;
case SWRAP_SEND_RST:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
+ dest_addr = si->myname;
+ src_addr = si->peername;
if (si->type == SOCK_DGRAM) {
return swrap_marshall_packet(si, si->peername,
@@ -1057,8 +1213,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
break;
case SWRAP_PENDING_RST:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
+ dest_addr = si->myname;
+ src_addr = si->peername;
if (si->type == SOCK_DGRAM) {
return NULL;
@@ -1071,8 +1227,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
break;
case SWRAP_RECV:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
+ dest_addr = si->myname;
+ src_addr = si->peername;
tcp_seqno = si->io.pck_rcv;
tcp_ack = si->io.pck_snd;
@@ -1083,8 +1239,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
break;
case SWRAP_RECV_RST:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
+ dest_addr = si->myname;
+ src_addr = si->peername;
if (si->type == SOCK_DGRAM) {
return NULL;
@@ -1097,24 +1253,24 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
break;
case SWRAP_SENDTO:
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)addr;
+ src_addr = si->myname;
+ dest_addr = addr;
si->io.pck_snd += len;
break;
case SWRAP_SENDTO_UNREACH:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
+ dest_addr = si->myname;
+ src_addr = addr;
unreachable = 1;
break;
case SWRAP_RECVFROM:
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)addr;
+ dest_addr = si->myname;
+ src_addr = addr;
si->io.pck_rcv += len;
@@ -1123,8 +1279,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CLOSE_SEND:
if (si->type != SOCK_STREAM) return NULL;
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)si->peername;
+ src_addr = si->myname;
+ dest_addr = si->peername;
tcp_seqno = si->io.pck_snd;
tcp_ack = si->io.pck_rcv;
@@ -1137,8 +1293,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CLOSE_RECV:
if (si->type != SOCK_STREAM) return NULL;
- dest_addr = (const struct sockaddr_in *)si->myname;
- src_addr = (const struct sockaddr_in *)si->peername;
+ dest_addr = si->myname;
+ src_addr = si->peername;
tcp_seqno = si->io.pck_rcv;
tcp_ack = si->io.pck_snd;
@@ -1151,8 +1307,8 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
case SWRAP_CLOSE_ACK:
if (si->type != SOCK_STREAM) return NULL;
- src_addr = (const struct sockaddr_in *)si->myname;
- dest_addr = (const struct sockaddr_in *)si->peername;
+ src_addr = si->myname;
+ dest_addr = si->peername;
tcp_seqno = si->io.pck_snd;
tcp_ack = si->io.pck_rcv;
@@ -1166,18 +1322,18 @@ static struct swrap_packet *swrap_marshall_packet(struct socket_info *si,
swrapGetTimeOfDay(&tv);
return swrap_packet_init(&tv, src_addr, dest_addr, si->type,
- (const unsigned char *)buf, len,
- tcp_seqno, tcp_ack, tcp_ctl, unreachable,
- packet_len);
+ (const uint8_t *)buf, len,
+ tcp_seqno, tcp_ack, tcp_ctl, unreachable,
+ packet_len);
}
-static void swrap_dump_packet(struct socket_info *si,
- const struct sockaddr *addr,
- enum swrap_packet_type type,
- const void *buf, size_t len)
+static void swrap_dump_packet(struct socket_info *si,
+ const struct sockaddr *addr,
+ enum swrap_packet_type type,
+ const void *buf, size_t len)
{
const char *file_name;
- struct swrap_packet *packet;
+ uint8_t *packet;
size_t packet_len = 0;
int fd;
@@ -1432,13 +1588,14 @@ static int swrap_auto_bind(struct socket_info *si)
type = SOCKET_TYPE_CHAR_UDP_V6;
break;
default:
- errno = ESOCKTNOSUPPORT;
- return -1;
+ errno = ESOCKTNOSUPPORT;
+ return -1;
}
memset(&in6, 0, sizeof(in6));
in6.sin6_family = AF_INET6;
- in6.sin6_addr.s6_addr[0] = SW_IPV6_ADDRESS;
+ in6.sin6_addr = swrap_ipv6;
+ in6.sin6_addr.s6_addr[15] = socket_wrapper_default_iface();
si->myname_len = sizeof(in6);
si->myname = sockaddr_dup(&in6, si->myname_len);
break;
@@ -1781,7 +1938,7 @@ _PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags)
swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0);
} else if (ret == 0) { /* END OF FILE */
swrap_dump_packet(si, NULL, SWRAP_RECV_RST, NULL, 0);
- } else {
+ } else if (ret > 0) {
swrap_dump_packet(si, NULL, SWRAP_RECV, buf, ret);
}
diff --git a/lib/talloc/configure.ac b/lib/talloc/configure.ac
index d2538f9222..39cea393ce 100644
--- a/lib/talloc/configure.ac
+++ b/lib/talloc/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.50)
-AC_INIT(talloc, 1.2.0)
+AC_INIT(talloc, 1.2.1)
AC_CONFIG_SRCDIR([talloc.c])
AC_SUBST(datarootdir)
AC_CONFIG_HEADER(config.h)
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 1f7e52439f..c472e9fda9 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -806,6 +806,30 @@ void *talloc_check_name(const void *ptr, const char *name)
return NULL;
}
+static void talloc_abort_type_missmatch(const char *location,
+ const char *name,
+ const char *expected)
+{
+ TALLOC_ABORT("Type missmatch");
+}
+
+void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location)
+{
+ const char *pname;
+
+ if (unlikely(ptr == NULL)) {
+ talloc_abort_type_missmatch(location, NULL, name);
+ return NULL;
+ }
+
+ pname = talloc_get_name(ptr);
+ if (likely(pname == name || strcmp(pname, name) == 0)) {
+ return discard_const_p(void, ptr);
+ }
+
+ talloc_abort_type_missmatch(location, pname, name);
+ return NULL;
+}
/*
this is for compatibility with older versions of talloc
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 5431971655..002e06e52d 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -102,6 +102,7 @@ typedef void TALLOC_CTX;
#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
+#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__)
#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type)
@@ -129,6 +130,7 @@ void *talloc_named(const void *context, size_t size,
void *talloc_named_const(const void *context, size_t size, const char *name);
const char *talloc_get_name(const void *ptr);
void *talloc_check_name(const void *ptr, const char *name);
+void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location);
void *talloc_parent(const void *ptr);
const char *talloc_parent_name(const void *ptr);
void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index b19e4cea29..e58c8ca7ff 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -461,6 +461,10 @@ fail:
/* reopen all tdb's */
int tdb_reopen_all(int parent_longlived)
{
+#if defined(LIBREPLACE_PREAD_NOT_REPLACED) && \
+ defined(LIBREPLACE_PWRITE_NOT_REPLACED)
+ return 0;
+#else
struct tdb_context *tdb;
for (tdb=tdbs; tdb; tdb = tdb->next) {
@@ -483,6 +487,7 @@ int tdb_reopen_all(int parent_longlived)
if (tdb_reopen(tdb) != 0)
return -1;
}
+#endif
return 0;
}
diff --git a/lib/tevent/libtevent.m4 b/lib/tevent/libtevent.m4
index 29a64ae3b3..c316823a71 100644
--- a/lib/tevent/libtevent.m4
+++ b/lib/tevent/libtevent.m4
@@ -27,7 +27,7 @@ AC_SUBST(TEVENT_LIBS)
TEVENT_CFLAGS="-I$teventdir"
TEVENT_OBJ="tevent.o tevent_fd.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o"
-TEVENT_OBJ="$TEVENT_OBJ tevent_req.o tevent_wakeup.o"
+TEVENT_OBJ="$TEVENT_OBJ tevent_req.o tevent_wakeup.o tevent_queue.o"
TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o"
AC_CHECK_HEADERS(sys/epoll.h)
diff --git a/lib/tevent/pytevent.c b/lib/tevent/pytevent.c
index 3b45ba1928..fe7e7e3e38 100644
--- a/lib/tevent/pytevent.c
+++ b/lib/tevent/pytevent.c
@@ -29,7 +29,6 @@
#include <tevent.h>
#include <stdbool.h>
-#include "tevent_util.h"
typedef struct {
PyObject_HEAD
@@ -54,7 +53,8 @@ static PyObject *py_backend_list(PyObject *self)
PyObject *ret;
int i, len;
- len = ev_str_list_length(backends);
+ for (len = 0; backends[len]; len++);
+
ret = PyList_New(len);
for (i = 0; i < len; i++)
PyList_SetItem(ret, i, PyString_FromString(backends[i]));
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 33747f0986..5089d18ec2 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -31,7 +31,7 @@
#include <stdint.h>
#include <talloc.h>
#include <sys/time.h>
-#include <../lib/replace/replace.h>
+#include <stdbool.h>
struct tevent_context;
struct tevent_ops;
@@ -183,89 +183,24 @@ enum tevent_req_state {
* finished. This can happen while the completion function is called.
*/
-struct tevent_req {
- /**
- * @brief What to do on completion
- *
- * This is used for the user of an async request, fn is called when
- * the request completes, either successfully or with an error.
- */
- struct {
- /**
- * @brief Completion function
- * Completion function, to be filled by the API user
- */
- void (*fn)(struct tevent_req *);
- /**
- * @brief Private data for the completion function
- */
- void *private_data;
- } async;
+struct tevent_req;
- /**
- * @brief Private state pointer for the actual implementation
- *
- * The implementation doing the work for the async request needs a
- * current state like for example a fd event. The user of an async
- * request should not touch this.
- */
- void *private_state;
+typedef void (*tevent_req_fn)(struct tevent_req *);
- /**
- * @brief Internal state of the request
- *
- * Callers should only access this via functions and never directly.
- */
- struct {
- /**
- * @brief The talloc type of the private_state pointer
- *
- * This is filled by the tevent_req_create() macro.
- *
- * This for debugging only.
- */
- const char *private_type;
-
- /**
- * @brief The location where the request was created
- *
- * This uses the __location__ macro via the tevent_req_create()
- * macro.
- *
- * This for debugging only.
- */
- const char *location;
-
- /**
- * @brief The external state - will be queried by the caller
- *
- * While the async request is being processed, state will remain in
- * TEVENT_REQ_IN_PROGRESS. A request is finished if
- * req->state>=TEVENT_REQ_DONE.
- */
- enum tevent_req_state state;
-
- /**
- * @brief status code when finished
- *
- * This status can be queried in the async completion function. It
- * will be set to 0 when everything went fine.
- */
- uint64_t error;
-
- /**
- * @brief the timer event if tevent_req_post was used
- *
- */
- struct tevent_timer *trigger;
-
- /**
- * @brief the timer event if tevent_req_set_timeout was used
- *
- */
- struct tevent_timer *timer;
- } internal;
-};
+void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt);
+void *_tevent_req_callback_data(struct tevent_req *req);
+void *_tevent_req_data(struct tevent_req *req);
+
+#define tevent_req_callback_data(_req, _type) \
+ talloc_get_type_abort(_tevent_req_callback_data(_req), _type)
+#define tevent_req_data(_req, _type) \
+ talloc_get_type_abort(_tevent_req_data(_req), _type)
+
+typedef char *(*tevent_req_print_fn)(struct tevent_req *, TALLOC_CTX *);
+
+void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn);
+
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx);
char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req);
@@ -296,6 +231,9 @@ struct tevent_req *tevent_req_post(struct tevent_req *req,
bool tevent_req_is_in_progress(struct tevent_req *req);
+bool tevent_req_poll(struct tevent_req *req,
+ struct tevent_context *ev);
+
bool tevent_req_is_error(struct tevent_req *req,
enum tevent_req_state *state,
uint64_t *error);
@@ -324,6 +262,28 @@ struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs);
+struct tevent_queue;
+
+struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
+ const char *name,
+ const char *location);
+
+#define tevent_queue_create(_mem_ctx, _name) \
+ _tevent_queue_create((_mem_ctx), (_name), __location__)
+
+typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
+ void *private_data);
+bool tevent_queue_add(struct tevent_queue *queue,
+ struct tevent_context *ev,
+ struct tevent_req *req,
+ tevent_queue_trigger_fn_t trigger,
+ void *private_data);
+bool tevent_queue_start(struct tevent_queue *queue,
+ struct tevent_context *ev);
+void tevent_queue_stop(struct tevent_queue *queue);
+
+size_t tevent_queue_length(struct tevent_queue *queue);
+
#ifdef TEVENT_COMPAT_DEFINES
#define event_context tevent_context
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 758bdb4628..fa73b22a48 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -25,6 +25,99 @@
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+struct tevent_req {
+ /**
+ * @brief What to do on completion
+ *
+ * This is used for the user of an async request, fn is called when
+ * the request completes, either successfully or with an error.
+ */
+ struct {
+ /**
+ * @brief Completion function
+ * Completion function, to be filled by the API user
+ */
+ tevent_req_fn fn;
+ /**
+ * @brief Private data for the completion function
+ */
+ void *private_data;
+ } async;
+
+ /**
+ * @brief Private state pointer for the actual implementation
+ *
+ * The implementation doing the work for the async request needs to
+ * keep around current data like for example a fd event. The user of
+ * an async request should not touch this.
+ */
+ void *data;
+
+ /**
+ * @brief A function to overwrite the default print function
+ *
+ * The implementation doing the work may want to imeplement a
+ * custom function to print the text representation of the async
+ * request.
+ */
+ tevent_req_print_fn private_print;
+
+ /**
+ * @brief Internal state of the request
+ *
+ * Callers should only access this via functions and never directly.
+ */
+ struct {
+ /**
+ * @brief The talloc type of the data pointer
+ *
+ * This is filled by the tevent_req_create() macro.
+ *
+ * This for debugging only.
+ */
+ const char *private_type;
+
+ /**
+ * @brief The location where the request was created
+ *
+ * This uses the __location__ macro via the tevent_req_create()
+ * macro.
+ *
+ * This for debugging only.
+ */
+ const char *location;
+
+ /**
+ * @brief The external state - will be queried by the caller
+ *
+ * While the async request is being processed, state will remain in
+ * TEVENT_REQ_IN_PROGRESS. A request is finished if
+ * req->state>=TEVENT_REQ_DONE.
+ */
+ enum tevent_req_state state;
+
+ /**
+ * @brief status code when finished
+ *
+ * This status can be queried in the async completion function. It
+ * will be set to 0 when everything went fine.
+ */
+ uint64_t error;
+
+ /**
+ * @brief the timer event if tevent_req_post was used
+ *
+ */
+ struct tevent_timer *trigger;
+
+ /**
+ * @brief the timer event if tevent_req_set_timeout was used
+ *
+ */
+ struct tevent_timer *timer;
+ } internal;
+};
+
struct tevent_ops {
/* conntext init */
int (*context_init)(struct tevent_context *ev);
diff --git a/lib/tevent/tevent_queue.c b/lib/tevent/tevent_queue.c
new file mode 100644
index 0000000000..6c8fbe4f95
--- /dev/null
+++ b/lib/tevent/tevent_queue.c
@@ -0,0 +1,198 @@
+/*
+ Unix SMB/CIFS implementation.
+ Infrastructure for async requests
+ Copyright (C) Volker Lendecke 2008
+ Copyright (C) Stefan Metzmacher 2009
+
+ ** NOTE! The following LGPL license applies to the tevent
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+struct tevent_queue_entry {
+ struct tevent_queue_entry *prev, *next;
+ struct tevent_queue *queue;
+
+ bool triggered;
+
+ struct tevent_req *req;
+
+ tevent_queue_trigger_fn_t trigger;
+ void *private_data;
+};
+
+struct tevent_queue {
+ const char *name;
+ const char *location;
+
+ bool running;
+ struct tevent_timer *timer;
+
+ size_t length;
+ struct tevent_queue_entry *list;
+};
+
+static int tevent_queue_entry_destructor(struct tevent_queue_entry *e)
+{
+ struct tevent_queue *q = e->queue;
+
+ if (!q) {
+ return 0;
+ }
+
+ DLIST_REMOVE(q->list, e);
+ q->length--;
+
+ if (e->triggered &&
+ q->running &&
+ q->list) {
+ q->list->triggered = true;
+ q->list->trigger(q->list->req,
+ q->list->private_data);
+ }
+
+ return 0;
+}
+
+static int tevent_queue_destructor(struct tevent_queue *q)
+{
+ q->running = false;
+
+ while (q->list) {
+ struct tevent_queue_entry *e = q->list;
+ talloc_free(e);
+ }
+
+ return 0;
+}
+
+struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
+ const char *name,
+ const char *location)
+{
+ struct tevent_queue *queue;
+
+ queue = talloc_zero(mem_ctx, struct tevent_queue);
+ if (!queue) {
+ return NULL;
+ }
+
+ queue->name = talloc_strdup(queue, name);
+ if (!queue->name) {
+ talloc_free(queue);
+ return NULL;
+ }
+
+ queue->location = location;
+
+ /* queue is running by default */
+ queue->running = true;
+
+ talloc_set_destructor(queue, tevent_queue_destructor);
+ return queue;
+}
+
+static void tevent_queue_timer_start(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval now,
+ void *private_data)
+{
+ struct tevent_queue *q = talloc_get_type(private_data,
+ struct tevent_queue);
+
+ talloc_free(te);
+ q->timer = NULL;
+
+ q->list->triggered = true;
+ q->list->trigger(q->list->req, q->list->private_data);
+}
+
+bool tevent_queue_add(struct tevent_queue *queue,
+ struct tevent_context *ev,
+ struct tevent_req *req,
+ tevent_queue_trigger_fn_t trigger,
+ void *private_data)
+{
+ struct tevent_queue_entry *e;
+
+ e = talloc_zero(req, struct tevent_queue_entry);
+ if (e == NULL) {
+ return false;
+ }
+
+ e->queue = queue;
+ e->req = req;
+ e->trigger = trigger;
+ e->private_data = private_data;
+
+ if (queue->running &&
+ !queue->timer &&
+ !queue->list) {
+ queue->timer = tevent_add_timer(ev, queue, tevent_timeval_zero(),
+ tevent_queue_timer_start,
+ queue);
+ if (!queue->timer) {
+ talloc_free(e);
+ return false;
+ }
+ }
+
+ DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
+ queue->length++;
+ talloc_set_destructor(e, tevent_queue_entry_destructor);
+
+ return true;
+}
+
+bool tevent_queue_start(struct tevent_queue *queue,
+ struct tevent_context *ev)
+{
+ if (queue->running) {
+ /* already started */
+ return true;
+ }
+
+ if (!queue->timer &&
+ queue->list) {
+ queue->timer = tevent_add_timer(ev, queue, tevent_timeval_zero(),
+ tevent_queue_timer_start,
+ queue);
+ if (!queue->timer) {
+ return false;
+ }
+ }
+
+ queue->running = true;
+
+ return true;
+}
+
+void tevent_queue_stop(struct tevent_queue *queue)
+{
+ queue->running = false;
+ talloc_free(queue->timer);
+ queue->timer = NULL;
+}
+
+size_t tevent_queue_length(struct tevent_queue *queue)
+{
+ return queue->length;
+}
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index 800e3855d1..9b3e00ec8f 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -28,14 +28,17 @@
#include "tevent_util.h"
/**
- * @brief Print an tevent_req structure in debug messages
- * @param[in] mem_ctx The memory context for the result
+ * @brief The default print function for creating debug messages
* @param[in] req The request to be printed
+ * @param[in] mem_ctx The memory context for the result
* @retval Text representation of req
*
+ * The function should not be used by users of the asynx API,
+ * but custom print function can use it and append custom text
+ * to the string.
*/
-char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
{
return talloc_asprintf(mem_ctx,
"tevent_req[%p/%s]: state[%d] error[%lld (0x%llX)] "
@@ -44,13 +47,31 @@ char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
req->internal.state,
(unsigned long long)req->internal.error,
(unsigned long long)req->internal.error,
- talloc_get_name(req->private_state),
- req->private_state,
+ talloc_get_name(req->data),
+ req->data,
req->internal.timer
);
}
/**
+ * @brief Print an tevent_req structure in debug messages
+ * @param[in] mem_ctx The memory context for the result
+ * @param[in] req The request to be printed
+ * @retval Text representation of req
+ *
+ * This function should be used by callers of the async API
+ */
+
+char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+{
+ if (!req->private_print) {
+ return tevent_req_default_print(req, mem_ctx);
+ }
+
+ return req->private_print(req, mem_ctx);
+}
+
+/**
* @brief Create an async request
* @param[in] mem_ctx The memory context for the result
* @param[in] ev The event context this async request will be driven by
@@ -60,14 +81,14 @@ char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
*/
struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
- void *pstate,
- size_t state_size,
+ void *pdata,
+ size_t data_size,
const char *type,
const char *location)
{
struct tevent_req *req;
- void **ppstate = (void **)pstate;
- void *state;
+ void **ppdata = (void **)pdata;
+ void *data;
req = talloc_zero(mem_ctx, struct tevent_req);
if (req == NULL) {
@@ -77,16 +98,16 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
req->internal.location = location;
req->internal.state = TEVENT_REQ_IN_PROGRESS;
- state = talloc_size(req, state_size);
- if (state == NULL) {
+ data = talloc_size(req, data_size);
+ if (data == NULL) {
talloc_free(req);
return NULL;
}
- talloc_set_name_const(state, type);
+ talloc_set_name_const(data, type);
- req->private_state = state;
+ req->data = data;
- *ppstate = state;
+ *ppdata = data;
return req;
}
@@ -235,6 +256,21 @@ bool tevent_req_is_in_progress(struct tevent_req *req)
return false;
}
+bool tevent_req_poll(struct tevent_req *req,
+ struct tevent_context *ev)
+{
+ while (tevent_req_is_in_progress(req)) {
+ int ret;
+
+ ret = tevent_loop_once(ev);
+ if (ret != 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
bool tevent_req_is_error(struct tevent_req *req, enum tevent_req_state *state,
uint64_t *error)
{
@@ -278,3 +314,23 @@ bool tevent_req_set_endtime(struct tevent_req *req,
return true;
}
+void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt)
+{
+ req->async.fn = fn;
+ req->async.private_data = pvt;
+}
+
+void *_tevent_req_callback_data(struct tevent_req *req)
+{
+ return req->async.private_data;
+}
+
+void *_tevent_req_data(struct tevent_req *req)
+{
+ return req->data;
+}
+
+void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn)
+{
+ req->private_print = fn;
+}
diff --git a/lib/torture/config.mk b/lib/torture/config.mk
index abd89260f6..b4ad9ae17f 100644
--- a/lib/torture/config.mk
+++ b/lib/torture/config.mk
@@ -3,7 +3,9 @@
PUBLIC_DEPENDENCIES = \
LIBSAMBA-HOSTCONFIG \
LIBSAMBA-UTIL \
- LIBTALLOC
+ LIBSAMBA-ERRORS \
+ LIBTALLOC \
+ LIBTEVENT
CFLAGS = -I$(libtorturesrcdir) -I$(libtorturesrcdir)/../
torture_VERSION = 0.0.1
diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c
index 1f3b1ac846..258730ec82 100644
--- a/lib/util/charset/charcnv.c
+++ b/lib/util/charset/charcnv.c
@@ -186,7 +186,7 @@ convert:
destlen = 2 + (destlen*3);
ob = talloc_realloc(ctx, outbuf, char, destlen);
if (!ob) {
- DEBUG(0, ("convert_string_talloc: realloc failed!\n"));
+ DEBUG(0, ("iconv_talloc: realloc failed!\n"));
talloc_free(outbuf);
return (size_t)-1;
} else {
@@ -237,10 +237,11 @@ convert:
* @param destlen maximal length allowed for string
* @returns the number of bytes occupied in the destination
**/
-_PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
+_PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
void const *src, size_t srclen,
- void *dest, size_t destlen)
+ void *dest, size_t destlen, size_t *converted_size,
+ bool allow_badcharcnv)
{
size_t i_len, o_len;
size_t retval;
@@ -248,6 +249,11 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
char* outbuf = (char*)dest;
smb_iconv_t descriptor;
+ if (allow_badcharcnv) {
+ /* Not implemented yet */
+ return false;
+ }
+
if (srclen == (size_t)-1)
srclen = strlen(inbuf)+1;
@@ -257,7 +263,8 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
/* conversion not supported, use as is */
size_t len = MIN(srclen,destlen);
memcpy(dest,src,len);
- return len;
+ *converted_size = len;
+ return true;
}
i_len=srclen;
@@ -268,7 +275,7 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
switch(errno) {
case EINVAL:
reason="Incomplete multibyte sequence";
- return -1;
+ return false;
case E2BIG:
reason="No more room";
if (from == CH_UNIX) {
@@ -281,14 +288,16 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
charset_name(ic, from), charset_name(ic, to),
(int)srclen, (int)destlen));
}
- return -1;
+ return false;
case EILSEQ:
reason="Illegal multibyte sequence";
- return -1;
+ return false;
}
/* smb_panic(reason); */
}
- return destlen-o_len;
+ if (converted_size != NULL)
+ *converted_size = destlen-o_len;
+ return true;
}
/**
@@ -301,18 +310,23 @@ _PUBLIC_ ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
* @returns Size in bytes of the converted string; or -1 in case of error.
**/
-_PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
+_PUBLIC_ bool convert_string_talloc_convenience(TALLOC_CTX *ctx,
struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
void const *src, size_t srclen,
- void **dest)
+ void **dest, size_t *converted_size,
+ bool allow_badcharcnv)
{
smb_iconv_t descriptor;
+ ssize_t ret;
+
+ if (allow_badcharcnv)
+ return false; /* Not implemented yet */
*dest = NULL;
if (src == NULL || srclen == (size_t)-1 || srclen == 0)
- return (size_t)-1;
+ return false;
descriptor = get_conv_handle(ic, from, to);
@@ -321,10 +335,15 @@ _PUBLIC_ ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
DEBUG(3, ("convert_string_talloc: conversion from %s to %s not supported!\n",
charset_name(ic, from),
charset_name(ic, to)));
- return -1;
+ return false;
}
- return iconv_talloc(ctx, descriptor, src, srclen, dest);
+ ret = iconv_talloc(ctx, descriptor, src, srclen, dest);
+ if (ret == -1)
+ return false;
+ if (converted_size != NULL)
+ *converted_size = ret;
+ return true;
}
/*
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index f027beb8db..655bae7bcd 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -28,9 +28,16 @@
#include <talloc.h>
/* this defines the charset types used in samba */
-typedef enum {CH_UTF16=0, CH_UNIX, CH_DOS, CH_UTF8, CH_UTF16BE, CH_UTF16MUNGED} charset_t;
+typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX, CH_DISPLAY, CH_DOS, CH_UTF8, CH_UTF16BE, CH_UTF16MUNGED} charset_t;
-#define NUM_CHARSETS 6
+#define NUM_CHARSETS 7
+
+/*
+ * SMB UCS2 (16-bit unicode) internal type.
+ * smb_ucs2_t is *always* in little endian format.
+ */
+
+typedef uint16_t smb_ucs2_t;
/*
* for each charset we have a function that pulls from that charset to
@@ -51,6 +58,17 @@ typedef uint32_t codepoint_t;
#define INVALID_CODEPOINT ((codepoint_t)-1)
+/*
+ * This is auxiliary struct used by source/script/gen-8-bit-gap.sh script
+ * during generation of an encoding table for charset module
+ * */
+
+struct charset_gap_table {
+ uint16_t start;
+ uint16_t end;
+ int32_t idx;
+};
+
/* generic iconv conversion structure */
typedef struct smb_iconv_s {
@@ -61,6 +79,7 @@ typedef struct smb_iconv_s {
size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft);
void *cd_direct, *cd_pull, *cd_push;
+ char *from_name, *to_name;
} *smb_iconv_t;
/* string manipulation flags */
@@ -105,23 +124,24 @@ bool strhaslower(const char *string);
char *strrchr_m(const char *s, char c);
char *strchr_m(const char *s, char c);
-ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
-ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src);
-ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
-ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
-ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src);
-ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src);
+bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
+bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size);
+bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
+bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
+bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src, size_t *converted_size);
+bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size);
ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags);
ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
-ssize_t convert_string_talloc(TALLOC_CTX *ctx,
+bool convert_string_talloc(TALLOC_CTX *ctx,
charset_t from, charset_t to,
void const *src, size_t srclen,
- void **dest);
+ void **dest, size_t *converted_size,
+ bool allow_badcharcnv);
-ssize_t convert_string(charset_t from, charset_t to,
+size_t convert_string(charset_t from, charset_t to,
void const *src, size_t srclen,
- void *dest, size_t destlen);
+ void *dest, size_t destlen, bool allow_badcharcnv);
ssize_t iconv_talloc(TALLOC_CTX *mem_ctx,
smb_iconv_t cd,
@@ -147,15 +167,16 @@ struct smb_iconv_convenience *smb_iconv_convenience_init(TALLOC_CTX *mem_ctx,
const char *unix_charset,
bool native_iconv);
-ssize_t convert_string_convenience(struct smb_iconv_convenience *ic,
+bool convert_string_convenience(struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
void const *src, size_t srclen,
- void *dest, size_t destlen);
-ssize_t convert_string_talloc_convenience(TALLOC_CTX *ctx,
+ void *dest, size_t destlen, size_t *converted_size,
+ bool allow_badcharcnv);
+bool convert_string_talloc_convenience(TALLOC_CTX *ctx,
struct smb_iconv_convenience *ic,
charset_t from, charset_t to,
void const *src, size_t srclen,
- void **dest);
+ void **dest, size_t *converted_size, bool allow_badcharcnv);
/* iconv */
smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode);
int smb_iconv_close(smb_iconv_t cd);
@@ -168,4 +189,81 @@ smb_iconv_t smb_iconv_open_ex(TALLOC_CTX *mem_ctx, const char *tocode,
void load_case_tables(void);
bool charset_register_backend(const void *_funcs);
+/*
+ * Define stub for charset module which implements 8-bit encoding with gaps.
+ * Encoding tables for such module should be produced from glibc's CHARMAPs
+ * using script source/script/gen-8bit-gap.sh
+ * CHARSETNAME is CAPITALIZED charset name
+ *
+ * */
+#define SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CHARSETNAME) \
+static size_t CHARSETNAME ## _push(void *cd, const char **inbuf, size_t *inbytesleft, \
+ char **outbuf, size_t *outbytesleft) \
+{ \
+ while (*inbytesleft >= 2 && *outbytesleft >= 1) { \
+ int i; \
+ int done = 0; \
+ \
+ uint16 ch = SVAL(*inbuf,0); \
+ \
+ for (i=0; from_idx[i].start != 0xffff; i++) { \
+ if ((from_idx[i].start <= ch) && (from_idx[i].end >= ch)) { \
+ ((unsigned char*)(*outbuf))[0] = from_ucs2[from_idx[i].idx+ch]; \
+ (*inbytesleft) -= 2; \
+ (*outbytesleft) -= 1; \
+ (*inbuf) += 2; \
+ (*outbuf) += 1; \
+ done = 1; \
+ break; \
+ } \
+ } \
+ if (!done) { \
+ errno = EINVAL; \
+ return -1; \
+ } \
+ \
+ } \
+ \
+ if (*inbytesleft == 1) { \
+ errno = EINVAL; \
+ return -1; \
+ } \
+ \
+ if (*inbytesleft > 1) { \
+ errno = E2BIG; \
+ return -1; \
+ } \
+ \
+ return 0; \
+} \
+ \
+static size_t CHARSETNAME ## _pull(void *cd, const char **inbuf, size_t *inbytesleft, \
+ char **outbuf, size_t *outbytesleft) \
+{ \
+ while (*inbytesleft >= 1 && *outbytesleft >= 2) { \
+ *(uint16*)(*outbuf) = to_ucs2[((unsigned char*)(*inbuf))[0]]; \
+ (*inbytesleft) -= 1; \
+ (*outbytesleft) -= 2; \
+ (*inbuf) += 1; \
+ (*outbuf) += 2; \
+ } \
+ \
+ if (*inbytesleft > 0) { \
+ errno = E2BIG; \
+ return -1; \
+ } \
+ \
+ return 0; \
+} \
+ \
+struct charset_functions CHARSETNAME ## _functions = \
+ {#CHARSETNAME, CHARSETNAME ## _pull, CHARSETNAME ## _push}; \
+ \
+NTSTATUS charset_ ## CHARSETNAME ## _init(void); \
+NTSTATUS charset_ ## CHARSETNAME ## _init(void) \
+{ \
+ return smb_register_charset(& CHARSETNAME ## _functions); \
+} \
+
+
#endif /* __CHARSET_H__ */
diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c
index b6842a49aa..9825e4be01 100644
--- a/lib/util/charset/iconv.c
+++ b/lib/util/charset/iconv.c
@@ -22,6 +22,7 @@
#include "../lib/util/dlinklist.h"
#include "system/iconv.h"
#include "system/filesys.h"
+#undef strcasecmp
/**
@@ -49,6 +50,7 @@
static size_t ascii_pull (void *,const char **, size_t *, char **, size_t *);
static size_t ascii_push (void *,const char **, size_t *, char **, size_t *);
+static size_t latin1_push (void *,const char **, size_t *, char **, size_t *);
static size_t utf8_pull (void *,const char **, size_t *, char **, size_t *);
static size_t utf8_push (void *,const char **, size_t *, char **, size_t *);
static size_t utf16_munged_pull(void *,const char **, size_t *, char **, size_t *);
@@ -72,6 +74,8 @@ static const struct charset_functions builtin_functions[] = {
{"UTF16_MUNGED", utf16_munged_pull, iconv_copy},
{"ASCII", ascii_pull, ascii_push},
+ {"646", ascii_pull, ascii_push},
+ {"ISO-8859-1", ascii_pull, latin1_push},
{"UCS2-HEX", ucs2hex_pull, ucs2hex_push}
};
@@ -340,6 +344,32 @@ static size_t ascii_push(void *cd, const char **inbuf, size_t *inbytesleft,
return ir_count;
}
+static size_t latin1_push(void *cd, const char **inbuf, size_t *inbytesleft,
+ char **outbuf, size_t *outbytesleft)
+{
+ int ir_count=0;
+
+ while (*inbytesleft >= 2 && *outbytesleft >= 1) {
+ (*outbuf)[0] = (*inbuf)[0];
+ if ((*inbuf)[1]) ir_count++;
+ (*inbytesleft) -= 2;
+ (*outbytesleft) -= 1;
+ (*inbuf) += 2;
+ (*outbuf) += 1;
+ }
+
+ if (*inbytesleft == 1) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (*inbytesleft > 1) {
+ errno = E2BIG;
+ return -1;
+ }
+
+ return ir_count;
+}
static size_t ucs2hex_pull(void *cd, const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c
index 1facea6136..091876f63b 100644
--- a/lib/util/charset/tests/iconv.c
+++ b/lib/util/charset/tests/iconv.c
@@ -404,12 +404,12 @@ static bool test_string2key(struct torture_context *tctx)
uint16_t *buf;
char *dest = NULL;
TALLOC_CTX *mem_ctx = talloc_new(tctx);
- ssize_t ret;
size_t len = (random()%1000)+1;
const uint16_t in1[10] = { 'a', 0xd805, 'b', 0xdcf0, 'c', 0, 'd', 'e', 'f', 'g' };
uint8_t le1[20];
uint8_t *munged1;
uint8_t *out1;
+ size_t ret;
int i;
const char *correct = "a\357\277\275b\357\277\275c\001defg";
@@ -418,8 +418,7 @@ static bool test_string2key(struct torture_context *tctx)
torture_comment(tctx, "converting random buffer\n");
- ret = convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)buf, len*2, (void**)&dest);
- if (ret == -1) {
+ if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)buf, len*2, (void**)&dest, &ret, false)) {
torture_fail(tctx, "Failed to convert random buffer\n");
}
@@ -429,8 +428,7 @@ static bool test_string2key(struct torture_context *tctx)
torture_comment(tctx, "converting fixed buffer to UTF16\n");
- ret = convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF16, (void *)le1, 20, (void**)&munged1);
- if (ret == -1) {
+ if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF16, (void *)le1, 20, (void**)&munged1, &ret, false)) {
torture_fail(tctx, "Failed to convert fixed buffer to UTF16_MUNGED\n");
}
@@ -438,8 +436,7 @@ static bool test_string2key(struct torture_context *tctx)
torture_comment(tctx, "converting fixed buffer to UTF8\n");
- ret = convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)le1, 20, (void**)&out1);
- if (ret == -1) {
+ if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)le1, 20, (void**)&out1, &ret, false)) {
torture_fail(tctx, "Failed to convert fixed buffer to UTF8\n");
}
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index 41b9c94cbb..ec88e784d0 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -656,7 +656,7 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag
if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII))
src_len++;
- return convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len);
+ return convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len, false);
}
/**
@@ -668,11 +668,11 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag
* @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
-_PUBLIC_ ssize_t push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
- return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest);
+ return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, converted_size, false);
}
@@ -706,7 +706,7 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s
}
}
- ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len);
+ ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len, false);
if (dest_len)
dest[MIN(ret, dest_len-1)] = 0;
@@ -759,7 +759,7 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags
/* ucs2 is always a multiple of 2 bytes */
dest_len &= ~1;
- ret = convert_string(CH_UNIX, CH_UTF16, src, src_len, dest, dest_len);
+ ret = convert_string(CH_UNIX, CH_UTF16, src, src_len, dest, dest_len, false);
if (ret == (size_t)-1) {
return 0;
}
@@ -779,11 +779,11 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags
* @returns The number of bytes occupied by the string in the destination
* or -1 in case of error.
**/
-_PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
+_PUBLIC_ bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
- return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, dest);
+ return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, (void **)dest, converted_size, false);
}
@@ -795,11 +795,11 @@ _PUBLIC_ ssize_t push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
* @returns The number of bytes occupied by the string in the destination
**/
-_PUBLIC_ ssize_t push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
- return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest);
+ return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, converted_size, false);
}
/**
@@ -835,7 +835,7 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src
if (src_len != (size_t)-1)
src_len &= ~1;
- ret = convert_string(CH_UTF16, CH_UNIX, src, src_len, dest, dest_len);
+ ret = convert_string(CH_UTF16, CH_UNIX, src, src_len, dest, dest_len, false);
if (dest_len)
dest[MIN(ret, dest_len-1)] = 0;
@@ -850,11 +850,11 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src
* @returns The number of bytes occupied by the string in the destination
**/
-_PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
- return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest);
+ return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
}
/**
@@ -865,11 +865,11 @@ _PUBLIC_ ssize_t pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src
* @returns The number of bytes occupied by the string in the destination
**/
-_PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
+_PUBLIC_ bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src, size_t *converted_size)
{
size_t src_len = utf16_len(src);
*dest = NULL;
- return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest);
+ return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
}
/**
@@ -880,11 +880,11 @@ _PUBLIC_ ssize_t pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const void *src)
* @returns The number of bytes occupied by the string in the destination
**/
-_PUBLIC_ ssize_t pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src)
+_PUBLIC_ bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, size_t *converted_size)
{
size_t src_len = strlen(src)+1;
*dest = NULL;
- return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest);
+ return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, converted_size, false);
}
/**
@@ -950,13 +950,18 @@ _PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_
* @param destlen maximal length allowed for string
* @returns the number of bytes occupied in the destination
**/
-_PUBLIC_ ssize_t convert_string(charset_t from, charset_t to,
+_PUBLIC_ size_t convert_string(charset_t from, charset_t to,
void const *src, size_t srclen,
- void *dest, size_t destlen)
+ void *dest, size_t destlen,
+ bool allow_badcharcnv)
{
- return convert_string_convenience(get_iconv_convenience(), from, to,
+ size_t ret;
+ if (!convert_string_convenience(get_iconv_convenience(), from, to,
src, srclen,
- dest, destlen);
+ dest, destlen, &ret,
+ allow_badcharcnv))
+ return -1;
+ return ret;
}
/**
@@ -964,18 +969,22 @@ _PUBLIC_ ssize_t convert_string(charset_t from, charset_t to,
*
* @param srclen length of source buffer.
* @param dest always set at least to NULL
+ * @param converted_size Size in bytes of the converted string
* @note -1 is not accepted for srclen.
*
- * @returns Size in bytes of the converted string; or -1 in case of error.
+ * @returns boolean indication whether the conversion succeeded
**/
-_PUBLIC_ ssize_t convert_string_talloc(TALLOC_CTX *ctx,
+_PUBLIC_ bool convert_string_talloc(TALLOC_CTX *ctx,
charset_t from, charset_t to,
void const *src, size_t srclen,
- void **dest)
+ void **dest, size_t *converted_size,
+ bool allow_badcharcnv)
{
return convert_string_talloc_convenience(ctx, get_iconv_convenience(),
- from, to, src, srclen, dest);
+ from, to, src, srclen, dest,
+ converted_size,
+ allow_badcharcnv);
}
diff --git a/lib/util/tevent_ntstatus.c b/lib/util/tevent_ntstatus.c
new file mode 100644
index 0000000000..1a34e9c749
--- /dev/null
+++ b/lib/util/tevent_ntstatus.c
@@ -0,0 +1,51 @@
+/*
+ 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_ntstatus.h"
+#include "../replace/replace.h"
+
+bool tevent_req_nterror(struct tevent_req *req, NTSTATUS status)
+{
+ return tevent_req_error(req, NT_STATUS_V(status));
+}
+
+bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *status)
+{
+ 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:
+ *status = NT_STATUS_IO_TIMEOUT;
+ break;
+ case TEVENT_REQ_NO_MEMORY:
+ *status = NT_STATUS_NO_MEMORY;
+ break;
+ case TEVENT_REQ_USER_ERROR:
+ *status = NT_STATUS(err);
+ break;
+ default:
+ *status = NT_STATUS_INTERNAL_ERROR;
+ break;
+ }
+ return true;
+}
diff --git a/lib/util/tevent_ntstatus.h b/lib/util/tevent_ntstatus.h
new file mode 100644
index 0000000000..84c275fb13
--- /dev/null
+++ b/lib/util/tevent_ntstatus.h
@@ -0,0 +1,32 @@
+/*
+ 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_NTSTATUS_H
+#define _TEVENT_NTSTATUS_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "config.h"
+#include "../libcli/util/ntstatus.h"
+#include "../tevent/tevent.h"
+
+bool tevent_req_nterror(struct tevent_req *req, NTSTATUS status);
+bool tevent_req_is_nterror(struct tevent_req *req, NTSTATUS *pstatus);
+
+#endif
diff --git a/lib/util/util.c b/lib/util/util.c
index 988d8f9fa0..0148bdb00d 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -541,21 +541,6 @@ void *malloc_array(size_t el_size, unsigned int count)
return realloc_array(NULL, el_size, count, false);
}
-_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name)
-{
- void *result;
-
- result = talloc_check_name(ptr, name);
- if (result != NULL)
- return result;
-
- DEBUG(0, ("Talloc type mismatch, expected %s, got %s\n",
- name, talloc_get_name(ptr)));
- smb_panic("talloc type mismatch");
- /* Keep the compiler happy */
- return NULL;
-}
-
/**
Trim the specified elements off the front and back of a string.
**/
@@ -836,4 +821,104 @@ _PUBLIC_ size_t utf16_len_n(const void *src, size_t n)
return len;
}
+/**
+ * @file
+ * @brief String utilities.
+ **/
+
+static bool next_token_internal_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep,
+ bool ltrim)
+{
+ char *s;
+ char *saved_s;
+ char *pbuf;
+ bool quoted;
+ size_t len=1;
+
+ *pp_buff = NULL;
+ if (!ptr) {
+ return(false);
+ }
+
+ s = (char *)*ptr;
+
+ /* default to simple separators */
+ if (!sep) {
+ sep = " \t\n\r";
+ }
+
+ /* find the first non sep char, if left-trimming is requested */
+ if (ltrim) {
+ while (*s && strchr_m(sep,*s)) {
+ s++;
+ }
+ }
+
+ /* nothing left? */
+ if (!*s) {
+ return false;
+ }
+
+ /* When restarting we need to go from here. */
+ saved_s = s;
+
+ /* Work out the length needed. */
+ for (quoted = false; *s &&
+ (quoted || !strchr_m(sep,*s)); s++) {
+ if (*s == '\"') {
+ quoted = !quoted;
+ } else {
+ len++;
+ }
+ }
+
+ /* We started with len = 1 so we have space for the nul. */
+ *pp_buff = talloc_array(ctx, char, len);
+ if (!*pp_buff) {
+ return false;
+ }
+
+ /* copy over the token */
+ pbuf = *pp_buff;
+ s = saved_s;
+ for (quoted = false; *s &&
+ (quoted || !strchr_m(sep,*s)); s++) {
+ if ( *s == '\"' ) {
+ quoted = !quoted;
+ } else {
+ *pbuf++ = *s;
+ }
+ }
+
+ *ptr = (*s) ? s+1 : s;
+ *pbuf = 0;
+
+ return true;
+}
+
+bool next_token_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep)
+{
+ return next_token_internal_talloc(ctx, ptr, pp_buff, sep, true);
+}
+
+/*
+ * Get the next token from a string, return false if none found. Handles
+ * double-quotes. This version does not trim leading separator characters
+ * before looking for a token.
+ */
+
+bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep)
+{
+ return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false);
+}
+
diff --git a/lib/util/util.h b/lib/util/util.h
index 27f94cd685..defef127d9 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -204,6 +204,21 @@ _PUBLIC_ void display_set_stderr(void);
/* The following definitions come from lib/util/util_str.c */
+bool next_token_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep);
+
+/**
+ * Get the next token from a string, return false if none found. Handles
+ * double-quotes. This version does not trim leading separator characters
+ * before looking for a token.
+ */
+bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
+ const char **ptr,
+ char **pp_buff,
+ const char *sep);
+
/**
Trim the specified elements off the front and back of a string.
@@ -752,13 +767,6 @@ bool pm_process( const char *fileName,
bool (*pfunc)(const char *, const char *, void *),
void *userdata);
-/**
- * Add-on to talloc_get_type
- */
-_PUBLIC_ void *talloc_check_name_abort(const void *ptr, const char *name);
-#define talloc_get_type_abort(ptr, type) \
- (type *)talloc_check_name_abort(ptr, #type)
-
bool unmap_file(void *start, size_t size);
void print_asc(int level, const uint8_t *buf,int len);
diff --git a/libcli/security/dom_sid.h b/libcli/security/dom_sid.h
index 9d96392777..e89253554e 100644
--- a/libcli/security/dom_sid.h
+++ b/libcli/security/dom_sid.h
@@ -23,6 +23,8 @@
#ifndef _DOM_SID_H_
#define _DOM_SID_H_
+#include "librpc/gen_ndr/security.h"
+
int dom_sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2);
bool dom_sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
bool dom_sid_parse(const char *sidstr, struct dom_sid *ret);
diff --git a/source3/lib/secace.c b/libcli/security/secace.c
index 878fac252b..7d87b1cd5e 100644
--- a/source3/lib/secace.c
+++ b/libcli/security/secace.c
@@ -1,6 +1,6 @@
/*
* Unix SMB/Netbios implementation.
- * SEC_ACE handling functions
+ * struct security_ace handling functions
* Copyright (C) Andrew Tridgell 1992-1998,
* Copyright (C) Jeremy R. Allison 1995-2003.
* Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
@@ -21,56 +21,58 @@
*/
#include "includes.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "libcli/security/dom_sid.h"
-/*******************************************************************
- Check if ACE has OBJECT type.
-********************************************************************/
+#define SEC_ACE_HEADER_SIZE (2 * sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint32_t))
-bool sec_ace_object(uint8 type)
+/**
+ * Check if ACE has OBJECT type.
+ */
+bool sec_ace_object(uint8_t type)
{
if (type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT ||
type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT ||
type == SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT ||
type == SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT) {
- return True;
+ return true;
}
- return False;
+ return false;
}
-/*******************************************************************
- copy a SEC_ACE structure.
-********************************************************************/
-void sec_ace_copy(SEC_ACE *ace_dest, SEC_ACE *ace_src)
+/**
+ * copy a struct security_ace structure.
+ */
+void sec_ace_copy(struct security_ace *ace_dest, struct security_ace *ace_src)
{
ace_dest->type = ace_src->type;
ace_dest->flags = ace_src->flags;
ace_dest->size = ace_src->size;
ace_dest->access_mask = ace_src->access_mask;
ace_dest->object = ace_src->object;
- sid_copy(&ace_dest->trustee, &ace_src->trustee);
+ ace_dest->trustee = ace_src->trustee;
}
/*******************************************************************
- Sets up a SEC_ACE structure.
+ Sets up a struct security_ace structure.
********************************************************************/
-void init_sec_ace(SEC_ACE *t, const DOM_SID *sid, enum security_ace_type type,
- uint32_t mask, uint8 flag)
+void init_sec_ace(struct security_ace *t, const struct dom_sid *sid, enum security_ace_type type,
+ uint32_t mask, uint8_t flag)
{
t->type = type;
t->flags = flag;
t->size = ndr_size_dom_sid(sid, NULL, 0) + 8;
t->access_mask = mask;
- ZERO_STRUCTP(&t->trustee);
- sid_copy(&t->trustee, sid);
+ t->trustee = *sid;
}
/*******************************************************************
adds new SID with its permissions to ACE list
********************************************************************/
-NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, unsigned *num, DOM_SID *sid, uint32 mask)
+NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, struct dom_sid *sid, uint32_t mask)
{
unsigned int i = 0;
@@ -78,7 +80,7 @@ NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, unsign
*num += 1;
- if((pp_new[0] = TALLOC_ZERO_ARRAY(ctx, SEC_ACE, *num )) == 0)
+ if((pp_new[0] = talloc_zero_array(ctx, struct security_ace, *num )) == 0)
return NT_STATUS_NO_MEMORY;
for (i = 0; i < *num - 1; i ++)
@@ -88,7 +90,7 @@ NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, unsign
(*pp_new)[i].flags = 0;
(*pp_new)[i].size = SEC_ACE_HEADER_SIZE + ndr_size_dom_sid(sid, NULL, 0);
(*pp_new)[i].access_mask = mask;
- sid_copy(&(*pp_new)[i].trustee, sid);
+ (*pp_new)[i].trustee = *sid;
return NT_STATUS_OK;
}
@@ -96,14 +98,14 @@ NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, unsign
modify SID's permissions at ACL
********************************************************************/
-NTSTATUS sec_ace_mod_sid(SEC_ACE *ace, size_t num, DOM_SID *sid, uint32 mask)
+NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, struct dom_sid *sid, uint32_t mask)
{
unsigned int i = 0;
if (!ace || !sid) return NT_STATUS_INVALID_PARAMETER;
for (i = 0; i < num; i ++) {
- if (sid_compare(&ace[i].trustee, sid) == 0) {
+ if (dom_sid_equal(&ace[i].trustee, sid)) {
ace[i].access_mask = mask;
return NT_STATUS_OK;
}
@@ -115,7 +117,7 @@ NTSTATUS sec_ace_mod_sid(SEC_ACE *ace, size_t num, DOM_SID *sid, uint32 mask)
delete SID from ACL
********************************************************************/
-NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, uint32 *num, DOM_SID *sid)
+NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, struct dom_sid *sid)
{
unsigned int i = 0;
unsigned int n_del = 0;
@@ -123,14 +125,14 @@ NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, uint32
if (!ctx || !pp_new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER;
if (*num) {
- if((pp_new[0] = TALLOC_ZERO_ARRAY(ctx, SEC_ACE, *num )) == 0)
+ if((pp_new[0] = talloc_zero_array(ctx, struct security_ace, *num )) == 0)
return NT_STATUS_NO_MEMORY;
} else {
pp_new[0] = NULL;
}
for (i = 0; i < *num; i ++) {
- if (sid_compare(&old[i].trustee, sid) != 0)
+ if (!dom_sid_equal(&old[i].trustee, sid))
sec_ace_copy(&(*pp_new)[i], &old[i]);
else
n_del ++;
@@ -144,38 +146,38 @@ NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, uint32
}
/*******************************************************************
- Compares two SEC_ACE structures
+ Compares two struct security_ace structures
********************************************************************/
-bool sec_ace_equal(SEC_ACE *s1, SEC_ACE *s2)
+bool sec_ace_equal(struct security_ace *s1, struct security_ace *s2)
{
/* Trivial case */
if (!s1 && !s2) {
- return True;
+ return true;
}
if (!s1 || !s2) {
- return False;
+ return false;
}
/* Check top level stuff */
if (s1->type != s2->type || s1->flags != s2->flags ||
s1->access_mask != s2->access_mask) {
- return False;
+ return false;
}
/* Check SID */
- if (!sid_equal(&s1->trustee, &s2->trustee)) {
- return False;
+ if (!dom_sid_equal(&s1->trustee, &s2->trustee)) {
+ return false;
}
- return True;
+ return true;
}
-int nt_ace_inherit_comp( SEC_ACE *a1, SEC_ACE *a2)
+int nt_ace_inherit_comp( struct security_ace *a1, struct security_ace *a2)
{
int a1_inh = a1->flags & SEC_ACE_FLAG_INHERITED_ACE;
int a2_inh = a2->flags & SEC_ACE_FLAG_INHERITED_ACE;
@@ -192,7 +194,7 @@ int nt_ace_inherit_comp( SEC_ACE *a1, SEC_ACE *a2)
Comparison function to apply the order explained below in a group.
*******************************************************************/
-int nt_ace_canon_comp( SEC_ACE *a1, SEC_ACE *a2)
+int nt_ace_canon_comp( struct security_ace *a1, struct security_ace *a2)
{
if ((a1->type == SEC_ACE_TYPE_ACCESS_DENIED) &&
(a2->type != SEC_ACE_TYPE_ACCESS_DENIED))
@@ -247,7 +249,7 @@ The following describes the preferred order:
********************************************************************/
-void dacl_sort_into_canonical_order(SEC_ACE *srclist, unsigned int num_aces)
+void dacl_sort_into_canonical_order(struct security_ace *srclist, unsigned int num_aces)
{
unsigned int i;
@@ -259,7 +261,7 @@ void dacl_sort_into_canonical_order(SEC_ACE *srclist, unsigned int num_aces)
/* Find the boundary between non-inherited ACEs. */
for (i = 0; i < num_aces; i++ ) {
- SEC_ACE *curr_ace = &srclist[i];
+ struct security_ace *curr_ace = &srclist[i];
if (curr_ace->flags & SEC_ACE_FLAG_INHERITED_ACE)
break;
@@ -276,18 +278,4 @@ void dacl_sort_into_canonical_order(SEC_ACE *srclist, unsigned int num_aces)
qsort( &srclist[i], num_aces - i, sizeof(srclist[0]), QSORT_CAST nt_ace_canon_comp);
}
-/*******************************************************************
- Check if this ACE has a SID in common with the token.
-********************************************************************/
-
-bool token_sid_in_ace(const NT_USER_TOKEN *token, const SEC_ACE *ace)
-{
- size_t i;
- for (i = 0; i < token->num_sids; i++) {
- if (sid_equal(&ace->trustee, &token->user_sids[i]))
- return True;
- }
-
- return False;
-}
diff --git a/libcli/security/secace.h b/libcli/security/secace.h
new file mode 100644
index 0000000000..8b6625d07d
--- /dev/null
+++ b/libcli/security/secace.h
@@ -0,0 +1,39 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+
+ Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
+
+ 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 _ACE_H_
+#define _ACE_H_
+
+#include "librpc/gen_ndr/security.h"
+
+bool sec_ace_object(uint8_t type);
+void sec_ace_copy(struct security_ace *ace_dest, struct security_ace *ace_src);
+void init_sec_ace(struct security_ace *t, const struct dom_sid *sid, enum security_ace_type type,
+ uint32_t mask, uint8_t flag);
+NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, unsigned *num, struct dom_sid *sid, uint32_t mask);
+NTSTATUS sec_ace_mod_sid(struct security_ace *ace, size_t num, struct dom_sid *sid, uint32_t mask);
+NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, struct security_ace **pp_new, struct security_ace *old, uint32_t *num, struct dom_sid *sid);
+bool sec_ace_equal(struct security_ace *s1, struct security_ace *s2);
+int nt_ace_inherit_comp( struct security_ace *a1, struct security_ace *a2);
+int nt_ace_canon_comp( struct security_ace *a1, struct security_ace *a2);
+void dacl_sort_into_canonical_order(struct security_ace *srclist, unsigned int num_aces);
+
+#endif /*_ACE_H_*/
+
diff --git a/source3/lib/secacl.c b/libcli/security/secacl.c
index 5e82242e1b..9373ef5812 100644
--- a/source3/lib/secacl.c
+++ b/libcli/security/secacl.c
@@ -21,18 +21,23 @@
*/
#include "includes.h"
+#include "librpc/gen_ndr/ndr_security.h"
+#include "libcli/security/secace.h"
+
+#define SEC_ACL_HEADER_SIZE (2 * sizeof(uint16_t) + sizeof(uint32_t))
/*******************************************************************
Create a SEC_ACL structure.
********************************************************************/
-SEC_ACL *make_sec_acl(TALLOC_CTX *ctx, enum security_acl_revision revision,
- int num_aces, SEC_ACE *ace_list)
+struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
+ enum security_acl_revision revision,
+ int num_aces, struct security_ace *ace_list)
{
- SEC_ACL *dst;
+ struct security_acl *dst;
int i;
- if((dst = TALLOC_ZERO_P(ctx,SEC_ACL)) == NULL)
+ if((dst = talloc_zero(ctx, struct security_acl)) == NULL)
return NULL;
dst->revision = revision;
@@ -46,7 +51,7 @@ SEC_ACL *make_sec_acl(TALLOC_CTX *ctx, enum security_acl_revision revision,
positive number. */
if ((num_aces) &&
- ((dst->aces = TALLOC_ARRAY(ctx, SEC_ACE, num_aces))
+ ((dst->aces = talloc_array(ctx, struct security_ace, num_aces))
== NULL)) {
return NULL;
}
@@ -63,7 +68,7 @@ SEC_ACL *make_sec_acl(TALLOC_CTX *ctx, enum security_acl_revision revision,
Duplicate a SEC_ACL structure.
********************************************************************/
-SEC_ACL *dup_sec_acl(TALLOC_CTX *ctx, SEC_ACL *src)
+struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src)
{
if(src == NULL)
return NULL;
@@ -75,44 +80,44 @@ SEC_ACL *dup_sec_acl(TALLOC_CTX *ctx, SEC_ACL *src)
Compares two SEC_ACL structures
********************************************************************/
-bool sec_acl_equal(SEC_ACL *s1, SEC_ACL *s2)
+bool sec_acl_equal(struct security_acl *s1, struct security_acl *s2)
{
unsigned int i, j;
/* Trivial cases */
- if (!s1 && !s2) return True;
- if (!s1 || !s2) return False;
+ if (!s1 && !s2) return true;
+ if (!s1 || !s2) return false;
/* Check top level stuff */
if (s1->revision != s2->revision) {
DEBUG(10, ("sec_acl_equal(): revision differs (%d != %d)\n",
s1->revision, s2->revision));
- return False;
+ return false;
}
if (s1->num_aces != s2->num_aces) {
DEBUG(10, ("sec_acl_equal(): num_aces differs (%d != %d)\n",
s1->revision, s2->revision));
- return False;
+ return false;
}
/* The ACEs could be in any order so check each ACE in s1 against
each ACE in s2. */
for (i = 0; i < s1->num_aces; i++) {
- bool found = False;
+ bool found = false;
for (j = 0; j < s2->num_aces; j++) {
if (sec_ace_equal(&s1->aces[i], &s2->aces[j])) {
- found = True;
+ found = true;
break;
}
}
- if (!found) return False;
+ if (!found) return false;
}
- return True;
+ return true;
}
diff --git a/libcli/security/secacl.h b/libcli/security/secacl.h
new file mode 100644
index 0000000000..9f1e8fa183
--- /dev/null
+++ b/libcli/security/secacl.h
@@ -0,0 +1,33 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba utility functions
+
+ Copyright (C) 2009 Jelmer Vernooij <jelmer@samba.org>
+
+ 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 _SECACL_H_
+#define _SECACL_H_
+
+#include "librpc/gen_ndr/security.h"
+
+struct security_acl *make_sec_acl(TALLOC_CTX *ctx, enum security_acl_revision revision,
+ int num_aces, struct security_ace *ace_list);
+struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src);
+bool sec_acl_equal(struct security_acl *s1, struct security_acl *s2);
+
+
+#endif /*_SECACL_H_*/
+
diff --git a/libcli/util/doserr.c b/libcli/util/doserr.c
index 1044ab351a..5104c3ee02 100644
--- a/libcli/util/doserr.c
+++ b/libcli/util/doserr.c
@@ -133,6 +133,7 @@ static const struct werror_code_struct dos_errs[] =
{ "WERR_NO_SPOOL_SPACE", WERR_NO_SPOOL_SPACE },
{ "WERR_CAN_NOT_COMPLETE", WERR_CAN_NOT_COMPLETE },
{ "WERR_INVALID_FLAGS", WERR_INVALID_FLAGS },
+ { "WERR_DEVICE_NOT_CONNECTED", WERR_DEVICE_NOT_CONNECTED },
{ "WERR_NOT_FOUND", WERR_NOT_FOUND },
{ "WERR_SERVER_UNAVAILABLE", WERR_SERVER_UNAVAILABLE },
{ "WERR_INVALID_USER_BUFFER", WERR_INVALID_USER_BUFFER },
diff --git a/libcli/util/werror.h b/libcli/util/werror.h
index 4b34b14243..d92232706a 100644
--- a/libcli/util/werror.h
+++ b/libcli/util/werror.h
@@ -60,6 +60,18 @@ typedef uint32_t WERROR;
}\
} while (0)
+#define W_ERROR_NOT_OK_GOTO_DONE(x) do { \
+ if (!W_ERROR_IS_OK(x)) {\
+ goto done;\
+ }\
+} while (0)
+
+#define W_ERROR_NOT_OK_GOTO(x, y) do {\
+ if (!W_ERROR_IS_OK(x)) {\
+ goto y;\
+ }\
+} while(0)
+
/* these are win32 error codes. There are only a few places where
these matter for Samba, primarily in the NT printing code */
#define WERR_OK W_ERROR(0)
@@ -102,6 +114,7 @@ typedef uint32_t WERROR;
#define WERR_SERVICE_ALREADY_RUNNING W_ERROR(1056)
#define WERR_SERVICE_DISABLED W_ERROR(1058)
#define WERR_SERVICE_NEVER_STARTED W_ERROR(1077)
+#define WERR_DEVICE_NOT_CONNECTED W_ERROR(1167)
#define WERR_NOT_FOUND W_ERROR(1168)
#define WERR_INVALID_COMPUTERNAME W_ERROR(1210)
#define WERR_INVALID_DOMAINNAME W_ERROR(1212)
diff --git a/librpc/gen_ndr/dfs.h b/librpc/gen_ndr/dfs.h
index 07548c3742..41be3bd28d 100644
--- a/librpc/gen_ndr/dfs.h
+++ b/librpc/gen_ndr/dfs.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#ifndef _HEADER_netdfs
#define _HEADER_netdfs
diff --git a/librpc/gen_ndr/drsblobs.h b/librpc/gen_ndr/drsblobs.h
index bb33464c76..190e012cb5 100644
--- a/librpc/gen_ndr/drsblobs.h
+++ b/librpc/gen_ndr/drsblobs.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/drsuapi.h"
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/samr.h"
diff --git a/librpc/gen_ndr/drsuapi.h b/librpc/gen_ndr/drsuapi.h
index e3d480365e..8f9b165631 100644
--- a/librpc/gen_ndr/drsuapi.h
+++ b/librpc/gen_ndr/drsuapi.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/samr.h"
diff --git a/librpc/gen_ndr/dssetup.h b/librpc/gen_ndr/dssetup.h
index d284a63375..5d254fe92e 100644
--- a/librpc/gen_ndr/dssetup.h
+++ b/librpc/gen_ndr/dssetup.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#ifndef _HEADER_dssetup
#define _HEADER_dssetup
diff --git a/librpc/gen_ndr/echo.h b/librpc/gen_ndr/echo.h
index 79d4220714..9c783046f3 100644
--- a/librpc/gen_ndr/echo.h
+++ b/librpc/gen_ndr/echo.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#ifndef _HEADER_rpcecho
#define _HEADER_rpcecho
diff --git a/librpc/gen_ndr/epmapper.h b/librpc/gen_ndr/epmapper.h
index e5155a8cad..ff80fbb4fd 100644
--- a/librpc/gen_ndr/epmapper.h
+++ b/librpc/gen_ndr/epmapper.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#ifndef _HEADER_epmapper
#define _HEADER_epmapper
diff --git a/librpc/gen_ndr/eventlog.h b/librpc/gen_ndr/eventlog.h
index 2a9b824601..b6e792fdd3 100644
--- a/librpc/gen_ndr/eventlog.h
+++ b/librpc/gen_ndr/eventlog.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/security.h"
#ifndef _HEADER_eventlog
diff --git a/librpc/gen_ndr/initshutdown.h b/librpc/gen_ndr/initshutdown.h
index 014e2fe689..913eb8f740 100644
--- a/librpc/gen_ndr/initshutdown.h
+++ b/librpc/gen_ndr/initshutdown.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/lsa.h"
#ifndef _HEADER_initshutdown
#define _HEADER_initshutdown
diff --git a/librpc/gen_ndr/krb5pac.h b/librpc/gen_ndr/krb5pac.h
index 73bd0d95bb..03b23bdaae 100644
--- a/librpc/gen_ndr/krb5pac.h
+++ b/librpc/gen_ndr/krb5pac.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/netlogon.h"
#include "librpc/gen_ndr/samr.h"
diff --git a/librpc/gen_ndr/lsa.h b/librpc/gen_ndr/lsa.h
index 03a0464d5b..a6da7a6cef 100644
--- a/librpc/gen_ndr/lsa.h
+++ b/librpc/gen_ndr/lsa.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/security.h"
#ifndef _HEADER_lsarpc
diff --git a/librpc/gen_ndr/misc.h b/librpc/gen_ndr/misc.h
index e000cb0624..824483d292 100644
--- a/librpc/gen_ndr/misc.h
+++ b/librpc/gen_ndr/misc.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#ifndef _HEADER_misc
#define _HEADER_misc
diff --git a/librpc/gen_ndr/named_pipe_auth.h b/librpc/gen_ndr/named_pipe_auth.h
index 7ca7444c92..e35c221118 100644
--- a/librpc/gen_ndr/named_pipe_auth.h
+++ b/librpc/gen_ndr/named_pipe_auth.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/netlogon.h"
#ifndef _HEADER_named_pipe_auth
#define _HEADER_named_pipe_auth
diff --git a/librpc/gen_ndr/nbt.h b/librpc/gen_ndr/nbt.h
index 1f3ad37d9b..affbeffa08 100644
--- a/librpc/gen_ndr/nbt.h
+++ b/librpc/gen_ndr/nbt.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/svcctl.h"
diff --git a/librpc/gen_ndr/ndr_drsblobs.c b/librpc/gen_ndr/ndr_drsblobs.c
index 72e182d3ff..ee7c9933c2 100644
--- a/librpc/gen_ndr/ndr_drsblobs.c
+++ b/librpc/gen_ndr/ndr_drsblobs.c
@@ -1870,9 +1870,6 @@ static enum ndr_err_code ndr_push_package_PrimaryKerberosCtr4(struct ndr_push *n
for (cntr_keys_0 = 0; cntr_keys_0 < r->num_keys; cntr_keys_0++) {
NDR_CHECK(ndr_push_package_PrimaryKerberosKey4(ndr, NDR_SCALARS, &r->keys[cntr_keys_0]));
}
- for (cntr_service_keys_0 = 0; cntr_service_keys_0 < 0; cntr_service_keys_0++) {
- NDR_CHECK(ndr_push_package_PrimaryKerberosKey4(ndr, NDR_SCALARS, &r->service_keys[cntr_service_keys_0]));
- }
for (cntr_old_keys_0 = 0; cntr_old_keys_0 < r->num_old_keys; cntr_old_keys_0++) {
NDR_CHECK(ndr_push_package_PrimaryKerberosKey4(ndr, NDR_SCALARS, &r->old_keys[cntr_old_keys_0]));
}
@@ -1885,9 +1882,6 @@ static enum ndr_err_code ndr_push_package_PrimaryKerberosCtr4(struct ndr_push *n
for (cntr_keys_0 = 0; cntr_keys_0 < r->num_keys; cntr_keys_0++) {
NDR_CHECK(ndr_push_package_PrimaryKerberosKey4(ndr, NDR_BUFFERS, &r->keys[cntr_keys_0]));
}
- for (cntr_service_keys_0 = 0; cntr_service_keys_0 < 0; cntr_service_keys_0++) {
- NDR_CHECK(ndr_push_package_PrimaryKerberosKey4(ndr, NDR_BUFFERS, &r->service_keys[cntr_service_keys_0]));
- }
for (cntr_old_keys_0 = 0; cntr_old_keys_0 < r->num_old_keys; cntr_old_keys_0++) {
NDR_CHECK(ndr_push_package_PrimaryKerberosKey4(ndr, NDR_BUFFERS, &r->old_keys[cntr_old_keys_0]));
}
diff --git a/librpc/gen_ndr/ndr_spoolss.c b/librpc/gen_ndr/ndr_spoolss.c
index fdafa2582b..f82f42e146 100644
--- a/librpc/gen_ndr/ndr_spoolss.c
+++ b/librpc/gen_ndr/ndr_spoolss.c
@@ -224,6 +224,86 @@ _PUBLIC_ void ndr_print_spoolss_MinorVersion(struct ndr_print *ndr, const char *
ndr_print_enum(ndr, name, "ENUM", val, r);
}
+static enum ndr_err_code ndr_push_spoolss_PrinterStatus(struct ndr_push *ndr, int ndr_flags, uint32_t r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_PrinterStatus(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_PrinterStatus(struct ndr_print *ndr, const char *name, uint32_t r)
+{
+ ndr_print_uint32(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAUSED", PRINTER_STATUS_PAUSED, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_ERROR", PRINTER_STATUS_ERROR, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PENDING_DELETION", PRINTER_STATUS_PENDING_DELETION, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_JAM", PRINTER_STATUS_PAPER_JAM, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_OUT", PRINTER_STATUS_PAPER_OUT, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_MANUAL_FEED", PRINTER_STATUS_MANUAL_FEED, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_PROBLEM", PRINTER_STATUS_PAPER_PROBLEM, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OFFLINE", PRINTER_STATUS_OFFLINE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_IO_ACTIVE", PRINTER_STATUS_IO_ACTIVE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_BUSY", PRINTER_STATUS_BUSY, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PRINTING", PRINTER_STATUS_PRINTING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OUTPUT_BIN_FULL", PRINTER_STATUS_OUTPUT_BIN_FULL, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_NOT_AVAILABLE", PRINTER_STATUS_NOT_AVAILABLE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_WAITING", PRINTER_STATUS_WAITING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PROCESSING", PRINTER_STATUS_PROCESSING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_INITIALIZING", PRINTER_STATUS_INITIALIZING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_WARMING_UP", PRINTER_STATUS_WARMING_UP, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_TONER_LOW", PRINTER_STATUS_TONER_LOW, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_NO_TONER", PRINTER_STATUS_NO_TONER, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAGE_PUNT", PRINTER_STATUS_PAGE_PUNT, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_USER_INTERVENTION", PRINTER_STATUS_USER_INTERVENTION, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OUT_OF_MEMORY", PRINTER_STATUS_OUT_OF_MEMORY, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_DOOR_OPEN", PRINTER_STATUS_DOOR_OPEN, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_SERVER_UNKNOWN", PRINTER_STATUS_SERVER_UNKNOWN, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_POWER_SAVE", PRINTER_STATUS_POWER_SAVE, r);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_JobStatus(struct ndr_push *ndr, int ndr_flags, uint32_t r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_JobStatus(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_JobStatus(struct ndr_print *ndr, const char *name, uint32_t r)
+{
+ ndr_print_uint32(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_PAUSED", JOB_STATUS_PAUSED, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_ERROR", JOB_STATUS_ERROR, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_DELETING", JOB_STATUS_DELETING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_SPOOLING", JOB_STATUS_SPOOLING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_PRINTING", JOB_STATUS_PRINTING, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_OFFLINE", JOB_STATUS_OFFLINE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_PAPEROUT", JOB_STATUS_PAPEROUT, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_PRINTED", JOB_STATUS_PRINTED, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_DELETED", JOB_STATUS_DELETED, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_BLOCKED_DEVQ", JOB_STATUS_BLOCKED_DEVQ, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_USER_INTERVENTION", JOB_STATUS_USER_INTERVENTION, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_RESTART", JOB_STATUS_RESTART, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_STATUS_COMPLETE", JOB_STATUS_COMPLETE, r);
+ ndr->depth--;
+}
+
static enum ndr_err_code ndr_push_spoolss_PrinterInfo0(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo0 *r)
{
if (ndr_flags & NDR_SCALARS) {
@@ -253,13 +333,13 @@ static enum ndr_err_code ndr_push_spoolss_PrinterInfo0(struct ndr_push *ndr, int
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->session_counter));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_error_out_of_paper));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_error_not_ready));
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_error));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->job_error));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->number_of_processors));
NDR_CHECK(ndr_push_spoolss_ProcessorType(ndr, NDR_SCALARS, r->processor_type));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->high_part_total_bytes));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->change_id));
NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->last_error));
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_spoolss_PrinterStatus(ndr, NDR_SCALARS, r->status));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->enumerate_network_printers));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->c_setprinter));
NDR_CHECK(ndr_push_spoolss_ProcessorArchitecture(ndr, NDR_SCALARS, r->processor_architecture));
@@ -336,13 +416,13 @@ static enum ndr_err_code ndr_pull_spoolss_PrinterInfo0(struct ndr_pull *ndr, int
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->session_counter));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_error_out_of_paper));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_error_not_ready));
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_error));
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->job_error));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->number_of_processors));
NDR_CHECK(ndr_pull_spoolss_ProcessorType(ndr, NDR_SCALARS, &r->processor_type));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->high_part_total_bytes));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->change_id));
NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->last_error));
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_spoolss_PrinterStatus(ndr, NDR_SCALARS, &r->status));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->enumerate_network_printers));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->c_setprinter));
NDR_CHECK(ndr_pull_spoolss_ProcessorArchitecture(ndr, NDR_SCALARS, &r->processor_architecture));
@@ -415,13 +495,13 @@ _PUBLIC_ void ndr_print_spoolss_PrinterInfo0(struct ndr_print *ndr, const char *
ndr_print_uint32(ndr, "session_counter", r->session_counter);
ndr_print_uint32(ndr, "num_error_out_of_paper", r->num_error_out_of_paper);
ndr_print_uint32(ndr, "num_error_not_ready", r->num_error_not_ready);
- ndr_print_uint32(ndr, "job_error", r->job_error);
+ ndr_print_spoolss_JobStatus(ndr, "job_error", r->job_error);
ndr_print_uint32(ndr, "number_of_processors", r->number_of_processors);
ndr_print_spoolss_ProcessorType(ndr, "processor_type", r->processor_type);
ndr_print_uint32(ndr, "high_part_total_bytes", r->high_part_total_bytes);
ndr_print_uint32(ndr, "change_id", r->change_id);
ndr_print_WERROR(ndr, "last_error", r->last_error);
- ndr_print_uint32(ndr, "status", r->status);
+ ndr_print_spoolss_PrinterStatus(ndr, "status", r->status);
ndr_print_uint32(ndr, "enumerate_network_printers", r->enumerate_network_printers);
ndr_print_uint32(ndr, "c_setprinter", r->c_setprinter);
ndr_print_spoolss_ProcessorArchitecture(ndr, "processor_architecture", r->processor_architecture);
@@ -895,52 +975,6 @@ _PUBLIC_ void ndr_print_spoolss_PrinterAttributes(struct ndr_print *ndr, const c
ndr->depth--;
}
-static enum ndr_err_code ndr_push_spoolss_PrinterStatus(struct ndr_push *ndr, int ndr_flags, uint32_t r)
-{
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
- return NDR_ERR_SUCCESS;
-}
-
-static enum ndr_err_code ndr_pull_spoolss_PrinterStatus(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
-{
- uint32_t v;
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
- *r = v;
- return NDR_ERR_SUCCESS;
-}
-
-_PUBLIC_ void ndr_print_spoolss_PrinterStatus(struct ndr_print *ndr, const char *name, uint32_t r)
-{
- ndr_print_uint32(ndr, name, r);
- ndr->depth++;
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAUSED", PRINTER_STATUS_PAUSED, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_ERROR", PRINTER_STATUS_ERROR, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PENDING_DELETION", PRINTER_STATUS_PENDING_DELETION, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_JAM", PRINTER_STATUS_PAPER_JAM, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_OUT", PRINTER_STATUS_PAPER_OUT, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_MANUAL_FEED", PRINTER_STATUS_MANUAL_FEED, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAPER_PROBLEM", PRINTER_STATUS_PAPER_PROBLEM, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OFFLINE", PRINTER_STATUS_OFFLINE, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_IO_ACTIVE", PRINTER_STATUS_IO_ACTIVE, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_BUSY", PRINTER_STATUS_BUSY, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PRINTING", PRINTER_STATUS_PRINTING, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OUTPUT_BIN_FULL", PRINTER_STATUS_OUTPUT_BIN_FULL, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_NOT_AVAILABLE", PRINTER_STATUS_NOT_AVAILABLE, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_WAITING", PRINTER_STATUS_WAITING, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PROCESSING", PRINTER_STATUS_PROCESSING, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_INITIALIZING", PRINTER_STATUS_INITIALIZING, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_WARMING_UP", PRINTER_STATUS_WARMING_UP, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_TONER_LOW", PRINTER_STATUS_TONER_LOW, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_NO_TONER", PRINTER_STATUS_NO_TONER, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_PAGE_PUNT", PRINTER_STATUS_PAGE_PUNT, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_USER_INTERVENTION", PRINTER_STATUS_USER_INTERVENTION, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_OUT_OF_MEMORY", PRINTER_STATUS_OUT_OF_MEMORY, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_DOOR_OPEN", PRINTER_STATUS_DOOR_OPEN, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_SERVER_UNKNOWN", PRINTER_STATUS_SERVER_UNKNOWN, r);
- ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_STATUS_POWER_SAVE", PRINTER_STATUS_POWER_SAVE, r);
- ndr->depth--;
-}
-
static enum ndr_err_code ndr_push_spoolss_PrinterInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PrinterInfo2 *r)
{
if (ndr_flags & NDR_SCALARS) {
@@ -2561,12 +2595,12 @@ static enum ndr_err_code ndr_push_spoolss_JobInfo1(struct ndr_push *ndr, int ndr
NDR_CHECK(ndr_push_relative_ptr1(ndr, r->text_status));
ndr->flags = _flags_save_string;
}
- NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->status));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed));
- NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->time));
+ NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
}
if (ndr_flags & NDR_BUFFERS) {
{
@@ -2716,12 +2750,12 @@ static enum ndr_err_code ndr_pull_spoolss_JobInfo1(struct ndr_pull *ndr, int ndr
}
ndr->flags = _flags_save_string;
}
- NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->status));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed));
- NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->time));
+ NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
}
if (ndr_flags & NDR_BUFFERS) {
{
@@ -2859,12 +2893,1291 @@ _PUBLIC_ void ndr_print_spoolss_JobInfo1(struct ndr_print *ndr, const char *name
ndr_print_string(ndr, "text_status", r->text_status);
}
ndr->depth--;
- ndr_print_uint32(ndr, "status", r->status);
+ ndr_print_spoolss_JobStatus(ndr, "status", r->status);
ndr_print_uint32(ndr, "priority", r->priority);
ndr_print_uint32(ndr, "position", r->position);
ndr_print_uint32(ndr, "total_pages", r->total_pages);
ndr_print_uint32(ndr, "pages_printed", r->pages_printed);
- ndr_print_spoolss_Time(ndr, "time", &r->time);
+ ndr_print_spoolss_Time(ndr, "submitted", &r->submitted);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_JobInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo2 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printer_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->server_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->user_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->document_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->notify_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->data_type));
+ 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->print_processor));
+ 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->parameters));
+ 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->driver_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->devmode));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->text_status));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->secdesc));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->start_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->until_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size));
+ NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->printer_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printer_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printer_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->server_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->server_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->server_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->user_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->user_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->document_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->document_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->document_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->notify_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->notify_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->notify_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->data_type) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_type));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_type));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->print_processor) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->print_processor));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->print_processor));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->parameters) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->parameters));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->parameters));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ 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;
+ }
+ if (r->devmode) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->devmode));
+ NDR_CHECK(ndr_push_spoolss_DeviceMode(ndr, NDR_SCALARS, r->devmode));
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->text_status) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->text_status));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->text_status));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->secdesc) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, 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_JobInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo2 *r)
+{
+ uint32_t _ptr_printer_name;
+ TALLOC_CTX *_mem_save_printer_name_0;
+ uint32_t _ptr_server_name;
+ TALLOC_CTX *_mem_save_server_name_0;
+ uint32_t _ptr_user_name;
+ TALLOC_CTX *_mem_save_user_name_0;
+ uint32_t _ptr_document_name;
+ TALLOC_CTX *_mem_save_document_name_0;
+ uint32_t _ptr_notify_name;
+ TALLOC_CTX *_mem_save_notify_name_0;
+ uint32_t _ptr_data_type;
+ TALLOC_CTX *_mem_save_data_type_0;
+ uint32_t _ptr_print_processor;
+ TALLOC_CTX *_mem_save_print_processor_0;
+ uint32_t _ptr_parameters;
+ TALLOC_CTX *_mem_save_parameters_0;
+ uint32_t _ptr_driver_name;
+ TALLOC_CTX *_mem_save_driver_name_0;
+ uint32_t _ptr_devmode;
+ TALLOC_CTX *_mem_save_devmode_0;
+ uint32_t _ptr_text_status;
+ TALLOC_CTX *_mem_save_text_status_0;
+ 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_uint32(ndr, NDR_SCALARS, &r->job_id));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printer_name));
+ if (_ptr_printer_name) {
+ NDR_PULL_ALLOC(ndr, r->printer_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printer_name, _ptr_printer_name));
+ } else {
+ r->printer_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_server_name));
+ if (_ptr_server_name) {
+ NDR_PULL_ALLOC(ndr, r->server_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->server_name, _ptr_server_name));
+ } else {
+ r->server_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_user_name));
+ if (_ptr_user_name) {
+ NDR_PULL_ALLOC(ndr, r->user_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->user_name, _ptr_user_name));
+ } else {
+ r->user_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_document_name));
+ if (_ptr_document_name) {
+ NDR_PULL_ALLOC(ndr, r->document_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->document_name, _ptr_document_name));
+ } else {
+ r->document_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_notify_name));
+ if (_ptr_notify_name) {
+ NDR_PULL_ALLOC(ndr, r->notify_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->notify_name, _ptr_notify_name));
+ } else {
+ r->notify_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_data_type));
+ if (_ptr_data_type) {
+ NDR_PULL_ALLOC(ndr, r->data_type);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_type, _ptr_data_type));
+ } else {
+ r->data_type = 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_print_processor));
+ if (_ptr_print_processor) {
+ NDR_PULL_ALLOC(ndr, r->print_processor);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->print_processor, _ptr_print_processor));
+ } else {
+ r->print_processor = 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_parameters));
+ if (_ptr_parameters) {
+ NDR_PULL_ALLOC(ndr, r->parameters);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->parameters, _ptr_parameters));
+ } else {
+ r->parameters = 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_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;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode));
+ if (_ptr_devmode) {
+ NDR_PULL_ALLOC(ndr, r->devmode);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->devmode, _ptr_devmode));
+ } else {
+ r->devmode = NULL;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_text_status));
+ if (_ptr_text_status) {
+ NDR_PULL_ALLOC(ndr, r->text_status);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->text_status, _ptr_text_status));
+ } else {
+ r->text_status = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_secdesc));
+ if (_ptr_secdesc) {
+ NDR_PULL_ALLOC(ndr, r->secdesc);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->secdesc, _ptr_secdesc));
+ } else {
+ r->secdesc = NULL;
+ }
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->start_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->until_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->printer_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printer_name));
+ _mem_save_printer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->printer_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printer_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printer_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->server_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->server_name));
+ _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->server_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->server_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_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->user_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->user_name));
+ _mem_save_user_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->user_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_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->document_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->document_name));
+ _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->document_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_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->notify_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->notify_name));
+ _mem_save_notify_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->notify_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->notify_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_notify_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->data_type) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_type));
+ _mem_save_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->data_type, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_type));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_type_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->print_processor) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->print_processor));
+ _mem_save_print_processor_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->print_processor, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->print_processor));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_print_processor_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->parameters) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->parameters));
+ _mem_save_parameters_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->parameters, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->parameters));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_parameters_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->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;
+ }
+ if (r->devmode) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->devmode));
+ _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0);
+ NDR_CHECK(ndr_pull_spoolss_DeviceMode(ndr, NDR_SCALARS, r->devmode));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_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->text_status) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->text_status));
+ _mem_save_text_status_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->text_status, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->text_status));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_text_status_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->secdesc) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, 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);
+ ndr->offset = _relative_save_offset;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_JobInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo2 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_JobInfo2");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "job_id", r->job_id);
+ ndr_print_ptr(ndr, "printer_name", r->printer_name);
+ ndr->depth++;
+ if (r->printer_name) {
+ ndr_print_string(ndr, "printer_name", r->printer_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "server_name", r->server_name);
+ ndr->depth++;
+ if (r->server_name) {
+ ndr_print_string(ndr, "server_name", r->server_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "user_name", r->user_name);
+ ndr->depth++;
+ if (r->user_name) {
+ ndr_print_string(ndr, "user_name", r->user_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "document_name", r->document_name);
+ ndr->depth++;
+ if (r->document_name) {
+ ndr_print_string(ndr, "document_name", r->document_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "notify_name", r->notify_name);
+ ndr->depth++;
+ if (r->notify_name) {
+ ndr_print_string(ndr, "notify_name", r->notify_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "data_type", r->data_type);
+ ndr->depth++;
+ if (r->data_type) {
+ ndr_print_string(ndr, "data_type", r->data_type);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "print_processor", r->print_processor);
+ ndr->depth++;
+ if (r->print_processor) {
+ ndr_print_string(ndr, "print_processor", r->print_processor);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "parameters", r->parameters);
+ ndr->depth++;
+ if (r->parameters) {
+ ndr_print_string(ndr, "parameters", r->parameters);
+ }
+ ndr->depth--;
+ 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, "devmode", r->devmode);
+ ndr->depth++;
+ if (r->devmode) {
+ ndr_print_spoolss_DeviceMode(ndr, "devmode", r->devmode);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "text_status", r->text_status);
+ ndr->depth++;
+ if (r->text_status) {
+ ndr_print_string(ndr, "text_status", r->text_status);
+ }
+ 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_spoolss_JobStatus(ndr, "status", r->status);
+ ndr_print_uint32(ndr, "priority", r->priority);
+ ndr_print_uint32(ndr, "position", r->position);
+ ndr_print_uint32(ndr, "start_time", r->start_time);
+ ndr_print_uint32(ndr, "until_time", r->until_time);
+ ndr_print_uint32(ndr, "total_pages", r->total_pages);
+ ndr_print_uint32(ndr, "size", r->size);
+ ndr_print_spoolss_Time(ndr, "submitted", &r->submitted);
+ ndr_print_uint32(ndr, "time", r->time);
+ ndr_print_uint32(ndr, "pages_printed", r->pages_printed);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_JobInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo3 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->next_job_id));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->reserved));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_JobInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo3 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_id));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->next_job_id));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->reserved));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_JobInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo3 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_JobInfo3");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "job_id", r->job_id);
+ ndr_print_uint32(ndr, "next_job_id", r->next_job_id);
+ ndr_print_uint32(ndr, "reserved", r->reserved);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_JobInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_JobInfo4 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->printer_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->server_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->user_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->document_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->notify_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->data_type));
+ 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->print_processor));
+ 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->parameters));
+ 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->driver_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->devmode));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->text_status));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->secdesc));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->start_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->until_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size));
+ NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size_high));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->printer_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->printer_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->printer_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->server_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->server_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->server_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->user_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->user_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->user_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->document_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->document_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->document_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->notify_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->notify_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->notify_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->data_type) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->data_type));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->data_type));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->print_processor) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->print_processor));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->print_processor));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->parameters) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->parameters));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->parameters));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ 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;
+ }
+ if (r->devmode) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->devmode));
+ NDR_CHECK(ndr_push_spoolss_DeviceMode(ndr, NDR_SCALARS, r->devmode));
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->text_status) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->text_status));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->text_status));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->secdesc) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, 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_JobInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_JobInfo4 *r)
+{
+ uint32_t _ptr_printer_name;
+ TALLOC_CTX *_mem_save_printer_name_0;
+ uint32_t _ptr_server_name;
+ TALLOC_CTX *_mem_save_server_name_0;
+ uint32_t _ptr_user_name;
+ TALLOC_CTX *_mem_save_user_name_0;
+ uint32_t _ptr_document_name;
+ TALLOC_CTX *_mem_save_document_name_0;
+ uint32_t _ptr_notify_name;
+ TALLOC_CTX *_mem_save_notify_name_0;
+ uint32_t _ptr_data_type;
+ TALLOC_CTX *_mem_save_data_type_0;
+ uint32_t _ptr_print_processor;
+ TALLOC_CTX *_mem_save_print_processor_0;
+ uint32_t _ptr_parameters;
+ TALLOC_CTX *_mem_save_parameters_0;
+ uint32_t _ptr_driver_name;
+ TALLOC_CTX *_mem_save_driver_name_0;
+ uint32_t _ptr_devmode;
+ TALLOC_CTX *_mem_save_devmode_0;
+ uint32_t _ptr_text_status;
+ TALLOC_CTX *_mem_save_text_status_0;
+ 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_uint32(ndr, NDR_SCALARS, &r->job_id));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printer_name));
+ if (_ptr_printer_name) {
+ NDR_PULL_ALLOC(ndr, r->printer_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->printer_name, _ptr_printer_name));
+ } else {
+ r->printer_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_server_name));
+ if (_ptr_server_name) {
+ NDR_PULL_ALLOC(ndr, r->server_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->server_name, _ptr_server_name));
+ } else {
+ r->server_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_user_name));
+ if (_ptr_user_name) {
+ NDR_PULL_ALLOC(ndr, r->user_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->user_name, _ptr_user_name));
+ } else {
+ r->user_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_document_name));
+ if (_ptr_document_name) {
+ NDR_PULL_ALLOC(ndr, r->document_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->document_name, _ptr_document_name));
+ } else {
+ r->document_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_notify_name));
+ if (_ptr_notify_name) {
+ NDR_PULL_ALLOC(ndr, r->notify_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->notify_name, _ptr_notify_name));
+ } else {
+ r->notify_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_data_type));
+ if (_ptr_data_type) {
+ NDR_PULL_ALLOC(ndr, r->data_type);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->data_type, _ptr_data_type));
+ } else {
+ r->data_type = 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_print_processor));
+ if (_ptr_print_processor) {
+ NDR_PULL_ALLOC(ndr, r->print_processor);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->print_processor, _ptr_print_processor));
+ } else {
+ r->print_processor = 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_parameters));
+ if (_ptr_parameters) {
+ NDR_PULL_ALLOC(ndr, r->parameters);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->parameters, _ptr_parameters));
+ } else {
+ r->parameters = 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_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;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_devmode));
+ if (_ptr_devmode) {
+ NDR_PULL_ALLOC(ndr, r->devmode);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->devmode, _ptr_devmode));
+ } else {
+ r->devmode = NULL;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_text_status));
+ if (_ptr_text_status) {
+ NDR_PULL_ALLOC(ndr, r->text_status);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->text_status, _ptr_text_status));
+ } else {
+ r->text_status = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_secdesc));
+ if (_ptr_secdesc) {
+ NDR_PULL_ALLOC(ndr, r->secdesc);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->secdesc, _ptr_secdesc));
+ } else {
+ r->secdesc = NULL;
+ }
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->start_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->until_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size_high));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->printer_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->printer_name));
+ _mem_save_printer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->printer_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->printer_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printer_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->server_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->server_name));
+ _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->server_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->server_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_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->user_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->user_name));
+ _mem_save_user_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->user_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->user_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_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->document_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->document_name));
+ _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->document_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_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->notify_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->notify_name));
+ _mem_save_notify_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->notify_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->notify_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_notify_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->data_type) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->data_type));
+ _mem_save_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->data_type, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->data_type));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_type_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->print_processor) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->print_processor));
+ _mem_save_print_processor_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->print_processor, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->print_processor));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_print_processor_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->parameters) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->parameters));
+ _mem_save_parameters_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->parameters, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->parameters));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_parameters_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->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;
+ }
+ if (r->devmode) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->devmode));
+ _mem_save_devmode_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->devmode, 0);
+ NDR_CHECK(ndr_pull_spoolss_DeviceMode(ndr, NDR_SCALARS, r->devmode));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_devmode_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->text_status) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->text_status));
+ _mem_save_text_status_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->text_status, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->text_status));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_text_status_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ if (r->secdesc) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, 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);
+ ndr->offset = _relative_save_offset;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_JobInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo4 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_JobInfo4");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "job_id", r->job_id);
+ ndr_print_ptr(ndr, "printer_name", r->printer_name);
+ ndr->depth++;
+ if (r->printer_name) {
+ ndr_print_string(ndr, "printer_name", r->printer_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "server_name", r->server_name);
+ ndr->depth++;
+ if (r->server_name) {
+ ndr_print_string(ndr, "server_name", r->server_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "user_name", r->user_name);
+ ndr->depth++;
+ if (r->user_name) {
+ ndr_print_string(ndr, "user_name", r->user_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "document_name", r->document_name);
+ ndr->depth++;
+ if (r->document_name) {
+ ndr_print_string(ndr, "document_name", r->document_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "notify_name", r->notify_name);
+ ndr->depth++;
+ if (r->notify_name) {
+ ndr_print_string(ndr, "notify_name", r->notify_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "data_type", r->data_type);
+ ndr->depth++;
+ if (r->data_type) {
+ ndr_print_string(ndr, "data_type", r->data_type);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "print_processor", r->print_processor);
+ ndr->depth++;
+ if (r->print_processor) {
+ ndr_print_string(ndr, "print_processor", r->print_processor);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "parameters", r->parameters);
+ ndr->depth++;
+ if (r->parameters) {
+ ndr_print_string(ndr, "parameters", r->parameters);
+ }
+ ndr->depth--;
+ 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, "devmode", r->devmode);
+ ndr->depth++;
+ if (r->devmode) {
+ ndr_print_spoolss_DeviceMode(ndr, "devmode", r->devmode);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "text_status", r->text_status);
+ ndr->depth++;
+ if (r->text_status) {
+ ndr_print_string(ndr, "text_status", r->text_status);
+ }
+ 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_spoolss_JobStatus(ndr, "status", r->status);
+ ndr_print_uint32(ndr, "priority", r->priority);
+ ndr_print_uint32(ndr, "position", r->position);
+ ndr_print_uint32(ndr, "start_time", r->start_time);
+ ndr_print_uint32(ndr, "until_time", r->until_time);
+ ndr_print_uint32(ndr, "total_pages", r->total_pages);
+ ndr_print_uint32(ndr, "size", r->size);
+ ndr_print_spoolss_Time(ndr, "submitted", &r->submitted);
+ ndr_print_uint32(ndr, "time", r->time);
+ ndr_print_uint32(ndr, "pages_printed", r->pages_printed);
+ ndr_print_uint32(ndr, "size_high", r->size_high);
ndr->depth--;
}
@@ -2881,9 +4194,21 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo(struct ndr_push *ndr, int nd
break; }
case 2: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_JobInfo2(ndr, NDR_SCALARS, &r->info2));
break; }
case 3: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_JobInfo3(ndr, NDR_SCALARS, &r->info3));
+ break; }
+
+ case 4: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_JobInfo4(ndr, NDR_SCALARS, &r->info4));
break; }
default: {
@@ -2900,11 +4225,16 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_JobInfo(struct ndr_push *ndr, int nd
break;
case 2:
+ NDR_CHECK(ndr_push_spoolss_JobInfo2(ndr, NDR_BUFFERS, &r->info2));
break;
case 3:
break;
+ case 4:
+ NDR_CHECK(ndr_push_spoolss_JobInfo4(ndr, NDR_BUFFERS, &r->info4));
+ break;
+
default:
break;
@@ -2928,9 +4258,21 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo(struct ndr_pull *ndr, int nd
break; }
case 2: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_JobInfo2(ndr, NDR_SCALARS, &r->info2));
break; }
case 3: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_JobInfo3(ndr, NDR_SCALARS, &r->info3));
+ break; }
+
+ case 4: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_JobInfo4(ndr, NDR_SCALARS, &r->info4));
break; }
default: {
@@ -2946,11 +4288,16 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_JobInfo(struct ndr_pull *ndr, int nd
break;
case 2:
+ NDR_CHECK(ndr_pull_spoolss_JobInfo2(ndr, NDR_BUFFERS, &r->info2));
break;
case 3:
break;
+ case 4:
+ NDR_CHECK(ndr_pull_spoolss_JobInfo4(ndr, NDR_BUFFERS, &r->info4));
+ break;
+
default:
break;
@@ -2971,9 +4318,1272 @@ _PUBLIC_ void ndr_print_spoolss_JobInfo(struct ndr_print *ndr, const char *name,
break;
case 2:
+ ndr_print_spoolss_JobInfo2(ndr, "info2", &r->info2);
+ break;
+
+ case 3:
+ ndr_print_spoolss_JobInfo3(ndr, "info3", &r->info3);
+ break;
+
+ case 4:
+ ndr_print_spoolss_JobInfo4(ndr, "info4", &r->info4);
+ break;
+
+ default:
+ break;
+
+ }
+}
+
+static enum ndr_err_code ndr_push_spoolss_SetJobInfo1(struct ndr_push *ndr, int ndr_flags, const struct spoolss_SetJobInfo1 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->printer_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->server_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->user_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->document_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->data_type));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->text_status));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed));
+ NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->printer_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->printer_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->printer_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->printer_name, ndr_charset_length(r->printer_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->server_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->server_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->server_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->server_name, ndr_charset_length(r->server_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->user_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->user_name, ndr_charset_length(r->user_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->document_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->document_name, ndr_charset_length(r->document_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->data_type) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->data_type, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->data_type, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->data_type, ndr_charset_length(r->data_type, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->text_status) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->text_status, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->text_status, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->text_status, ndr_charset_length(r->text_status, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_SetJobInfo1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_SetJobInfo1 *r)
+{
+ uint32_t _ptr_printer_name;
+ TALLOC_CTX *_mem_save_printer_name_0;
+ uint32_t _ptr_server_name;
+ TALLOC_CTX *_mem_save_server_name_0;
+ uint32_t _ptr_user_name;
+ TALLOC_CTX *_mem_save_user_name_0;
+ uint32_t _ptr_document_name;
+ TALLOC_CTX *_mem_save_document_name_0;
+ uint32_t _ptr_data_type;
+ TALLOC_CTX *_mem_save_data_type_0;
+ uint32_t _ptr_text_status;
+ TALLOC_CTX *_mem_save_text_status_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_id));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printer_name));
+ if (_ptr_printer_name) {
+ NDR_PULL_ALLOC(ndr, r->printer_name);
+ } else {
+ r->printer_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server_name));
+ if (_ptr_server_name) {
+ NDR_PULL_ALLOC(ndr, r->server_name);
+ } else {
+ r->server_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_user_name));
+ if (_ptr_user_name) {
+ NDR_PULL_ALLOC(ndr, r->user_name);
+ } else {
+ r->user_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_document_name));
+ if (_ptr_document_name) {
+ NDR_PULL_ALLOC(ndr, r->document_name);
+ } else {
+ r->document_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_type));
+ if (_ptr_data_type) {
+ NDR_PULL_ALLOC(ndr, r->data_type);
+ } else {
+ r->data_type = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_text_status));
+ if (_ptr_text_status) {
+ NDR_PULL_ALLOC(ndr, r->text_status);
+ } else {
+ r->text_status = NULL;
+ }
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed));
+ NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->printer_name) {
+ _mem_save_printer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->printer_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->printer_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->printer_name));
+ if (ndr_get_array_length(ndr, &r->printer_name) > ndr_get_array_size(ndr, &r->printer_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->printer_name), ndr_get_array_length(ndr, &r->printer_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->printer_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->printer_name, ndr_get_array_length(ndr, &r->printer_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printer_name_0, 0);
+ }
+ if (r->server_name) {
+ _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->server_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->server_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->server_name));
+ if (ndr_get_array_length(ndr, &r->server_name) > ndr_get_array_size(ndr, &r->server_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->server_name), ndr_get_array_length(ndr, &r->server_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->server_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->server_name, ndr_get_array_length(ndr, &r->server_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_name_0, 0);
+ }
+ if (r->user_name) {
+ _mem_save_user_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->user_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->user_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->user_name));
+ if (ndr_get_array_length(ndr, &r->user_name) > ndr_get_array_size(ndr, &r->user_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->user_name), ndr_get_array_length(ndr, &r->user_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->user_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->user_name, ndr_get_array_length(ndr, &r->user_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_name_0, 0);
+ }
+ if (r->document_name) {
+ _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->document_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->document_name));
+ if (ndr_get_array_length(ndr, &r->document_name) > ndr_get_array_size(ndr, &r->document_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->document_name), ndr_get_array_length(ndr, &r->document_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->document_name, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_name_0, 0);
+ }
+ if (r->data_type) {
+ _mem_save_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->data_type, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->data_type));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->data_type));
+ if (ndr_get_array_length(ndr, &r->data_type) > ndr_get_array_size(ndr, &r->data_type)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->data_type), ndr_get_array_length(ndr, &r->data_type));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->data_type), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->data_type, ndr_get_array_length(ndr, &r->data_type), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_type_0, 0);
+ }
+ if (r->text_status) {
+ _mem_save_text_status_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->text_status, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->text_status));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->text_status));
+ if (ndr_get_array_length(ndr, &r->text_status) > ndr_get_array_size(ndr, &r->text_status)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->text_status), ndr_get_array_length(ndr, &r->text_status));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->text_status), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->text_status, ndr_get_array_length(ndr, &r->text_status), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_text_status_0, 0);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_SetJobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo1 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_SetJobInfo1");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "job_id", r->job_id);
+ ndr_print_ptr(ndr, "printer_name", r->printer_name);
+ ndr->depth++;
+ if (r->printer_name) {
+ ndr_print_string(ndr, "printer_name", r->printer_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "server_name", r->server_name);
+ ndr->depth++;
+ if (r->server_name) {
+ ndr_print_string(ndr, "server_name", r->server_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "user_name", r->user_name);
+ ndr->depth++;
+ if (r->user_name) {
+ ndr_print_string(ndr, "user_name", r->user_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "document_name", r->document_name);
+ ndr->depth++;
+ if (r->document_name) {
+ ndr_print_string(ndr, "document_name", r->document_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "data_type", r->data_type);
+ ndr->depth++;
+ if (r->data_type) {
+ ndr_print_string(ndr, "data_type", r->data_type);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "text_status", r->text_status);
+ ndr->depth++;
+ if (r->text_status) {
+ ndr_print_string(ndr, "text_status", r->text_status);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_JobStatus(ndr, "status", r->status);
+ ndr_print_uint32(ndr, "priority", r->priority);
+ ndr_print_uint32(ndr, "position", r->position);
+ ndr_print_uint32(ndr, "total_pages", r->total_pages);
+ ndr_print_uint32(ndr, "pages_printed", r->pages_printed);
+ ndr_print_spoolss_Time(ndr, "submitted", &r->submitted);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_SetJobInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_SetJobInfo2 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->printer_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->server_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->user_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->document_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->notify_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->data_type));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->print_processor));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->parameters));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->driver_name));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->_devmode_ptr));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->text_status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->_secdesc_ptr));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->start_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->until_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size));
+ NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->printer_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->printer_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->printer_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->printer_name, ndr_charset_length(r->printer_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->server_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->server_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->server_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->server_name, ndr_charset_length(r->server_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->user_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->user_name, ndr_charset_length(r->user_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->document_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->document_name, ndr_charset_length(r->document_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->notify_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->notify_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->notify_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->notify_name, ndr_charset_length(r->notify_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->data_type) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->data_type, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->data_type, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->data_type, ndr_charset_length(r->data_type, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->print_processor) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->print_processor, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->print_processor, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->print_processor, ndr_charset_length(r->print_processor, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->parameters) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->parameters, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->parameters, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->parameters, ndr_charset_length(r->parameters, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->driver_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->driver_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->driver_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->driver_name, ndr_charset_length(r->driver_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->text_status) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->text_status, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->text_status, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->text_status, ndr_charset_length(r->text_status, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_SetJobInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_SetJobInfo2 *r)
+{
+ uint32_t _ptr_printer_name;
+ TALLOC_CTX *_mem_save_printer_name_0;
+ uint32_t _ptr_server_name;
+ TALLOC_CTX *_mem_save_server_name_0;
+ uint32_t _ptr_user_name;
+ TALLOC_CTX *_mem_save_user_name_0;
+ uint32_t _ptr_document_name;
+ TALLOC_CTX *_mem_save_document_name_0;
+ uint32_t _ptr_notify_name;
+ TALLOC_CTX *_mem_save_notify_name_0;
+ uint32_t _ptr_data_type;
+ TALLOC_CTX *_mem_save_data_type_0;
+ uint32_t _ptr_print_processor;
+ TALLOC_CTX *_mem_save_print_processor_0;
+ uint32_t _ptr_parameters;
+ TALLOC_CTX *_mem_save_parameters_0;
+ uint32_t _ptr_driver_name;
+ TALLOC_CTX *_mem_save_driver_name_0;
+ uint32_t _ptr_text_status;
+ TALLOC_CTX *_mem_save_text_status_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_id));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printer_name));
+ if (_ptr_printer_name) {
+ NDR_PULL_ALLOC(ndr, r->printer_name);
+ } else {
+ r->printer_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server_name));
+ if (_ptr_server_name) {
+ NDR_PULL_ALLOC(ndr, r->server_name);
+ } else {
+ r->server_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_user_name));
+ if (_ptr_user_name) {
+ NDR_PULL_ALLOC(ndr, r->user_name);
+ } else {
+ r->user_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_document_name));
+ if (_ptr_document_name) {
+ NDR_PULL_ALLOC(ndr, r->document_name);
+ } else {
+ r->document_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_notify_name));
+ if (_ptr_notify_name) {
+ NDR_PULL_ALLOC(ndr, r->notify_name);
+ } else {
+ r->notify_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_type));
+ if (_ptr_data_type) {
+ NDR_PULL_ALLOC(ndr, r->data_type);
+ } else {
+ r->data_type = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_print_processor));
+ if (_ptr_print_processor) {
+ NDR_PULL_ALLOC(ndr, r->print_processor);
+ } else {
+ r->print_processor = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_parameters));
+ if (_ptr_parameters) {
+ NDR_PULL_ALLOC(ndr, r->parameters);
+ } else {
+ r->parameters = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name));
+ if (_ptr_driver_name) {
+ NDR_PULL_ALLOC(ndr, r->driver_name);
+ } else {
+ r->driver_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_devmode_ptr));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_text_status));
+ if (_ptr_text_status) {
+ NDR_PULL_ALLOC(ndr, r->text_status);
+ } else {
+ r->text_status = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_secdesc_ptr));
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->start_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->until_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->printer_name) {
+ _mem_save_printer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->printer_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->printer_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->printer_name));
+ if (ndr_get_array_length(ndr, &r->printer_name) > ndr_get_array_size(ndr, &r->printer_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->printer_name), ndr_get_array_length(ndr, &r->printer_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->printer_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->printer_name, ndr_get_array_length(ndr, &r->printer_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printer_name_0, 0);
+ }
+ if (r->server_name) {
+ _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->server_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->server_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->server_name));
+ if (ndr_get_array_length(ndr, &r->server_name) > ndr_get_array_size(ndr, &r->server_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->server_name), ndr_get_array_length(ndr, &r->server_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->server_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->server_name, ndr_get_array_length(ndr, &r->server_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_name_0, 0);
+ }
+ if (r->user_name) {
+ _mem_save_user_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->user_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->user_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->user_name));
+ if (ndr_get_array_length(ndr, &r->user_name) > ndr_get_array_size(ndr, &r->user_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->user_name), ndr_get_array_length(ndr, &r->user_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->user_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->user_name, ndr_get_array_length(ndr, &r->user_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_name_0, 0);
+ }
+ if (r->document_name) {
+ _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->document_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->document_name));
+ if (ndr_get_array_length(ndr, &r->document_name) > ndr_get_array_size(ndr, &r->document_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->document_name), ndr_get_array_length(ndr, &r->document_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->document_name, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_name_0, 0);
+ }
+ if (r->notify_name) {
+ _mem_save_notify_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->notify_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->notify_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->notify_name));
+ if (ndr_get_array_length(ndr, &r->notify_name) > ndr_get_array_size(ndr, &r->notify_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->notify_name), ndr_get_array_length(ndr, &r->notify_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->notify_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->notify_name, ndr_get_array_length(ndr, &r->notify_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_notify_name_0, 0);
+ }
+ if (r->data_type) {
+ _mem_save_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->data_type, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->data_type));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->data_type));
+ if (ndr_get_array_length(ndr, &r->data_type) > ndr_get_array_size(ndr, &r->data_type)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->data_type), ndr_get_array_length(ndr, &r->data_type));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->data_type), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->data_type, ndr_get_array_length(ndr, &r->data_type), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_type_0, 0);
+ }
+ if (r->print_processor) {
+ _mem_save_print_processor_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->print_processor, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->print_processor));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->print_processor));
+ if (ndr_get_array_length(ndr, &r->print_processor) > ndr_get_array_size(ndr, &r->print_processor)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->print_processor), ndr_get_array_length(ndr, &r->print_processor));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->print_processor), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->print_processor, ndr_get_array_length(ndr, &r->print_processor), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_print_processor_0, 0);
+ }
+ if (r->parameters) {
+ _mem_save_parameters_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->parameters, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->parameters));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->parameters));
+ if (ndr_get_array_length(ndr, &r->parameters) > ndr_get_array_size(ndr, &r->parameters)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->parameters), ndr_get_array_length(ndr, &r->parameters));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->parameters), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->parameters, ndr_get_array_length(ndr, &r->parameters), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_parameters_0, 0);
+ }
+ if (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_array_size(ndr, &r->driver_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->driver_name));
+ if (ndr_get_array_length(ndr, &r->driver_name) > ndr_get_array_size(ndr, &r->driver_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->driver_name), ndr_get_array_length(ndr, &r->driver_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->driver_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->driver_name, ndr_get_array_length(ndr, &r->driver_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_name_0, 0);
+ }
+ if (r->text_status) {
+ _mem_save_text_status_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->text_status, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->text_status));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->text_status));
+ if (ndr_get_array_length(ndr, &r->text_status) > ndr_get_array_size(ndr, &r->text_status)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->text_status), ndr_get_array_length(ndr, &r->text_status));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->text_status), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->text_status, ndr_get_array_length(ndr, &r->text_status), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_text_status_0, 0);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_SetJobInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo2 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_SetJobInfo2");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "job_id", r->job_id);
+ ndr_print_ptr(ndr, "printer_name", r->printer_name);
+ ndr->depth++;
+ if (r->printer_name) {
+ ndr_print_string(ndr, "printer_name", r->printer_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "server_name", r->server_name);
+ ndr->depth++;
+ if (r->server_name) {
+ ndr_print_string(ndr, "server_name", r->server_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "user_name", r->user_name);
+ ndr->depth++;
+ if (r->user_name) {
+ ndr_print_string(ndr, "user_name", r->user_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "document_name", r->document_name);
+ ndr->depth++;
+ if (r->document_name) {
+ ndr_print_string(ndr, "document_name", r->document_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "notify_name", r->notify_name);
+ ndr->depth++;
+ if (r->notify_name) {
+ ndr_print_string(ndr, "notify_name", r->notify_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "data_type", r->data_type);
+ ndr->depth++;
+ if (r->data_type) {
+ ndr_print_string(ndr, "data_type", r->data_type);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "print_processor", r->print_processor);
+ ndr->depth++;
+ if (r->print_processor) {
+ ndr_print_string(ndr, "print_processor", r->print_processor);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "parameters", r->parameters);
+ ndr->depth++;
+ if (r->parameters) {
+ ndr_print_string(ndr, "parameters", r->parameters);
+ }
+ ndr->depth--;
+ 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_uint32(ndr, "_devmode_ptr", r->_devmode_ptr);
+ ndr_print_ptr(ndr, "text_status", r->text_status);
+ ndr->depth++;
+ if (r->text_status) {
+ ndr_print_string(ndr, "text_status", r->text_status);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "_secdesc_ptr", r->_secdesc_ptr);
+ ndr_print_spoolss_JobStatus(ndr, "status", r->status);
+ ndr_print_uint32(ndr, "priority", r->priority);
+ ndr_print_uint32(ndr, "position", r->position);
+ ndr_print_uint32(ndr, "start_time", r->start_time);
+ ndr_print_uint32(ndr, "until_time", r->until_time);
+ ndr_print_uint32(ndr, "total_pages", r->total_pages);
+ ndr_print_uint32(ndr, "size", r->size);
+ ndr_print_spoolss_Time(ndr, "submitted", &r->submitted);
+ ndr_print_uint32(ndr, "time", r->time);
+ ndr_print_uint32(ndr, "pages_printed", r->pages_printed);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_SetJobInfo4(struct ndr_push *ndr, int ndr_flags, const struct spoolss_SetJobInfo4 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->job_id));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->printer_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->server_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->user_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->document_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->notify_name));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->data_type));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->print_processor));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->parameters));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->driver_name));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->_devmode_ptr));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->text_status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->_secdesc_ptr));
+ NDR_CHECK(ndr_push_spoolss_JobStatus(ndr, NDR_SCALARS, r->status));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->priority));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->position));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->start_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->until_time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->total_pages));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size));
+ NDR_CHECK(ndr_push_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->time));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->pages_printed));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->size_high));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->printer_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->printer_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->printer_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->printer_name, ndr_charset_length(r->printer_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->server_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->server_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->server_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->server_name, ndr_charset_length(r->server_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->user_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->user_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->user_name, ndr_charset_length(r->user_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->document_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->document_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->document_name, ndr_charset_length(r->document_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->notify_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->notify_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->notify_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->notify_name, ndr_charset_length(r->notify_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->data_type) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->data_type, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->data_type, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->data_type, ndr_charset_length(r->data_type, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->print_processor) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->print_processor, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->print_processor, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->print_processor, ndr_charset_length(r->print_processor, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->parameters) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->parameters, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->parameters, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->parameters, ndr_charset_length(r->parameters, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->driver_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->driver_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->driver_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->driver_name, ndr_charset_length(r->driver_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->text_status) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->text_status, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->text_status, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->text_status, ndr_charset_length(r->text_status, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_SetJobInfo4(struct ndr_pull *ndr, int ndr_flags, struct spoolss_SetJobInfo4 *r)
+{
+ uint32_t _ptr_printer_name;
+ TALLOC_CTX *_mem_save_printer_name_0;
+ uint32_t _ptr_server_name;
+ TALLOC_CTX *_mem_save_server_name_0;
+ uint32_t _ptr_user_name;
+ TALLOC_CTX *_mem_save_user_name_0;
+ uint32_t _ptr_document_name;
+ TALLOC_CTX *_mem_save_document_name_0;
+ uint32_t _ptr_notify_name;
+ TALLOC_CTX *_mem_save_notify_name_0;
+ uint32_t _ptr_data_type;
+ TALLOC_CTX *_mem_save_data_type_0;
+ uint32_t _ptr_print_processor;
+ TALLOC_CTX *_mem_save_print_processor_0;
+ uint32_t _ptr_parameters;
+ TALLOC_CTX *_mem_save_parameters_0;
+ uint32_t _ptr_driver_name;
+ TALLOC_CTX *_mem_save_driver_name_0;
+ uint32_t _ptr_text_status;
+ TALLOC_CTX *_mem_save_text_status_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->job_id));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_printer_name));
+ if (_ptr_printer_name) {
+ NDR_PULL_ALLOC(ndr, r->printer_name);
+ } else {
+ r->printer_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_server_name));
+ if (_ptr_server_name) {
+ NDR_PULL_ALLOC(ndr, r->server_name);
+ } else {
+ r->server_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_user_name));
+ if (_ptr_user_name) {
+ NDR_PULL_ALLOC(ndr, r->user_name);
+ } else {
+ r->user_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_document_name));
+ if (_ptr_document_name) {
+ NDR_PULL_ALLOC(ndr, r->document_name);
+ } else {
+ r->document_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_notify_name));
+ if (_ptr_notify_name) {
+ NDR_PULL_ALLOC(ndr, r->notify_name);
+ } else {
+ r->notify_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_data_type));
+ if (_ptr_data_type) {
+ NDR_PULL_ALLOC(ndr, r->data_type);
+ } else {
+ r->data_type = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_print_processor));
+ if (_ptr_print_processor) {
+ NDR_PULL_ALLOC(ndr, r->print_processor);
+ } else {
+ r->print_processor = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_parameters));
+ if (_ptr_parameters) {
+ NDR_PULL_ALLOC(ndr, r->parameters);
+ } else {
+ r->parameters = NULL;
+ }
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_driver_name));
+ if (_ptr_driver_name) {
+ NDR_PULL_ALLOC(ndr, r->driver_name);
+ } else {
+ r->driver_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_devmode_ptr));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_text_status));
+ if (_ptr_text_status) {
+ NDR_PULL_ALLOC(ndr, r->text_status);
+ } else {
+ r->text_status = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->_secdesc_ptr));
+ NDR_CHECK(ndr_pull_spoolss_JobStatus(ndr, NDR_SCALARS, &r->status));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->priority));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->position));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->start_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->until_time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->total_pages));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_pull_spoolss_Time(ndr, NDR_SCALARS, &r->submitted));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->time));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->pages_printed));
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->size_high));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->printer_name) {
+ _mem_save_printer_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->printer_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->printer_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->printer_name));
+ if (ndr_get_array_length(ndr, &r->printer_name) > ndr_get_array_size(ndr, &r->printer_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->printer_name), ndr_get_array_length(ndr, &r->printer_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->printer_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->printer_name, ndr_get_array_length(ndr, &r->printer_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printer_name_0, 0);
+ }
+ if (r->server_name) {
+ _mem_save_server_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->server_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->server_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->server_name));
+ if (ndr_get_array_length(ndr, &r->server_name) > ndr_get_array_size(ndr, &r->server_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->server_name), ndr_get_array_length(ndr, &r->server_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->server_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->server_name, ndr_get_array_length(ndr, &r->server_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_server_name_0, 0);
+ }
+ if (r->user_name) {
+ _mem_save_user_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->user_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->user_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->user_name));
+ if (ndr_get_array_length(ndr, &r->user_name) > ndr_get_array_size(ndr, &r->user_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->user_name), ndr_get_array_length(ndr, &r->user_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->user_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->user_name, ndr_get_array_length(ndr, &r->user_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_user_name_0, 0);
+ }
+ if (r->document_name) {
+ _mem_save_document_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->document_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->document_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->document_name));
+ if (ndr_get_array_length(ndr, &r->document_name) > ndr_get_array_size(ndr, &r->document_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->document_name), ndr_get_array_length(ndr, &r->document_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->document_name, ndr_get_array_length(ndr, &r->document_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_document_name_0, 0);
+ }
+ if (r->notify_name) {
+ _mem_save_notify_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->notify_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->notify_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->notify_name));
+ if (ndr_get_array_length(ndr, &r->notify_name) > ndr_get_array_size(ndr, &r->notify_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->notify_name), ndr_get_array_length(ndr, &r->notify_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->notify_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->notify_name, ndr_get_array_length(ndr, &r->notify_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_notify_name_0, 0);
+ }
+ if (r->data_type) {
+ _mem_save_data_type_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->data_type, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->data_type));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->data_type));
+ if (ndr_get_array_length(ndr, &r->data_type) > ndr_get_array_size(ndr, &r->data_type)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->data_type), ndr_get_array_length(ndr, &r->data_type));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->data_type), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->data_type, ndr_get_array_length(ndr, &r->data_type), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_type_0, 0);
+ }
+ if (r->print_processor) {
+ _mem_save_print_processor_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->print_processor, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->print_processor));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->print_processor));
+ if (ndr_get_array_length(ndr, &r->print_processor) > ndr_get_array_size(ndr, &r->print_processor)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->print_processor), ndr_get_array_length(ndr, &r->print_processor));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->print_processor), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->print_processor, ndr_get_array_length(ndr, &r->print_processor), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_print_processor_0, 0);
+ }
+ if (r->parameters) {
+ _mem_save_parameters_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->parameters, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->parameters));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->parameters));
+ if (ndr_get_array_length(ndr, &r->parameters) > ndr_get_array_size(ndr, &r->parameters)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->parameters), ndr_get_array_length(ndr, &r->parameters));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->parameters), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->parameters, ndr_get_array_length(ndr, &r->parameters), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_parameters_0, 0);
+ }
+ if (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_array_size(ndr, &r->driver_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->driver_name));
+ if (ndr_get_array_length(ndr, &r->driver_name) > ndr_get_array_size(ndr, &r->driver_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->driver_name), ndr_get_array_length(ndr, &r->driver_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->driver_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->driver_name, ndr_get_array_length(ndr, &r->driver_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_driver_name_0, 0);
+ }
+ if (r->text_status) {
+ _mem_save_text_status_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->text_status, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->text_status));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->text_status));
+ if (ndr_get_array_length(ndr, &r->text_status) > ndr_get_array_size(ndr, &r->text_status)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->text_status), ndr_get_array_length(ndr, &r->text_status));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->text_status), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->text_status, ndr_get_array_length(ndr, &r->text_status), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_text_status_0, 0);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_SetJobInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo4 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_SetJobInfo4");
+ ndr->depth++;
+ ndr_print_uint32(ndr, "job_id", r->job_id);
+ ndr_print_ptr(ndr, "printer_name", r->printer_name);
+ ndr->depth++;
+ if (r->printer_name) {
+ ndr_print_string(ndr, "printer_name", r->printer_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "server_name", r->server_name);
+ ndr->depth++;
+ if (r->server_name) {
+ ndr_print_string(ndr, "server_name", r->server_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "user_name", r->user_name);
+ ndr->depth++;
+ if (r->user_name) {
+ ndr_print_string(ndr, "user_name", r->user_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "document_name", r->document_name);
+ ndr->depth++;
+ if (r->document_name) {
+ ndr_print_string(ndr, "document_name", r->document_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "notify_name", r->notify_name);
+ ndr->depth++;
+ if (r->notify_name) {
+ ndr_print_string(ndr, "notify_name", r->notify_name);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "data_type", r->data_type);
+ ndr->depth++;
+ if (r->data_type) {
+ ndr_print_string(ndr, "data_type", r->data_type);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "print_processor", r->print_processor);
+ ndr->depth++;
+ if (r->print_processor) {
+ ndr_print_string(ndr, "print_processor", r->print_processor);
+ }
+ ndr->depth--;
+ ndr_print_ptr(ndr, "parameters", r->parameters);
+ ndr->depth++;
+ if (r->parameters) {
+ ndr_print_string(ndr, "parameters", r->parameters);
+ }
+ ndr->depth--;
+ 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_uint32(ndr, "_devmode_ptr", r->_devmode_ptr);
+ ndr_print_ptr(ndr, "text_status", r->text_status);
+ ndr->depth++;
+ if (r->text_status) {
+ ndr_print_string(ndr, "text_status", r->text_status);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "_secdesc_ptr", r->_secdesc_ptr);
+ ndr_print_spoolss_JobStatus(ndr, "status", r->status);
+ ndr_print_uint32(ndr, "priority", r->priority);
+ ndr_print_uint32(ndr, "position", r->position);
+ ndr_print_uint32(ndr, "start_time", r->start_time);
+ ndr_print_uint32(ndr, "until_time", r->until_time);
+ ndr_print_uint32(ndr, "total_pages", r->total_pages);
+ ndr_print_uint32(ndr, "size", r->size);
+ ndr_print_spoolss_Time(ndr, "submitted", &r->submitted);
+ ndr_print_uint32(ndr, "time", r->time);
+ ndr_print_uint32(ndr, "pages_printed", r->pages_printed);
+ ndr_print_uint32(ndr, "size_high", r->size_high);
+ ndr->depth--;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_spoolss_SetJobInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_SetJobInfo *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, level));
+ switch (level) {
+ case 1: {
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->info1));
+ break; }
+
+ case 2: {
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->info2));
+ break; }
+
+ case 3: {
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->info3));
+ break; }
+
+ case 4: {
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->info4));
+ break; }
+
+ default: {
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ int level = ndr_push_get_switch_value(ndr, r);
+ switch (level) {
+ case 1:
+ if (r->info1) {
+ NDR_CHECK(ndr_push_spoolss_SetJobInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1));
+ }
+ break;
+
+ case 2:
+ if (r->info2) {
+ NDR_CHECK(ndr_push_spoolss_SetJobInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2));
+ }
+ break;
+
+ case 3:
+ if (r->info3) {
+ NDR_CHECK(ndr_push_spoolss_JobInfo3(ndr, NDR_SCALARS, r->info3));
+ }
+ break;
+
+ case 4:
+ if (r->info4) {
+ NDR_CHECK(ndr_push_spoolss_SetJobInfo4(ndr, NDR_SCALARS|NDR_BUFFERS, r->info4));
+ }
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_spoolss_SetJobInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_SetJobInfo *r)
+{
+ int level;
+ uint32_t _level;
+ TALLOC_CTX *_mem_save_info1_0;
+ TALLOC_CTX *_mem_save_info2_0;
+ TALLOC_CTX *_mem_save_info3_0;
+ TALLOC_CTX *_mem_save_info4_0;
+ level = ndr_pull_get_switch_value(ndr, r);
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level));
+ if (_level != level) {
+ return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u for r", _level);
+ }
+ switch (level) {
+ case 1: {
+ uint32_t _ptr_info1;
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info1));
+ if (_ptr_info1) {
+ NDR_PULL_ALLOC(ndr, r->info1);
+ } else {
+ r->info1 = NULL;
+ }
+ break; }
+
+ case 2: {
+ uint32_t _ptr_info2;
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info2));
+ if (_ptr_info2) {
+ NDR_PULL_ALLOC(ndr, r->info2);
+ } else {
+ r->info2 = NULL;
+ }
+ break; }
+
+ case 3: {
+ uint32_t _ptr_info3;
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info3));
+ if (_ptr_info3) {
+ NDR_PULL_ALLOC(ndr, r->info3);
+ } else {
+ r->info3 = NULL;
+ }
+ break; }
+
+ case 4: {
+ uint32_t _ptr_info4;
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info4));
+ if (_ptr_info4) {
+ NDR_PULL_ALLOC(ndr, r->info4);
+ } else {
+ r->info4 = NULL;
+ }
+ break; }
+
+ default: {
+ break; }
+
+ }
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ switch (level) {
+ case 1:
+ if (r->info1) {
+ _mem_save_info1_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->info1, 0);
+ NDR_CHECK(ndr_pull_spoolss_SetJobInfo1(ndr, NDR_SCALARS|NDR_BUFFERS, r->info1));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info1_0, 0);
+ }
+ break;
+
+ case 2:
+ if (r->info2) {
+ _mem_save_info2_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->info2, 0);
+ NDR_CHECK(ndr_pull_spoolss_SetJobInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info2_0, 0);
+ }
+ break;
+
+ case 3:
+ 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_JobInfo3(ndr, NDR_SCALARS, r->info3));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info3_0, 0);
+ }
+ break;
+
+ case 4:
+ if (r->info4) {
+ _mem_save_info4_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->info4, 0);
+ NDR_CHECK(ndr_pull_spoolss_SetJobInfo4(ndr, NDR_SCALARS|NDR_BUFFERS, r->info4));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info4_0, 0);
+ }
+ break;
+
+ default:
+ break;
+
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_SetJobInfo(struct ndr_print *ndr, const char *name, const union spoolss_SetJobInfo *r)
+{
+ int level;
+ level = ndr_print_get_switch_value(ndr, r);
+ ndr_print_union(ndr, name, level, "spoolss_SetJobInfo");
+ switch (level) {
+ case 1:
+ ndr_print_ptr(ndr, "info1", r->info1);
+ ndr->depth++;
+ if (r->info1) {
+ ndr_print_spoolss_SetJobInfo1(ndr, "info1", r->info1);
+ }
+ ndr->depth--;
+ break;
+
+ case 2:
+ ndr_print_ptr(ndr, "info2", r->info2);
+ ndr->depth++;
+ if (r->info2) {
+ ndr_print_spoolss_SetJobInfo2(ndr, "info2", r->info2);
+ }
+ ndr->depth--;
break;
case 3:
+ ndr_print_ptr(ndr, "info3", r->info3);
+ ndr->depth++;
+ if (r->info3) {
+ ndr_print_spoolss_JobInfo3(ndr, "info3", r->info3);
+ }
+ ndr->depth--;
+ break;
+
+ case 4:
+ ndr_print_ptr(ndr, "info4", r->info4);
+ ndr->depth++;
+ if (r->info4) {
+ ndr_print_spoolss_SetJobInfo4(ndr, "info4", r->info4);
+ }
+ ndr->depth--;
break;
default:
@@ -2988,10 +5598,10 @@ static enum ndr_err_code ndr_push_spoolss_JobInfoContainer(struct ndr_push *ndr,
NDR_CHECK(ndr_push_align(ndr, 4));
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->level));
NDR_CHECK(ndr_push_set_switch_value(ndr, &r->info, r->level));
- NDR_CHECK(ndr_push_spoolss_JobInfo(ndr, NDR_SCALARS, &r->info));
+ NDR_CHECK(ndr_push_spoolss_SetJobInfo(ndr, NDR_SCALARS, &r->info));
}
if (ndr_flags & NDR_BUFFERS) {
- NDR_CHECK(ndr_push_spoolss_JobInfo(ndr, NDR_BUFFERS, &r->info));
+ NDR_CHECK(ndr_push_spoolss_SetJobInfo(ndr, NDR_BUFFERS, &r->info));
}
return NDR_ERR_SUCCESS;
}
@@ -3002,10 +5612,10 @@ static enum ndr_err_code ndr_pull_spoolss_JobInfoContainer(struct ndr_pull *ndr,
NDR_CHECK(ndr_pull_align(ndr, 4));
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->level));
NDR_CHECK(ndr_pull_set_switch_value(ndr, &r->info, r->level));
- NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_SCALARS, &r->info));
+ NDR_CHECK(ndr_pull_spoolss_SetJobInfo(ndr, NDR_SCALARS, &r->info));
}
if (ndr_flags & NDR_BUFFERS) {
- NDR_CHECK(ndr_pull_spoolss_JobInfo(ndr, NDR_BUFFERS, &r->info));
+ NDR_CHECK(ndr_pull_spoolss_SetJobInfo(ndr, NDR_BUFFERS, &r->info));
}
return NDR_ERR_SUCCESS;
}
@@ -3016,7 +5626,7 @@ _PUBLIC_ void ndr_print_spoolss_JobInfoContainer(struct ndr_print *ndr, const ch
ndr->depth++;
ndr_print_uint32(ndr, "level", r->level);
ndr_print_set_switch_value(ndr, &r->info, r->level);
- ndr_print_spoolss_JobInfo(ndr, "info", &r->info);
+ ndr_print_spoolss_SetJobInfo(ndr, "info", &r->info);
ndr->depth--;
}
@@ -3046,6 +5656,8 @@ _PUBLIC_ void ndr_print_spoolss_JobControl(struct ndr_print *ndr, const char *na
case SPOOLSS_JOB_CONTROL_DELETE: val = "SPOOLSS_JOB_CONTROL_DELETE"; break;
case SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER: val = "SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER"; break;
case SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED: val = "SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED"; break;
+ case SPOOLSS_JOB_CONTROL_RETAIN: val = "SPOOLSS_JOB_CONTROL_RETAIN"; break;
+ case SPOOLSS_JOB_CONTROL_RELEASE: val = "SPOOLSS_JOB_CONTROL_RELEASE"; break;
}
ndr_print_enum(ndr, name, "ENUM", val, r);
}
@@ -11356,6 +13968,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PrintProcessorDirectoryInfo(struct n
break; }
default: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_PrintProcessorDirectoryInfo1(ndr, NDR_SCALARS, &r->info1));
break; }
}
@@ -11390,6 +14005,9 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PrintProcessorDirectoryInfo(struct n
break; }
default: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_PrintProcessorDirectoryInfo1(ndr, NDR_SCALARS, &r->info1));
break; }
}
@@ -11420,6 +14038,7 @@ _PUBLIC_ void ndr_print_spoolss_PrintProcessorDirectoryInfo(struct ndr_print *nd
break;
default:
+ ndr_print_spoolss_PrintProcessorDirectoryInfo1(ndr, "info1", &r->info1);
break;
}
@@ -12232,6 +14851,275 @@ _PUBLIC_ void ndr_print_spoolss_FormInfo1(struct ndr_print *ndr, const char *nam
ndr->depth--;
}
+static enum ndr_err_code ndr_push_spoolss_FormStringType(struct ndr_push *ndr, int ndr_flags, uint32_t r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_FormStringType(struct ndr_pull *ndr, int ndr_flags, uint32_t *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_FormStringType(struct ndr_print *ndr, const char *name, uint32_t r)
+{
+ ndr_print_uint32(ndr, name, r);
+ ndr->depth++;
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_FORM_STRING_TYPE_NONE", SPOOLSS_FORM_STRING_TYPE_NONE, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_FORM_STRING_TYPE_MUI_DLL", SPOOLSS_FORM_STRING_TYPE_MUI_DLL, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "SPOOLSS_FORM_STRING_TYPE_LANG_PAIR", SPOOLSS_FORM_STRING_TYPE_LANG_PAIR, r);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_FormInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_FormInfo2 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_spoolss_FormFlags(ndr, NDR_SCALARS, r->flags));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->form_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_spoolss_FormSize(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_push_spoolss_FormArea(ndr, NDR_SCALARS, &r->area));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->keyword));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_spoolss_FormStringType(ndr, NDR_SCALARS, r->string_type));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->mui_dll));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ressource_id));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->display_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->lang_id));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->form_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->form_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->form_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ if (r->keyword) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->keyword));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->keyword));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->mui_dll) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->mui_dll));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->mui_dll));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->display_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->display_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->display_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_FormInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_FormInfo2 *r)
+{
+ uint32_t _ptr_form_name;
+ TALLOC_CTX *_mem_save_form_name_0;
+ uint32_t _ptr_keyword;
+ TALLOC_CTX *_mem_save_keyword_0;
+ uint32_t _ptr_mui_dll;
+ TALLOC_CTX *_mem_save_mui_dll_0;
+ uint32_t _ptr_display_name;
+ TALLOC_CTX *_mem_save_display_name_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_spoolss_FormFlags(ndr, NDR_SCALARS, &r->flags));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_form_name));
+ if (_ptr_form_name) {
+ NDR_PULL_ALLOC(ndr, r->form_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->form_name, _ptr_form_name));
+ } else {
+ r->form_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_spoolss_FormSize(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_pull_spoolss_FormArea(ndr, NDR_SCALARS, &r->area));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_keyword));
+ if (_ptr_keyword) {
+ NDR_PULL_ALLOC(ndr, r->keyword);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->keyword, _ptr_keyword));
+ } else {
+ r->keyword = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_spoolss_FormStringType(ndr, NDR_SCALARS, &r->string_type));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_mui_dll));
+ if (_ptr_mui_dll) {
+ NDR_PULL_ALLOC(ndr, r->mui_dll);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->mui_dll, _ptr_mui_dll));
+ } else {
+ r->mui_dll = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ressource_id));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_display_name));
+ if (_ptr_display_name) {
+ NDR_PULL_ALLOC(ndr, r->display_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->display_name, _ptr_display_name));
+ } else {
+ r->display_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->lang_id));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->form_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->form_name));
+ _mem_save_form_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->form_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->form_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_form_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_ASCII|LIBNDR_FLAG_STR_NULLTERM);
+ if (r->keyword) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->keyword));
+ _mem_save_keyword_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->keyword, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->keyword));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_keyword_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->mui_dll) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->mui_dll));
+ _mem_save_mui_dll_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->mui_dll, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->mui_dll));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_mui_dll_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->display_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->display_name));
+ _mem_save_display_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->display_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->display_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_display_name_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_FormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo2 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_FormInfo2");
+ ndr->depth++;
+ ndr_print_spoolss_FormFlags(ndr, "flags", r->flags);
+ ndr_print_ptr(ndr, "form_name", r->form_name);
+ ndr->depth++;
+ if (r->form_name) {
+ ndr_print_string(ndr, "form_name", r->form_name);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_FormSize(ndr, "size", &r->size);
+ ndr_print_spoolss_FormArea(ndr, "area", &r->area);
+ ndr_print_ptr(ndr, "keyword", r->keyword);
+ ndr->depth++;
+ if (r->keyword) {
+ ndr_print_string(ndr, "keyword", r->keyword);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_FormStringType(ndr, "string_type", r->string_type);
+ ndr_print_ptr(ndr, "mui_dll", r->mui_dll);
+ ndr->depth++;
+ if (r->mui_dll) {
+ ndr_print_string(ndr, "mui_dll", r->mui_dll);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "ressource_id", r->ressource_id);
+ ndr_print_ptr(ndr, "display_name", r->display_name);
+ ndr->depth++;
+ if (r->display_name) {
+ ndr_print_string(ndr, "display_name", r->display_name);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "lang_id", r->lang_id);
+ ndr->depth--;
+}
+
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_FormInfo *r)
{
uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);
@@ -12244,6 +15132,12 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int n
NDR_CHECK(ndr_push_spoolss_FormInfo1(ndr, NDR_SCALARS, &r->info1));
break; }
+ case 2: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_FormInfo2(ndr, NDR_SCALARS, &r->info2));
+ break; }
+
default: {
break; }
@@ -12257,6 +15151,10 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int n
NDR_CHECK(ndr_push_spoolss_FormInfo1(ndr, NDR_BUFFERS, &r->info1));
break;
+ case 2:
+ NDR_CHECK(ndr_push_spoolss_FormInfo2(ndr, NDR_BUFFERS, &r->info2));
+ break;
+
default:
break;
@@ -12279,6 +15177,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int n
NDR_CHECK(ndr_pull_spoolss_FormInfo1(ndr, NDR_SCALARS, &r->info1));
break; }
+ case 2: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_FormInfo2(ndr, NDR_SCALARS, &r->info2));
+ break; }
+
default: {
break; }
@@ -12291,6 +15195,10 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int n
NDR_CHECK(ndr_pull_spoolss_FormInfo1(ndr, NDR_BUFFERS, &r->info1));
break;
+ case 2:
+ NDR_CHECK(ndr_pull_spoolss_FormInfo2(ndr, NDR_BUFFERS, &r->info2));
+ break;
+
default:
break;
@@ -12310,6 +15218,10 @@ _PUBLIC_ void ndr_print_spoolss_FormInfo(struct ndr_print *ndr, const char *name
ndr_print_spoolss_FormInfo1(ndr, "info1", &r->info1);
break;
+ case 2:
+ ndr_print_spoolss_FormInfo2(ndr, "info2", &r->info2);
+ break;
+
default:
break;
@@ -12390,6 +15302,183 @@ _PUBLIC_ void ndr_print_spoolss_AddFormInfo1(struct ndr_print *ndr, const char *
ndr->depth--;
}
+static enum ndr_err_code ndr_push_spoolss_AddFormInfo2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_AddFormInfo2 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_spoolss_FormFlags(ndr, NDR_SCALARS, r->flags));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->form_name));
+ NDR_CHECK(ndr_push_spoolss_FormSize(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_push_spoolss_FormArea(ndr, NDR_SCALARS, &r->area));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->keyword));
+ NDR_CHECK(ndr_push_spoolss_FormStringType(ndr, NDR_SCALARS, r->string_type));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->mui_dll));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->ressource_id));
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->display_name));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->lang_id));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->form_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->form_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->form_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->form_name, ndr_charset_length(r->form_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->keyword) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->keyword, CH_DOS)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->keyword, CH_DOS)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->keyword, ndr_charset_length(r->keyword, CH_DOS), sizeof(uint8_t), CH_DOS));
+ }
+ if (r->mui_dll) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->mui_dll, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->mui_dll, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->mui_dll, ndr_charset_length(r->mui_dll, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ if (r->display_name) {
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->display_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->display_name, CH_UTF16)));
+ NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->display_name, ndr_charset_length(r->display_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_AddFormInfo2(struct ndr_pull *ndr, int ndr_flags, struct spoolss_AddFormInfo2 *r)
+{
+ uint32_t _ptr_form_name;
+ TALLOC_CTX *_mem_save_form_name_0;
+ uint32_t _ptr_keyword;
+ TALLOC_CTX *_mem_save_keyword_0;
+ uint32_t _ptr_mui_dll;
+ TALLOC_CTX *_mem_save_mui_dll_0;
+ uint32_t _ptr_display_name;
+ TALLOC_CTX *_mem_save_display_name_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_spoolss_FormFlags(ndr, NDR_SCALARS, &r->flags));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_form_name));
+ if (_ptr_form_name) {
+ NDR_PULL_ALLOC(ndr, r->form_name);
+ } else {
+ r->form_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_spoolss_FormSize(ndr, NDR_SCALARS, &r->size));
+ NDR_CHECK(ndr_pull_spoolss_FormArea(ndr, NDR_SCALARS, &r->area));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_keyword));
+ if (_ptr_keyword) {
+ NDR_PULL_ALLOC(ndr, r->keyword);
+ } else {
+ r->keyword = NULL;
+ }
+ NDR_CHECK(ndr_pull_spoolss_FormStringType(ndr, NDR_SCALARS, &r->string_type));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_mui_dll));
+ if (_ptr_mui_dll) {
+ NDR_PULL_ALLOC(ndr, r->mui_dll);
+ } else {
+ r->mui_dll = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->ressource_id));
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_display_name));
+ if (_ptr_display_name) {
+ NDR_PULL_ALLOC(ndr, r->display_name);
+ } else {
+ r->display_name = NULL;
+ }
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->lang_id));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ if (r->form_name) {
+ _mem_save_form_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->form_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->form_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->form_name));
+ if (ndr_get_array_length(ndr, &r->form_name) > ndr_get_array_size(ndr, &r->form_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->form_name), ndr_get_array_length(ndr, &r->form_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->form_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->form_name, ndr_get_array_length(ndr, &r->form_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_form_name_0, 0);
+ }
+ if (r->keyword) {
+ _mem_save_keyword_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->keyword, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->keyword));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->keyword));
+ if (ndr_get_array_length(ndr, &r->keyword) > ndr_get_array_size(ndr, &r->keyword)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->keyword), ndr_get_array_length(ndr, &r->keyword));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->keyword), sizeof(uint8_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->keyword, ndr_get_array_length(ndr, &r->keyword), sizeof(uint8_t), CH_DOS));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_keyword_0, 0);
+ }
+ if (r->mui_dll) {
+ _mem_save_mui_dll_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->mui_dll, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->mui_dll));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->mui_dll));
+ if (ndr_get_array_length(ndr, &r->mui_dll) > ndr_get_array_size(ndr, &r->mui_dll)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->mui_dll), ndr_get_array_length(ndr, &r->mui_dll));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->mui_dll), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->mui_dll, ndr_get_array_length(ndr, &r->mui_dll), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_mui_dll_0, 0);
+ }
+ if (r->display_name) {
+ _mem_save_display_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->display_name, 0);
+ NDR_CHECK(ndr_pull_array_size(ndr, &r->display_name));
+ NDR_CHECK(ndr_pull_array_length(ndr, &r->display_name));
+ if (ndr_get_array_length(ndr, &r->display_name) > ndr_get_array_size(ndr, &r->display_name)) {
+ return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->display_name), ndr_get_array_length(ndr, &r->display_name));
+ }
+ NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->display_name), sizeof(uint16_t)));
+ NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->display_name, ndr_get_array_length(ndr, &r->display_name), sizeof(uint16_t), CH_UTF16));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_display_name_0, 0);
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_AddFormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo2 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_AddFormInfo2");
+ ndr->depth++;
+ ndr_print_spoolss_FormFlags(ndr, "flags", r->flags);
+ ndr_print_ptr(ndr, "form_name", r->form_name);
+ ndr->depth++;
+ if (r->form_name) {
+ ndr_print_string(ndr, "form_name", r->form_name);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_FormSize(ndr, "size", &r->size);
+ ndr_print_spoolss_FormArea(ndr, "area", &r->area);
+ ndr_print_ptr(ndr, "keyword", r->keyword);
+ ndr->depth++;
+ if (r->keyword) {
+ ndr_print_string(ndr, "keyword", r->keyword);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_FormStringType(ndr, "string_type", r->string_type);
+ ndr_print_ptr(ndr, "mui_dll", r->mui_dll);
+ ndr->depth++;
+ if (r->mui_dll) {
+ ndr_print_string(ndr, "mui_dll", r->mui_dll);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "ressource_id", r->ressource_id);
+ ndr_print_ptr(ndr, "display_name", r->display_name);
+ ndr->depth++;
+ if (r->display_name) {
+ ndr_print_string(ndr, "display_name", r->display_name);
+ }
+ ndr->depth--;
+ ndr_print_uint32(ndr, "lang_id", r->lang_id);
+ ndr->depth--;
+}
+
static enum ndr_err_code ndr_push_spoolss_AddFormInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_AddFormInfo *r)
{
if (ndr_flags & NDR_SCALARS) {
@@ -12400,6 +15489,10 @@ static enum ndr_err_code ndr_push_spoolss_AddFormInfo(struct ndr_push *ndr, int
NDR_CHECK(ndr_push_unique_ptr(ndr, r->info1));
break; }
+ case 2: {
+ NDR_CHECK(ndr_push_unique_ptr(ndr, r->info2));
+ break; }
+
default:
return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
}
@@ -12413,6 +15506,12 @@ static enum ndr_err_code ndr_push_spoolss_AddFormInfo(struct ndr_push *ndr, int
}
break;
+ case 2:
+ if (r->info2) {
+ NDR_CHECK(ndr_push_spoolss_AddFormInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2));
+ }
+ break;
+
default:
return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
}
@@ -12425,6 +15524,7 @@ static enum ndr_err_code ndr_pull_spoolss_AddFormInfo(struct ndr_pull *ndr, int
int level;
uint32_t _level;
TALLOC_CTX *_mem_save_info1_0;
+ TALLOC_CTX *_mem_save_info2_0;
level = ndr_pull_get_switch_value(ndr, r);
if (ndr_flags & NDR_SCALARS) {
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &_level));
@@ -12442,6 +15542,16 @@ static enum ndr_err_code ndr_pull_spoolss_AddFormInfo(struct ndr_pull *ndr, int
}
break; }
+ case 2: {
+ uint32_t _ptr_info2;
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info2));
+ if (_ptr_info2) {
+ NDR_PULL_ALLOC(ndr, r->info2);
+ } else {
+ r->info2 = NULL;
+ }
+ break; }
+
default:
return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
}
@@ -12457,6 +15567,15 @@ static enum ndr_err_code ndr_pull_spoolss_AddFormInfo(struct ndr_pull *ndr, int
}
break;
+ case 2:
+ if (r->info2) {
+ _mem_save_info2_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->info2, 0);
+ NDR_CHECK(ndr_pull_spoolss_AddFormInfo2(ndr, NDR_SCALARS|NDR_BUFFERS, r->info2));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info2_0, 0);
+ }
+ break;
+
default:
return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level);
}
@@ -12479,6 +15598,15 @@ _PUBLIC_ void ndr_print_spoolss_AddFormInfo(struct ndr_print *ndr, const char *n
ndr->depth--;
break;
+ case 2:
+ ndr_print_ptr(ndr, "info2", r->info2);
+ ndr->depth++;
+ if (r->info2) {
+ ndr_print_spoolss_AddFormInfo2(ndr, "info2", r->info2);
+ }
+ ndr->depth--;
+ break;
+
default:
ndr_print_bad_level(ndr, name, level);
}
@@ -12769,6 +15897,231 @@ _PUBLIC_ void ndr_print_spoolss_PortInfo2(struct ndr_print *ndr, const char *nam
ndr->depth--;
}
+static enum ndr_err_code ndr_push_spoolss_PortStatus(struct ndr_push *ndr, int ndr_flags, enum spoolss_PortStatus r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_PortStatus(struct ndr_pull *ndr, int ndr_flags, enum spoolss_PortStatus *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_PortStatus(struct ndr_print *ndr, const char *name, enum spoolss_PortStatus r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case PORT_STATUS_CLEAR: val = "PORT_STATUS_CLEAR"; break;
+ case PORT_STATUS_OFFLINE: val = "PORT_STATUS_OFFLINE"; break;
+ case PORT_STATUS_PAPER_JAM: val = "PORT_STATUS_PAPER_JAM"; break;
+ case PORT_STATUS_PAPER_OUT: val = "PORT_STATUS_PAPER_OUT"; break;
+ case PORT_STATUS_OUTPUT_BIN_FULL: val = "PORT_STATUS_OUTPUT_BIN_FULL"; break;
+ case PORT_STATUS_PAPER_PROBLEM: val = "PORT_STATUS_PAPER_PROBLEM"; break;
+ case PORT_STATUS_NO_TONER: val = "PORT_STATUS_NO_TONER"; break;
+ case PORT_STATUS_DOOR_OPEN: val = "PORT_STATUS_DOOR_OPEN"; break;
+ case PORT_STATUS_USER_INTERVENTION: val = "PORT_STATUS_USER_INTERVENTION"; break;
+ case PORT_STATUS_OUT_OF_MEMORY: val = "PORT_STATUS_OUT_OF_MEMORY"; break;
+ case PORT_STATUS_TONER_LOW: val = "PORT_STATUS_TONER_LOW"; break;
+ case PORT_STATUS_WARMING_UP: val = "PORT_STATUS_WARMING_UP"; break;
+ case PORT_STATUS_POWER_SAVE: val = "PORT_STATUS_POWER_SAVE"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_spoolss_PortSeverity(struct ndr_push *ndr, int ndr_flags, enum spoolss_PortSeverity r)
+{
+ NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r));
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_PortSeverity(struct ndr_pull *ndr, int ndr_flags, enum spoolss_PortSeverity *r)
+{
+ uint32_t v;
+ NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
+ *r = v;
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_PortSeverity(struct ndr_print *ndr, const char *name, enum spoolss_PortSeverity r)
+{
+ const char *val = NULL;
+
+ switch (r) {
+ case PORT_STATUS_TYPE_ERROR: val = "PORT_STATUS_TYPE_ERROR"; break;
+ case PORT_STATUS_TYPE_WARNING: val = "PORT_STATUS_TYPE_WARNING"; break;
+ case PORT_STATUS_TYPE_INFO: val = "PORT_STATUS_TYPE_INFO"; break;
+ }
+ ndr_print_enum(ndr, name, "ENUM", val, r);
+}
+
+static enum ndr_err_code ndr_push_spoolss_PortInfo3(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfo3 *r)
+{
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_spoolss_PortStatus(ndr, NDR_SCALARS, r->status));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_push_relative_ptr1(ndr, r->status_string));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_spoolss_PortSeverity(ndr, NDR_SCALARS, r->severity));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->status_string) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->status_string));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->status_string));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_PortInfo3(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfo3 *r)
+{
+ uint32_t _ptr_status_string;
+ TALLOC_CTX *_mem_save_status_string_0;
+ if (ndr_flags & NDR_SCALARS) {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_spoolss_PortStatus(ndr, NDR_SCALARS, &r->status));
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_status_string));
+ if (_ptr_status_string) {
+ NDR_PULL_ALLOC(ndr, r->status_string);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->status_string, _ptr_status_string));
+ } else {
+ r->status_string = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_spoolss_PortSeverity(ndr, NDR_SCALARS, &r->severity));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->status_string) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->status_string));
+ _mem_save_status_string_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->status_string, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->status_string));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_status_string_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_PortInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo3 *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_PortInfo3");
+ ndr->depth++;
+ ndr_print_spoolss_PortStatus(ndr, "status", r->status);
+ ndr_print_ptr(ndr, "status_string", r->status_string);
+ ndr->depth++;
+ if (r->status_string) {
+ ndr_print_string(ndr, "status_string", r->status_string);
+ }
+ ndr->depth--;
+ ndr_print_spoolss_PortSeverity(ndr, "severity", r->severity);
+ ndr->depth--;
+}
+
+static enum ndr_err_code ndr_push_spoolss_PortInfoFF(struct ndr_push *ndr, int ndr_flags, const struct spoolss_PortInfoFF *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->port_name));
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->monitor_data));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->port_name) {
+ NDR_CHECK(ndr_push_relative_ptr2(ndr, r->port_name));
+ NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->port_name));
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_spoolss_PortInfoFF(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PortInfoFF *r)
+{
+ uint32_t _ptr_port_name;
+ TALLOC_CTX *_mem_save_port_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_port_name));
+ if (_ptr_port_name) {
+ NDR_PULL_ALLOC(ndr, r->port_name);
+ NDR_CHECK(ndr_pull_relative_ptr1(ndr, r->port_name, _ptr_port_name));
+ } else {
+ r->port_name = NULL;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->monitor_data));
+ }
+ if (ndr_flags & NDR_BUFFERS) {
+ {
+ uint32_t _flags_save_string = ndr->flags;
+ ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_NULLTERM);
+ if (r->port_name) {
+ uint32_t _relative_save_offset;
+ _relative_save_offset = ndr->offset;
+ NDR_CHECK(ndr_pull_relative_ptr2(ndr, r->port_name));
+ _mem_save_port_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+ NDR_PULL_SET_MEM_CTX(ndr, r->port_name, 0);
+ NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->port_name));
+ NDR_PULL_SET_MEM_CTX(ndr, _mem_save_port_name_0, 0);
+ ndr->offset = _relative_save_offset;
+ }
+ ndr->flags = _flags_save_string;
+ }
+ }
+ return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_spoolss_PortInfoFF(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfoFF *r)
+{
+ ndr_print_struct(ndr, name, "spoolss_PortInfoFF");
+ ndr->depth++;
+ ndr_print_ptr(ndr, "port_name", r->port_name);
+ ndr->depth++;
+ if (r->port_name) {
+ ndr_print_string(ndr, "port_name", r->port_name);
+ }
+ ndr->depth--;
+ ndr_print_DATA_BLOB(ndr, "monitor_data", r->monitor_data);
+ ndr->depth--;
+}
+
_PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PortInfo *r)
{
uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);
@@ -12788,6 +16141,15 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int n
break; }
case 3: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_PortInfo3(ndr, NDR_SCALARS, &r->info3));
+ break; }
+
+ case 0xff: {
+ NDR_CHECK(ndr_push_align(ndr, 4));
+ NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_push_spoolss_PortInfoFF(ndr, NDR_SCALARS, &r->infoFF));
break; }
default: {
@@ -12808,6 +16170,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int n
break;
case 3:
+ NDR_CHECK(ndr_push_spoolss_PortInfo3(ndr, NDR_BUFFERS, &r->info3));
+ break;
+
+ case 0xff:
+ NDR_CHECK(ndr_push_spoolss_PortInfoFF(ndr, NDR_BUFFERS, &r->infoFF));
break;
default:
@@ -12839,6 +16206,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfo(struct ndr_pull *ndr, int n
break; }
case 3: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_PortInfo3(ndr, NDR_SCALARS, &r->info3));
+ break; }
+
+ case 0xff: {
+ NDR_CHECK(ndr_pull_align(ndr, 4));
+ NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, r, ndr->offset));
+ NDR_CHECK(ndr_pull_spoolss_PortInfoFF(ndr, NDR_SCALARS, &r->infoFF));
break; }
default: {
@@ -12858,6 +16234,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_PortInfo(struct ndr_pull *ndr, int n
break;
case 3:
+ NDR_CHECK(ndr_pull_spoolss_PortInfo3(ndr, NDR_BUFFERS, &r->info3));
+ break;
+
+ case 0xff:
+ NDR_CHECK(ndr_pull_spoolss_PortInfoFF(ndr, NDR_BUFFERS, &r->infoFF));
break;
default:
@@ -12884,6 +16265,11 @@ _PUBLIC_ void ndr_print_spoolss_PortInfo(struct ndr_print *ndr, const char *name
break;
case 3:
+ ndr_print_spoolss_PortInfo3(ndr, "info3", &r->info3);
+ break;
+
+ case 0xff:
+ ndr_print_spoolss_PortInfoFF(ndr, "infoFF", &r->infoFF);
break;
default:
@@ -14559,6 +17945,7 @@ _PUBLIC_ void ndr_print_spoolss_AccessRights(struct ndr_print *ndr, const char *
ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ACCESS_ADMINISTER", PRINTER_ACCESS_ADMINISTER, r);
ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "PRINTER_ACCESS_USE", PRINTER_ACCESS_USE, r);
ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_ACCESS_ADMINISTER", JOB_ACCESS_ADMINISTER, r);
+ ndr_print_bitmap_flag(ndr, sizeof(uint32_t), "JOB_ACCESS_READ", JOB_ACCESS_READ, r);
ndr->depth--;
}
@@ -17048,7 +20435,7 @@ static enum ndr_err_code ndr_push_spoolss_GetPrintProcessorDirectory(struct ndr_
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_PrintProcessorDirectoryInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ NDR_CHECK(ndr_push_spoolss_PrintProcessorDirectoryInfo(_ndr_info, NDR_SCALARS, r->out.info));
NDR_CHECK(ndr_push_subcontext_end(ndr, _ndr_info, 4, r->in.offered));
}
}
@@ -17142,7 +20529,7 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrintProcessorDirectory(struct ndr_
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_PrintProcessorDirectoryInfo(_ndr_info, NDR_SCALARS|NDR_BUFFERS, r->out.info));
+ NDR_CHECK(ndr_pull_spoolss_PrintProcessorDirectoryInfo(_ndr_info, NDR_SCALARS, 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);
diff --git a/librpc/gen_ndr/ndr_spoolss.h b/librpc/gen_ndr/ndr_spoolss.h
index 5b32d510c0..eaa16e81a1 100644
--- a/librpc/gen_ndr/ndr_spoolss.h
+++ b/librpc/gen_ndr/ndr_spoolss.h
@@ -211,6 +211,8 @@ void ndr_print_spoolss_ProcessorArchitecture(struct ndr_print *ndr, const char *
void ndr_print_spoolss_ProcessorType(struct ndr_print *ndr, const char *name, enum spoolss_ProcessorType r);
void ndr_print_spoolss_MajorVersion(struct ndr_print *ndr, const char *name, enum spoolss_MajorVersion r);
void ndr_print_spoolss_MinorVersion(struct ndr_print *ndr, const char *name, enum spoolss_MinorVersion r);
+void ndr_print_spoolss_PrinterStatus(struct ndr_print *ndr, const char *name, uint32_t r);
+void ndr_print_spoolss_JobStatus(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_PrinterInfo0(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo0 *r);
void ndr_print_spoolss_DeviceModeFields(struct ndr_print *ndr, const char *name, uint32_t r);
enum ndr_err_code ndr_push_spoolss_DeviceMode(struct ndr_push *ndr, int ndr_flags, const struct spoolss_DeviceMode *r);
@@ -222,7 +224,6 @@ enum ndr_err_code ndr_pull_spoolss_EnumPrinterFlags(struct ndr_pull *ndr, int nd
void ndr_print_spoolss_EnumPrinterFlags(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_PrinterInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo1 *r);
void ndr_print_spoolss_PrinterAttributes(struct ndr_print *ndr, const char *name, uint32_t r);
-void ndr_print_spoolss_PrinterStatus(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_PrinterInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo2 *r);
void ndr_print_spoolss_PrinterInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo3 *r);
void ndr_print_spoolss_PrinterInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_PrinterInfo4 *r);
@@ -236,9 +237,18 @@ enum ndr_err_code ndr_pull_spoolss_PrinterInfo(struct ndr_pull *ndr, int ndr_fla
void ndr_print_spoolss_PrinterInfo(struct ndr_print *ndr, const char *name, const union spoolss_PrinterInfo *r);
void ndr_print_spoolss_DevmodeContainer(struct ndr_print *ndr, const char *name, const struct spoolss_DevmodeContainer *r);
void ndr_print_spoolss_JobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo1 *r);
+void ndr_print_spoolss_JobInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo2 *r);
+void ndr_print_spoolss_JobInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo3 *r);
+void ndr_print_spoolss_JobInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfo4 *r);
enum ndr_err_code ndr_push_spoolss_JobInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_JobInfo *r);
enum ndr_err_code ndr_pull_spoolss_JobInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_JobInfo *r);
void ndr_print_spoolss_JobInfo(struct ndr_print *ndr, const char *name, const union spoolss_JobInfo *r);
+void ndr_print_spoolss_SetJobInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo1 *r);
+void ndr_print_spoolss_SetJobInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo2 *r);
+void ndr_print_spoolss_SetJobInfo4(struct ndr_print *ndr, const char *name, const struct spoolss_SetJobInfo4 *r);
+enum ndr_err_code ndr_push_spoolss_SetJobInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_SetJobInfo *r);
+enum ndr_err_code ndr_pull_spoolss_SetJobInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_SetJobInfo *r);
+void ndr_print_spoolss_SetJobInfo(struct ndr_print *ndr, const char *name, const union spoolss_SetJobInfo *r);
void ndr_print_spoolss_JobInfoContainer(struct ndr_print *ndr, const char *name, const struct spoolss_JobInfoContainer *r);
void ndr_print_spoolss_JobControl(struct ndr_print *ndr, const char *name, enum spoolss_JobControl r);
void ndr_print_spoolss_PrinterControl(struct ndr_print *ndr, const char *name, enum spoolss_PrinterControl r);
@@ -344,15 +354,22 @@ void ndr_print_spoolss_FormFlags(struct ndr_print *ndr, const char *name, enum s
void ndr_print_spoolss_FormSize(struct ndr_print *ndr, const char *name, const struct spoolss_FormSize *r);
void ndr_print_spoolss_FormArea(struct ndr_print *ndr, const char *name, const struct spoolss_FormArea *r);
void ndr_print_spoolss_FormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo1 *r);
+void ndr_print_spoolss_FormStringType(struct ndr_print *ndr, const char *name, uint32_t r);
+void ndr_print_spoolss_FormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_FormInfo2 *r);
enum ndr_err_code ndr_push_spoolss_FormInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_FormInfo *r);
enum ndr_err_code ndr_pull_spoolss_FormInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_FormInfo *r);
void ndr_print_spoolss_FormInfo(struct ndr_print *ndr, const char *name, const union spoolss_FormInfo *r);
size_t ndr_size_spoolss_FormInfo(const union spoolss_FormInfo *r, uint32_t level, struct smb_iconv_convenience *ic, int flags);
void ndr_print_spoolss_AddFormInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo1 *r);
+void ndr_print_spoolss_AddFormInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_AddFormInfo2 *r);
void ndr_print_spoolss_AddFormInfo(struct ndr_print *ndr, const char *name, const union spoolss_AddFormInfo *r);
void ndr_print_spoolss_PortInfo1(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo1 *r);
void ndr_print_spoolss_PortType(struct ndr_print *ndr, const char *name, uint32_t r);
void ndr_print_spoolss_PortInfo2(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo2 *r);
+void ndr_print_spoolss_PortStatus(struct ndr_print *ndr, const char *name, enum spoolss_PortStatus r);
+void ndr_print_spoolss_PortSeverity(struct ndr_print *ndr, const char *name, enum spoolss_PortSeverity r);
+void ndr_print_spoolss_PortInfo3(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfo3 *r);
+void ndr_print_spoolss_PortInfoFF(struct ndr_print *ndr, const char *name, const struct spoolss_PortInfoFF *r);
enum ndr_err_code ndr_push_spoolss_PortInfo(struct ndr_push *ndr, int ndr_flags, const union spoolss_PortInfo *r);
enum ndr_err_code ndr_pull_spoolss_PortInfo(struct ndr_pull *ndr, int ndr_flags, union spoolss_PortInfo *r);
void ndr_print_spoolss_PortInfo(struct ndr_print *ndr, const char *name, const union spoolss_PortInfo *r);
diff --git a/librpc/gen_ndr/netlogon.h b/librpc/gen_ndr/netlogon.h
index d1038d76c8..892e770bad 100644
--- a/librpc/gen_ndr/netlogon.h
+++ b/librpc/gen_ndr/netlogon.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/samr.h"
diff --git a/librpc/gen_ndr/ntsvcs.h b/librpc/gen_ndr/ntsvcs.h
index 5021aa2252..804c452816 100644
--- a/librpc/gen_ndr/ntsvcs.h
+++ b/librpc/gen_ndr/ntsvcs.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/winreg.h"
#ifndef _HEADER_ntsvcs
#define _HEADER_ntsvcs
diff --git a/librpc/gen_ndr/samr.h b/librpc/gen_ndr/samr.h
index 782987de1c..044756469e 100644
--- a/librpc/gen_ndr/samr.h
+++ b/librpc/gen_ndr/samr.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/security.h"
diff --git a/librpc/gen_ndr/security.h b/librpc/gen_ndr/security.h
index 4fa9a8084c..32ea2eaacd 100644
--- a/librpc/gen_ndr/security.h
+++ b/librpc/gen_ndr/security.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#define dom_sid2 dom_sid
#define dom_sid28 dom_sid
diff --git a/librpc/gen_ndr/spoolss.h b/librpc/gen_ndr/spoolss.h
index ad4554dbe5..9c5496e07c 100644
--- a/librpc/gen_ndr/spoolss.h
+++ b/librpc/gen_ndr/spoolss.h
@@ -2,12 +2,16 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/winreg.h"
#ifndef _HEADER_spoolss
#define _HEADER_spoolss
+#define PRINTER_STATUS_OK ( 0x00000000 )
+#define JOB_STATUS_QUEUED ( 0x0000 )
#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" )
@@ -117,6 +121,48 @@ enum spoolss_MinorVersion
#endif
;
+/* bitmap spoolss_PrinterStatus */
+#define PRINTER_STATUS_PAUSED ( 0x00000001 )
+#define PRINTER_STATUS_ERROR ( 0x00000002 )
+#define PRINTER_STATUS_PENDING_DELETION ( 0x00000004 )
+#define PRINTER_STATUS_PAPER_JAM ( 0x00000008 )
+#define PRINTER_STATUS_PAPER_OUT ( 0x00000010 )
+#define PRINTER_STATUS_MANUAL_FEED ( 0x00000020 )
+#define PRINTER_STATUS_PAPER_PROBLEM ( 0x00000040 )
+#define PRINTER_STATUS_OFFLINE ( 0x00000080 )
+#define PRINTER_STATUS_IO_ACTIVE ( 0x00000100 )
+#define PRINTER_STATUS_BUSY ( 0x00000200 )
+#define PRINTER_STATUS_PRINTING ( 0x00000400 )
+#define PRINTER_STATUS_OUTPUT_BIN_FULL ( 0x00000800 )
+#define PRINTER_STATUS_NOT_AVAILABLE ( 0x00001000 )
+#define PRINTER_STATUS_WAITING ( 0x00002000 )
+#define PRINTER_STATUS_PROCESSING ( 0x00004000 )
+#define PRINTER_STATUS_INITIALIZING ( 0x00008000 )
+#define PRINTER_STATUS_WARMING_UP ( 0x00010000 )
+#define PRINTER_STATUS_TONER_LOW ( 0x00020000 )
+#define PRINTER_STATUS_NO_TONER ( 0x00040000 )
+#define PRINTER_STATUS_PAGE_PUNT ( 0x00080000 )
+#define PRINTER_STATUS_USER_INTERVENTION ( 0x00100000 )
+#define PRINTER_STATUS_OUT_OF_MEMORY ( 0x00200000 )
+#define PRINTER_STATUS_DOOR_OPEN ( 0x00400000 )
+#define PRINTER_STATUS_SERVER_UNKNOWN ( 0x00800000 )
+#define PRINTER_STATUS_POWER_SAVE ( 0x01000000 )
+
+/* bitmap spoolss_JobStatus */
+#define JOB_STATUS_PAUSED ( 0x00000001 )
+#define JOB_STATUS_ERROR ( 0x00000002 )
+#define JOB_STATUS_DELETING ( 0x00000004 )
+#define JOB_STATUS_SPOOLING ( 0x00000008 )
+#define JOB_STATUS_PRINTING ( 0x00000010 )
+#define JOB_STATUS_OFFLINE ( 0x00000020 )
+#define JOB_STATUS_PAPEROUT ( 0x00000040 )
+#define JOB_STATUS_PRINTED ( 0x00000080 )
+#define JOB_STATUS_DELETED ( 0x00000100 )
+#define JOB_STATUS_BLOCKED_DEVQ ( 0x00000200 )
+#define JOB_STATUS_USER_INTERVENTION ( 0x00000400 )
+#define JOB_STATUS_RESTART ( 0x00000800 )
+#define JOB_STATUS_COMPLETE ( 0x00001000 )
+
struct spoolss_PrinterInfo0 {
const char * printername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * servername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
@@ -263,33 +309,6 @@ struct spoolss_PrinterInfo1 {
#define PRINTER_ATTRIBUTE_FAX ( 0x00004000 )
#define PRINTER_ATTRIBUTE_TS ( 0x00008000 )
-/* bitmap spoolss_PrinterStatus */
-#define PRINTER_STATUS_PAUSED ( 0x00000001 )
-#define PRINTER_STATUS_ERROR ( 0x00000002 )
-#define PRINTER_STATUS_PENDING_DELETION ( 0x00000004 )
-#define PRINTER_STATUS_PAPER_JAM ( 0x00000008 )
-#define PRINTER_STATUS_PAPER_OUT ( 0x00000010 )
-#define PRINTER_STATUS_MANUAL_FEED ( 0x00000020 )
-#define PRINTER_STATUS_PAPER_PROBLEM ( 0x00000040 )
-#define PRINTER_STATUS_OFFLINE ( 0x00000080 )
-#define PRINTER_STATUS_IO_ACTIVE ( 0x00000100 )
-#define PRINTER_STATUS_BUSY ( 0x00000200 )
-#define PRINTER_STATUS_PRINTING ( 0x00000400 )
-#define PRINTER_STATUS_OUTPUT_BIN_FULL ( 0x00000800 )
-#define PRINTER_STATUS_NOT_AVAILABLE ( 0x00001000 )
-#define PRINTER_STATUS_WAITING ( 0x00002000 )
-#define PRINTER_STATUS_PROCESSING ( 0x00004000 )
-#define PRINTER_STATUS_INITIALIZING ( 0x00008000 )
-#define PRINTER_STATUS_WARMING_UP ( 0x00010000 )
-#define PRINTER_STATUS_TONER_LOW ( 0x00020000 )
-#define PRINTER_STATUS_NO_TONER ( 0x00040000 )
-#define PRINTER_STATUS_PAGE_PUNT ( 0x00080000 )
-#define PRINTER_STATUS_USER_INTERVENTION ( 0x00100000 )
-#define PRINTER_STATUS_OUT_OF_MEMORY ( 0x00200000 )
-#define PRINTER_STATUS_DOOR_OPEN ( 0x00400000 )
-#define PRINTER_STATUS_SERVER_UNKNOWN ( 0x00800000 )
-#define PRINTER_STATUS_POWER_SAVE ( 0x01000000 )
-
struct spoolss_PrinterInfo2 {
const char * servername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
const char * printername;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
@@ -383,16 +402,154 @@ struct spoolss_JobInfo1 {
uint32_t position;
uint32_t total_pages;
uint32_t pages_printed;
- struct spoolss_Time time;
+ struct spoolss_Time submitted;
+};
+
+struct spoolss_JobInfo2 {
+ uint32_t job_id;
+ const char * printer_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * server_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * document_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * notify_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * data_type;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * print_processor;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * parameters;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * driver_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct spoolss_DeviceMode *devmode;/* [relative] */
+ const char * text_status;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct security_descriptor *secdesc;/* [relative] */
+ uint32_t status;
+ uint32_t priority;
+ uint32_t position;
+ uint32_t start_time;
+ uint32_t until_time;
+ uint32_t total_pages;
+ uint32_t size;
+ struct spoolss_Time submitted;
+ uint32_t time;
+ uint32_t pages_printed;
+};
+
+struct spoolss_JobInfo3 {
+ uint32_t job_id;
+ uint32_t next_job_id;
+ uint32_t reserved;
+};
+
+struct spoolss_JobInfo4 {
+ uint32_t job_id;
+ const char * printer_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * server_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * user_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * document_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * notify_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * data_type;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * print_processor;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * parameters;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ const char * driver_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct spoolss_DeviceMode *devmode;/* [relative] */
+ const char * text_status;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct security_descriptor *secdesc;/* [relative] */
+ uint32_t status;
+ uint32_t priority;
+ uint32_t position;
+ uint32_t start_time;
+ uint32_t until_time;
+ uint32_t total_pages;
+ uint32_t size;
+ struct spoolss_Time submitted;
+ uint32_t time;
+ uint32_t pages_printed;
+ uint32_t size_high;
};
union spoolss_JobInfo {
struct spoolss_JobInfo1 info1;/* [case] */
+ struct spoolss_JobInfo2 info2;/* [case(2)] */
+ struct spoolss_JobInfo3 info3;/* [case(3)] */
+ struct spoolss_JobInfo4 info4;/* [case(4)] */
}/* [relative_base,nodiscriminant,public] */;
+struct spoolss_SetJobInfo1 {
+ uint32_t job_id;
+ const char *printer_name;/* [unique,charset(UTF16)] */
+ const char *server_name;/* [unique,charset(UTF16)] */
+ const char *user_name;/* [unique,charset(UTF16)] */
+ const char *document_name;/* [unique,charset(UTF16)] */
+ const char *data_type;/* [unique,charset(UTF16)] */
+ const char *text_status;/* [unique,charset(UTF16)] */
+ uint32_t status;
+ uint32_t priority;
+ uint32_t position;
+ uint32_t total_pages;
+ uint32_t pages_printed;
+ struct spoolss_Time submitted;
+};
+
+struct spoolss_SetJobInfo2 {
+ uint32_t job_id;
+ const char *printer_name;/* [unique,charset(UTF16)] */
+ const char *server_name;/* [unique,charset(UTF16)] */
+ const char *user_name;/* [unique,charset(UTF16)] */
+ const char *document_name;/* [unique,charset(UTF16)] */
+ const char *notify_name;/* [unique,charset(UTF16)] */
+ const char *data_type;/* [unique,charset(UTF16)] */
+ const char *print_processor;/* [unique,charset(UTF16)] */
+ const char *parameters;/* [unique,charset(UTF16)] */
+ const char *driver_name;/* [unique,charset(UTF16)] */
+ uint32_t _devmode_ptr;
+ const char *text_status;/* [unique,charset(UTF16)] */
+ uint32_t _secdesc_ptr;
+ uint32_t status;
+ uint32_t priority;
+ uint32_t position;
+ uint32_t start_time;
+ uint32_t until_time;
+ uint32_t total_pages;
+ uint32_t size;
+ struct spoolss_Time submitted;
+ uint32_t time;
+ uint32_t pages_printed;
+};
+
+struct spoolss_SetJobInfo4 {
+ uint32_t job_id;
+ const char *printer_name;/* [unique,charset(UTF16)] */
+ const char *server_name;/* [unique,charset(UTF16)] */
+ const char *user_name;/* [unique,charset(UTF16)] */
+ const char *document_name;/* [unique,charset(UTF16)] */
+ const char *notify_name;/* [unique,charset(UTF16)] */
+ const char *data_type;/* [unique,charset(UTF16)] */
+ const char *print_processor;/* [unique,charset(UTF16)] */
+ const char *parameters;/* [unique,charset(UTF16)] */
+ const char *driver_name;/* [unique,charset(UTF16)] */
+ uint32_t _devmode_ptr;
+ const char *text_status;/* [unique,charset(UTF16)] */
+ uint32_t _secdesc_ptr;
+ uint32_t status;
+ uint32_t priority;
+ uint32_t position;
+ uint32_t start_time;
+ uint32_t until_time;
+ uint32_t total_pages;
+ uint32_t size;
+ struct spoolss_Time submitted;
+ uint32_t time;
+ uint32_t pages_printed;
+ uint32_t size_high;
+};
+
+union spoolss_SetJobInfo {
+ struct spoolss_SetJobInfo1 *info1;/* [unique,case] */
+ struct spoolss_SetJobInfo2 *info2;/* [unique,case(2)] */
+ struct spoolss_JobInfo3 *info3;/* [unique,case(3)] */
+ struct spoolss_SetJobInfo4 *info4;/* [unique,case(4)] */
+}/* [public] */;
+
struct spoolss_JobInfoContainer {
uint32_t level;
- union spoolss_JobInfo info;/* [switch_is(level)] */
+ union spoolss_SetJobInfo info;/* [switch_is(level)] */
};
enum spoolss_JobControl
@@ -404,7 +561,9 @@ enum spoolss_JobControl
SPOOLSS_JOB_CONTROL_RESTART=4,
SPOOLSS_JOB_CONTROL_DELETE=5,
SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER=6,
- SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED=7
+ SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED=7,
+ SPOOLSS_JOB_CONTROL_RETAIN=8,
+ SPOOLSS_JOB_CONTROL_RELEASE=9
}
#else
{ __donnot_use_enum_spoolss_JobControl=0x7FFFFFFF}
@@ -415,6 +574,8 @@ enum spoolss_JobControl
#define SPOOLSS_JOB_CONTROL_DELETE ( 5 )
#define SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER ( 6 )
#define SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED ( 7 )
+#define SPOOLSS_JOB_CONTROL_RETAIN ( 8 )
+#define SPOOLSS_JOB_CONTROL_RELEASE ( 9 )
#endif
;
@@ -958,8 +1119,27 @@ struct spoolss_FormInfo1 {
struct spoolss_FormArea area;
};
+/* bitmap spoolss_FormStringType */
+#define SPOOLSS_FORM_STRING_TYPE_NONE ( 0x00000001 )
+#define SPOOLSS_FORM_STRING_TYPE_MUI_DLL ( 0x00000002 )
+#define SPOOLSS_FORM_STRING_TYPE_LANG_PAIR ( 0x00000004 )
+
+struct spoolss_FormInfo2 {
+ enum spoolss_FormFlags flags;
+ const char * form_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ struct spoolss_FormSize size;
+ struct spoolss_FormArea area;
+ const char * keyword;/* [relative,flag(LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t string_type;
+ const char * mui_dll;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t ressource_id;
+ const char * display_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ uint32_t lang_id;
+};
+
union spoolss_FormInfo {
struct spoolss_FormInfo1 info1;/* [case] */
+ struct spoolss_FormInfo2 info2;/* [case(2)] */
}/* [relative_base,gensize,public,nodiscriminant] */;
struct spoolss_AddFormInfo1 {
@@ -969,8 +1149,22 @@ struct spoolss_AddFormInfo1 {
struct spoolss_FormArea area;
};
+struct spoolss_AddFormInfo2 {
+ enum spoolss_FormFlags flags;
+ const char *form_name;/* [unique,charset(UTF16)] */
+ struct spoolss_FormSize size;
+ struct spoolss_FormArea area;
+ const char *keyword;/* [unique,charset(DOS)] */
+ uint32_t string_type;
+ const char *mui_dll;/* [unique,charset(UTF16)] */
+ uint32_t ressource_id;
+ const char *display_name;/* [unique,charset(UTF16)] */
+ uint32_t lang_id;
+};
+
union spoolss_AddFormInfo {
struct spoolss_AddFormInfo1 *info1;/* [unique,case] */
+ struct spoolss_AddFormInfo2 *info2;/* [unique,case(2)] */
}/* [switch_type(uint32)] */;
struct spoolss_PortInfo1 {
@@ -991,9 +1185,72 @@ struct spoolss_PortInfo2 {
uint32_t reserved;
};
+enum spoolss_PortStatus
+#ifndef USE_UINT_ENUMS
+ {
+ PORT_STATUS_CLEAR=0x00000000,
+ PORT_STATUS_OFFLINE=0x00000001,
+ PORT_STATUS_PAPER_JAM=0x00000002,
+ PORT_STATUS_PAPER_OUT=0x00000003,
+ PORT_STATUS_OUTPUT_BIN_FULL=0x00000004,
+ PORT_STATUS_PAPER_PROBLEM=0x00000005,
+ PORT_STATUS_NO_TONER=0x00000006,
+ PORT_STATUS_DOOR_OPEN=0x00000007,
+ PORT_STATUS_USER_INTERVENTION=0x00000008,
+ PORT_STATUS_OUT_OF_MEMORY=0x00000009,
+ PORT_STATUS_TONER_LOW=0x0000000A,
+ PORT_STATUS_WARMING_UP=0x0000000B,
+ PORT_STATUS_POWER_SAVE=0x0000000C
+}
+#else
+ { __donnot_use_enum_spoolss_PortStatus=0x7FFFFFFF}
+#define PORT_STATUS_CLEAR ( 0x00000000 )
+#define PORT_STATUS_OFFLINE ( 0x00000001 )
+#define PORT_STATUS_PAPER_JAM ( 0x00000002 )
+#define PORT_STATUS_PAPER_OUT ( 0x00000003 )
+#define PORT_STATUS_OUTPUT_BIN_FULL ( 0x00000004 )
+#define PORT_STATUS_PAPER_PROBLEM ( 0x00000005 )
+#define PORT_STATUS_NO_TONER ( 0x00000006 )
+#define PORT_STATUS_DOOR_OPEN ( 0x00000007 )
+#define PORT_STATUS_USER_INTERVENTION ( 0x00000008 )
+#define PORT_STATUS_OUT_OF_MEMORY ( 0x00000009 )
+#define PORT_STATUS_TONER_LOW ( 0x0000000A )
+#define PORT_STATUS_WARMING_UP ( 0x0000000B )
+#define PORT_STATUS_POWER_SAVE ( 0x0000000C )
+#endif
+;
+
+enum spoolss_PortSeverity
+#ifndef USE_UINT_ENUMS
+ {
+ PORT_STATUS_TYPE_ERROR=0x00000001,
+ PORT_STATUS_TYPE_WARNING=0x00000002,
+ PORT_STATUS_TYPE_INFO=0x00000003
+}
+#else
+ { __donnot_use_enum_spoolss_PortSeverity=0x7FFFFFFF}
+#define PORT_STATUS_TYPE_ERROR ( 0x00000001 )
+#define PORT_STATUS_TYPE_WARNING ( 0x00000002 )
+#define PORT_STATUS_TYPE_INFO ( 0x00000003 )
+#endif
+;
+
+struct spoolss_PortInfo3 {
+ enum spoolss_PortStatus status;
+ const char * status_string;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ enum spoolss_PortSeverity severity;
+};
+
+struct spoolss_PortInfoFF {
+ const char * port_name;/* [relative,flag(LIBNDR_FLAG_STR_NULLTERM)] */
+ DATA_BLOB monitor_data;
+};
+
union spoolss_PortInfo {
struct spoolss_PortInfo1 info1;/* [case] */
struct spoolss_PortInfo2 info2;/* [case(2)] */
+ struct spoolss_PortInfo3 info3;/* [case(3)] */
+ struct spoolss_PortInfoFF infoFF;/* [case(0xff)] */
}/* [relative_base,nodiscriminant,public] */;
struct spoolss_MonitorInfo1 {
@@ -1227,6 +1484,7 @@ struct spoolss_UserLevelCtr {
#define PRINTER_ACCESS_ADMINISTER ( 0x00000004 )
#define PRINTER_ACCESS_USE ( 0x00000008 )
#define JOB_ACCESS_ADMINISTER ( 0x00000010 )
+#define JOB_ACCESS_READ ( 0x00000020 )
/* bitmap spoolss_DeleteDriverFlags */
#define DPD_DELETE_UNUSED_FILES ( 0x00000001 )
diff --git a/librpc/gen_ndr/srvsvc.h b/librpc/gen_ndr/srvsvc.h
index 6467f72a5b..4a8fd051f6 100644
--- a/librpc/gen_ndr/srvsvc.h
+++ b/librpc/gen_ndr/srvsvc.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/security.h"
#include "librpc/gen_ndr/svcctl.h"
#ifndef _HEADER_srvsvc
diff --git a/librpc/gen_ndr/svcctl.h b/librpc/gen_ndr/svcctl.h
index 328d8ab517..6ba0e4f378 100644
--- a/librpc/gen_ndr/svcctl.h
+++ b/librpc/gen_ndr/svcctl.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/security.h"
#ifndef _HEADER_svcctl
diff --git a/librpc/gen_ndr/winreg.h b/librpc/gen_ndr/winreg.h
index 79cf33e769..e0300fd0e7 100644
--- a/librpc/gen_ndr/winreg.h
+++ b/librpc/gen_ndr/winreg.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/security.h"
#ifndef _HEADER_winreg
diff --git a/librpc/gen_ndr/wkssvc.h b/librpc/gen_ndr/wkssvc.h
index dc12fe2a3f..19aa126322 100644
--- a/librpc/gen_ndr/wkssvc.h
+++ b/librpc/gen_ndr/wkssvc.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/srvsvc.h"
#include "librpc/gen_ndr/lsa.h"
#ifndef _HEADER_wkssvc
diff --git a/librpc/gen_ndr/xattr.h b/librpc/gen_ndr/xattr.h
index 1148a0acec..1ce58f7ec6 100644
--- a/librpc/gen_ndr/xattr.h
+++ b/librpc/gen_ndr/xattr.h
@@ -2,6 +2,8 @@
#include <stdint.h>
+#include "libcli/util/ntstatus.h"
+
#include "librpc/gen_ndr/security.h"
#ifndef _HEADER_xattr
#define _HEADER_xattr
diff --git a/librpc/idl/spoolss.idl b/librpc/idl/spoolss.idl
index 3e35399f8d..f9ca4c1476 100644
--- a/librpc/idl/spoolss.idl
+++ b/librpc/idl/spoolss.idl
@@ -66,6 +66,56 @@ import "misc.idl", "security.idl", "winreg.idl";
SPOOLSS_MINOR_VERSION_ME = 0x0000005a
} spoolss_MinorVersion;
+ const int PRINTER_STATUS_OK = 0x00000000;
+
+ typedef bitmap {
+ PRINTER_STATUS_PAUSED = 0x00000001,
+ PRINTER_STATUS_ERROR = 0x00000002,
+ PRINTER_STATUS_PENDING_DELETION = 0x00000004,
+ PRINTER_STATUS_PAPER_JAM = 0x00000008,
+ PRINTER_STATUS_PAPER_OUT = 0x00000010,
+ PRINTER_STATUS_MANUAL_FEED = 0x00000020,
+ PRINTER_STATUS_PAPER_PROBLEM = 0x00000040,
+ PRINTER_STATUS_OFFLINE = 0x00000080,
+ PRINTER_STATUS_IO_ACTIVE = 0x00000100,
+ PRINTER_STATUS_BUSY = 0x00000200,
+ PRINTER_STATUS_PRINTING = 0x00000400,
+ PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800,
+ PRINTER_STATUS_NOT_AVAILABLE = 0x00001000,
+ PRINTER_STATUS_WAITING = 0x00002000,
+ PRINTER_STATUS_PROCESSING = 0x00004000,
+ PRINTER_STATUS_INITIALIZING = 0x00008000,
+ PRINTER_STATUS_WARMING_UP = 0x00010000,
+ PRINTER_STATUS_TONER_LOW = 0x00020000,
+ PRINTER_STATUS_NO_TONER = 0x00040000,
+ PRINTER_STATUS_PAGE_PUNT = 0x00080000,
+ PRINTER_STATUS_USER_INTERVENTION= 0x00100000,
+ PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000,
+ PRINTER_STATUS_DOOR_OPEN = 0x00400000,
+ PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000,
+ PRINTER_STATUS_POWER_SAVE = 0x01000000
+ } spoolss_PrinterStatus;
+
+ /* JOB status codes. */
+
+ const int JOB_STATUS_QUEUED = 0x0000;
+
+ typedef [bitmap32bit] bitmap {
+ JOB_STATUS_PAUSED = 0x00000001,
+ JOB_STATUS_ERROR = 0x00000002,
+ JOB_STATUS_DELETING = 0x00000004,
+ JOB_STATUS_SPOOLING = 0x00000008,
+ JOB_STATUS_PRINTING = 0x00000010,
+ JOB_STATUS_OFFLINE = 0x00000020,
+ JOB_STATUS_PAPEROUT = 0x00000040,
+ JOB_STATUS_PRINTED = 0x00000080,
+ JOB_STATUS_DELETED = 0x00000100,
+ JOB_STATUS_BLOCKED_DEVQ = 0x00000200,
+ JOB_STATUS_USER_INTERVENTION = 0x00000400,
+ JOB_STATUS_RESTART = 0x00000800,
+ JOB_STATUS_COMPLETE = 0x00001000
+ } spoolss_JobStatus;
+
typedef struct {
[relative] nstring *printername;
[relative] nstring *servername;
@@ -82,13 +132,13 @@ import "misc.idl", "security.idl", "winreg.idl";
uint32 session_counter;
uint32 num_error_out_of_paper;
uint32 num_error_not_ready;
- uint32 job_error;
+ spoolss_JobStatus job_error;
uint32 number_of_processors;
spoolss_ProcessorType processor_type;
uint32 high_part_total_bytes;
uint32 change_id;
WERROR last_error;
- uint32 status;
+ spoolss_PrinterStatus status;
uint32 enumerate_network_printers;
uint32 c_setprinter;
spoolss_ProcessorArchitecture processor_architecture;
@@ -224,34 +274,6 @@ import "misc.idl", "security.idl", "winreg.idl";
PRINTER_ATTRIBUTE_TS = 0x00008000
} spoolss_PrinterAttributes;
- typedef bitmap {
- PRINTER_STATUS_PAUSED = 0x00000001,
- PRINTER_STATUS_ERROR = 0x00000002,
- PRINTER_STATUS_PENDING_DELETION = 0x00000004,
- PRINTER_STATUS_PAPER_JAM = 0x00000008,
- PRINTER_STATUS_PAPER_OUT = 0x00000010,
- PRINTER_STATUS_MANUAL_FEED = 0x00000020,
- PRINTER_STATUS_PAPER_PROBLEM = 0x00000040,
- PRINTER_STATUS_OFFLINE = 0x00000080,
- PRINTER_STATUS_IO_ACTIVE = 0x00000100,
- PRINTER_STATUS_BUSY = 0x00000200,
- PRINTER_STATUS_PRINTING = 0x00000400,
- PRINTER_STATUS_OUTPUT_BIN_FULL = 0x00000800,
- PRINTER_STATUS_NOT_AVAILABLE = 0x00001000,
- PRINTER_STATUS_WAITING = 0x00002000,
- PRINTER_STATUS_PROCESSING = 0x00004000,
- PRINTER_STATUS_INITIALIZING = 0x00008000,
- PRINTER_STATUS_WARMING_UP = 0x00010000,
- PRINTER_STATUS_TONER_LOW = 0x00020000,
- PRINTER_STATUS_NO_TONER = 0x00040000,
- PRINTER_STATUS_PAGE_PUNT = 0x00080000,
- PRINTER_STATUS_USER_INTERVENTION= 0x00100000,
- PRINTER_STATUS_OUT_OF_MEMORY = 0x00200000,
- PRINTER_STATUS_DOOR_OPEN = 0x00400000,
- PRINTER_STATUS_SERVER_UNKNOWN = 0x00800000,
- PRINTER_STATUS_POWER_SAVE = 0x01000000
- } spoolss_PrinterStatus;
-
typedef struct {
[relative] nstring *servername;
[relative] nstring *printername;
@@ -378,6 +400,7 @@ import "misc.idl", "security.idl", "winreg.idl";
/******************/
/* Function: 0x02 */
+
typedef struct {
uint32 job_id;
[relative] nstring *printer_name;
@@ -386,24 +409,161 @@ import "misc.idl", "security.idl", "winreg.idl";
[relative] nstring *document_name;
[relative] nstring *data_type;
[relative] nstring *text_status;
- uint32 status;
+ spoolss_JobStatus status;
uint32 priority;
uint32 position;
uint32 total_pages;
uint32 pages_printed;
- spoolss_Time time;
+ spoolss_Time submitted;
} spoolss_JobInfo1;
+ typedef struct {
+ uint32 job_id;
+ [relative] nstring *printer_name;
+ [relative] nstring *server_name;
+ [relative] nstring *user_name;
+ [relative] nstring *document_name;
+ [relative] nstring *notify_name;
+ [relative] nstring *data_type;
+ [relative] nstring *print_processor;
+ [relative] nstring *parameters;
+ [relative] nstring *driver_name;
+ [relative] spoolss_DeviceMode *devmode;
+ [relative] nstring *text_status;
+ [relative] security_descriptor *secdesc;
+ spoolss_JobStatus status;
+ uint32 priority;
+ uint32 position;
+ uint32 start_time;
+ uint32 until_time;
+ uint32 total_pages;
+ uint32 size;
+ spoolss_Time submitted;
+ uint32 time;
+ uint32 pages_printed;
+ } spoolss_JobInfo2;
+
+ typedef struct {
+ uint32 job_id;
+ uint32 next_job_id;
+ uint32 reserved;
+ } spoolss_JobInfo3;
+
+ typedef struct {
+ uint32 job_id;
+ [relative] nstring *printer_name;
+ [relative] nstring *server_name;
+ [relative] nstring *user_name;
+ [relative] nstring *document_name;
+ [relative] nstring *notify_name;
+ [relative] nstring *data_type;
+ [relative] nstring *print_processor;
+ [relative] nstring *parameters;
+ [relative] nstring *driver_name;
+ [relative] spoolss_DeviceMode *devmode;
+ [relative] nstring *text_status;
+ [relative] security_descriptor *secdesc;
+ spoolss_JobStatus status;
+ uint32 priority;
+ uint32 position;
+ uint32 start_time;
+ uint32 until_time;
+ uint32 total_pages;
+ uint32 size;
+ spoolss_Time submitted;
+ uint32 time;
+ uint32 pages_printed;
+ uint32 size_high;
+ } spoolss_JobInfo4;
+
typedef [nodiscriminant,relative_base,public] union {
[case(1)] spoolss_JobInfo1 info1;
- [case(2)]; /* TODO */
- [case(3)]; /* TODO */
+ [case(2)] spoolss_JobInfo2 info2;
+ [case(3)] spoolss_JobInfo3 info3;
+ [case(4)] spoolss_JobInfo4 info4;
[default];
} spoolss_JobInfo;
typedef struct {
+ uint32 job_id;
+ [string,charset(UTF16)] uint16 *printer_name;
+ [string,charset(UTF16)] uint16 *server_name;
+ [string,charset(UTF16)] uint16 *user_name;
+ [string,charset(UTF16)] uint16 *document_name;
+ [string,charset(UTF16)] uint16 *data_type;
+ [string,charset(UTF16)] uint16 *text_status;
+ spoolss_JobStatus status;
+ uint32 priority;
+ uint32 position;
+ uint32 total_pages;
+ uint32 pages_printed;
+ spoolss_Time submitted;
+ } spoolss_SetJobInfo1;
+
+ typedef struct {
+ uint32 job_id;
+ [string,charset(UTF16)] uint16 *printer_name;
+ [string,charset(UTF16)] uint16 *server_name;
+ [string,charset(UTF16)] uint16 *user_name;
+ [string,charset(UTF16)] uint16 *document_name;
+ [string,charset(UTF16)] uint16 *notify_name;
+ [string,charset(UTF16)] uint16 *data_type;
+ [string,charset(UTF16)] uint16 *print_processor;
+ [string,charset(UTF16)] uint16 *parameters;
+ [string,charset(UTF16)] uint16 *driver_name;
+ uint32 _devmode_ptr; /* pointer to truncated devicemode */
+ [string,charset(UTF16)] uint16 *text_status;
+ uint32 _secdesc_ptr;
+ spoolss_JobStatus status;
+ uint32 priority;
+ uint32 position;
+ uint32 start_time;
+ uint32 until_time;
+ uint32 total_pages;
+ uint32 size;
+ spoolss_Time submitted;
+ uint32 time;
+ uint32 pages_printed;
+ } spoolss_SetJobInfo2;
+
+ typedef struct {
+ uint32 job_id;
+ [string,charset(UTF16)] uint16 *printer_name;
+ [string,charset(UTF16)] uint16 *server_name;
+ [string,charset(UTF16)] uint16 *user_name;
+ [string,charset(UTF16)] uint16 *document_name;
+ [string,charset(UTF16)] uint16 *notify_name;
+ [string,charset(UTF16)] uint16 *data_type;
+ [string,charset(UTF16)] uint16 *print_processor;
+ [string,charset(UTF16)] uint16 *parameters;
+ [string,charset(UTF16)] uint16 *driver_name;
+ uint32 _devmode_ptr; /* pointer to truncated devicemode */
+ [string,charset(UTF16)] uint16 *text_status;
+ uint32 _secdesc_ptr;
+ spoolss_JobStatus status;
+ uint32 priority;
+ uint32 position;
+ uint32 start_time;
+ uint32 until_time;
+ uint32 total_pages;
+ uint32 size;
+ spoolss_Time submitted;
+ uint32 time;
+ uint32 pages_printed;
+ uint32 size_high;
+ } spoolss_SetJobInfo4;
+
+ typedef [public] union {
+ [case(1)] spoolss_SetJobInfo1 *info1;
+ [case(2)] spoolss_SetJobInfo2 *info2;
+ [case(3)] spoolss_JobInfo3 *info3;
+ [case(4)] spoolss_SetJobInfo4 *info4;
+ [default];
+ } spoolss_SetJobInfo;
+
+ typedef struct {
uint32 level;
- [switch_is(level)] spoolss_JobInfo info;
+ [switch_is(level)] spoolss_SetJobInfo info;
} spoolss_JobInfoContainer;
typedef [v1_enum] enum {
@@ -413,7 +573,9 @@ import "misc.idl", "security.idl", "winreg.idl";
SPOOLSS_JOB_CONTROL_RESTART = 4,
SPOOLSS_JOB_CONTROL_DELETE = 5,
SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER = 6,
- SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED = 7
+ SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED = 7,
+ SPOOLSS_JOB_CONTROL_RETAIN = 8,
+ SPOOLSS_JOB_CONTROL_RELEASE = 9
} spoolss_JobControl;
WERROR spoolss_SetJob(
@@ -1021,7 +1183,7 @@ import "misc.idl", "security.idl", "winreg.idl";
typedef [nodiscriminant,relative_base,gensize,public] union {
[case(1)] spoolss_PrintProcessorDirectoryInfo1 info1;
- [default];
+ [default] spoolss_PrintProcessorDirectoryInfo1 info1;
} spoolss_PrintProcessorDirectoryInfo;
WERROR spoolss_GetPrintProcessorDirectory(
@@ -1237,8 +1399,28 @@ import "misc.idl", "security.idl", "winreg.idl";
spoolss_FormArea area;
} spoolss_FormInfo1;
+ typedef [bitmap32bit] bitmap {
+ SPOOLSS_FORM_STRING_TYPE_NONE = 0x00000001,
+ SPOOLSS_FORM_STRING_TYPE_MUI_DLL = 0x00000002,
+ SPOOLSS_FORM_STRING_TYPE_LANG_PAIR = 0x00000004
+ } spoolss_FormStringType;
+
+ typedef struct {
+ spoolss_FormFlags flags;
+ [relative] nstring *form_name;
+ spoolss_FormSize size;
+ spoolss_FormArea area;
+ [relative] astring *keyword;
+ spoolss_FormStringType string_type;
+ [relative] nstring *mui_dll;
+ uint32 ressource_id;
+ [relative] nstring *display_name;
+ uint32 lang_id;
+ } spoolss_FormInfo2;
+
typedef [nodiscriminant,relative_base,public,gensize] union {
[case(1)] spoolss_FormInfo1 info1;
+ [case(2)] spoolss_FormInfo2 info2;
[default];
} spoolss_FormInfo;
@@ -1249,8 +1431,22 @@ import "misc.idl", "security.idl", "winreg.idl";
spoolss_FormArea area;
} spoolss_AddFormInfo1;
+ typedef struct {
+ spoolss_FormFlags flags;
+ [string,charset(UTF16)] uint16 *form_name;
+ spoolss_FormSize size;
+ spoolss_FormArea area;
+ [string,charset(DOS)] uint8 *keyword;
+ spoolss_FormStringType string_type;
+ [string,charset(UTF16)] uint16 *mui_dll;
+ uint32 ressource_id;
+ [string,charset(UTF16)] uint16 *display_name;
+ uint32 lang_id;
+ } spoolss_AddFormInfo2;
+
typedef [switch_type(uint32)] union {
[case(1)] spoolss_AddFormInfo1 *info1;
+ [case(2)] spoolss_AddFormInfo2 *info2;
} spoolss_AddFormInfo;
WERROR spoolss_AddForm(
@@ -1332,10 +1528,44 @@ import "misc.idl", "security.idl", "winreg.idl";
uint32 reserved;
} spoolss_PortInfo2;
+ typedef [v1_enum] enum {
+ PORT_STATUS_CLEAR = 0x00000000,
+ PORT_STATUS_OFFLINE = 0x00000001,
+ PORT_STATUS_PAPER_JAM = 0x00000002,
+ PORT_STATUS_PAPER_OUT = 0x00000003,
+ PORT_STATUS_OUTPUT_BIN_FULL = 0x00000004,
+ PORT_STATUS_PAPER_PROBLEM = 0x00000005,
+ PORT_STATUS_NO_TONER = 0x00000006,
+ PORT_STATUS_DOOR_OPEN = 0x00000007,
+ PORT_STATUS_USER_INTERVENTION = 0x00000008,
+ PORT_STATUS_OUT_OF_MEMORY = 0x00000009,
+ PORT_STATUS_TONER_LOW = 0x0000000A,
+ PORT_STATUS_WARMING_UP = 0x0000000B,
+ PORT_STATUS_POWER_SAVE = 0x0000000C
+ } spoolss_PortStatus;
+
+ typedef [v1_enum] enum {
+ PORT_STATUS_TYPE_ERROR = 0x00000001,
+ PORT_STATUS_TYPE_WARNING = 0x00000002,
+ PORT_STATUS_TYPE_INFO = 0x00000003
+ } spoolss_PortSeverity;
+
+ typedef struct {
+ spoolss_PortStatus status;
+ [relative] nstring *status_string;
+ spoolss_PortSeverity severity;
+ } spoolss_PortInfo3;
+
+ typedef struct {
+ [relative] nstring *port_name;
+ DATA_BLOB monitor_data; /* relative ?? */
+ } spoolss_PortInfoFF;
+
typedef [nodiscriminant,relative_base,public] union {
[case(1)] spoolss_PortInfo1 info1;
[case(2)] spoolss_PortInfo2 info2;
- [case(3)]; /* TODO */
+ [case(3)] spoolss_PortInfo3 info3;
+ [case(0xff)] spoolss_PortInfoFF infoFF;
[default];
} spoolss_PortInfo;
@@ -1807,7 +2037,8 @@ import "misc.idl", "security.idl", "winreg.idl";
SERVER_ACCESS_ENUMERATE = 0x00000002,
PRINTER_ACCESS_ADMINISTER = 0x00000004,
PRINTER_ACCESS_USE = 0x00000008,
- JOB_ACCESS_ADMINISTER = 0x00000010
+ JOB_ACCESS_ADMINISTER = 0x00000010,
+ JOB_ACCESS_READ = 0x00000020
} spoolss_AccessRights;
/* Access rights for print servers */
diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm
index 0411466c82..5315957946 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -407,6 +407,9 @@ sub Parse($)
}
pidl "#include <stdint.h>\n";
pidl "\n";
+ # FIXME: Include this only if NTSTATUS was actually used
+ pidl choose_header("libcli/util/ntstatus.h", "core/ntstatus.h") . "\n";
+ pidl "\n";
foreach (@{$ndr}) {
($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_);
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
index f8209be654..f2a96a3037 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -131,7 +131,9 @@ sub Parse($$$$)
if (is_intree()) {
$res .= "#include \"includes.h\"\n";
} else {
+ $res .= "#ifndef _GNU_SOURCE\n";
$res .= "#define _GNU_SOURCE\n";
+ $res .= "#endif\n";
$res .= "#include <stdio.h>\n";
$res .= "#include <stdbool.h>\n";
$res .= "#include <stdlib.h>\n";
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index af6885f67a..34aebc7f0f 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -586,9 +586,15 @@ sub ParseElementPushLevel
my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL});
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
+ my $array_pointless = ($length eq "0");
+
+ if ($array_pointless) {
+ warning($e->{ORIGINAL}, "pointless array `$e->{NAME}' will always have size 0");
+ }
+
$var_name = get_array_element($var_name, $counter);
- if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) {
+ if ((($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) and not $array_pointless) {
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
$self->indent;
$self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 0);
@@ -596,7 +602,7 @@ sub ParseElementPushLevel
$self->pidl("}");
}
- if ($deferred and ContainsDeferred($e, $l)) {
+ if ($deferred and ContainsDeferred($e, $l) and not $array_pointless) {
$self->pidl("for ($counter = 0; $counter < $length; $counter++) {");
$self->indent;
$self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 0, 1);
@@ -2548,7 +2554,9 @@ sub GenerateIncludes($)
if (is_intree()) {
$self->pidl("#include \"includes.h\"");
} else {
+ $self->pidl("#ifndef _GNU_SOURCE");
$self->pidl("#define _GNU_SOURCE");
+ $self->pidl("#endif");
$self->pidl("#include <stdint.h>");
$self->pidl("#include <stdlib.h>");
$self->pidl("#include <stdio.h>");
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/source3/Makefile.in b/source3/Makefile.in
index 73b2989421..6aabcf0c8d 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -340,7 +340,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.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/system.o \
- ../lib/util/tevent_unix.o
+ ../lib/util/tevent_unix.o ../lib/util/tevent_ntstatus.o
CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
@@ -366,11 +366,12 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
lib/substitute.o lib/dbwrap_util.o \
lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \
- lib/iconv.o lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \
- lib/adt_tree.o lib/gencache.o \
+ lib/iconv.o lib/pam_errors.o intl/lang_tdb.o \
+ lib/conn_tdb.o lib/adt_tree.o lib/gencache.o \
lib/module.o lib/events.o @LIBTEVENT_OBJ0@ \
lib/ldap_escape.o @CHARSET_STATIC@ \
- lib/secdesc.o lib/util_seaccess.o lib/secace.o lib/secacl.o \
+ lib/secdesc.o lib/util_seaccess.o ../libcli/security/secace.o \
+ ../libcli/security/secacl.o \
libads/krb5_errs.o lib/system_smbd.o lib/audit.o $(LIBNDR_OBJ) \
lib/file_id.o lib/idmap_cache.o \
../libcli/security/dom_sid.o
@@ -671,8 +672,8 @@ VFS_ACL_XATTR_OBJ = modules/vfs_acl_xattr.o
VFS_ACL_TDB_OBJ = modules/vfs_acl_tdb.o
VFS_SMB_TRAFFIC_ANALYZER_OBJ = modules/vfs_smb_traffic_analyzer.o
VFS_ONEFS_OBJ = modules/vfs_onefs.o modules/onefs_acl.o modules/onefs_system.o \
- modules/onefs_open.o modules/onefs_streams.o modules/onefs_dir.c \
- modules/onefs_cbrl.o modules/onefs_notify.o
+ modules/onefs_open.o modules/onefs_streams.o modules/onefs_dir.o \
+ modules/onefs_cbrl.o modules/onefs_notify.o modules/onefs_config.o
VFS_ONEFS_SHADOW_COPY_OBJ = modules/vfs_onefs_shadow_copy.o modules/onefs_shadow_copy.o
PERFCOUNT_ONEFS_OBJ = modules/perfcount_onefs.o
PERFCOUNT_TEST_OBJ = modules/perfcount_test.o
@@ -689,7 +690,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
@@ -2207,7 +2208,7 @@ installliblua:: installdirs liblua
@$(SHELL) $(srcdir)/script/installdirs.sh $(INSTALLPERMS_BIN) $(DESTDIR) $(LIBDIR)
-$(INSTALLLIBCMD_SH) $(LIBLUA_SHARED_TARGET_SONAME) $(DESTDIR)$(LIBDIR)
@rm -f $(DESTDIR)$(LIBDIR)/`basename $(LIBLUA_SHARED_TARGET)`
- -if test -e $(LIBLUA_SHARED_TARGET_SONAME) ; then \
+ -if test -f $(LIBLUA_SHARED_TARGET_SONAME) ; then \
ln -f -s `basename $(LIBLUA_SHARED_TARGET_SONAME)` \
$(DESTDIR)$(LIBDIR)/`basename $(LIBLUA_SHARED_TARGET)` ; \
fi
@@ -2355,9 +2356,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 $@"
@@ -2375,9 +2376,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_util.c b/source3/auth/auth_util.c
index 1f00e22a3c..c39aa8501d 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -806,7 +806,7 @@ NTSTATUS create_local_token(auth_serversupplied_info *server_info)
}
/*
- * Create an artificial NT token given just a username. (Initially indended
+ * Create an artificial NT token given just a username. (Initially intended
* for force user)
*
* We go through lookup_name() to avoid problems we had with 'winbind use
@@ -859,12 +859,6 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
goto done;
}
- if (!sid_to_uid(&user_sid, uid)) {
- DEBUG(1, ("sid_to_uid for %s (%s) failed\n",
- username, sid_string_dbg(&user_sid)));
- goto done;
- }
-
if (sid_check_is_in_our_domain(&user_sid)) {
bool ret;
@@ -922,6 +916,12 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
unix_user:
+ if (!sid_to_uid(&user_sid, uid)) {
+ DEBUG(1, ("sid_to_uid for %s (%s) failed\n",
+ username, sid_string_dbg(&user_sid)));
+ goto done;
+ }
+
uid_to_unix_users_sid(*uid, &user_sid);
pass = getpwuid_alloc(tmp_ctx, *uid);
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/mount.cifs.c b/source3/client/mount.cifs.c
index ae8a7fd186..8623d3c04b 100644
--- a/source3/client/mount.cifs.c
+++ b/source3/client/mount.cifs.c
@@ -649,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) {
diff --git a/source3/configure.in b/source3/configure.in
index bd3d4af40b..e48ff34554 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"
@@ -4723,35 +4723,6 @@ SMB_LIBRARY(addns, 0, no, [undefined API])
#################################################
-# check to see if we should set the protected madvise flag,
-# which will keep smbd alive in low memory conditions
-AC_MSG_CHECKING(whether to protect smbd from being killed in low memory)
-AC_ARG_WITH(madvise-protect,
-[AS_HELP_STRING([--with-madvise-protect], [Include low memory madvise protection (default=no)])],
-[ case "$withval" in
- yes)
- AC_TRY_COMPILE([
- #include <sys/mman.h>
- ],[
- int a = MADV_PROTECT;
- ],
- [samba_cv_madvise_protect=yes],
- [samba_cv_madvise_protect=no])
- if test x"$samba_cv_madvise_protect" = x"yes"; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(WITH_MADVISE_PROTECTED,1,[Whether to include low memory protection support])
- else
- AC_MSG_ERROR(Low memory protection supporte requires availability of MADVISE_PROTECT flag.)
- fi
- ;;
- *)
- AC_MSG_RESULT(no)
- ;;
- esac ],
- AC_MSG_RESULT(no)
-)
-
-#################################################
# these tests are taken from the GNU fileutils package
AC_CHECKING(how to get filesystem space usage)
space=no
@@ -6130,7 +6101,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 +6144,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/charset.h b/source3/include/charset.h
deleted file mode 100644
index 1c2a5fb5f0..0000000000
--- a/source3/include/charset.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- charset defines
- Copyright (C) Andrew Tridgell 2001
- Copyright (C) Jelmer Vernooij 2002
-
- 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/>.
-*/
-
-struct smb_iconv_convenience;
-
-/* this defines the charset types used in samba */
-typedef enum {CH_UTF16LE=0, CH_UTF16=0, CH_UNIX=1, CH_DISPLAY=2, CH_DOS=3, CH_UTF8=4, CH_UTF16BE=5} charset_t;
-
-#define NUM_CHARSETS 6
-
-/*
- * for each charset we have a function that pushes from that charset to a ucs2
- * buffer, and a function that pulls from ucs2 buffer to that charset.
- * */
-
-struct charset_functions {
- const char *name;
- size_t (*pull)(void *, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- size_t (*push)(void *, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- struct charset_functions *prev, *next;
-};
-
-/*
- * This is auxiliary struct used by source/script/gen-8-bit-gap.sh script
- * during generation of an encoding table for charset module
- * */
-
-struct charset_gap_table {
- uint16 start;
- uint16 end;
- int32 idx;
-};
-
-/*
- * Define stub for charset module which implements 8-bit encoding with gaps.
- * Encoding tables for such module should be produced from glibc's CHARMAPs
- * using script source/script/gen-8bit-gap.sh
- * CHARSETNAME is CAPITALIZED charset name
- *
- * */
-#define SMB_GENERATE_CHARSET_MODULE_8_BIT_GAP(CHARSETNAME) \
-static size_t CHARSETNAME ## _push(void *cd, const char **inbuf, size_t *inbytesleft, \
- char **outbuf, size_t *outbytesleft) \
-{ \
- while (*inbytesleft >= 2 && *outbytesleft >= 1) { \
- int i; \
- int done = 0; \
- \
- uint16 ch = SVAL(*inbuf,0); \
- \
- for (i=0; from_idx[i].start != 0xffff; i++) { \
- if ((from_idx[i].start <= ch) && (from_idx[i].end >= ch)) { \
- ((unsigned char*)(*outbuf))[0] = from_ucs2[from_idx[i].idx+ch]; \
- (*inbytesleft) -= 2; \
- (*outbytesleft) -= 1; \
- (*inbuf) += 2; \
- (*outbuf) += 1; \
- done = 1; \
- break; \
- } \
- } \
- if (!done) { \
- errno = EINVAL; \
- return -1; \
- } \
- \
- } \
- \
- if (*inbytesleft == 1) { \
- errno = EINVAL; \
- return -1; \
- } \
- \
- if (*inbytesleft > 1) { \
- errno = E2BIG; \
- return -1; \
- } \
- \
- return 0; \
-} \
- \
-static size_t CHARSETNAME ## _pull(void *cd, const char **inbuf, size_t *inbytesleft, \
- char **outbuf, size_t *outbytesleft) \
-{ \
- while (*inbytesleft >= 1 && *outbytesleft >= 2) { \
- *(uint16*)(*outbuf) = to_ucs2[((unsigned char*)(*inbuf))[0]]; \
- (*inbytesleft) -= 1; \
- (*outbytesleft) -= 2; \
- (*inbuf) += 1; \
- (*outbuf) += 2; \
- } \
- \
- if (*inbytesleft > 0) { \
- errno = E2BIG; \
- return -1; \
- } \
- \
- return 0; \
-} \
- \
-struct charset_functions CHARSETNAME ## _functions = \
- {#CHARSETNAME, CHARSETNAME ## _pull, CHARSETNAME ## _push}; \
- \
-NTSTATUS charset_ ## CHARSETNAME ## _init(void); \
-NTSTATUS charset_ ## CHARSETNAME ## _init(void) \
-{ \
- return smb_register_charset(& CHARSETNAME ## _functions); \
-} \
-
diff --git a/source3/include/dbwrap.h b/source3/include/dbwrap.h
index aad4ccd721..16f10cc125 100644
--- a/source3/include/dbwrap.h
+++ b/source3/include/dbwrap.h
@@ -46,6 +46,10 @@ struct db_context {
int (*transaction_start)(struct db_context *db);
int (*transaction_commit)(struct db_context *db);
int (*transaction_cancel)(struct db_context *db);
+ int (*parse_record)(struct db_context *db, TDB_DATA key,
+ int (*parser)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data);
void *private_data;
bool persistent;
};
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 80d7bfc6cf..b48a75526a 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -577,22 +577,20 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
#include "../talloc/talloc.h"
#include "event.h"
+#include "../lib/util/tevent_unix.h"
+#include "../lib/util/tevent_ntstatus.h"
#include "../lib/util/data_blob.h"
#include "../lib/util/time.h"
#include "../lib/util/asn1.h"
-/* And a little extension. Abort on type mismatch */
-#define talloc_get_type_abort(ptr, type) \
- (type *)talloc_check_name_abort(ptr, #type)
-
#include "ads.h"
#include "ads_dns.h"
#include "interfaces.h"
#include "trans2.h"
#include "../libcli/util/error.h"
#include "ntioctl.h"
-#include "charset.h"
+#include "../lib/util/charset/charset.h"
#include "dynconfig.h"
#include "util_getent.h"
#include "debugparse.h"
@@ -701,6 +699,8 @@ enum flush_reason_enum {
#ifndef NO_PROTO_H
#include "proto.h"
#endif
+#include "libcli/security/secace.h"
+#include "libcli/security/secacl.h"
#if defined(HAVE_POSIX_ACLS)
#include "modules/vfs_posixacl.h"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9366607995..78110161c5 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -336,6 +336,7 @@ int bitmap_find(struct bitmap *bm, unsigned ofs);
/* The following definitions come from lib/charcnv.c */
+NTSTATUS smb_register_charset(struct charset_functions *funcs);
char lp_failed_convert_char(void);
void lazy_initialize_conv(void);
void gfree_charcnv(void);
@@ -347,7 +348,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void *dst,
size_t *converted_size, bool allow_bad_conv);
bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
- void const *src, size_t srclen, void *dst,
+ void const *src, size_t srclen, void **dst,
size_t *converted_size, bool allow_bad_conv);
size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen);
char *strdup_upper(const char *s);
@@ -528,15 +529,6 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
int gencache_lock_entry( const char *key );
void gencache_unlock_entry( const char *key );
-/* The following definitions come from lib/iconv.c */
-
-NTSTATUS smb_register_charset(struct charset_functions *funcs) ;
-size_t smb_iconv(smb_iconv_t cd,
- const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
-smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode);
-int smb_iconv_close (smb_iconv_t cd);
-
/* The following definitions come from lib/interface.c */
bool ismyaddr(const struct sockaddr *ip);
@@ -659,28 +651,6 @@ ssize_t sys_recvfile(int fromfd,
size_t count);
ssize_t drain_socket(int sockfd, size_t count);
-/* The following definitions come from lib/secace.c */
-
-bool sec_ace_object(uint8 type);
-void sec_ace_copy(SEC_ACE *ace_dest, SEC_ACE *ace_src);
-void init_sec_ace(SEC_ACE *t, const DOM_SID *sid, enum security_ace_type type,
- uint32 mask, uint8 flag);
-NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, unsigned *num, DOM_SID *sid, uint32 mask);
-NTSTATUS sec_ace_mod_sid(SEC_ACE *ace, size_t num, DOM_SID *sid, uint32 mask);
-NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **pp_new, SEC_ACE *old, uint32 *num, DOM_SID *sid);
-bool sec_ace_equal(SEC_ACE *s1, SEC_ACE *s2);
-int nt_ace_inherit_comp( SEC_ACE *a1, SEC_ACE *a2);
-int nt_ace_canon_comp( SEC_ACE *a1, SEC_ACE *a2);
-void dacl_sort_into_canonical_order(SEC_ACE *srclist, unsigned int num_aces);
-bool token_sid_in_ace(const NT_USER_TOKEN *token, const SEC_ACE *ace);
-
-/* The following definitions come from lib/secacl.c */
-
-SEC_ACL *make_sec_acl(TALLOC_CTX *ctx, enum security_acl_revision revision,
- int num_aces, SEC_ACE *ace_list);
-SEC_ACL *dup_sec_acl(TALLOC_CTX *ctx, SEC_ACL *src);
-bool sec_acl_equal(SEC_ACL *s1, SEC_ACL *s2);
-
/* The following definitions come from lib/secdesc.c */
bool sec_desc_equal(SEC_DESC *s1, SEC_DESC *s2);
@@ -1203,7 +1173,6 @@ bool mask_match_search(const char *string, const char *pattern, bool is_case_sen
bool mask_match_list(const char *string, char **list, int listLen, bool is_case_sensitive);
bool unix_wild_match(const char *pattern, const char *string);
bool name_to_fqdn(fstring fqdn, const char *name);
-void *talloc_check_name_abort(const void *ptr, const char *name);
void *talloc_append_blob(TALLOC_CTX *mem_ctx, void *buf, DATA_BLOB blob);
uint32 map_share_mode_to_deny_mode(uint32 share_access, uint32 private_options);
pid_t procid_to_pid(const struct server_id *proc);
@@ -1261,6 +1230,7 @@ NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
const struct nt_user_token *token_1,
const struct nt_user_token *token_2,
struct nt_user_token **token_out);
+bool token_sid_in_ace(const NT_USER_TOKEN *token, const SEC_ACE *ace);
/* The following definitions come from lib/util_pw.c */
@@ -1423,12 +1393,12 @@ int open_socket_in(int type,
bool rebind);
NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
int timeout, int *pfd);
-struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- const struct sockaddr_storage *pss,
- uint16_t port,
- int timeout);
-NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd);
+struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ const struct sockaddr_storage *pss,
+ uint16_t port,
+ int timeout);
+NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd);
struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct timeval wait_time,
@@ -4693,6 +4663,10 @@ NTSTATUS pdb_nds_init(void);
NTSTATUS pdb_smbpasswd_init(void) ;
+/* The following definitions come from passdb/pdb_wbc_sam.c */
+
+NTSTATUS pdb_wbc_sam_init(void);
+
/* The following definitions come from passdb/pdb_tdb.c */
bool init_sam_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 buflen);
@@ -5045,12 +5019,15 @@ WERROR init_registry_data(void);
WERROR regdb_init(void);
WERROR regdb_open( void );
int regdb_close( void );
+WERROR regdb_transaction_start(void);
+WERROR regdb_transaction_commit(void);
+WERROR regdb_transaction_cancel(void);
int regdb_get_seqnum(void);
-bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr);
-int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr);
+bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr);
+int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr);
int regdb_fetch_values( const char* key, REGVAL_CTR *values );
bool regdb_store_values( const char *key, REGVAL_CTR *values );
-bool regdb_subkeys_need_update(REGSUBKEY_CTR *subkeys);
+bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys);
bool regdb_values_need_update(REGVAL_CTR *values);
/* The following definitions come from registry/reg_backend_hkpt_params.c */
@@ -5086,9 +5063,11 @@ void reghook_dump_cache( int debuglevel );
/* The following definitions come from registry/reg_dispatcher.c */
-bool store_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys );
+bool store_reg_keys( REGISTRY_KEY *key, struct regsubkey_ctr *subkeys );
bool store_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val );
-int fetch_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkey_ctr );
+WERROR create_reg_subkey(REGISTRY_KEY *key, const char *subkey);
+WERROR delete_reg_subkey(REGISTRY_KEY *key, const char *subkey);
+int fetch_reg_keys( REGISTRY_KEY *key, struct regsubkey_ctr *subkey_ctr );
int fetch_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val );
bool regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
const struct nt_user_token *token );
@@ -5096,7 +5075,7 @@ WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key,
struct security_descriptor **psecdesc);
WERROR regkey_set_secdesc(REGISTRY_KEY *key,
struct security_descriptor *psecdesc);
-bool reg_subkeys_need_update(REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys);
+bool reg_subkeys_need_update(REGISTRY_KEY *key, struct regsubkey_ctr *subkeys);
bool reg_values_need_update(REGISTRY_KEY *key, REGVAL_CTR *values);
/* The following definitions come from registry/reg_eventlog.c */
@@ -5122,11 +5101,14 @@ WERROR registry_init_smbconf(const char *keyname);
/* The following definitions come from registry/reg_objects.c */
-WERROR regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname );
-int regsubkey_ctr_delkey( REGSUBKEY_CTR *ctr, const char *keyname );
-bool regsubkey_ctr_key_exists( REGSUBKEY_CTR *ctr, const char *keyname );
-int regsubkey_ctr_numkeys( REGSUBKEY_CTR *ctr );
-char* regsubkey_ctr_specific_key( REGSUBKEY_CTR *ctr, uint32 key_index );
+WERROR regsubkey_ctr_init(TALLOC_CTX *mem_ctx, struct regsubkey_ctr **ctr);
+WERROR regsubkey_ctr_set_seqnum(struct regsubkey_ctr *ctr, int seqnum);
+int regsubkey_ctr_get_seqnum(struct regsubkey_ctr *ctr);
+WERROR regsubkey_ctr_addkey( struct regsubkey_ctr *ctr, const char *keyname );
+WERROR regsubkey_ctr_delkey( struct regsubkey_ctr *ctr, const char *keyname );
+bool regsubkey_ctr_key_exists( struct regsubkey_ctr *ctr, const char *keyname );
+int regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr );
+char* regsubkey_ctr_specific_key( struct regsubkey_ctr *ctr, uint32 key_index );
int regval_ctr_numvals( REGVAL_CTR *ctr );
REGISTRY_VALUE* dup_registry_value( REGISTRY_VALUE *val );
void free_registry_value( REGISTRY_VALUE *val );
@@ -5476,33 +5458,38 @@ WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
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_getjob(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t job_id,
+ uint32_t level,
+ uint32_t offered,
+ union spoolss_JobInfo *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_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_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);
WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, uint32 level, uint32 firstjob,
uint32 num_jobs, uint32 *returned, JOB_INFO_CTR *ctr);
-WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 jobid, uint32 level,
- JOB_INFO_CTR *ctr);
WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *valuename,
REGISTRY_VALUE *value);
@@ -5804,17 +5791,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);
@@ -5884,19 +5861,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,
@@ -5916,17 +5880,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 make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src);
-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);
@@ -5966,9 +5920,6 @@ bool spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX
bool make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
uint32 level, RPC_BUFFER *buffer,
uint32 offered);
-bool make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle,
- uint32 jobid, uint32 level, RPC_BUFFER *buffer,
- uint32 offered);
/* The following definitions come from rpc_server/srv_eventlog_lib.c */
@@ -6540,6 +6491,7 @@ files_struct *file_find_fsp(files_struct *orig_fsp);
files_struct *file_find_di_first(struct file_id id);
files_struct *file_find_di_next(files_struct *start_fsp);
files_struct *file_find_print(void);
+bool file_find_subpath(files_struct *dir_fsp);
void file_sync_all(connection_struct *conn);
void file_free(struct smb_request *req, files_struct *fsp);
files_struct *file_fnum(uint16 fnum);
diff --git a/source3/include/reg_db.h b/source3/include/reg_db.h
index 92448ae543..5cafa0a5fb 100644
--- a/source3/include/reg_db.h
+++ b/source3/include/reg_db.h
@@ -26,5 +26,6 @@
#define REG_VALUE_PREFIX "SAMBA_REGVAL"
#define REG_SECDESC_PREFIX "SAMBA_SECDESC"
+#define REG_SORTED_SUBKEYS_PREFIX "SAMBA_SORTED_SUBKEYS"
#endif /* _REG_DB_H */
diff --git a/source3/include/reg_objects.h b/source3/include/reg_objects.h
index d9159dd464..a03ac1bff4 100644
--- a/source3/include/reg_objects.h
+++ b/source3/include/reg_objects.h
@@ -66,11 +66,7 @@ typedef struct {
/* container for registry subkey names */
-typedef struct {
- uint32 num_subkeys;
- char **subkeys;
- int seqnum;
-} REGSUBKEY_CTR;
+struct regsubkey_ctr;
/*
*
@@ -132,9 +128,11 @@ typedef struct {
typedef struct {
/* functions for enumerating subkeys and values */
- int (*fetch_subkeys)( const char *key, REGSUBKEY_CTR *subkeys);
+ int (*fetch_subkeys)( const char *key, struct regsubkey_ctr *subkeys);
int (*fetch_values) ( const char *key, REGVAL_CTR *val );
- bool (*store_subkeys)( const char *key, REGSUBKEY_CTR *subkeys );
+ bool (*store_subkeys)( const char *key, struct regsubkey_ctr *subkeys );
+ WERROR (*create_subkey)(const char *key, const char *subkey);
+ WERROR (*delete_subkey)(const char *key, const char *subkey);
bool (*store_values)( const char *key, REGVAL_CTR *val );
bool (*reg_access_check)( const char *keyname, uint32 requested,
uint32 *granted,
@@ -143,7 +141,7 @@ typedef struct {
struct security_descriptor **psecdesc);
WERROR (*set_secdesc)(const char *key,
struct security_descriptor *sec_desc);
- bool (*subkeys_need_update)(REGSUBKEY_CTR *subkeys);
+ bool (*subkeys_need_update)(struct regsubkey_ctr *subkeys);
bool (*values_need_update)(REGVAL_CTR *values);
} REGISTRY_OPS;
@@ -164,7 +162,7 @@ typedef struct _RegistryKey {
struct registry_key {
REGISTRY_KEY *key;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
REGVAL_CTR *values;
struct nt_user_token *token;
};
diff --git a/source3/include/regfio.h b/source3/include/regfio.h
index 63516a358d..0e957d51e5 100644
--- a/source3/include/regfio.h
+++ b/source3/include/regfio.h
@@ -214,7 +214,7 @@ int regfio_close( REGF_FILE *r );
REGF_NK_REC* regfio_rootkey( REGF_FILE *file );
REGF_NK_REC* regfio_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk );
REGF_NK_REC* regfio_write_key ( REGF_FILE *file, const char *name,
- REGVAL_CTR *values, REGSUBKEY_CTR *subkeys,
+ REGVAL_CTR *values, struct regsubkey_ctr *subkeys,
SEC_DESC *sec_desc, REGF_NK_REC *parent );
diff --git a/source3/include/rpc_secdes.h b/source3/include/rpc_secdes.h
index a1cfad9003..c74d621f35 100644
--- a/source3/include/rpc_secdes.h
+++ b/source3/include/rpc_secdes.h
@@ -39,9 +39,6 @@
#define SEC_RIGHTS_RESET_PASSWD SEC_RIGHTS_EXTENDED
#define SEC_RIGHTS_FULL_CTRL 0xf01ff
-#define SEC_ACE_OBJECT_PRESENT 0x00000001 /* thanks for Jim McDonough <jmcd@us.ibm.com> */
-#define SEC_ACE_OBJECT_INHERITED_PRESENT 0x00000002
-
/*
* New Windows 2000 bits.
*/
@@ -72,7 +69,6 @@
/* SEC_ACE */
typedef struct security_ace SEC_ACE;
-#define SEC_ACE_HEADER_SIZE (2 * sizeof(uint8) + sizeof(uint16) + sizeof(uint32))
#ifndef ACL_REVISION
#define ACL_REVISION 0x3
@@ -81,7 +77,6 @@ typedef struct security_ace SEC_ACE;
#ifndef _SEC_ACL
/* SEC_ACL */
typedef struct security_acl SEC_ACL;
-#define SEC_ACL_HEADER_SIZE (2 * sizeof(uint16) + sizeof(uint32))
#define _SEC_ACL
#endif
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 48609a3cd6..2b4a036ce8 100644
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -121,41 +121,10 @@
#define SPL_XCV_MONITOR_LOCALMON ",XcvMonitor Local Port"
#define SPL_XCV_MONITOR_TCPMON ",XcvMonitor Standard TCP/IP Port"
-
-#define PRINTER_STATUS_OK 0x00000000
-#define JOB_ACCESS_READ 0x00000020
-
-/* JOB status codes. */
-
-#define JOB_STATUS_QUEUED 0x0000
-#define JOB_STATUS_PAUSED 0x0001
-#define JOB_STATUS_ERROR 0x0002
-#define JOB_STATUS_DELETING 0x0004
-#define JOB_STATUS_SPOOLING 0x0008
-#define JOB_STATUS_PRINTING 0x0010
-#define JOB_STATUS_OFFLINE 0x0020
-#define JOB_STATUS_PAPEROUT 0x0040
-#define JOB_STATUS_PRINTED 0x0080
-#define JOB_STATUS_DELETED 0x0100
-#define JOB_STATUS_BLOCKED 0x0200
-#define JOB_STATUS_USER_INTERVENTION 0x0400
-
/* Notify field types */
-#define NOTIFY_ONE_VALUE 1 /* Notify data is stored in value1 */
-#define NOTIFY_TWO_VALUE 2 /* Notify data is stored in value2 */
-#define NOTIFY_POINTER 3 /* Data is a pointer to a buffer */
-#define NOTIFY_STRING 4 /* Data is a pointer to a buffer w/length */
-#define NOTIFY_SECDESC 5 /* Data is a security descriptor */
-
#define PRINTER_NOTIFY_TYPE 0x00
#define JOB_NOTIFY_TYPE 0x01
-#define PRINT_TABLE_END 0xFF
-
-#define MAX_PRINTER_NOTIFY 26
-#define MAX_JOB_NOTIFY 24
-
-#define MAX_NOTIFY_TYPE_FOR_NOW 26
#define PRINTER_NOTIFY_SERVER_NAME 0x00
#define PRINTER_NOTIFY_PRINTER_NAME 0x01
@@ -261,25 +230,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
*/
@@ -343,19 +293,6 @@ PRINTER_DEFAULT;
/********************************************/
-typedef struct s_header_type
-{
- uint32 type;
- union
- {
- uint32 value;
- UNISTR string;
- }
- data;
-}
-HEADER_TYPE;
-
-
typedef struct spool_q_getprinterdata
{
POLICY_HND handle;
@@ -488,11 +425,6 @@ typedef struct printer_info_6
}
PRINTER_INFO_6;
-#define SPOOL_DS_PUBLISH 1
-#define SPOOL_DS_UPDATE 2
-#define SPOOL_DS_UNPUBLISH 4
-#define SPOOL_DS_PENDING 0x80000000
-
typedef struct printer_info_7
{
UNISTR guid; /* text form of printer guid */
@@ -872,115 +804,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_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_enumprintprocessors
{
uint32 name_ptr;
diff --git a/source3/include/smb.h b/source3/include/smb.h
index f02088731d..a0140fe081 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -149,8 +149,6 @@ typedef union unid_t {
* smb_ucs2_t is *always* in little endian format.
*/
-typedef uint16 smb_ucs2_t;
-
#ifdef WORDS_BIGENDIAN
#define UCS2_SHIFT 8
#else
@@ -167,10 +165,6 @@ typedef uint16 smb_ucs2_t;
#define COPY_UCS2_CHAR(dest,src) (((unsigned char *)(dest))[0] = ((unsigned char *)(src))[0],\
((unsigned char *)(dest))[1] = ((unsigned char *)(src))[1], (dest))
-/* Large data type for manipulating uint32 unicode codepoints */
-typedef uint32 codepoint_t;
-#define INVALID_CODEPOINT ((codepoint_t)-1)
-
/* pipe string names */
#define PIPE_LANMAN "\\PIPE\\LANMAN"
@@ -579,6 +573,12 @@ typedef struct connection_struct {
*/
struct auth_serversupplied_info *server_info;
+ /*
+ * If the "force group" parameter is set, this is the primary gid that
+ * may be used in the users token, depending on the vuid using this tid.
+ */
+ gid_t force_group_gid;
+
char client_address[INET6_ADDRSTRLEN]; /* String version of client IP address. */
uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
@@ -1831,18 +1831,6 @@ struct unix_error_map {
#define SAFE_NETBIOS_CHARS ". -_"
-/* generic iconv conversion structure */
-typedef struct _smb_iconv_t {
- size_t (*direct)(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- size_t (*pull)(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- size_t (*push)(void *cd, const char **inbuf, size_t *inbytesleft,
- char **outbuf, size_t *outbytesleft);
- void *cd_direct, *cd_pull, *cd_push;
- char *from_name, *to_name;
-} *smb_iconv_t;
-
/* The maximum length of a trust account password.
Used when we randomly create it, 15 char passwords
exceed NT4's max password length */
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/charcnv.c b/source3/lib/charcnv.c
index c3b345142f..81cb9a5094 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -763,7 +763,7 @@ bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
* converted.
*/
bool convert_string_talloc(TALLOC_CTX *ctx, charset_t from, charset_t to,
- void const *src, size_t srclen, void *dst,
+ void const *src, size_t srclen, void **dst,
size_t *converted_size, bool allow_bad_conv)
{
void **dest = (void **)dst;
diff --git a/source3/lib/dbwrap.c b/source3/lib/dbwrap.c
index a57b7c97a5..5e7ce6099f 100644
--- a/source3/lib/dbwrap.c
+++ b/source3/lib/dbwrap.c
@@ -42,6 +42,29 @@ static int dbwrap_fallback_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
return 0;
}
+/*
+ * Fall back using fetch if no genuine parse operation is provided
+ */
+
+static int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
+ int (*parser)(TDB_DATA key,
+ TDB_DATA data,
+ void *private_data),
+ void *private_data)
+{
+ TDB_DATA data;
+ int res;
+
+ res = db->fetch(db, talloc_tos(), key, &data);
+ if (res != 0) {
+ return res;
+ }
+
+ res = parser(key, data, private_data);
+ TALLOC_FREE(data.dptr);
+ return res;
+}
+
/**
* open a database
*/
@@ -101,6 +124,9 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
if ((result != NULL) && (result->fetch == NULL)) {
result->fetch = dbwrap_fallback_fetch;
}
+ if ((result != NULL) && (result->parse_record == NULL)) {
+ result->parse_record = dbwrap_fallback_parse_record;
+ }
return result;
}
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index 03667ff355..4a5bf6d81a 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -121,9 +121,9 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
{
struct ctdb_rec_data *r;
size_t m_size, r_size;
- struct ctdb_marshall_buffer *m2;
+ struct ctdb_marshall_buffer *m2 = NULL;
- r = db_ctdb_marshall_record(mem_ctx, reqid, key, header, data);
+ r = db_ctdb_marshall_record(talloc_tos(), reqid, key, header, data);
if (r == NULL) {
talloc_free(m);
return NULL;
@@ -133,7 +133,7 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
m = (struct ctdb_marshall_buffer *)talloc_zero_size(
mem_ctx, offsetof(struct ctdb_marshall_buffer, data));
if (m == NULL) {
- return NULL;
+ goto done;
}
m->db_id = db_id;
}
@@ -145,15 +145,15 @@ static struct ctdb_marshall_buffer *db_ctdb_marshall_add(TALLOC_CTX *mem_ctx,
mem_ctx, m, m_size + r_size);
if (m2 == NULL) {
talloc_free(m);
- return NULL;
+ goto done;
}
memcpy(m_size + (uint8_t *)m2, r, r_size);
- talloc_free(r);
-
m2->count++;
+done:
+ talloc_free(r);
return m2;
}
diff --git a/source3/lib/dbwrap_rbt.c b/source3/lib/dbwrap_rbt.c
index 6e09627223..cf4faa25b9 100644
--- a/source3/lib/dbwrap_rbt.c
+++ b/source3/lib/dbwrap_rbt.c
@@ -131,12 +131,12 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag)
*/
}
- node = (struct db_rbt_node *)SMB_MALLOC(
+ node = (struct db_rbt_node *)talloc_size(rec_priv->db_ctx,
offsetof(struct db_rbt_node, data) + rec->key.dsize
+ data.dsize);
if (node == NULL) {
- SAFE_FREE(rec_priv->node);
+ TALLOC_FREE(rec_priv->node);
return NT_STATUS_NO_MEMORY;
}
@@ -148,7 +148,7 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag)
db_rbt_parse_node(node, &this_key, &this_val);
memcpy(this_key.dptr, rec->key.dptr, node->keysize);
- SAFE_FREE(rec_priv->node);
+ TALLOC_FREE(rec_priv->node);
memcpy(this_val.dptr, data.dptr, node->valuesize);
@@ -194,7 +194,7 @@ static NTSTATUS db_rbt_delete(struct db_record *rec)
}
rb_erase(&rec_priv->node->rb_node, &rec_priv->db_ctx->tree);
- SAFE_FREE(rec_priv->node);
+ TALLOC_FREE(rec_priv->node);
return NT_STATUS_OK;
}
diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c
index b5eb1881d4..c71e073b41 100644
--- a/source3/lib/dbwrap_tdb.c
+++ b/source3/lib/dbwrap_tdb.c
@@ -176,6 +176,17 @@ static int db_tdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
return 0;
}
+static int db_tdb_parse(struct db_context *db, TDB_DATA key,
+ int (*parser)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data)
+{
+ struct db_tdb_ctx *ctx = talloc_get_type_abort(
+ db->private_data, struct db_tdb_ctx);
+
+ return tdb_parse_record(ctx->wtdb->tdb, key, parser, private_data);
+}
+
static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag)
{
struct db_tdb_ctx *ctx = talloc_get_type_abort(rec->private_data,
@@ -351,6 +362,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
result->fetch = db_tdb_fetch;
result->traverse = db_tdb_traverse;
result->traverse_read = db_tdb_traverse_read;
+ result->parse_record = db_tdb_parse;
result->get_seqnum = db_tdb_get_seqnum;
result->get_flags = db_tdb_get_flags;
result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);
diff --git a/source3/lib/display_sec.c b/source3/lib/display_sec.c
index 636639c11d..fe1ae77edd 100644
--- a/source3/lib/display_sec.c
+++ b/source3/lib/display_sec.c
@@ -155,13 +155,13 @@ void display_sec_ace_flags(uint8_t flags)
****************************************************************************/
static void disp_sec_ace_object(struct security_ace_object *object)
{
- if (object->flags & SEC_ACE_OBJECT_PRESENT) {
- printf("Object type: SEC_ACE_OBJECT_PRESENT\n");
+ if (object->flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
+ printf("Object type: SEC_ACE_OBJECT_TYPE_PRESENT\n");
printf("Object GUID: %s\n", GUID_string(talloc_tos(),
&object->type.type));
}
- if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) {
- printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n");
+ if (object->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
+ printf("Object type: SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT\n");
printf("Object GUID: %s\n", GUID_string(talloc_tos(),
&object->inherited_type.inherited_type));
}
diff --git a/source3/lib/events.c b/source3/lib/events.c
index 44b4562757..f875e0dc0c 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -282,12 +282,13 @@ static void s3_event_debug(void *context, enum tevent_debug_level level,
samba_level = 2;
break;
case TEVENT_DEBUG_TRACE:
- samba_level = 5;
+ samba_level = 10;
break;
};
- vasprintf(&s, fmt, ap);
- if (!s) return;
+ if (vasprintf(&s, fmt, ap) == -1) {
+ return;
+ }
DEBUG(samba_level, ("s3_event: %s", s));
free(s);
}
diff --git a/source3/lib/fault.c b/source3/lib/fault.c
index 8c4a45bbc9..efd1dddfd4 100644
--- a/source3/lib/fault.c
+++ b/source3/lib/fault.c
@@ -2,6 +2,7 @@
Unix SMB/CIFS implementation.
Critical Fault handling
Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Tim Prouty 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
@@ -87,6 +88,128 @@ void fault_setup(void (*fn)(void *))
#endif
}
+/**
+ * Build up the default corepath as "<logbase>/cores/<progname>"
+ */
+static char *get_default_corepath(const char *logbase, const char *progname)
+{
+ char *tmp_corepath;
+
+ /* Setup core dir in logbase. */
+ tmp_corepath = talloc_asprintf(NULL, "%s/cores", logbase);
+ if (!tmp_corepath)
+ return NULL;
+
+ if ((mkdir(tmp_corepath, 0700) == -1) && errno != EEXIST)
+ goto err_out;
+
+ if (chmod(tmp_corepath, 0700) == -1)
+ goto err_out;
+
+ talloc_free(tmp_corepath);
+
+ /* Setup progname-specific core subdir */
+ tmp_corepath = talloc_asprintf(NULL, "%s/cores/%s", logbase, progname);
+ if (!tmp_corepath)
+ return NULL;
+
+ if (mkdir(tmp_corepath, 0700) == -1 && errno != EEXIST)
+ goto err_out;
+
+ if (chown(tmp_corepath, getuid(), getgid()) == -1)
+ goto err_out;
+
+ if (chmod(tmp_corepath, 0700) == -1)
+ goto err_out;
+
+ return tmp_corepath;
+
+ err_out:
+ talloc_free(tmp_corepath);
+ return NULL;
+}
+
+/**
+ * Get the FreeBSD corepath.
+ *
+ * On FreeBSD the current working directory is ignored when creating a core
+ * file. Instead the core directory is controlled via sysctl. This consults
+ * the value of "kern.corefile" so the correct corepath can be printed out
+ * before dump_core() calls abort.
+ */
+#if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
+static char *get_freebsd_corepath(void)
+{
+ char *tmp_corepath = NULL;
+ char *end = NULL;
+ size_t len = 128;
+ int ret;
+
+ /* Loop with increasing sizes so we don't allocate too much. */
+ do {
+ if (len > 1024) {
+ goto err_out;
+ }
+
+ tmp_corepath = (char *)talloc_realloc(NULL, tmp_corepath,
+ char, len);
+ if (!tmp_corepath) {
+ return NULL;
+ }
+
+ ret = sysctlbyname("kern.corefile", tmp_corepath, &len, NULL,
+ 0);
+ if (ret == -1) {
+ if (errno != ENOMEM) {
+ DEBUG(0, ("sysctlbyname failed getting "
+ "kern.corefile %s\n",
+ strerror(errno)));
+ goto err_out;
+ }
+
+ /* Not a large enough array, try a bigger one. */
+ len = len << 1;
+ }
+ } while (ret == -1);
+
+ /* Strip off the common filename expansion */
+ if ((end = strrchr_m(tmp_corepath, '/'))) {
+ *end = '\0';
+ }
+
+ return tmp_corepath;
+
+ err_out:
+ if (tmp_corepath) {
+ talloc_free(tmp_corepath);
+ }
+ return NULL;
+}
+#endif
+
+/**
+ * Try getting system-specific corepath if one exists.
+ *
+ * If the system doesn't define a corepath, then the default is used.
+ */
+static char *get_corepath(const char *logbase, const char *progname)
+{
+ char *tmp_corepath = NULL;
+
+ /* @todo: Add support for the linux corepath. */
+#if (defined(FREEBSD) && defined(HAVE_SYSCTLBYNAME))
+ tmp_corepath = get_freebsd_corepath();
+#endif
+
+ /* If this has been set correctly, we're done. */
+ if (tmp_corepath) {
+ return tmp_corepath;
+ }
+
+ /* Fall back to the default. */
+ return get_default_corepath(logbase, progname);
+}
+
/*******************************************************************
make all the preparations to safely dump a core file
********************************************************************/
@@ -104,7 +227,7 @@ void dump_core_setup(const char *progname)
*end = '\0';
}
} else {
- /* We will end up here is the log file is given on the command
+ /* We will end up here if the log file is given on the command
* line by the -l option but the "log file" option is not set
* in smb.conf.
*/
@@ -115,49 +238,13 @@ void dump_core_setup(const char *progname)
SMB_ASSERT(progname != NULL);
- if (asprintf(&corepath, "%s/cores", logbase) < 0) {
- SAFE_FREE(logbase);
- return;
- }
- if (mkdir(corepath,0700) == -1) {
- if (errno != EEXIST) {
- SAFE_FREE(corepath);
- SAFE_FREE(logbase);
- return;
- }
- }
- if (chmod(corepath,0700) == -1) {
- SAFE_FREE(corepath);
- SAFE_FREE(logbase);
- return;
- }
-
- SAFE_FREE(corepath);
- if (asprintf(&corepath, "%s/cores/%s",
- logbase, progname) < 0) {
- SAFE_FREE(logbase);
- return;
- }
- if (mkdir(corepath,0700) == -1) {
- if (errno != EEXIST) {
- SAFE_FREE(corepath);
- SAFE_FREE(logbase);
- return;
- }
- }
-
- if (chown(corepath,getuid(),getgid()) == -1) {
- SAFE_FREE(corepath);
- SAFE_FREE(logbase);
- return;
- }
- if (chmod(corepath,0700) == -1) {
- SAFE_FREE(corepath);
- SAFE_FREE(logbase);
- return;
+ corepath = get_corepath(logbase, progname);
+ if (!corepath) {
+ DEBUG(0, ("Unable to setup corepath for %s: %s\n", progname,
+ strerror(errno)));
+ goto out;
}
- SAFE_FREE(logbase);
#ifdef HAVE_GETRLIMIT
#ifdef RLIMIT_CORE
@@ -184,6 +271,8 @@ void dump_core_setup(const char *progname)
/* FIXME: if we have a core-plus-pid facility, configurably set
* this up here.
*/
+ out:
+ SAFE_FREE(logbase);
}
void dump_core(void)
diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c
index 3ceb637b8e..44500542f2 100644
--- a/source3/lib/iconv.c
+++ b/source3/lib/iconv.c
@@ -207,12 +207,12 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode)
from = charsets;
to = charsets;
- ret = SMB_MALLOC_P(struct _smb_iconv_t);
+ ret = SMB_MALLOC_P(struct smb_iconv_s);
if (!ret) {
errno = ENOMEM;
return (smb_iconv_t)-1;
}
- memset(ret, 0, sizeof(struct _smb_iconv_t));
+ memset(ret, 0, sizeof(struct smb_iconv_s));
ret->from_name = SMB_STRDUP(fromcode);
ret->to_name = SMB_STRDUP(tocode);
diff --git a/source3/lib/smbconf/smbconf_reg.c b/source3/lib/smbconf/smbconf_reg.c
index e36fa8a2a1..ae6a41151d 100644
--- a/source3/lib/smbconf/smbconf_reg.c
+++ b/source3/lib/smbconf/smbconf_reg.c
@@ -23,7 +23,7 @@
#define INCLUDES_VALNAME "includes"
struct reg_private_data {
- NT_USER_TOKEN *token;
+ struct registry_key *base_key;
bool open; /* did _we_ open the registry? */
};
@@ -72,54 +72,6 @@ static bool smbconf_reg_valname_valid(const char *valname)
}
/**
- * Open a registry key specified by "path"
- */
-static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
- struct smbconf_ctx *ctx,
- const char *path,
- uint32 desired_access,
- struct registry_key **key)
-{
- WERROR werr = WERR_OK;
-
- if (ctx == NULL) {
- DEBUG(1, ("Error: configuration is not open!\n"));
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
- if (rpd(ctx)->token == NULL) {
- DEBUG(1, ("Error: token missing from smbconf_ctx. "
- "was smbconf_init() called?\n"));
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
- werr = ctx->ops->open_conf(ctx);
- if (!W_ERROR_IS_OK(werr)) {
- DEBUG(1, ("Error opening the registry.\n"));
- goto done;
- }
-
- if (path == NULL) {
- DEBUG(1, ("Error: NULL path string given\n"));
- werr = WERR_INVALID_PARAM;
- goto done;
- }
-
- werr = reg_open_path(mem_ctx, path, desired_access, rpd(ctx)->token,
- key);
-
- if (!W_ERROR_IS_OK(werr)) {
- DEBUG(5, ("Error opening registry path '%s': %s\n",
- path, win_errstr(werr)));
- }
-
-done:
- return werr;
-}
-
-/**
* Open a subkey of the base key (i.e a service)
*/
static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
@@ -128,40 +80,23 @@ static WERROR smbconf_reg_open_service_key(TALLOC_CTX *mem_ctx,
uint32 desired_access,
struct registry_key **key)
{
- WERROR werr = WERR_OK;
- char *path = NULL;
+ WERROR werr;
if (servicename == NULL) {
- path = talloc_strdup(mem_ctx, ctx->path);
- } else {
- path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path,
- servicename);
- }
- if (path == NULL) {
- werr = WERR_NOMEM;
- goto done;
+ *key = rpd(ctx)->base_key;
+ return WERR_OK;
}
+ werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
+ desired_access, key);
- werr = smbconf_reg_open_path(mem_ctx, ctx, path, desired_access, key);
+ if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
+ werr = WERR_NO_SUCH_SERVICE;
+ }
-done:
- talloc_free(path);
return werr;
}
/**
- * open the base key
- */
-static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx,
- struct smbconf_ctx *ctx,
- uint32 desired_access,
- struct registry_key **key)
-{
- return smbconf_reg_open_path(mem_ctx, ctx, ctx->path, desired_access,
- key);
-}
-
-/**
* check if a value exists in a given registry key
*/
static bool smbconf_value_exists(struct registry_key *key, const char *param)
@@ -189,7 +124,6 @@ static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
struct registry_key **newkey)
{
WERROR werr = WERR_OK;
- struct registry_key *create_parent = NULL;
TALLOC_CTX *create_ctx;
enum winreg_CreateAction action = REG_ACTION_NONE;
@@ -198,13 +132,7 @@ static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
* and will be destroyed when leaving this function... */
create_ctx = talloc_stackframe();
- werr = smbconf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE,
- &create_parent);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
-
- werr = reg_createkey(mem_ctx, create_parent, subkeyname,
+ werr = reg_createkey(mem_ctx, rpd(ctx)->base_key, subkeyname,
REG_KEY_WRITE, newkey, &action);
if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
DEBUG(10, ("Key '%s' already exists.\n", subkeyname));
@@ -215,7 +143,6 @@ static WERROR smbconf_reg_create_service_key(TALLOC_CTX *mem_ctx,
subkeyname, win_errstr(werr)));
}
-done:
talloc_free(create_ctx);
return werr;
}
@@ -608,6 +535,7 @@ done:
static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
{
WERROR werr = WERR_OK;
+ struct nt_user_token *token;
if (path == NULL) {
path = KEY_SMBCONF;
@@ -620,8 +548,7 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
- werr = ntstatus_to_werror(registry_create_admin_token(ctx,
- &(rpd(ctx)->token)));
+ werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
if (!W_ERROR_IS_OK(werr)) {
DEBUG(1, ("Error creating admin token\n"));
goto done;
@@ -633,6 +560,19 @@ static WERROR smbconf_reg_init(struct smbconf_ctx *ctx, const char *path)
goto done;
}
+ werr = ctx->ops->open_conf(ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("Error opening the registry.\n"));
+ goto done;
+ }
+
+ werr = reg_open_path(ctx, ctx->path,
+ SEC_RIGHTS_ENUM_SUBKEYS | REG_KEY_WRITE,
+ token, &rpd(ctx)->base_key);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
done:
return werr;
}
@@ -723,6 +663,13 @@ static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
struct registry_key *new_key = NULL;
TALLOC_CTX* mem_ctx = talloc_stackframe();
enum winreg_CreateAction action;
+ struct nt_user_token *token;
+
+ werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("Error creating admin token\n"));
+ goto done;
+ }
path = talloc_strdup(mem_ctx, ctx->path);
if (path == NULL) {
@@ -731,8 +678,8 @@ static WERROR smbconf_reg_drop(struct smbconf_ctx *ctx)
}
p = strrchr(path, '\\');
*p = '\0';
- werr = smbconf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE,
- &parent_key);
+ werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token,
+ &parent_key);
if (!W_ERROR_IS_OK(werr)) {
goto done;
@@ -765,7 +712,6 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
uint32_t added_count = 0;
TALLOC_CTX *tmp_ctx = NULL;
WERROR werr = WERR_OK;
- struct registry_key *key = NULL;
char *subkey_name = NULL;
char **tmp_share_names = NULL;
@@ -777,13 +723,8 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
tmp_ctx = talloc_stackframe();
/* if there are values in the base key, return NULL as share name */
- werr = smbconf_reg_open_base_key(tmp_ctx, ctx,
- SEC_RIGHTS_ENUM_SUBKEYS, &key);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
- if (smbconf_reg_key_has_values(key)) {
+ if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) {
werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
0, NULL);
if (!W_ERROR_IS_OK(werr)) {
@@ -803,7 +744,8 @@ static WERROR smbconf_reg_get_share_names(struct smbconf_ctx *ctx,
}
for (count = 0;
- werr = reg_enumkey(tmp_ctx, key, count, &subkey_name, NULL),
+ werr = reg_enumkey(tmp_ctx, rpd(ctx)->base_key, count,
+ &subkey_name, NULL),
W_ERROR_IS_OK(werr);
count++)
{
@@ -865,18 +807,16 @@ static WERROR smbconf_reg_create_share(struct smbconf_ctx *ctx,
const char *servicename)
{
WERROR werr;
- TALLOC_CTX *mem_ctx = talloc_stackframe();
struct registry_key *key = NULL;
if (servicename == NULL) {
- werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE,
- &key);
- } else {
- werr = smbconf_reg_create_service_key(mem_ctx, ctx,
- servicename, &key);
+ return WERR_OK;
}
- talloc_free(mem_ctx);
+ werr = smbconf_reg_create_service_key(talloc_tos(), ctx,
+ servicename, &key);
+
+ talloc_free(key);
return werr;
}
@@ -934,21 +874,15 @@ static WERROR smbconf_reg_delete_share(struct smbconf_ctx *ctx,
const char *servicename)
{
WERROR werr = WERR_OK;
- struct registry_key *key = NULL;
TALLOC_CTX *mem_ctx = talloc_stackframe();
- werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
-
if (servicename != NULL) {
- werr = reg_deletekey_recursive(key, key, servicename);
+ werr = reg_deletekey_recursive(mem_ctx, rpd(ctx)->base_key,
+ servicename);
} else {
- werr = smbconf_reg_delete_values(key);
+ werr = smbconf_reg_delete_values(rpd(ctx)->base_key);
}
-done:
talloc_free(mem_ctx);
return werr;
}
@@ -1137,6 +1071,21 @@ done:
return werr;
}
+static WERROR smbconf_reg_transaction_start(struct smbconf_ctx *ctx)
+{
+ return regdb_transaction_start();
+}
+
+static WERROR smbconf_reg_transaction_commit(struct smbconf_ctx *ctx)
+{
+ return regdb_transaction_commit();
+}
+
+static WERROR smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx)
+{
+ return regdb_transaction_cancel();
+}
+
struct smbconf_ops smbconf_ops_reg = {
.init = smbconf_reg_init,
.shutdown = smbconf_reg_shutdown,
@@ -1157,6 +1106,9 @@ struct smbconf_ops smbconf_ops_reg = {
.get_includes = smbconf_reg_get_includes,
.set_includes = smbconf_reg_set_includes,
.delete_includes = smbconf_reg_delete_includes,
+ .transaction_start = smbconf_reg_transaction_start,
+ .transaction_commit = smbconf_reg_transaction_commit,
+ .transaction_cancel = smbconf_reg_transaction_cancel,
};
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 89f7be8e6c..ec794ca74e 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -899,13 +899,6 @@ bool reinit_after_fork(struct messaging_context *msg_ctx,
* numbers as each other */
set_need_random_reseed();
-#ifdef WITH_MADVISE_PROTECTED
- /* Protect parent process from being killed by kernel when system
- * memory is low. Child processes can still be killed */
- if(!parent_longlived)
- madvise(NULL,0,MADV_PROTECT);
-#endif
-
/* tdb needs special fork handling */
if (tdb_reopen_all(parent_longlived ? 1 : 0) == -1) {
DEBUG(0,("tdb_reopen_all failed.\n"));
diff --git a/source3/lib/util_nttoken.c b/source3/lib/util_nttoken.c
index 774ef498b7..76e7402422 100644
--- a/source3/lib/util_nttoken.c
+++ b/source3/lib/util_nttoken.c
@@ -115,3 +115,19 @@ NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
+
+/*******************************************************************
+ Check if this ACE has a SID in common with the token.
+********************************************************************/
+
+bool token_sid_in_ace(const NT_USER_TOKEN *token, const struct security_ace *ace)
+{
+ size_t i;
+
+ for (i = 0; i < token->num_sids; i++) {
+ if (sid_equal(&ace->trustee, &token->user_sids[i]))
+ return true;
+ }
+
+ return false;
+}
diff --git a/source3/lib/util_reg_api.c b/source3/lib/util_reg_api.c
index 8f28e9c282..9313193f10 100644
--- a/source3/lib/util_reg_api.c
+++ b/source3/lib/util_reg_api.c
@@ -92,7 +92,7 @@ WERROR registry_pull_value(TALLOC_CTX *mem_ctx,
}
if (!convert_string_talloc(value, CH_UTF16LE, CH_UNIX, tmp,
- length+2, &value->v.sz.str,
+ length+2, (void **)&value->v.sz.str,
&value->v.sz.len, False)) {
SAFE_FREE(tmp);
err = WERR_INVALID_PARAM;
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 83e8a9d355..3604be369f 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -967,20 +967,20 @@ static int open_socket_out_state_destructor(struct open_socket_out_state *s)
Create an outgoing socket. timeout is in milliseconds.
**************************************************************************/
-struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- const struct sockaddr_storage *pss,
- uint16_t port,
- int timeout)
+struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ const struct sockaddr_storage *pss,
+ uint16_t port,
+ int timeout)
{
char addr[INET6_ADDRSTRLEN];
- struct async_req *result;
- struct tevent_req *subreq;
+ struct tevent_req *result, *subreq;
struct open_socket_out_state *state;
NTSTATUS status;
- if (!async_req_setup(mem_ctx, &result, &state,
- struct open_socket_out_state)) {
+ result = tevent_req_create(mem_ctx, &state,
+ struct open_socket_out_state);
+ if (result == NULL) {
return NULL;
}
state->ev = ev;
@@ -996,7 +996,8 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
}
talloc_set_destructor(state, open_socket_out_state_destructor);
- if (!async_req_set_timeout(result, ev, timeval_set(0, timeout*1000))) {
+ if (!tevent_req_set_endtime(
+ result, ev, timeval_current_ofs(0, timeout*1000))) {
goto fail;
}
@@ -1030,18 +1031,14 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
|| !tevent_req_set_endtime(
subreq, state->ev,
timeval_current_ofs(0, state->wait_nsec))) {
- status = NT_STATUS_NO_MEMORY;
- goto post_status;
+ goto fail;
}
- subreq->async.fn = open_socket_out_connected;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, open_socket_out_connected, result);
return result;
post_status:
- if (!async_post_ntstatus(result, ev, status)) {
- goto fail;
- }
- return result;
+ tevent_req_nterror(result, status);
+ return tevent_req_post(result, ev);
fail:
TALLOC_FREE(result);
return NULL;
@@ -1049,17 +1046,17 @@ struct async_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
static void open_socket_out_connected(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- 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);
+ struct tevent_req *req =
+ tevent_req_callback_data(subreq, struct tevent_req);
+ struct open_socket_out_state *state =
+ tevent_req_data(req, struct open_socket_out_state);
int ret;
int sys_errno;
ret = async_connect_recv(subreq, &sys_errno);
TALLOC_FREE(subreq);
if (ret == 0) {
- async_req_done(req);
+ tevent_req_done(req);
return;
}
@@ -1082,39 +1079,38 @@ static void open_socket_out_connected(struct tevent_req *subreq)
subreq = async_connect_send(state, state->ev, state->fd,
(struct sockaddr *)&state->ss,
state->salen);
- if (async_req_nomem(subreq, req)) {
+ if (tevent_req_nomem(subreq, req)) {
return;
}
if (!tevent_req_set_endtime(
subreq, state->ev,
timeval_current_ofs(0, state->wait_nsec))) {
- async_req_error(req, ENOMEM);
+ tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
- subreq->async.fn = open_socket_out_connected;
- subreq->async.private_data = req;
+ tevent_req_set_callback(subreq, open_socket_out_connected, req);
return;
}
#ifdef EISCONN
if (sys_errno == EISCONN) {
- async_req_done(req);
+ tevent_req_done(req);
return;
}
#endif
/* real error */
- async_req_error(req, sys_errno);
+ tevent_req_nterror(req, map_nt_error_from_unix(sys_errno));
}
-NTSTATUS open_socket_out_recv(struct async_req *req, int *pfd)
+NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd)
{
- struct open_socket_out_state *state = talloc_get_type_abort(
- req->private_data, struct open_socket_out_state);
- int err;
+ struct open_socket_out_state *state =
+ tevent_req_data(req, struct open_socket_out_state);
+ NTSTATUS status;
- if (async_req_is_errno(req, &err)) {
- return map_nt_error_from_unix(err);
+ if (tevent_req_is_nterror(req, &status)) {
+ return status;
}
*pfd = state->fd;
state->fd = -1;
@@ -1126,7 +1122,7 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
{
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
- struct async_req *req;
+ struct tevent_req *req;
NTSTATUS status = NT_STATUS_NO_MEMORY;
ev = event_context_init(frame);
@@ -1138,10 +1134,10 @@ NTSTATUS open_socket_out(const struct sockaddr_storage *pss, uint16_t port,
if (req == NULL) {
goto fail;
}
- while (req->state < ASYNC_REQ_DONE) {
- event_loop_once(ev);
+ if (!tevent_req_poll(req, ev)) {
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto fail;
}
-
status = open_socket_out_recv(req, pfd);
fail:
TALLOC_FREE(frame);
@@ -1157,7 +1153,7 @@ struct open_socket_out_defer_state {
};
static void open_socket_out_defer_waited(struct async_req *subreq);
-static void open_socket_out_defer_connected(struct async_req *subreq);
+static void open_socket_out_defer_connected(struct tevent_req *subreq);
struct async_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
@@ -1204,6 +1200,7 @@ static void open_socket_out_defer_waited(struct async_req *subreq)
subreq->async.priv, struct async_req);
struct open_socket_out_defer_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_defer_state);
+ struct tevent_req *subreq2;
bool ret;
ret = async_wait_recv(subreq);
@@ -1213,19 +1210,18 @@ static void open_socket_out_defer_waited(struct async_req *subreq)
return;
}
- subreq = open_socket_out_send(state, state->ev, &state->ss,
- state->port, state->timeout);
- if (async_req_nomem(subreq, req)) {
+ subreq2 = open_socket_out_send(state, state->ev, &state->ss,
+ state->port, state->timeout);
+ if (async_req_nomem(subreq2, req)) {
return;
}
- subreq->async.fn = open_socket_out_defer_connected;
- subreq->async.priv = req;
+ tevent_req_set_callback(subreq2, open_socket_out_defer_connected, req);
}
-static void open_socket_out_defer_connected(struct async_req *subreq)
+static void open_socket_out_defer_connected(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.priv, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct open_socket_out_defer_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_defer_state);
NTSTATUS status;
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c
index 9358061797..b9ccb83e55 100644
--- a/source3/lib/util_str.c
+++ b/source3/lib/util_str.c
@@ -36,118 +36,6 @@ const char toupper_ascii_fast_table[128] = {
};
/**
- * @file
- * @brief String utilities.
- **/
-
-static bool next_token_internal_talloc(TALLOC_CTX *ctx,
- const char **ptr,
- char **pp_buff,
- const char *sep,
- bool ltrim)
-{
- char *s;
- char *saved_s;
- char *pbuf;
- bool quoted;
- size_t len=1;
-
- *pp_buff = NULL;
- if (!ptr) {
- return(false);
- }
-
- s = (char *)*ptr;
-
- /* default to simple separators */
- if (!sep) {
- sep = " \t\n\r";
- }
-
- /* find the first non sep char, if left-trimming is requested */
- if (ltrim) {
- while (*s && strchr_m(sep,*s)) {
- s++;
- }
- }
-
- /* nothing left? */
- if (!*s) {
- return false;
- }
-
- /* When restarting we need to go from here. */
- saved_s = s;
-
- /* Work out the length needed. */
- for (quoted = false; *s &&
- (quoted || !strchr_m(sep,*s)); s++) {
- if (*s == '\"') {
- quoted = !quoted;
- } else {
- len++;
- }
- }
-
- /* We started with len = 1 so we have space for the nul. */
- *pp_buff = TALLOC_ARRAY(ctx, char, len);
- if (!*pp_buff) {
- return false;
- }
-
- /* copy over the token */
- pbuf = *pp_buff;
- s = saved_s;
- for (quoted = false; *s &&
- (quoted || !strchr_m(sep,*s)); s++) {
- if ( *s == '\"' ) {
- quoted = !quoted;
- } else {
- *pbuf++ = *s;
- }
- }
-
- *ptr = (*s) ? s+1 : s;
- *pbuf = 0;
-
- return true;
-}
-
-#if 0
-/*
- * Get the next token from a string, return false if none found. Handles
- * double-quotes. This version trims leading separator characters before
- * looking for a token.
- */
-bool next_token(const char **ptr, char *buff, const char *sep, size_t bufsize)
-{
- return next_token_internal(ptr, buff, sep, bufsize, true);
-}
-#endif
-
-bool next_token_talloc(TALLOC_CTX *ctx,
- const char **ptr,
- char **pp_buff,
- const char *sep)
-{
- return next_token_internal_talloc(ctx, ptr, pp_buff, sep, true);
-}
-
-/*
- * Get the next token from a string, return false if none found. Handles
- * double-quotes. This version does not trim leading separator characters
- * before looking for a token.
- */
-
-bool next_token_no_ltrim_talloc(TALLOC_CTX *ctx,
- const char **ptr,
- char **pp_buff,
- const char *sep)
-{
- return next_token_internal_talloc(ctx, ptr, pp_buff, sep, false);
-}
-
-/**
* Case insensitive string compararison.
*
* iconv does not directly give us a way to compare strings in
diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c
index a5adf8f108..222b64667c 100644
--- a/source3/lib/wb_reqtrans.c
+++ b/source3/lib/wb_reqtrans.c
@@ -103,8 +103,7 @@ struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
goto nomem;
}
- subreq->async.fn = wb_req_read_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_req_read_done, result);
return result;
nomem:
TALLOC_FREE(result);
@@ -140,8 +139,8 @@ 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 *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct req_read_state *state = talloc_get_type_abort(
req->private_data, struct req_read_state);
int err;
@@ -213,8 +212,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = wb_req_write_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_req_write_done, result);
return result;
fail:
@@ -224,8 +222,8 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
static void wb_req_write_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
int err;
ssize_t ret;
@@ -266,8 +264,7 @@ struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto nomem;
}
- subreq->async.fn = wb_resp_read_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_resp_read_done, result);
return result;
nomem:
@@ -288,13 +285,13 @@ static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data)
return -1;
}
}
- return resp->length - 4;
+ return resp->length - buflen;
}
static void wb_resp_read_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct resp_read_state *state = talloc_get_type_abort(
req->private_data, struct resp_read_state);
uint8_t *buf;
@@ -367,8 +364,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = wb_resp_write_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_resp_write_done, result);
return result;
fail:
@@ -378,8 +374,8 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
static void wb_resp_write_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
int err;
ssize_t ret;
diff --git a/source3/lib/wbclient.c b/source3/lib/wbclient.c
index b8d55a944a..7034e668ed 100644
--- a/source3/lib/wbclient.c
+++ b/source3/lib/wbclient.c
@@ -224,8 +224,7 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto nomem;
}
- subreq->async.fn = wbc_connect_connected;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wbc_connect_connected, result);
if (!tevent_req_set_endtime(subreq, ev, timeval_current_ofs(30, 0))) {
goto nomem;
@@ -245,8 +244,8 @@ static struct async_req *wb_connect_send(TALLOC_CTX *mem_ctx,
static void wbc_connect_connected(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
int res, err;
res = async_connect_recv(subreq, &err);
diff --git a/source3/libads/disp_sec.c b/source3/libads/disp_sec.c
index a5e04a4a6c..3bf0b6f7a7 100644
--- a/source3/libads/disp_sec.c
+++ b/source3/libads/disp_sec.c
@@ -112,15 +112,15 @@ static void ads_disp_sec_ace_object(ADS_STRUCT *ads,
TALLOC_CTX *mem_ctx,
struct security_ace_object *object)
{
- if (object->flags & SEC_ACE_OBJECT_PRESENT) {
- printf("Object type: SEC_ACE_OBJECT_PRESENT\n");
+ if (object->flags & SEC_ACE_OBJECT_TYPE_PRESENT) {
+ printf("Object type: SEC_ACE_OBJECT_TYPE_PRESENT\n");
printf("Object GUID: %s (%s)\n", GUID_string(mem_ctx,
&object->type.type),
ads_interprete_guid_from_object(ads, mem_ctx,
&object->type.type));
}
- if (object->flags & SEC_ACE_OBJECT_INHERITED_PRESENT) {
- printf("Object type: SEC_ACE_OBJECT_INHERITED_PRESENT\n");
+ if (object->flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT) {
+ printf("Object type: SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT\n");
printf("Object GUID: %s (%s)\n", GUID_string(mem_ctx,
&object->inherited_type.inherited_type),
ads_interprete_guid_from_object(ads, mem_ctx,
diff --git a/source3/libgpo/gpo_ini.c b/source3/libgpo/gpo_ini.c
index aa8f7c7770..edca85530b 100644
--- a/source3/libgpo/gpo_ini.c
+++ b/source3/libgpo/gpo_ini.c
@@ -83,7 +83,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
}
if (!convert_string_talloc(mem_ctx, CH_UTF16LE, CH_UNIX, data_in, n,
- &data_out, &converted_size, False))
+ (void **)&data_out, &converted_size, False))
{
status = NT_STATUS_INVALID_BUFFER_SIZE;
goto out;
diff --git a/source3/libgpo/gpo_sec.c b/source3/libgpo/gpo_sec.c
index 42ab72a99b..c72bb26732 100644
--- a/source3/libgpo/gpo_sec.c
+++ b/source3/libgpo/gpo_sec.c
@@ -38,12 +38,12 @@ static bool gpo_sd_check_agp_object_guid(const struct security_ace_object *objec
}
switch (object->flags) {
- case SEC_ACE_OBJECT_PRESENT:
+ case SEC_ACE_OBJECT_TYPE_PRESENT:
if (GUID_equal(&object->type.type,
&ext_right_apg_guid)) {
return True;
}
- case SEC_ACE_OBJECT_INHERITED_PRESENT:
+ case SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT:
if (GUID_equal(&object->inherited_type.inherited_type,
&ext_right_apg_guid)) {
return True;
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 20f7b97745..117178f376 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -50,12 +50,6 @@
#define LIBNET_UNJOIN_OUT_DUMP_CTX(ctx, r) \
LIBNET_UNJOIN_DUMP_CTX(ctx, r, NDR_OUT)
-#define W_ERROR_NOT_OK_GOTO_DONE(x) do { \
- if (!W_ERROR_IS_OK(x)) {\
- goto done;\
- }\
-} while (0)
-
/****************************************************************
****************************************************************/
diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 16599005b9..9fc4524654 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -26,6 +26,7 @@
static bool gpfs_share_modes;
static bool gpfs_leases;
+static bool gpfs_getrealfilename;
static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType);
@@ -139,7 +140,8 @@ int smbd_gpfs_putacl(char *pathname, int flags, void *acl)
int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
int *buflen)
{
- if (gpfs_get_realfilename_path_fn == NULL) {
+ if ((!gpfs_getrealfilename)
+ || (gpfs_get_realfilename_path_fn == NULL)) {
errno = ENOSYS;
return -1;
}
@@ -208,6 +210,8 @@ void init_gpfs(void)
gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True);
gpfs_leases = lp_parm_bool(-1, "gpfs", "leases", True);
+ gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename",
+ True);
return;
}
diff --git a/source3/modules/onefs.h b/source3/modules/onefs.h
index 418e13d9d2..ebeece40ad 100644
--- a/source3/modules/onefs.h
+++ b/source3/modules/onefs.h
@@ -21,112 +21,6 @@
#ifndef _ONEFS_H
#define _ONEFS_H
-#include "includes.h"
-#include "oplock_onefs.h"
-#include <sys/isi_acl.h>
-
-/* OneFS Module smb.conf parameters and defaults */
-
-/**
-* Specifies when ACLs presented to Windows should be canonicalized
-* into the ordering which Explorer expects.
-*/
-enum onefs_acl_wire_format
-{
- ACL_FORMAT_RAW, /**< Never canonicalize */
- ACL_FORMAT_WINDOWS_SD, /**< Only canonicalize synthetic ACLs */
- ACL_FORMAT_ALWAYS /**< Always canonicalize */
-};
-
-#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"
-#define PARM_ATIME_STATIC_DEFAULT NULL
-#define PARM_ATIME_SLOP "atime now slop"
-#define PARM_ATIME_SLOP_DEFAULT 0
-#define PARM_ATOMIC_SENDFILE "atomic sendfile"
-#define PARM_ATOMIC_SENDFILE_DEFAULT true
-#define PARM_CREATOR_OWNER_GETS_FULL_CONTROL "creator owner gets full control"
-#define PARM_CREATOR_OWNER_GETS_FULL_CONTROL_DEFAULT true
-#define PARM_CTIME_NOW "ctime now files"
-#define PARM_CTIME_NOW_DEFAULT NULL
-#define PARM_CTIME_SLOP "ctime now slop"
-#define PARM_CTIME_SLOP_DEFAULT 0
-#define PARM_IGNORE_SACLS "ignore sacls"
-#define PARM_IGNORE_SACLS_DEFAULT false
-#define PARM_MTIME_NOW "mtime now files"
-#define PARM_MTIME_NOW_DEFAULT NULL
-#define PARM_MTIME_STATIC "mtime static files"
-#define PARM_MTIME_STATIC_DEFAULT NULL
-#define PARM_MTIME_SLOP "mtime now slop"
-#define PARM_MTIME_SLOP_DEFAULT 0
-#define PARM_USE_READDIRPLUS "use readdirplus"
-#define PARM_USE_READDIRPLUS_DEFAULT true
-#define PARM_SENDFILE_LARGE_READS "sendfile large reads"
-#define PARM_SENDFILE_LARGE_READS_DEFAULT false
-#define PARM_SENDFILE_SAFE "sendfile safe"
-#define PARM_SENDFILE_SAFE_DEFAULT true
-#define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE "simple file sharing compatibility mode"
-#define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE_DEFAULT false
-#define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE "unmappable sids deny everyone"
-#define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE_DEFAULT false
-#define PARM_UNMAPPABLE_SIDS_IGNORE "ignore unmappable sids"
-#define PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT false
-#define PARM_UNMAPPABLE_SIDS_IGNORE_LIST "unmappable sids ignore list"
-#define PARM_UNMAPPABLE_SIDS_IGNORE_LIST_DEFAULT NULL
-
-#define IS_CTIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
- (cfg)->ctime_now_list,(conn)->case_sensitive))
-#define IS_MTIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
- (cfg)->mtime_now_list,(conn)->case_sensitive))
-#define IS_ATIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
- (cfg)->atime_now_list,(conn)->case_sensitive))
-#define IS_MTIME_STATIC_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
- (cfg)->mtime_static_list,(conn)->case_sensitive))
-#define IS_ATIME_STATIC_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
- (cfg)->atime_static_list,(conn)->case_sensitive))
-
-/*
- * Store some commonly evaluated parameters to avoid loadparm pain.
- */
-
-#define ONEFS_VFS_CONFIG_INITIALIZED 0x00010000
-
-#define ONEFS_VFS_CONFIG_FAKETIMESTAMPS 0x00000001
-
-struct onefs_vfs_config
-{
- int32 init_flags;
-
- /* data for fake timestamps */
- int atime_slop;
- int ctime_slop;
- int mtime_slop;
-
- /* Per-share list of files to fake the create time for. */
- name_compare_entry *ctime_now_list;
-
- /* Per-share list of files to fake the modification time for. */
- name_compare_entry *mtime_now_list;
-
- /* Per-share list of files to fake the access time for. */
- name_compare_entry *atime_now_list;
-
- /* Per-share list of files to fake the modification time for. */
- name_compare_entry *mtime_static_list;
-
- /* The access time will equal the create time. */
- /* The modification time will equal the create time.*/
-
- /* Per-share list of files to fake the access time for. */
- name_compare_entry *atime_static_list;
-};
-
/*
* vfs interface handlers
*/
@@ -233,15 +127,13 @@ NTSTATUS onefs_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
/*
* Utility functions
*/
+struct ifs_security_descriptor;
NTSTATUS onefs_samba_sd_to_sd(uint32 security_info_sent, SEC_DESC *psd,
struct ifs_security_descriptor *sd, int snum);
NTSTATUS onefs_split_ntfs_stream_name(TALLOC_CTX *mem_ctx, const char *fname,
char **pbase, char **pstream);
-bool onefs_get_config(int snum, int config_type,
- struct onefs_vfs_config *cfg);
-
int onefs_rdp_add_dir_state(connection_struct *conn, SMB_STRUCT_DIR *dirp);
/*
diff --git a/source3/modules/onefs_acl.c b/source3/modules/onefs_acl.c
index 7bc4a1728f..6f23d608d4 100644
--- a/source3/modules/onefs_acl.c
+++ b/source3/modules/onefs_acl.c
@@ -19,10 +19,13 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "onefs.h"
+#include "onefs_config.h"
#include <isi_acl/isi_acl_util.h>
#include <ifs/ifs_syscalls.h>
+#include <sys/isi_acl.h>
const struct enum_list enum_onefs_acl_wire_format[] = {
{ACL_FORMAT_RAW, "No Format"},
@@ -273,9 +276,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 +614,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 +755,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 +893,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 +945,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..7311e1961e 100644
--- a/source3/modules/onefs_cbrl.c
+++ b/source3/modules/onefs_cbrl.c
@@ -18,6 +18,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "onefs.h"
#include <ifs/ifs_syscalls.h>
@@ -255,6 +256,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 +304,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 +349,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 +364,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 +383,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 +392,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 +421,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 +435,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 +447,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_config.c b/source3/modules/onefs_config.c
new file mode 100644
index 0000000000..06f4b16ac1
--- /dev/null
+++ b/source3/modules/onefs_config.c
@@ -0,0 +1,276 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Support for OneFS
+ *
+ * Copyright (C) Todd Stecher, 2009
+ * Copyright (C) Tim Prouty, 2009
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "onefs_config.h"
+
+#include <ifs/ifs_syscalls.h>
+
+#define ONEFS_DATA_FASTBUF 10
+
+struct onefs_vfs_share_config vfs_share_config[ONEFS_DATA_FASTBUF];
+struct onefs_vfs_share_config *pvfs_share_config;
+
+static void onefs_load_faketimestamp_config(struct connection_struct *conn,
+ struct onefs_vfs_share_config *cfg)
+{
+ const char **parm;
+ int snum = SNUM(conn);
+
+ parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_NOW,
+ PARM_ATIME_NOW_DEFAULT);
+
+ if (parm) {
+ cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
+ set_namearray(&cfg->atime_now_list,*parm);
+ }
+
+ parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_CTIME_NOW,
+ PARM_CTIME_NOW_DEFAULT);
+
+ if (parm) {
+ cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
+ set_namearray(&cfg->ctime_now_list,*parm);
+ }
+
+ parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_MTIME_NOW,
+ PARM_MTIME_NOW_DEFAULT);
+
+ if (parm) {
+ cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
+ set_namearray(&cfg->mtime_now_list,*parm);
+ }
+
+ parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_STATIC,
+ PARM_ATIME_STATIC_DEFAULT);
+
+ if (parm) {
+ cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
+ set_namearray(&cfg->atime_static_list,*parm);
+ }
+
+ parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_MTIME_STATIC,
+ PARM_MTIME_STATIC_DEFAULT);
+
+ if (parm) {
+ cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
+ set_namearray(&cfg->mtime_static_list,*parm);
+ }
+
+ cfg->atime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_ATIME_SLOP,
+ PARM_ATIME_SLOP_DEFAULT);
+ cfg->ctime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_CTIME_SLOP,
+ PARM_CTIME_SLOP_DEFAULT);
+ cfg->mtime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_MTIME_SLOP,
+ PARM_MTIME_SLOP_DEFAULT);
+}
+
+/**
+ * Set onefs-specific vfs global config parameters.
+ *
+ * Since changes in these parameters require calling syscalls, we only want to
+ * call them when the configuration actually changes.
+ */
+static void onefs_load_global_config(connection_struct *conn)
+{
+ static struct onefs_vfs_global_config global_config;
+ bool dot_snap_child_accessible;
+ bool dot_snap_child_visible;
+ bool dot_snap_root_accessible;
+ bool dot_snap_root_visible;
+ bool dot_snap_tilde;
+ bool reconfig_dso = false;
+ bool reconfig_tilde = false;
+
+ /* Check if this is the first time setting the config options. */
+ if (!(global_config.init_flags & ONEFS_VFS_CONFIG_INITIALIZED)) {
+ global_config.init_flags |= ONEFS_VFS_CONFIG_INITIALIZED;
+
+ /* Set process encoding */
+ onefs_sys_config_enc();
+
+ reconfig_dso = true;
+ reconfig_tilde = true;
+ }
+
+ /* Get the dot snap options from the conf. */
+ dot_snap_child_accessible =
+ lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+ PARM_DOT_SNAP_CHILD_ACCESSIBLE,
+ PARM_DOT_SNAP_CHILD_ACCESSIBLE_DEFAULT);
+ dot_snap_child_visible =
+ lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+ PARM_DOT_SNAP_CHILD_VISIBLE,
+ PARM_DOT_SNAP_CHILD_VISIBLE_DEFAULT);
+ dot_snap_root_accessible =
+ lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+ PARM_DOT_SNAP_ROOT_ACCESSIBLE,
+ PARM_DOT_SNAP_ROOT_ACCESSIBLE_DEFAULT);
+ dot_snap_root_visible =
+ lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+ PARM_DOT_SNAP_ROOT_VISIBLE,
+ PARM_DOT_SNAP_ROOT_VISIBLE_DEFAULT);
+ dot_snap_tilde =
+ lp_parm_bool(SNUM(conn), PARM_ONEFS_TYPE,
+ PARM_DOT_SNAP_TILDE,
+ PARM_DOT_SNAP_TILDE_DEFAULT);
+
+ /* Check if any of the dot snap options need updating. */
+ if (dot_snap_child_accessible !=
+ global_config.dot_snap_child_accessible) {
+ global_config.dot_snap_child_accessible =
+ dot_snap_child_accessible;
+ reconfig_dso = true;
+ }
+ if (dot_snap_child_visible !=
+ global_config.dot_snap_child_visible) {
+ global_config.dot_snap_child_visible =
+ dot_snap_child_visible;
+ reconfig_dso = true;
+ }
+ if (dot_snap_root_accessible !=
+ global_config.dot_snap_root_accessible) {
+ global_config.dot_snap_root_accessible =
+ dot_snap_root_accessible;
+ reconfig_dso = true;
+ }
+ if (dot_snap_root_visible !=
+ global_config.dot_snap_root_visible) {
+ global_config.dot_snap_root_visible =
+ dot_snap_root_visible;
+ reconfig_dso = true;
+ }
+ if (dot_snap_tilde != global_config.dot_snap_tilde) {
+ global_config.dot_snap_tilde = dot_snap_tilde;
+ reconfig_tilde = true;
+ }
+
+ /* If a dot snap option has changed update the process. */
+ if (reconfig_dso) {
+ onefs_sys_config_snap_opt(&global_config);
+ }
+
+ /* If the dot snap tilde option has changed update the process. */
+ if (reconfig_tilde) {
+ onefs_sys_config_tilde(&global_config);
+ }
+}
+
+int onefs_load_config(connection_struct *conn)
+{
+ int snum = SNUM(conn);
+ int share_count = lp_numservices();
+
+ /* Share config */
+ if (!pvfs_share_config) {
+
+ if (share_count <= ONEFS_DATA_FASTBUF)
+ pvfs_share_config = vfs_share_config;
+ else {
+ pvfs_share_config =
+ SMB_MALLOC_ARRAY(struct onefs_vfs_share_config,
+ share_count);
+ if (!pvfs_share_config) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ memset(pvfs_share_config, 0,
+ (sizeof(struct onefs_vfs_share_config) *
+ share_count));
+ }
+ }
+
+ if ((pvfs_share_config[snum].init_flags &
+ ONEFS_VFS_CONFIG_INITIALIZED) == 0) {
+ pvfs_share_config[snum].init_flags =
+ ONEFS_VFS_CONFIG_INITIALIZED;
+ onefs_load_faketimestamp_config(conn,
+ &pvfs_share_config[snum]);
+ }
+
+ /* Global config */
+ onefs_load_global_config(conn);
+
+ return 0;
+}
+
+bool onefs_get_config(int snum, int config_type,
+ struct onefs_vfs_share_config *cfg)
+{
+ if (vfs_share_config[snum].init_flags & config_type)
+ *cfg = vfs_share_config[snum];
+ else
+ return false;
+
+ return true;
+}
+
+
+/**
+ * Set the per-process encoding, ignoring errors.
+ */
+void onefs_sys_config_enc(void)
+{
+ int ret;
+
+ ret = enc_set_proc(ENC_UTF8);
+ if (ret) {
+ DEBUG(0, ("Setting process encoding failed: %s",
+ strerror(errno)));
+ }
+}
+
+/**
+ * Set the per-process .snpashot directory options, ignoring errors.
+ */
+void onefs_sys_config_snap_opt(struct onefs_vfs_global_config *global_config)
+{
+ struct ifs_dotsnap_options dso;
+ int ret;
+
+ dso.per_proc = 1;
+ dso.sub_accessible = global_config->dot_snap_child_accessible;
+ dso.sub_visible = global_config->dot_snap_child_visible;
+ dso.root_accessible = global_config->dot_snap_root_accessible;
+ dso.root_visible = global_config->dot_snap_root_visible;
+
+ ret = ifs_set_dotsnap_options(&dso);
+ if (ret) {
+ DEBUG(0, ("Setting snapshot visibility/accessibility "
+ "failed: %s", strerror(errno)));
+ }
+}
+
+/**
+ * Set the per-process flag saying whether or not to accept ~snapshot
+ * as an alternative name for .snapshot directories.
+ */
+void onefs_sys_config_tilde(struct onefs_vfs_global_config *global_config)
+{
+ int ret;
+
+ ret = ifs_tilde_snapshot(global_config->dot_snap_tilde);
+ if (ret) {
+ DEBUG(0, ("Setting snapshot tilde failed: %s",
+ strerror(errno)));
+ }
+}
diff --git a/source3/modules/onefs_config.h b/source3/modules/onefs_config.h
new file mode 100644
index 0000000000..f0f48e6379
--- /dev/null
+++ b/source3/modules/onefs_config.h
@@ -0,0 +1,160 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * OneFS vfs module configuration and defaults
+ *
+ * Copyright (C) Steven Danneman, 2008
+ * Copyright (C) Tim Prouty, 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 _ONEFS_CONFIG_H
+#define _ONEFS_CONFIG_H
+
+/**
+* Specifies when ACLs presented to Windows should be canonicalized
+* into the ordering which Explorer expects.
+*/
+enum onefs_acl_wire_format
+{
+ ACL_FORMAT_RAW, /**< Never canonicalize */
+ ACL_FORMAT_WINDOWS_SD, /**< Only canonicalize synthetic ACLs */
+ ACL_FORMAT_ALWAYS /**< Always canonicalize */
+};
+
+#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"
+#define PARM_ATIME_STATIC_DEFAULT NULL
+#define PARM_ATIME_SLOP "atime now slop"
+#define PARM_ATIME_SLOP_DEFAULT 0
+#define PARM_ATOMIC_SENDFILE "atomic sendfile"
+#define PARM_ATOMIC_SENDFILE_DEFAULT true
+#define PARM_CREATOR_OWNER_GETS_FULL_CONTROL "creator owner gets full control"
+#define PARM_CREATOR_OWNER_GETS_FULL_CONTROL_DEFAULT true
+#define PARM_CTIME_NOW "ctime now files"
+#define PARM_CTIME_NOW_DEFAULT NULL
+#define PARM_CTIME_SLOP "ctime now slop"
+#define PARM_CTIME_SLOP_DEFAULT 0
+#define PARM_DOT_SNAP_CHILD_ACCESSIBLE "dot snap child accessible"
+#define PARM_DOT_SNAP_CHILD_ACCESSIBLE_DEFAULT true
+#define PARM_DOT_SNAP_CHILD_VISIBLE "dot snap child visible"
+#define PARM_DOT_SNAP_CHILD_VISIBLE_DEFAULT false
+#define PARM_DOT_SNAP_ROOT_ACCESSIBLE "dot snap root accessible"
+#define PARM_DOT_SNAP_ROOT_ACCESSIBLE_DEFAULT true
+#define PARM_DOT_SNAP_ROOT_VISIBLE "dot snap root visible"
+#define PARM_DOT_SNAP_ROOT_VISIBLE_DEFAULT true
+#define PARM_DOT_SNAP_TILDE "dot snap tilde"
+#define PARM_DOT_SNAP_TILDE_DEFAULT true
+#define PARM_IGNORE_SACLS "ignore sacls"
+#define PARM_IGNORE_SACLS_DEFAULT false
+#define PARM_IGNORE_STREAMS "ignore streams"
+#define PARM_IGNORE_STREAMS_DEFAULT false
+#define PARM_MTIME_NOW "mtime now files"
+#define PARM_MTIME_NOW_DEFAULT NULL
+#define PARM_MTIME_STATIC "mtime static files"
+#define PARM_MTIME_STATIC_DEFAULT NULL
+#define PARM_MTIME_SLOP "mtime now slop"
+#define PARM_MTIME_SLOP_DEFAULT 0
+#define PARM_USE_READDIRPLUS "use readdirplus"
+#define PARM_USE_READDIRPLUS_DEFAULT true
+#define PARM_SENDFILE_LARGE_READS "sendfile large reads"
+#define PARM_SENDFILE_LARGE_READS_DEFAULT false
+#define PARM_SENDFILE_SAFE "sendfile safe"
+#define PARM_SENDFILE_SAFE_DEFAULT true
+#define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE "simple file sharing compatibility mode"
+#define PARM_SIMPLE_FILE_SHARING_COMPATIBILITY_MODE_DEFAULT false
+#define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE "unmappable sids deny everyone"
+#define PARM_UNMAPPABLE_SIDS_DENY_EVERYONE_DEFAULT false
+#define PARM_UNMAPPABLE_SIDS_IGNORE "ignore unmappable sids"
+#define PARM_UNMAPPABLE_SIDS_IGNORE_DEFAULT false
+#define PARM_UNMAPPABLE_SIDS_IGNORE_LIST "unmappable sids ignore list"
+#define PARM_UNMAPPABLE_SIDS_IGNORE_LIST_DEFAULT NULL
+
+#define IS_CTIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
+ (cfg)->ctime_now_list,(conn)->case_sensitive))
+#define IS_MTIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
+ (cfg)->mtime_now_list,(conn)->case_sensitive))
+#define IS_ATIME_NOW_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
+ (cfg)->atime_now_list,(conn)->case_sensitive))
+#define IS_MTIME_STATIC_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
+ (cfg)->mtime_static_list,(conn)->case_sensitive))
+#define IS_ATIME_STATIC_PATH(conn,cfg,path) ((conn) && is_in_path((path),\
+ (cfg)->atime_static_list,(conn)->case_sensitive))
+
+/*
+ * Store some commonly evaluated parameters to avoid loadparm pain.
+ */
+
+#define ONEFS_VFS_CONFIG_INITIALIZED 0x00010000
+
+#define ONEFS_VFS_CONFIG_FAKETIMESTAMPS 0x00000001
+
+struct onefs_vfs_share_config
+{
+ uint32_t init_flags;
+
+ /* data for fake timestamps */
+ int atime_slop;
+ int ctime_slop;
+ int mtime_slop;
+
+ /* Per-share list of files to fake the create time for. */
+ name_compare_entry *ctime_now_list;
+
+ /* Per-share list of files to fake the modification time for. */
+ name_compare_entry *mtime_now_list;
+
+ /* Per-share list of files to fake the access time for. */
+ name_compare_entry *atime_now_list;
+
+ /* Per-share list of files to fake the modification time for. */
+ name_compare_entry *mtime_static_list;
+
+ /* The access time will equal the create time. */
+ /* The modification time will equal the create time.*/
+
+ /* Per-share list of files to fake the access time for. */
+ name_compare_entry *atime_static_list;
+};
+
+struct onefs_vfs_global_config
+{
+ uint32_t init_flags;
+
+ /* Snapshot options */
+ bool dot_snap_child_accessible;
+ bool dot_snap_child_visible;
+ bool dot_snap_root_accessible;
+ bool dot_snap_root_visible;
+ bool dot_snap_tilde;
+};
+
+int onefs_load_config(connection_struct *conn);
+
+bool onefs_get_config(int snum, int config_type,
+ struct onefs_vfs_share_config *cfg);
+
+void onefs_sys_config_enc(void);
+
+void onefs_sys_config_snap_opt(struct onefs_vfs_global_config *global_config);
+
+void onefs_sys_config_tilde(struct onefs_vfs_global_config *global_config);
+
+#endif /* _ONEFS_CONFIG_H */
diff --git a/source3/modules/onefs_dir.c b/source3/modules/onefs_dir.c
index 83622b2bcd..68a58b3bb2 100644
--- a/source3/modules/onefs_dir.c
+++ b/source3/modules/onefs_dir.c
@@ -19,7 +19,9 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "onefs.h"
+#include "onefs_config.h"
#include <ifs/ifs_syscalls.h>
diff --git a/source3/modules/onefs_notify.c b/source3/modules/onefs_notify.c
index 40f690876d..3455afd4ab 100644
--- a/source3/modules/onefs_notify.c
+++ b/source3/modules/onefs_notify.c
@@ -33,6 +33,7 @@
* CompletionFilter and WatchTree of open SMB requests, and return notify
* events back to the proper SMB requests */
+#include "includes.h"
#include "onefs.h"
#include <ifs/ifs_types.h>
diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c
index 382ecc60a3..d3ba0ac979 100644
--- a/source3/modules/onefs_open.c
+++ b/source3/modules/onefs_open.c
@@ -32,7 +32,10 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "onefs.h"
+#include "onefs_config.h"
+#include "oplock_onefs.h"
#include "smbd/globals.h"
extern const struct generic_mapping file_generic_mapping;
@@ -193,7 +196,7 @@ static NTSTATUS onefs_open_file(files_struct *fsp,
&base, &stream);
}
/* It's a stream, so pass in the base_fd */
- if (stream != NULL) {
+ if ((conn->fs_capabilities & FILE_NAMED_STREAMS) && stream != NULL) {
SMB_ASSERT(fsp->base_fsp);
/*
diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c
index 9616ca48d5..05b36d7d3c 100644
--- a/source3/modules/onefs_streams.c
+++ b/source3/modules/onefs_streams.c
@@ -19,7 +19,10 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "onefs.h"
+#include "onefs_config.h"
+
#include <sys/isi_enc.h>
/*
@@ -160,18 +163,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 +203,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);
@@ -220,7 +233,7 @@ static void merge_stat(SMB_STRUCT_STAT *stream_sbuf,
static void onefs_adjust_stat_time(vfs_handle_struct *handle, const char *fname,
SMB_STRUCT_STAT *sbuf)
{
- struct onefs_vfs_config cfg;
+ struct onefs_vfs_share_config cfg;
struct timeval tv_now = {0, 0};
bool static_mtime = False;
bool static_atime = False;
@@ -658,6 +671,11 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
state.streams = NULL;
state.num_streams = 0;
+ if (lp_parm_bool(SNUM(handle->conn), PARM_ONEFS_TYPE,
+ PARM_IGNORE_STREAMS, PARM_IGNORE_STREAMS_DEFAULT)) {
+ goto out;
+ }
+
/* Add the default stream. */
if (S_ISREG(sbuf.st_mode)) {
if (!add_one_stream(mem_ctx,
@@ -689,7 +707,7 @@ NTSTATUS onefs_streaminfo(vfs_handle_struct *handle,
return state.status;
}
}
-
+ out:
*num_streams = state.num_streams;
*streams = state.streams;
return NT_STATUS_OK;
diff --git a/source3/modules/onefs_system.c b/source3/modules/onefs_system.c
index 76df006d82..b8b059bce9 100644
--- a/source3/modules/onefs_system.c
+++ b/source3/modules/onefs_system.c
@@ -18,10 +18,14 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "includes.h"
#include "onefs.h"
+#include "onefs_config.h"
+#include "oplock_onefs.h"
#include <ifs/ifs_syscalls.h>
#include <isi_acl/isi_acl_util.h>
+#include <sys/isi_acl.h>
/*
* Initialize the sm_lock struct before passing it to ifs_createfile.
@@ -95,6 +99,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;
@@ -196,6 +202,7 @@ int onefs_sys_create_file(connection_struct *conn,
}
out:
+ END_PROFILE(syscall_createfile);
aclu_free_sd(pifs_sd, false);
return ret_fd;
@@ -307,6 +314,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)) {
@@ -320,6 +329,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;
}
@@ -391,6 +401,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;
}
@@ -402,6 +413,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;
}
@@ -421,6 +433,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;
}
@@ -439,9 +452,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;
}
@@ -455,6 +470,7 @@ ssize_t onefs_sys_sendfile(connection_struct *conn, int tofd, int fromfd,
count, strerror(errno)));
}
+ END_PROFILE(syscall_sendfile);
return ret;
}
@@ -509,10 +525,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;
}
@@ -624,6 +643,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_acl_tdb.c b/source3/modules/vfs_acl_tdb.c
index 909de9d7c8..a77f6d60f4 100644
--- a/source3/modules/vfs_acl_tdb.c
+++ b/source3/modules/vfs_acl_tdb.c
@@ -186,20 +186,26 @@ static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
TDB_DATA data;
struct file_id id;
struct db_context *db;
+ int ret = -1;
SMB_STRUCT_STAT sbuf;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
return NT_STATUS_INTERNAL_DB_CORRUPTION);
if (fsp && fsp->fh->fd != -1) {
- if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
- return map_nt_error_from_unix(errno);
- }
+ ret = SMB_VFS_FSTAT(fsp, &sbuf);
} else {
- if (SMB_VFS_STAT(handle->conn, name, &sbuf) == -1) {
- return map_nt_error_from_unix(errno);
+ if (fsp && fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(handle->conn, name, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, name, &sbuf);
}
}
+
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
id = vfs_file_id_from_sbuf(handle->conn, &sbuf);
/* For backwards compatibility only store the dev/inode. */
@@ -270,6 +276,7 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
TDB_DATA data;
struct db_context *db;
struct db_record *rec;
+ int ret = -1;
DEBUG(10,("store_acl_blob_fsp: storing blob length %u on file %s\n",
(unsigned int)pblob->length, fsp->fsp_name));
@@ -278,14 +285,19 @@ static NTSTATUS store_acl_blob_fsp(vfs_handle_struct *handle,
return NT_STATUS_INTERNAL_DB_CORRUPTION);
if (fsp->fh->fd != -1) {
- if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
- return map_nt_error_from_unix(errno);
- }
+ ret = SMB_VFS_FSTAT(fsp, &sbuf);
} else {
- if (SMB_VFS_STAT(handle->conn, fsp->fsp_name, &sbuf) == -1) {
- return map_nt_error_from_unix(errno);
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(handle->conn, fsp->fsp_name, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, fsp->fsp_name, &sbuf);
}
}
+
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
id = vfs_file_id_from_sbuf(handle->conn, &sbuf);
/* For backwards compatibility only store the dev/inode. */
@@ -316,6 +328,7 @@ static NTSTATUS store_acl_blob_pathname(vfs_handle_struct *handle,
SMB_STRUCT_STAT sbuf;
struct db_context *db;
struct db_record *rec;
+ int ret = -1;
DEBUG(10,("store_acl_blob_pathname: storing blob "
"length %u on file %s\n",
@@ -324,7 +337,13 @@ static NTSTATUS store_acl_blob_pathname(vfs_handle_struct *handle,
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
return NT_STATUS_INTERNAL_DB_CORRUPTION);
- if (SMB_VFS_STAT(handle->conn, fname, &sbuf) == -1) {
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, fname, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, fname, &sbuf);
+ }
+
+ if (ret == -1) {
return map_nt_error_from_unix(errno);
}
@@ -494,7 +513,11 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
if (fsp && !fsp->is_directory && fsp->fh->fd != -1) {
ret = SMB_VFS_FSTAT(fsp, &sbuf);
} else {
- ret = SMB_VFS_STAT(handle->conn,fname, &sbuf);
+ if (fsp && fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(handle->conn,fname, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn,fname, &sbuf);
+ }
}
if (ret == -1) {
return map_nt_error_from_unix(errno);
@@ -583,11 +606,17 @@ static int unlink_acl_tdb(vfs_handle_struct *handle, const char *path)
{
SMB_STRUCT_STAT sbuf;
struct db_context *db;
- int ret;
+ int ret = -1;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
- if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) {
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, path, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, path, &sbuf);
+ }
+
+ if (ret == -1) {
return -1;
}
@@ -626,11 +655,17 @@ static int rmdir_acl_tdb(vfs_handle_struct *handle, const char *path)
SMB_STRUCT_STAT sbuf;
struct db_context *db;
- int ret;
+ int ret = -1;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
- if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) {
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, path, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, path, &sbuf);
+ }
+
+ if (ret == -1) {
return -1;
}
@@ -728,7 +763,11 @@ static NTSTATUS fset_nt_acl_tdb(vfs_handle_struct *handle, files_struct *fsp,
return NT_STATUS_OK;
}
if (fsp->is_directory || fsp->fh->fd == -1) {
- ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
+ }
} else {
ret = SMB_VFS_FSTAT(fsp, &sbuf);
}
@@ -813,11 +852,17 @@ static int sys_acl_set_file_tdb(vfs_handle_struct *handle,
{
SMB_STRUCT_STAT sbuf;
struct db_context *db;
- int ret;
+ int ret = -1;
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
- if (SMB_VFS_STAT(handle->conn, path, &sbuf) == -1) {
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, path, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, path, &sbuf);
+ }
+
+ if (ret == -1) {
return -1;
}
@@ -848,7 +893,11 @@ static int sys_acl_set_fd_tdb(vfs_handle_struct *handle,
SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);
if (fsp->is_directory || fsp->fh->fd == -1) {
- ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
+ }
} else {
ret = SMB_VFS_FSTAT(fsp, &sbuf);
}
diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c
index 7c78b506f0..49e4899879 100644
--- a/source3/modules/vfs_acl_xattr.c
+++ b/source3/modules/vfs_acl_xattr.c
@@ -381,7 +381,11 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle,
if (fsp && !fsp->is_directory && fsp->fh->fd != -1) {
ret = SMB_VFS_FSTAT(fsp, &sbuf);
} else {
- ret = SMB_VFS_STAT(handle->conn,fname, &sbuf);
+ if (fsp && fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(handle->conn,fname, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn,fname, &sbuf);
+ }
}
if (ret == -1) {
return map_nt_error_from_unix(errno);
@@ -559,7 +563,11 @@ static NTSTATUS fset_nt_acl_xattr(vfs_handle_struct *handle, files_struct *fsp,
return NT_STATUS_OK;
}
if (fsp->is_directory || fsp->fh->fd == -1) {
- ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name, &sbuf);
+ }
} else {
ret = SMB_VFS_FSTAT(fsp, &sbuf);
}
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 1d7cdba014..3c061ece79 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -96,6 +96,11 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
TALLOC_FREE(full_path);
+ if ((result == -1) && (errno == ENOSYS)) {
+ return SMB_VFS_NEXT_GET_REAL_FILENAME(
+ handle, path, name, mem_ctx, found_name);
+ }
+
if (result == -1) {
DEBUG(10, ("smbd_gpfs_get_realfilename_path returned %s\n",
strerror(errno)));
diff --git a/source3/modules/vfs_onefs.c b/source3/modules/vfs_onefs.c
index 60c2c977a4..2ec6e069c3 100644
--- a/source3/modules/vfs_onefs.c
+++ b/source3/modules/vfs_onefs.c
@@ -20,122 +20,21 @@
#include "includes.h"
#include "onefs.h"
+#include "onefs_config.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
-#define ONEFS_DATA_FASTBUF 10
-
-struct onefs_vfs_config share_config[ONEFS_DATA_FASTBUF];
-struct onefs_vfs_config *pshare_config;
-
-static void onefs_load_faketimestamp_config(struct vfs_handle_struct *handle,
- struct onefs_vfs_config *cfg)
-{
- const char **parm;
- int snum = SNUM(handle->conn);
-
- parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_NOW,
- PARM_ATIME_NOW_DEFAULT);
-
- if (parm) {
- cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
- set_namearray(&cfg->atime_now_list,*parm);
- }
-
- parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_CTIME_NOW,
- PARM_CTIME_NOW_DEFAULT);
-
- if (parm) {
- cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
- set_namearray(&cfg->ctime_now_list,*parm);
- }
-
- parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_MTIME_NOW,
- PARM_MTIME_NOW_DEFAULT);
-
- if (parm) {
- cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
- set_namearray(&cfg->mtime_now_list,*parm);
- }
-
- parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_ATIME_STATIC,
- PARM_ATIME_STATIC_DEFAULT);
-
- if (parm) {
- cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
- set_namearray(&cfg->atime_static_list,*parm);
- }
-
- parm = lp_parm_string_list(snum, PARM_ONEFS_TYPE, PARM_MTIME_STATIC,
- PARM_MTIME_STATIC_DEFAULT);
-
- if (parm) {
- cfg->init_flags |= ONEFS_VFS_CONFIG_FAKETIMESTAMPS;
- set_namearray(&cfg->mtime_static_list,*parm);
- }
-
- cfg->atime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_ATIME_SLOP,
- PARM_ATIME_SLOP_DEFAULT);
- cfg->ctime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_CTIME_SLOP,
- PARM_CTIME_SLOP_DEFAULT);
- cfg->mtime_slop = lp_parm_int(snum, PARM_ONEFS_TYPE, PARM_MTIME_SLOP,
- PARM_MTIME_SLOP_DEFAULT);
-}
-
-
-static int onefs_load_config(struct vfs_handle_struct *handle)
-{
- int snum = SNUM(handle->conn);
- int share_count = lp_numservices();
-
- if (!pshare_config) {
-
- if (share_count <= ONEFS_DATA_FASTBUF)
- pshare_config = share_config;
- else {
- pshare_config =
- SMB_MALLOC_ARRAY(struct onefs_vfs_config,
- share_count);
- if (!pshare_config) {
- errno = ENOMEM;
- return -1;
- }
-
- memset(pshare_config, 0,
- (sizeof(struct onefs_vfs_config) * share_count));
- }
- }
-
- if ((pshare_config[snum].init_flags &
- ONEFS_VFS_CONFIG_INITIALIZED) == 0) {
- pshare_config[snum].init_flags =
- ONEFS_VFS_CONFIG_INITIALIZED;
- onefs_load_faketimestamp_config(handle,
- &pshare_config[snum]);
- }
-
- return 0;
-}
-
-bool onefs_get_config(int snum, int config_type,
- struct onefs_vfs_config *cfg)
-{
- if (share_config[snum].init_flags & config_type)
- *cfg = share_config[snum];
- else
- return false;
-
- return true;
-}
-
static int onefs_connect(struct vfs_handle_struct *handle, const char *service,
const char *user)
{
- int ret = onefs_load_config(handle);
+ int ret;
- if (ret)
+ ret = onefs_load_config(handle->conn);
+ if (ret) {
+ DEBUG(3, ("Load config failed: %s\n", strerror(errno)));
return ret;
+ }
return SMB_VFS_NEXT_CONNECT(handle, service, user);
}
@@ -323,7 +222,14 @@ static int onefs_ntimes(vfs_handle_struct *handle, const char *fname,
static uint32_t onefs_fs_capabilities(struct vfs_handle_struct *handle)
{
- return SMB_VFS_NEXT_FS_CAPABILITIES(handle) | FILE_NAMED_STREAMS;
+ uint32_t result = 0;
+
+ if (!lp_parm_bool(SNUM(handle->conn), PARM_ONEFS_TYPE,
+ PARM_IGNORE_STREAMS, PARM_IGNORE_STREAMS_DEFAULT)) {
+ result |= FILE_NAMED_STREAMS;
+ }
+
+ return result | SMB_VFS_NEXT_FS_CAPABILITIES(handle);
}
static vfs_op_tuple onefs_ops[] = {
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 9329be7a9c..023d2b9ec0 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -494,7 +494,13 @@ static int streams_depot_unlink(vfs_handle_struct *handle, const char *fname)
* We potentially need to delete the per-inode streams directory
*/
- if (SMB_VFS_NEXT_STAT(handle, fname, &sbuf) == -1) {
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_NEXT_LSTAT(handle, fname, &sbuf);
+ } else {
+ ret = SMB_VFS_NEXT_STAT(handle, fname, &sbuf);
+ }
+
+ if (ret == -1) {
return -1;
}
@@ -678,7 +684,11 @@ static NTSTATUS streams_depot_streaminfo(vfs_handle_struct *handle,
if (is_ntfs_stream_name(fname)) {
return NT_STATUS_INVALID_PARAMETER;
}
- ret = SMB_VFS_NEXT_STAT(handle, fname, &sbuf);
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_NEXT_LSTAT(handle, fname, &sbuf);
+ } else {
+ ret = SMB_VFS_NEXT_STAT(handle, fname, &sbuf);
+ }
}
if (ret == -1) {
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 77ffff5fb5..3d5478d7a2 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -135,6 +135,7 @@ static bool streams_xattr_recheck(struct stream_io *sio)
static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
SMB_STRUCT_STAT *sbuf)
{
+ int ret = -1;
struct stream_io *io = (struct stream_io *)
VFS_FETCH_FSP_EXTENSION(handle, fsp);
@@ -148,7 +149,13 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
return -1;
}
- if (SMB_VFS_STAT(handle->conn, io->base, sbuf) == -1) {
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, io->base, sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, io->base, sbuf);
+ }
+
+ if (ret == -1) {
return -1;
}
@@ -719,7 +726,11 @@ static NTSTATUS streams_xattr_streaminfo(vfs_handle_struct *handle,
if (is_ntfs_stream_name(fname)) {
return NT_STATUS_INVALID_PARAMETER;
}
- ret = SMB_VFS_STAT(handle->conn, fname, &sbuf);
+ if (lp_posix_pathnames()) {
+ ret = SMB_VFS_LSTAT(handle->conn, fname, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, fname, &sbuf);
+ }
}
if (ret == -1) {
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 89c706d874..f49a1bc4c9 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -4668,7 +4668,9 @@ static int max_open_files(void)
#if (defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE))
{
- struct rlimit rl = {};
+ struct rlimit rl;
+
+ ZERO_STRUCT(rl);
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
rlimit_max = rl.rlim_cur;
diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index 53845117e2..9c20042a62 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1308,13 +1308,20 @@ void uid_to_sid(DOM_SID *psid, uid_t uid)
if (!ret || expired) {
/* Not in cache. Ask winbindd. */
if (!winbind_uid_to_sid(psid, uid)) {
- if (!winbind_ping()) {
- legacy_uid_to_sid(psid, uid);
- return;
- }
+ /*
+ * We shouldn't return the NULL SID
+ * here if winbind was running and
+ * couldn't map, as winbind will have
+ * added a negative entry that will
+ * cause us to go though the
+ * legacy_uid_to_sid()
+ * function anyway in the case above
+ * the next time we ask.
+ */
+ DEBUG(5, ("uid_to_sid: winbind failed to find a sid "
+ "for uid %u\n", uid));
- DEBUG(5, ("uid_to_sid: winbind failed to find a sid for uid %u\n",
- uid));
+ legacy_uid_to_sid(psid, uid);
return;
}
}
@@ -1354,13 +1361,20 @@ void gid_to_sid(DOM_SID *psid, gid_t gid)
if (!ret || expired) {
/* Not in cache. Ask winbindd. */
if (!winbind_gid_to_sid(psid, gid)) {
- if (!winbind_ping()) {
- legacy_gid_to_sid(psid, gid);
- return;
- }
+ /*
+ * We shouldn't return the NULL SID
+ * here if winbind was running and
+ * couldn't map, as winbind will have
+ * added a negative entry that will
+ * cause us to go though the
+ * legacy_gid_to_sid()
+ * function anyway in the case above
+ * the next time we ask.
+ */
+ DEBUG(5, ("gid_to_sid: winbind failed to find a sid "
+ "for gid %u\n", gid));
- DEBUG(5, ("gid_to_sid: winbind failed to find a sid for gid %u\n",
- gid));
+ legacy_gid_to_sid(psid, gid);
return;
}
}
diff --git a/source3/passdb/pdb_onefs_sam.c b/source3/passdb/pdb_wbc_sam.c
index 51b8618aad..d2c7fda293 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,
@@ -100,10 +115,12 @@ static NTSTATUS pdb_onefs_sam_enum_group_memberships(struct pdb_methods *methods
{
size_t i;
const char *username = pdb_get_username(user);
+ uint32_t num_groups;
- if (!winbind_get_groups(mem_ctx, username, p_num_groups, pp_gids)) {
+ if (!winbind_get_groups(mem_ctx, username, &num_groups, pp_gids)) {
return NT_STATUS_NO_SUCH_USER;
}
+ *p_num_groups = num_groups;
if (*p_num_groups == 0) {
smb_panic("primary group missing");
@@ -123,7 +140,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 +181,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 +205,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 +215,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 +223,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 +247,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 +286,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 +326,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 +364,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 +372,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 +401,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 +409,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 +444,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/nt_printing.c b/source3/printing/nt_printing.c
index bbe8ebc2bc..d8658e9280 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1381,7 +1381,8 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
goto error_exit;
}
old_create_time = st.st_mtime;
- DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n", old_create_time));
+ DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n",
+ (long)old_create_time));
}
}
close_file(NULL, fsp, NORMAL_CLOSE);
@@ -1432,7 +1433,8 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
goto error_exit;
}
new_create_time = st.st_mtime;
- DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n", new_create_time));
+ DEBUGADD(6,("file_version_is_newer: mod time = %ld sec\n",
+ (long)new_create_time));
}
}
close_file(NULL, fsp, NORMAL_CLOSE);
@@ -3423,8 +3425,8 @@ WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action)
goto done;
switch (action) {
- case SPOOL_DS_PUBLISH:
- case SPOOL_DS_UPDATE:
+ case DSPRINT_PUBLISH:
+ case DSPRINT_UPDATE:
/* set the DsSpooler info and attributes */
if (!(map_nt_printer_info2_to_dsspooler(printer->info_2))) {
win_rc = WERR_NOMEM;
@@ -3433,7 +3435,7 @@ WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action)
printer->info_2->attributes |= PRINTER_ATTRIBUTE_PUBLISHED;
break;
- case SPOOL_DS_UNPUBLISH:
+ case DSPRINT_UNPUBLISH:
printer->info_2->attributes ^= PRINTER_ATTRIBUTE_PUBLISHED;
break;
default:
@@ -3467,11 +3469,11 @@ WERROR nt_printer_publish(Printer_entry *print_hnd, int snum, int action)
}
switch (action) {
- case SPOOL_DS_PUBLISH:
- case SPOOL_DS_UPDATE:
+ case DSPRINT_PUBLISH:
+ case DSPRINT_UPDATE:
win_rc = nt_printer_publish_ads(ads, printer);
break;
- case SPOOL_DS_UNPUBLISH:
+ case DSPRINT_UNPUBLISH:
win_rc = nt_printer_unpublish_ads(ads, printer);
break;
}
diff --git a/source3/printing/printfsp.c b/source3/printing/printfsp.c
index b485711f91..243b8ea03b 100644
--- a/source3/printing/printfsp.c
+++ b/source3/printing/printfsp.c
@@ -88,7 +88,6 @@ NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
{
uint32 jobid;
- fstring sharename;
if (fsp->fh->private_options & FILE_DELETE_ON_CLOSE) {
/*
@@ -102,7 +101,7 @@ void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
string_free(&fsp->fsp_name);
}
- if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
+ if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
DEBUG(3,("print_fsp_end: Unable to convert RAP jobid %u to print jobid.\n",
(unsigned int)fsp->rap_print_jobid ));
return;
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 7179184b73..fc3667ea3a 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -117,7 +117,9 @@ bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid)
if ( data.dptr && data.dsize == sizeof(struct rap_jobid_key) )
{
struct rap_jobid_key *jinfo = (struct rap_jobid_key*)data.dptr;
- fstrcpy( sharename, jinfo->sharename );
+ if (sharename != NULL) {
+ fstrcpy( sharename, jinfo->sharename );
+ }
*pjobid = jinfo->jobid;
DEBUG(10,("rap_to_pjobid: jobid %u maps to RAP jobid %u\n",
(unsigned int)*pjobid, (unsigned int)rap_jobid));
@@ -447,7 +449,7 @@ static const struct {
{ LPQ_PAPEROUT, JOB_STATUS_PAPEROUT },
{ LPQ_PRINTED, JOB_STATUS_PRINTED },
{ LPQ_DELETED, JOB_STATUS_DELETED },
- { LPQ_BLOCKED, JOB_STATUS_BLOCKED },
+ { LPQ_BLOCKED, JOB_STATUS_BLOCKED_DEVQ },
{ LPQ_USER_INTERVENTION, JOB_STATUS_USER_INTERVENTION },
{ -1, 0 }
};
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/registry/reg_api.c b/source3/registry/reg_api.c
index a5f3935821..67767a2e56 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -94,15 +94,16 @@ static WERROR fill_value_cache(struct registry_key *key)
static WERROR fill_subkey_cache(struct registry_key *key)
{
+ WERROR werr;
+
if (key->subkeys != NULL) {
if (!reg_subkeys_need_update(key->key, key->subkeys)) {
return WERR_OK;
}
}
- if (!(key->subkeys = TALLOC_ZERO_P(key, REGSUBKEY_CTR))) {
- return WERR_NOMEM;
- }
+ werr = regsubkey_ctr_init(key, &(key->subkeys));
+ W_ERROR_NOT_OK_RETURN(werr);
if (fetch_reg_keys(key->key, key->subkeys) == -1) {
TALLOC_FREE(key->subkeys);
@@ -127,7 +128,7 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
WERROR result = WERR_OK;
struct registry_key *regkey;
REGISTRY_KEY *key;
- REGSUBKEY_CTR *subkeys = NULL;
+ struct regsubkey_ctr *subkeys = NULL;
DEBUG(7,("regkey_open_onelevel: name = [%s]\n", name));
@@ -193,8 +194,8 @@ static WERROR regkey_open_onelevel(TALLOC_CTX *mem_ctx,
/* check if the path really exists; failed is indicated by -1 */
/* if the subkey count failed, bail out */
- if ( !(subkeys = TALLOC_ZERO_P( key, REGSUBKEY_CTR )) ) {
- result = WERR_NOMEM;
+ result = regsubkey_ctr_init(key, &subkeys);
+ if (!W_ERROR_IS_OK(result)) {
goto done;
}
@@ -308,11 +309,13 @@ WERROR reg_enumkey(TALLOC_CTX *mem_ctx, struct registry_key *key,
return err;
}
- if (idx >= key->subkeys->num_subkeys) {
+ if (idx >= regsubkey_ctr_numkeys(key->subkeys)) {
return WERR_NO_MORE_ITEMS;
}
- if (!(*name = talloc_strdup(mem_ctx, key->subkeys->subkeys[idx]))) {
+ if (!(*name = talloc_strdup(mem_ctx,
+ regsubkey_ctr_specific_key(key->subkeys, idx))))
+ {
return WERR_NOMEM;
}
@@ -406,11 +409,12 @@ WERROR reg_queryinfokey(struct registry_key *key, uint32_t *num_subkeys,
}
max_len = 0;
- for (i=0; i<key->subkeys->num_subkeys; i++) {
- max_len = MAX(max_len, strlen(key->subkeys->subkeys[i]));
+ for (i=0; i< regsubkey_ctr_numkeys(key->subkeys); i++) {
+ max_len = MAX(max_len,
+ strlen(regsubkey_ctr_specific_key(key->subkeys, i)));
}
- *num_subkeys = key->subkeys->num_subkeys;
+ *num_subkeys = regsubkey_ctr_numkeys(key->subkeys);
*max_subkeylen = max_len;
*max_subkeysize = 0; /* Class length? */
@@ -520,14 +524,8 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
err = fill_subkey_cache(create_parent);
if (!W_ERROR_IS_OK(err)) goto done;
- err = regsubkey_ctr_addkey(create_parent->subkeys, path);
- if (!W_ERROR_IS_OK(err)) goto done;
-
- if (!store_reg_keys(create_parent->key, create_parent->subkeys)) {
- TALLOC_FREE(create_parent->subkeys);
- err = WERR_REG_IO_FAILURE;
- goto done;
- }
+ err = create_reg_subkey(key->key, path);
+ W_ERROR_NOT_OK_GOTO_DONE(err);
/*
* Now open the newly created key
@@ -546,40 +544,36 @@ WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
WERROR reg_deletekey(struct registry_key *parent, const char *path)
{
WERROR err;
- TALLOC_CTX *mem_ctx;
char *name, *end;
- int num_subkeys;
struct registry_key *tmp_key, *key;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
- if (!(mem_ctx = talloc_init("reg_createkey"))) return WERR_NOMEM;
-
- if (!(name = talloc_strdup(mem_ctx, path))) {
+ name = talloc_strdup(mem_ctx, path);
+ if (name == NULL) {
err = WERR_NOMEM;
- goto error;
+ goto done;
}
/* check if the key has subkeys */
err = reg_openkey(mem_ctx, parent, name, REG_KEY_READ, &key);
- if (!W_ERROR_IS_OK(err)) {
- goto error;
- }
- if (!W_ERROR_IS_OK(err = fill_subkey_cache(key))) {
- goto error;
- }
- if (key->subkeys->num_subkeys > 0) {
+ W_ERROR_NOT_OK_GOTO_DONE(err);
+
+ err = fill_subkey_cache(key);
+ W_ERROR_NOT_OK_GOTO_DONE(err);
+
+ if (regsubkey_ctr_numkeys(key->subkeys) > 0) {
err = WERR_ACCESS_DENIED;
- goto error;
+ goto done;
}
/* no subkeys - proceed with delete */
- if ((end = strrchr(name, '\\')) != NULL) {
+ end = strrchr(name, '\\');
+ if (end != NULL) {
*end = '\0';
err = reg_openkey(mem_ctx, parent, name,
SEC_RIGHTS_CREATE_SUBKEY, &tmp_key);
- if (!W_ERROR_IS_OK(err)) {
- goto error;
- }
+ W_ERROR_NOT_OK_GOTO_DONE(err);
parent = tmp_key;
name = end+1;
@@ -587,31 +581,12 @@ WERROR reg_deletekey(struct registry_key *parent, const char *path)
if (name[0] == '\0') {
err = WERR_INVALID_PARAM;
- goto error;
- }
-
- if (!W_ERROR_IS_OK(err = fill_subkey_cache(parent))) {
- goto error;
- }
-
- num_subkeys = parent->subkeys->num_subkeys;
-
- if (regsubkey_ctr_delkey(parent->subkeys, name) == num_subkeys) {
- err = WERR_BADFILE;
- goto error;
- }
-
- if (!store_reg_keys(parent->key, parent->subkeys)) {
- TALLOC_FREE(parent->subkeys);
- err = WERR_REG_IO_FAILURE;
- goto error;
+ goto done;
}
- regkey_set_secdesc(key->key, NULL);
-
- err = WERR_OK;
+ err = delete_reg_subkey(parent->key, name);
- error:
+done:
TALLOC_FREE(mem_ctx);
return err;
}
@@ -726,7 +701,7 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
REGF_NK_REC *subkey;
REGISTRY_KEY registry_key;
REGVAL_CTR *values;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
int i;
char *path = NULL;
WERROR result = WERR_OK;
@@ -748,10 +723,8 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
/* now start parsing the values and subkeys */
- subkeys = TALLOC_ZERO_P(regfile->mem_ctx, REGSUBKEY_CTR);
- if (subkeys == NULL) {
- return WERR_NOMEM;
- }
+ result = regsubkey_ctr_init(regfile->mem_ctx, &subkeys);
+ W_ERROR_NOT_OK_RETURN(result);
values = TALLOC_ZERO_P(subkeys, REGVAL_CTR);
if (values == NULL) {
@@ -767,7 +740,7 @@ static WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath,
(key->values[i].data_size & ~VK_DATA_IN_OFFSET));
}
- /* copy subkeys into the REGSUBKEY_CTR */
+ /* copy subkeys into the struct regsubkey_ctr */
key->subkey_index = 0;
while ((subkey = regfio_fetch_subkey( regfile, key ))) {
@@ -861,7 +834,7 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath,
{
REGF_NK_REC *key;
REGVAL_CTR *values;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
int i, num_subkeys;
char *key_tmp = NULL;
char *keyname, *parentpath;
@@ -909,10 +882,8 @@ static WERROR reg_write_tree(REGF_FILE *regfile, const char *keypath,
/* lookup the values and subkeys */
- subkeys = TALLOC_ZERO_P(regfile->mem_ctx, REGSUBKEY_CTR);
- if (subkeys == NULL) {
- return WERR_NOMEM;
- }
+ result = regsubkey_ctr_init(regfile->mem_ctx, &subkeys);
+ W_ERROR_NOT_OK_RETURN(result);
values = TALLOC_ZERO_P(subkeys, REGVAL_CTR);
if (values == NULL) {
@@ -1091,6 +1062,7 @@ static WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx,
WERROR werr = WERR_OK;
struct registry_key *key;
char *subkey_name = NULL;
+ uint32 i;
mem_ctx = talloc_new(ctx);
if (mem_ctx == NULL) {
@@ -1104,25 +1076,21 @@ static WERROR reg_deletekey_recursive_internal(TALLOC_CTX *ctx,
goto done;
}
- while (W_ERROR_IS_OK(werr = reg_enumkey(mem_ctx, key, 0,
- &subkey_name, NULL)))
- {
+ werr = fill_subkey_cache(key);
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ /*
+ * loop from top to bottom for perfomance:
+ * this way, we need to rehash the regsubkey containers less
+ */
+ for (i = regsubkey_ctr_numkeys(key->subkeys) ; i > 0; i--) {
+ subkey_name = regsubkey_ctr_specific_key(key->subkeys, i-1);
werr = reg_deletekey_recursive_internal(mem_ctx, key,
- subkey_name,
- true);
- if (!W_ERROR_IS_OK(werr)) {
- goto done;
- }
- }
- if (!W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, werr)) {
- DEBUG(1, ("reg_deletekey_recursive_internal: "
- "Error enumerating subkeys: %s\n",
- win_errstr(werr)));
- goto done;
+ subkey_name,
+ true);
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
}
- werr = WERR_OK;
-
if (del_key) {
/* now delete the actual key */
werr = reg_deletekey(parent, path);
@@ -1133,18 +1101,57 @@ done:
return werr;
}
+static WERROR reg_deletekey_recursive_trans(TALLOC_CTX *ctx,
+ struct registry_key *parent,
+ const char *path,
+ bool del_key)
+{
+ WERROR werr;
+
+ werr = regdb_transaction_start();
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, ("reg_deletekey_recursive_trans: "
+ "error starting transaction: %s\n",
+ win_errstr(werr)));
+ return werr;
+ }
+
+ werr = reg_deletekey_recursive_internal(ctx, parent, path, del_key);
+
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, (__location__ " failed to delete key '%s' from key "
+ "'%s': %s\n", path, parent->key->name,
+ win_errstr(werr)));
+ werr = regdb_transaction_cancel();
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, ("reg_deletekey_recursive_trans: "
+ "error cancelling transaction: %s\n",
+ win_errstr(werr)));
+ }
+ } else {
+ werr = regdb_transaction_commit();
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, ("reg_deletekey_recursive_trans: "
+ "error committing transaction: %s\n",
+ win_errstr(werr)));
+ }
+ }
+
+ return werr;
+}
+
WERROR reg_deletekey_recursive(TALLOC_CTX *ctx,
struct registry_key *parent,
const char *path)
{
- return reg_deletekey_recursive_internal(ctx, parent, path, true);
+ return reg_deletekey_recursive_trans(ctx, parent, path, true);
}
WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx,
struct registry_key *parent,
const char *path)
{
- return reg_deletekey_recursive_internal(ctx, parent, path, false);
+ return reg_deletekey_recursive_trans(ctx, parent, path, false);
}
#if 0
diff --git a/source3/registry/reg_backend_current_version.c b/source3/registry/reg_backend_current_version.c
index 04cc0ebfa7..f76840ee22 100644
--- a/source3/registry/reg_backend_current_version.c
+++ b/source3/registry/reg_backend_current_version.c
@@ -70,7 +70,7 @@ static int current_version_fetch_values(const char *key, REGVAL_CTR *values)
}
static int current_version_fetch_subkeys(const char *key,
- REGSUBKEY_CTR *subkey_ctr)
+ struct regsubkey_ctr *subkey_ctr)
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 8ef83a19a1..30f1db9c53 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -103,7 +103,7 @@ static WERROR init_registry_key_internal(const char *add_path)
char *remaining = NULL;
char *keyname;
char *subkeyname;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
const char *p, *p2;
DEBUG(6, ("init_registry_key: Adding [%s]\n", add_path));
@@ -167,9 +167,9 @@ static WERROR init_registry_key_internal(const char *add_path)
* since we are about to update the record.
* We just want any subkeys already present */
- if (!(subkeys = TALLOC_ZERO_P(frame, REGSUBKEY_CTR))) {
+ werr = regsubkey_ctr_init(frame, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("talloc() failure!\n"));
- werr = WERR_NOMEM;
goto fail;
}
@@ -482,6 +482,24 @@ int regdb_close( void )
return 0;
}
+WERROR regdb_transaction_start(void)
+{
+ return (regdb->transaction_start(regdb) == 0) ?
+ WERR_OK : WERR_REG_IO_FAILURE;
+}
+
+WERROR regdb_transaction_commit(void)
+{
+ return (regdb->transaction_commit(regdb) == 0) ?
+ WERR_OK : WERR_REG_IO_FAILURE;
+}
+
+WERROR regdb_transaction_cancel(void)
+{
+ return (regdb->transaction_cancel(regdb) == 0) ?
+ WERR_OK : WERR_REG_IO_FAILURE;
+}
+
/***********************************************************************
return the tdb sequence number of the registry tdb.
this is an indicator for the content of the registry
@@ -492,13 +510,97 @@ int regdb_get_seqnum(void)
return regdb->get_seqnum(regdb);
}
+
+static WERROR regdb_delete_key_with_prefix(const char *keyname,
+ const char *prefix)
+{
+ char *path;
+ WERROR werr = WERR_NOMEM;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+
+ if (keyname == NULL) {
+ werr = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ if (prefix == NULL) {
+ path = discard_const_p(char, keyname);
+ } else {
+ path = talloc_asprintf(mem_ctx, "%s/%s", prefix, keyname);
+ if (path == NULL) {
+ goto done;
+ }
+ }
+
+ path = normalize_reg_path(mem_ctx, path);
+ if (path == NULL) {
+ goto done;
+ }
+
+ werr = ntstatus_to_werror(dbwrap_delete_bystring(regdb, path));
+
+ /* treat "not" found" as ok */
+ if (W_ERROR_EQUAL(werr, WERR_NOT_FOUND)) {
+ werr = WERR_OK;
+ }
+
+done:
+ talloc_free(mem_ctx);
+ return werr;
+}
+
+
+static WERROR regdb_delete_values(const char *keyname)
+{
+ return regdb_delete_key_with_prefix(keyname, REG_VALUE_PREFIX);
+}
+
+static WERROR regdb_delete_secdesc(const char *keyname)
+{
+ return regdb_delete_key_with_prefix(keyname, REG_SECDESC_PREFIX);
+}
+
+static WERROR regdb_delete_subkeylist(const char *keyname)
+{
+ return regdb_delete_key_with_prefix(keyname, NULL);
+}
+
+static WERROR regdb_delete_key_lists(const char *keyname)
+{
+ WERROR werr;
+
+ werr = regdb_delete_values(keyname);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
+ REG_VALUE_PREFIX, keyname, win_errstr(werr)));
+ goto done;
+ }
+
+ werr = regdb_delete_secdesc(keyname);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, (__location__ " Deleting %s/%s failed: %s\n",
+ REG_SECDESC_PREFIX, keyname, win_errstr(werr)));
+ goto done;
+ }
+
+ werr = regdb_delete_subkeylist(keyname);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, (__location__ " Deleting %s failed: %s\n",
+ keyname, win_errstr(werr)));
+ goto done;
+ }
+
+done:
+ return werr;
+}
+
/***********************************************************************
Add subkey strings to the registry tdb under a defined key
fmt is the same format as tdb_pack except this function only supports
fstrings
***********************************************************************/
-static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr)
+static bool regdb_store_keys_internal(const char *key, struct regsubkey_ctr *ctr)
{
TDB_DATA dbuf;
uint8 *buffer = NULL;
@@ -578,6 +680,16 @@ static bool regdb_store_keys_internal(const char *key, REGSUBKEY_CTR *ctr)
goto done;
}
+ /*
+ * Delete a sorted subkey cache for regdb_key_exists, will be
+ * recreated automatically
+ */
+ keyname = talloc_asprintf(ctx, "%s/%s", REG_SORTED_SUBKEYS_PREFIX,
+ keyname);
+ if (keyname != NULL) {
+ dbwrap_delete_bystring(regdb, keyname);
+ }
+
done:
TALLOC_FREE(ctx);
SAFE_FREE(buffer);
@@ -589,14 +701,14 @@ done:
do not currently exist
***********************************************************************/
-bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
+bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr)
{
- int num_subkeys, i;
+ int num_subkeys, old_num_subkeys, i;
char *path = NULL;
- REGSUBKEY_CTR *subkeys = NULL, *old_subkeys = NULL;
+ struct regsubkey_ctr *subkeys = NULL, *old_subkeys = NULL;
char *oldkeyname = NULL;
TALLOC_CTX *ctx = talloc_stackframe();
- NTSTATUS status;
+ WERROR werr;
if (!regdb_key_is_base_key(key) && !regdb_key_exists(key)) {
goto fail;
@@ -607,23 +719,28 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
* changed
*/
- if (!(old_subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR))) {
+ werr = regsubkey_ctr_init(ctx, &old_subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
return false;
}
regdb_fetch_keys(key, old_subkeys);
- if ((ctr->num_subkeys && old_subkeys->num_subkeys) &&
- (ctr->num_subkeys == old_subkeys->num_subkeys)) {
-
- for (i = 0; i<ctr->num_subkeys; i++) {
- if (strcmp(ctr->subkeys[i],
- old_subkeys->subkeys[i]) != 0) {
+ num_subkeys = regsubkey_ctr_numkeys(ctr);
+ old_num_subkeys = regsubkey_ctr_numkeys(old_subkeys);
+ if ((num_subkeys && old_num_subkeys) &&
+ (num_subkeys == old_num_subkeys)) {
+
+ for (i = 0; i < num_subkeys; i++) {
+ if (strcmp(regsubkey_ctr_specific_key(ctr, i),
+ regsubkey_ctr_specific_key(old_subkeys, i))
+ != 0)
+ {
break;
}
}
- if (i == ctr->num_subkeys) {
+ if (i == num_subkeys) {
/*
* Nothing changed, no point to even start a tdb
* transaction
@@ -644,7 +761,8 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
* Re-fetch the old keys inside the transaction
*/
- if (!(old_subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR))) {
+ werr = regsubkey_ctr_init(ctx, &old_subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
goto cancel;
}
@@ -686,66 +804,14 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
continue;
}
- /* (a) Delete the value list for this key */
-
- path = talloc_asprintf(ctx, "%s/%s/%s",
- REG_VALUE_PREFIX,
- key,
- oldkeyname );
- if (!path) {
- goto cancel;
- }
- path = normalize_reg_path(ctx, path);
- if (!path) {
- goto cancel;
- }
- /* Ignore errors here, we might have no values around */
- dbwrap_delete_bystring(regdb, path);
- TALLOC_FREE(path);
-
- /* (b) Delete the secdesc for this key */
-
- path = talloc_asprintf(ctx, "%s/%s/%s",
- REG_SECDESC_PREFIX,
- key,
- oldkeyname );
- if (!path) {
- goto cancel;
- }
- path = normalize_reg_path(ctx, path);
+ path = talloc_asprintf(ctx, "%s/%s", key, oldkeyname);
if (!path) {
goto cancel;
}
- status = dbwrap_delete_bystring(regdb, path);
- /* Don't fail if there are no values around. */
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND))
- {
- DEBUG(1, ("Deleting %s failed: %s\n", path,
- nt_errstr(status)));
- goto cancel;
- }
- TALLOC_FREE(path);
- /* (c) Delete the list of subkeys of this key */
+ werr = regdb_delete_key_lists(path);
+ W_ERROR_NOT_OK_GOTO(werr, cancel);
- path = talloc_asprintf(ctx, "%s/%s", key, oldkeyname);
- if (!path) {
- goto cancel;
- }
- path = normalize_reg_path(ctx, path);
- if (!path) {
- goto cancel;
- }
- status = dbwrap_delete_bystring(regdb, path);
- /* Don't fail if the subkey record was not found. */
- if (!NT_STATUS_IS_OK(status) &&
- !NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND))
- {
- DEBUG(1, ("Deleting %s failed: %s\n", path,
- nt_errstr(status)));
- goto cancel;
- }
TALLOC_FREE(path);
}
@@ -764,7 +830,8 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
num_subkeys = regsubkey_ctr_numkeys(ctr);
if (num_subkeys == 0) {
- if (!(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR)) ) {
+ werr = regsubkey_ctr_init(ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
goto cancel;
}
@@ -785,7 +852,8 @@ bool regdb_store_keys(const char *key, REGSUBKEY_CTR *ctr)
if (!path) {
goto cancel;
}
- if (!(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR)) ) {
+ werr = regsubkey_ctr_init(ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("regdb_store_keys: talloc() failure!\n"));
goto cancel;
}
@@ -822,6 +890,139 @@ fail:
return false;
}
+static WERROR regdb_create_subkey(const char *key, const char *subkey)
+{
+ WERROR werr;
+ struct regsubkey_ctr *subkeys;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+
+ if (!regdb_key_is_base_key(key) && !regdb_key_exists(key)) {
+ werr = WERR_NOT_FOUND;
+ goto done;
+ }
+
+ werr = regsubkey_ctr_init(mem_ctx, &subkeys);
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ if (regdb_fetch_keys(key, subkeys) < 0) {
+ werr = WERR_REG_IO_FAILURE;
+ goto done;
+ }
+
+ if (regsubkey_ctr_key_exists(subkeys, subkey)) {
+ werr = WERR_OK;
+ goto done;
+ }
+
+ talloc_free(subkeys);
+
+ werr = regdb_transaction_start();
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ werr = regsubkey_ctr_init(mem_ctx, &subkeys);
+ W_ERROR_NOT_OK_GOTO(werr, cancel);
+
+ if (regdb_fetch_keys(key, subkeys) < 0) {
+ werr = WERR_REG_IO_FAILURE;
+ goto cancel;
+ }
+
+ werr = regsubkey_ctr_addkey(subkeys, subkey);
+ W_ERROR_NOT_OK_GOTO(werr, cancel);
+
+ if (!regdb_store_keys_internal(key, subkeys)) {
+ DEBUG(0, (__location__ " failed to store new subkey list for "
+ "parent key %s\n", key));
+ werr = WERR_REG_IO_FAILURE;
+ goto cancel;
+ }
+
+ werr = regdb_transaction_commit();
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, (__location__ " failed to commit transaction: %s\n",
+ win_errstr(werr)));
+ }
+
+ goto done;
+
+cancel:
+ werr = regdb_transaction_cancel();
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, (__location__ " failed to cancel transaction: %s\n",
+ win_errstr(werr)));
+ }
+
+done:
+ talloc_free(mem_ctx);
+ return werr;
+}
+
+static WERROR regdb_delete_subkey(const char *key, const char *subkey)
+{
+ WERROR werr, werr2;
+ struct regsubkey_ctr *subkeys;
+ char *path;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+
+ if (!regdb_key_is_base_key(key) && !regdb_key_exists(key)) {
+ werr = WERR_NOT_FOUND;
+ goto done;
+ }
+
+ path = talloc_asprintf(mem_ctx, "%s/%s", key, subkey);
+ if (path == NULL) {
+ werr = WERR_NOMEM;
+ goto done;
+ }
+
+ if (!regdb_key_exists(path)) {
+ werr = WERR_OK;
+ goto done;
+ }
+
+ werr = regdb_transaction_start();
+ W_ERROR_NOT_OK_GOTO_DONE(werr);
+
+ werr = regdb_delete_key_lists(path);
+ W_ERROR_NOT_OK_GOTO(werr, cancel);
+
+ werr = regsubkey_ctr_init(mem_ctx, &subkeys);
+ W_ERROR_NOT_OK_GOTO(werr, cancel);
+
+ if (regdb_fetch_keys(key, subkeys) < 0) {
+ werr = WERR_REG_IO_FAILURE;
+ goto cancel;
+ }
+
+ werr = regsubkey_ctr_delkey(subkeys, subkey);
+ W_ERROR_NOT_OK_GOTO(werr, cancel);
+
+ if (!regdb_store_keys_internal(key, subkeys)) {
+ DEBUG(0, (__location__ " failed to store new subkey_list for "
+ "parent key %s\n", key));
+ werr = WERR_REG_IO_FAILURE;
+ goto cancel;
+ }
+
+ werr = regdb_transaction_commit();
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, (__location__ " failed to commit transaction: %s\n",
+ win_errstr(werr)));
+ }
+
+ goto done;
+
+cancel:
+ werr2 = regdb_transaction_cancel();
+ if (!W_ERROR_IS_OK(werr2)) {
+ DEBUG(0, (__location__ " failed to cancel transaction: %s\n",
+ win_errstr(werr2)));
+ }
+
+done:
+ talloc_free(mem_ctx);
+ return werr;
+}
static TDB_DATA regdb_fetch_key_internal(TALLOC_CTX *mem_ctx, const char *key)
{
@@ -871,6 +1072,223 @@ done:
return ret;
}
+/*
+ * regdb_key_exists() is a very frequent operation. It can be quite
+ * time-consuming to fully fetch the parent's subkey list, talloc_strdup all
+ * subkeys and then compare the keyname linearly to all the parent's subkeys.
+ *
+ * The following code tries to make this operation as efficient as possible:
+ * Per registry key we create a list of subkeys that is very efficient to
+ * search for existence of a subkey. Its format is:
+ *
+ * 4 bytes num_subkeys
+ * 4*num_subkey bytes offset into the string array
+ * then follows a sorted list of subkeys in uppercase
+ *
+ * This record is created by create_sorted_subkeys() on demand if it does not
+ * exist. scan_parent_subkeys() uses regdb->parse_record to search the sorted
+ * list, the parsing code and the binary search can be found in
+ * parent_subkey_scanner. The code uses parse_record() to avoid a memcpy of
+ * the potentially large subkey record.
+ *
+ * The sorted subkey record is deleted in regdb_store_keys_internal and
+ * recreated on demand.
+ */
+
+static int cmp_keynames(const void *p1, const void *p2)
+{
+ return StrCaseCmp(*((char **)p1), *((char **)p2));
+}
+
+static bool create_sorted_subkeys(const char *key, const char *sorted_keyname)
+{
+ char **sorted_subkeys;
+ struct regsubkey_ctr *ctr;
+ bool result = false;
+ NTSTATUS status;
+ char *buf;
+ char *p;
+ int i, res;
+ size_t len;
+ int num_subkeys;
+ WERROR werr;
+
+ if (regdb->transaction_start(regdb) != 0) {
+ DEBUG(0, ("create_sorted_subkeys: transaction_start "
+ "failed\n"));
+ return false;
+ }
+
+ werr = regsubkey_ctr_init(talloc_tos(), &ctr);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto fail;
+ }
+
+ res = regdb_fetch_keys(key, ctr);
+ if (res == -1) {
+ goto fail;
+ }
+
+ num_subkeys = regsubkey_ctr_numkeys(ctr);
+ sorted_subkeys = talloc_array(ctr, char *, num_subkeys);
+ if (sorted_subkeys == NULL) {
+ goto fail;
+ }
+
+ len = 4 + 4*num_subkeys;
+
+ for (i = 0; i < num_subkeys; i++) {
+ sorted_subkeys[i] = talloc_strdup_upper(sorted_subkeys,
+ regsubkey_ctr_specific_key(ctr, i));
+ if (sorted_subkeys[i] == NULL) {
+ goto fail;
+ }
+ len += strlen(sorted_subkeys[i])+1;
+ }
+
+ qsort(sorted_subkeys, num_subkeys, sizeof(char *), cmp_keynames);
+
+ buf = talloc_array(ctr, char, len);
+ if (buf == NULL) {
+ goto fail;
+ }
+ p = buf + 4 + 4*num_subkeys;
+
+ SIVAL(buf, 0, num_subkeys);
+
+ for (i=0; i < num_subkeys; i++) {
+ ptrdiff_t offset = p - buf;
+ SIVAL(buf, 4 + 4*i, offset);
+ strlcpy(p, sorted_subkeys[i], len-offset);
+ p += strlen(sorted_subkeys[i]) + 1;
+ }
+
+ status = dbwrap_store_bystring(
+ regdb, sorted_keyname, make_tdb_data((uint8_t *)buf, len),
+ TDB_REPLACE);
+ if (!NT_STATUS_IS_OK(status)) {
+ /*
+ * Don't use a "goto fail;" here, this would commit the broken
+ * transaction. See below for an explanation.
+ */
+ if (regdb->transaction_cancel(regdb) == -1) {
+ DEBUG(0, ("create_sorted_subkeys: transaction_cancel "
+ "failed\n"));
+ }
+ TALLOC_FREE(ctr);
+ return false;
+ }
+
+ result = true;
+ fail:
+ /*
+ * We only get here via the "goto fail" when we did not write anything
+ * yet. Using transaction_commit even in a failure case is necessary
+ * because this (disposable) call might be nested in other
+ * transactions. Doing a cancel here would destroy the possibility of
+ * a transaction_commit for transactions that we might be wrapped in.
+ */
+ if (regdb->transaction_commit(regdb) == -1) {
+ DEBUG(0, ("create_sorted_subkeys: transaction_start "
+ "failed\n"));
+ goto fail;
+ }
+
+ TALLOC_FREE(ctr);
+ return result;
+}
+
+struct scan_subkey_state {
+ char *name;
+ bool scanned;
+ bool found;
+};
+
+static int parent_subkey_scanner(TDB_DATA key, TDB_DATA data,
+ void *private_data)
+{
+ struct scan_subkey_state *state =
+ (struct scan_subkey_state *)private_data;
+ uint32_t num_subkeys;
+ uint32_t l, u;
+
+ if (data.dsize < sizeof(uint32_t)) {
+ return -1;
+ }
+
+ state->scanned = true;
+ state->found = false;
+
+ tdb_unpack(data.dptr, data.dsize, "d", &num_subkeys);
+
+ l = 0;
+ u = num_subkeys;
+
+ while (l < u) {
+ uint32_t idx = (l+u)/2;
+ char *s = (char *)data.dptr + IVAL(data.dptr, 4 + 4*idx);
+ int comparison = strcmp(state->name, s);
+
+ if (comparison < 0) {
+ u = idx;
+ } else if (comparison > 0) {
+ l = idx + 1;
+ } else {
+ state->found = true;
+ return 0;
+ }
+ }
+ return 0;
+}
+
+static bool scan_parent_subkeys(const char *parent, const char *name)
+{
+ char *path = NULL;
+ char *key = NULL;
+ struct scan_subkey_state state = { 0, };
+ bool result = false;
+ int res;
+
+ state.name = NULL;
+
+ path = normalize_reg_path(talloc_tos(), parent);
+ if (path == NULL) {
+ goto fail;
+ }
+
+ key = talloc_asprintf(talloc_tos(), "%s/%s",
+ REG_SORTED_SUBKEYS_PREFIX, path);
+ if (key == NULL) {
+ goto fail;
+ }
+
+ state.name = talloc_strdup_upper(talloc_tos(), name);
+ if (state.name == NULL) {
+ goto fail;
+ }
+ state.scanned = false;
+
+ res = regdb->parse_record(regdb, string_term_tdb_data(key),
+ parent_subkey_scanner, &state);
+
+ if (state.scanned) {
+ result = state.found;
+ } else {
+ if (!create_sorted_subkeys(path, key)) {
+ goto fail;
+ }
+ res = regdb->parse_record(regdb, string_term_tdb_data(key),
+ parent_subkey_scanner, &state);
+ if ((res == 0) && (state.scanned)) {
+ result = state.found;
+ }
+ }
+
+ fail:
+ TALLOC_FREE(path);
+ TALLOC_FREE(state.name);
+ return result;
+}
/**
* Check for the existence of a key.
@@ -907,26 +1325,8 @@ static bool regdb_key_exists(const char *key)
value = regdb_fetch_key_internal(mem_ctx, path);
ret = (value.dptr != NULL);
} else {
- /* get the list of subkeys of the parent key */
- uint32 num_items, len, i;
- fstring subkeyname;
-
*p = '\0';
- p++;
- value = regdb_fetch_key_internal(mem_ctx, path);
- if (value.dptr == NULL) {
- goto done;
- }
-
- len = tdb_unpack(value.dptr, value.dsize, "d", &num_items);
- for (i = 0; i < num_items; i++) {
- len += tdb_unpack(value.dptr +len, value.dsize -len,
- "f", &subkeyname);
- if (strequal(subkeyname, p)) {
- ret = true;
- goto done;
- }
- }
+ ret = scan_parent_subkeys(path, p+1);
}
done:
@@ -940,8 +1340,9 @@ done:
released by the caller.
***********************************************************************/
-int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
+int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr)
{
+ WERROR werr;
uint32 num_items;
uint8 *buf;
uint32 buflen, len;
@@ -957,7 +1358,10 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
goto done;
}
- ctr->seqnum = regdb_get_seqnum();
+ werr = regsubkey_ctr_set_seqnum(ctr, regdb_get_seqnum());
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
value = regdb_fetch_key_internal(frame, key);
@@ -972,35 +1376,12 @@ int regdb_fetch_keys(const char *key, REGSUBKEY_CTR *ctr)
buflen = value.dsize;
len = tdb_unpack( buf, buflen, "d", &num_items);
- /*
- * The following code breaks the abstraction that reg_objects.c sets
- * up with regsubkey_ctr_addkey(). But if we use that with the current
- * data structure of ctr->subkeys being an unsorted array, we end up
- * with an O(n^2) algorithm for retrieving keys from the tdb
- * file. This is pretty pointless, as we have to trust the data
- * structure on disk not to have duplicates anyway. The alternative to
- * breaking this abstraction would be to set up a more sophisticated
- * data structure in REGSUBKEY_CTR.
- *
- * This makes "net conf list" for a registry with >1000 shares
- * actually usable :-)
- */
-
- ctr->subkeys = talloc_array(ctr, char *, num_items);
- if (ctr->subkeys == NULL) {
- DEBUG(5, ("regdb_fetch_keys: could not allocate subkeys\n"));
- goto done;
- }
- ctr->num_subkeys = num_items;
-
for (i=0; i<num_items; i++) {
len += tdb_unpack(buf+len, buflen-len, "f", subkeyname);
- ctr->subkeys[i] = talloc_strdup(ctr->subkeys, subkeyname);
- if (ctr->subkeys[i] == NULL) {
- DEBUG(5, ("regdb_fetch_keys: could not allocate "
- "subkeyname\n"));
- TALLOC_FREE(ctr->subkeys);
- ctr->num_subkeys = 0;
+ werr = regsubkey_ctr_addkey(ctr, subkeyname);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(5, ("regdb_fetch_keys: regsubkey_ctr_addkey "
+ "failed: %s\n", win_errstr(werr)));
goto done;
}
}
@@ -1238,7 +1619,6 @@ static WERROR regdb_set_secdesc(const char *key,
{
TALLOC_CTX *mem_ctx = talloc_stackframe();
char *tdbkey;
- NTSTATUS status;
WERROR err = WERR_NOMEM;
TDB_DATA tdbdata;
@@ -1255,36 +1635,27 @@ static WERROR regdb_set_secdesc(const char *key,
if (secdesc == NULL) {
/* assuming a delete */
- status = dbwrap_trans_delete_bystring(regdb, tdbkey);
- if (NT_STATUS_IS_OK(status)) {
- err = WERR_OK;
- } else {
- err = ntstatus_to_werror(status);
- }
+ err = ntstatus_to_werror(dbwrap_trans_delete_bystring(regdb,
+ tdbkey));
goto done;
}
err = ntstatus_to_werror(marshall_sec_desc(mem_ctx, secdesc,
&tdbdata.dptr,
&tdbdata.dsize));
- if (!W_ERROR_IS_OK(err)) {
- goto done;
- }
+ W_ERROR_NOT_OK_GOTO_DONE(err);
- status = dbwrap_trans_store_bystring(regdb, tdbkey, tdbdata, 0);
- if (!NT_STATUS_IS_OK(status)) {
- err = ntstatus_to_werror(status);
- goto done;
- }
+ err = ntstatus_to_werror(dbwrap_trans_store_bystring(regdb, tdbkey,
+ tdbdata, 0));
done:
TALLOC_FREE(mem_ctx);
return err;
}
-bool regdb_subkeys_need_update(REGSUBKEY_CTR *subkeys)
+bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys)
{
- return (regdb_get_seqnum() != subkeys->seqnum);
+ return (regdb_get_seqnum() != regsubkey_ctr_get_seqnum(subkeys));
}
bool regdb_values_need_update(REGVAL_CTR *values)
@@ -1301,6 +1672,8 @@ REGISTRY_OPS regdb_ops = {
.fetch_values = regdb_fetch_values,
.store_subkeys = regdb_store_keys,
.store_values = regdb_store_values,
+ .create_subkey = regdb_create_subkey,
+ .delete_subkey = regdb_delete_subkey,
.get_secdesc = regdb_get_secdesc,
.set_secdesc = regdb_set_secdesc,
.subkeys_need_update = regdb_subkeys_need_update,
diff --git a/source3/registry/reg_backend_hkpt_params.c b/source3/registry/reg_backend_hkpt_params.c
index 2ed5e78e1c..c67f7b3ea4 100644
--- a/source3/registry/reg_backend_hkpt_params.c
+++ b/source3/registry/reg_backend_hkpt_params.c
@@ -59,7 +59,7 @@ static int hkpt_params_fetch_values(const char *key, REGVAL_CTR *regvals)
}
static int hkpt_params_fetch_subkeys(const char *key,
- REGSUBKEY_CTR *subkey_ctr)
+ struct regsubkey_ctr *subkey_ctr)
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
diff --git a/source3/registry/reg_backend_netlogon_params.c b/source3/registry/reg_backend_netlogon_params.c
index 71f88144c8..17abf038a6 100644
--- a/source3/registry/reg_backend_netlogon_params.c
+++ b/source3/registry/reg_backend_netlogon_params.c
@@ -46,7 +46,7 @@ static int netlogon_params_fetch_values(const char *key, REGVAL_CTR *regvals)
}
static int netlogon_params_fetch_subkeys(const char *key,
- REGSUBKEY_CTR *subkey_ctr)
+ struct regsubkey_ctr *subkey_ctr)
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
diff --git a/source3/registry/reg_backend_perflib.c b/source3/registry/reg_backend_perflib.c
index 999bca2682..e23c87efe8 100644
--- a/source3/registry/reg_backend_perflib.c
+++ b/source3/registry/reg_backend_perflib.c
@@ -95,7 +95,7 @@ static int perflib_fetch_values(const char *key, REGVAL_CTR *regvals)
}
static int perflib_fetch_subkeys(const char *key,
- REGSUBKEY_CTR *subkey_ctr)
+ struct regsubkey_ctr *subkey_ctr)
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
diff --git a/source3/registry/reg_backend_printing.c b/source3/registry/reg_backend_printing.c
index 5c1e6eb543..192bc78e09 100644
--- a/source3/registry/reg_backend_printing.c
+++ b/source3/registry/reg_backend_printing.c
@@ -42,8 +42,8 @@ struct reg_dyn_tree {
const char *path;
/* callbscks for fetch/store operations */
- int ( *fetch_subkeys) ( const char *path, REGSUBKEY_CTR *subkeys );
- bool (*store_subkeys) ( const char *path, REGSUBKEY_CTR *subkeys );
+ int ( *fetch_subkeys) ( const char *path, struct regsubkey_ctr *subkeys );
+ bool (*store_subkeys) ( const char *path, struct regsubkey_ctr *subkeys );
int (*fetch_values) ( const char *path, REGVAL_CTR *values );
bool (*store_values) ( const char *path, REGVAL_CTR *values );
};
@@ -77,7 +77,7 @@ static const char *dos_basename(const char *path)
*********************************************************************
*********************************************************************/
-static int key_forms_fetch_keys(const char *key, REGSUBKEY_CTR *subkeys)
+static int key_forms_fetch_keys(const char *key, struct regsubkey_ctr *subkeys)
{
char *p = reg_remaining_path(talloc_tos(), key + strlen(KEY_FORMS));
@@ -196,7 +196,7 @@ static char *strip_printers_prefix(const char *key)
/*********************************************************************
*********************************************************************/
-static int key_printers_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static int key_printers_fetch_keys( const char *key, struct regsubkey_ctr *subkeys )
{
int n_services = lp_numservices();
int snum;
@@ -275,7 +275,7 @@ done:
keyname is the sharename and not the printer name.
*********************************************************************/
-static bool add_printers_by_registry( REGSUBKEY_CTR *subkeys )
+static bool add_printers_by_registry( struct regsubkey_ctr *subkeys )
{
int i, num_keys, snum;
char *printername;
@@ -310,7 +310,7 @@ static bool add_printers_by_registry( REGSUBKEY_CTR *subkeys )
/**********************************************************************
*********************************************************************/
-static bool key_printers_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static bool key_printers_store_keys( const char *key, struct regsubkey_ctr *subkeys )
{
char *printers_key;
char *printername, *printerdatakey;
@@ -738,7 +738,7 @@ static bool key_printers_store_values( const char *key, REGVAL_CTR *values )
*********************************************************************
*********************************************************************/
-static int key_driver_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static int key_driver_fetch_keys( const char *key, struct regsubkey_ctr *subkeys )
{
const char *environments[] = {
"Windows 4.0",
@@ -1085,7 +1085,7 @@ static int key_driver_fetch_values( const char *key, REGVAL_CTR *values )
*********************************************************************
*********************************************************************/
-static int key_print_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static int key_print_fetch_keys( const char *key, struct regsubkey_ctr *subkeys )
{
int key_len = strlen(key);
@@ -1192,7 +1192,7 @@ static int match_registry_path(const char *key)
/***********************************************************************
**********************************************************************/
-static int regprint_fetch_reg_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static int regprint_fetch_reg_keys( const char *key, struct regsubkey_ctr *subkeys )
{
int i = match_registry_path( key );
@@ -1208,7 +1208,7 @@ static int regprint_fetch_reg_keys( const char *key, REGSUBKEY_CTR *subkeys )
/**********************************************************************
*********************************************************************/
-static bool regprint_store_reg_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static bool regprint_store_reg_keys( const char *key, struct regsubkey_ctr *subkeys )
{
int i = match_registry_path( key );
diff --git a/source3/registry/reg_backend_prod_options.c b/source3/registry/reg_backend_prod_options.c
index 7ac5c5b4b9..3e9d32cd97 100644
--- a/source3/registry/reg_backend_prod_options.c
+++ b/source3/registry/reg_backend_prod_options.c
@@ -59,7 +59,7 @@ static int prod_options_fetch_values(const char *key, REGVAL_CTR *regvals)
}
static int prod_options_fetch_subkeys(const char *key,
- REGSUBKEY_CTR *subkey_ctr)
+ struct regsubkey_ctr *subkey_ctr)
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
diff --git a/source3/registry/reg_backend_shares.c b/source3/registry/reg_backend_shares.c
index ee9e5dc5a1..a30ae34b4e 100644
--- a/source3/registry/reg_backend_shares.c
+++ b/source3/registry/reg_backend_shares.c
@@ -66,7 +66,7 @@ static char* trim_reg_path( const char *path )
Caller is responsible for freeing memory to **subkeys
*********************************************************************/
-static int shares_subkey_info( const char *key, REGSUBKEY_CTR *subkey_ctr )
+static int shares_subkey_info( const char *key, struct regsubkey_ctr *subkey_ctr )
{
char *path;
bool top_level = False;
@@ -134,7 +134,7 @@ static int shares_value_info( const char *key, REGVAL_CTR *val )
(for now at least)
*********************************************************************/
-static bool shares_store_subkey( const char *key, REGSUBKEY_CTR *subkeys )
+static bool shares_store_subkey( const char *key, struct regsubkey_ctr *subkeys )
{
return False;
}
diff --git a/source3/registry/reg_backend_smbconf.c b/source3/registry/reg_backend_smbconf.c
index 2e4a5f1c1d..8e1bbcab6f 100644
--- a/source3/registry/reg_backend_smbconf.c
+++ b/source3/registry/reg_backend_smbconf.c
@@ -25,16 +25,26 @@
extern REGISTRY_OPS regdb_ops; /* these are the default */
-static int smbconf_fetch_keys( const char *key, REGSUBKEY_CTR *subkey_ctr )
+static int smbconf_fetch_keys( const char *key, struct regsubkey_ctr *subkey_ctr )
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
-static bool smbconf_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
+static bool smbconf_store_keys( const char *key, struct regsubkey_ctr *subkeys )
{
return regdb_ops.store_subkeys(key, subkeys);
}
+static WERROR smbconf_create_subkey(const char *key, const char *subkey)
+{
+ return regdb_ops.create_subkey(key, subkey);
+}
+
+static WERROR smbconf_delete_subkey(const char *key, const char *subkey)
+{
+ return regdb_ops.delete_subkey(key, subkey);
+}
+
static int smbconf_fetch_values( const char *key, REGVAL_CTR *val )
{
return regdb_ops.fetch_values(key, val);
@@ -79,6 +89,8 @@ REGISTRY_OPS smbconf_reg_ops = {
.fetch_values = smbconf_fetch_values,
.store_subkeys = smbconf_store_keys,
.store_values = smbconf_store_values,
+ .create_subkey = smbconf_create_subkey,
+ .delete_subkey = smbconf_delete_subkey,
.reg_access_check = smbconf_reg_access_check,
.get_secdesc = smbconf_get_secdesc,
.set_secdesc = smbconf_set_secdesc,
diff --git a/source3/registry/reg_backend_tcpip_params.c b/source3/registry/reg_backend_tcpip_params.c
index db7df5dd8f..a6aa2fc2ea 100644
--- a/source3/registry/reg_backend_tcpip_params.c
+++ b/source3/registry/reg_backend_tcpip_params.c
@@ -56,7 +56,7 @@ static int tcpip_params_fetch_values(const char *key, REGVAL_CTR *regvals)
}
static int tcpip_params_fetch_subkeys(const char *key,
- REGSUBKEY_CTR *subkey_ctr)
+ struct regsubkey_ctr *subkey_ctr)
{
return regdb_ops.fetch_subkeys(key, subkey_ctr);
}
diff --git a/source3/registry/reg_dispatcher.c b/source3/registry/reg_dispatcher.c
index c160622054..f8c382536f 100644
--- a/source3/registry/reg_dispatcher.c
+++ b/source3/registry/reg_dispatcher.c
@@ -80,7 +80,7 @@ static WERROR construct_registry_sd(TALLOC_CTX *ctx, SEC_DESC **psd)
High level wrapper function for storing registry subkeys
***********************************************************************/
-bool store_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys )
+bool store_reg_keys( REGISTRY_KEY *key, struct regsubkey_ctr *subkeys )
{
if (key->ops && key->ops->store_subkeys)
return key->ops->store_subkeys(key->name, subkeys);
@@ -100,12 +100,30 @@ bool store_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
return false;
}
+WERROR create_reg_subkey(REGISTRY_KEY *key, const char *subkey)
+{
+ if (key->ops && key->ops->create_subkey) {
+ return key->ops->create_subkey(key->name, subkey);
+ }
+
+ return WERR_NOT_SUPPORTED;
+}
+
+WERROR delete_reg_subkey(REGISTRY_KEY *key, const char *subkey)
+{
+ if (key->ops && key->ops->delete_subkey) {
+ return key->ops->delete_subkey(key->name, subkey);
+ }
+
+ return WERR_NOT_SUPPORTED;
+}
+
/***********************************************************************
High level wrapper function for enumerating registry subkeys
Initialize the TALLOC_CTX if necessary
***********************************************************************/
-int fetch_reg_keys( REGISTRY_KEY *key, REGSUBKEY_CTR *subkey_ctr )
+int fetch_reg_keys( REGISTRY_KEY *key, struct regsubkey_ctr *subkey_ctr )
{
int result = -1;
@@ -143,7 +161,6 @@ bool regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
SEC_DESC *sec_desc;
NTSTATUS status;
WERROR err;
- TALLOC_CTX *mem_ctx;
/* use the default security check if the backend has not defined its
* own */
@@ -153,30 +170,20 @@ bool regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
granted, token);
}
- /*
- * The secdesc routines can't yet cope with a NULL talloc ctx sanely.
- */
-
- if (!(mem_ctx = talloc_init("regkey_access_check"))) {
- return false;
- }
-
- err = regkey_get_secdesc(mem_ctx, key, &sec_desc);
+ err = regkey_get_secdesc(talloc_tos(), key, &sec_desc);
if (!W_ERROR_IS_OK(err)) {
- TALLOC_FREE(mem_ctx);
return false;
}
se_map_generic( &requested, &reg_generic_map );
status =se_access_check(sec_desc, token, requested, granted);
+ TALLOC_FREE(sec_desc);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(mem_ctx);
return false;
}
- TALLOC_FREE(mem_ctx);
return NT_STATUS_IS_OK(status);
}
@@ -216,7 +223,7 @@ WERROR regkey_set_secdesc(REGISTRY_KEY *key,
* Check whether the in-memory version of the subkyes of a
* registry key needs update from disk.
*/
-bool reg_subkeys_need_update(REGISTRY_KEY *key, REGSUBKEY_CTR *subkeys)
+bool reg_subkeys_need_update(REGISTRY_KEY *key, struct regsubkey_ctr *subkeys)
{
if (key->ops && key->ops->subkeys_need_update)
{
diff --git a/source3/registry/reg_eventlog.c b/source3/registry/reg_eventlog.c
index 8994acf107..c02318beac 100644
--- a/source3/registry/reg_eventlog.c
+++ b/source3/registry/reg_eventlog.c
@@ -35,16 +35,18 @@ bool eventlog_init_keys(void)
const char **elogs = lp_eventlog_list();
char *evtlogpath = NULL;
char *evtfilepath = NULL;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
REGVAL_CTR *values;
uint32 uiMaxSize;
uint32 uiRetention;
uint32 uiCategoryCount;
UNISTR2 data;
TALLOC_CTX *ctx = talloc_tos();
+ WERROR werr;
while (elogs && *elogs) {
- if (!(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR ) ) ) {
+ werr = regsubkey_ctr_init(ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}
@@ -70,7 +72,8 @@ bool eventlog_init_keys(void)
DEBUG( 5,
( "Adding key of [%s] to path of [%s]\n", *elogs,
evtlogpath ) );
- if (!(subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR))) {
+ werr = regsubkey_ctr_init(ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}
@@ -197,7 +200,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
const char **elogs = lp_eventlog_list( );
char **wrklist, **wp;
char *evtlogpath = NULL;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
REGVAL_CTR *values;
REGISTRY_VALUE *rval;
UNISTR2 data;
@@ -207,6 +210,7 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
int i;
int numsources;
TALLOC_CTX *ctx = talloc_tos();
+ WERROR werr;
if (!elogs) {
return False;
@@ -315,7 +319,8 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
TALLOC_FREE(values);
TALLOC_FREE(wrklist); /* */
- if ( !( subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR ) ) ) {
+ werr = regsubkey_ctr_init(ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}
@@ -342,7 +347,8 @@ bool eventlog_add_source( const char *eventlog, const char *sourcename,
/* now allocate room for the source's subkeys */
- if ( !( subkeys = TALLOC_ZERO_P(ctx, REGSUBKEY_CTR ) ) ) {
+ werr = regsubkey_ctr_init(ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG( 0, ( "talloc() failure!\n" ) );
return False;
}
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index 47122ccad2..b975ced324 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -24,25 +24,135 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY
+struct regsubkey_ctr {
+ uint32_t num_subkeys;
+ char **subkeys;
+ struct db_context *subkeys_hash;
+ int seqnum;
+};
+
/**********************************************************************
- Note that the REGSUB_CTR and REGVAL_CTR objects *must* be talloc()'d
- since the methods use the object pointer as the talloc context for
- internal private data.
+ Note that the struct regsubkey_ctr and REGVAL_CTR objects *must* be
+ talloc()'d since the methods use the object pointer as the talloc
+ context for internal private data.
- There is no longer a regXXX_ctr_intit() and regXXX_ctr_destroy()
+ There is no longer a regval_ctr_intit() and regval_ctr_destroy()
pair of functions. Simply TALLOC_ZERO_P() and TALLOC_FREE() the
object.
**********************************************************************/
+WERROR regsubkey_ctr_init(TALLOC_CTX *mem_ctx, struct regsubkey_ctr **ctr)
+{
+ if (ctr == NULL) {
+ return WERR_INVALID_PARAM;
+ }
+
+ *ctr = talloc_zero(mem_ctx, struct regsubkey_ctr);
+ if (*ctr == NULL) {
+ return WERR_NOMEM;
+ }
+
+ (*ctr)->subkeys_hash = db_open_rbt(*ctr);
+ if ((*ctr)->subkeys_hash == NULL) {
+ talloc_free(*ctr);
+ return WERR_NOMEM;
+ }
+
+ return WERR_OK;
+}
+
+WERROR regsubkey_ctr_set_seqnum(struct regsubkey_ctr *ctr, int seqnum)
+{
+ if (ctr == NULL) {
+ return WERR_INVALID_PARAM;
+ }
+
+ ctr->seqnum = seqnum;
+
+ return WERR_OK;
+}
+
+int regsubkey_ctr_get_seqnum(struct regsubkey_ctr *ctr)
+{
+ if (ctr == NULL) {
+ return -1;
+ }
+
+ return ctr->seqnum;
+}
+
+static WERROR regsubkey_ctr_hash_keyname(struct regsubkey_ctr *ctr,
+ const char *keyname,
+ uint32 idx)
+{
+ WERROR werr;
+
+ werr = ntstatus_to_werror(dbwrap_store_bystring(ctr->subkeys_hash,
+ keyname,
+ make_tdb_data((uint8 *)&idx,
+ sizeof(idx)),
+ TDB_REPLACE));
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("error hashing new key '%s' in container: %s\n",
+ keyname, win_errstr(werr)));
+ }
+
+ return werr;
+}
+
+static WERROR regsubkey_ctr_unhash_keyname(struct regsubkey_ctr *ctr,
+ const char *keyname)
+{
+ WERROR werr;
+
+ werr = ntstatus_to_werror(dbwrap_delete_bystring(ctr->subkeys_hash,
+ keyname));
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(1, ("error unhashing key '%s' in container: %s\n",
+ keyname, win_errstr(werr)));
+ }
+
+ return werr;
+}
+
+static WERROR regsubkey_ctr_index_for_keyname(struct regsubkey_ctr *ctr,
+ const char *keyname,
+ uint32 *idx)
+{
+ TDB_DATA data;
+
+ if ((ctr == NULL) || (keyname == NULL)) {
+ return WERR_INVALID_PARAM;
+ }
+
+ data = dbwrap_fetch_bystring(ctr->subkeys_hash, ctr, keyname);
+ if (data.dptr == NULL) {
+ return WERR_NOT_FOUND;
+ }
+
+ if (data.dsize != sizeof(*idx)) {
+ talloc_free(data.dptr);
+ return WERR_INVALID_DATATYPE;
+ }
+
+ if (idx != NULL) {
+ *idx = *(uint32 *)data.dptr;
+ }
+
+ talloc_free(data.dptr);
+ return WERR_OK;
+}
+
/***********************************************************************
Add a new key to the array
**********************************************************************/
-WERROR regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname )
+WERROR regsubkey_ctr_addkey( struct regsubkey_ctr *ctr, const char *keyname )
{
char **newkeys;
+ WERROR werr;
if ( !keyname ) {
return WERR_OK;
@@ -68,6 +178,10 @@ WERROR regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname )
*/
return WERR_NOMEM;
}
+
+ werr = regsubkey_ctr_hash_keyname(ctr, keyname, ctr->num_subkeys);
+ W_ERROR_NOT_OK_RETURN(werr);
+
ctr->num_subkeys++;
return WERR_OK;
@@ -77,57 +191,64 @@ WERROR regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname )
Delete a key from the array
**********************************************************************/
-int regsubkey_ctr_delkey( REGSUBKEY_CTR *ctr, const char *keyname )
+WERROR regsubkey_ctr_delkey( struct regsubkey_ctr *ctr, const char *keyname )
{
- int i;
+ WERROR werr;
+ uint32 idx, j;
- if ( !keyname )
- return ctr->num_subkeys;
+ if (keyname == NULL) {
+ return WERR_INVALID_PARAM;
+ }
/* make sure the keyname is actually already there */
- for ( i=0; i<ctr->num_subkeys; i++ ) {
- if ( strequal( ctr->subkeys[i], keyname ) )
- break;
- }
+ werr = regsubkey_ctr_index_for_keyname(ctr, keyname, &idx);
+ W_ERROR_NOT_OK_RETURN(werr);
- if ( i == ctr->num_subkeys )
- return ctr->num_subkeys;
+ werr = regsubkey_ctr_unhash_keyname(ctr, keyname);
+ W_ERROR_NOT_OK_RETURN(werr);
/* update if we have any keys left */
ctr->num_subkeys--;
- if ( i < ctr->num_subkeys )
- memmove(&ctr->subkeys[i], &ctr->subkeys[i+1],
- sizeof(char*) * (ctr->num_subkeys-i));
+ if (idx < ctr->num_subkeys) {
+ memmove(&ctr->subkeys[idx], &ctr->subkeys[idx+1],
+ sizeof(char *) * (ctr->num_subkeys - idx));
+
+ /* we have to re-hash rest of the array... :-( */
+ for (j = idx; j < ctr->num_subkeys; j++) {
+ werr = regsubkey_ctr_hash_keyname(ctr, ctr->subkeys[j], j);
+ W_ERROR_NOT_OK_RETURN(werr);
+ }
+ }
- return ctr->num_subkeys;
+ return WERR_OK;
}
/***********************************************************************
Check for the existance of a key
**********************************************************************/
-bool regsubkey_ctr_key_exists( REGSUBKEY_CTR *ctr, const char *keyname )
+bool regsubkey_ctr_key_exists( struct regsubkey_ctr *ctr, const char *keyname )
{
- int i;
+ WERROR werr;
if (!ctr->subkeys) {
return False;
}
- for ( i=0; i<ctr->num_subkeys; i++ ) {
- if ( strequal( ctr->subkeys[i],keyname ) )
- return True;
+ werr = regsubkey_ctr_index_for_keyname(ctr, keyname, NULL);
+ if (!W_ERROR_IS_OK(werr)) {
+ return false;
}
- return False;
+ return true;
}
/***********************************************************************
How many keys does the container hold ?
**********************************************************************/
-int regsubkey_ctr_numkeys( REGSUBKEY_CTR *ctr )
+int regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr )
{
return ctr->num_subkeys;
}
@@ -136,7 +257,7 @@ int regsubkey_ctr_numkeys( REGSUBKEY_CTR *ctr )
Retreive a specific key string
**********************************************************************/
-char* regsubkey_ctr_specific_key( REGSUBKEY_CTR *ctr, uint32 key_index )
+char* regsubkey_ctr_specific_key( struct regsubkey_ctr *ctr, uint32_t key_index )
{
if ( ! (key_index < ctr->num_subkeys) )
return NULL;
diff --git a/source3/registry/regfio.c b/source3/registry/regfio.c
index 5395f225f1..d002bd72e7 100644
--- a/source3/registry/regfio.c
+++ b/source3/registry/regfio.c
@@ -1693,7 +1693,7 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
*******************************************************************/
REGF_NK_REC* regfio_write_key( REGF_FILE *file, const char *name,
- REGVAL_CTR *values, REGSUBKEY_CTR *subkeys,
+ REGVAL_CTR *values, struct regsubkey_ctr *subkeys,
SEC_DESC *sec_desc, REGF_NK_REC *parent )
{
REGF_NK_REC *nk;
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 19e9aae0f8..d76d20c962 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -137,6 +137,149 @@ WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
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;
+}
+
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_GetJob
+**********************************************************************/
+
+WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx,
+ struct policy_handle *handle,
+ uint32_t job_id,
+ uint32_t level,
+ uint32_t offered,
+ union spoolss_JobInfo *info)
+{
+ 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_GetJob(cli, mem_ctx,
+ handle,
+ job_id,
+ 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, needed);
+ W_ERROR_HAVE_NO_MEMORY(buffer.data);
+
+ status = rpccli_spoolss_GetJob(cli, mem_ctx,
+ handle,
+ job_id,
+ level,
+ &buffer,
+ offered,
+ info,
+ &needed,
+ &werror);
+ }
+
+ return werror;
+}
+
+
/*********************************************************************
Decode various spoolss rpc's and info levels
********************************************************************/
@@ -271,38 +414,6 @@ static bool decode_printer_info_3(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
/**********************************************************************
**********************************************************************/
-static bool decode_printer_info_7(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
- uint32 returned, PRINTER_INFO_7 **info)
-{
- uint32 i;
- PRINTER_INFO_7 *inf;
-
- if (returned) {
- inf=TALLOC_ARRAY(mem_ctx, PRINTER_INFO_7, returned);
- if (!inf) {
- return False;
- }
- memset(inf, 0, returned*sizeof(PRINTER_INFO_7));
- } else {
- inf = NULL;
- }
-
- prs_set_offset(&buffer->prs,0);
-
- for (i=0; i<returned; i++) {
- if (!smb_io_printer_info_7("", buffer, &inf[i], 0)) {
- return False;
- }
- }
-
- *info=inf;
- return True;
-}
-
-
-/**********************************************************************
-**********************************************************************/
-
static bool decode_port_info_1(TALLOC_CTX *mem_ctx, RPC_BUFFER *buffer,
uint32 returned, PORT_INFO_1 **info)
{
@@ -691,116 +802,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_enumprinterdrivers (struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
uint32 level, const char *env,
@@ -886,41 +887,6 @@ WERROR rpccli_spoolss_enumprinterdrivers (struct rpc_pipe_client *cli,
/**********************************************************************
**********************************************************************/
-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)
@@ -1051,73 +1017,6 @@ WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
/**********************************************************************
**********************************************************************/
-WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 jobid, uint32 level,
- JOB_INFO_CTR *ctr)
-{
- prs_struct qbuf, rbuf;
- SPOOL_Q_GETJOB in;
- SPOOL_R_GETJOB out;
- RPC_BUFFER buffer;
- uint32 offered;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- offered = 0;
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_getjob( &in, hnd, jobid, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_GETJOB,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_getjob,
- spoolss_io_r_getjob,
- WERR_GENERAL_FAILURE );
-
- if ( W_ERROR_EQUAL( out.status, WERR_MORE_DATA ) ) {
- offered = out.needed;
-
- ZERO_STRUCT(in);
- ZERO_STRUCT(out);
-
- if (!rpcbuf_init(&buffer, offered, mem_ctx))
- return WERR_NOMEM;
- make_spoolss_q_getjob( &in, hnd, jobid, level, &buffer, offered );
-
- CLI_DO_RPC_WERR( cli, mem_ctx, &syntax_spoolss, SPOOLSS_GETJOB,
- in, out,
- qbuf, rbuf,
- spoolss_io_q_getjob,
- spoolss_io_r_getjob,
- WERR_GENERAL_FAILURE );
- }
-
- if (!W_ERROR_IS_OK(out.status))
- return out.status;
-
- switch(level) {
- case 1:
- if (!decode_jobs_1(mem_ctx, out.buffer, 1, &ctr->job.job_info_1)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- case 2:
- if (!decode_jobs_2(mem_ctx, out.buffer, 1, &ctr->job.job_info_2)) {
- return WERR_GENERAL_FAILURE;
- }
- break;
- default:
- return WERR_UNKNOWN_LEVEL;
- }
-
- return out.status;
-}
-
-/**********************************************************************
-**********************************************************************/
-
WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, const char *valuename,
REGISTRY_VALUE *value)
@@ -1359,5 +1258,4 @@ WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli, TALLOC_CTX *me
return out.status;
}
-
/** @} **/
diff --git a/source3/rpc_client/rpc_transport_sock.c b/source3/rpc_client/rpc_transport_sock.c
index c0fa41b0de..b1d9d8fbe1 100644
--- a/source3/rpc_client/rpc_transport_sock.c
+++ b/source3/rpc_client/rpc_transport_sock.c
@@ -35,6 +35,12 @@ static int rpc_transport_sock_state_destructor(struct rpc_transport_sock_state *
return 0;
}
+struct rpc_sock_read_state {
+ ssize_t received;
+};
+
+static void rpc_sock_read_done(struct tevent_req *subreq);
+
static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
uint8_t *data, size_t size,
@@ -42,25 +48,61 @@ static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
{
struct rpc_transport_sock_state *sock_transp = talloc_get_type_abort(
priv, struct rpc_transport_sock_state);
- return async_recv(mem_ctx, ev, sock_transp->fd, data, size, 0);
+ struct async_req *result;
+ struct tevent_req *subreq;
+ struct rpc_sock_read_state *state;
+
+ if (!async_req_setup(mem_ctx, &result, &state,
+ struct rpc_sock_read_state)) {
+ return NULL;
+ }
+
+ subreq = async_recv_send(state, ev, sock_transp->fd, data, size, 0);
+ if (subreq == NULL) {
+ goto fail;
+ }
+ tevent_req_set_callback(subreq, rpc_sock_read_done, result);
+ return result;
+ fail:
+ TALLOC_FREE(result);
+ return NULL;
}
-static NTSTATUS rpc_sock_read_recv(struct async_req *req, ssize_t *preceived)
+static void rpc_sock_read_done(struct tevent_req *subreq)
{
- ssize_t received;
- int sys_errno;
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
+ struct rpc_sock_read_state *state = talloc_get_type_abort(
+ req->private_data, struct rpc_sock_read_state);
+ int err;
- received = async_syscall_result_ssize_t(req, &sys_errno);
- if (received == -1) {
- return map_nt_error_from_unix(sys_errno);
+ state->received = async_recv_recv(subreq, &err);
+ if (state->received == -1) {
+ async_req_nterror(req, map_nt_error_from_unix(err));
+ return;
}
- if (received == 0) {
- return NT_STATUS_END_OF_FILE;
+ async_req_done(req);
+}
+
+static NTSTATUS rpc_sock_read_recv(struct async_req *req, ssize_t *preceived)
+{
+ struct rpc_sock_read_state *state = talloc_get_type_abort(
+ req->private_data, struct rpc_sock_read_state);
+ NTSTATUS status;
+
+ if (async_req_is_nterror(req, &status)) {
+ return status;
}
- *preceived = received;
+ *preceived = state->received;
return NT_STATUS_OK;
}
+struct rpc_sock_write_state {
+ ssize_t sent;
+};
+
+static void rpc_sock_write_done(struct tevent_req *subreq);
+
static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
struct event_context *ev,
const uint8_t *data, size_t size,
@@ -68,19 +110,51 @@ static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
{
struct rpc_transport_sock_state *sock_transp = talloc_get_type_abort(
priv, struct rpc_transport_sock_state);
- return async_send(mem_ctx, ev, sock_transp->fd, data, size, 0);
+ struct async_req *result;
+ struct tevent_req *subreq;
+ struct rpc_sock_write_state *state;
+
+ if (!async_req_setup(mem_ctx, &result, &state,
+ struct rpc_sock_write_state)) {
+ return NULL;
+ }
+ subreq = async_send_send(state, ev, sock_transp->fd, data, size, 0);
+ if (subreq == NULL) {
+ goto fail;
+ }
+ tevent_req_set_callback(subreq, rpc_sock_write_done, result);
+ return result;
+ fail:
+ TALLOC_FREE(result);
+ return NULL;
+}
+
+static void rpc_sock_write_done(struct tevent_req *subreq)
+{
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
+ struct rpc_sock_write_state *state = talloc_get_type_abort(
+ req->private_data, struct rpc_sock_write_state);
+ int err;
+
+ state->sent = async_send_recv(subreq, &err);
+ if (state->sent == -1) {
+ async_req_nterror(req, map_nt_error_from_unix(err));
+ return;
+ }
+ async_req_done(req);
}
static NTSTATUS rpc_sock_write_recv(struct async_req *req, ssize_t *psent)
{
- ssize_t sent;
- int sys_errno;
+ struct rpc_sock_write_state *state = talloc_get_type_abort(
+ req->private_data, struct rpc_sock_write_state);
+ NTSTATUS status;
- sent = async_syscall_result_ssize_t(req, &sys_errno);
- if (sent == -1) {
- return map_nt_error_from_unix(sys_errno);
+ if (async_req_is_nterror(req, &status)) {
+ return status;
}
- *psent = sent;
+ *psent = state->sent;
return NT_STATUS_OK;
}
diff --git a/source3/rpc_parse/parse_sec.c b/source3/rpc_parse/parse_sec.c
index 23c9610381..91d8591a05 100644
--- a/source3/rpc_parse/parse_sec.c
+++ b/source3/rpc_parse/parse_sec.c
@@ -73,11 +73,11 @@ static bool sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps,
if (!prs_uint32("obj_flags", ps, depth, &psa->object.object.flags))
return False;
- if (psa->object.object.flags & SEC_ACE_OBJECT_PRESENT)
+ if (psa->object.object.flags & SEC_ACE_OBJECT_TYPE_PRESENT)
if (!smb_io_uuid("obj_guid", &psa->object.object.type.type, ps,depth))
return False;
- if (psa->object.object.flags & SEC_ACE_OBJECT_INHERITED_PRESENT)
+ if (psa->object.object.flags & SEC_ACE_INHERITED_OBJECT_TYPE_PRESENT)
if (!smb_io_uuid("inh_guid", &psa->object.object.inherited_type.inherited_type, ps,depth))
return False;
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 12c7af49cf..78c041f863 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.
********************************************************************/
@@ -2291,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)
@@ -2791,316 +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;
-}
-
-/*******************************************************************
make a BUFFER5 struct from a uint16*
******************************************************************/
@@ -3125,37 +2324,6 @@ bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16
}
/*******************************************************************
- ********************************************************************/
-
-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)
@@ -3931,20 +3099,3 @@ bool make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle,
return True;
}
-
-/*******************************************************************
- * init a structure.
- ********************************************************************/
-
-bool make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle,
- uint32 jobid, uint32 level, RPC_BUFFER *buffer,
- uint32 offered)
-{
- memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
- q_u->jobid = jobid;
- q_u->level = level;
- q_u->buffer = buffer;
- q_u->offered = offered;
-
- return True;
-}
diff --git a/source3/rpc_server/srv_eventlog_lib.c b/source3/rpc_server/srv_eventlog_lib.c
index edd1cfacb8..f83c4fc3b8 100644
--- a/source3/rpc_server/srv_eventlog_lib.c
+++ b/source3/rpc_server/srv_eventlog_lib.c
@@ -936,7 +936,7 @@ NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx,
size_t len;
if (!convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
t->sid.data, t->sid.length,
- &sid_str, &len, false)) {
+ (void **)&sid_str, &len, false)) {
return NT_STATUS_INVALID_SID;
}
if (len > 0) {
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 33e89c8acb..a5d059c06a 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -1247,14 +1247,13 @@ static void np_write_trigger(struct async_req *req)
if (async_req_nomem(subreq, req)) {
return;
}
- subreq->async.fn = np_write_done;
- subreq->async.private_data = req;
+ tevent_req_set_callback(subreq, np_write_done, req);
}
static void np_write_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct np_write_state *state = talloc_get_type_abort(
req->private_data, struct np_write_state);
ssize_t received;
@@ -1398,14 +1397,13 @@ static void np_read_trigger(struct async_req *req)
if (async_req_nomem(subreq, req)) {
return;
}
- subreq->async.fn = np_read_done;
- subreq->async.private_data = req;
+ tevent_req_set_callback(subreq, np_read_done, req);
}
static void np_read_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct np_read_state *state = talloc_get_type_abort(
req->private_data, struct np_read_state);
ssize_t received;
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 62301c001b..814f406e87 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -110,7 +110,7 @@ static int nt_printj_status(int v)
case LPQ_DELETED:
return JOB_STATUS_DELETED;
case LPQ_BLOCKED:
- return JOB_STATUS_BLOCKED;
+ return JOB_STATUS_BLOCKED_DEVQ;
case LPQ_USER_INTERVENTION:
return JOB_STATUS_USER_INTERVENTION;
}
@@ -3486,7 +3486,6 @@ static const struct s_notify_info_data_table notify_info_data_table[] =
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_PAGES, "JOB_NOTIFY_TOTAL_PAGES", NOTIFY_TABLE_DWORD, spoolss_notify_total_pages },
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_PAGES_PRINTED, "JOB_NOTIFY_PAGES_PRINTED", NOTIFY_TABLE_DWORD, spoolss_notify_pages_printed },
{ JOB_NOTIFY_TYPE, JOB_NOTIFY_TOTAL_BYTES, "JOB_NOTIFY_TOTAL_BYTES", NOTIFY_TABLE_DWORD, spoolss_notify_job_size },
-{ PRINT_TABLE_END, 0x0, NULL, 0x0, NULL },
};
/*******************************************************************
@@ -3519,7 +3518,7 @@ static bool search_notify(enum spoolss_NotifyType type,
{
int i;
- for (i = 0; notify_info_data_table[i].type != PRINT_TABLE_END; i++) {
+ for (i = 0; i < ARRAY_SIZE(notify_info_data_table); i++) {
if (notify_info_data_table[i].type == type &&
notify_info_data_table[i].field == field &&
notify_info_data_table[i].fn != NULL) {
@@ -4354,10 +4353,10 @@ static bool construct_printer_info_7(Printer_entry *print_hnd, PRINTER_INFO_7 *p
strupper_m(guid_str);
init_unistr(&printer->guid, guid_str);
SAFE_FREE(guid_str);
- printer->action = SPOOL_DS_PUBLISH;
+ printer->action = DSPRINT_PUBLISH;
} else {
init_unistr(&printer->guid, "");
- printer->action = SPOOL_DS_UNPUBLISH;
+ printer->action = DSPRINT_UNPUBLISH;
}
return True;
@@ -6619,6 +6618,10 @@ WERROR _spoolss_AddJob(pipes_struct *p,
/* this is what a NT server returns for AddJob. AddJob must fail on
* non-local printers */
+ if (r->in.level != 1) {
+ return WERR_UNKNOWN_LEVEL;
+ }
+
return WERR_INVALID_PARAM;
}
@@ -8180,28 +8183,21 @@ WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p,
return WERR_INVALID_PARAM;
}
- if (r->in.offered > MAX_RPC_DATA_SIZE) {
- return WERR_INVALID_PARAM;
- }
-
- DEBUG(4,("_spoolss_GetPrinterDriverDirectory\n"));
+ DEBUG(5,("_spoolss_GetPrinterDriverDirectory: level %d\n",
+ r->in.level));
*r->out.needed = 0;
- switch (r->in.level) {
- case 1:
- werror = getprinterdriverdir_level_1(p->mem_ctx,
- r->in.server,
- r->in.environment,
- &r->out.info->info1,
- r->in.offered,
- r->out.needed);
- if (!W_ERROR_IS_OK(werror)) {
- TALLOC_FREE(r->out.info);
- }
- break;
- default:
- return WERR_UNKNOWN_LEVEL;
+ /* r->in.level is ignored */
+
+ werror = getprinterdriverdir_level_1(p->mem_ctx,
+ r->in.server,
+ r->in.environment,
+ &r->out.info->info1,
+ r->in.offered,
+ r->out.needed);
+ if (!W_ERROR_IS_OK(werror)) {
+ TALLOC_FREE(r->out.info);
}
return werror;
@@ -9834,28 +9830,21 @@ WERROR _spoolss_GetPrintProcessorDirectory(pipes_struct *p,
return WERR_INVALID_PARAM;
}
- if (r->in.offered > MAX_RPC_DATA_SIZE) {
- return WERR_INVALID_PARAM;
- }
-
- DEBUG(5,("_spoolss_GetPrintProcessorDirectory\n"));
+ DEBUG(5,("_spoolss_GetPrintProcessorDirectory: level %d\n",
+ r->in.level));
*r->out.needed = 0;
- switch (r->in.level) {
- case 1:
- result = getprintprocessordirectory_level_1(p->mem_ctx,
- r->in.server,
- r->in.environment,
- &r->out.info->info1,
- r->in.offered,
- r->out.needed);
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(r->out.info);
- }
- break;
- default:
- result = WERR_UNKNOWN_LEVEL;
+ /* r->in.level is ignored */
+
+ result = getprintprocessordirectory_level_1(p->mem_ctx,
+ r->in.server,
+ r->in.environment,
+ &r->out.info->info1,
+ r->in.offered,
+ r->out.needed);
+ if (!W_ERROR_IS_OK(result)) {
+ TALLOC_FREE(r->out.info);
}
return result;
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 9955d2d3fa..45df488018 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -1107,6 +1107,49 @@ static NTSTATUS cmd_netlogon_database_redo(struct rpc_pipe_client *cli,
return status;
}
+static NTSTATUS cmd_netlogon_capabilities(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
+ struct netr_Authenticator credential;
+ struct netr_Authenticator return_authenticator;
+ union netr_Capabilities capabilities;
+ uint32_t level = 1;
+
+ if (argc > 2) {
+ fprintf(stderr, "Usage: %s <level>\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ if (argc == 2) {
+ level = atoi(argv[1]);
+ }
+
+#if 0
+ netlogon_creds_client_step(cli->dc, &credential);
+#else
+ ZERO_STRUCT(credential);
+#endif
+
+ status = rpccli_netr_LogonGetCapabilities(cli, mem_ctx,
+ cli->desthost,
+ global_myname(),
+ &credential,
+ &return_authenticator,
+ level,
+ &capabilities);
+#if 0
+ if (!netlogon_creds_client_check(cli->dc,
+ &return_authenticator.cred)) {
+ DEBUG(0,("credentials chain check failed\n"));
+ return NT_STATUS_ACCESS_DENIED;
+ }
+#endif
+
+ return status;
+}
+
/* List of commands exported by this module */
struct cmd_set netlogon_commands[] = {
@@ -1134,6 +1177,7 @@ struct cmd_set netlogon_commands[] = {
{ "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains", "" },
{ "getdcsitecoverage", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcsitecoverage, &ndr_table_netlogon.syntax_id, NULL, "Get the Site-Coverage from a DC", "" },
{ "database_redo", RPC_RTYPE_NTSTATUS, cmd_netlogon_database_redo, NULL, &ndr_table_netlogon.syntax_id, NULL, "Replicate single object from a DC", "" },
+ { "capabilities", RPC_RTYPE_NTSTATUS, cmd_netlogon_capabilities, NULL, &ndr_table_netlogon.syntax_id, NULL, "Return Capabilities", "" },
{ NULL }
};
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 31977e9554..936c2081f3 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -789,7 +789,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
struct samr_SamArray *dom_users = NULL;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
uint32 acb_mask = ACB_NORMAL;
- bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 1) || (argc > 3)) {
printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]);
@@ -811,8 +810,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- got_connect_pol = True;
-
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(cli, mem_ctx,
@@ -824,8 +821,6 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- got_domain_pol = True;
-
/* Enumerate domain users */
start_idx = 0;
@@ -852,10 +847,10 @@ static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
- if (got_domain_pol)
+ if (is_valid_policy_hnd(&domain_pol))
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
- if (got_connect_pol)
+ if (is_valid_policy_hnd(&connect_pol))
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
@@ -872,7 +867,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
uint32 start_idx, size, num_dom_groups, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
struct samr_SamArray *dom_groups = NULL;
- bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 1) || (argc > 2)) {
printf("Usage: %s [access_mask]\n", argv[0]);
@@ -891,8 +885,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- got_connect_pol = True;
-
/* Get domain policy handle */
result = rpccli_samr_OpenDomain(cli, mem_ctx,
@@ -904,8 +896,6 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- got_domain_pol = True;
-
/* Enumerate domain groups */
start_idx = 0;
@@ -930,10 +920,10 @@ static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
- if (got_domain_pol)
+ if (is_valid_policy_hnd(&domain_pol))
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
- if (got_connect_pol)
+ if (is_valid_policy_hnd(&connect_pol))
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
@@ -950,7 +940,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
uint32 start_idx, size, num_als_groups, i;
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
struct samr_SamArray *als_groups = NULL;
- bool got_connect_pol = False, got_domain_pol = False;
if ((argc < 2) || (argc > 3)) {
printf("Usage: %s builtin|domain [access mask]\n", argv[0]);
@@ -969,8 +958,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- got_connect_pol = True;
-
/* Get domain policy handle */
result = get_domain_handle(cli, mem_ctx, argv[1],
@@ -982,8 +969,6 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
if (!NT_STATUS_IS_OK(result))
goto done;
- got_domain_pol = True;
-
/* Enumerate alias groups */
start_idx = 0;
@@ -1008,10 +993,10 @@ static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
- if (got_domain_pol)
+ if (is_valid_policy_hnd(&domain_pol))
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
- if (got_connect_pol)
+ if (is_valid_policy_hnd(&connect_pol))
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
return result;
@@ -1027,7 +1012,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
uint32 start_idx, size, num_entries, i;
uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
- bool got_connect_pol = false;
struct samr_SamArray *sam = NULL;
if ((argc < 1) || (argc > 2)) {
@@ -1049,8 +1033,6 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
goto done;
}
- got_connect_pol = true;
-
/* Enumerate alias groups */
start_idx = 0;
@@ -1075,7 +1057,7 @@ static NTSTATUS cmd_samr_enum_domains(struct rpc_pipe_client *cli,
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
done:
- if (got_connect_pol) {
+ if (is_valid_policy_hnd(&connect_pol)) {
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
}
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 17ff818de6..5b55ac3e2a 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,36 @@ 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;
+ info.info2.secdesc = NULL;
+ info.info2.devmode = NULL;
- 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 +543,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 +576,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 +620,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 +644,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 +669,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 +754,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 +782,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 +796,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 +812,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 +847,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 +894,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;
@@ -1058,7 +1082,6 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli,
POLICY_HND pol;
WERROR werror;
uint32 info_level = 3;
- bool opened_hnd = False;
const char *printername;
uint32 i;
bool success = False;
@@ -1090,8 +1113,6 @@ 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++) {
@@ -1133,7 +1154,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 )
@@ -1489,14 +1510,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)
@@ -1506,9 +1521,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];
@@ -1536,25 +1549,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]);
@@ -1570,11 +1566,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)
@@ -1594,15 +1595,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;
@@ -1610,10 +1609,20 @@ 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.info2.devmode = NULL;
+ info.info2.secdesc = NULL;
+ 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;;
@@ -1624,7 +1633,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;
@@ -1808,14 +1817,15 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
WERROR werror;
NTSTATUS status;
const char *printername;
- bool got_handle = False;
union spoolss_AddFormInfo info;
struct spoolss_AddFormInfo1 info1;
+ struct spoolss_AddFormInfo2 info2;
+ uint32_t level = 1;
/* Parse the command arguments */
- if (argc != 3) {
- printf ("Usage: %s <printer> <formname>\n", argv[0]);
+ if (argc < 3 || argc > 5) {
+ printf ("Usage: %s <printer> <formname> [level]\n", argv[0]);
return WERR_OK;
}
@@ -1830,32 +1840,58 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
if (!W_ERROR_IS_OK(werror))
goto done;
- got_handle = True;
-
/* Dummy up some values for the form data */
- info1.flags = FORM_USER;
- info1.form_name = argv[2];
- info1.size.width = 100;
- info1.size.height = 100;
- info1.area.left = 0;
- info1.area.top = 10;
- info1.area.right = 20;
- info1.area.bottom = 30;
+ if (argc == 4) {
+ level = atoi(argv[3]);
+ }
- info.info1 = &info1;
+ switch (level) {
+ case 1:
+ info1.flags = FORM_USER;
+ info1.form_name = argv[2];
+ info1.size.width = 100;
+ info1.size.height = 100;
+ info1.area.left = 0;
+ info1.area.top = 10;
+ info1.area.right = 20;
+ info1.area.bottom = 30;
+
+ info.info1 = &info1;
+
+ break;
+ case 2:
+ info2.flags = FORM_USER;
+ info2.form_name = argv[2];
+ info2.size.width = 100;
+ info2.size.height = 100;
+ info2.area.left = 0;
+ info2.area.top = 10;
+ info2.area.right = 20;
+ info2.area.bottom = 30;
+ info2.keyword = argv[2];
+ info2.string_type = SPOOLSS_FORM_STRING_TYPE_NONE;
+ info2.mui_dll = NULL;
+ info2.ressource_id = 0;
+ info2.display_name = argv[2];
+ info2.lang_id = 0;
+
+ info.info2 = &info2;
+
+ break;
+ }
/* Add the form */
status = rpccli_spoolss_AddForm(cli, mem_ctx,
&handle,
- 1,
+ level,
info,
&werror);
done:
- if (got_handle)
+ if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror;
@@ -1871,7 +1907,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
WERROR werror;
NTSTATUS status;
const char *printername;
- bool got_handle = False;
union spoolss_AddFormInfo info;
struct spoolss_AddFormInfo1 info1;
@@ -1893,8 +1928,6 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
if (!W_ERROR_IS_OK(werror))
goto done;
- got_handle = True;
-
/* Dummy up some values for the form data */
info1.flags = FORM_PRINTER;
@@ -1918,7 +1951,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
&werror);
done:
- if (got_handle)
+ if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror;
@@ -1980,6 +2013,28 @@ static void display_form_info1(struct spoolss_FormInfo1 *r)
/****************************************************************************
****************************************************************************/
+static void display_form_info2(struct spoolss_FormInfo2 *r)
+{
+ printf("%s\n" \
+ "\tflag: %s (%d)\n" \
+ "\twidth: %d, length: %d\n" \
+ "\tleft: %d, right: %d, top: %d, bottom: %d\n",
+ r->form_name, get_form_flag(r->flags), r->flags,
+ r->size.width, r->size.height,
+ r->area.left, r->area.right,
+ r->area.top, r->area.bottom);
+ printf("\tkeyword: %s\n", r->keyword);
+ printf("\tstring_type: 0x%08x\n", r->string_type);
+ printf("\tmui_dll: %s\n", r->mui_dll);
+ printf("\tressource_id: 0x%08x\n", r->ressource_id);
+ printf("\tdisplay_name: %s\n", r->display_name);
+ printf("\tlang_id: %d\n", r->lang_id);
+ printf("\n");
+}
+
+/****************************************************************************
+****************************************************************************/
+
static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
int argc, const char **argv)
{
@@ -1987,16 +2042,16 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
WERROR werror;
NTSTATUS status;
const char *printername;
- bool got_handle = False;
DATA_BLOB buffer;
uint32_t offered = 0;
union spoolss_FormInfo info;
uint32_t needed;
+ uint32_t level = 1;
/* Parse the command arguments */
- if (argc != 3) {
- printf ("Usage: %s <printer> <formname>\n", argv[0]);
+ if (argc < 3 || argc > 5) {
+ printf ("Usage: %s <printer> <formname> [level]\n", argv[0]);
return WERR_OK;
}
@@ -2011,26 +2066,28 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
if (!W_ERROR_IS_OK(werror))
goto done;
- got_handle = True;
+ if (argc == 4) {
+ level = atoi(argv[3]);
+ }
/* Get the form */
status = rpccli_spoolss_GetForm(cli, mem_ctx,
&handle,
argv[2],
- 1,
+ level,
NULL,
offered,
&info,
&needed,
&werror);
if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
- buffer = data_blob_talloc(mem_ctx, NULL, needed);
+ buffer = data_blob_talloc_zero(mem_ctx, needed);
offered = needed;
status = rpccli_spoolss_GetForm(cli, mem_ctx,
&handle,
argv[2],
- 1,
+ level,
&buffer,
offered,
&info,
@@ -2042,9 +2099,17 @@ static WERROR cmd_spoolss_getform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c
return werror;
}
- display_form_info1(&info.info1);
+ switch (level) {
+ case 1:
+ display_form_info1(&info.info1);
+ break;
+ case 2:
+ display_form_info2(&info.info2);
+ break;
+ }
+
done:
- if (got_handle)
+ if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror;
@@ -2061,7 +2126,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
WERROR werror;
NTSTATUS status;
const char *printername;
- bool got_handle = False;
/* Parse the command arguments */
@@ -2081,8 +2145,6 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(werror))
goto done;
- got_handle = True;
-
/* Delete the form */
status = rpccli_spoolss_DeleteForm(cli, mem_ctx,
@@ -2094,7 +2156,7 @@ static WERROR cmd_spoolss_deleteform(struct rpc_pipe_client *cli,
}
done:
- if (got_handle)
+ if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror;
@@ -2110,7 +2172,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
POLICY_HND handle;
WERROR werror;
const char *printername;
- bool got_handle = False;
uint32 num_forms, level = 1, i;
FORM_1 *forms;
@@ -2132,8 +2193,6 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(werror))
goto done;
- got_handle = True;
-
/* Enumerate forms */
werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms);
@@ -2150,7 +2209,7 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
}
done:
- if (got_handle)
+ if (is_valid_policy_hnd(&handle))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
return werror;
@@ -2166,9 +2225,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();
@@ -2216,17 +2273,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 */
@@ -2306,18 +2362,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;
@@ -2368,13 +2427,53 @@ static void display_job_info_2(JOB_INFO_2 *job)
/****************************************************************************
****************************************************************************/
+static void display_job_info1(struct spoolss_JobInfo1 *r)
+{
+ printf("%d: jobid[%d]: %s %s %s %d/%d pages\n", r->position, r->job_id,
+ r->user_name, r->document_name, r->text_status, r->pages_printed,
+ r->total_pages);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static void display_job_info2(struct spoolss_JobInfo2 *r)
+{
+ printf("%d: jobid[%d]: %s %s %s %d/%d pages, %d bytes\n",
+ r->position, r->job_id,
+ r->user_name, r->document_name, r->text_status, r->pages_printed,
+ r->total_pages, r->size);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static void display_job_info3(struct spoolss_JobInfo3 *r)
+{
+ printf("jobid[%d], next_jobid[%d]\n",
+ r->job_id, r->next_job_id);
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static void display_job_info4(struct spoolss_JobInfo4 *r)
+{
+ printf("%d: jobid[%d]: %s %s %s %d/%d pages, %d/%d bytes\n",
+ r->position, r->job_id,
+ r->user_name, r->document_name, r->text_status, r->pages_printed,
+ r->total_pages, r->size, r->size_high);
+}
+
+/****************************************************************************
+****************************************************************************/
+
static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
WERROR result;
uint32 level = 1, num_jobs, i;
- bool got_hnd = False;
const char *printername;
POLICY_HND hnd;
JOB_INFO_CTR ctr;
@@ -2398,8 +2497,6 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- got_hnd = True;
-
/* Enumerate ports */
result = rpccli_spoolss_enumjobs(cli, mem_ctx, &hnd, level, 0, 1000,
@@ -2423,7 +2520,7 @@ static WERROR cmd_spoolss_enum_jobs(struct rpc_pipe_client *cli,
}
done:
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
return result;
@@ -2432,13 +2529,89 @@ done:
/****************************************************************************
****************************************************************************/
+static WERROR cmd_spoolss_get_job(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ WERROR result;
+ const char *printername;
+ struct policy_handle hnd;
+ uint32_t job_id;
+ uint32_t level = 1;
+ union spoolss_JobInfo info;
+
+ if (argc < 3 || argc > 4) {
+ printf("Usage: %s printername job_id [level]\n", argv[0]);
+ return WERR_OK;
+ }
+
+ job_id = atoi(argv[2]);
+
+ if (argc == 4) {
+ level = atoi(argv[3]);
+ }
+
+ /* Open printer handle */
+
+ RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
+
+ result = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
+ printername,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &hnd);
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
+ /* Enumerate ports */
+
+ result = rpccli_spoolss_getjob(cli, mem_ctx,
+ &hnd,
+ job_id,
+ level,
+ 0,
+ &info);
+
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
+ switch (level) {
+ case 1:
+ display_job_info1(&info.info1);
+ break;
+ case 2:
+ display_job_info2(&info.info2);
+ break;
+ case 3:
+ display_job_info3(&info.info3);
+ break;
+ case 4:
+ display_job_info4(&info.info4);
+ break;
+ default:
+ d_printf("unknown info level %d\n", level);
+ break;
+ }
+
+done:
+ if (is_valid_policy_hnd(&hnd)) {
+ rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
+ }
+
+ return result;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx, int argc,
const char **argv)
{
WERROR result;
uint32 i=0, val_needed, data_needed;
- bool got_hnd = False;
const char *printername;
POLICY_HND hnd;
@@ -2458,8 +2631,6 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- got_hnd = True;
-
/* Enumerate data */
result = rpccli_spoolss_enumprinterdata(cli, mem_ctx, &hnd, i, 0, 0,
@@ -2477,7 +2648,7 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
result = W_ERROR(ERRsuccess);
done:
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
return result;
@@ -2492,7 +2663,6 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
{
WERROR result;
uint32 i;
- bool got_hnd = False;
const char *printername;
const char *keyname = NULL;
POLICY_HND hnd;
@@ -2516,8 +2686,6 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- got_hnd = True;
-
/* Enumerate subkeys */
if ( !(ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) )
@@ -2535,7 +2703,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
TALLOC_FREE( ctr );
done:
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
return result;
@@ -2549,7 +2717,6 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
const char **argv)
{
WERROR result;
- bool got_hnd = False;
const char *printername;
const char *keyname = NULL;
POLICY_HND hnd;
@@ -2576,8 +2743,6 @@ static WERROR cmd_spoolss_enum_printerkey( struct rpc_pipe_client *cli,
if (!W_ERROR_IS_OK(result))
goto done;
- got_hnd = True;
-
/* Enumerate subkeys */
result = rpccli_spoolss_enumprinterkey(cli, mem_ctx, &hnd, keyname, &keylist, NULL);
@@ -2601,7 +2766,7 @@ done:
SAFE_FREE(keylist);
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
return result;
@@ -2617,7 +2782,6 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
const char *printername;
const char *clientname;
POLICY_HND hnd;
- bool got_hnd = False;
WERROR result;
NTSTATUS status;
struct spoolss_NotifyOption option;
@@ -2641,8 +2805,6 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
goto done;
}
- got_hnd = True;
-
/* Create spool options */
option.version = 2;
@@ -2694,7 +2856,7 @@ static WERROR cmd_spoolss_rffpcnex(struct rpc_pipe_client *cli,
}
done:
- if (got_hnd)
+ if (is_valid_policy_hnd(&hnd))
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
return result;
@@ -2706,12 +2868,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);
@@ -2720,7 +2886,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);
@@ -2739,7 +2909,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;
@@ -2747,7 +2917,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;
@@ -2756,7 +2930,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;
@@ -2767,14 +2945,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");
@@ -2905,6 +3077,7 @@ struct cmd_set spoolss_commands[] = {
{ "enumdataex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_data_ex, &syntax_spoolss, NULL, "Enumerate printer data for a key", "" },
{ "enumkey", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printerkey, &syntax_spoolss, NULL, "Enumerate printer keys", "" },
{ "enumjobs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_jobs, &syntax_spoolss, NULL, "Enumerate print jobs", "" },
+ { "getjob", RPC_RTYPE_WERROR, NULL, cmd_spoolss_get_job, &syntax_spoolss, NULL, "Get print job", "" },
{ "enumports", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_ports, &syntax_spoolss, NULL, "Enumerate printer ports", "" },
{ "enumdrivers", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_drivers, &syntax_spoolss, NULL, "Enumerate installed printer drivers", "" },
{ "enumprinters", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_printers, &syntax_spoolss, NULL, "Enumerate printers", "" },
diff --git a/source3/services/services_db.c b/source3/services/services_db.c
index ef975cfbc4..7a4b90c7cf 100644
--- a/source3/services/services_db.c
+++ b/source3/services/services_db.c
@@ -332,14 +332,14 @@ static void fill_service_values( const char *name, REGVAL_CTR *values )
/********************************************************************
********************************************************************/
-static void add_new_svc_name( REGISTRY_KEY *key_parent, REGSUBKEY_CTR *subkeys,
+static void add_new_svc_name( REGISTRY_KEY *key_parent, struct regsubkey_ctr *subkeys,
const char *name )
{
REGISTRY_KEY *key_service = NULL, *key_secdesc = NULL;
WERROR wresult;
char *path = NULL;
REGVAL_CTR *values = NULL;
- REGSUBKEY_CTR *svc_subkeys = NULL;
+ struct regsubkey_ctr *svc_subkeys = NULL;
SEC_DESC *sd = NULL;
DATA_BLOB sd_blob;
NTSTATUS status;
@@ -366,7 +366,8 @@ static void add_new_svc_name( REGISTRY_KEY *key_parent, REGSUBKEY_CTR *subkeys,
/* add the 'Security' key */
- if ( !(svc_subkeys = TALLOC_ZERO_P( key_service, REGSUBKEY_CTR )) ) {
+ wresult = regsubkey_ctr_init(key_service, &svc_subkeys);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("add_new_svc_name: talloc() failed!\n"));
TALLOC_FREE( key_service );
return;
@@ -444,7 +445,7 @@ void svcctl_init_keys( void )
{
const char **service_list = lp_svcctl_list();
int i;
- REGSUBKEY_CTR *subkeys = NULL;
+ struct regsubkey_ctr *subkeys = NULL;
REGISTRY_KEY *key = NULL;
WERROR wresult;
@@ -461,7 +462,8 @@ void svcctl_init_keys( void )
/* lookup the available subkeys */
- if ( !(subkeys = TALLOC_ZERO_P( key, REGSUBKEY_CTR )) ) {
+ wresult = regsubkey_ctr_init(key, &subkeys);
+ if (!W_ERROR_IS_OK(wresult)) {
DEBUG(0,("svcctl_init_keys: talloc() failed!\n"));
TALLOC_FREE( key );
return;
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 78b8123680..d23b509af2 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -471,6 +471,7 @@ static NTSTATUS update_write_time_on_close(struct files_struct *fsp)
SMB_STRUCT_STAT sbuf;
struct smb_file_time ft;
NTSTATUS status;
+ int ret = -1;
ZERO_STRUCT(sbuf);
ZERO_STRUCT(ft);
@@ -485,15 +486,19 @@ static NTSTATUS update_write_time_on_close(struct files_struct *fsp)
/* Ensure we have a valid stat struct for the source. */
if (fsp->fh->fd != -1) {
- if (SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
- return map_nt_error_from_unix(errno);
- }
+ ret = SMB_VFS_FSTAT(fsp, &sbuf);
} else {
- if (SMB_VFS_STAT(fsp->conn,fsp->fsp_name,&sbuf) == -1) {
- return map_nt_error_from_unix(errno);
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(fsp->conn,fsp->fsp_name,&sbuf);
+ } else {
+ ret = SMB_VFS_STAT(fsp->conn,fsp->fsp_name,&sbuf);
}
}
+ if (ret == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+
if (!VALID_STAT(sbuf)) {
/* if it doesn't seem to be a real file */
return NT_STATUS_OK;
@@ -581,6 +586,13 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp,
*/
saved_status4 = update_write_time_on_close(fsp);
+ if (NT_STATUS_EQUAL(saved_status4, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ /* Someone renamed the file or a parent directory containing
+ * this file. We can't do anything about this, we don't have
+ * an "update timestamp by fd" call in POSIX. Eat the error. */
+
+ saved_status4 = NT_STATUS_OK;
+ }
if (NT_STATUS_IS_OK(status)) {
if (!NT_STATUS_IS_OK(saved_status1)) {
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 4b467b0312..a52f2d2e96 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -140,6 +140,7 @@ find_again:
return NULL;
}
conn->cnum = i;
+ conn->force_group_gid = (gid_t)-1;
bitmap_set(bmap, i);
diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c
index fe7ba1cc46..abffcd2f4f 100644
--- a/source3/smbd/file_access.c
+++ b/source3/smbd/file_access.c
@@ -34,6 +34,11 @@ bool can_access_file_acl(struct connection_struct *conn,
uint32_t access_granted;
struct security_descriptor *secdesc = NULL;
+ if (conn->server_info->utok.uid == 0 || conn->admin_user) {
+ /* I'm sorry sir, I didn't know you were root... */
+ return true;
+ }
+
status = SMB_VFS_GET_NT_ACL(conn, fname,
(OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION |
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index a9a97a2d14..adf664b396 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -256,10 +256,9 @@ ssize_t write_file(struct smb_request *req,
int write_path = -1;
if (fsp->print_file) {
- fstring sharename;
uint32 jobid;
- if (!rap_to_pjobid(fsp->rap_print_jobid, sharename, &jobid)) {
+ if (!rap_to_pjobid(fsp->rap_print_jobid, NULL, &jobid)) {
DEBUG(3,("write_file: Unable to map RAP jobid %u to jobid.\n",
(unsigned int)fsp->rap_print_jobid ));
errno = EBADF;
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index efaadffc06..36e80a086a 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -356,6 +356,49 @@ files_struct *file_find_print(void)
}
/****************************************************************************
+ Find any fsp open with a pathname below that of an already open path.
+****************************************************************************/
+
+bool file_find_subpath(files_struct *dir_fsp)
+{
+ files_struct *fsp;
+ size_t dlen;
+ char *d_fullname = talloc_asprintf(talloc_tos(),
+ "%s/%s",
+ dir_fsp->conn->connectpath,
+ dir_fsp->fsp_name);
+
+ if (!d_fullname) {
+ return false;
+ }
+
+ dlen = strlen(d_fullname);
+
+ for (fsp=Files;fsp;fsp=fsp->next) {
+ char *d1_fullname;
+
+ if (fsp == dir_fsp) {
+ continue;
+ }
+
+ d1_fullname = talloc_asprintf(talloc_tos(),
+ "%s/%s",
+ fsp->conn->connectpath,
+ fsp->fsp_name);
+
+ if (strnequal(d_fullname, d1_fullname, dlen)) {
+ TALLOC_FREE(d_fullname);
+ TALLOC_FREE(d1_fullname);
+ return true;
+ }
+ TALLOC_FREE(d1_fullname);
+ }
+
+ TALLOC_FREE(d_fullname);
+ return false;
+}
+
+/****************************************************************************
Sync open files on a connection.
****************************************************************************/
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index a42705adb6..acd347520d 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -76,6 +76,15 @@ static NTSTATUS check_open_rights(struct connection_struct *conn,
*access_granted = 0;
+ if (conn->server_info->utok.uid == 0 || conn->admin_user) {
+ /* I'm sorry sir, I didn't know you were root... */
+ *access_granted = access_mask;
+ if (access_mask & SEC_FLAG_MAXIMUM_ALLOWED) {
+ *access_granted |= FILE_GENERIC_ALL;
+ }
+ return NT_STATUS_OK;
+ }
+
status = SMB_VFS_GET_NT_ACL(conn, fname,
(OWNER_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION |
@@ -2457,6 +2466,25 @@ static NTSTATUS open_directory(connection_struct *conn,
fname,
access_mask,
&access_granted);
+
+ /* Were we trying to do a directory open
+ * for delete and didn't get DELETE
+ * access (only) ? Check if the
+ * directory allows DELETE_CHILD.
+ * See here:
+ * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx
+ * for details. */
+
+ if ((NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) &&
+ (access_mask & DELETE_ACCESS) &&
+ (access_granted == DELETE_ACCESS) &&
+ can_delete_file_in_directory(conn, fname))) {
+ DEBUG(10,("open_directory: overrode ACCESS_DENIED "
+ "on directory %s\n",
+ fname ));
+ status = NT_STATUS_OK;
+ }
+
if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("open_directory: check_open_rights on "
"file %s failed with %s\n",
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index b30ef23c0e..22e4c1aad7 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2214,6 +2214,16 @@ static NTSTATUS can_rename(connection_struct *conn, files_struct *fsp,
}
if (S_ISDIR(pst->st_mode)) {
+ if (fsp->posix_open) {
+ return NT_STATUS_OK;
+ }
+
+ /* If no pathnames are open below this
+ directory, allow the rename. */
+
+ if (file_find_subpath(fsp)) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
return NT_STATUS_OK;
}
@@ -2808,9 +2818,9 @@ static void send_file_readbraw(connection_struct *conn,
}
return;
}
-#endif
normal_readbraw:
+#endif
outbuf = TALLOC_ARRAY(NULL, char, nread+4);
if (!outbuf) {
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 346e8973de..538e04938e 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -730,7 +730,7 @@ void reload_printers(void)
DEBUG(3, ("removing stale printer %s\n", pname));
if (is_printer_published(NULL, snum, NULL))
- nt_printer_publish(NULL, snum, SPOOL_DS_UNPUBLISH);
+ nt_printer_publish(NULL, snum, DSPRINT_UNPUBLISH);
del_a_printer(pname);
lp_killservice(snum);
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index dcdd69f997..eb16a2601e 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -833,6 +833,14 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
*pstatus = status;
return NULL;
}
+
+ /*
+ * We need to cache this gid, to use within
+ * change_to_user() separately from the conn->server_info
+ * struct. We only use conn->server_info directly if
+ * "force_user" was set.
+ */
+ conn->force_group_gid = conn->server_info->utok.gid;
}
conn->vuid = (vuser != NULL) ? vuser->vuid : UID_FIELD_INVALID;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 759e520866..ee1dda98b2 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);
@@ -6415,6 +6423,8 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
create_disp = FILE_OVERWRITE_IF;
} else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) {
create_disp = FILE_OPEN_IF;
+ } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) {
+ create_disp = FILE_OPEN;
} else {
DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n",
(unsigned int)wire_open_mode ));
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index 4f059bdb59..f8c55b1b8f 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -254,6 +254,8 @@ bool change_to_user(connection_struct *conn, uint16 vuid)
if((group_c = *lp_force_group(snum))) {
+ SMB_ASSERT(conn->force_group_gid != (gid_t)-1);
+
if(group_c == '+') {
/*
@@ -266,15 +268,18 @@ bool change_to_user(connection_struct *conn, uint16 vuid)
int i;
for (i = 0; i < num_groups; i++) {
if (group_list[i]
- == conn->server_info->utok.gid) {
- gid = conn->server_info->utok.gid;
+ == conn->force_group_gid) {
+ conn->server_info->utok.gid =
+ conn->force_group_gid;
+ gid = conn->force_group_gid;
gid_to_sid(&conn->server_info->ptok
->user_sids[1], gid);
break;
}
}
} else {
- gid = conn->server_info->utok.gid;
+ conn->server_info->utok.gid = conn->force_group_gid;
+ gid = conn->force_group_gid;
gid_to_sid(&conn->server_info->ptok->user_sids[1],
gid);
}
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index 0c2cd24fb2..38a2553e53 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -338,11 +338,11 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
servicename,
&service);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
werr = import_process_service(c, conf_ctx, service);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
} else {
struct smbconf_service **services = NULL;
@@ -352,24 +352,72 @@ static int net_conf_import(struct net_context *c, struct smbconf_ctx *conf_ctx,
&num_shares,
&services);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
if (!c->opt_testmode) {
werr = smbconf_drop(conf_ctx);
if (!W_ERROR_IS_OK(werr)) {
- goto done;
+ goto cancel;
}
}
+
+ /*
+ * Wrap the importing of shares into a transaction,
+ * but only 100 at a time, in order to serve memory.
+ * The allocated memory accumulates across the actions
+ * within the transaction, and for me, some 1500
+ * imported shares, the MAX_TALLOC_SIZE of 256 MB
+ * was exceeded.
+ */
+ werr = smbconf_transaction_start(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error starting transaction: %s\n",
+ win_errstr(werr));
+ goto done;
+ }
+
for (sidx = 0; sidx < num_shares; sidx++) {
werr = import_process_service(c, conf_ctx,
services[sidx]);
if (!W_ERROR_IS_OK(werr)) {
+ goto cancel;
+ }
+
+ if (sidx % 100) {
+ continue;
+ }
+
+ werr = smbconf_transaction_commit(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error committing transaction: %s\n",
+ win_errstr(werr));
+ goto done;
+ }
+ werr = smbconf_transaction_start(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error starting transaction: %s\n",
+ win_errstr(werr));
goto done;
}
}
}
- ret = 0;
+ werr = smbconf_transaction_commit(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error committing transaction: %s\n",
+ win_errstr(werr));
+ } else {
+ ret = 0;
+ }
+
+ goto done;
+
+cancel:
+ werr = smbconf_transaction_cancel(conf_ctx);
+ if (!W_ERROR_IS_OK(werr)) {
+ d_printf("error cancelling transaction: %s\n",
+ win_errstr(werr));
+ }
done:
TALLOC_FREE(mem_ctx);
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 17df69597f..8116764d9b 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -775,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;
@@ -794,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));
@@ -1027,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) {
@@ -1039,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],
@@ -1047,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;
}
@@ -1216,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;
@@ -1246,21 +1307,19 @@ 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 */
switch (action) {
- case SPOOL_DS_PUBLISH:
+ case DSPRINT_PUBLISH:
action_str = "published";
break;
- case SPOOL_DS_UPDATE:
+ case DSPRINT_UPDATE:
action_str = "updated";
break;
- case SPOOL_DS_UNPUBLISH:
+ case DSPRINT_UNPUBLISH:
action_str = "unpublished";
break;
default:
@@ -1269,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;
@@ -1283,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;
@@ -1298,7 +1369,7 @@ NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
int argc,
const char **argv)
{
- return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_PUBLISH);
+ return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_PUBLISH);
}
NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
@@ -1310,7 +1381,7 @@ NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
int argc,
const char **argv)
{
- return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UNPUBLISH);
+ return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_UNPUBLISH);
}
NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
@@ -1322,7 +1393,7 @@ NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
int argc,
const char **argv)
{
- return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UPDATE);
+ return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_UPDATE);
}
/**
@@ -1355,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))
@@ -1387,32 +1457,25 @@ 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:
+ case DSPRINT_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:
+ case DSPRINT_UNPUBLISH:
printf("printer [%s] is unpublished\n", sharename);
break;
- case SPOOL_DS_UPDATE:
+ case DSPRINT_UPDATE:
printf("printer [%s] is currently updating\n", sharename);
break;
default:
@@ -1424,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;
@@ -1464,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);
@@ -1530,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;
}
}
@@ -1579,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);
}
@@ -1625,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;
@@ -1686,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 */
@@ -1758,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;
}
}
@@ -1773,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) {
@@ -1816,14 +1863,13 @@ 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;
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;
@@ -1900,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;
@@ -1914,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 */
@@ -1965,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;
}
@@ -1976,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;
}
}
@@ -1992,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) {
@@ -2043,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"));
@@ -2100,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;
}
@@ -2125,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);
@@ -2146,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) {
@@ -2208,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;
@@ -2221,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"));
@@ -2280,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 = DSPRINT_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"));
}
@@ -2325,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,
@@ -2345,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
@@ -2529,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;
}
}
@@ -2548,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/net_rpc_registry.c b/source3/utils/net_rpc_registry.c
index 005e3ca556..00c827928e 100644
--- a/source3/utils/net_rpc_registry.c
+++ b/source3/utils/net_rpc_registry.c
@@ -971,12 +971,15 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
{
REGF_NK_REC *key, *subkey;
REGVAL_CTR *values = NULL;
- REGSUBKEY_CTR *subkeys = NULL;
+ struct regsubkey_ctr *subkeys = NULL;
int i;
char *path = NULL;
+ WERROR werr;
- if ( !( subkeys = TALLOC_ZERO_P( infile->mem_ctx, REGSUBKEY_CTR )) ) {
- DEBUG(0,("write_registry_tree: talloc() failed!\n"));
+ werr = regsubkey_ctr_init(infile->mem_ctx, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
+ DEBUG(0, ("write_registry_tree: regsubkey_ctr_init failed: "
+ "%s\n", win_errstr(werr)));
return false;
}
@@ -993,7 +996,7 @@ static bool write_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
(const char *)nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) );
}
- /* copy subkeys into the REGSUBKEY_CTR */
+ /* copy subkeys into the struct regsubkey_ctr */
while ( (subkey = regfio_fetch_subkey( infile, nk )) ) {
regsubkey_ctr_addkey( subkeys, subkey->keyname );
diff --git a/source3/utils/profiles.c b/source3/utils/profiles.c
index bbbaaf089f..0ac93dedeb 100644
--- a/source3/utils/profiles.c
+++ b/source3/utils/profiles.c
@@ -118,9 +118,10 @@ static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
REGF_NK_REC *key, *subkey;
SEC_DESC *new_sd;
REGVAL_CTR *values;
- REGSUBKEY_CTR *subkeys;
+ struct regsubkey_ctr *subkeys;
int i;
char *path;
+ WERROR werr;
/* swap out the SIDs in the security descriptor */
@@ -132,7 +133,8 @@ static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
verbose_output("ACL for %s%s%s\n", parentpath, parent ? "\\" : "", nk->keyname);
swap_sid_in_acl( new_sd, &old_sid, &new_sid );
- if ( !(subkeys = TALLOC_ZERO_P( NULL, REGSUBKEY_CTR )) ) {
+ werr = regsubkey_ctr_init(NULL, &subkeys);
+ if (!W_ERROR_IS_OK(werr)) {
DEBUG(0,("copy_registry_tree: talloc() failure!\n"));
return False;
}
@@ -150,7 +152,7 @@ static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk,
(const char *)nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) );
}
- /* copy subkeys into the REGSUBKEY_CTR */
+ /* copy subkeys into the struct regsubkey_ctr */
while ( (subkey = regfio_fetch_subkey( infile, nk )) ) {
regsubkey_ctr_addkey( subkeys, subkey->keyname );
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index b22e5af94a..5c29ba0b22 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -304,6 +304,11 @@ static NTSTATUS idmap_ad_unixids_to_sids(struct idmap_domain *dom, struct id_map
char *u_filter = NULL;
char *g_filter = NULL;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
/* Only do query if we are online */
if (idmap_is_offline()) {
return NT_STATUS_FILE_IS_OFFLINE;
@@ -516,6 +521,11 @@ static NTSTATUS idmap_ad_sids_to_unixids(struct idmap_domain *dom, struct id_map
int i;
char *sidstr;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
/* Only do query if we are online */
if (idmap_is_offline()) {
return NT_STATUS_FILE_IS_OFFLINE;
diff --git a/source3/winbindd/idmap_adex/idmap_adex.c b/source3/winbindd/idmap_adex/idmap_adex.c
index 7e186ca8a1..e2fcda83d3 100644
--- a/source3/winbindd/idmap_adex/idmap_adex.c
+++ b/source3/winbindd/idmap_adex/idmap_adex.c
@@ -159,6 +159,11 @@ static NTSTATUS _idmap_adex_get_sid_from_id(struct
NTSTATUS nt_status;
struct likewise_cell *cell;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
nt_status = _idmap_adex_init(dom, NULL);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -207,6 +212,11 @@ static NTSTATUS _idmap_adex_get_id_from_sid(struct
NTSTATUS nt_status;
struct likewise_cell *cell;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
nt_status = _idmap_adex_init(dom, NULL);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
diff --git a/source3/winbindd/idmap_hash/idmap_hash.c b/source3/winbindd/idmap_hash/idmap_hash.c
index 7dd94aede0..42830720f3 100644
--- a/source3/winbindd/idmap_hash/idmap_hash.c
+++ b/source3/winbindd/idmap_hash/idmap_hash.c
@@ -160,6 +160,11 @@ static NTSTATUS unixids_to_sids(struct idmap_domain *dom,
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
nt_status = be_init(dom, NULL);
BAIL_ON_NTSTATUS_ERROR(nt_status);
@@ -206,6 +211,11 @@ static NTSTATUS sids_to_unixids(struct idmap_domain *dom,
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
nt_status = be_init(dom, NULL);
BAIL_ON_NTSTATUS_ERROR(nt_status);
diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c
index c86a5023d0..7224589076 100644
--- a/source3/winbindd/idmap_ldap.c
+++ b/source3/winbindd/idmap_ldap.c
@@ -935,6 +935,10 @@ static NTSTATUS idmap_ldap_unixids_to_sids(struct idmap_domain *dom,
multi = True;
}
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
again:
if (multi) {
@@ -1156,6 +1160,10 @@ static NTSTATUS idmap_ldap_sids_to_unixids(struct idmap_domain *dom,
multi = True;
}
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
again:
if (multi) {
diff --git a/source3/winbindd/idmap_nss.c b/source3/winbindd/idmap_nss.c
index 156fdc7cc9..f50e6172ba 100644
--- a/source3/winbindd/idmap_nss.c
+++ b/source3/winbindd/idmap_nss.c
@@ -44,6 +44,11 @@ static NTSTATUS idmap_nss_unixids_to_sids(struct idmap_domain *dom, struct id_ma
TALLOC_CTX *ctx;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ctx = talloc_new(dom);
if ( ! ctx) {
DEBUG(0, ("Out of memory!\n"));
@@ -130,6 +135,11 @@ static NTSTATUS idmap_nss_sids_to_unixids(struct idmap_domain *dom, struct id_ma
TALLOC_CTX *ctx;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ctx = talloc_new(dom);
if ( ! ctx) {
DEBUG(0, ("Out of memory!\n"));
diff --git a/source3/winbindd/idmap_rid.c b/source3/winbindd/idmap_rid.c
index 9d1898708c..359bbfd411 100644
--- a/source3/winbindd/idmap_rid.c
+++ b/source3/winbindd/idmap_rid.c
@@ -171,6 +171,11 @@ static NTSTATUS idmap_rid_unixids_to_sids(struct idmap_domain *dom, struct id_ma
NTSTATUS ret;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
ctx = talloc_new(dom);
@@ -205,6 +210,11 @@ static NTSTATUS idmap_rid_sids_to_unixids(struct idmap_domain *dom, struct id_ma
NTSTATUS ret;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ridctx = talloc_get_type(dom->private_data, struct idmap_rid_context);
ctx = talloc_new(dom);
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index 3a64979f33..22c17578e6 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -775,6 +775,11 @@ static NTSTATUS idmap_tdb_unixids_to_sids(struct idmap_domain *dom, struct id_ma
NTSTATUS ret;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
for (i = 0; ids[i]; i++) {
@@ -813,6 +818,11 @@ static NTSTATUS idmap_tdb_sids_to_unixids(struct idmap_domain *dom, struct id_ma
NTSTATUS ret;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
for (i = 0; ids[i]; i++) {
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index fb90dd097e..b2723270eb 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -655,6 +655,11 @@ static NTSTATUS idmap_tdb2_unixids_to_sids(struct idmap_domain *dom, struct id_m
NTSTATUS ret;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
for (i = 0; ids[i]; i++) {
@@ -692,6 +697,11 @@ static NTSTATUS idmap_tdb2_sids_to_unixids(struct idmap_domain *dom, struct id_m
NTSTATUS ret;
int i;
+ /* initialize the status to avoid suprise */
+ for (i = 0; ids[i]; i++) {
+ ids[i]->status = ID_UNKNOWN;
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
for (i = 0; ids[i]; i++) {
diff --git a/source4/Makefile b/source4/Makefile
index 508836f6da..15b1b8ba40 100644
--- a/source4/Makefile
+++ b/source4/Makefile
@@ -146,7 +146,7 @@ endif
clean::
@find ../lib ../libcli ../librpc ../nsswitch -name '*.o' -o -name '*.ho' | xargs rm -f
-PUBLIC_HEADERS += $(srcdir)/version.h
+PUBLIC_HEADERS += ./version.h
libraries:: $(STATIC_LIBS) $(SHARED_LIBS)
modules:: $(PLUGINS)
diff --git a/source4/VERSION b/source4/VERSION
index e7d05f6a09..58f8cc169d 100644
--- a/source4/VERSION
+++ b/source4/VERSION
@@ -57,7 +57,7 @@ SAMBA_VERSION_TP_RELEASE=
# e.g. SAMBA_VERSION_ALPHA_RELEASE=1 #
# -> "4.0.0alpha1" #
########################################################
-SAMBA_VERSION_ALPHA_RELEASE=7
+SAMBA_VERSION_ALPHA_RELEASE=8
########################################################
# For 'pre' releases the version will be #
diff --git a/source4/auth/ntlm/ntlm_check.c b/source4/auth/ntlm/ntlm_check.c
index a3ac7f3347..0805b1b043 100644
--- a/source4/auth/ntlm/ntlm_check.c
+++ b/source4/auth/ntlm/ntlm_check.c
@@ -323,7 +323,7 @@ NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
if (lm_response->length &&
(convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX,
lm_response->data, lm_response->length,
- (void **)&unix_pw) != -1)) {
+ (void **)&unix_pw, NULL, false))) {
if (E_deshash(unix_pw, client_lm.hash)) {
lm_ok = true;
} else {
diff --git a/source4/auth/ntlmssp/ntlmssp_parse.c b/source4/auth/ntlmssp/ntlmssp_parse.c
index d606b8d563..969845d6c5 100644
--- a/source4/auth/ntlmssp/ntlmssp_parse.c
+++ b/source4/auth/ntlmssp/ntlmssp_parse.c
@@ -44,14 +44,15 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
DATA_BLOB *blob,
const char *format, ...)
{
- int i;
- ssize_t n;
+ int i, j;
+ bool ret;
va_list ap;
char *s;
uint8_t *b;
int head_size=0, data_size=0;
int head_ofs, data_ofs;
int *intargs;
+ size_t n;
DATA_BLOB *pointers;
@@ -65,8 +66,9 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
case 'U':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
- if (n == -1) {
+ ret = push_ucs2_talloc(pointers, (smb_ucs2_t **)&pointers[i].data,
+ s, &n);
+ if (!ret) {
return false;
}
pointers[i].length = n;
@@ -76,8 +78,9 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
case 'A':
s = va_arg(ap, char *);
head_size += 8;
- n = push_ascii_talloc(pointers, (char **)&pointers[i].data, s);
- if (n == -1) {
+ ret = push_ascii_talloc(pointers, (char **)&pointers[i].data, s,
+ &n);
+ if (!ret) {
return false;
}
pointers[i].length = n;
@@ -85,11 +88,12 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
data_size += pointers[i].length;
break;
case 'a':
- n = va_arg(ap, int);
- intargs[i] = n;
+ j = va_arg(ap, int);
+ intargs[i] = j;
s = va_arg(ap, char *);
- n = push_ucs2_talloc(pointers, (void **)&pointers[i].data, s);
- if (n == -1) {
+ ret = push_ucs2_talloc(pointers, (smb_ucs2_t **)&pointers[i].data,
+ s, &n);
+ if (!ret) {
return false;
}
pointers[i].length = n;
@@ -110,8 +114,8 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
head_size += pointers[i].length;
break;
case 'd':
- n = va_arg(ap, int);
- intargs[i] = n;
+ j = va_arg(ap, int);
+ intargs[i] = j;
head_size += 4;
break;
case 'C':
@@ -145,8 +149,8 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
data_ofs += n;
break;
case 'a':
- n = intargs[i];
- SSVAL(blob->data, data_ofs, n); data_ofs += 2;
+ j = intargs[i];
+ SSVAL(blob->data, data_ofs, j); data_ofs += 2;
n = pointers[i].length;
SSVAL(blob->data, data_ofs, n); data_ofs += 2;
@@ -156,8 +160,8 @@ bool msrpc_gen(TALLOC_CTX *mem_ctx,
data_ofs += n;
break;
case 'd':
- n = intargs[i];
- SIVAL(blob->data, head_ofs, n);
+ j = intargs[i];
+ SIVAL(blob->data, head_ofs, j);
head_ofs += 4;
break;
case 'b':
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/configure.ac b/source4/configure.ac
index 54ca9108b1..d33df08406 100644
--- a/source4/configure.ac
+++ b/source4/configure.ac
@@ -42,7 +42,7 @@ AC_CONFIG_FILES(param/samba-hostconfig.pc)
AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
AC_CONFIG_FILES(librpc/dcerpc_atsvc.pc)
-SMB_INCLUDED_LIB_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0, [],
+SMB_INCLUDED_LIB_PKGCONFIG(LIBTALLOC, talloc >= 1.2.1, [],
[
m4_include(../lib/talloc/libtalloc.m4)
SMB_INCLUDE_MK(../lib/talloc/config.mk)
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index b02a162293..19eb3433a9 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -1693,7 +1693,7 @@ NTSTATUS samdb_set_password(struct ldb_context *ctx, TALLOC_CTX *mem_ctx,
if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ctx, "loadparm")),
CH_UTF16, CH_UNIX,
new_password->data, new_password->length,
- (void **)&new_pass) != -1) {
+ (void **)&new_pass, NULL, false)) {
/* possibly check password complexity */
diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c
index da4c57463b..56d4c4fe36 100644
--- a/source4/dsdb/samdb/ldb_modules/password_hash.c
+++ b/source4/dsdb/samdb/ldb_modules/password_hash.c
@@ -1307,7 +1307,7 @@ static int setup_password_fields(struct setup_password_fields_io *io)
struct ldb_context *ldb;
bool ok;
int ret;
- ssize_t converted_pw_len;
+ size_t converted_pw_len;
ldb = ldb_module_get_ctx(io->ac->module);
@@ -1337,10 +1337,9 @@ static int setup_password_fields(struct setup_password_fields_io *io)
ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
+ if (!convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
CH_UTF8, CH_UTF16, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length,
- (void **)&cleartext_utf16_str);
- if (converted_pw_len == -1) {
+ (void **)&cleartext_utf16_str, &converted_pw_len, false)) {
ldb_asprintf_errstring(ldb,
"setup_password_fields: "
"failed to generate UTF16 password from cleartext UTF8 password");
@@ -1355,10 +1354,9 @@ static int setup_password_fields(struct setup_password_fields_io *io)
ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
+ if (!convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
CH_UTF16MUNGED, CH_UTF8, io->n.cleartext_utf16->data, io->n.cleartext_utf16->length,
- (void **)&cleartext_utf8_str);
- if (converted_pw_len == -1) {
+ (void **)&cleartext_utf8_str, &converted_pw_len, false)) {
/* We can't bail out entirely, as these unconvertable passwords are frustratingly valid */
io->n.cleartext_utf8 = NULL;
talloc_free(cleartext_utf8_blob);
@@ -1381,10 +1379,9 @@ static int setup_password_fields(struct setup_password_fields_io *io)
if (io->n.cleartext_utf8) {
struct samr_Password *lm_hash;
char *cleartext_unix;
- converted_pw_len = convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
+ if (convert_string_talloc_convenience(io->ac, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
CH_UTF8, CH_UNIX, io->n.cleartext_utf8->data, io->n.cleartext_utf8->length,
- (void **)&cleartext_unix);
- if (converted_pw_len != -1) {
+ (void **)&cleartext_unix, &converted_pw_len, false)) {
lm_hash = talloc(io->ac, struct samr_Password);
if (!lm_hash) {
ldb_oom(ldb);
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 763872cf2b..a67aecd1e8 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -1186,12 +1186,11 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
return WERR_INVALID_PARAM; \
} \
if (_a && _a->value_ctr.num_values >= 1) { \
- ssize_t _ret; \
- _ret = convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
+ size_t _ret; \
+ if (!convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
_a->value_ctr.values[0].blob->data, \
_a->value_ctr.values[0].blob->length, \
- (void **)discard_const(&(p)->elem)); \
- if (_ret == -1) { \
+ (void **)discard_const(&(p)->elem), &_ret, false)) { \
DEBUG(0,("%s: invalid data!\n", attr)); \
dump_data(0, \
_a->value_ctr.values[0].blob->data, \
@@ -1203,6 +1202,34 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
} \
} while (0)
+#define GET_STRING_LIST_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
+ int get_string_list_counter; \
+ struct drsuapi_DsReplicaAttribute *_a; \
+ _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
+ if (strict && !_a) { \
+ d_printf("%s: %s == NULL\n", __location__, attr); \
+ return WERR_INVALID_PARAM; \
+ } \
+ (p)->elem = _a ? talloc_array(mem_ctx, const char *, _a->value_ctr.num_values + 1) : NULL; \
+ for (get_string_list_counter=0; \
+ _a && get_string_list_counter < _a->value_ctr.num_values; \
+ get_string_list_counter++) { \
+ size_t _ret; \
+ if (!convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
+ _a->value_ctr.values[get_string_list_counter].blob->data, \
+ _a->value_ctr.values[get_string_list_counter].blob->length, \
+ (void **)discard_const(&(p)->elem[get_string_list_counter]), &_ret, false)) { \
+ DEBUG(0,("%s: invalid data!\n", attr)); \
+ dump_data(0, \
+ _a->value_ctr.values[get_string_list_counter].blob->data, \
+ _a->value_ctr.values[get_string_list_counter].blob->length); \
+ return WERR_FOOBAR; \
+ } \
+ (p)->elem[get_string_list_counter+1] = NULL; \
+ } \
+ talloc_steal(mem_ctx, (p)->elem); \
+} while (0)
+
#define GET_DN_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
struct drsuapi_DsReplicaAttribute *_a; \
_a = dsdb_find_object_attr_name(s, r, attr, NULL); \
@@ -1413,17 +1440,18 @@ WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, true);
- obj->systemAuxiliaryClass = NULL;
- obj->systemPossSuperiors = NULL;
- obj->systemMustContain = NULL;
- obj->systemMayContain = NULL;
- obj->auxiliaryClass = NULL;
- obj->possSuperiors = NULL;
- obj->mustContain = NULL;
- obj->mayContain = NULL;
+ GET_STRING_LIST_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, false);
+ GET_STRING_LIST_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, false);
+
+ GET_STRING_LIST_DS(schema, r, "systemMustContain", mem_ctx, obj, systemMustContain, false);
+ GET_STRING_LIST_DS(schema, r, "systemMayContain", mem_ctx, obj, systemMayContain, false);
+ GET_STRING_LIST_DS(schema, r, "mustContain", mem_ctx, obj, mustContain, false);
+ GET_STRING_LIST_DS(schema, r, "mayContain", mem_ctx, obj, mayContain, false);
- obj->possibleInferiors = NULL;
+ GET_STRING_LIST_DS(schema, r, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, false);
+ GET_STRING_LIST_DS(schema, r, "possSuperiors", mem_ctx, obj, possSuperiors, false);
+ GET_STRING_LIST_DS(schema, r, "possibleInferiors", mem_ctx, obj, possibleInferiors, false);
GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index 4141026b7e..27c9a6c4a4 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -779,7 +779,6 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(struct ldb_context *ldb,
W_ERROR_HAVE_NO_MEMORY(out->values);
for (i=0; i < out->num_values; i++) {
- ssize_t ret;
char *str;
if (in->value_ctr.values[i].blob == NULL) {
@@ -790,13 +789,12 @@ static WERROR dsdb_syntax_UNICODE_drsuapi_to_ldb(struct ldb_context *ldb,
return WERR_FOOBAR;
}
- ret = convert_string_talloc_convenience(out->values,
+ if (!convert_string_talloc_convenience(out->values,
schema->iconv_convenience,
CH_UTF16, CH_UNIX,
in->value_ctr.values[i].blob->data,
in->value_ctr.values[i].blob->length,
- (void **)&str);
- if (ret == -1) {
+ (void **)&str, NULL, false)) {
return WERR_FOOBAR;
}
@@ -835,11 +833,10 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(struct ldb_context *ldb,
out->value_ctr.values[i].blob = &blobs[i];
- ret = convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16,
+ if (!convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16,
in->values[i].data,
in->values[i].length,
- (void **)&blobs[i].data);
- if (ret == -1) {
+ (void **)&blobs[i].data, NULL, false)) {
return WERR_FOOBAR;
}
blobs[i].length = ret;
@@ -1145,7 +1142,6 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(struct ldb_context
for (i=0; i < out->num_values; i++) {
uint32_t len;
- ssize_t ret;
char *str;
if (in->value_ctr.values[i].blob == NULL) {
@@ -1162,11 +1158,10 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_drsuapi_to_ldb(struct ldb_context
return WERR_FOOBAR;
}
- ret = convert_string_talloc_convenience(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX,
+ if (!convert_string_talloc_convenience(out->values, schema->iconv_convenience, CH_UTF16, CH_UNIX,
in->value_ctr.values[i].blob->data+4,
in->value_ctr.values[i].blob->length-4,
- (void **)&str);
- if (ret == -1) {
+ (void **)&str, NULL, false)) {
return WERR_FOOBAR;
}
@@ -1202,15 +1197,14 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(struct ldb_context
for (i=0; i < in->num_values; i++) {
uint8_t *data;
- ssize_t ret;
+ size_t ret;
out->value_ctr.values[i].blob = &blobs[i];
- ret = convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16,
+ if (!convert_string_talloc_convenience(blobs, schema->iconv_convenience, CH_UNIX, CH_UTF16,
in->values[i].data,
in->values[i].length,
- (void **)&data);
- if (ret == -1) {
+ (void **)&data, &ret, false)) {
return WERR_FOOBAR;
}
diff --git a/source4/heimdal_build/internal.m4 b/source4/heimdal_build/internal.m4
index 50a3c8adda..4cd7521c37 100644
--- a/source4/heimdal_build/internal.m4
+++ b/source4/heimdal_build/internal.m4
@@ -77,6 +77,7 @@ AC_CHECK_FUNCS([ \
atexit \
cgetent \
getprogname \
+ setprogname \
inet_aton \
gethostname \
getnameinfo \
@@ -170,6 +171,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=""
@@ -262,16 +269,18 @@ SMB_ENABLE(compile_et, YES)
# only add closefrom if needed
SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, NO)
+SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM_H, NO)
if test t$ac_cv_func_closefrom != tyes; then
SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM, YES)
+ SMB_ENABLE(HEIMDAL_ROKEN_CLOSEFROM_H, YES)
fi
# only add getprogname if needed
-SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, NO)
-SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, NO)
+SMB_ENABLE(HEIMDAL_ROKEN_PROGNAME, NO)
+SMB_ENABLE(HEIMDAL_ROKEN_PROGNAME_H, NO)
if test t$ac_cv_func_getprogname != tyes; then
- SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME, YES)
- SMB_ENABLE(HEIMDAL_ROKEN_GETPROGNAME_H, YES)
+ SMB_ENABLE(HEIMDAL_ROKEN_PROGNAME, YES)
+ SMB_ENABLE(HEIMDAL_ROKEN_PROGNAME_H, YES)
fi
VPATH="$VPATH:\$(HEIMDAL_VPATH)"
diff --git a/source4/heimdal_build/internal.mk b/source4/heimdal_build/internal.mk
index 9e32898a07..ea8d4731db 100644
--- a/source4/heimdal_build/internal.mk
+++ b/source4/heimdal_build/internal.mk
@@ -255,7 +255,7 @@ HEIMDAL_GSSAPI_OBJ_FILES = \
CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/krb5 -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/com_err
PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN HEIMDAL_PKINIT_ASN1 HEIMDAL_WIND \
HEIMDAL_KRB5_ASN1 HEIMDAL_HX509 HEIMDAL_HCRYPTO \
- LIBNETIF LIBSAMBA-HOSTCONFIG
+ LIBNETIF LIBSAMBA-HOSTCONFIG INTL
PUBLIC_DEPENDENCIES = HEIMDAL_COM_ERR
# End SUBSYSTEM HEIMDAL_KRB5
#######################
@@ -568,27 +568,36 @@ $(heimdalsrcdir)/lib/wind/bidi_table.h $(heimdalsrcdir)/lib/wind/bidi_table.c: $
clean::
@rm -f $(heimdalsrcdir)/lib/wind/bidi_table.h $(heimdalsrcdir)/lib/wind/bidi_table.c
-[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME]
+[SUBSYSTEM::HEIMDAL_ROKEN_PROGNAME]
-HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.o
-$(HEIMDAL_ROKEN_GETPROGNAME_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
+HEIMDAL_ROKEN_PROGNAME_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/roken/getprogname.o \
+ $(heimdalsrcdir)/lib/roken/setprogname.o
+$(HEIMDAL_ROKEN_PROGNAME_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
[SUBSYSTEM::HEIMDAL_ROKEN_CLOSEFROM]
HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES = $(heimdalsrcdir)/lib/roken/closefrom.o
$(HEIMDAL_ROKEN_CLOSEFROM_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
-[SUBSYSTEM::HEIMDAL_ROKEN_GETPROGNAME_H]
+[SUBSYSTEM::HEIMDAL_ROKEN_PROGNAME_H]
-HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES = $(heimdalsrcdir)/lib/roken/getprogname.ho
-$(HEIMDAL_ROKEN_GETPROGNAME_H_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
+HEIMDAL_ROKEN_PROGNAME_H_OBJ_FILES = \
+ $(heimdalsrcdir)/lib/roken/getprogname.ho \
+ $(heimdalsrcdir)/lib/roken/setprogname.ho
+$(HEIMDAL_ROKEN_PROGNAME_H_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -DSOCKET_WRAPPER_DISABLE=1
+
+[SUBSYSTEM::HEIMDAL_ROKEN_CLOSEFROM_H]
+
+HEIMDAL_ROKEN_CLOSEFROM_H_OBJ_FILES = $(heimdalsrcdir)/lib/roken/closefrom.ho
+$(HEIMDAL_ROKEN_CLOSEFROM_H_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -DSOCKET_WRAPPER_DISABLE=1
#######################
# Start SUBSYSTEM HEIMDAL_ROKEN
[SUBSYSTEM::HEIMDAL_ROKEN]
CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
PRIVATE_DEPENDENCIES = \
- HEIMDAL_ROKEN_GETPROGNAME \
+ HEIMDAL_ROKEN_PROGNAME \
HEIMDAL_ROKEN_CLOSEFROM \
RESOLV \
LIBREPLACE_NETWORK
@@ -615,7 +624,6 @@ HEIMDAL_ROKEN_OBJ_FILES = \
$(heimdalsrcdir)/lib/roken/roken_gethostby.o \
$(heimdalsrcdir)/lib/roken/signal.o \
$(heimdalsrcdir)/lib/roken/vis.o \
- $(heimdalsrcdir)/lib/roken/setprogname.o \
$(heimdalsrcdir)/lib/roken/strlwr.o \
$(heimdalsrcdir)/lib/roken/strsep_copy.o \
$(heimdalsrcdir)/lib/roken/strsep.o \
@@ -631,7 +639,17 @@ HEIMDAL_ROKEN_OBJ_FILES = \
$(heimdalbuildsrcdir)/replace.o
$(HEIMDAL_ROKEN_OBJ_FILES) $(HEIMDAL_ROKEN_OBJ_FILES:.o=.d):: $(heimdalsrcdir)/lib/roken/roken.h
-$(HEIMDAL_ROKEN_OBJ_FILES:.o=.ho) $(HEIMDAL_ROKEN_OBJ_FILES:.o=.hd):: $(heimdalsrcdir)/lib/roken/roken.h
+
+[SUBSYSTEM::HEIMDAL_ROKEN_H]
+CFLAGS = -I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/roken -DSOCKET_WRAPPER_DISABLE=1
+PRIVATE_DEPENDENCIES = \
+ HEIMDAL_ROKEN_PROGNAME_H \
+ HEIMDAL_ROKEN_CLOSEFROM_H \
+ RESOLV \
+ LIBREPLACE_NETWORK
+
+HEIMDAL_ROKEN_H_OBJ_FILES = $(HEIMDAL_ROKEN_OBJ_FILES:.o=.ho)
+$(HEIMDAL_ROKEN_H_OBJ_FILES:.ho=.hd):: $(heimdalsrcdir)/lib/roken/roken.h
$(heimdalsrcdir)/lib/roken/roken.h:
@echo 'Creating $(heimdalsrcdir)/lib/roken/roken.h'
@@ -656,7 +674,7 @@ HEIMDAL_COM_ERR_OBJ_FILES = \
# Start BINARY asn1_compile
[BINARY::asn1_compile]
USE_HOSTCC = YES
-PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN
+PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN_H
ASN1C = $(builddir)/bin/asn1_compile
@@ -680,10 +698,9 @@ dist:: $(heimdalsrcdir)/lib/asn1/lex.c
asn1_compile_OBJ_FILES = \
$(asn1_compile_ASN1_OBJ_FILES) \
- $(heimdalsrcdir)/lib/vers/print_version.ho \
- $(socketwrappersrcdir)/socket_wrapper.ho \
+ $(heimdalsrcdir)/lib/vers/print_version.ho
-$(asn1_compile_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
+$(asn1_compile_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/asn1 -I$(heimdalsrcdir)/lib/roken -DSOCKET_WRAPPER_DISABLE=1
$(eval $(call heimdal_proto_header_template, \
$(heimdalsrcdir)/lib/asn1/der-protos.h, \
@@ -699,7 +716,7 @@ $(eval $(call heimdal_proto_header_template, \
# Start BINARY compile_et
[BINARY::compile_et]
USE_HOSTCC = YES
-PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN
+PRIVATE_DEPENDENCIES = HEIMDAL_ROKEN_H
# End BINARY compile_et
#######################
@@ -708,10 +725,9 @@ ET_COMPILER = $(builddir)/bin/compile_et
compile_et_OBJ_FILES = $(heimdalsrcdir)/lib/vers/print_version.ho \
$(heimdalsrcdir)/lib/com_err/parse.ho \
$(heimdalsrcdir)/lib/com_err/lex.ho \
- $(heimdalsrcdir)/lib/com_err/compile_et.ho \
- $(socketwrappersrcdir)/socket_wrapper.ho \
+ $(heimdalsrcdir)/lib/com_err/compile_et.ho
-$(compile_et_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/com_err -I$(heimdalsrcdir)/lib/roken -I$(socketwrappersrcdir)
+$(compile_et_OBJ_FILES): CFLAGS+=-I$(heimdalbuildsrcdir) -I$(heimdalsrcdir)/lib/com_err -I$(heimdalsrcdir)/lib/roken -DSOCKET_WRAPPER_DISABLE=1
$(heimdalsrcdir)/lib/com_err/lex.c:: $(heimdalsrcdir)/lib/com_err/parse.c
dist:: $(heimdalsrcdir)/lib/com_err/lex.c
diff --git a/source4/kdc/kpasswdd.c b/source4/kdc/kpasswdd.c
index 39817d922b..8f2cb68129 100644
--- a/source4/kdc/kpasswdd.c
+++ b/source4/kdc/kpasswdd.c
@@ -61,12 +61,11 @@ static bool kpasswdd_make_error_reply(struct kdc_server *kdc,
DATA_BLOB *error_blob)
{
char *error_string_utf8;
- ssize_t len;
+ size_t len;
DEBUG(result_code ? 3 : 10, ("kpasswdd: %s\n", error_string));
- len = push_utf8_talloc(mem_ctx, &error_string_utf8, error_string);
- if (len == -1) {
+ if (!push_utf8_talloc(mem_ctx, &error_string_utf8, error_string, &len)) {
return false;
}
@@ -219,7 +218,7 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
DATA_BLOB *reply)
{
struct auth_session_info *session_info;
- ssize_t pw_len;
+ size_t pw_len;
if (!NT_STATUS_IS_OK(gensec_session_info(gensec_security,
&session_info))) {
@@ -233,13 +232,11 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
case KRB5_KPASSWD_VERS_CHANGEPW:
{
DATA_BLOB password;
- pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx),
+ if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx),
CH_UTF8, CH_UTF16,
(const char *)input->data,
input->length,
- (void **)&password.data);
-
- if (pw_len == -1) {
+ (void **)&password.data, &pw_len, false)) {
return false;
}
password.length = pw_len;
@@ -281,12 +278,11 @@ static bool kpasswd_process_request(struct kdc_server *kdc,
reply);
}
- pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx),
+ if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(kdc->task->lp_ctx),
CH_UTF8, CH_UTF16,
(const char *)chpw.newpasswd.data,
chpw.newpasswd.length,
- (void **)&password.data);
- if (pw_len == -1) {
+ (void **)&password.data, &pw_len, false)) {
free_ChangePasswdDataMS(&chpw);
return false;
}
diff --git a/source4/lib/events/tevent_s4.c b/source4/lib/events/tevent_s4.c
index a05ac0796f..89ca7bbe5c 100644
--- a/source4/lib/events/tevent_s4.c
+++ b/source4/lib/events/tevent_s4.c
@@ -41,7 +41,7 @@ static void ev_wrap_debug(void *context, enum tevent_debug_level level,
samba_level = 2;
break;
case TEVENT_DEBUG_TRACE:
- samba_level = 5;
+ samba_level = 10;
break;
};
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index eb8e0ed11e..be41151409 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -46,16 +46,7 @@
#define _LDB_H_ 1
/*! \endcond */
-#ifndef bool
-typedef int bool;
-#endif
-#ifndef true
-#define true 1
-#endif
-#ifndef false
-#define false 0
-#endif
-
+#include <stdbool.h>
#include "talloc.h"
#include "tevent.h"
#include "ldb_errors.h"
diff --git a/source4/lib/ldb/ldb_map/ldb_map.c b/source4/lib/ldb/ldb_map/ldb_map.c
index 959540374c..5b4ea7910a 100644
--- a/source4/lib/ldb/ldb_map/ldb_map.c
+++ b/source4/lib/ldb/ldb_map/ldb_map.c
@@ -35,6 +35,7 @@
* Author: Jelmer Vernooij, Martin Kuehl
*/
+#include "ldb_includes.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
diff --git a/source4/lib/ldb/ldb_map/ldb_map_inbound.c b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
index 822dea654e..455740ce59 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_inbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_inbound.c
@@ -24,6 +24,7 @@
*/
+#include "ldb_includes.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
diff --git a/source4/lib/ldb/ldb_map/ldb_map_outbound.c b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
index eb7b4590ba..ffcefad6be 100644
--- a/source4/lib/ldb/ldb_map/ldb_map_outbound.c
+++ b/source4/lib/ldb/ldb_map/ldb_map_outbound.c
@@ -25,6 +25,7 @@
*/
+#include "ldb_includes.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
diff --git a/source4/lib/ldb/tools/cmdline.h b/source4/lib/ldb/tools/cmdline.h
index 3473d62a16..45619ce496 100644
--- a/source4/lib/ldb/tools/cmdline.h
+++ b/source4/lib/ldb/tools/cmdline.h
@@ -50,5 +50,4 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const
void (*usage)(void));
-struct ldb_control **parse_controls(void *mem_ctx, char **control_strings);
int handle_controls_reply(struct ldb_control **reply, struct ldb_control **request);
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c
index 1d238f4e23..c558805e04 100644
--- a/source4/lib/registry/ldb.c
+++ b/source4/lib/registry/ldb.c
@@ -60,9 +60,9 @@ static void reg_ldb_unpack_value(TALLOC_CTX *mem_ctx,
case REG_SZ:
case REG_EXPAND_SZ:
if (val != NULL)
- data->length = convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16,
+ convert_string_talloc(mem_ctx, CH_UTF8, CH_UTF16,
val->data, val->length,
- (void **)&data->data);
+ (void **)&data->data, &data->length, false);
else {
data->data = NULL;
data->length = 0;
@@ -105,10 +105,10 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx,
case REG_SZ:
case REG_EXPAND_SZ:
if (data.data[0] != '\0') {
- val.length = convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8,
+ convert_string_talloc(mem_ctx, CH_UTF16, CH_UTF8,
(void *)data.data,
data.length,
- (void **)&val.data);
+ (void **)&val.data, &val.length, false);
ldb_msg_add_value(msg, "data", &val, NULL);
} else {
ldb_msg_add_empty(msg, "data", LDB_FLAG_MOD_DELETE, NULL);
diff --git a/source4/lib/registry/tests/generic.c b/source4/lib/registry/tests/generic.c
index f1fa5ad0b2..3de7602e53 100644
--- a/source4/lib/registry/tests/generic.c
+++ b/source4/lib/registry/tests/generic.c
@@ -53,8 +53,8 @@ static bool test_reg_val_data_string_dword(struct torture_context *ctx)
static bool test_reg_val_data_string_sz(struct torture_context *ctx)
{
DATA_BLOB db;
- db.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
- "bla", 3, (void **)&db.data);
+ convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
+ "bla", 3, (void **)&db.data, &db.length, false);
torture_assert_str_equal(ctx, "bla",
reg_val_data_string(ctx, lp_iconv_convenience(ctx->lp_ctx), REG_SZ, db),
"sz failed");
@@ -88,10 +88,10 @@ static bool test_reg_val_data_string_empty(struct torture_context *ctx)
static bool test_reg_val_description(struct torture_context *ctx)
{
DATA_BLOB data;
- data.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
+ convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
"stationary traveller",
strlen("stationary traveller"),
- (void **)&data.data);
+ (void **)&data.data, &data.length, false);
torture_assert_str_equal(ctx, "camel = REG_SZ : stationary traveller",
reg_val_description(ctx, lp_iconv_convenience(ctx->lp_ctx), "camel", REG_SZ, data),
"reg_val_description failed");
@@ -102,10 +102,10 @@ static bool test_reg_val_description(struct torture_context *ctx)
static bool test_reg_val_description_nullname(struct torture_context *ctx)
{
DATA_BLOB data;
- data.length = convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
+ convert_string_talloc_convenience(ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF8, CH_UTF16,
"west berlin",
strlen("west berlin"),
- (void **)&data.data);
+ (void **)&data.data, &data.length, false);
torture_assert_str_equal(ctx, "<No Name> = REG_SZ : west berlin",
reg_val_description(ctx, lp_iconv_convenience(ctx->lp_ctx), NULL, REG_SZ, data),
"description with null name failed");
diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c
index 38f994f386..a1897eff2e 100644
--- a/source4/lib/registry/util.c
+++ b/source4/lib/registry/util.c
@@ -65,7 +65,7 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx,
case REG_SZ:
convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UTF16, CH_UNIX,
data.data, data.length,
- (void **)&ret);
+ (void **)&ret, NULL, false);
return ret;
case REG_BINARY:
ret = data_blob_hex_string(mem_ctx, &data);
@@ -123,9 +123,9 @@ _PUBLIC_ bool reg_string_to_val(TALLOC_CTX *mem_ctx,
{
case REG_SZ:
case REG_EXPAND_SZ:
- data->length = convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16,
+ convert_string_talloc_convenience(mem_ctx, iconv_convenience, CH_UNIX, CH_UTF16,
data_str, strlen(data_str),
- (void **)&data->data);
+ (void **)&data->data, &data->length, false);
break;
case REG_DWORD: {
diff --git a/source4/lib/tdr/tdr.c b/source4/lib/tdr/tdr.c
index 2d1d1ca7e1..8b62ea0c2b 100644
--- a/source4/lib/tdr/tdr.c
+++ b/source4/lib/tdr/tdr.c
@@ -130,7 +130,7 @@ NTSTATUS tdr_print_uint32(struct tdr_print *tdr, const char *name, uint32_t *v)
NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, uint32_t length, uint32_t el_size, charset_t chset)
{
- int ret;
+ size_t ret;
if (length == -1) {
switch (chset) {
@@ -153,9 +153,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v,
TDR_PULL_NEED_BYTES(tdr, el_size*length);
- ret = convert_string_talloc_convenience(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v));
-
- if (ret == -1) {
+ if (!convert_string_talloc_convenience(ctx, tdr->iconv_convenience, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v), &ret, false)) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -166,7 +164,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v,
NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, uint32_t el_size, charset_t chset)
{
- ssize_t ret, required;
+ size_t ret, required;
if (length == -1) {
length = strlen(*v) + 1; /* Extra element for null character */
@@ -175,9 +173,7 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length,
required = el_size * length;
TDR_PUSH_NEED_BYTES(tdr, required);
- ret = convert_string_convenience(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required);
-
- if (ret == -1) {
+ if (!convert_string_convenience(tdr->iconv_convenience, CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required, &ret, false)) {
return NT_STATUS_INVALID_PARAMETER;
}
diff --git a/source4/libcli/auth/smbencrypt.c b/source4/libcli/auth/smbencrypt.c
index bbb363e0dd..c6118c6568 100644
--- a/source4/libcli/auth/smbencrypt.c
+++ b/source4/libcli/auth/smbencrypt.c
@@ -63,11 +63,12 @@ bool SMBencrypt(const char *passwd, const uint8_t *c8, uint8_t p24[24])
bool E_md4hash(const char *passwd, uint8_t p16[16])
{
- int len;
- void *wpwd;
+ size_t len;
+ smb_ucs2_t *wpwd;
+ bool ret;
- len = push_ucs2_talloc(NULL, &wpwd, passwd);
- if (len < 2) {
+ ret = push_ucs2_talloc(NULL, &wpwd, passwd, &len);
+ if (!ret || len < 2) {
/* We don't want to return fixed data, as most callers
* don't check */
mdfour(p16, (const uint8_t *)passwd, strlen(passwd));
@@ -75,7 +76,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16])
}
len -= 2;
- mdfour(p16, wpwd, len);
+ mdfour(p16, (const uint8_t *)wpwd, len);
talloc_free(wpwd);
return true;
@@ -116,10 +117,11 @@ bool ntv2_owf_gen(const uint8_t owf[16],
bool upper_case_domain, /* Transform the domain into UPPER case */
uint8_t kr_buf[16])
{
- void *user;
- void *domain;
+ smb_ucs2_t *user;
+ smb_ucs2_t *domain;
size_t user_byte_len;
size_t domain_byte_len;
+ bool ret;
HMACMD5Context ctx;
TALLOC_CTX *mem_ctx = talloc_init("ntv2_owf_gen for %s\\%s", domain_in, user_in);
@@ -150,15 +152,15 @@ bool ntv2_owf_gen(const uint8_t owf[16],
}
}
- user_byte_len = push_ucs2_talloc(mem_ctx, &user, user_in);
- if (user_byte_len == (ssize_t)-1) {
+ ret = push_ucs2_talloc(mem_ctx, &user, user_in, &user_byte_len );
+ if (!ret) {
DEBUG(0, ("push_uss2_talloc() for user returned -1 (probably talloc() failure)\n"));
talloc_free(mem_ctx);
return false;
}
- domain_byte_len = push_ucs2_talloc(mem_ctx, &domain, domain_in);
- if (domain_byte_len == (ssize_t)-1) {
+ ret = push_ucs2_talloc(mem_ctx, &domain, domain_in, &domain_byte_len);
+ if (!ret) {
DEBUG(0, ("push_ucs2_talloc() for domain returned -1 (probably talloc() failure)\n"));
talloc_free(mem_ctx);
return false;
@@ -172,14 +174,14 @@ bool ntv2_owf_gen(const uint8_t owf[16],
domain_byte_len = domain_byte_len - 2;
hmac_md5_init_limK_to_64(owf, 16, &ctx);
- hmac_md5_update(user, user_byte_len, &ctx);
- hmac_md5_update(domain, domain_byte_len, &ctx);
+ hmac_md5_update((const void *)user, user_byte_len, &ctx);
+ hmac_md5_update((const void *)domain, domain_byte_len, &ctx);
hmac_md5_final(kr_buf, &ctx);
#ifdef DEBUG_PASSWORD
DEBUG(100, ("ntv2_owf_gen: user, domain, owfkey, kr\n"));
- dump_data(100, user, user_byte_len);
- dump_data(100, domain, domain_byte_len);
+ dump_data(100, (const void *)user, user_byte_len);
+ dump_data(100, (const void *)domain, domain_byte_len);
dump_data(100, owf, 16);
dump_data(100, kr_buf, 16);
#endif
diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c
index 34fa4365ca..09ecb40002 100644
--- a/source4/libcli/raw/rawfileinfo.c
+++ b/source4/libcli/raw/rawfileinfo.c
@@ -49,7 +49,7 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
while (blob.length - ofs >= 24) {
uint_t n = io->num_streams;
uint32_t nlen, len;
- ssize_t size;
+ bool ret;
void *vstr;
io->streams =
talloc_realloc(mem_ctx, io->streams, struct stream_struct, n+1);
@@ -62,10 +62,10 @@ NTSTATUS smbcli_parse_stream_info(DATA_BLOB blob, TALLOC_CTX *mem_ctx,
if (nlen > blob.length - (ofs + 24)) {
return NT_STATUS_INFO_LENGTH_MISMATCH;
}
- size = convert_string_talloc(io->streams,
+ ret = convert_string_talloc(io->streams,
CH_UTF16, CH_UNIX,
- blob.data+ofs+24, nlen, &vstr);
- if (size == -1) {
+ blob.data+ofs+24, nlen, &vstr, NULL, false);
+ if (!ret) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
io->streams[n].stream_name.s = (const char *)vstr;
diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c
index 029d56428d..0f04190a8b 100644
--- a/source4/libcli/raw/rawrequest.c
+++ b/source4/libcli/raw/rawrequest.c
@@ -558,7 +558,8 @@ static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX *
char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2, alignment=0;
- ssize_t ret;
+ bool ret;
+ size_t ret_size;
if (!(flags & STR_NOALIGN) && ucs2_align(bufinfo->align_base, src, flags)) {
src++;
@@ -585,8 +586,8 @@ static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX *
return 0;
}
- ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest);
- if (ret == -1) {
+ ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)dest, &ret_size, false);
+ if (!ret) {
*dest = NULL;
return 0;
}
@@ -611,7 +612,8 @@ size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ct
char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2;
- ssize_t ret;
+ bool ret;
+ size_t ret_size;
src_len = bufinfo->data_size - PTR_DIFF(src, bufinfo->data);
if (src_len < 0) {
@@ -627,14 +629,14 @@ size_t smbcli_req_pull_ascii(struct request_bufinfo *bufinfo, TALLOC_CTX *mem_ct
src_len2++;
}
- ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)dest);
+ ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)dest, &ret_size, false);
- if (ret == -1) {
+ if (!ret) {
*dest = NULL;
return 0;
}
- return ret;
+ return ret_size;
}
/**
@@ -752,7 +754,8 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx,
const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2, alignment=0;
- ssize_t ret;
+ size_t ret_size;
+ bool ret;
char *dest2;
if (src < blob->data ||
@@ -780,8 +783,8 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx,
src_len2 = utf16_len_n(src, src_len);
- ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
- if (ret == -1) {
+ ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, &ret_size, false);
+ if (!ret) {
*dest = NULL;
return 0;
}
@@ -808,7 +811,8 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx,
const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2;
- ssize_t ret;
+ size_t ret_size;
+ bool ret;
char *dest2;
src_len = blob->length - PTR_DIFF(src, blob->data);
@@ -826,15 +830,15 @@ static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx,
src_len2++;
}
- ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
+ ret = convert_string_talloc(mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2, &ret_size, false);
- if (ret == -1) {
+ if (!ret) {
*dest = NULL;
return 0;
}
*dest = dest2;
- return ret;
+ return ret_size;
}
/**
diff --git a/source4/libcli/security/config.mk b/source4/libcli/security/config.mk
index cd5b75bb81..d6d9ad5545 100644
--- a/source4/libcli/security/config.mk
+++ b/source4/libcli/security/config.mk
@@ -3,6 +3,8 @@ PUBLIC_DEPENDENCIES = LIBNDR LIBSECURITY_COMMON
LIBSECURITY_OBJ_FILES = $(addprefix $(libclisrcdir)/security/, \
security_token.o security_descriptor.o \
- access_check.o privilege.o sddl.o)
+ access_check.o privilege.o sddl.o) \
+ ../libcli/security/secace.o \
+ ../libcli/security/secacl.o
$(eval $(call proto_header_template,$(libclisrcdir)/security/proto.h,$(LIBSECURITY_OBJ_FILES:.o=.c)))
diff --git a/source4/libcli/security/security.h b/source4/libcli/security/security.h
index 517f3e8ebe..2608c9f7ed 100644
--- a/source4/libcli/security/security.h
+++ b/source4/libcli/security/security.h
@@ -30,5 +30,6 @@ struct auth_session_info;
/* Moved the dom_sid functions to the top level dir with manual proto header */
#include "libcli/security/dom_sid.h"
-
+#include "libcli/security/secace.h"
+#include "libcli/security/secacl.h"
#include "libcli/security/proto.h"
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index e1d6b0e7a6..649a1db8d5 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -656,8 +656,8 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me
{
DATA_BLOB blob;
NTSTATUS status;
- ssize_t size;
void *vstr;
+ bool ret;
status = smb2_pull_o16s16_blob(buf, mem_ctx, ptr, &blob);
NT_STATUS_NOT_OK_RETURN(status);
@@ -675,11 +675,11 @@ NTSTATUS smb2_pull_o16s16_string(struct smb2_request_buffer *buf, TALLOC_CTX *me
return NT_STATUS_OK;
}
- size = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
- blob.data, blob.length, &vstr);
+ ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX,
+ blob.data, blob.length, &vstr, NULL, false);
data_blob_free(&blob);
(*str) = (char *)vstr;
- if (size == -1) {
+ if (!ret) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
return NT_STATUS_OK;
@@ -694,7 +694,7 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf,
{
DATA_BLOB blob;
NTSTATUS status;
- ssize_t size;
+ bool ret;
if (str == NULL) {
return smb2_push_o16s16_blob(buf, ofs, data_blob(NULL, 0));
@@ -706,12 +706,12 @@ NTSTATUS smb2_push_o16s16_string(struct smb2_request_buffer *buf,
return smb2_push_o16s16_blob(buf, ofs, blob);
}
- size = convert_string_talloc(buf->buffer, CH_UNIX, CH_UTF16,
- str, strlen(str), (void **)&blob.data);
- if (size == -1) {
+ ret = convert_string_talloc(buf->buffer, CH_UNIX, CH_UTF16,
+ str, strlen(str), (void **)&blob.data, &blob.length,
+ false);
+ if (!ret) {
return NT_STATUS_ILLEGAL_CHARACTER;
}
- blob.length = size;
status = smb2_push_o16s16_blob(buf, ofs, blob);
data_blob_free(&blob);
diff --git a/source4/libnet/libnet_samdump.c b/source4/libnet/libnet_samdump.c
index b35fef2c16..10a14655f3 100644
--- a/source4/libnet/libnet_samdump.c
+++ b/source4/libnet/libnet_samdump.c
@@ -185,9 +185,9 @@ NTSTATUS libnet_SamDump(struct libnet_context *ctx, TALLOC_CTX *mem_ctx,
if (strcasecmp_m(s->name, secret_name) != 0) {
continue;
}
- if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX,
+ if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(ctx->lp_ctx), CH_UTF16, CH_UNIX,
s->secret.data, s->secret.length,
- (void **)&secret_string) == -1) {
+ (void **)&secret_string, NULL, false)) {
r->out.error_string = talloc_asprintf(mem_ctx,
"Could not convert secret for domain %s to a string",
t->name);
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index 1b5da2dcc2..d6d996846e 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -30,7 +30,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
char *as=NULL;
uint32_t len1, ofs, len2;
uint16_t len3;
- int ret;
+ size_t ret;
charset_t chset = CH_UTF16;
unsigned byte_mul = 2;
unsigned flags = ndr->flags;
@@ -81,12 +81,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len2 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience, chset, CH_UNIX,
ndr->data+ndr->offset,
(len2 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -118,13 +117,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -157,13 +155,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -192,13 +189,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len3 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
(len3 + c_len_term)*byte_mul,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -225,13 +221,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len3 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
len3,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -246,12 +241,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
} else {
len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
}
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience, chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -271,13 +265,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
if (len1 == 0) {
as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
- (void **)&as);
- if (ret == -1) {
+ (void **)&as, &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -301,7 +294,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
{
- ssize_t s_len, c_len, d_len;
+ size_t s_len, c_len, d_len;
int chset = CH_UTF16;
unsigned flags = ndr->flags;
unsigned byte_mul = 2;
@@ -334,8 +327,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_string(struct ndr_push *ndr, int ndr_flags,
if (!(flags & LIBNDR_FLAG_STR_NOTERM)) {
s_len++;
}
- d_len = convert_string_talloc_convenience(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest);
- if (d_len == -1) {
+ if (!convert_string_talloc_convenience(ndr, ndr->iconv_convenience, CH_UNIX, chset, s, s_len, (void **)&dest, &d_len, false)) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -656,7 +648,7 @@ _PUBLIC_ enum ndr_err_code ndr_check_string_terminator(struct ndr_pull *ndr, uin
_PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset)
{
- int ret;
+ size_t ret;
if (length == 0) {
*var = talloc_strdup(ndr->current_mem_ctx, "");
return NDR_ERR_SUCCESS;
@@ -668,13 +660,12 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags,
NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
- ret = convert_string_talloc_convenience(ndr->current_mem_ctx,
+ if (!convert_string_talloc_convenience(ndr->current_mem_ctx,
ndr->iconv_convenience,
chset, CH_UNIX,
ndr->data+ndr->offset,
length*byte_mul,
- discard_const_p(void *, var));
- if (ret == -1) {
+ discard_const_p(void *, var), &ret, false)) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
@@ -685,7 +676,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags,
_PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset)
{
- ssize_t ret, required;
+ size_t ret, required;
if (NDR_BE(ndr) && chset == CH_UTF16) {
chset = CH_UTF16BE;
@@ -694,10 +685,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags,
required = byte_mul * length;
NDR_PUSH_NEED_BYTES(ndr, required);
- ret = convert_string_convenience(ndr->iconv_convenience, CH_UNIX, chset,
+ if (!convert_string_convenience(ndr->iconv_convenience, CH_UNIX, chset,
var, strlen(var),
- ndr->data+ndr->offset, required);
- if (ret == -1) {
+ ndr->data+ndr->offset, required, &ret, false)) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
}
diff --git a/source4/ntptr/ntptr.h b/source4/ntptr/ntptr.h
index 24c467fe65..91817a202f 100644
--- a/source4/ntptr/ntptr.h
+++ b/source4/ntptr/ntptr.h
@@ -74,6 +74,7 @@ struct spoolss_EnumForms;
struct spoolss_EnumPorts;
struct spoolss_EnumPrintProcessors;
struct spoolss_XcvData;
+struct spoolss_GetPrintProcessorDirectory;
/* the ntptr operations structure - contains function pointers to
the backend implementations of each operation */
@@ -144,6 +145,8 @@ struct ntptr_ops {
/* PrintProcessor functions */
WERROR (*EnumPrintProcessors)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
struct spoolss_EnumPrintProcessors *r);
+ WERROR (*GetPrintProcessorDirectory)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
+ struct spoolss_GetPrintProcessorDirectory *r);
/* Printer functions */
WERROR (*EnumPrinters)(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
diff --git a/source4/ntptr/ntptr_interface.c b/source4/ntptr/ntptr_interface.c
index 109a9f560b..b65a2e32cd 100644
--- a/source4/ntptr/ntptr_interface.c
+++ b/source4/ntptr/ntptr_interface.c
@@ -263,6 +263,15 @@ WERROR ntptr_EnumPrintProcessors(struct ntptr_context *ntptr, TALLOC_CTX *mem_ct
return ntptr->ops->EnumPrintProcessors(ntptr, mem_ctx, r);
}
+WERROR ntptr_GetPrintProcessorDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
+ struct spoolss_GetPrintProcessorDirectory *r)
+{
+ if (!ntptr->ops->GetPrintProcessorDirectory) {
+ return WERR_NOT_SUPPORTED;
+ }
+ return ntptr->ops->GetPrintProcessorDirectory(ntptr, mem_ctx, r);
+}
+
/* Printer functions */
WERROR ntptr_EnumPrinters(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
diff --git a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
index c570b03a35..459babce0e 100644
--- a/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
+++ b/source4/ntptr/simple_ldb/ntptr_simple_ldb.c
@@ -750,6 +750,47 @@ static WERROR sptr_GetPrinterForm(struct ntptr_GenericHandle *printer, TALLOC_CT
return WERR_OK;
}
+static WERROR sptr_GetPrintProcessorDirectory(struct ntptr_context *ntptr, TALLOC_CTX *mem_ctx,
+ struct spoolss_GetPrintProcessorDirectory *r)
+{
+ union spoolss_PrintProcessorDirectoryInfo *info;
+ const char *prefix;
+ const char *postfix;
+
+ /*
+ * NOTE: normally r->in.level is 1, but both w2k3 and nt4 sp6a
+ * are ignoring the r->in.level completely, so we do :-)
+ */
+
+ /*
+ * TODO: check the server name is ours
+ * - if it's a invalid UNC then return WERR_INVALID_NAME
+ * - if it's the wrong host name return WERR_INVALID_PARAM
+ * - if it's "" then we need to return a local WINDOWS path
+ */
+ if (!r->in.server || !r->in.server[0]) {
+ prefix = "C:\\PRTPROCS";
+ } else {
+ prefix = talloc_asprintf(mem_ctx, "%s\\prnproc$", r->in.server);
+ W_ERROR_HAVE_NO_MEMORY(prefix);
+ }
+
+ if (r->in.environment && strcmp(SPOOLSS_ARCHITECTURE_NT_X86, r->in.environment) == 0) {
+ postfix = "W32X86";
+ } else {
+ return WERR_INVALID_ENVIRONMENT;
+ }
+
+ info = talloc(mem_ctx, union spoolss_PrintProcessorDirectoryInfo);
+ W_ERROR_HAVE_NO_MEMORY(info);
+
+ info->info1.directory_name = talloc_asprintf(mem_ctx, "%s\\%s", prefix, postfix);
+ W_ERROR_HAVE_NO_MEMORY(info->info1.directory_name);
+
+ r->out.info = info;
+ return WERR_OK;
+}
+
/*
initialialise the simble ldb backend, registering ourselves with the ntptr subsystem
@@ -793,6 +834,8 @@ static const struct ntptr_ops ntptr_simple_ldb_ops = {
/* PrintProcessor functions */
/* .EnumPrintProcessors = sptr_EnumPrintProcessors,
*/
+ .GetPrintProcessorDirectory = sptr_GetPrintProcessorDirectory,
+
/* Printer functions */
.EnumPrinters = sptr_EnumPrinters,
.OpenPrinter = sptr_OpenPrinter,
diff --git a/source4/param/provision.c b/source4/param/provision.c
index 7a06f77d96..c8bff59deb 100644
--- a/source4/param/provision.c
+++ b/source4/param/provision.c
@@ -34,6 +34,7 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
struct provision_settings *settings,
struct provision_result *result)
{
+ char *configfile;
PyObject *provision_mod, *provision_dict, *provision_fn, *py_result, *parameters;
DEBUG(0,("Provision for Become-DC test using python\n"));
@@ -76,8 +77,11 @@ NTSTATUS provision_bare(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
settings->targetdir));
parameters = PyDict_New();
- PyDict_SetItemString(parameters, "smbconf",
- PyString_FromString(lp_configfile(lp_ctx)));
+ configfile = lp_configfile(lp_ctx);
+ if (configfile != NULL) {
+ PyDict_SetItemString(parameters, "smbconf",
+ PyString_FromString(configfile));
+ }
PyDict_SetItemString(parameters, "rootdn",
PyString_FromString(settings->root_dn_str));
diff --git a/source4/param/util.c b/source4/param/util.c
index 92728d505a..3881107cbc 100644
--- a/source4/param/util.c
+++ b/source4/param/util.c
@@ -107,7 +107,7 @@ char *config_path(TALLOC_CTX* mem_ctx, struct loadparm_context *lp_ctx,
char *fname, *config_dir, *p;
config_dir = talloc_strdup(mem_ctx, lp_configfile(lp_ctx));
if (config_dir == NULL) {
- return NULL;
+ config_dir = talloc_strdup(mem_ctx, lp_default_path());
}
p = strrchr(config_dir, '/');
if (p == NULL) {
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index f1c063ed90..2efddc74fc 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -1220,7 +1220,7 @@ static WERROR dcesrv_netr_DsRGetDCNameEx2(struct dcesrv_call_state *dce_call, TA
/* Win7-beta will send the domain name in the form the user typed, so we have to cope
with both the short and long form here */
- if (strcasecmp(r->in.domain_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx)) == 0) {
+ if (r->in.domain_name == NULL || strcasecmp(r->in.domain_name, lp_workgroup(dce_call->conn->dce_ctx->lp_ctx)) == 0) {
r->in.domain_name = lp_realm(dce_call->conn->dce_ctx->lp_ctx);
}
diff --git a/source4/rpc_server/samr/samr_password.c b/source4/rpc_server/samr/samr_password.c
index ff8215a673..f334eeb8f3 100644
--- a/source4/rpc_server/samr/samr_password.c
+++ b/source4/rpc_server/samr/samr_password.c
@@ -196,7 +196,7 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
DATA_BLOB lm_pwd_blob;
uint8_t new_lm_hash[16];
struct samr_Password lm_verifier;
- ssize_t unicode_pw_len;
+ size_t unicode_pw_len;
if (pwbuf == NULL) {
return NT_STATUS_INVALID_PARAMETER;
@@ -251,22 +251,21 @@ NTSTATUS dcesrv_samr_OemChangePasswordUser2(struct dcesrv_call_state *dce_call,
return NT_STATUS_WRONG_PASSWORD;
}
- if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx),
+ if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx),
CH_DOS, CH_UNIX,
(const char *)new_password.data,
new_password.length,
- (void **)&new_pass) == -1) {
+ (void **)&new_pass, NULL, false)) {
DEBUG(3,("samr: failed to convert incoming password buffer to unix charset\n"));
ldb_transaction_cancel(sam_ctx);
return NT_STATUS_WRONG_PASSWORD;
}
- unicode_pw_len = convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx),
+ if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx),
CH_DOS, CH_UTF16,
(const char *)new_password.data,
new_password.length,
- (void **)&new_unicode_password.data);
- if (unicode_pw_len == -1) {
+ (void **)&new_unicode_password.data, &unicode_pw_len, false)) {
DEBUG(3,("samr: failed to convert incoming password buffer to UTF16 charset\n"));
ldb_transaction_cancel(sam_ctx);
return NT_STATUS_WRONG_PASSWORD;
@@ -429,11 +428,11 @@ NTSTATUS dcesrv_samr_ChangePasswordUser3(struct dcesrv_call_state *dce_call,
* this) */
if (lm_pwd && r->in.lm_verifier != NULL) {
char *new_pass;
- if (convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx),
+ if (!convert_string_talloc_convenience(mem_ctx, lp_iconv_convenience(dce_call->conn->dce_ctx->lp_ctx),
CH_UTF16, CH_UNIX,
(const char *)new_password.data,
new_password.length,
- (void **)&new_pass) != -1) {
+ (void **)&new_pass, NULL, false)) {
E_deshash(new_pass, new_lm_hash);
E_old_pw_hash(new_nt_hash, lm_pwd->hash, lm_verifier.hash);
if (memcmp(lm_verifier.hash, r->in.lm_verifier->hash, 16) != 0) {
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 33c657cc1b..f1ef2f0acb 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -454,7 +454,19 @@ static WERROR dcesrv_spoolss_EnumPrintProcessors(struct dcesrv_call_state *dce_c
static WERROR dcesrv_spoolss_GetPrintProcessorDirectory(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_GetPrintProcessorDirectory *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ struct ntptr_context *ntptr = talloc_get_type(dce_call->context->private_data, struct ntptr_context);
+ WERROR status;
+ struct smb_iconv_convenience *ic = lp_iconv_convenience(ntptr->lp_ctx);
+
+ status = dcesrv_spoolss_check_server_name(dce_call, mem_ctx, r->in.server);
+ W_ERROR_NOT_OK_RETURN(status);
+
+ status = ntptr_GetPrintProcessorDirectory(ntptr, mem_ctx, r);
+ W_ERROR_NOT_OK_RETURN(status);
+
+ *r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_PrintProcessorDirectoryInfo, ic, r->out.info, r->in.level);
+ r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL);
+ return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
}
@@ -534,7 +546,11 @@ static WERROR dcesrv_spoolss_EndDocPrinter(struct dcesrv_call_state *dce_call, T
static WERROR dcesrv_spoolss_AddJob(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
struct spoolss_AddJob *r)
{
- DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR);
+ if (r->in.level != 1) {
+ return WERR_UNKNOWN_LEVEL;
+ }
+
+ return WERR_INVALID_PARAM;
}
diff --git a/source4/script/installman.sh b/source4/script/installman.sh
index ae99bceacf..a3b6ec0d93 100755
--- a/source4/script/installman.sh
+++ b/source4/script/installman.sh
@@ -6,7 +6,7 @@ MANPAGES=$*
for I in $MANPAGES
do
- SECTION=`echo $I | grep -o '.$'`
+ SECTION=`echo -n $I | sed "s/.*\(.\)$/\1/"
DIR="$MANDIR/man$SECTION"
if [ ! -d "$DIR" ]
then
diff --git a/source4/script/uninstallman.sh b/source4/script/uninstallman.sh
index 72b523ed9e..9b087c68bb 100755
--- a/source4/script/uninstallman.sh
+++ b/source4/script/uninstallman.sh
@@ -8,7 +8,7 @@ MANPAGES=$*
for I in $MANPAGES
do
- SECTION=`echo $I | grep -o '.$'`
+ SECTION=`echo -n $I | sed "s/.*\(.\)$/\1/"
FNAME=$MANDIR/man$SECTION/$I
if test -f $FNAME; then
echo Deleting $FNAME
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index e9fc26af20..a49e6e1ead 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -223,7 +223,7 @@ def check_all_substituted(text):
:param text: The text to search for substitution variables
"""
if not "${" in text:
- return
+ return
var_start = text.find("${")
var_end = text.find("}", var_start)
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 1ac0e4553e..8029565399 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -53,7 +53,7 @@ def find_setup_dir():
"""Find the setup directory used by provision."""
dirname = os.path.dirname(__file__)
if "/site-packages/" in dirname:
- prefix = dirname[:dirname.index("/site-packages/")]
+ prefix = "/".join(dirname[:dirname.index("/site-packages/")].split("/")[:-2])
for suffix in ["share/setup", "share/samba/setup", "setup"]:
ret = os.path.join(prefix, suffix)
if os.path.isdir(ret):
@@ -1132,7 +1132,8 @@ def provision(setup_dir, message, session_info,
message("NetBIOS Domain: %s" % names.domain)
message("DNS Domain: %s" % names.dnsdomain)
message("DOMAIN SID: %s" % str(domainsid))
- message("Admin password: %s" % adminpass)
+ if samdb_fill == FILL_FULL:
+ message("Admin password: %s" % adminpass)
result = ProvisionResult()
result.domaindn = domaindn
@@ -1365,7 +1366,7 @@ def provision_backend(setup_dir=None, message=None,
"MMRDN": names.domaindn,
"LDAPSERVER" : url,
"MMR_PASSWORD": mmr_pass })
- # olc = yes?
+ # olc = yes?
olc_config_pass = ""
olc_config_acl = ""
olc_syncrepl_config = ""
diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py
index 9cc55e5629..614970d3ec 100644
--- a/source4/scripting/python/samba/samdb.py
+++ b/source4/scripting/python/samba/samdb.py
@@ -201,11 +201,11 @@ userAccountControl: %u
glue.dsdb_attach_schema_from_ldif_file(self, pf, df)
def set_invocation_id(self, invocation_id):
- """Set the invocation id for this SamDB handle.
-
- :param invocation_id: GUID of the invocation id.
- """
- glue.dsdb_set_ntds_invocation_id(self, invocation_id)
+ """Set the invocation id for this SamDB handle.
+
+ :param invocation_id: GUID of the invocation id.
+ """
+ glue.dsdb_set_ntds_invocation_id(self, invocation_id)
def setexpiry(self, user, expiry_seconds, noexpiry):
"""Set the password expiry for a user
diff --git a/source4/scripting/python/samba/tests/__init__.py b/source4/scripting/python/samba/tests/__init__.py
index d827bfa004..b342b93c49 100644
--- a/source4/scripting/python/samba/tests/__init__.py
+++ b/source4/scripting/python/samba/tests/__init__.py
@@ -70,8 +70,8 @@ class SubstituteVarTestCase(unittest.TestCase):
samba.substitute_var("foo ${bla} gsff", {"bar": "bla"}))
def test_check_all_substituted(self):
- samba.check_all_substituted("nothing to see here")
- self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}")
+ samba.check_all_substituted("nothing to see here")
+ self.assertRaises(Exception, samba.check_all_substituted, "Not subsituted: ${FOOBAR}")
class LdbExtensionTests(TestCaseInTempDir):
diff --git a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
index 12638e2397..62268005c2 100644
--- a/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
+++ b/source4/scripting/python/samba/tests/dcerpc/rpcecho.py
@@ -49,7 +49,7 @@ class RpcEchoTests(RpcInterfaceTestCase):
surrounding_struct.x = 4
surrounding_struct.surrounding = [1,2,3,4]
y = self.conn.TestSurrounding(surrounding_struct)
- self.assertEquals(8 * [0], y.surrounding)
+ self.assertEquals(4 * [0], y.surrounding)
def test_manual_request(self):
self.assertEquals("\x01\x00\x00\x00", self.conn.request(0, chr(0) * 4))
diff --git a/source4/scripting/python/samba/tests/provision.py b/source4/scripting/python/samba/tests/provision.py
index 352357f694..fdac9d4ea2 100644
--- a/source4/scripting/python/samba/tests/provision.py
+++ b/source4/scripting/python/samba/tests/provision.py
@@ -56,7 +56,7 @@ class ProvisionTestCase(samba.tests.TestCaseInTempDir):
machinepass="machinepass", dnsdomain="example.com")
self.assertEquals(1,
len(secrets_ldb.search("samAccountName=krbtgt,flatname=EXAMPLE,CN=Principals")))
- self.assertEquals("keytab.path",
+ self.assertEquals("keytab.path",
secrets_ldb.searchone(basedn="flatname=EXAMPLE,CN=primary domains",
expression="(privateKeytab=*)",
attribute="privateKeytab"))
diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh
index 36e3bbe364..39e6cff274 100755
--- a/source4/selftest/tests.sh
+++ b/source4/selftest/tests.sh
@@ -23,6 +23,11 @@ then
PERL=perl
fi
+if [ ! -n "$PYTHON" ]
+then
+ PYTHON=python
+fi
+
plantest() {
name=$1
env=$2
@@ -121,7 +126,7 @@ all_tests="$ncalrpc_tests $ncacn_np_tests $ncacn_ip_tcp_tests $slow_ncalrpc_test
# Make sure all tests get run
for t in `$smb4torture --list | grep "^RPC-"`
do
- echo $all_tests | grep $t > /dev/null
+ echo $all_tests | grep "$t" > /dev/null
if [ $? -ne 0 ]
then
auto_rpc_tests="$auto_rpc_tests $t"
@@ -169,7 +174,7 @@ done
# Tests for the NET API
-net=`$smb4torture --list | grep ^NET-`
+net=`$smb4torture --list | grep "^NET-"`
for t in $net; do
plansmbtorturetest "$t" dc "\$SERVER[$VALIDATE]" -U"\$USERNAME"%"\$PASSWORD" -W "\$DOMAIN" "$*"
@@ -394,7 +399,6 @@ then
plantest "nss.test using winbind" member $VALGRIND $nsstest4 $samba4bindir/shared/libnss_winbind.so
fi
-PYTHON=/usr/bin/python
SUBUNITRUN="$VALGRIND $PYTHON $samba4srcdir/scripting/bin/subunitrun"
plantest "ldb.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/lib/ldb/tests/python/" $SUBUNITRUN api
plantest "credentials.python" none PYTHONPATH="$PYTHONPATH:$samba4srcdir/auth/credentials/tests" $SUBUNITRUN bindings
diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c
index 444714fa5e..6846f80594 100644
--- a/source4/smb_server/smb/request.c
+++ b/source4/smb_server/smb/request.c
@@ -482,7 +482,7 @@ size_t req_append_var_block(struct smbsrv_request *req,
static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2, alignment=0;
- ssize_t ret;
+ bool ret;
char *dest2;
if (!(flags & STR_NOALIGN) && ucs2_align(bufinfo->align_base, src, flags)) {
@@ -513,9 +513,9 @@ static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest,
return src_len2 + alignment;
}
- ret = convert_string_talloc(bufinfo->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2);
+ ret = convert_string_talloc(bufinfo->mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, NULL, false);
- if (ret == -1) {
+ if (!ret) {
*dest = NULL;
return 0;
}
@@ -540,7 +540,7 @@ static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest,
static size_t req_pull_ascii(struct request_bufinfo *bufinfo, const char **dest, const uint8_t *src, int byte_len, uint_t flags)
{
int src_len, src_len2;
- ssize_t ret;
+ bool ret;
char *dest2;
if (flags & STR_NO_RANGE_CHECK) {
@@ -562,9 +562,9 @@ static size_t req_pull_ascii(struct request_bufinfo *bufinfo, const char **dest,
src_len2++;
}
- ret = convert_string_talloc(bufinfo->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2);
+ ret = convert_string_talloc(bufinfo->mem_ctx, CH_DOS, CH_UNIX, src, src_len2, (void **)&dest2, NULL, false);
- if (ret == -1) {
+ if (!ret) {
*dest = NULL;
return 0;
}
diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c
index 0ae7f6036b..5ac299dbbe 100644
--- a/source4/torture/basic/charset.c
+++ b/source4/torture/basic/charset.c
@@ -42,7 +42,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx,
{
union smb_open io;
char *fname, *fname2=NULL, *ucs_name;
- int i;
+ size_t i;
NTSTATUS status;
ucs_name = talloc_size(mem_ctx, (1+u_name_len)*2);
@@ -56,8 +56,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx,
}
SSVAL(ucs_name, i*2, 0);
- i = convert_string_talloc_convenience(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
- if (i == -1) {
+ if (!convert_string_talloc_convenience(ucs_name, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname, &i, false)) {
torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n");
talloc_free(ucs_name);
return NT_STATUS_NO_MEMORY;
diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c
index f0700f73a0..ca6c2fd576 100644
--- a/source4/torture/basic/utable.c
+++ b/source4/torture/basic/utable.c
@@ -32,7 +32,8 @@ bool torture_utable(struct torture_context *tctx,
const char *alt_name;
int fnum;
uint8_t c2[4];
- int c, len, fd;
+ int c, fd;
+ size_t len;
int chars_allowed=0, alt_allowed=0;
uint8_t valid[0x10000];
@@ -49,9 +50,9 @@ bool torture_utable(struct torture_context *tctx,
SSVAL(c2, 0, c);
strncpy(fname, "\\utable\\x", sizeof(fname)-1);
p = fname+strlen(fname);
- len = convert_string_convenience(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX,
+ convert_string_convenience(lp_iconv_convenience(tctx->lp_ctx), CH_UTF16, CH_UNIX,
c2, 2,
- p, sizeof(fname)-strlen(fname));
+ p, sizeof(fname)-strlen(fname), &len, false);
p[len] = 0;
strncat(fname,"_a_long_extension",sizeof(fname)-1);
@@ -102,15 +103,15 @@ static char *form_name(struct smb_iconv_convenience *iconv_convenience, int c)
static char fname[256];
uint8_t c2[4];
char *p;
- int len;
+ size_t len;
strncpy(fname, "\\utable\\", sizeof(fname)-1);
p = fname+strlen(fname);
SSVAL(c2, 0, c);
- len = convert_string_convenience(iconv_convenience, CH_UTF16, CH_UNIX,
+ convert_string_convenience(iconv_convenience, CH_UTF16, CH_UNIX,
c2, 2,
- p, sizeof(fname)-strlen(fname));
+ p, sizeof(fname)-strlen(fname), &len, false);
p[len] = 0;
return fname;
}
diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c
index 9d629f0bbf..951d91a684 100644
--- a/source4/torture/raw/rename.c
+++ b/source4/torture/raw/rename.c
@@ -516,6 +516,91 @@ done:
return ret;
}
+/*
+ test dir rename.
+*/
+static bool test_dir_rename(struct torture_context *tctx, struct smbcli_state *cli)
+{
+ union smb_open io;
+ union smb_rename ren_io;
+ NTSTATUS status;
+ const char *dname1 = BASEDIR "\\dir_for_rename";
+ const char *dname2 = BASEDIR "\\renamed_dir";
+ const char *fname = BASEDIR "\\dir_for_rename\\file.txt";
+ bool ret = true;
+ int fnum = -1;
+
+ printf("Checking rename on a directory containing an open file.\n");
+
+ if (!torture_setup_dir(cli, BASEDIR)) {
+ return false;
+ }
+
+ /* create a directory */
+ smbcli_rmdir(cli->tree, dname1);
+ smbcli_rmdir(cli->tree, dname2);
+ smbcli_unlink(cli->tree, dname1);
+ smbcli_unlink(cli->tree, dname2);
+
+ ZERO_STRUCT(io);
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.fname = dname1;
+ status = smb_raw_open(cli->tree, tctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ fnum = io.ntcreatex.out.file.fnum;
+ smbcli_close(cli->tree, fnum);
+
+ /* Now create and hold open a file. */
+ ZERO_STRUCT(io);
+
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+ io.ntcreatex.in.create_options = 0;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = fname;
+
+ /* Create the file. */
+
+ status = smb_raw_open(cli->tree, tctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+
+ /* Now try and rename the directory. */
+
+ ZERO_STRUCT(ren_io);
+ ren_io.generic.level = RAW_RENAME_RENAME;
+ ren_io.rename.in.pattern1 = dname1;
+ ren_io.rename.in.pattern2 = dname2;
+ ren_io.rename.in.attrib = 0;
+
+ status = smb_raw_rename(cli->tree, &ren_io);
+ CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED);
+
+done:
+
+ if (fnum != -1) {
+ smbcli_close(cli->tree, fnum);
+ }
+ smb_raw_exit(cli->session);
+ smbcli_deltree(cli->tree, BASEDIR);
+ return ret;
+}
+
extern bool test_trans2rename(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2);
extern bool test_nttransrename(struct torture_context *tctx, struct smbcli_state *cli1);
@@ -533,6 +618,7 @@ struct torture_suite *torture_raw_rename(TALLOC_CTX *mem_ctx)
torture_suite_add_1smb_test(suite, "nttransrename", test_nttransrename);
torture_suite_add_1smb_test(suite, "ntrename", test_ntrename);
torture_suite_add_1smb_test(suite, "osxrename", test_osxrename);
+ torture_suite_add_1smb_test(suite, "directory rename", test_dir_rename);
return suite;
}
diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c
index 0622e0809d..d0d21ccc06 100644
--- a/source4/torture/raw/streams.c
+++ b/source4/torture/raw/streams.c
@@ -1454,7 +1454,7 @@ static bool test_stream_create_disposition(struct torture_context *tctx,
status = smb_raw_open(cli->tree, mem_ctx, &io);
CHECK_STATUS(status, NT_STATUS_OK);
smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
- if (!check_stream_list(cli, fname, 2, &default_stream_name)) {
+ if (!check_stream_list(cli, fname, 1, &default_stream_name)) {
goto done;
}
@@ -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/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c
index c9e65cf493..7cacba7418 100644
--- a/source4/torture/rpc/samba3rpc.c
+++ b/source4/torture/rpc/samba3rpc.c
@@ -2537,7 +2537,7 @@ static NTSTATUS get_servername(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree,
memcpy(servername, r.out.info.info0.name, 16);
servername[16] = '\0';
- if (pull_ascii_talloc(mem_ctx, name, servername) < 0) {
+ if (!pull_ascii_talloc(mem_ctx, name, servername, NULL)) {
return NT_STATUS_NO_MEMORY;
}
diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index db4657e835..ce9bf5ea6e 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -1150,7 +1150,7 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
DATA_BLOB lm_response = data_blob(NULL, 0);
char *password;
char *dospw;
- void *unicodepw;
+ smb_ucs2_t *unicodepw;
uint8_t user_session_key[16];
uint8_t lm_key[16];
@@ -1161,8 +1161,8 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
ZERO_STRUCT(user_session_key);
- if ((push_ucs2_talloc(samlogon_state->mem_ctx,
- &unicodepw, samlogon_state->password)) == -1) {
+ if (!push_ucs2_talloc(samlogon_state->mem_ctx,
+ &unicodepw, samlogon_state->password, NULL)) {
DEBUG(0, ("push_ucs2_allocate failed!\n"));
exit(1);
}
@@ -1171,11 +1171,11 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
password = strupper_talloc(samlogon_state->mem_ctx, samlogon_state->password);
- if ((convert_string_talloc_convenience(samlogon_state->mem_ctx,
+ if (!convert_string_talloc_convenience(samlogon_state->mem_ctx,
samlogon_state->iconv_convenience,
CH_UNIX, CH_DOS,
password, strlen(password)+1,
- (void**)&dospw)) == -1) {
+ (void**)&dospw, NULL, false)) {
DEBUG(0, ("convert_string_talloc failed!\n"));
exit(1);
}
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index de600e8fb3..9d8bc4b186 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -168,6 +168,69 @@ static bool test_EnumPorts(struct torture_context *tctx,
return true;
}
+static bool test_GetPrintProcessorDirectory(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct test_spoolss_context *ctx)
+{
+ NTSTATUS status;
+ struct spoolss_GetPrintProcessorDirectory r;
+ struct {
+ uint16_t level;
+ const char *server;
+ } levels[] = {{
+ .level = 1,
+ .server = NULL
+ },{
+ .level = 1,
+ .server = ""
+ },{
+ .level = 78,
+ .server = ""
+ },{
+ .level = 1,
+ .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p))
+ },{
+ .level = 1024,
+ .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p))
+ }
+ };
+ int i;
+ uint32_t needed;
+
+ for (i=0;i<ARRAY_SIZE(levels);i++) {
+ int level = levels[i].level;
+ DATA_BLOB blob;
+
+ r.in.server = levels[i].server;
+ r.in.environment = SPOOLSS_ARCHITECTURE_NT_X86;
+ r.in.level = level;
+ r.in.buffer = NULL;
+ r.in.offered = 0;
+ r.out.needed = &needed;
+
+ torture_comment(tctx, "Testing GetPrintProcessorDirectory level %u\n", r.in.level);
+
+ status = dcerpc_spoolss_GetPrintProcessorDirectory(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status,
+ "dcerpc_spoolss_GetPrintProcessorDirectory failed");
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER,
+ "GetPrintProcessorDirectory unexpected return code");
+
+ blob = data_blob_talloc(ctx, NULL, needed);
+ data_blob_clear(&blob);
+ r.in.buffer = &blob;
+ r.in.offered = needed;
+
+ status = dcerpc_spoolss_GetPrintProcessorDirectory(p, ctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_GetPrintProcessorDirectory failed");
+
+ torture_assert_werr_ok(tctx, r.out.result, "GetPrintProcessorDirectory failed");
+ }
+
+ return true;
+}
+
+
static bool test_GetPrinterDriverDirectory(struct torture_context *tctx,
struct dcerpc_pipe *p,
struct test_spoolss_context *ctx)
@@ -679,7 +742,8 @@ static bool test_ClosePrinter(struct torture_context *tctx,
static bool test_GetForm(struct torture_context *tctx,
struct dcerpc_pipe *p,
struct policy_handle *handle,
- const char *form_name)
+ const char *form_name,
+ uint32_t level)
{
NTSTATUS status;
struct spoolss_GetForm r;
@@ -687,12 +751,12 @@ static bool test_GetForm(struct torture_context *tctx,
r.in.handle = handle;
r.in.form_name = form_name;
- r.in.level = 1;
+ r.in.level = level;
r.in.buffer = NULL;
r.in.offered = 0;
r.out.needed = &needed;
- torture_comment(tctx, "Testing GetForm\n");
+ torture_comment(tctx, "Testing GetForm level %d\n", r.in.level);
status = dcerpc_spoolss_GetForm(p, tctx, &r);
torture_assert_ntstatus_ok(tctx, status, "GetForm failed");
@@ -724,45 +788,54 @@ static bool test_EnumForms(struct torture_context *tctx,
bool ret = true;
uint32_t needed;
uint32_t count;
+ uint32_t levels[] = { 1, 2 };
+ int i;
- r.in.handle = handle;
- r.in.level = 1;
- r.in.buffer = NULL;
- r.in.offered = 0;
- r.out.needed = &needed;
- r.out.count = &count;
+ for (i=0; i<ARRAY_SIZE(levels); i++) {
+
+ r.in.handle = handle;
+ r.in.level = levels[i];
+ r.in.buffer = NULL;
+ r.in.offered = 0;
+ r.out.needed = &needed;
+ r.out.count = &count;
- torture_comment(tctx, "Testing EnumForms\n");
+ torture_comment(tctx, "Testing EnumForms level %d\n", levels[i]);
- status = dcerpc_spoolss_EnumForms(p, tctx, &r);
- torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
+ status = dcerpc_spoolss_EnumForms(p, tctx, &r);
+ torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
- if (print_server && W_ERROR_EQUAL(r.out.result, WERR_BADFID))
- torture_fail(tctx, "EnumForms on the PrintServer isn't supported by test server (NT4)");
+ if ((r.in.level == 2) && (W_ERROR_EQUAL(r.out.result, WERR_UNKNOWN_LEVEL))) {
+ break;
+ }
- if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
- union spoolss_FormInfo *info;
- int j;
- DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
- data_blob_clear(&blob);
- r.in.buffer = &blob;
- r.in.offered = needed;
+ if (print_server && W_ERROR_EQUAL(r.out.result, WERR_BADFID))
+ torture_fail(tctx, "EnumForms on the PrintServer isn't supported by test server (NT4)");
- status = dcerpc_spoolss_EnumForms(p, tctx, &r);
+ if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) {
+ union spoolss_FormInfo *info;
+ int j;
+ DATA_BLOB blob = data_blob_talloc(tctx, NULL, needed);
+ data_blob_clear(&blob);
+ r.in.buffer = &blob;
+ r.in.offered = needed;
- torture_assert(tctx, r.out.info, "No forms returned");
+ status = dcerpc_spoolss_EnumForms(p, tctx, &r);
- info = r.out.info;
+ torture_assert(tctx, r.out.info, "No forms returned");
- for (j = 0; j < count; j++) {
- if (!print_server)
- ret &= test_GetForm(tctx, p, handle, info[j].info1.form_name);
+ info = r.out.info;
+
+ for (j = 0; j < count; j++) {
+ if (!print_server)
+ ret &= test_GetForm(tctx, p, handle, info[j].info1.form_name, levels[i]);
+ }
}
- }
- torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
+ torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
- torture_assert_werr_ok(tctx, r.out.result, "EnumForms failed");
+ torture_assert_werr_ok(tctx, r.out.result, "EnumForms failed");
+ }
return true;
}
@@ -815,7 +888,7 @@ static bool test_AddForm(struct torture_context *tctx,
torture_assert_werr_ok(tctx, r.out.result, "AddForm failed");
- if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name);
+ if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name, 1);
{
struct spoolss_SetForm sf;
@@ -839,7 +912,7 @@ static bool test_AddForm(struct torture_context *tctx,
torture_assert_werr_ok(tctx, r.out.result, "SetForm failed");
}
- if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name);
+ if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name, 1);
if (!test_DeleteForm(tctx, p, handle, form_name)) {
ret = false;
@@ -972,6 +1045,33 @@ static bool test_SetJob(struct torture_context *tctx,
return true;
}
+static bool test_AddJob(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
+{
+ NTSTATUS status;
+ struct spoolss_AddJob r;
+ uint32_t needed;
+
+ r.in.level = 0;
+ r.in.handle = handle;
+ r.in.offered = 0;
+ r.out.needed = &needed;
+
+ torture_comment(tctx, "Testing AddJob\n");
+
+ status = dcerpc_spoolss_AddJob(p, tctx, &r);
+ torture_assert_werr_equal(tctx, r.out.result, WERR_UNKNOWN_LEVEL, "AddJob failed");
+
+ r.in.level = 1;
+
+ status = dcerpc_spoolss_AddJob(p, tctx, &r);
+ torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_PARAM, "AddJob failed");
+
+ return true;
+}
+
+
static bool test_EnumJobs(struct torture_context *tctx,
struct dcerpc_pipe *p,
struct policy_handle *handle)
@@ -1011,6 +1111,7 @@ static bool test_EnumJobs(struct torture_context *tctx,
info = r.out.info;
for (j = 0; j < count; j++) {
+
test_GetJob(tctx, p, handle, info[j].info1.job_id);
test_SetJob(tctx, p, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE);
test_SetJob(tctx, p, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME);
@@ -1090,6 +1191,7 @@ static bool test_DoPrintTest(struct torture_context *tctx,
torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EndDocPrinter failed");
torture_assert_werr_ok(tctx, e.out.result, "EndDocPrinter failed");
+ ret &= test_AddJob(tctx, p, handle);
ret &= test_EnumJobs(tctx, p, handle);
ret &= test_SetJob(tctx, p, handle, job_id, SPOOLSS_JOB_CONTROL_DELETE);
@@ -1831,6 +1933,7 @@ bool torture_rpc_spoolss(struct torture_context *torture)
ret &= test_AddForm(torture, p, &ctx->server_handle, true);
ret &= test_EnumPorts(torture, p, ctx);
ret &= test_GetPrinterDriverDirectory(torture, p, ctx);
+ ret &= test_GetPrintProcessorDirectory(torture, p, ctx);
ret &= test_EnumPrinterDrivers(torture, p, ctx);
ret &= test_EnumMonitors(torture, p, ctx);
ret &= test_EnumPrintProcessors(torture, p, ctx);
diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c
index 6ecace2ae6..08fadafe2c 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -383,7 +383,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16,
CH_UNIX, epk.out.key_buffer, *epk.out.needed,
- (void**)&ctx->printer_keys);
+ (void**)&ctx->printer_keys, NULL, false);
return true;
}
diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c
index 0f49562d8b..3c34229dff 100644
--- a/source4/torture/rpc/wkssvc.c
+++ b/source4/torture/rpc/wkssvc.c
@@ -966,7 +966,7 @@ static bool test_NetrMessageBufferSend(struct torture_context *tctx,
size_t size;
uint8_t *msg;
- size = push_ucs2_talloc(tctx, (void **)&msg, message);
+ push_ucs2_talloc(tctx, (void **)&msg, message, &size);
r.in.server_name = dcerpc_server_name(p);
r.in.message_name = dcerpc_server_name(p);
diff --git a/testprogs/blackbox/test_ldb.sh b/testprogs/blackbox/test_ldb.sh
index e301b5485a..ba4f01f4a8 100755
--- a/testprogs/blackbox/test_ldb.sh
+++ b/testprogs/blackbox/test_ldb.sh
@@ -33,7 +33,7 @@ check() {
}
-ldbsearch="$BUILDDIR/bin/ldbsearch$EXEEXT"
+ldbsearch="$VALGRIND $BUILDDIR/bin/ldbsearch$EXEEXT"
check "RootDSE" $ldbsearch $CONFIGURATION $options --basedn='' -H $p://$SERVER -s base DUMMY=x dnsHostName highestCommittedUSN || failed=`expr $failed + 1`