summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs-xml/manpages-3/vfs_dirsort.8.xml69
-rw-r--r--lib/talloc/talloc.h2
-rw-r--r--selftest/target/Samba3.pm37
-rw-r--r--selftest/target/Samba4.pm8
-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
-rw-r--r--source4/lib/ldb/modules/paged_searches.c115
-rw-r--r--source4/lib/ldb/pyldb.c80
-rwxr-xr-xsource4/lib/ldb/tests/python/api.py13
-rw-r--r--source4/main.mk1
-rwxr-xr-xsource4/script/uninstallman.sh2
-rw-r--r--source4/scripting/bin/fullschema179
-rwxr-xr-xsource4/scripting/bin/minschema200
-rw-r--r--source4/scripting/python/samba/__init__.py6
-rw-r--r--source4/scripting/python/samba/provision.py2
-rw-r--r--source4/selftest/config.mk12
-rw-r--r--source4/smbd/server.c2
-rw-r--r--source4/torture/ldap/cldap.c4
35 files changed, 1484 insertions, 659 deletions
diff --git a/docs-xml/manpages-3/vfs_dirsort.8.xml b/docs-xml/manpages-3/vfs_dirsort.8.xml
new file mode 100644
index 0000000000..cec5f270c8
--- /dev/null
+++ b/docs-xml/manpages-3/vfs_dirsort.8.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
+<refentry id="vfs_dirsort.8">
+
+<refmeta>
+ <refentrytitle>vfs_dirsort</refentrytitle>
+ <manvolnum>8</manvolnum>
+ <refmiscinfo class="source">Samba</refmiscinfo>
+ <refmiscinfo class="manual">System Administration tools</refmiscinfo>
+ <refmiscinfo class="version">3.3</refmiscinfo>
+</refmeta>
+
+
+<refnamediv>
+ <refname>vfs_dirsort</refname>
+ <refpurpose>Sort directory contents</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+ <cmdsynopsis>
+ <command>vfs objects = dirsort</command>
+ </cmdsynopsis>
+</refsynopsisdiv>
+
+<refsect1>
+ <title>DESCRIPTION</title>
+
+ <para>This VFS module is part of the
+ <citerefentry><refentrytitle>samba</refentrytitle>
+ <manvolnum>7</manvolnum></citerefentry> suite.</para>
+
+ <para>The <command>vfs_dirsort</command> module sorts directory
+ entries alphabetically before sending them to the client.</para>
+
+ <para>Please be aware that adding this module might have negative
+ performance implications for large directories.</para>
+
+</refsect1>
+
+<refsect1>
+ <title>EXAMPLES</title>
+
+ <para>Sort directories for all shares:</para>
+
+<programlisting>
+ <smbconfsection name="[global]"/>
+ <smbconfoption name="vfs objects">dirsort</smbconfoption>
+</programlisting>
+
+</refsect1>
+
+<refsect1>
+ <title>VERSION</title>
+
+ <para>This man page is correct for version 3.3 of the Samba suite.
+ </para>
+</refsect1>
+
+<refsect1>
+ <title>AUTHOR</title>
+
+ <para>The original Samba software and related utilities
+ were created by Andrew Tridgell. Samba is now developed
+ by the Samba Team as an Open Source project similar
+ to the way the Linux kernel is developed.</para>
+
+</refsect1>
+
+</refentry>
diff --git a/lib/talloc/talloc.h b/lib/talloc/talloc.h
index 5c8d5c5fe2..f87564a13b 100644
--- a/lib/talloc/talloc.h
+++ b/lib/talloc/talloc.h
@@ -94,7 +94,7 @@ typedef void TALLOC_CTX;
#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
-#define talloc_array_length(ctx) ((ctx) ? talloc_get_size(ctx)/sizeof(*ctx) : 0)
+#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx))
#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type)
#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index e1bea16523..78aafa7533 100644
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -41,6 +41,9 @@ sub teardown_env($$)
$self->stop_sig_term($smbdpid);
$self->stop_sig_term($nmbdpid);
$self->stop_sig_term($winbinddpid);
+
+ sleep(2);
+
$self->stop_sig_kill($smbdpid);
$self->stop_sig_kill($nmbdpid);
$self->stop_sig_kill($winbinddpid);
@@ -123,9 +126,8 @@ sub setup_dc($$)
$dc_options);
$self->check_or_start($vars,
- ($ENV{NMBD_MAXTIME} or 2700),
- ($ENV{WINBINDD_MAXTIME} or 2700),
- ($ENV{SMBD_MAXTIME} or 2700));
+ ($ENV{SMBD_MAXTIME} or 2700),
+ "yes", "yes", "yes");
$self->wait_for_start($vars);
@@ -160,9 +162,8 @@ sub setup_member($$$)
system($cmd) == 0 or die("Join failed\n$cmd");
$self->check_or_start($ret,
- ($ENV{NMBD_MAXTIME} or 2700),
- ($ENV{WINBINDD_MAXTIME} or 2700),
- ($ENV{SMBD_MAXTIME} or 2700));
+ ($ENV{SMBD_MAXTIME} or 2700),
+ "yes", "yes", "yes");
$self->wait_for_start($ret);
@@ -187,7 +188,7 @@ sub stop_sig_term($$) {
sub stop_sig_kill($$) {
my ($self, $pid) = @_;
- kill("KILL", $pid) or warn("Unable to kill $pid: $!");
+ kill("ALRM", $pid) or warn("Unable to kill $pid: $!");
}
sub write_pid($$$)
@@ -209,8 +210,8 @@ sub read_pid($$)
return $pid;
}
-sub check_or_start($$$$) {
- my ($self, $env_vars, $nmbd_maxtime, $winbindd_maxtime, $smbd_maxtime) = @_;
+sub check_or_start($$$$$) {
+ my ($self, $env_vars, $maxtime, $nmbd, $winbindd, $smbd) = @_;
unlink($env_vars->{NMBD_TEST_LOG});
print "STARTING NMBD...";
@@ -226,13 +227,13 @@ sub check_or_start($$$$) {
$ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
- if ($nmbd_maxtime eq "skip") {
+ if ($nmbd ne "yes") {
$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
my $signame = shift;
print("Skip nmbd received signal $signame");
exit 0;
};
- sleep(999999);
+ sleep($maxtime);
exit 0;
}
@@ -243,7 +244,7 @@ sub check_or_start($$$$) {
$ENV{MAKE_TEST_BINARY} = $self->binpath("nmbd");
- my @preargs = ($self->binpath("timelimit"), $nmbd_maxtime);
+ my @preargs = ($self->binpath("timelimit"), $maxtime);
if(defined($ENV{NMBD_VALGRIND})) {
@preargs = split(/ /, $ENV{NMBD_VALGRIND});
}
@@ -267,13 +268,13 @@ sub check_or_start($$$$) {
$ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
- if ($winbindd_maxtime eq "skip") {
+ if ($winbindd ne "yes") {
$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
my $signame = shift;
print("Skip winbindd received signal $signame");
exit 0;
};
- sleep(999999);
+ sleep($maxtime);
exit 0;
}
@@ -284,7 +285,7 @@ sub check_or_start($$$$) {
$ENV{MAKE_TEST_BINARY} = $self->binpath("winbindd");
- my @preargs = ($self->binpath("timelimit"), $winbindd_maxtime);
+ my @preargs = ($self->binpath("timelimit"), $maxtime);
if(defined($ENV{WINBINDD_VALGRIND})) {
@preargs = split(/ /, $ENV{WINBINDD_VALGRIND});
}
@@ -308,13 +309,13 @@ sub check_or_start($$$$) {
$ENV{NSS_WRAPPER_PASSWD} = $env_vars->{NSS_WRAPPER_PASSWD};
$ENV{NSS_WRAPPER_GROUP} = $env_vars->{NSS_WRAPPER_GROUP};
- if ($smbd_maxtime eq "skip") {
+ if ($smbd ne "yes") {
$SIG{USR1} = $SIG{ALRM} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
my $signame = shift;
print("Skip smbd received signal $signame");
exit 0;
};
- sleep(999999);
+ sleep($maxtime);
exit 0;
}
@@ -323,7 +324,7 @@ sub check_or_start($$$$) {
if (defined($ENV{SMBD_OPTIONS})) {
@optargs = split(/ /, $ENV{SMBD_OPTIONS});
}
- my @preargs = ($self->binpath("timelimit"), $smbd_maxtime);
+ my @preargs = ($self->binpath("timelimit"), $maxtime);
if(defined($ENV{SMBD_VALGRIND})) {
@preargs = split(/ /,$ENV{SMBD_VALGRIND});
}
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 71dddf6939..1058ac66e0 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -103,8 +103,8 @@ sub check_or_start($$$)
SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
my $valgrind = "";
- if (defined($ENV{SMBD_VALGRIND})) {
- $valgrind = $ENV{SMBD_VALGRIND};
+ if (defined($ENV{SAMBA_VALGRIND})) {
+ $valgrind = $ENV{SAMBA_VALGRIND};
}
$ENV{KRB5_CONFIG} = $env_vars->{KRB5_CONFIG};
@@ -122,8 +122,8 @@ sub check_or_start($$$)
if (defined($max_time)) {
$optarg = "--maximum-runtime=$max_time ";
}
- if (defined($ENV{SMBD_OPTIONS})) {
- $optarg.= " $ENV{SMBD_OPTIONS}";
+ if (defined($ENV{SAMBA_OPTIONS})) {
+ $optarg.= " $ENV{SAMBA_OPTIONS}";
}
my $samba = $self->bindir_path("samba");
my $ret = system("$valgrind $samba $optarg $env_vars->{CONFIGURATION} -M single -i --leak-report-full");
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;
}
diff --git a/source4/lib/ldb/modules/paged_searches.c b/source4/lib/ldb/modules/paged_searches.c
index 01e77cb22c..c5430eb9bf 100644
--- a/source4/lib/ldb/modules/paged_searches.c
+++ b/source4/lib/ldb/modules/paged_searches.c
@@ -2,6 +2,7 @@
ldb database library
Copyright (C) Simo Sorce 2005-2008
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -52,23 +53,40 @@ struct ps_context {
char **saved_referrals;
int num_referrals;
+
+ struct ldb_request *down_req;
};
-static int check_ps_continuation(struct ldb_request *req, struct ldb_reply *ares)
+static int check_ps_continuation(struct ps_context *ac, struct ldb_request *req, struct ldb_reply *ares)
{
- struct ps_context *ac;
- struct ldb_paged_control *rep_control, *req_control;
+ struct ldb_context *ldb;
+ struct ldb_control *rep_control, *req_control;
+ struct ldb_paged_control *paged_rep_control = NULL, *paged_req_control = NULL;
+ ldb = ldb_module_get_ctx(ac->module);
- ac = talloc_get_type(req->context, struct ps_context);
+ rep_control = ldb_reply_get_control(ares, LDB_CONTROL_PAGED_RESULTS_OID);
+ if (rep_control) {
+ paged_rep_control = talloc_get_type(rep_control->data, struct ldb_paged_control);
+ }
- /* look up our paged control */
- if (!ares->controls || strcmp(LDB_CONTROL_PAGED_RESULTS_OID, ares->controls[0]->oid) != 0) {
- /* something wrong here */
- return LDB_ERR_OPERATIONS_ERROR;
+ req_control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID);
+ paged_req_control = talloc_get_type(req_control->data, struct ldb_paged_control);
+
+ if (!rep_control || !paged_rep_control) {
+ if (paged_req_control->cookie) {
+ /* something wrong here - why give us a control back befre, but not one now? */
+ ldb_set_errstring(ldb, "paged_searches: ERROR: We got back a control from a previous page, but this time no control was returned!");
+ return LDB_ERR_OPERATIONS_ERROR;
+ } else {
+ /* No cookie recived yet, valid to just return the full data set */
+
+ /* we are done */
+ ac->pending = false;
+ return LDB_SUCCESS;
+ }
}
- rep_control = talloc_get_type(ares->controls[0]->data, struct ldb_paged_control);
- if (rep_control->cookie_len == 0) {
+ if (paged_rep_control->cookie_len == 0) {
/* we are done */
ac->pending = false;
return LDB_SUCCESS;
@@ -79,21 +97,14 @@ static int check_ps_continuation(struct ldb_request *req, struct ldb_reply *ares
/* if there's a reply control we must find a request
* control matching it */
- if (strcmp(LDB_CONTROL_PAGED_RESULTS_OID, req->controls[0]->oid) != 0) {
- /* something wrong here */
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- req_control = talloc_get_type(req->controls[0]->data, struct ldb_paged_control);
-
- if (req_control->cookie) {
- talloc_free(req_control->cookie);
+ if (paged_req_control->cookie) {
+ talloc_free(paged_req_control->cookie);
}
- req_control->cookie = talloc_memdup(req_control,
- rep_control->cookie,
- rep_control->cookie_len);
- req_control->cookie_len = rep_control->cookie_len;
+ paged_req_control->cookie = talloc_memdup(req_control,
+ paged_rep_control->cookie,
+ paged_rep_control->cookie_len);
+ paged_req_control->cookie_len = paged_rep_control->cookie_len;
ac->pending = true;
return LDB_SUCCESS;
@@ -141,8 +152,6 @@ static int send_referrals(struct ps_context *ac)
return LDB_SUCCESS;
}
-static int ps_next_request(struct ps_context *ac);
-
static int ps_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct ps_context *ac;
@@ -176,14 +185,15 @@ static int ps_callback(struct ldb_request *req, struct ldb_reply *ares)
case LDB_REPLY_DONE:
- ret = check_ps_continuation(req, ares);
+ ret = check_ps_continuation(ac, req, ares);
if (ret != LDB_SUCCESS) {
return ldb_module_done(ac->req, NULL, NULL, ret);
}
if (ac->pending) {
- ret = ps_next_request(ac);
+ ret = ldb_next_request(ac->module, ac->down_req);
+
if (ret != LDB_SUCCESS) {
return ldb_module_done(ac->req,
NULL, NULL, ret);
@@ -214,14 +224,16 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req)
struct ldb_context *ldb;
struct private_data *private_data;
struct ps_context *ac;
+ struct ldb_paged_control *control;
+ int ret;
private_data = talloc_get_type(ldb_module_get_private(module), struct private_data);
ldb = ldb_module_get_ctx(module);
- /* check if paging is supported and if there is a any control */
- if (!private_data || !private_data->paged_supported || req->controls) {
+ /* check if paging is supported */
+ if (!private_data || !private_data->paged_supported) {
/* do not touch this request paged controls not
- * supported or explicit controls have been set or we
+ * supported or we
* are just not setup yet */
return ldb_next_request(module, req);
}
@@ -238,30 +250,9 @@ static int ps_search(struct ldb_module *module, struct ldb_request *req)
ac->saved_referrals = NULL;
ac->num_referrals = 0;
- return ps_next_request(ac);
-}
-
-static int ps_next_request(struct ps_context *ac) {
-
- struct ldb_context *ldb;
- struct ldb_paged_control *control;
- struct ldb_control **controls;
- struct ldb_request *new_req;
- int ret;
-
ldb = ldb_module_get_ctx(ac->module);
- controls = talloc_array(ac, struct ldb_control *, 2);
- if (!controls) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- controls[0] = talloc(controls, struct ldb_control);
- if (!controls[0]) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- control = talloc(controls[0], struct ldb_paged_control);
+ control = talloc(ac, struct ldb_paged_control);
if (!control) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -270,26 +261,28 @@ static int ps_next_request(struct ps_context *ac) {
control->cookie = NULL;
control->cookie_len = 0;
- controls[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID;
- controls[0]->critical = 1;
- controls[0]->data = control;
- controls[1] = NULL;
-
- ret = ldb_build_search_req_ex(&new_req, ldb, ac,
+ ret = ldb_build_search_req_ex(&ac->down_req, ldb, ac,
ac->req->op.search.base,
ac->req->op.search.scope,
ac->req->op.search.tree,
ac->req->op.search.attrs,
- controls,
+ ac->req->controls,
ac,
ps_callback,
ac->req);
if (ret != LDB_SUCCESS) {
return ret;
}
- talloc_steal(new_req, controls);
- return ldb_next_request(ac->module, new_req);
+ ret = ldb_request_add_control(ac->down_req, LDB_CONTROL_PAGED_RESULTS_OID,
+ true, control);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ talloc_steal(ac->down_req, control);
+
+ return ldb_next_request(ac->module, ac->down_req);
}
static int check_supported_paged(struct ldb_request *req,
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index 81b960979f..bceda05e4f 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -5,7 +5,7 @@
Copyright (C) 2005,2006 Tim Potter <tpot@samba.org>
Copyright (C) 2006 Simo Sorce <idra@samba.org>
- Copyright (C) 2007-2008 Jelmer Vernooij <jelmer@samba.org>
+ Copyright (C) 2007-2009 Jelmer Vernooij <jelmer@samba.org>
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
@@ -65,18 +65,7 @@ static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx,
PyObject *ret;
new_val = *val;
-
- if (ldb_ctx != NULL) {
- a = ldb_schema_attribute_by_name(ldb_ctx, el->name);
-
- if (a != NULL) {
- if (a->syntax->ldif_write_fn(ldb_ctx, mem_ctx, val, &new_val) != 0) {
- talloc_free(mem_ctx);
- return NULL;
- }
- }
- }
-
+
ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length);
talloc_free(mem_ctx);
@@ -84,6 +73,14 @@ static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx,
return ret;
}
+/**
+ * Obtain a ldb DN from a Python object.
+ *
+ * @param mem_ctx Memory context
+ * @param object Python object
+ * @param ldb_ctx LDB context
+ * @return Whether or not the conversion succeeded
+ */
bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object,
struct ldb_context *ldb_ctx, struct ldb_dn **dn)
{
@@ -104,6 +101,12 @@ bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object,
return false;
}
+/**
+ * Create a Python object from a ldb_result.
+ *
+ * @param result LDB result to convert
+ * @return Python object with converted result (a list object)
+ */
static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
{
PyObject *ret;
@@ -119,7 +122,16 @@ static PyObject *PyLdbResult_FromResult(struct ldb_result *result)
return ret;
}
-static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx, PyObject *obj)
+/**
+ * Create a LDB Result from a Python object.
+ * If conversion fails, NULL will be returned and a Python exception set.
+ *
+ * @param mem_ctx Memory context in which to allocate the LDB Result
+ * @param obj Python object to convert
+ * @return a ldb_result, or NULL if the conversion failed
+ */
+static struct ldb_result *PyLdbResult_AsResult(TALLOC_CTX *mem_ctx,
+ PyObject *obj)
{
struct ldb_result *res;
int i;
@@ -451,7 +463,6 @@ static PyObject *py_ldb_get_schema_basedn(PyLdbObject *self)
return PyLdbDn_FromDn(dn);
}
-
static PyObject *py_ldb_get_config_basedn(PyLdbObject *self)
{
struct ldb_dn *dn = ldb_get_config_basedn(PyLdb_AsLdbContext(self));
@@ -460,7 +471,6 @@ static PyObject *py_ldb_get_config_basedn(PyLdbObject *self)
return PyLdbDn_FromDn(dn);
}
-
static PyObject *py_ldb_get_default_basedn(PyLdbObject *self)
{
struct ldb_dn *dn = ldb_get_default_basedn(PyLdb_AsLdbContext(self));
@@ -469,19 +479,20 @@ static PyObject *py_ldb_get_default_basedn(PyLdbObject *self)
return PyLdbDn_FromDn(dn);
}
-static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list)
+static const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list,
+ const char *paramname)
{
const char **ret;
int i;
if (!PyList_Check(list)) {
- PyErr_SetString(PyExc_TypeError, "options is not a list");
+ PyErr_Format(PyExc_TypeError, "%s is not a list", paramname);
return NULL;
}
ret = talloc_array(NULL, const char *, PyList_Size(list)+1);
for (i = 0; i < PyList_Size(list); i++) {
PyObject *item = PyList_GetItem(list, i);
if (!PyString_Check(item)) {
- PyErr_SetString(PyExc_TypeError, "options should be strings");
+ PyErr_Format(PyExc_TypeError, "%s should be strings", paramname);
return NULL;
}
ret[i] = PyString_AsString(item);
@@ -510,7 +521,7 @@ static int py_ldb_init(PyLdbObject *self, PyObject *args, PyObject *kwargs)
if (py_options == Py_None) {
options = NULL;
} else {
- options = PyList_AsStringList(ldb, py_options);
+ options = PyList_AsStringList(ldb, py_options, "options");
if (options == NULL)
return -1;
}
@@ -563,7 +574,7 @@ static PyObject *py_ldb_connect(PyLdbObject *self, PyObject *args, PyObject *kwa
if (py_options == Py_None) {
options = NULL;
} else {
- options = PyList_AsStringList(NULL, py_options);
+ options = PyList_AsStringList(NULL, py_options, "options");
if (options == NULL)
return NULL;
}
@@ -651,8 +662,6 @@ static PyObject *py_ldb_add(PyLdbObject *self, PyObject *args)
Py_RETURN_NONE;
}
-
-
static PyObject *py_ldb_delete(PyLdbObject *self, PyObject *args)
{
PyObject *py_dn;
@@ -813,7 +822,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
if (py_attrs == Py_None) {
attrs = NULL;
} else {
- attrs = PyList_AsStringList(ldb_ctx, py_attrs);
+ attrs = PyList_AsStringList(ldb_ctx, py_attrs, "attrs");
if (attrs == NULL)
return NULL;
}
@@ -828,7 +837,7 @@ static PyObject *py_ldb_search(PyLdbObject *self, PyObject *args, PyObject *kwar
if (py_controls == Py_None) {
parsed_controls = NULL;
} else {
- const char **controls = PyList_AsStringList(ldb_ctx, py_controls);
+ const char **controls = PyList_AsStringList(ldb_ctx, py_controls, "controls");
parsed_controls = ldb_parse_control_strings(ldb_ctx, ldb_ctx, controls);
talloc_free(controls);
}
@@ -1129,7 +1138,7 @@ static PyObject *py_ldb_module_search(PyLdbModuleObject *self, PyObject *args, P
mod = self->mod;
ret = ldb_build_search_req(&req, mod->ldb, NULL, PyLdbDn_AsDn(py_base),
- scope, NULL /* expr */, py_attrs == Py_None?NULL:PyList_AsStringList(req, py_attrs),
+ scope, NULL /* expr */, py_attrs == Py_None?NULL:PyList_AsStringList(req, py_attrs, "attrs"),
NULL /* controls */, NULL, NULL, NULL);
PyErr_LDB_ERROR_IS_ERR_RAISE(ret, mod->ldb);
@@ -1256,6 +1265,21 @@ PyTypeObject PyLdbModule = {
.tp_flags = Py_TPFLAGS_DEFAULT,
};
+
+/**
+ * Create a ldb_message_element from a Python object.
+ *
+ * This will accept any sequence objects that contains strings, or
+ * a string object.
+ *
+ * A reference to set_obj will be borrowed.
+ *
+ * @param mem_ctx Memory context
+ * @param set_obj Python object to convert
+ * @param flags ldb_message_element flags to set
+ * @param attr_name Name of the attribute
+ * @return New ldb_message_element, allocated as child of mem_ctx
+ */
struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
PyObject *set_obj, int flags,
const char *attr_name)
@@ -1273,9 +1297,7 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
me->num_values = 1;
me->values = talloc_array(me, struct ldb_val, me->num_values);
me->values[0].length = PyString_Size(set_obj);
- me->values[0].data = (uint8_t *)talloc_strndup(me->values,
- PyString_AsString(set_obj),
- me->values[0].length);
+ me->values[0].data = (uint8_t *)PyString_AsString(set_obj);
} else if (PySequence_Check(set_obj)) {
int i;
me->num_values = PySequence_Size(set_obj);
diff --git a/source4/lib/ldb/tests/python/api.py b/source4/lib/ldb/tests/python/api.py
index c372b8fa71..07500e2372 100755
--- a/source4/lib/ldb/tests/python/api.py
+++ b/source4/lib/ldb/tests/python/api.py
@@ -258,6 +258,19 @@ class SimpleLdb(unittest.TestCase):
l = ldb.Ldb(filename())
l.set_debug(my_report_fn)
+ def test_zero_byte_string(self):
+ """Testing we do not get trapped in the \0 byte in a property string."""
+ l = ldb.Ldb(filename())
+ l.add({
+ "dn" : "dc=somedn",
+ "objectclass" : "user",
+ "cN" : "LDAPtestUSER",
+ "givenname" : "ldap",
+ "displayname" : "foo\0bar",
+ })
+ res = l.search(expression="(dn=dc=somedn)")
+ self.assertEquals("foo\0bar", res[0]["displayname"][0])
+
class DnTests(unittest.TestCase):
def setUp(self):
diff --git a/source4/main.mk b/source4/main.mk
index a143604f33..d7db0580e9 100644
--- a/source4/main.mk
+++ b/source4/main.mk
@@ -46,6 +46,7 @@ mkinclude torture/config.mk
mkinclude librpc/config.mk
mkinclude client/config.mk
mkinclude libcli/config.mk
+mkinclude ../libcli/cldap/config.mk
mkinclude scripting/python/config.mk
mkinclude kdc/config.mk
mkinclude ../lib/smbconf/config.mk
diff --git a/source4/script/uninstallman.sh b/source4/script/uninstallman.sh
index 9b087c68bb..edc1c47e4d 100755
--- a/source4/script/uninstallman.sh
+++ b/source4/script/uninstallman.sh
@@ -8,7 +8,7 @@ MANPAGES=$*
for I in $MANPAGES
do
- SECTION=`echo -n $I | sed "s/.*\(.\)$/\1/"
+ SECTION=`echo -n $I | sed "s/.*\(.\)$/\1/"`
FNAME=$MANDIR/man$SECTION/$I
if test -f $FNAME; then
echo Deleting $FNAME
diff --git a/source4/scripting/bin/fullschema b/source4/scripting/bin/fullschema
new file mode 100644
index 0000000000..41c45f30c8
--- /dev/null
+++ b/source4/scripting/bin/fullschema
@@ -0,0 +1,179 @@
+#!/usr/bin/python
+#
+# work out the minimal schema for a set of objectclasses
+#
+
+import base64
+import optparse
+import os
+import sys
+
+# Find right directory when running from source tree
+sys.path.insert(0, "bin/python")
+
+import samba
+from samba import getopt as options, Ldb
+from ldb import SCOPE_SUBTREE, SCOPE_BASE, LdbError
+import sys
+
+parser = optparse.OptionParser("fullschema <URL>")
+sambaopts = options.SambaOptions(parser)
+parser.add_option_group(sambaopts)
+credopts = options.CredentialsOptions(parser)
+parser.add_option_group(credopts)
+parser.add_option_group(options.VersionOptions(parser))
+parser.add_option("--dump-classes", action="store_true")
+parser.add_option("--dump-attributes", action="store_true")
+
+opts, args = parser.parse_args()
+opts.dump_all = True
+
+if opts.dump_classes:
+ opts.dump_all = False
+if opts.dump_attributes:
+ opts.dump_all = False
+if opts.dump_all:
+ opts.dump_classes = True
+ opts.dump_attributes = True
+
+if len(args) != 1:
+ parser.print_usage()
+ sys.exit(1)
+
+url = args[0]
+
+lp_ctx = sambaopts.get_loadparm()
+
+creds = credopts.get_credentials(lp_ctx)
+ldb = Ldb(url, credentials=creds, lp=lp_ctx, options=["modules:paged_searches"])
+
+# the attributes we need for objectclasses
+class_attrs = ["objectClass",
+ "cn",
+ "subClassOf",
+ "governsID",
+ "possSuperiors",
+ "possibleInferiors",
+ "mayContain",
+ "mustContain",
+ "auxiliaryClass",
+ "rDNAttID",
+ "adminDisplayName",
+ "adminDescription",
+ "objectClassCategory",
+ "lDAPDisplayName",
+ "schemaIDGUID",
+ "systemOnly",
+ "systemPossSuperiors",
+ "systemMayContain",
+ "systemMustContain",
+ "systemAuxiliaryClass",
+ "defaultSecurityDescriptor",
+ "systemFlags",
+ "defaultHidingValue",
+ "defaultObjectCategory",
+
+ # this attributes are not used by w2k3
+ "schemaFlagsEx",
+ "msDs-IntId",
+ "msDs-Schema-Extensions",
+ "classDisplayName",
+ "isDefunct"]
+
+attrib_attrs = ["objectClass",
+ "cn",
+ "attributeID",
+ "attributeSyntax",
+ "isSingleValued",
+ "rangeLower",
+ "rangeUpper",
+ "mAPIID",
+ "linkID",
+ "adminDisplayName",
+ "oMObjectClass",
+ "adminDescription",
+ "oMSyntax",
+ "searchFlags",
+ "extendedCharsAllowed",
+ "lDAPDisplayName",
+ "schemaIDGUID",
+ "attributeSecurityGUID",
+ "systemOnly",
+ "systemFlags",
+ "isMemberOfPartialAttributeSet",
+
+ # this attributes are not used by w2k3
+ "schemaFlagsEx",
+ "msDs-IntId",
+ "msDs-Schema-Extensions",
+ "classDisplayName",
+ "isEphemeral",
+ "isDefunct"]
+
+class Objectclass(dict):
+
+ def __init__(self, ldb, name):
+ """create an objectclass object"""
+ self.name = name
+
+
+class Attribute(dict):
+
+ def __init__(self, ldb, name):
+ """create an attribute object"""
+ self.name = name
+ self["cn"] = get_object_cn(ldb, name)
+
+
+
+def fix_dn(dn):
+ """fix a string DN to use ${SCHEMADN}"""
+ return dn.replace(rootDse["schemaNamingContext"][0], "${SCHEMADN}")
+
+
+def write_ldif_one(o, attrs):
+ """dump an object as ldif"""
+ print "dn: CN=%s,${SCHEMADN}" % o["cn"]
+ for a in attrs:
+ if not o.has_key(a):
+ continue
+ # special case for oMObjectClass, which is a binary object
+ v = o[a]
+ for j in v:
+ value = fix_dn(j)
+ if a != "cn":
+ if a == "oMObjectClass":
+ print "%s:: %s" % (a, base64.b64encode(value))
+ elif a.endswith("GUID"):
+ print "%s: %s" % (a, ldb.schema_format_value(a, value))
+ else:
+ print "%s: %s" % (a, value)
+ print ""
+
+
+# get the rootDSE
+res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["schemaNamingContext"])
+rootDse = res[0]
+
+if opts.dump_attributes:
+ res = ldb.search(expression="objectClass=attributeSchema",
+ base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE,attrs=attrib_attrs,
+ controls=["server_sort:1:0:cn"])
+
+ for msg in res:
+ o = Objectclass(ldb, msg["ldapDisplayName"])
+ for a in msg:
+ o[a] = msg[a]
+ write_ldif_one(o, attrib_attrs)
+
+if opts.dump_classes:
+ res = ldb.search(expression="objectClass=classSchema",
+ base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE,attrs=class_attrs,
+ controls=["server_sort:1:0:cn"])
+
+ for msg in res:
+ o = Objectclass(ldb, msg["ldapDisplayName"])
+ for a in msg:
+ o[a] = msg[a]
+ write_ldif_one(o, class_attrs)
+
diff --git a/source4/scripting/bin/minschema b/source4/scripting/bin/minschema
index e7d7ed4979..c860495e96 100755
--- a/source4/scripting/bin/minschema
+++ b/source4/scripting/bin/minschema
@@ -3,9 +3,10 @@
# work out the minimal schema for a set of objectclasses
#
+import base64
import optparse
-
-import os, sys
+import os
+import sys
# Find right directory when running from source tree
sys.path.insert(0, "bin/python")
@@ -54,10 +55,10 @@ if len(args) != 2:
lp_ctx = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp_ctx)
-ldb = Ldb(url, credentials=creds)
+ldb = Ldb(url, credentials=creds, lp=lp_ctx)
-objectclasses = []
-attributes = []
+objectclasses = {}
+attributes = {}
objectclasses_expanded = set()
@@ -71,7 +72,6 @@ class_attrs = ["objectClass",
"mustContain",
"auxiliaryClass",
"rDNAttID",
- "showInAdvancedViewOnly",
"adminDisplayName",
"adminDescription",
"objectClassCategory",
@@ -103,7 +103,6 @@ attrib_attrs = ["objectClass",
"rangeUpper",
"mAPIID",
"linkID",
- "showInAdvancedViewOnly",
"adminDisplayName",
"oMObjectClass",
"adminDescription",
@@ -136,24 +135,25 @@ attrib_attrs = ["objectClass",
def get_object_cn(ldb, name):
attrs = ["cn"]
-
- res = ldb.search("(ldapDisplayName=%s)" % name, rootDse["schemaNamingContext"], SCOPE_SUBTREE, attrs)
+ res = ldb.search(expression="(ldapDisplayName=%s)" % name, base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE, attrs=attrs)
assert len(res) == 1
-
return res[0]["cn"]
-class Objectclass:
+
+class Objectclass(dict):
+
def __init__(self, ldb, name):
"""create an objectclass object"""
self.name = name
- self.cn = get_object_cn(ldb, name)
+ self["cn"] = get_object_cn(ldb, name)
+
+class Attribute(dict):
-class Attribute:
def __init__(self, ldb, name):
"""create an attribute object"""
self.name = name
- self.cn = get_object_cn(ldb, name)
+ self["cn"] = get_object_cn(ldb, name)
syntaxmap = dict()
@@ -180,36 +180,38 @@ syntaxmap['2.5.5.17'] = '1.3.6.1.4.1.1466.115.121.1.40'
def map_attribute_syntax(s):
"""map some attribute syntaxes from some apparently MS specific
syntaxes to the standard syntaxes"""
- if syntaxmap.has_key(s):
+ if s in list(syntaxmap):
return syntaxmap[s]
return s
def fix_dn(dn):
"""fix a string DN to use ${SCHEMADN}"""
- return dn.replace(rootDse["schemaNamingContext"], "${SCHEMADN}")
+ return dn.replace(rootDse["schemaNamingContext"][0], "${SCHEMADN}")
def write_ldif_one(o, attrs):
"""dump an object as ldif"""
- print "dn: CN=%s,${SCHEMADN}\n" % o["cn"]
+ print "dn: CN=%s,${SCHEMADN}" % o["cn"]
for a in attrs:
if not o.has_key(a):
continue
# special case for oMObjectClass, which is a binary object
- if a == "oMObjectClass":
- print "%s:: %s\n" % (a, o[a])
- continue
v = o[a]
- if isinstance(v, str):
- v = [v]
for j in v:
- print "%s: %s\n" % (a, fix_dn(j))
- print "\n"
+ value = fix_dn(j)
+ if a == "oMObjectClass":
+ print "%s:: %s" % (a, base64.b64encode(value))
+ elif a.endswith("GUID"):
+ print "%s: %s" % (a, ldb.schema_format_value(a, value))
+ else:
+ print "%s: %s" % (a, value)
+ print ""
+
def write_ldif(o, attrs):
"""dump an array of objects as ldif"""
- for i in o:
+ for n, i in o.items():
write_ldif_one(i, attrs)
@@ -225,7 +227,7 @@ def find_objectclass_properties(ldb, o):
"""the properties of an objectclass"""
res = ldb.search(
expression="(ldapDisplayName=%s)" % o.name,
- base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE, attrs=class_attrs)
+ base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE, attrs=class_attrs)
assert(len(res) == 1)
msg = res[0]
for a in msg:
@@ -235,15 +237,11 @@ def find_attribute_properties(ldb, o):
"""find the properties of an attribute"""
res = ldb.search(
expression="(ldapDisplayName=%s)" % o.name,
- base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE,
+ base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE,
attrs=attrib_attrs)
assert(len(res) == 1)
msg = res[0]
for a in msg:
- # special case for oMObjectClass, which is a binary object
- if a == "oMObjectClass":
- o[a] = ldb.encode(msg[a])
- continue
o[a] = msg[a]
@@ -254,15 +252,15 @@ def find_objectclass_auto(ldb, o):
return
testdn = create_testdn(o.exampleDN)
- print "testdn is '%s'\n" % testdn
+ print "testdn is '%s'" % testdn
ldif = "dn: " + testdn
ldif += "\nobjectClass: " + o.name
try:
ldb.add(ldif)
except LdbError, e:
- print "error adding %s: %s\n" % (o.name, e)
- print "%s\n" % ldif
+ print "error adding %s: %s" % (o.name, e)
+ print "%s" % ldif
return
res = ldb.search(base=testdn, scope=ldb.SCOPE_BASE)
@@ -280,20 +278,20 @@ def expand_objectclass(ldb, o):
"subClassOf"]
res = ldb.search(
expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % o.name,
- base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE,
+ base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE,
attrs=attrs)
- print "Expanding class %s\n" % o.name
+ print >>sys.stderr, "Expanding class %s" % o.name
assert(len(res) == 1)
msg = res[0]
- for a in attrs:
- if not msg.has_key(aname):
+ for aname in attrs:
+ if not aname in msg:
continue
list = msg[aname]
if isinstance(list, str):
list = [msg[aname]]
for name in list:
if not objectclasses.has_key(name):
- print "Found new objectclass '%s'\n" % name
+ print >>sys.stderr, "Found new objectclass '%s'" % name
objectclasses[name] = Objectclass(ldb, name)
@@ -320,13 +318,13 @@ def walk_dn(ldb, dn):
try:
res = ldb.search("objectClass=*", dn, SCOPE_BASE, attrs)
except LdbError, e:
- print "Unable to fetch allowedAttributes for '%s' - %r\n" % (dn, e)
+ print >>sys.stderr, "Unable to fetch allowedAttributes for '%s' - %r" % (dn, e)
return
allattrs = res[0]["allowedAttributes"]
try:
res = ldb.search("objectClass=*", dn, SCOPE_BASE, allattrs)
except LdbError, e:
- print "Unable to fetch all attributes for '%s' - %s\n" % (dn, e)
+ print >>sys.stderr, "Unable to fetch all attributes for '%s' - %s" % (dn, e)
return
msg = res[0]
for a in msg:
@@ -339,7 +337,7 @@ def walk_naming_context(ldb, namingContext):
res = ldb.search("objectClass=*", namingContext, SCOPE_DEFAULT,
["objectClass"])
except LdbError, e:
- print "Unable to fetch objectClasses for '%s' - %s\n" % (namingContext, e)
+ print >>sys.stderr, "Unable to fetch objectClasses for '%s' - %s" % (namingContext, e)
return
for msg in res:
msg = res.msgs[r]["objectClass"]
@@ -356,12 +354,9 @@ def trim_objectclass_attributes(ldb, objectclass):
if objectclass.has_key("possibleInferiors"):
possinf = objectclass["possibleInferiors"]
newpossinf = []
- if isinstance(possinf, str):
- possinf = [possinf]
for x in possinf:
if objectclasses.has_key(x):
- newpossinf[n] = x
- n+=1
+ newpossinf.append(x)
objectclass["possibleInferiors"] = newpossinf
# trim systemMayContain,
@@ -369,8 +364,6 @@ def trim_objectclass_attributes(ldb, objectclass):
if objectclass.has_key("systemMayContain"):
sysmay = objectclass["systemMayContain"]
newsysmay = []
- if isinstance(sysmay, str):
- sysmay = [sysmay]
for x in sysmay:
if not x in newsysmay:
newsysmay.append(x)
@@ -378,7 +371,7 @@ def trim_objectclass_attributes(ldb, objectclass):
# trim mayContain,
# remove duplicates
- if not objectclass.has_key("mayContain"):
+ if objectclass.has_key("mayContain"):
may = objectclass["mayContain"]
newmay = []
if isinstance(may, str):
@@ -388,71 +381,65 @@ def trim_objectclass_attributes(ldb, objectclass):
newmay.append(x)
objectclass["mayContain"] = newmay
+
def build_objectclass(ldb, name):
"""load the basic attributes of an objectClass"""
attrs = ["name"]
- try:
- res = ldb.search(
- expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % name,
- base=rootDse["schemaNamingContext"], scope=SCOPE_SUBTREE,
- attrs=attrs)
- except LdbError, e:
- print "unknown class '%s'\n" % name
- return None
+ res = ldb.search(
+ expression="(&(objectClass=classSchema)(ldapDisplayName=%s))" % name,
+ base=rootDse["schemaNamingContext"][0], scope=SCOPE_SUBTREE,
+ attrs=attrs)
if len(res) == 0:
- print "unknown class '%s'\n" % name
+ print >>sys.stderr, "unknown class '%s'" % name
return None
return Objectclass(ldb, name)
+
def attribute_list(objectclass, attr1, attr2):
"""form a coalesced attribute list"""
- a1 = objectclass[attr1]
- a2 = objectclass[attr2]
- if isinstance(a1, str):
- a1 = [a1]
- if isinstance(a2, str):
- a2 = [a2]
+ a1 = list(objectclass.get(attr1, []))
+ a2 = list(objectclass.get(attr2, []))
return a1 + a2
def aggregate_list(name, list):
"""write out a list in aggregate form"""
- if list is None:
- return
- print "%s ( %s )" % (name, "$ ".join(list))
+ if list == []:
+ return ""
+ return " %s ( %s )" % (name, " $ ".join(list))
def write_aggregate_objectclass(objectclass):
"""write the aggregate record for an objectclass"""
- print "objectClasses: ( %s NAME '%s' " % (objectclass.governsID, objectclass.name)
+ line = "objectClasses: ( %s NAME '%s' " % (objectclass["governsID"], objectclass.name)
if not objectclass.has_key('subClassOf'):
- print "SUP %s " % objectclass['subClassOf']
- if objectclass.objectClassCategory == 1:
- print "STRUCTURAL "
- elif objectclass.objectClassCategory == 2:
- print "ABSTRACT "
- elif objectclass.objectClassCategory == 3:
- print "AUXILIARY "
+ line += "SUP %s" % objectclass['subClassOf']
+ if objectclass["objectClassCategory"] == 1:
+ line += "STRUCTURAL"
+ elif objectclass["objectClassCategory"] == 2:
+ line += "ABSTRACT"
+ elif objectclass["objectClassCategory"] == 3:
+ line += "AUXILIARY"
list = attribute_list(objectclass, "systemMustContain", "mustContain")
- aggregate_list("MUST", list)
+ line += aggregate_list("MUST", list)
list = attribute_list(objectclass, "systemMayContain", "mayContain")
- aggregate_list("MAY", list)
+ line += aggregate_list("MAY", list)
- print ")\n"
+ print line + " )"
def write_aggregate_ditcontentrule(objectclass):
"""write the aggregate record for an ditcontentrule"""
list = attribute_list(objectclass, "auxiliaryClass", "systemAuxiliaryClass")
- if list is None:
+ if list == []:
return
- print "dITContentRules: ( %s NAME '%s' " % (objectclass.governsID, objectclass.name)
+ line = "dITContentRules: ( %s NAME '%s'" % (objectclass["governsID"], objectclass.name)
- aggregate_list("AUX", list)
+ line += aggregate_list("AUX", list)
- may_list = None
- must_list = None
+ may_list = []
+ must_list = []
for c in list:
list2 = attribute_list(objectclasses[c],
@@ -462,44 +449,43 @@ def write_aggregate_ditcontentrule(objectclass):
"mustContain", "systemMustContain")
must_list = must_list + list2
- aggregate_list("MUST", must_list)
- aggregate_list("MAY", may_list)
+ line += aggregate_list("MUST", must_list)
+ line += aggregate_list("MAY", may_list)
- print ")\n"
+ print line + " )"
def write_aggregate_attribute(attrib):
"""write the aggregate record for an attribute"""
- print "attributeTypes: ( %s NAME '%s' SYNTAX '%s' " % (
- attrib.attributeID, attrib.name,
- map_attribute_syntax(attrib.attributeSyntax))
- if attrib['isSingleValued'] == "TRUE":
- print "SINGLE-VALUE "
- if attrib['systemOnly'] == "TRUE":
- print "NO-USER-MODIFICATION "
+ line = "attributeTypes: ( %s NAME '%s' SYNTAX '%s' " % (
+ attrib["attributeID"], attrib.name,
+ map_attribute_syntax(attrib["attributeSyntax"]))
+ if attrib.get('isSingleValued') == "TRUE":
+ line += "SINGLE-VALUE "
+ if attrib.get('systemOnly') == "TRUE":
+ line += "NO-USER-MODIFICATION "
- print ")\n"
+ print line + ")"
def write_aggregate():
"""write the aggregate record"""
- print "dn: CN=Aggregate,${SCHEMADN}\n"
+ print "dn: CN=Aggregate,${SCHEMADN}"
print """objectClass: top
objectClass: subSchema
-objectCategory: CN=SubSchema,${SCHEMADN}
-"""
+objectCategory: CN=SubSchema,${SCHEMADN}"""
if not opts.dump_subschema_auto:
return
- for objectclass in objectclasses:
+ for objectclass in objectclasses.values():
write_aggregate_objectclass(objectclass)
- for attr in attributes:
+ for attr in attributes.values():
write_aggregate_attribute(attr)
- for objectclass in objectclasses:
+ for objectclass in objectclasses.values():
write_aggregate_ditcontentrule(objectclass)
def load_list(file):
"""load a list from a file"""
- return open(file, 'r').readlines()
+ return [l.strip("\n") for l in open(file, 'r').readlines()]
# get the rootDSE
res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["schemaNamingContext"])
@@ -523,32 +509,32 @@ expanded = 0
# than necessary to recursively expand all classes
#
for inf in range(500):
- for n in objectclasses:
+ for n, o in objectclasses.items():
if not n in objectclasses_expanded:
- expand_objectclass(ldb, objectclasses[i])
+ expand_objectclass(ldb, o)
objectclasses_expanded.add(n)
#
# find objectclass properties
#
-for objectclass in objectclasses:
+for name, objectclass in objectclasses.items():
find_objectclass_properties(ldb, objectclass)
#
# form the full list of attributes
#
-for objectclass in objectclasses:
+for name, objectclass in objectclasses.items():
add_objectclass_attributes(ldb, objectclass)
# and attribute properties
-for attr in attributes:
+for name, attr in attributes.items():
find_attribute_properties(ldb, attr)
#
# trim the 'may' attribute lists to those really needed
#
-for objectclass in objectclasses:
+for name, objectclass in objectclasses.items():
trim_objectclass_attributes(ldb, objectclass)
#
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index a49e6e1ead..c5827b96e0 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -54,7 +54,7 @@ class Ldb(ldb.Ldb):
functions see samdb.py.
"""
def __init__(self, url=None, session_info=None, credentials=None,
- modules_dir=None, lp=None):
+ modules_dir=None, lp=None, options=None):
"""Open a Samba Ldb file.
:param url: Optional LDB URL to open
@@ -67,7 +67,7 @@ class Ldb(ldb.Ldb):
modules-dir is used by default and that credentials and session_info
can be passed through (required by some modules).
"""
- super(Ldb, self).__init__()
+ super(Ldb, self).__init__(options=options)
if modules_dir is not None:
self.set_modules_dir(modules_dir)
@@ -90,7 +90,7 @@ class Ldb(ldb.Ldb):
#self.set_debug(msg)
if url is not None:
- self.connect(url)
+ self.connect(url, options=options)
def set_credentials(self, credentials):
glue.ldb_set_credentials(self, credentials)
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index d96857661e..896f237bd7 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -1056,7 +1056,7 @@ def provision(setup_dir, message, session_info,
serverrole=serverrole, ldap_backend=ldap_backend,
ldap_backend_type=ldap_backend_type)
- if lp.get("server role") == "domain controller":
+ if serverrole == "domain controller":
if paths.netlogon is None:
message("Existing smb.conf does not have a [netlogon] share, but you are configuring a DC.")
message("Please either remove %s or see the template at %s" %
diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk
index 324532c22a..1838a0bb38 100644
--- a/source4/selftest/config.mk
+++ b/source4/selftest/config.mk
@@ -59,31 +59,31 @@ test-%::
valgrindtest:: valgrindtest-all
valgrindtest-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" \
$(SELFTEST) $(SELFTEST_QUICK_OPTS) --immediate --socket-wrapper $(TESTS)
valgrindtest-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" \
$(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS)
valgrindtest-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" \
$(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --socket-wrapper --testenv
gdbtest:: gdbtest-all
gdbtest-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)" \
$(SELFTEST) $(SELFTEST_QUICK_OPTS) --immediate --socket-wrapper $(TESTS)
gdbtest-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)" \
$(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS)
gdbtest-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)" \
$(SELFTEST) $(SELFTEST_NOSLOW_OPTS) --socket-wrapper --testenv
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index d576782ab1..635e84fafe 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -365,5 +365,5 @@ static int binary_smbd_main(const char *binary_name, int argc, const char *argv[
int main(int argc, const char *argv[])
{
- return binary_smbd_main("smbd", argc, argv);
+ return binary_smbd_main("samba", argc, argv);
}
diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c
index 98669288a8..814c9ac86d 100644
--- a/source4/torture/ldap/cldap.c
+++ b/source4/torture/ldap/cldap.c
@@ -59,8 +59,8 @@ static bool test_cldap_netlogon(struct torture_context *tctx, const char *dest)
CHECK_STATUS(status, NT_STATUS_OK);
ZERO_STRUCT(search);
- search.in.dest_address = NULL;//dest;
- search.in.dest_port = 0;//lp_cldap_port(tctx->lp_ctx);
+ search.in.dest_address = NULL;
+ search.in.dest_port = 0;
search.in.acct_control = -1;
search.in.version = NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX;
search.in.map_response = true;