summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-03-23 11:47:38 +1100
committerAndrew Tridgell <tridge@samba.org>2009-03-23 11:47:38 +1100
commit7f113904eba5361d963075bcea7e36fd98ca34aa (patch)
tree2d5f22f3418a3439c306b3aaf570f52ff1d0823e /source3
parent9709ddcd3db3a96ff4d86aa1a5daf7f9261f13d3 (diff)
parent979a1b06d01817a01967d9137e4f70f222fa8eab (diff)
downloadsamba-7f113904eba5361d963075bcea7e36fd98ca34aa.tar.gz
samba-7f113904eba5361d963075bcea7e36fd98ca34aa.tar.bz2
samba-7f113904eba5361d963075bcea7e36fd98ca34aa.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in5
-rw-r--r--source3/configure.in3
-rw-r--r--source3/include/proto.h19
-rw-r--r--source3/lib/netapi/group.c10
-rw-r--r--source3/lib/netapi/user.c18
-rw-r--r--source3/libads/kerberos.c12
-rw-r--r--source3/libsmb/async_smb.c9
-rw-r--r--source3/libsmb/clikrb5.c30
-rw-r--r--source3/modules/vfs_dirsort.c194
-rw-r--r--source3/nmbd/nmbd.c6
-rw-r--r--source3/nmbd/nmbd_processlogon.c238
-rw-r--r--source3/printing/nt_printing.c11
-rw-r--r--source3/rpc_server/srv_samr_nt.c120
-rw-r--r--source3/rpc_server/srv_samr_util.c87
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c504
-rw-r--r--source3/rpcclient/cmd_spoolss.c45
-rw-r--r--source3/samba4.mk12
-rw-r--r--source3/utils/net_rpc.c4
-rw-r--r--source3/utils/net_rpc_printer.c84
19 files changed, 986 insertions, 425 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index cf74182f27..49cf8408d3 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -687,6 +687,7 @@ VFS_ONEFS_OBJ = modules/vfs_onefs.o modules/onefs_acl.o modules/onefs_system.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
+VFS_DIRSORT_OBJ = modules/vfs_dirsort.o
PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o
@@ -2625,6 +2626,10 @@ bin/security.@SHLIBEXT@: $(BINARY_PREREQS) libgpo/gpext/security.o
@echo "Building plugin $@"
@$(SHLD_MODULE) libgpo/gpext/security.o
+bin/dirsort.@SHLIBEXT@: $(BINARY_PREREQS) $(VFS_DIRSORT_OBJ)
+ @echo "Building plugin $@"
+ @$(SHLD_MODULE) $(VFS_DIRSORT_OBJ)
+
#########################################################
## IdMap NSS plugins
diff --git a/source3/configure.in b/source3/configure.in
index dc5850aba1..cfc2473a82 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -879,7 +879,7 @@ fi
AC_CHECK_FUNCS(dirfd)
if test x"$ac_cv_func_dirfd" = x"yes"; then
- default_shared_modules="$default_shared_modules vfs_syncops"
+ default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort"
fi
AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [
@@ -6213,6 +6213,7 @@ SMB_MODULE(vfs_acl_tdb, \$(VFS_ACL_TDB_OBJ), "bin/acl_tdb.$SHLIBEXT", VFS)
SMB_MODULE(vfs_smb_traffic_analyzer, \$(VFS_SMB_TRAFFIC_ANALYZER_OBJ), "bin/smb_traffic_analyzer.$SHLIBEXT", VFS)
SMB_MODULE(vfs_onefs, \$(VFS_ONEFS), "bin/onefs.$SHLIBEXT", VFS)
SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_copy.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS)
SMB_SUBSYSTEM(VFS,smbd/vfs.o)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 3d87f75c7b..c84b1cb9ac 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3779,6 +3779,8 @@ bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
/* The following definitions come from nmbd/nmbd_processlogon.c */
+bool initialize_nmbd_proxy_logon(void);
+
void process_logon_packet(struct packet_struct *p, char *buf,int len,
const char *mailslot);
@@ -4828,7 +4830,7 @@ WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const cha
REGISTRY_VALUE* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
bool set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
-bool del_driver_init(char *drivername);
+bool del_driver_init(const char *drivername);
WERROR save_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level, uint8 *data, uint32 data_len);
WERROR get_a_printer( Printer_entry *print_hnd,
NT_PRINTER_INFO_LEVEL **pp_printer,
@@ -4840,8 +4842,8 @@ WERROR get_a_printer_search( Printer_entry *print_hnd,
const char *sharename);
uint32 free_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level);
uint32 add_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level);
-WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level,
- fstring drivername, const char *architecture, uint32 version);
+WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level,
+ const char *drivername, const char *architecture, uint32_t version);
uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level);
bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 );
bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info );
@@ -5898,6 +5900,8 @@ NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
/* The following definitions come from rpc_server/srv_samr_util.c */
+void copy_id18_to_sam_passwd(struct samu *to,
+ struct samr_UserInfo18 *from);
void copy_id20_to_sam_passwd(struct samu *to,
struct samr_UserInfo20 *from);
void copy_id21_to_sam_passwd(const char *log_prefix,
@@ -5905,8 +5909,12 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
struct samr_UserInfo21 *from);
void copy_id23_to_sam_passwd(struct samu *to,
struct samr_UserInfo23 *from);
+void copy_id24_to_sam_passwd(struct samu *to,
+ struct samr_UserInfo24 *from);
void copy_id25_to_sam_passwd(struct samu *to,
struct samr_UserInfo25 *from);
+void copy_id26_to_sam_passwd(struct samu *to,
+ struct samr_UserInfo26 *from);
/* The following definitions come from rpc_server/srv_spoolss_nt.c */
@@ -5925,8 +5933,9 @@ void reset_all_printerdata(struct messaging_context *msg,
bool convert_devicemode(const char *printername,
const struct spoolss_DeviceMode *devmode,
NT_DEVICEMODE **pp_nt_devmode);
-WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value,
- uint32 type, uint8 *data, int real_len );
+WERROR set_printer_dataex(NT_PRINTER_INFO_LEVEL *printer,
+ const char *key, const char *value,
+ uint32_t type, uint8_t *data, int real_len);
void spoolss_notify_server_name(int snum,
struct spoolss_Notify *data,
print_queue_struct *queue,
diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c
index 189902a78e..c09632a857 100644
--- a/source3/lib/netapi/group.c
+++ b/source3/lib/netapi/group.c
@@ -1276,6 +1276,7 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx,
*r->out.buffer = NULL;
*r->out.entries_read = 0;
+ *r->out.total_entries = 0;
switch (r->in.level) {
case 0:
@@ -1364,13 +1365,8 @@ WERROR NetGroupGetUsers_r(struct libnetapi_ctx *ctx,
}
}
- if (r->out.entries_read) {
- *r->out.entries_read = entries_read;
- }
-
- if (r->out.total_entries) {
- *r->out.total_entries = entries_read;
- }
+ *r->out.entries_read = entries_read;
+ *r->out.total_entries = entries_read;
werr = WERR_OK;
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index 8cc65a6e9e..e760a8b1de 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -2806,6 +2806,7 @@ WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx,
*r->out.buffer = NULL;
*r->out.entries_read = 0;
+ *r->out.total_entries = 0;
switch (r->in.level) {
case 0:
@@ -2899,12 +2900,8 @@ WERROR NetUserGetGroups_r(struct libnetapi_ctx *ctx,
}
}
- if (r->out.entries_read) {
- *r->out.entries_read = entries_read;
- }
- if (r->out.total_entries) {
- *r->out.total_entries = entries_read;
- }
+ *r->out.entries_read = entries_read;
+ *r->out.total_entries = entries_read;
done:
if (ctx->disable_policy_handle_cache) {
@@ -3242,6 +3239,7 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx,
*r->out.buffer = NULL;
*r->out.entries_read = 0;
+ *r->out.total_entries = 0;
switch (r->in.level) {
case 0:
@@ -3402,12 +3400,8 @@ WERROR NetUserGetLocalGroups_r(struct libnetapi_ctx *ctx,
}
}
- if (r->out.entries_read) {
- *r->out.entries_read = entries_read;
- }
- if (r->out.total_entries) {
- *r->out.total_entries = entries_read;
- }
+ *r->out.entries_read = entries_read;
+ *r->out.total_entries = entries_read;
done:
if (ctx->disable_policy_handle_cache) {
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index 56d7b061a1..52cb975a6c 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -511,13 +511,13 @@ char *kerberos_get_default_realm_from_ccache( void )
out:
- if (princ) {
- krb5_free_principal(ctx, princ);
- }
- if (cc) {
- krb5_cc_close(ctx, cc);
- }
if (ctx) {
+ if (princ) {
+ krb5_free_principal(ctx, princ);
+ }
+ if (cc) {
+ krb5_cc_close(ctx, cc);
+ }
krb5_free_context(ctx);
}
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index e579d1c9f0..066ac7bdb8 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -861,7 +861,7 @@ static NTSTATUS validate_smb_crypto(struct cli_state *cli, char *pdu)
static void handle_incoming_pdu(struct cli_state *cli)
{
- struct cli_request *req;
+ struct cli_request *req, *next;
uint16_t mid;
size_t raw_pdu_len, buf_len, pdu_len, rest_len;
char *pdu;
@@ -978,8 +978,11 @@ static void handle_incoming_pdu(struct cli_state *cli)
DEBUG(10, ("handle_incoming_pdu: Aborting with %s\n",
nt_errstr(status)));
- for (req = cli->outstanding_requests; req; req = req->next) {
- async_req_nterror(req->async[0], status);
+ for (req = cli->outstanding_requests; req; req = next) {
+ next = req->next;
+ if (req->num_async) {
+ async_req_nterror(req->async[0], status);
+ }
}
return;
}
diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c
index 168ca63303..4ab31374e2 100644
--- a/source3/libsmb/clikrb5.c
+++ b/source3/libsmb/clikrb5.c
@@ -878,24 +878,30 @@ failed:
bool get_krb5_smb_session_key(krb5_context context, krb5_auth_context auth_context, DATA_BLOB *session_key, bool remote)
{
- krb5_keyblock *skey;
- krb5_error_code err;
- bool ret = False;
+ krb5_keyblock *skey = NULL;
+ krb5_error_code err = 0;
+ bool ret = false;
- if (remote)
+ if (remote) {
err = krb5_auth_con_getremotesubkey(context, auth_context, &skey);
- else
+ } else {
err = krb5_auth_con_getlocalsubkey(context, auth_context, &skey);
- if (err == 0 && skey != NULL) {
- DEBUG(10, ("Got KRB5 session key of length %d\n", (int)KRB5_KEY_LENGTH(skey)));
- *session_key = data_blob(KRB5_KEY_DATA(skey), KRB5_KEY_LENGTH(skey));
- dump_data_pw("KRB5 Session Key:\n", session_key->data, session_key->length);
+ }
- ret = True;
+ if (err || skey == NULL) {
+ DEBUG(10, ("KRB5 error getting session key %d\n", err));
+ goto done;
+ }
+ DEBUG(10, ("Got KRB5 session key of length %d\n", (int)KRB5_KEY_LENGTH(skey)));
+ *session_key = data_blob(KRB5_KEY_DATA(skey), KRB5_KEY_LENGTH(skey));
+ dump_data_pw("KRB5 Session Key:\n", session_key->data, session_key->length);
+
+ ret = true;
+
+ done:
+ if (skey) {
krb5_free_keyblock(context, skey);
- } else {
- DEBUG(10, ("KRB5 error getting session key %d\n", err));
}
return ret;
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
new file mode 100644
index 0000000000..53d1820c11
--- /dev/null
+++ b/source3/modules/vfs_dirsort.c
@@ -0,0 +1,194 @@
+/*
+ * VFS module to provide a sorted directory list.
+ *
+ * Copyright (C) Andy Kelk (andy@mopoke.co.uk), 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"
+
+static int compare_dirent (const void *a, const void *b) {
+ const SMB_STRUCT_DIRENT *da = (const SMB_STRUCT_DIRENT *) a;
+ const SMB_STRUCT_DIRENT *db = (const SMB_STRUCT_DIRENT *) b;
+ return StrCaseCmp(da->d_name, db->d_name);
+}
+
+struct dirsort_privates {
+ long pos;
+ SMB_STRUCT_DIRENT *directory_list;
+ long number_of_entries;
+ time_t mtime;
+ SMB_STRUCT_DIR *source_directory;
+ int fd;
+};
+
+static void free_dirsort_privates(void **datap) {
+ struct dirsort_privates *data = (struct dirsort_privates *) *datap;
+ SAFE_FREE(data->directory_list);
+ SAFE_FREE(data);
+ *datap = NULL;
+
+ return;
+}
+
+static void open_and_sort_dir (vfs_handle_struct *handle)
+{
+ SMB_STRUCT_DIRENT *dp;
+ struct stat dir_stat;
+ long current_pos;
+ struct dirsort_privates *data = NULL;
+
+ SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return);
+
+ data->number_of_entries = 0;
+
+ if (fstat(data->fd, &dir_stat) == 0) {
+ data->mtime = dir_stat.st_mtime;
+ }
+
+ while (SMB_VFS_NEXT_READDIR(handle, data->source_directory, NULL)
+ != NULL) {
+ data->number_of_entries++;
+ }
+
+ /* Open the underlying directory and count the number of entries
+ Skip back to the beginning as we'll read it again */
+ SMB_VFS_NEXT_REWINDDIR(handle, data->source_directory);
+
+ /* Set up an array and read the directory entries into it */
+ SAFE_FREE(data->directory_list); /* destroy previous cache if needed */
+ data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC(
+ data->number_of_entries * sizeof(SMB_STRUCT_DIRENT));
+ current_pos = data->pos;
+ data->pos = 0;
+ while ((dp = SMB_VFS_NEXT_READDIR(handle, data->source_directory,
+ NULL)) != NULL) {
+ data->directory_list[data->pos++] = *dp;
+ }
+
+ /* Sort the directory entries by name */
+ data->pos = current_pos;
+ qsort(data->directory_list, data->number_of_entries,
+ sizeof(SMB_STRUCT_DIRENT), compare_dirent);
+}
+
+static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle,
+ const char *fname, const char *mask,
+ uint32 attr)
+{
+ struct dirsort_privates *data = NULL;
+
+ /* set up our private data about this directory */
+ data = (struct dirsort_privates *)SMB_MALLOC(
+ sizeof(struct dirsort_privates));
+
+ data->directory_list = NULL;
+ data->pos = 0;
+
+ /* Open the underlying directory and count the number of entries */
+ data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
+ attr);
+
+ data->fd = dirfd(data->source_directory);
+
+ SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
+ struct dirsort_privates, return NULL);
+
+ open_and_sort_dir(handle);
+
+ return data->source_directory;
+}
+
+static SMB_STRUCT_DIRENT *dirsort_readdir(vfs_handle_struct *handle,
+ SMB_STRUCT_DIR *dirp)
+{
+ struct dirsort_privates *data = NULL;
+ time_t current_mtime;
+ struct stat dir_stat;
+
+ SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
+ return NULL);
+
+ if (fstat(data->fd, &dir_stat) == -1) {
+ return NULL;
+ }
+
+ current_mtime = dir_stat.st_mtime;
+
+ /* throw away cache and re-read the directory if we've changed */
+ if (current_mtime > data->mtime) {
+ open_and_sort_dir(handle);
+ }
+
+ if (data->pos >= data->number_of_entries) {
+ return NULL;
+ }
+
+ return &data->directory_list[data->pos++];
+}
+
+static void dirsort_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp,
+ long offset)
+{
+ struct dirsort_privates *data = NULL;
+ SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return);
+
+ data->pos = offset;
+}
+
+static long dirsort_telldir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
+{
+ struct dirsort_privates *data = NULL;
+ SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
+ return -1);
+
+ return data->pos;
+}
+
+static void dirsort_rewinddir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
+{
+ struct dirsort_privates *data = NULL;
+ SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates, return);
+
+ data->pos = 0;
+}
+
+/* VFS operations structure */
+
+static vfs_op_tuple dirsort_op_tuples[] = {
+
+ /* Directory operations */
+
+ {SMB_VFS_OP(dirsort_opendir), SMB_VFS_OP_OPENDIR,
+ SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(dirsort_readdir), SMB_VFS_OP_READDIR,
+ SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(dirsort_seekdir), SMB_VFS_OP_SEEKDIR,
+ SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(dirsort_telldir), SMB_VFS_OP_TELLDIR,
+ SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(dirsort_rewinddir), SMB_VFS_OP_REWINDDIR,
+ SMB_VFS_LAYER_TRANSPARENT},
+
+ {NULL, SMB_VFS_OP_NOOP,
+ SMB_VFS_LAYER_NOOP}
+};
+
+NTSTATUS vfs_dirsort_init(void)
+{
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "dirsort",
+ dirsort_op_tuples);
+}
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 3279466602..daf4c295a6 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -988,6 +988,12 @@ static bool open_sockets(bool isdaemon, int port)
exit(1);
}
+ if (!initialize_nmbd_proxy_logon()) {
+ DEBUG(0,("ERROR: Failed setup nmbd_proxy_logon.\n"));
+ kill_async_dns_child();
+ exit(1);
+ }
+
TALLOC_FREE(frame);
process();
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index 59a2ca405e..8173337da0 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -24,6 +24,9 @@
*/
#include "includes.h"
+#include "../libcli/netlogon.h"
+#include "../libcli/cldap/cldap.h"
+#include "../lib/tsocket/tsocket.h"
struct sam_database_info {
uint32 index;
@@ -65,6 +68,235 @@ static void delayed_init_logon_handler(struct event_context *event_ctx,
TALLOC_FREE(te);
}
+struct nmbd_proxy_logon_context {
+ struct cldap_socket *cldap_sock;
+};
+
+static struct nmbd_proxy_logon_context *global_nmbd_proxy_logon;
+
+bool initialize_nmbd_proxy_logon(void)
+{
+ const char *cldap_server = lp_parm_const_string(-1, "nmbd_proxy_logon",
+ "cldap_server", NULL);
+ struct nmbd_proxy_logon_context *ctx;
+ NTSTATUS status;
+ struct in_addr addr;
+ char addrstr[INET_ADDRSTRLEN];
+ const char *server_str;
+ int ret;
+ struct tsocket_address *server_addr;
+
+ if (!cldap_server) {
+ return true;
+ }
+
+ addr = interpret_addr2(cldap_server);
+ server_str = inet_ntop(AF_INET, &addr,
+ addrstr, sizeof(addrstr));
+ if (!server_str || strcmp("0.0.0.0", server_str) == 0) {
+ DEBUG(0,("Failed to resolve[%s] for nmbd_proxy_logon\n",
+ cldap_server));
+ return false;
+ }
+
+ ctx = talloc_zero(nmbd_event_context(),
+ struct nmbd_proxy_logon_context);
+ if (!ctx) {
+ return false;
+ }
+
+ ret = tsocket_address_inet_from_strings(ctx, "ipv4",
+ server_str, LDAP_PORT,
+ &server_addr);
+ if (ret != 0) {
+ TALLOC_FREE(ctx);
+ status = map_nt_error_from_unix(errno);
+ DEBUG(0,("Failed to create cldap tsocket_address for %s - %s\n",
+ server_str, nt_errstr(status)));
+ return false;
+ }
+
+ /* we create a connected udp socket */
+ status = cldap_socket_init(ctx, nmbd_event_context(), NULL,
+ server_addr, &ctx->cldap_sock);
+ TALLOC_FREE(server_addr);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(ctx);
+ DEBUG(0,("failed to create cldap socket for %s: %s\n",
+ server_str, nt_errstr(status)));
+ return false;
+ }
+
+ global_nmbd_proxy_logon = ctx;
+ return true;
+}
+
+struct nmbd_proxy_logon_state {
+ struct in_addr local_ip;
+ struct packet_struct *p;
+ const char *remote_name;
+ uint8_t remote_name_type;
+ const char *remote_mailslot;
+ struct nbt_netlogon_packet req;
+ struct nbt_netlogon_response resp;
+ struct cldap_netlogon io;
+};
+
+static int nmbd_proxy_logon_state_destructor(struct nmbd_proxy_logon_state *s)
+{
+ s->p->locked = false;
+ free_packet(s->p);
+ return 0;
+}
+
+static void nmbd_proxy_logon_done(struct tevent_req *subreq);
+
+static void nmbd_proxy_logon(struct nmbd_proxy_logon_context *ctx,
+ struct in_addr local_ip,
+ struct packet_struct *p,
+ uint8_t *buf,
+ uint32_t len)
+{
+ struct nmbd_proxy_logon_state *state;
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob = data_blob_const(buf, len);
+ const char *computer_name = NULL;
+ const char *mailslot_name = NULL;
+ const char *user_name = NULL;
+ const char *domain_sid = NULL;
+ uint32_t acct_control = 0;
+ uint32_t nt_version = 0;
+ struct tevent_req *subreq;
+ fstring source_name;
+ struct dgram_packet *dgram = &p->packet.dgram;
+
+ state = TALLOC_ZERO_P(ctx, struct nmbd_proxy_logon_state);
+ if (!state) {
+ DEBUG(0,("failed to allocate nmbd_proxy_logon_state\n"));
+ return;
+ }
+
+ pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
+ state->remote_name = talloc_strdup(state, source_name);
+ state->remote_name_type = dgram->source_name.name_type,
+ state->local_ip = local_ip;
+ state->p = p;
+
+ ndr_err = ndr_pull_struct_blob(
+ &blob, state, NULL, &state->req,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
+ DEBUG(0,("failed parse nbt_letlogon_packet: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(state);
+ return;
+ }
+
+ if (DEBUGLEVEL >= 10) {
+ DEBUG(10, ("nmbd_proxy_logon:\n"));
+ NDR_PRINT_DEBUG(nbt_netlogon_packet, &state->req);
+ }
+
+ switch (state->req.command) {
+ case LOGON_SAM_LOGON_REQUEST:
+ computer_name = state->req.req.logon.computer_name;
+ user_name = state->req.req.logon.user_name;
+ mailslot_name = state->req.req.logon.mailslot_name;
+ acct_control = state->req.req.logon.acct_control;
+ if (state->req.req.logon.sid_size > 0) {
+ domain_sid = dom_sid_string(state,
+ &state->req.req.logon.sid);
+ if (!domain_sid) {
+ DEBUG(0,("failed to get a string for sid\n"));
+ TALLOC_FREE(state);
+ return;
+ }
+ }
+ nt_version = state->req.req.logon.nt_version;
+ break;
+
+ default:
+ /* this can't happen as the caller already checks the command */
+ break;
+ }
+
+ state->remote_mailslot = mailslot_name;
+
+ if (user_name && strlen(user_name) == 0) {
+ user_name = NULL;
+ }
+
+ if (computer_name && strlen(computer_name) == 0) {
+ computer_name = NULL;
+ }
+
+ /*
+ * as the socket is connected,
+ * we don't need to specify the destination
+ */
+ state->io.in.dest_address = NULL;
+ state->io.in.dest_port = 0;
+ state->io.in.realm = NULL;
+ state->io.in.host = computer_name;
+ state->io.in.user = user_name;
+ state->io.in.domain_guid = NULL;
+ state->io.in.domain_sid = domain_sid;
+ state->io.in.acct_control = acct_control;
+ state->io.in.version = nt_version;
+ state->io.in.map_response = false;
+
+ subreq = cldap_netlogon_send(state,
+ ctx->cldap_sock,
+ &state->io);
+ if (!subreq) {
+ DEBUG(0,("failed to send cldap netlogon call\n"));
+ TALLOC_FREE(state);
+ return;
+ }
+ tevent_req_set_callback(subreq, nmbd_proxy_logon_done, state);
+
+ /* we reply async */
+ state->p->locked = true;
+ talloc_set_destructor(state, nmbd_proxy_logon_state_destructor);
+}
+
+static void nmbd_proxy_logon_done(struct tevent_req *subreq)
+{
+ struct nmbd_proxy_logon_state *state =
+ tevent_req_callback_data(subreq,
+ struct nmbd_proxy_logon_state);
+ NTSTATUS status;
+ DATA_BLOB response;
+
+ status = cldap_netlogon_recv(subreq, NULL, state, &state->io);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("failed to recv cldap netlogon call: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(state);
+ return;
+ }
+
+ status = push_netlogon_samlogon_response(&response, state, NULL,
+ &state->io.out.netlogon);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("failed to push netlogon_samlogon_response: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(state);
+ return;
+ }
+
+ send_mailslot(true, state->remote_mailslot,
+ (char *)response.data, response.length,
+ global_myname(), 0x0,
+ state->remote_name,
+ state->remote_name_type,
+ state->p->ip,
+ state->local_ip,
+ state->p->port);
+ TALLOC_FREE(state);
+}
+
/****************************************************************************
Process a domain logon packet
**************************************************************************/
@@ -318,6 +550,12 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
char *q = buf + 2;
fstring asccomp;
+ if (global_nmbd_proxy_logon) {
+ nmbd_proxy_logon(global_nmbd_proxy_logon,
+ ip, p, (uint8_t *)buf, len);
+ return;
+ }
+
q += 2;
if (PTR_DIFF(q, buf) >= len) {
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 8e6fe1f364..a99485d381 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2275,7 +2275,9 @@ static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **in
/****************************************************************************
****************************************************************************/
-static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, fstring drivername, const char *arch, uint32 version)
+static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr,
+ const char *drivername, const char *arch,
+ uint32_t version)
{
NT_PRINTER_DRIVER_INFO_LEVEL_3 driver;
TDB_DATA dbuf;
@@ -4448,7 +4450,7 @@ bool set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level)
Delete driver init data stored for a specified driver
****************************************************************************/
-bool del_driver_init(char *drivername)
+bool del_driver_init(const char *drivername)
{
char *key;
bool ret;
@@ -4837,8 +4839,9 @@ uint32 add_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level)
/****************************************************************************
****************************************************************************/
-WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level,
- fstring drivername, const char *architecture, uint32 version)
+WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32_t level,
+ const char *drivername, const char *architecture,
+ uint32_t version)
{
WERROR result;
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index dcbd0963c4..c60d904b18 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -3636,12 +3636,7 @@ static NTSTATUS set_user_info_18(struct samr_UserInfo18 *id18,
pdb_set_pass_last_set_time(pwd, time(NULL), PDB_CHANGED);
}
- if (id18->password_expired) {
- pdb_set_pass_last_set_time(pwd, 0, PDB_CHANGED);
- } else {
- /* FIXME */
- pdb_set_pass_last_set_time(pwd, time(NULL), PDB_CHANGED);
- }
+ copy_id18_to_sam_passwd(pwd, id18);
return pdb_update_sam_account(pwd);
}
@@ -3848,23 +3843,16 @@ static NTSTATUS set_user_info_23(TALLOC_CTX *mem_ctx,
set_user_info_pw
********************************************************************/
-static bool set_user_info_pw(uint8 *pass, struct samu *pwd,
- int level)
+static bool set_user_info_pw(uint8 *pass, struct samu *pwd)
{
uint32 len = 0;
char *plaintext_buf = NULL;
uint32 acct_ctrl;
- time_t last_set_time;
- enum pdb_value_state last_set_state;
DEBUG(5, ("Attempting administrator password change for user %s\n",
pdb_get_username(pwd)));
acct_ctrl = pdb_get_acct_ctrl(pwd);
- /* we need to know if it's expired, because this is an admin change, not a
- user change, so it's still expired when we're done */
- last_set_state = pdb_get_init_flags(pwd, PDB_PASSLASTSET);
- last_set_time = pdb_get_pass_last_set_time(pwd);
if (!decode_pw_buffer(talloc_tos(),
pass,
@@ -3907,29 +3895,38 @@ static bool set_user_info_pw(uint8 *pass, struct samu *pwd,
memset(plaintext_buf, '\0', strlen(plaintext_buf));
- /*
- * A level 25 change does reset the pwdlastset field, a level 24
- * change does not. I know this is probably not the full story, but
- * it is needed to make XP join LDAP correctly, without it the later
- * auth2 check can fail with PWD_MUST_CHANGE.
- */
- if (level != 25) {
- /*
- * restore last set time as this is an admin change, not a
- * user pw change
- */
- pdb_set_pass_last_set_time (pwd, last_set_time,
- last_set_state);
+ DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n"));
+
+ return True;
+}
+
+/*******************************************************************
+ set_user_info_24
+ ********************************************************************/
+
+static NTSTATUS set_user_info_24(TALLOC_CTX *mem_ctx,
+ struct samr_UserInfo24 *id24,
+ struct samu *pwd)
+{
+ NTSTATUS status;
+
+ if (id24 == NULL) {
+ DEBUG(5, ("set_user_info_24: NULL id24\n"));
+ return NT_STATUS_INVALID_PARAMETER;
}
- DEBUG(5,("set_user_info_pw: pdb_update_pwd()\n"));
+ if (!set_user_info_pw(id24->password.data, pwd)) {
+ return NT_STATUS_WRONG_PASSWORD;
+ }
- /* update the SAMBA password */
- if(!NT_STATUS_IS_OK(pdb_update_sam_account(pwd))) {
- return False;
+ copy_id24_to_sam_passwd(pwd, id24);
+
+ status = pdb_update_sam_account(pwd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- return True;
+ return NT_STATUS_OK;
}
/*******************************************************************
@@ -3955,6 +3952,14 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx,
return NT_STATUS_ACCESS_DENIED;
}
+ if ((id25->info.fields_present & SAMR_FIELD_NT_PASSWORD_PRESENT) ||
+ (id25->info.fields_present & SAMR_FIELD_LM_PASSWORD_PRESENT)) {
+
+ if (!set_user_info_pw(id25->password.data, pwd)) {
+ return NT_STATUS_WRONG_PASSWORD;
+ }
+ }
+
copy_id25_to_sam_passwd(pwd, id25);
/* write the change out */
@@ -3981,6 +3986,36 @@ static NTSTATUS set_user_info_25(TALLOC_CTX *mem_ctx,
}
/*******************************************************************
+ set_user_info_26
+ ********************************************************************/
+
+static NTSTATUS set_user_info_26(TALLOC_CTX *mem_ctx,
+ struct samr_UserInfo26 *id26,
+ struct samu *pwd)
+{
+ NTSTATUS status;
+
+ if (id26 == NULL) {
+ DEBUG(5, ("set_user_info_26: NULL id26\n"));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (!set_user_info_pw(id26->password.data, pwd)) {
+ return NT_STATUS_WRONG_PASSWORD;
+ }
+
+ copy_id26_to_sam_passwd(pwd, id26);
+
+ status = pdb_update_sam_account(pwd);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return NT_STATUS_OK;
+}
+
+
+/*******************************************************************
samr_SetUserInfo
********************************************************************/
@@ -4139,10 +4174,8 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p,
dump_data(100, info->info24.password.data, 516);
- if (!set_user_info_pw(info->info24.password.data, pwd,
- switch_value)) {
- status = NT_STATUS_WRONG_PASSWORD;
- }
+ status = set_user_info_24(p->mem_ctx,
+ &info->info24, pwd);
break;
case 25:
@@ -4157,13 +4190,6 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p,
status = set_user_info_25(p->mem_ctx,
&info->info25, pwd);
- if (!NT_STATUS_IS_OK(status)) {
- goto done;
- }
- if (!set_user_info_pw(info->info25.password.data, pwd,
- switch_value)) {
- status = NT_STATUS_WRONG_PASSWORD;
- }
break;
case 26:
@@ -4176,18 +4202,14 @@ NTSTATUS _samr_SetUserInfo(pipes_struct *p,
dump_data(100, info->info26.password.data, 516);
- if (!set_user_info_pw(info->info26.password.data, pwd,
- switch_value)) {
- status = NT_STATUS_WRONG_PASSWORD;
- }
+ status = set_user_info_26(p->mem_ctx,
+ &info->info26, pwd);
break;
default:
status = NT_STATUS_INVALID_INFO_CLASS;
}
- done:
-
TALLOC_FREE(pwd);
if (has_enough_rights) {
diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c
index ef588aed1a..068156054f 100644
--- a/source3/rpc_server/srv_samr_util.c
+++ b/source3/rpc_server/srv_samr_util.c
@@ -36,6 +36,27 @@
((s1) && (s2) && (strcmp((s1), (s2)) != 0))
/*************************************************************
+ Copies a struct samr_UserInfo18 to a struct samu
+**************************************************************/
+
+void copy_id18_to_sam_passwd(struct samu *to,
+ struct samr_UserInfo18 *from)
+{
+ struct samr_UserInfo21 i;
+
+ if (from == NULL || to == NULL) {
+ return;
+ }
+
+ ZERO_STRUCT(i);
+
+ i.fields_present = SAMR_FIELD_EXPIRED_FLAG;
+ i.password_expired = from->password_expired;
+
+ copy_id21_to_sam_passwd("INFO_18", to, &i);
+}
+
+/*************************************************************
Copies a struct samr_UserInfo20 to a struct samu
**************************************************************/
@@ -336,7 +357,7 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
if (from->fields_present & SAMR_FIELD_EXPIRED_FLAG) {
DEBUG(10,("%s SAMR_FIELD_EXPIRED_FLAG: %02X\n", l,
from->password_expired));
- if (from->password_expired == PASS_MUST_CHANGE_AT_NEXT_LOGON) {
+ if (from->password_expired != 0) {
pdb_set_pass_last_set_time(to, 0, PDB_CHANGED);
} else {
/* A subtlety here: some windows commands will
@@ -345,9 +366,27 @@ void copy_id21_to_sam_passwd(const char *log_prefix,
in these caess. "net user /dom <user> /active:y"
for example, to clear an autolocked acct.
We must check to see if it's expired first. jmcd */
+
+ uint32_t pwd_max_age = 0;
+ time_t now = time(NULL);
+
+ pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &pwd_max_age);
+
+ if (pwd_max_age == (uint32_t)-1 || pwd_max_age == 0) {
+ pwd_max_age = get_time_t_max();
+ }
+
stored_time = pdb_get_pass_last_set_time(to);
- if (stored_time == 0)
- pdb_set_pass_last_set_time(to, time(NULL),PDB_CHANGED);
+
+ /* we will only *set* a pwdlastset date when
+ a) the last pwdlastset time was 0 (user was forced to
+ change password).
+ b) the users password has not expired. gd. */
+
+ if ((stored_time == 0) ||
+ ((now - stored_time) > pwd_max_age)) {
+ pdb_set_pass_last_set_time(to, now, PDB_CHANGED);
+ }
}
}
}
@@ -368,6 +407,27 @@ void copy_id23_to_sam_passwd(struct samu *to,
}
/*************************************************************
+ Copies a struct samr_UserInfo24 to a struct samu
+**************************************************************/
+
+void copy_id24_to_sam_passwd(struct samu *to,
+ struct samr_UserInfo24 *from)
+{
+ struct samr_UserInfo21 i;
+
+ if (from == NULL || to == NULL) {
+ return;
+ }
+
+ ZERO_STRUCT(i);
+
+ i.fields_present = SAMR_FIELD_EXPIRED_FLAG;
+ i.password_expired = from->password_expired;
+
+ copy_id21_to_sam_passwd("INFO_24", to, &i);
+}
+
+/*************************************************************
Copies a struct samr_UserInfo25 to a struct samu
**************************************************************/
@@ -380,3 +440,24 @@ void copy_id25_to_sam_passwd(struct samu *to,
copy_id21_to_sam_passwd("INFO_25", to, &from->info);
}
+
+/*************************************************************
+ Copies a struct samr_UserInfo26 to a struct samu
+**************************************************************/
+
+void copy_id26_to_sam_passwd(struct samu *to,
+ struct samr_UserInfo26 *from)
+{
+ struct samr_UserInfo21 i;
+
+ if (from == NULL || to == NULL) {
+ return;
+ }
+
+ ZERO_STRUCT(i);
+
+ i.fields_present = SAMR_FIELD_EXPIRED_FLAG;
+ i.password_expired = from->password_expired;
+
+ copy_id21_to_sam_passwd("INFO_26", to, &i);
+}
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index ab15e5c5f6..a8d414b85e 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -66,13 +66,13 @@ typedef struct _counter_printer_0 {
struct _counter_printer_0 *prev;
int snum;
- uint32 counter;
+ uint32_t counter;
} counter_printer_0;
static counter_printer_0 *counter_list;
static struct rpc_pipe_client *notify_cli_pipe; /* print notify back-channel pipe handle*/
-static uint32 smb_connections=0;
+static uint32_t smb_connections = 0;
/* in printing/nt_printing.c */
@@ -186,7 +186,7 @@ static void srv_spoolss_replycloseprinter(int snum, struct policy_handle *handle
/* Tell the connections db we're no longer interested in
* printer notify messages. */
- register_message_flags( False, FLAG_MSG_PRINT_NOTIFY );
+ register_message_flags(false, FLAG_MSG_PRINT_NOTIFY);
}
smb_connections--;
@@ -198,7 +198,7 @@ static void srv_spoolss_replycloseprinter(int snum, struct policy_handle *handle
static int printer_entry_destructor(Printer_entry *Printer)
{
- if (Printer->notify.client_connected==True) {
+ if (Printer->notify.client_connected == true) {
int snum = -1;
if ( Printer->printer_type == SPLHND_SERVER) {
@@ -217,7 +217,7 @@ static int printer_entry_destructor(Printer_entry *Printer)
Printer->notify.localmachine[0]='\0';
Printer->notify.printerlocal=0;
TALLOC_FREE(Printer->notify.option);
- Printer->notify.client_connected=False;
+ Printer->notify.client_connected = false;
free_nt_devicemode( &Printer->nt_devmode );
free_a_printer( &Printer->printer_info, 2 );
@@ -255,12 +255,12 @@ static bool close_printer_handle(pipes_struct *p, struct policy_handle *hnd)
if (!Printer) {
DEBUG(2,("close_printer_handle: Invalid handle (%s:%u:%u)\n",
OUR_HANDLE(hnd)));
- return False;
+ return false;
}
close_policy_hnd(p, hnd);
- return True;
+ return true;
}
/****************************************************************************
@@ -273,7 +273,7 @@ WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *sh
char *command = NULL;
int ret;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- bool is_print_op = False;
+ bool is_print_op = false;
/* can't fail if we don't try */
@@ -315,7 +315,7 @@ WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *sh
return WERR_BADFID; /* What to return here? */
/* go ahead and re-read the services immediately */
- reload_services( False );
+ reload_services(false);
if ( lp_servicenumber( sharename ) < 0 )
return WERR_ACCESS_DENIED;
@@ -373,7 +373,7 @@ static bool get_printer_snum(pipes_struct *p, struct policy_handle *hnd,
if (!Printer) {
DEBUG(2,("get_printer_snum: Invalid handle (%s:%u:%u)\n",
OUR_HANDLE(hnd)));
- return False;
+ return false;
}
switch (Printer->printer_type) {
@@ -382,9 +382,9 @@ static bool get_printer_snum(pipes_struct *p, struct policy_handle *hnd,
*number = print_queue_snum(Printer->sharename);
return (*number != -1);
case SPLHND_SERVER:
- return False;
+ return false;
default:
- return False;
+ return false;
}
}
@@ -393,13 +393,13 @@ static bool get_printer_snum(pipes_struct *p, struct policy_handle *hnd,
Check if it's \\server or \\server\printer
****************************************************************************/
-static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename)
+static bool set_printer_hnd_printertype(Printer_entry *Printer, const char *handlename)
{
DEBUG(3,("Setting printer type=%s\n", handlename));
if ( strlen(handlename) < 3 ) {
DEBUGADD(4,("A print server must have at least 1 char ! %s\n", handlename));
- return False;
+ return false;
}
/* it's a print server */
@@ -413,7 +413,7 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename
Printer->printer_type = SPLHND_PRINTER;
}
- return True;
+ return true;
}
/****************************************************************************
@@ -423,20 +423,21 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, char *handlename
XcvDataPort() interface.
****************************************************************************/
-static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
+static bool set_printer_hnd_name(Printer_entry *Printer, const char *handlename)
{
int snum;
int n_services=lp_numservices();
char *aprinter, *printername;
const char *servername;
fstring sname;
- bool found=False;
+ bool found = false;
NT_PRINTER_INFO_LEVEL *printer = NULL;
WERROR result;
- DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename, (unsigned long)strlen(handlename)));
+ DEBUG(4,("Setting printer name=%s (len=%lu)\n", handlename,
+ (unsigned long)strlen(handlename)));
- aprinter = handlename;
+ aprinter = CONST_DISCARD(char *, handlename);
if ( *handlename == '\\' ) {
servername = canon_servername(handlename);
if ( (aprinter = strchr_m( servername, '\\' )) != NULL ) {
@@ -450,15 +451,15 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
/* save the servername to fill in replies on this handle */
if ( !is_myname_or_ipaddr( servername ) )
- return False;
+ return false;
fstrcpy( Printer->servername, servername );
if ( Printer->printer_type == SPLHND_SERVER )
- return True;
+ return true;
if ( Printer->printer_type != SPLHND_PRINTER )
- return False;
+ return false;
DEBUGADD(5, ("searching for [%s]\n", aprinter ));
@@ -467,12 +468,12 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) {
Printer->printer_type = SPLHND_PORTMON_TCP;
fstrcpy(sname, SPL_XCV_MONITOR_TCPMON);
- found = True;
+ found = true;
}
else if ( strequal( aprinter, SPL_XCV_MONITOR_LOCALMON ) ) {
Printer->printer_type = SPLHND_PORTMON_LOCAL;
fstrcpy(sname, SPL_XCV_MONITOR_LOCALMON);
- found = True;
+ found = true;
}
/* Search all sharenames first as this is easier than pulling
@@ -490,7 +491,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
fstrcpy(sname, lp_servicename(snum));
if ( strequal( aprinter, sname ) ) {
- found = True;
+ found = true;
break;
}
@@ -528,7 +529,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
if ( strequal(printername, aprinter) ) {
free_a_printer( &printer, 2);
- found = True;
+ found = true;
break;
}
@@ -541,14 +542,14 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
if ( !found ) {
DEBUGADD(4,("Printer not found\n"));
- return False;
+ return false;
}
DEBUGADD(4,("set_printer_hnd_name: Printer found: %s -> %s\n", aprinter, sname));
fstrcpy(Printer->sharename, sname);
- return True;
+ return true;
}
/****************************************************************************
@@ -556,7 +557,7 @@ static bool set_printer_hnd_name(Printer_entry *Printer, char *handlename)
****************************************************************************/
static bool open_printer_hnd(pipes_struct *p, struct policy_handle *hnd,
- char *name, uint32_t access_granted)
+ const char *name, uint32_t access_granted)
{
Printer_entry *new_printer;
@@ -570,7 +571,7 @@ static bool open_printer_hnd(pipes_struct *p, struct policy_handle *hnd,
if (!create_policy_hnd(p, hnd, new_printer)) {
TALLOC_FREE(new_printer);
- return False;
+ return false;
}
/* Add to the internal list. */
@@ -580,19 +581,19 @@ static bool open_printer_hnd(pipes_struct *p, struct policy_handle *hnd,
if (!set_printer_hnd_printertype(new_printer, name)) {
close_printer_handle(p, hnd);
- return False;
+ return false;
}
if (!set_printer_hnd_name(new_printer, name)) {
close_printer_handle(p, hnd);
- return False;
+ return false;
}
new_printer->access_granted = access_granted;
DEBUG(5, ("%d printer handles active\n", (int)p->pipe_handles->count ));
- return True;
+ return true;
}
/***************************************************************************
@@ -600,17 +601,17 @@ static bool open_printer_hnd(pipes_struct *p, struct policy_handle *hnd,
given by (notify_type, notify_field).
**************************************************************************/
-static bool is_monitoring_event_flags(uint32 flags, uint16 notify_type,
- uint16 notify_field)
+static bool is_monitoring_event_flags(uint32_t flags, uint16_t notify_type,
+ uint16_t notify_field)
{
- return True;
+ return true;
}
-static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
- uint16 notify_field)
+static bool is_monitoring_event(Printer_entry *p, uint16_t notify_type,
+ uint16_t notify_field)
{
struct spoolss_NotifyOption *option = p->notify.option;
- uint32 i, j;
+ uint32_t i, j;
/*
* Flags should always be zero when the change notify
@@ -620,7 +621,7 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
*/
if (!option) {
- return False;
+ return false;
}
if (p->notify.flags)
@@ -638,7 +639,7 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
for (j = 0; j < option->types[i].count; j++) {
if (option->types[i].fields[j].field == notify_field) {
- return True;
+ return true;
}
}
}
@@ -646,7 +647,7 @@ static bool is_monitoring_event(Printer_entry *p, uint16 notify_type,
DEBUG(10, ("Open handle for \\\\%s\\%s is not monitoring 0x%02x/0x%02x\n",
p->servername, p->sharename, notify_type, notify_field));
- return False;
+ return false;
}
#define SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(_data, _integer) \
@@ -849,7 +850,7 @@ static TALLOC_CTX* notify_ctr_getctx( SPOOLSS_NOTIFY_MSG_CTR *ctr )
/***********************************************************************
**********************************************************************/
-static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx )
+static SPOOLSS_NOTIFY_MSG_GROUP* notify_ctr_getgroup( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32_t idx )
{
if ( !ctr || !ctr->msg_groups )
return NULL;
@@ -940,7 +941,7 @@ static int notify_msg_ctr_addmsg( SPOOLSS_NOTIFY_MSG_CTR *ctr, SPOOLSS_NOTIFY_MS
back registered
**********************************************************************/
-static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32 idx )
+static void send_notify2_changes( SPOOLSS_NOTIFY_MSG_CTR *ctr, uint32_t idx )
{
Printer_entry *p;
TALLOC_CTX *mem_ctx = notify_ctr_getctx( ctr );
@@ -1113,23 +1114,23 @@ done:
static bool notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, void *buf, size_t len )
{
- uint32 tv_sec, tv_usec;
+ uint32_t tv_sec, tv_usec;
size_t offset = 0;
/* Unpack message */
- offset += tdb_unpack((uint8 *)buf + offset, len - offset, "f",
+ offset += tdb_unpack((uint8_t *)buf + offset, len - offset, "f",
msg->printer);
- offset += tdb_unpack((uint8 *)buf + offset, len - offset, "ddddddd",
+ offset += tdb_unpack((uint8_t *)buf + offset, len - offset, "ddddddd",
&tv_sec, &tv_usec,
&msg->type, &msg->field, &msg->id, &msg->len, &msg->flags);
if (msg->len == 0)
- tdb_unpack((uint8 *)buf + offset, len - offset, "dd",
+ tdb_unpack((uint8_t *)buf + offset, len - offset, "dd",
&msg->notify.value[0], &msg->notify.value[1]);
else
- tdb_unpack((uint8 *)buf + offset, len - offset, "B",
+ tdb_unpack((uint8_t *)buf + offset, len - offset, "B",
&msg->len, &msg->notify.data);
DEBUG(3, ("notify2_unpack_msg: got NOTIFY2 message for printer %s, jobid %u type %d, field 0x%02x, flags 0x%04x\n",
@@ -1142,9 +1143,9 @@ static bool notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi
DEBUG(3, ("notify2_unpack_msg: value1 = %d, value2 = %d\n", msg->notify.value[0],
msg->notify.value[1]));
else
- dump_data(3, (uint8 *)msg->notify.data, msg->len);
+ dump_data(3, (uint8_t *)msg->notify.data, msg->len);
- return True;
+ return true;
}
/********************************************************************
@@ -1233,7 +1234,8 @@ static void receive_notify2_message_list(struct messaging_context *msg,
/* cleanup */
- DEBUG(10,("receive_notify2_message_list: processed %u messages\n", (uint32)msg_count ));
+ DEBUG(10,("receive_notify2_message_list: processed %u messages\n",
+ (uint32_t)msg_count ));
notify_msg_ctr_destroy( &messages );
@@ -1246,21 +1248,21 @@ static void receive_notify2_message_list(struct messaging_context *msg,
driver
********************************************************************/
-static bool srv_spoolss_drv_upgrade_printer(char* drivername)
+static bool srv_spoolss_drv_upgrade_printer(const char *drivername)
{
int len = strlen(drivername);
if (!len)
- return False;
+ return false;
DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n",
drivername));
messaging_send_buf(smbd_messaging_context(), procid_self(),
MSG_PRINTER_DRVUPGRADE,
- (uint8 *)drivername, len+1);
+ (uint8_t *)drivername, len+1);
- return True;
+ return true;
}
/**********************************************************************
@@ -1328,7 +1330,7 @@ void update_monitored_printq_cache( void )
int snum;
/* loop through all printers and update the cache where
- client_connected == True */
+ client_connected == true */
while ( printer )
{
if ( (printer->printer_type == SPLHND_PRINTER)
@@ -1354,16 +1356,16 @@ static bool srv_spoolss_reset_printerdata(char* drivername)
int len = strlen(drivername);
if (!len)
- return False;
+ return false;
DEBUG(10,("srv_spoolss_reset_printerdata: Sending message about resetting printerdata [%s]\n",
drivername));
messaging_send_buf(smbd_messaging_context(), procid_self(),
MSG_PRINTERDATA_INIT_RESET,
- (uint8 *)drivername, len+1);
+ (uint8_t *)drivername, len+1);
- return True;
+ return true;
}
/**********************************************************************
@@ -1527,7 +1529,7 @@ bool convert_devicemode(const char *printername,
if ((devmode->__driverextra_length != 0) && (devmode->driverextra_data.data != NULL)) {
SAFE_FREE(nt_devmode->nt_dev_private);
nt_devmode->driverextra = devmode->__driverextra_length;
- if((nt_devmode->nt_dev_private=SMB_MALLOC_ARRAY(uint8, nt_devmode->driverextra)) == NULL)
+ if((nt_devmode->nt_dev_private = SMB_MALLOC_ARRAY(uint8_t, nt_devmode->driverextra)) == NULL)
return false;
memcpy(nt_devmode->nt_dev_private, devmode->driverextra_data.data, nt_devmode->driverextra);
}
@@ -1544,20 +1546,19 @@ bool convert_devicemode(const char *printername,
WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
struct spoolss_OpenPrinterEx *r)
{
- char *name = CONST_DISCARD(char *, r->in.printername);
int snum;
Printer_entry *Printer=NULL;
- if (!name) {
+ if (!r->in.printername) {
return WERR_INVALID_PARAM;
}
/* some sanity check because you can open a printer or a print server */
/* aka: \\server\printer or \\server */
- DEBUGADD(3,("checking name: %s\n",name));
+ DEBUGADD(3,("checking name: %s\n", r->in.printername));
- if (!open_printer_hnd(p, r->out.handle, name, 0)) {
+ if (!open_printer_hnd(p, r->out.handle, r->in.printername, 0)) {
ZERO_STRUCTP(r->out.handle);
return WERR_INVALID_PARAM;
}
@@ -1565,7 +1566,7 @@ WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
Printer = find_printer_index_by_hnd(p, r->out.handle);
if ( !Printer ) {
DEBUG(0,("_spoolss_OpenPrinterEx: logic error. Can't find printer "
- "handle we created for printer %s\n", name ));
+ "handle we created for printer %s\n", r->in.printername));
close_printer_handle(p, r->out.handle);
ZERO_STRUCTP(r->out.handle);
return WERR_INVALID_PARAM;
@@ -2017,7 +2018,7 @@ static WERROR _spoolss_enddocprinter_internal(pipes_struct *p,
if (!get_printer_snum(p, handle, &snum, NULL))
return WERR_BADFID;
- Printer->document_started=False;
+ Printer->document_started = false;
print_job_end(snum, Printer->jobid,NORMAL_CLOSE);
/* error codes unhandled so far ... */
@@ -2064,7 +2065,7 @@ WERROR _spoolss_DeletePrinter(pipes_struct *p,
result = delete_printer_handle(p, r->in.handle);
- update_c_setprinter(False);
+ update_c_setprinter(false);
return result;
}
@@ -2074,7 +2075,7 @@ WERROR _spoolss_DeletePrinter(pipes_struct *p,
* long architecture string
******************************************************************/
-static int get_version_id (char * arch)
+static int get_version_id(const char *arch)
{
int i;
struct table_node archi_table[]= {
@@ -2105,8 +2106,6 @@ static int get_version_id (char * arch)
WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
struct spoolss_DeletePrinterDriver *r)
{
- char *driver;
- char *arch;
NT_PRINTER_DRIVER_INFO_LEVEL info;
NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
int version;
@@ -2127,24 +2126,26 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
return WERR_ACCESS_DENIED;
}
- driver = CONST_DISCARD(char *, r->in.driver);
- arch = CONST_DISCARD(char *, r->in.architecture);
-
/* check that we have a valid driver name first */
- if ((version=get_version_id(arch)) == -1)
+ if ((version = get_version_id(r->in.architecture)) == -1)
return WERR_INVALID_ENVIRONMENT;
ZERO_STRUCT(info);
ZERO_STRUCT(info_win2k);
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version)))
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, r->in.driver,
+ r->in.architecture,
+ version)))
{
/* try for Win2k driver if "Windows NT x86" */
if ( version == 2 ) {
version = 3;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3,
+ r->in.driver,
+ r->in.architecture,
+ version))) {
status = WERR_UNKNOWN_PRINTER_DRIVER;
goto done;
}
@@ -2164,13 +2165,15 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
if ( version == 2 )
{
- if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3)))
+ if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3,
+ r->in.driver,
+ r->in.architecture, 3)))
{
/* if we get to here, we now have 2 driver info structures to remove */
/* remove the Win2k driver first*/
status_win2k = delete_printer_driver(
- p, info_win2k.info_3, 3, False );
+ p, info_win2k.info_3, 3, false);
free_a_printer_driver( info_win2k, 3 );
/* this should not have failed---if it did, report to client */
@@ -2182,7 +2185,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
}
}
- status = delete_printer_driver(p, info.info_3, version, False);
+ status = delete_printer_driver(p, info.info_3, version, false);
/* if at least one of the deletes succeeded return OK */
@@ -2202,12 +2205,9 @@ done:
WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
struct spoolss_DeletePrinterDriverEx *r)
{
- char *driver;
- char *arch;
NT_PRINTER_DRIVER_INFO_LEVEL info;
NT_PRINTER_DRIVER_INFO_LEVEL info_win2k;
int version;
- uint32_t flags = r->in.delete_flags;
bool delete_files;
WERROR status;
WERROR status_win2k = WERR_ACCESS_DENIED;
@@ -2225,22 +2225,20 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
return WERR_ACCESS_DENIED;
}
- driver = CONST_DISCARD(char *, r->in.driver);
- arch = CONST_DISCARD(char *, r->in.architecture);
-
/* check that we have a valid driver name first */
- if ((version=get_version_id(arch)) == -1) {
+ if ((version = get_version_id(r->in.architecture)) == -1) {
/* this is what NT returns */
return WERR_INVALID_ENVIRONMENT;
}
- if ( flags & DPD_DELETE_SPECIFIC_VERSION )
+ if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
version = r->in.version;
ZERO_STRUCT(info);
ZERO_STRUCT(info_win2k);
- status = get_a_printer_driver(&info, 3, driver, arch, version);
+ status = get_a_printer_driver(&info, 3, r->in.driver,
+ r->in.architecture, version);
if ( !W_ERROR_IS_OK(status) )
{
@@ -2250,13 +2248,15 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
* then we've failed
*/
- if ( (flags&DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
+ if ( (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
goto done;
/* try for Win2k driver if "Windows NT x86" */
version = 3;
- if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, driver, arch, version))) {
+ if (!W_ERROR_IS_OK(get_a_printer_driver(&info, 3, r->in.driver,
+ r->in.architecture,
+ version))) {
status = WERR_UNKNOWN_PRINTER_DRIVER;
goto done;
}
@@ -2279,11 +2279,11 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
* Refer to MSDN docs on DeletePrinterDriverEx() for details.
*/
- delete_files = flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
+ delete_files = r->in.delete_flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
/* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
- if ( delete_files && printer_driver_files_in_use(info.info_3) & (flags&DPD_DELETE_ALL_FILES) ) {
+ if ( delete_files && printer_driver_files_in_use(info.info_3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
/* no idea of the correct error here */
status = WERR_ACCESS_DENIED;
goto done;
@@ -2292,11 +2292,13 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
/* also check for W32X86/3 if necessary; maybe we already have? */
- if ( (version == 2) && ((flags&DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
- if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3, driver, arch, 3)))
+ if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
+ if (W_ERROR_IS_OK(get_a_printer_driver(&info_win2k, 3,
+ r->in.driver,
+ r->in.architecture, 3)))
{
- if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (flags&DPD_DELETE_ALL_FILES) ) {
+ if ( delete_files && printer_driver_files_in_use(info_win2k.info_3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
/* no idea of the correct error here */
free_a_printer_driver( info_win2k, 3 );
status = WERR_ACCESS_DENIED;
@@ -2341,8 +2343,9 @@ static WERROR delete_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char
Internal routine for storing printerdata
***************************************************************************/
-WERROR set_printer_dataex( NT_PRINTER_INFO_LEVEL *printer, const char *key, const char *value,
- uint32 type, uint8 *data, int real_len )
+WERROR set_printer_dataex(NT_PRINTER_INFO_LEVEL *printer,
+ const char *key, const char *value,
+ uint32_t type, uint8_t *data, int real_len)
{
/* the registry objects enforce uniqueness based on value name */
@@ -2409,10 +2412,10 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
}
/* REG_BINARY
- * uint32 size = 0x114
- * uint32 major = 5
- * uint32 minor = [0|1]
- * uint32 build = [2195|2600]
+ * uint32_t size = 0x114
+ * uint32_t major = 5
+ * uint32_t minor = [0|1]
+ * uint32_t build = [2195|2600]
* extra unicode string = e.g. "Service Pack 3"
*/
if (!StrCaseCmp(value, "OSVersion")) {
@@ -2596,12 +2599,12 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
if ( is_zero_addr((struct sockaddr *)client_ss) ) {
if ( !resolve_name( remote_machine, &rm_addr, 0x20) ) {
DEBUG(2,("spoolss_connect_to_client: Can't resolve address for %s\n", remote_machine));
- return False;
+ return false;
}
if (ismyaddr((struct sockaddr *)&rm_addr)) {
DEBUG(0,("spoolss_connect_to_client: Machine %s is one of our addresses. Cannot add to ourselves.\n", remote_machine));
- return False;
+ return false;
}
} else {
char addr[INET6_ADDRSTRLEN];
@@ -2623,13 +2626,13 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
if ( !NT_STATUS_IS_OK( ret ) ) {
DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n",
remote_machine ));
- return False;
+ return false;
}
if ( the_cli->protocol != PROTOCOL_NT1 ) {
DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine));
cli_shutdown(the_cli);
- return False;
+ return false;
}
/*
@@ -2642,10 +2645,10 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
DEBUG(2,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n",
remote_machine, nt_errstr(ret)));
cli_shutdown(the_cli);
- return False;
+ return false;
}
- return True;
+ return true;
}
/***************************************************************************
@@ -2653,7 +2656,7 @@ static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
****************************************************************************/
static bool srv_spoolss_replyopenprinter(int snum, const char *printer,
- uint32 localprinter, uint32 type,
+ uint32_t localprinter, uint32_t type,
struct policy_handle *handle,
struct sockaddr_storage *client_ss)
{
@@ -2670,14 +2673,14 @@ static bool srv_spoolss_replyopenprinter(int snum, const char *printer,
fstrcpy(unix_printer, printer+2); /* the +2 is to strip the leading 2 backslashs */
if ( !spoolss_connect_to_client( &notify_cli_pipe, client_ss, unix_printer ))
- return False;
+ return false;
messaging_register(smbd_messaging_context(), NULL,
MSG_PRINTER_NOTIFY2,
receive_notify2_message_list);
/* Tell the connections db we're now interested in printer
* notify messages. */
- register_message_flags( True, FLAG_MSG_PRINT_NOTIFY );
+ register_message_flags(true, FLAG_MSG_PRINT_NOTIFY);
}
/*
@@ -2811,7 +2814,7 @@ WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(pipes_struct *p,
&Printer->notify.client_hnd, &client_ss))
return WERR_SERVER_UNAVAILABLE;
- Printer->notify.client_connected=True;
+ Printer->notify.client_connected = true;
return WERR_OK;
}
@@ -3296,7 +3299,7 @@ struct s_notify_info_data_table
/* A table describing the various print notification constants and
whether the notification data is a pointer to a variable sized
- buffer, a one value uint32 or a two value uint32. */
+ buffer, a one value uint32_t or a two value uint32_t. */
static const struct s_notify_info_data_table notify_info_data_table[] =
{
@@ -3386,11 +3389,11 @@ static bool search_notify(enum spoolss_NotifyType type,
notify_info_data_table[i].field == field &&
notify_info_data_table[i].fn != NULL) {
*value = i;
- return True;
+ return true;
}
}
- return False;
+ return false;
}
/****************************************************************************
@@ -3435,7 +3438,7 @@ static bool construct_notify_printer_info(Printer_entry *print_hnd,
option_type->count, lp_servicename(snum)));
if (!W_ERROR_IS_OK(get_a_printer(print_hnd, &printer, 2, lp_const_servicename(snum))))
- return False;
+ return false;
for(field_num=0; field_num < option_type->count; field_num++) {
field = option_type->fields[field_num].field;
@@ -3451,7 +3454,7 @@ static bool construct_notify_printer_info(Printer_entry *print_hnd,
if (info->notifies == NULL) {
DEBUG(2,("construct_notify_printer_info: failed to enlarge buffer info->data!\n"));
free_a_printer(&printer, 2);
- return False;
+ return false;
}
current_data = &info->notifies[info->count];
@@ -3468,7 +3471,7 @@ static bool construct_notify_printer_info(Printer_entry *print_hnd,
}
free_a_printer(&printer, 2);
- return True;
+ return true;
}
/*******************************************************************
@@ -3509,7 +3512,7 @@ static bool construct_notify_jobs_info(print_queue_struct *queue,
info->count + 1);
if (info->notifies == NULL) {
DEBUG(2,("construct_notify_jobs_info: failed to enlarg buffer info->data!\n"));
- return False;
+ return false;
}
current_data=&(info->notifies[info->count]);
@@ -3520,7 +3523,7 @@ static bool construct_notify_jobs_info(print_queue_struct *queue,
info->count++;
}
- return True;
+ return true;
}
/*
@@ -3627,7 +3630,7 @@ static WERROR printer_notify_info(pipes_struct *p, struct policy_handle *hnd,
int snum;
Printer_entry *Printer = find_printer_index_by_hnd(p, hnd);
int i;
- uint32 id;
+ uint32_t id;
struct spoolss_NotifyOption *option;
struct spoolss_NotifyOptionType option_type;
int count,j;
@@ -3747,7 +3750,7 @@ WERROR _spoolss_RouterRefreshPrinterChangeNotify(pipes_struct *p,
/* We need to keep track of the change value to send back in
RRPCN replies otherwise our updates are ignored. */
- Printer->notify.fnpcn = True;
+ Printer->notify.fnpcn = true;
if (Printer->notify.client_connected) {
DEBUG(10,("_spoolss_RouterRefreshPrinterChangeNotify: "
@@ -3770,7 +3773,7 @@ WERROR _spoolss_RouterRefreshPrinterChangeNotify(pipes_struct *p,
break;
}
- Printer->notify.fnpcn = False;
+ Printer->notify.fnpcn = false;
done:
return result;
@@ -4201,61 +4204,84 @@ static bool snum_is_shared_printer(int snum)
Spoolss_enumprinters.
********************************************************************/
-static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
- uint32_t flags,
- union spoolss_PrinterInfo **info_p,
- uint32_t *count)
+static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
+ uint32_t level,
+ uint32_t flags,
+ union spoolss_PrinterInfo **info_p,
+ uint32_t *count_p)
{
int snum;
int n_services = lp_numservices();
union spoolss_PrinterInfo *info = NULL;
+ uint32_t count = 0;
WERROR result = WERR_OK;
- DEBUG(4,("enum_all_printers_info_1\n"));
-
- *count = 0;
+ *count_p = 0;
+ *info_p = NULL;
- for (snum=0; snum<n_services; snum++) {
+ for (snum = 0; snum < n_services; snum++) {
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
- struct spoolss_PrinterInfo1 info1;
if (!snum_is_shared_printer(snum)) {
continue;
}
- DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+ DEBUG(4,("Found a printer in smb.conf: %s[%x]\n",
+ lp_servicename(snum), snum));
- result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
- if (!W_ERROR_IS_OK(result)) {
- continue;
+ info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+ union spoolss_PrinterInfo,
+ count + 1);
+ if (!info) {
+ result = WERR_NOMEM;
+ goto out;
}
- result = construct_printer_info1(info, ntprinter, flags, &info1, snum);
- free_a_printer(&ntprinter,2);
+ result = get_a_printer(NULL, &ntprinter, 2,
+ lp_const_servicename(snum));
if (!W_ERROR_IS_OK(result)) {
- continue;
+ goto out;
}
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_PrinterInfo,
- *count + 1);
- if (!info) {
- DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
- result = WERR_NOMEM;
+ switch (level) {
+ case 1:
+ result = construct_printer_info1(info, ntprinter, flags,
+ &info[count].info1, snum);
+ break;
+ case 2:
+ result = construct_printer_info2(info, ntprinter,
+ &info[count].info2, snum);
+ break;
+ case 4:
+ result = construct_printer_info4(info, ntprinter,
+ &info[count].info4, snum);
+ break;
+ case 5:
+ result = construct_printer_info5(info, ntprinter,
+ &info[count].info5, snum);
+ break;
+
+ default:
+ result = WERR_UNKNOWN_LEVEL;
+ free_a_printer(&ntprinter, 2);
goto out;
}
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *count));
+ free_a_printer(&ntprinter, 2);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
- info[*count].info1 = info1;
- (*count)++;
+ count++;
}
+ *count_p = count;
+ *info_p = info;
+
out:
if (!W_ERROR_IS_OK(result)) {
TALLOC_FREE(info);
- *count = 0;
return result;
}
@@ -4265,6 +4291,19 @@ static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
}
/********************************************************************
+********************************************************************/
+
+static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ union spoolss_PrinterInfo **info,
+ uint32_t *count)
+{
+ DEBUG(4,("enum_all_printers_info_1\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 1, flags, info, count);
+}
+
+/********************************************************************
enum_all_printers_info_1_local.
*********************************************************************/
@@ -4340,64 +4379,12 @@ static WERROR enum_all_printers_info_1_network(TALLOC_CTX *mem_ctx,
********************************************************************/
static WERROR enum_all_printers_info_2(TALLOC_CTX *mem_ctx,
- union spoolss_PrinterInfo **info_p,
+ union spoolss_PrinterInfo **info,
uint32_t *count)
{
- int snum;
- int n_services = lp_numservices();
- union spoolss_PrinterInfo *info = NULL;
- WERROR result = WERR_OK;
-
- *count = 0;
-
- for (snum=0; snum<n_services; snum++) {
-
- struct spoolss_PrinterInfo2 info2;
- NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
-
- if (!snum_is_shared_printer(snum)) {
- continue;
- }
-
- DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
-
- result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
- if (!W_ERROR_IS_OK(result)) {
- continue;
- }
-
- result = construct_printer_info2(info, ntprinter, &info2, snum);
- free_a_printer(&ntprinter, 2);
- if (!W_ERROR_IS_OK(result)) {
- continue;
- }
-
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_PrinterInfo,
- *count + 1);
- if (!info) {
- DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
- result = WERR_NOMEM;
- goto out;
- }
-
- DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *count + 1));
-
- info[*count].info2 = info2;
+ DEBUG(4,("enum_all_printers_info_2\n"));
- (*count)++;
- }
-
- out:
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
-
- *info_p = info;
-
- return WERR_OK;
+ return enum_all_printers_info_level(mem_ctx, 2, 0, info, count);
}
/********************************************************************
@@ -4457,6 +4444,22 @@ static WERROR enumprinters_level2(TALLOC_CTX *mem_ctx,
}
/********************************************************************
+ * handle enumeration of printers at level 4
+ ********************************************************************/
+
+static WERROR enumprinters_level4(TALLOC_CTX *mem_ctx,
+ uint32_t flags,
+ const char *servername,
+ union spoolss_PrinterInfo **info,
+ uint32_t *count)
+{
+ DEBUG(4,("enum_all_printers_info_4\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 4, flags, info, count);
+}
+
+
+/********************************************************************
* handle enumeration of printers at level 5
********************************************************************/
@@ -4466,8 +4469,9 @@ static WERROR enumprinters_level5(TALLOC_CTX *mem_ctx,
union spoolss_PrinterInfo **info,
uint32_t *count)
{
-/* return enum_all_printers_info_5(mem_ctx, info, offered, needed, count);*/
- return WERR_OK;
+ DEBUG(4,("enum_all_printers_info_5\n"));
+
+ return enum_all_printers_info_level(mem_ctx, 5, flags, info, count);
}
/****************************************************************
@@ -4517,14 +4521,14 @@ WERROR _spoolss_EnumPrinters(pipes_struct *p,
result = enumprinters_level2(p->mem_ctx, r->in.flags, name,
r->out.info, r->out.count);
break;
+ case 4:
+ result = enumprinters_level4(p->mem_ctx, r->in.flags, name,
+ r->out.info, r->out.count);
+ break;
case 5:
result = enumprinters_level5(p->mem_ctx, r->in.flags, name,
r->out.info, r->out.count);
break;
- case 3:
- case 4:
- result = WERR_OK; /* ??? */
- break;
default:
return WERR_UNKNOWN_LEVEL;
}
@@ -5157,7 +5161,7 @@ WERROR _spoolss_StartPagePrinter(pipes_struct *p,
return WERR_BADFID;
}
- Printer->page_started=True;
+ Printer->page_started = true;
return WERR_OK;
}
@@ -5181,7 +5185,7 @@ WERROR _spoolss_EndPagePrinter(pipes_struct *p,
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
- Printer->page_started=False;
+ Printer->page_started = false;
print_job_endpage(snum, Printer->jobid);
return WERR_OK;
@@ -5194,7 +5198,6 @@ WERROR _spoolss_EndPagePrinter(pipes_struct *p,
WERROR _spoolss_StartDocPrinter(pipes_struct *p,
struct spoolss_StartDocPrinter *r)
{
- uint32_t *jobid = r->out.job_id;
struct spoolss_DocumentInfo1 *info_1;
int snum;
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -5222,7 +5225,7 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p,
if (info_1->datatype) {
if (strcmp(info_1->datatype, "RAW") != 0) {
- (*jobid)=0;
+ *r->out.job_id = 0;
return WERR_INVALID_DATATYPE;
}
}
@@ -5243,8 +5246,8 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p,
return map_werror_from_unix(errno);
}
- Printer->document_started=True;
- (*jobid) = Printer->jobid;
+ Printer->document_started = true;
+ *r->out.job_id = Printer->jobid;
return WERR_OK;
}
@@ -5266,9 +5269,7 @@ WERROR _spoolss_EndDocPrinter(pipes_struct *p,
WERROR _spoolss_WritePrinter(pipes_struct *p,
struct spoolss_WritePrinter *r)
{
- uint32 buffer_size = r->in._data_size;
- uint8 *buffer = r->in.data.data;
- uint32 *buffer_written = &r->in._data_size;
+ uint32_t buffer_written;
int snum;
Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -5282,9 +5283,11 @@ WERROR _spoolss_WritePrinter(pipes_struct *p,
if (!get_printer_snum(p, r->in.handle, &snum, NULL))
return WERR_BADFID;
- (*buffer_written) = (uint32)print_job_write(snum, Printer->jobid, (const char *)buffer,
- (SMB_OFF_T)-1, (size_t)buffer_size);
- if (*buffer_written == (uint32)-1) {
+ buffer_written = (uint32_t)print_job_write(snum, Printer->jobid,
+ (const char *)r->in.data.data,
+ (SMB_OFF_T)-1,
+ (size_t)r->in._data_size);
+ if (buffer_written == (uint32_t)-1) {
*r->out.num_written = 0;
if (errno == ENOSPC)
return WERR_NO_SPOOL_SPACE;
@@ -5515,7 +5518,7 @@ static bool check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
- return True;
+ return true;
}
/****************************************************************************
@@ -5527,7 +5530,7 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
char *command = NULL;
int ret;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- bool is_print_op = False;
+ bool is_print_op = false;
if ( !*cmd ) {
return WERR_ACCESS_DENIED;
@@ -5579,7 +5582,7 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV
int ret;
int fd;
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- bool is_print_op = False;
+ bool is_print_op = false;
char *remote_machine = talloc_strdup(ctx, "%m");
if (!remote_machine) {
@@ -5631,11 +5634,11 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV
if ( ret != 0 ) {
if (fd != -1)
close(fd);
- return False;
+ return false;
}
/* reload our services immediately */
- reload_services( False );
+ reload_services(false);
numlines = 0;
/* Get lines and convert them back to dos-codepage */
@@ -5653,7 +5656,7 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEV
}
TALLOC_FREE(qlines);
- return True;
+ return true;
}
@@ -5782,7 +5785,7 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
if (!strequal(printer->info_2->comment, old_printer->info_2->comment)) {
init_unistr2( &buffer, printer->info_2->comment, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "description",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_comment(snum, printer->info_2->comment);
}
@@ -5790,7 +5793,7 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
if (!strequal(printer->info_2->sharename, old_printer->info_2->sharename)) {
init_unistr2( &buffer, printer->info_2->sharename, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shareName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_sharename(snum, printer->info_2->sharename);
}
@@ -5806,7 +5809,7 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
init_unistr2( &buffer, pname, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "printerName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_printername( snum, pname );
}
@@ -5814,7 +5817,7 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
if (!strequal(printer->info_2->portname, old_printer->info_2->portname)) {
init_unistr2( &buffer, printer->info_2->portname, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "portName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_port(snum, printer->info_2->portname);
}
@@ -5822,7 +5825,7 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
if (!strequal(printer->info_2->location, old_printer->info_2->location)) {
init_unistr2( &buffer, printer->info_2->location, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "location",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
notify_printer_location(snum, printer->info_2->location);
}
@@ -5832,15 +5835,15 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
init_unistr2( &buffer, global_myname(), UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "serverName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "shortServerName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s",
global_myname(), printer->info_2->sharename );
init_unistr2( &buffer, asc_buffer, UNI_STR_TERMINATE);
set_printer_dataex( printer, SPOOL_DSSPOOLER_KEY, "uNCName",
- REG_SZ, (uint8*)buffer.buffer, buffer.uni_str_len*2 );
+ REG_SZ, (uint8_t *)buffer.buffer, buffer.uni_str_len*2 );
/* Update printer info */
result = mod_a_printer(printer, 2);
@@ -5942,7 +5945,7 @@ WERROR _spoolss_FindClosePrinterNotify(pipes_struct *p,
return WERR_BADFID;
}
- if (Printer->notify.client_connected==True) {
+ if (Printer->notify.client_connected == true) {
int snum = -1;
if ( Printer->printer_type == SPLHND_SERVER)
@@ -5959,7 +5962,7 @@ WERROR _spoolss_FindClosePrinterNotify(pipes_struct *p,
Printer->notify.localmachine[0]='\0';
Printer->notify.printerlocal=0;
TALLOC_FREE(Printer->notify.option);
- Printer->notify.client_connected=False;
+ Printer->notify.client_connected = false;
return WERR_OK;
}
@@ -6275,9 +6278,6 @@ WERROR _spoolss_ScheduleJob(pipes_struct *p,
WERROR _spoolss_SetJob(pipes_struct *p,
struct spoolss_SetJob *r)
{
- uint32 jobid = r->in.job_id;
- uint32 command = r->in.command;
-
int snum;
WERROR errcode = WERR_BADFUNC;
@@ -6285,25 +6285,25 @@ WERROR _spoolss_SetJob(pipes_struct *p,
return WERR_BADFID;
}
- if (!print_job_exists(lp_const_servicename(snum), jobid)) {
+ if (!print_job_exists(lp_const_servicename(snum), r->in.job_id)) {
return WERR_INVALID_PRINTER_NAME;
}
- switch (command) {
+ switch (r->in.command) {
case SPOOLSS_JOB_CONTROL_CANCEL:
case SPOOLSS_JOB_CONTROL_DELETE:
- if (print_job_delete(p->server_info, snum, jobid, &errcode)) {
+ if (print_job_delete(p->server_info, snum, r->in.job_id, &errcode)) {
errcode = WERR_OK;
}
break;
case SPOOLSS_JOB_CONTROL_PAUSE:
- if (print_job_pause(p->server_info, snum, jobid, &errcode)) {
+ if (print_job_pause(p->server_info, snum, r->in.job_id, &errcode)) {
errcode = WERR_OK;
}
break;
case SPOOLSS_JOB_CONTROL_RESTART:
case SPOOLSS_JOB_CONTROL_RESUME:
- if (print_job_resume(p->server_info, snum, jobid, &errcode)) {
+ if (print_job_resume(p->server_info, snum, r->in.job_id, &errcode)) {
errcode = WERR_OK;
}
break;
@@ -7209,7 +7209,7 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
return WERR_ACCESS_DENIED;
}
- update_c_setprinter(False);
+ update_c_setprinter(false);
free_a_printer(&printer,2);
return WERR_OK;
@@ -7250,8 +7250,8 @@ WERROR _spoolss_AddPrinterDriver(pipes_struct *p,
struct spoolss_AddDriverInfoCtr *info = r->in.info_ctr;
WERROR err = WERR_OK;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
- fstring driver_name;
- uint32 version;
+ const char *driver_name = NULL;
+ uint32_t version;
const char *fn;
switch (p->hdr_req.opnum) {
@@ -7300,12 +7300,10 @@ WERROR _spoolss_AddPrinterDriver(pipes_struct *p,
switch(level) {
case 3:
- fstrcpy(driver_name,
- driver.info_3->name ? driver.info_3->name : "");
+ driver_name = driver.info_3->name ? driver.info_3->name : "";
break;
case 6:
- fstrcpy(driver_name,
- driver.info_6->name ? driver.info_6->name : "");
+ driver_name = driver.info_6->name ? driver.info_6->name : "";
break;
}
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index cd04462426..c9c457b364 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -257,9 +257,10 @@ static WERROR cmd_spoolss_enum_printers(struct rpc_pipe_client *cli,
union spoolss_PrinterInfo *info;
uint32_t i, count;
const char *name;
+ uint32_t flags = PRINTER_ENUM_LOCAL;
- if (argc > 3) {
- printf("Usage: %s [level] [name]\n", argv[0]);
+ if (argc > 4) {
+ printf("Usage: %s [level] [name] [flags]\n", argv[0]);
return WERR_OK;
}
@@ -267,14 +268,18 @@ static WERROR cmd_spoolss_enum_printers(struct rpc_pipe_client *cli,
level = atoi(argv[1]);
}
- if (argc == 3) {
+ if (argc >= 3) {
name = argv[2];
} else {
name = cli->srv_name_slash;
}
+ if (argc == 4) {
+ flags = atoi(argv[3]);
+ }
+
result = rpccli_spoolss_enumprinters(cli, mem_ctx,
- PRINTER_ENUM_LOCAL,
+ flags,
name,
level,
0,
@@ -417,7 +422,7 @@ static WERROR cmd_spoolss_setprinter(struct rpc_pipe_client *cli,
struct policy_handle pol;
WERROR result;
NTSTATUS status;
- uint32 info_level = 2;
+ uint32_t info_level = 2;
union spoolss_PrinterInfo info;
struct spoolss_SetPrinterInfoCtr info_ctr;
const char *printername, *comment = NULL;
@@ -493,7 +498,7 @@ static WERROR cmd_spoolss_setprintername(struct rpc_pipe_client *cli,
struct policy_handle pol;
WERROR result;
NTSTATUS status;
- uint32 info_level = 2;
+ uint32_t info_level = 2;
union spoolss_PrinterInfo info;
const char *printername,
*new_printername = NULL;
@@ -644,7 +649,7 @@ static void display_reg_value(REGISTRY_VALUE value)
switch(value.type) {
case REG_DWORD:
printf("%s: REG_DWORD: 0x%08x\n", value.valuename,
- *((uint32 *) value.data_p));
+ *((uint32_t *) value.data_p));
break;
case REG_SZ:
rpcstr_pull_talloc(talloc_tos(),
@@ -673,7 +678,7 @@ static void display_reg_value(REGISTRY_VALUE value)
break;
}
case REG_MULTI_SZ: {
- uint32 i, num_values;
+ uint32_t i, num_values;
char **values;
if (!W_ERROR_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
@@ -1338,7 +1343,7 @@ static WERROR cmd_spoolss_addprinterdriver(struct rpc_pipe_client *cli,
{
WERROR result;
NTSTATUS status;
- uint32 level = 3;
+ uint32_t level = 3;
struct spoolss_AddDriverInfoCtr info_ctr;
struct spoolss_AddDriverInfo3 info3;
const char *arch;
@@ -1467,7 +1472,7 @@ static WERROR cmd_spoolss_setdriver(struct rpc_pipe_client *cli,
struct policy_handle pol;
WERROR result;
NTSTATUS status;
- uint32 level = 2;
+ uint32_t level = 2;
const char *printername;
union spoolss_PrinterInfo info;
struct spoolss_SetPrinterInfoCtr info_ctr;
@@ -2051,7 +2056,7 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli,
struct policy_handle handle;
WERROR werror;
const char *printername;
- uint32 num_forms, level = 1, i;
+ uint32_t num_forms, level = 1, i;
union spoolss_FormInfo *forms;
/* Parse the command arguments */
@@ -2544,7 +2549,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
const char **argv)
{
WERROR result;
- uint32 i;
+ uint32_t i;
const char *printername;
struct policy_handle hnd;
uint32_t count;
@@ -2764,7 +2769,7 @@ static bool compare_printer( struct rpc_pipe_client *cli1, struct policy_handle
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
talloc_destroy(mem_ctx);
- return False;
+ return false;
}
printf("ok\n");
@@ -2777,13 +2782,13 @@ static bool compare_printer( struct rpc_pipe_client *cli1, struct policy_handle
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
talloc_destroy(mem_ctx);
- return False;
+ return false;
}
printf("ok\n");
talloc_destroy(mem_ctx);
- return True;
+ return true;
}
/****************************************************************************
@@ -2796,7 +2801,7 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, struct policy
WERROR werror;
TALLOC_CTX *mem_ctx = talloc_init("compare_printer_secdesc");
SEC_DESC *sd1, *sd2;
- bool result = True;
+ bool result = true;
printf("Retrieving printer security for %s...", cli1->desthost);
@@ -2807,7 +2812,7 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, struct policy
&info1);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
- result = False;
+ result = false;
goto done;
}
printf("ok\n");
@@ -2820,7 +2825,7 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, struct policy
&info2);
if ( !W_ERROR_IS_OK(werror) ) {
printf("failed (%s)\n", win_errstr(werror));
- result = False;
+ result = false;
goto done;
}
printf("ok\n");
@@ -2833,13 +2838,13 @@ static bool compare_printer_secdesc( struct rpc_pipe_client *cli1, struct policy
if ( (sd1 != sd2) && ( !sd1 || !sd2 ) ) {
printf("NULL secdesc!\n");
- result = False;
+ result = false;
goto done;
}
if (!sec_desc_equal( sd1, sd2 ) ) {
printf("Security Descriptors *not* equal!\n");
- result = False;
+ result = false;
goto done;
}
diff --git a/source3/samba4.mk b/source3/samba4.mk
index 7e7690aadf..3f661bdd14 100644
--- a/source3/samba4.mk
+++ b/source3/samba4.mk
@@ -225,32 +225,32 @@ test4-%::
valgrindtest4:: valgrindtest-all
valgrindtest4-quick:: all
- SMBD_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
+ SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST4) $(SELFTEST4_QUICK_OPTS) --immediate --socket-wrapper $(TESTS)
valgrindtest4-all:: everything
- SMBD_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
+ SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS)
valgrindtest4-env:: everything
- SMBD_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
+ SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
$(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
gdbtest4:: gdbtest4-all
gdbtest4-quick:: all
- SMBD_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
+ SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
$(SELFTEST4) $(SELFTEST4_QUICK_OPTS) --immediate --socket-wrapper $(TESTS)
gdbtest4-all:: everything
- SMBD_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
+ SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
$(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS)
gdbtest4-env:: everything
- SMBD_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
+ SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
$(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
plugins: $(PLUGINS)
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index d83fb44aba..21881ba6a9 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -54,7 +54,7 @@ NTSTATUS net_get_remote_domain_sid(struct cli_state *cli, TALLOC_CTX *mem_ctx,
DOM_SID **domain_sid,
const char **domain_name)
{
- struct rpc_pipe_client *lsa_pipe;
+ struct rpc_pipe_client *lsa_pipe = NULL;
struct policy_handle pol;
NTSTATUS result = NT_STATUS_OK;
union lsa_PolicyInformation *info = NULL;
@@ -1657,7 +1657,7 @@ static NTSTATUS get_sid_from_name(struct cli_state *cli,
{
DOM_SID *sids = NULL;
enum lsa_SidType *types = NULL;
- struct rpc_pipe_client *pipe_hnd;
+ struct rpc_pipe_client *pipe_hnd = NULL;
struct policy_handle lsa_pol;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index b25c897770..1d0e9a38be 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -84,7 +84,7 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
switch(value.type) {
case REG_DWORD:
d_printf("\t[%s:%s]: REG_DWORD: 0x%08x\n", subkey, value.valuename,
- *((uint32 *) value.data_p));
+ *((uint32_t *) value.data_p));
break;
case REG_SZ:
@@ -105,7 +105,7 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
break;
case REG_MULTI_SZ: {
- uint32 i, num_values;
+ uint32_t i, num_values;
char **values;
if (!W_ERROR_IS_OK(reg_pull_multi_sz(NULL, value.data_p,
@@ -158,7 +158,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
int fnum_src = 0;
int fnum_dst = 0;
SEC_DESC *sd = NULL;
- uint16 attr;
+ uint16_t attr;
time_t f_atime, f_ctime, f_mtime;
@@ -654,9 +654,9 @@ static NTSTATUS copy_print_driver_3(struct net_context *c,
static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
char *name,
- uint32 flags,
- uint32 level,
- uint32 *num_printers,
+ uint32_t flags,
+ uint32_t level,
+ uint32_t *num_printers,
union spoolss_PrinterInfo **info)
{
WERROR result;
@@ -681,7 +681,7 @@ static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
const char *printername,
- uint32 access_required,
+ uint32_t access_required,
const char *username,
struct policy_handle *hnd)
{
@@ -723,7 +723,7 @@ static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
struct policy_handle *hnd,
- uint32 level,
+ uint32_t level,
union spoolss_PrinterInfo *info)
{
WERROR result;
@@ -745,7 +745,7 @@ static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
struct policy_handle *hnd,
- uint32 level,
+ uint32_t level,
union spoolss_PrinterInfo *info)
{
WERROR result;
@@ -863,7 +863,7 @@ static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
- uint32 offered,
+ uint32_t offered,
struct policy_handle *hnd,
const char *keyname,
uint32_t *count,
@@ -941,8 +941,8 @@ static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
- uint32 level, const char *env,
- uint32 *count,
+ uint32_t level, const char *env,
+ uint32_t *count,
union spoolss_DriverInfo **info)
{
WERROR result;
@@ -965,7 +965,7 @@ static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
- struct policy_handle *hnd, uint32 level,
+ struct policy_handle *hnd, uint32_t level,
const char *env, int version,
union spoolss_DriverInfo *info)
{
@@ -999,7 +999,7 @@ static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
- TALLOC_CTX *mem_ctx, uint32 level,
+ TALLOC_CTX *mem_ctx, uint32_t level,
union spoolss_DriverInfo *info)
{
WERROR result;
@@ -1039,7 +1039,7 @@ static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
}
/**
- * abstraction function to get uint32 num_printers and PRINTER_INFO_CTR ctr
+ * abstraction function to get uint32_t num_printers and PRINTER_INFO_CTR ctr
* for a single printer or for all printers depending on argc/argv
**/
@@ -1048,7 +1048,7 @@ static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
int level,
int argc,
const char **argv,
- uint32 *num_printers,
+ uint32_t *num_printers,
union spoolss_PrinterInfo **info_p)
{
struct policy_handle hnd;
@@ -1114,8 +1114,8 @@ NTSTATUS rpc_printer_list_internals(struct net_context *c,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, num_printers;
- uint32 level = 2;
+ uint32_t i, num_printers;
+ uint32_t level = 2;
const char *printername, *sharename;
union spoolss_PrinterInfo *info;
@@ -1166,8 +1166,8 @@ NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i;
- uint32 level = 3;
+ uint32_t i;
+ uint32_t level = 3;
union spoolss_DriverInfo *info;
int d;
@@ -1175,7 +1175,7 @@ NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
for (i=0; archi_table[i].long_archi!=NULL; i++) {
- uint32 num_drivers;
+ uint32_t num_drivers;
/* enum remote drivers */
if (!net_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx, level,
@@ -1225,11 +1225,11 @@ static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_
TALLOC_CTX *mem_ctx,
int argc,
const char **argv,
- uint32 action)
+ uint32_t action)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, num_printers;
- uint32 level = 7;
+ uint32_t i, num_printers;
+ uint32_t level = 7;
const char *printername, *sharename;
union spoolss_PrinterInfo *info_enum;
union spoolss_PrinterInfo info;
@@ -1373,8 +1373,8 @@ NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, num_printers;
- uint32 level = 7;
+ uint32_t i, num_printers;
+ uint32_t level = 7;
const char *printername, *sharename;
union spoolss_PrinterInfo *info_enum;
union spoolss_PrinterInfo info;
@@ -1465,9 +1465,9 @@ NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
convince jerry that we should add clientside setacls level 3 at least
*/
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i = 0;
- uint32 num_printers;
- uint32 level = 2;
+ uint32_t i = 0;
+ uint32_t num_printers;
+ uint32_t level = 2;
const char *printername, *sharename;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
struct policy_handle hnd_src, hnd_dst;
@@ -1611,9 +1611,9 @@ NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
WERROR result;
- uint32 i, f;
- uint32 num_printers;
- uint32 level = 1;
+ uint32_t i, f;
+ uint32_t num_printers;
+ uint32_t level = 1;
const char *printername, *sharename;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
struct policy_handle hnd_src, hnd_dst;
@@ -1771,9 +1771,9 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i, p;
- uint32 num_printers;
- uint32 level = 3;
+ uint32_t i, p;
+ uint32_t num_printers;
+ uint32_t level = 3;
const char *printername, *sharename;
bool got_src_driver_share = false;
bool got_dst_driver_share = false;
@@ -1902,7 +1902,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
}
- if (strlen(drivername) == 0) {
+ if (!drivername || strlen(drivername) == 0) {
DEBUGADD(1,("Did not get driver for printer %s\n",
printername));
goto done;
@@ -1983,8 +1983,8 @@ NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
{
WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i = 0, num_printers;
- uint32 level = 2;
+ uint32_t i = 0, num_printers;
+ uint32_t level = 2;
union spoolss_PrinterInfo info_dst, info_src;
union spoolss_PrinterInfo *info_enum;
struct cli_state *cli_dst = NULL;
@@ -2139,9 +2139,9 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- uint32 i = 0, p = 0, j = 0;
- uint32 num_printers;
- uint32 level = 2;
+ uint32_t i = 0, p = 0, j = 0;
+ uint32_t num_printers;
+ uint32_t level = 2;
const char *printername, *sharename;
struct rpc_pipe_client *pipe_hnd_dst = NULL;
struct policy_handle hnd_src, hnd_dst;
@@ -2445,7 +2445,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
value.type = REG_SZ;
value.size = data.uni_str_len * 2;
if (value.size) {
- value.data_p = (uint8 *)TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
+ value.data_p = (uint8_t *)TALLOC_MEMDUP(mem_ctx, data.buffer, value.size);
} else {
value.data_p = NULL;
}