summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-08-07 15:53:54 +0000
committerGerald Carter <jerry@samba.org>2005-08-07 15:53:54 +0000
commit6c6d666261852a27571f33aaa7d217107e3434eb (patch)
tree196412540f1b16ead5aedf26a0d2c9a9aa71ebe9
parent5084d752169cb9e734f3098ab013599917e7035e (diff)
downloadsamba-6c6d666261852a27571f33aaa7d217107e3434eb.tar.gz
r9184: pretty much all the recent changes from SAMBA_3_0 since
they are mostly crash bug fixes svn merge -r8911:8956 $SVNURL/branches/SAMBA_3_0 svn merge -r8956:8989 $SVNURL/branches/SAMBA_3_0 svn merge -r8992:9076 $SVNURL/branches/SAMBA_3_0 svn merge -r9080:9086 $SVNURL/branches/SAMBA_3_0 svn merge -r9087:9091 $SVNURL/branches/SAMBA_3_0 svn merge -r9091:9163 $SVNURL/branches/SAMBA_3_0
-rw-r--r--source/VERSION14
-rw-r--r--source/auth/pampass.c2
-rw-r--r--source/configure.in104
-rw-r--r--source/include/authdata.h10
-rw-r--r--source/include/msdfs.h17
-rw-r--r--source/include/vfs.h4
-rw-r--r--source/include/vfs_macros.h24
-rw-r--r--source/lib/privileges.c2
-rw-r--r--source/lib/smbldap.c2
-rw-r--r--source/lib/socket_wrapper.c21
-rw-r--r--source/lib/substitute.c2
-rw-r--r--source/lib/time.c6
-rw-r--r--source/lib/util_unistr.c4
-rw-r--r--source/libads/authdata.c32
-rw-r--r--source/libads/ldap_printer.c4
-rw-r--r--source/libads/sasl.c2
-rw-r--r--source/libsmb/credentials.c32
-rw-r--r--source/nmbd/nmbd_workgroupdb.c2
-rw-r--r--source/passdb/pdb_pgsql.c5
-rw-r--r--source/printing/nt_printing.c37
-rw-r--r--source/registry/reg_db.c14
-rw-r--r--source/registry/reg_objects.c7
-rw-r--r--source/rpc_client/cli_spoolss.c8
-rw-r--r--source/rpc_parse/parse_net.c2
-rw-r--r--source/rpc_parse/parse_spoolss.c30
-rw-r--r--source/rpc_parse/parse_svcctl.c6
-rw-r--r--source/rpc_server/srv_dfs_nt.c9
-rw-r--r--source/rpc_server/srv_netlog_nt.c17
-rw-r--r--source/rpc_server/srv_reg_nt.c29
-rw-r--r--source/rpc_server/srv_samr_nt.c8
-rw-r--r--source/rpc_server/srv_spoolss_nt.c30
-rw-r--r--source/rpc_server/srv_svcctl_nt.c81
-rw-r--r--source/rpcclient/cmd_samr.c6
-rw-r--r--source/rpcclient/cmd_spoolss.c5
-rw-r--r--source/rpcclient/rpcclient.c10
-rwxr-xr-xsource/script/mkversion.sh7
-rw-r--r--source/smbd/conn.c22
-rw-r--r--source/smbd/msdfs.c363
-rw-r--r--source/smbd/oplock.c12
-rw-r--r--source/smbd/process.c4
-rw-r--r--source/smbd/sesssetup.c45
-rw-r--r--source/smbd/trans2.c2
-rw-r--r--source/tdb/tdb.c4
-rw-r--r--source/utils/net.c2
-rw-r--r--source/utils/net_rpc.c13
-rw-r--r--source/utils/net_rpc_printer.c22
46 files changed, 685 insertions, 399 deletions
diff --git a/source/VERSION b/source/VERSION
index 33cc6f2e01c..560e6a294e9 100644
--- a/source/VERSION
+++ b/source/VERSION
@@ -22,6 +22,18 @@ SAMBA_VERSION_MINOR=0
SAMBA_VERSION_RELEASE=20
########################################################
+# If a official release has a serious bug #
+# a security release will have 'a' sufffix #
+# #
+# so SAMBA's version will be #
+# <MAJOR>.<MINOR>.<RELEASE><REVISION> #
+# #
+# e.g. SAMBA_VERSION_REVISION=a #
+# -> "2.2.8a" #
+########################################################
+SAMBA_VERSION_REVISION=
+
+########################################################
# For 'pre' releases the version will be #
# #
# <MAJOR>.<MINOR>.<RELEASE>pre<PRE_RELEASE> #
@@ -39,7 +51,7 @@ SAMBA_VERSION_PRE_RELEASE=
# e.g. SAMBA_VERSION_RC_RELEASE=1 #
# -> "3.0.0rc1" #
########################################################
-SAMBA_VERSION_RC_RELEASE=1
+SAMBA_VERSION_RC_RELEASE=2
########################################################
# To mark SVN snapshots this should be set to 'yes' #
diff --git a/source/auth/pampass.c b/source/auth/pampass.c
index 5a40bf6c477..18d83ee3648 100644
--- a/source/auth/pampass.c
+++ b/source/auth/pampass.c
@@ -202,7 +202,7 @@ struct chat_struct {
Create a linked list containing chat data.
***************************************************************/
-static struct chat_struct *make_pw_chat(char *p)
+static struct chat_struct *make_pw_chat(const char *p)
{
fstring prompt;
fstring reply;
diff --git a/source/configure.in b/source/configure.in
index e343a9f54fd..4bd237b4fb8 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -1404,7 +1404,6 @@ if test "$enable_shared" = "yes"; then
AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
;;
*hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
- SHLIBEXT="sl"
# Use special PIC flags for the native HP-UX compiler.
if test $ac_cv_prog_cc_Ae = yes; then
BLDSHARED="true"
@@ -1415,7 +1414,13 @@ if test "$enable_shared" = "yes"; then
elif test "${GCC}" = "yes"; then
PICFLAGS="-fPIC"
fi
- DYNEXP="-Wl,-E"
+ if test "$host_cpu" = "ia64"; then
+ SHLIBEXT="so"
+ DYNEXP="-Wl,-E,+b /usr/local/lib/hpux32:/usr/lib/hpux32"
+ else
+ SHLIBEXT="sl"
+ DYNEXP="-Wl,-E,+b /usr/local/lib:/usr/lib"
+ fi
AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
;;
@@ -1905,7 +1910,8 @@ dnl in both libiconv and in libc. In this case the jm_ICONV test will always
dnl succeed when the header is found. To counter this, make sure the
dnl library directory is there and check the ABI directory first (which
dnl should be harmless on other systems.
- for l in "lib32" "lib" ; do
+dnl For IA64 HPUX systems, the libs are located in lib/hpux32 instead of lib.
+ for l in "lib32" "lib" "lib/hpux32"; do
if test -d "$i/$l" ; then
LDFLAGS="$save_LDFLAGS -L$i/$l"
LIBS=
@@ -4165,6 +4171,7 @@ AC_ARG_WITH(aio-support,
[ case "$withval" in
yes)
+ AC_MSG_RESULT(yes)
case "$host_os" in
*)
AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$ACL_LIBS -lrt"])
@@ -4192,6 +4199,94 @@ samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
AC_DEFINE(WITH_AIO, 1, [Using asynchronous io])
LIBS="$LIBS -lrt"
fi
+
+ if test x"$samba_cv_HAVE_AIO" = x"yes"; then
+ AC_MSG_CHECKING(for aio_read)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_read(&a); }],
+[AC_DEFINE(HAVE_AIO_READ, 1, [Have aio_read]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_write)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_write(&a); }],
+[AC_DEFINE(HAVE_AIO_WRITE, 1, [Have aio_write]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_fsync)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_fsync(1, &a); }],
+[AC_DEFINE(HAVE_AIO_FSYNC, 1, [Have aio_fsync]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_return)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_return(&a); }],
+[AC_DEFINE(HAVE_AIO_RETURN, 1, [Have aio_return]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_error)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_error(&a); }],
+[AC_DEFINE(HAVE_AIO_ERROR, 1, [Have aio_error]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_cancel)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_cancel(1, &a); }],
+[AC_DEFINE(HAVE_AIO_CANCEL, 1, [Have aio_cancel]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_suspend)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_suspend(&a, 1, NULL); }],
+[AC_DEFINE(HAVE_AIO_SUSPEND, 1, [Have aio_suspend]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+ fi
+
+ if test x"$samba_cv_HAVE_AIO64" = x"yes"; then
+ AC_MSG_CHECKING(for aio_read64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_read64(&a); }],
+[AC_DEFINE(HAVE_AIO_READ64, 1, [Have aio_read64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_write64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_write64(&a); }],
+[AC_DEFINE(HAVE_AIO_WRITE64, 1, [Have aio_write64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_fsync64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_fsync64(1, &a); }],
+[AC_DEFINE(HAVE_AIO_FSYNC64, 1, [Have aio_fsync64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_return64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_return64(&a); }],
+[AC_DEFINE(HAVE_AIO_RETURN64, 1, [Have aio_return64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_error64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_error64(&a); }],
+[AC_DEFINE(HAVE_AIO_ERROR64, 1, [Have aio_error64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_cancel64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_cancel64(1, &a); }],
+[AC_DEFINE(HAVE_AIO_CANCEL64, 1, [Have aio_cancel64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+
+ AC_MSG_CHECKING(for aio_suspend64)
+ AC_LINK_IFELSE([#include <aio.h>
+int main() { struct aiocb a; return aio_suspend64(&a, 1, NULL); }],
+[AC_DEFINE(HAVE_AIO_SUSPEND64, 1, [Have aio_suspend64]) AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+ fi
;;
esac
;;
@@ -4204,9 +4299,6 @@ samba_cv_HAVE_AIO64=yes,samba_cv_HAVE_AIO64=no)
AC_MSG_RESULT(no)
)
-AC_CHECK_FUNCS(aio_cancel aio_cancel64 aio_error aio_error64 aio_fsync aio_fsync64 aio_read aio_read64)
-AC_CHECK_FUNCS(aio_return aio_return64 aio_suspend aio_suspend64 aio_write aio_write64)
-
#################################################
# check for sendfile support
diff --git a/source/include/authdata.h b/source/include/authdata.h
index 9d80745fb06..1be127aaac6 100644
--- a/source/include/authdata.h
+++ b/source/include/authdata.h
@@ -27,13 +27,13 @@
#define PAC_TYPE_LOGON_INFO 1
#define PAC_TYPE_SERVER_CHECKSUM 6
#define PAC_TYPE_PRIVSVR_CHECKSUM 7
-#define PAC_TYPE_UNKNOWN_10 10
+#define PAC_TYPE_LOGON_NAME 10
-typedef struct unknown_type_10 {
- NTTIME unknown_time;
+typedef struct pac_logon_name {
+ NTTIME logon_time;
uint16 len;
uint16 *username; /* might not be null terminated, so not UNISTR */
-} UNKNOWN_TYPE_10;
+} PAC_LOGON_NAME;
typedef struct pac_signature_data {
uint32 type;
@@ -130,7 +130,7 @@ typedef struct pac_info_ctr
PAC_LOGON_INFO *logon_info;
PAC_SIGNATURE_DATA *srv_cksum;
PAC_SIGNATURE_DATA *privsrv_cksum;
- UNKNOWN_TYPE_10 *type_10;
+ PAC_LOGON_NAME *logon_name;
} pac;
} PAC_INFO_CTR;
diff --git a/source/include/msdfs.h b/source/include/msdfs.h
index ff035ddd493..f7aa494cd2c 100644
--- a/source/include/msdfs.h
+++ b/source/include/msdfs.h
@@ -44,23 +44,20 @@ typedef struct _client_referral {
pstring dfspath;
} CLIENT_DFS_REFERRAL;
-struct referral
-{
+struct referral {
pstring alternate_path; /* contains the path referred */
uint32 proximity;
uint32 ttl; /* how long should client cache referral */
};
-struct junction_map
-{
- pstring service_name;
- pstring volume_name;
- int referral_count;
- struct referral* referral_list;
+struct junction_map {
+ pstring service_name;
+ pstring volume_name;
+ int referral_count;
+ struct referral* referral_list;
};
-struct dfs_path
-{
+struct dfs_path {
pstring hostname;
pstring servicename;
pstring reqpath;
diff --git a/source/include/vfs.h b/source/include/vfs.h
index 7f6c94f6e99..c7c7575d904 100644
--- a/source/include/vfs.h
+++ b/source/include/vfs.h
@@ -316,9 +316,9 @@ struct vfs_ops {
/* aio operations */
int (*aio_read)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
int (*aio_write)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
- ssize_t (*aio_return)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
+ ssize_t (*aio_return_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
int (*aio_cancel)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_STRUCT_AIOCB *aiocb);
- int (*aio_error)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
+ int (*aio_error_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
int (*aio_fsync)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
int (*aio_suspend)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *timeout);
diff --git a/source/include/vfs_macros.h b/source/include/vfs_macros.h
index 0647796ea84..e6bfb1f527c 100644
--- a/source/include/vfs_macros.h
+++ b/source/include/vfs_macros.h
@@ -125,9 +125,9 @@
/* AIO operations. */
#define SMB_VFS_AIO_READ(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_read((fsp)->conn->vfs.handles.aio_read,(fsp),(aiocb)))
#define SMB_VFS_AIO_WRITE(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_write((fsp)->conn->vfs.handles.aio_write,(fsp),(aiocb)))
-#define SMB_VFS_AIO_RETURN(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_return((fsp)->conn->vfs.handles.aio_return,(fsp),(aiocb)))
+#define SMB_VFS_AIO_RETURN(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_return_fn((fsp)->conn->vfs.handles.aio_return,(fsp),(aiocb)))
#define SMB_VFS_AIO_CANCEL(fsp,fd,aiocb) ((fsp)->conn->vfs.ops.aio_cancel((fsp)->conn->vfs.handles.aio_cancel,(fsp),(fd),(aiocb)))
-#define SMB_VFS_AIO_ERROR(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_error((fsp)->conn->vfs.handles.aio_error,(fsp),(aiocb)))
+#define SMB_VFS_AIO_ERROR(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_error_fn((fsp)->conn->vfs.handles.aio_error,(fsp),(aiocb)))
#define SMB_VFS_AIO_FSYNC(fsp,op,aiocb) ((fsp)->conn->vfs.ops.aio_fsync((fsp)->conn->vfs.handles.aio_fsync,(fsp),(op),(aiocb)))
#define SMB_VFS_AIO_SUSPEND(fsp,aiocb,n,ts) ((fsp)->conn->vfs.ops.aio_suspend((fsp)->conn->vfs.handles.aio_suspend,(fsp),(aiocb),(n),(ts)))
@@ -234,11 +234,11 @@
/* AIO operations. */
#define SMB_VFS_OPAQUE_AIO_READ(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_read((fsp)->conn->vfs_opaque.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_OPAQUE_AIO_WRITE(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_write((fsp)->conn->vfs_opaque.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_OPAQUE_AIO_RETURN(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_return((fsp)->conn->vfs_opaque.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_OPAQUE_AIO_CANCEL(fsp,fd,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_cancel((fsp)->conn->vfs_opaque.handles.aio_read,(fsp),(fd),(aiocb)))
-#define SMB_VFS_OPAQUE_AIO_ERROR(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_error((fsp)->conn->vfs_opaque.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_OPAQUE_AIO_FSYNC(fsp,op,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_fsync((fsp)->conn->vfs_opaque.handles.aio_read,(fsp),(op),(aiocb)))
+#define SMB_VFS_OPAQUE_AIO_WRITE(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_write((fsp)->conn->vfs_opaque.handles.aio_write,(fsp),(aiocb)))
+#define SMB_VFS_OPAQUE_AIO_RETURN(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_return_fn((fsp)->conn->vfs_opaque.handles.aio_return,(fsp),(aiocb)))
+#define SMB_VFS_OPAQUE_AIO_CANCEL(fsp,fd,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_cancel((fsp)->conn->vfs_opaque.handles.cancel,(fsp),(fd),(aiocb)))
+#define SMB_VFS_OPAQUE_AIO_ERROR(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_error_fn((fsp)->conn->vfs_opaque.handles.aio_error,(fsp),(aiocb)))
+#define SMB_VFS_OPAQUE_AIO_FSYNC(fsp,op,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_fsync((fsp)->conn->vfs_opaque.handles.aio_fsync,(fsp),(op),(aiocb)))
#define SMB_VFS_OPAQUE_AIO_SUSPEND(fsp,aiocb,n,ts) ((fsp)->conn->vfs_opaque.ops.aio_suspend((fsp)->conn->vfs_opaque.handles.aio_suspend,(fsp),(aiocb),(n),(ts)))
/*******************************************************************
@@ -345,11 +345,11 @@
/* AIO operations. */
#define SMB_VFS_NEXT_AIO_READ(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_read((handle)->vfs_next.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_NEXT_AIO_WRITE(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_write((handle)->vfs_next.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_NEXT_AIO_RETURN(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_return((handle)->vfs_next.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_NEXT_AIO_CANCEL(handle,fsp,fd,aiocb) ((handle)->vfs_next.ops.aio_cancel((handle)->vfs_next.handles.aio_read,(fsp),(fd),(aiocb)))
-#define SMB_VFS_NEXT_AIO_ERROR(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_error((handle)->vfs_next.handles.aio_read,(fsp),(aiocb)))
-#define SMB_VFS_NEXT_AIO_FSYNC(handle,fsp,op,aiocb) ((handle)->vfs_next.ops.aio_fsync((handle)->vfs_next.handles.aio_read,(fsp),(op),(aiocb)))
+#define SMB_VFS_NEXT_AIO_WRITE(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_write((handle)->vfs_next.handles.aio_write,(fsp),(aiocb)))
+#define SMB_VFS_NEXT_AIO_RETURN(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_return_fn((handle)->vfs_next.handles.aio_return,(fsp),(aiocb)))
+#define SMB_VFS_NEXT_AIO_CANCEL(handle,fsp,fd,aiocb) ((handle)->vfs_next.ops.aio_cancel((handle)->vfs_next.handles.aio_cancel,(fsp),(fd),(aiocb)))
+#define SMB_VFS_NEXT_AIO_ERROR(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_error_fn((handle)->vfs_next.handles.aio_error,(fsp),(aiocb)))
+#define SMB_VFS_NEXT_AIO_FSYNC(handle,fsp,op,aiocb) ((handle)->vfs_next.ops.aio_fsync((handle)->vfs_next.handles.aio_fsync,(fsp),(op),(aiocb)))
#define SMB_VFS_NEXT_AIO_SUSPEND(handle,fsp,aiocb,n,ts) ((handle)->vfs_next.ops.aio_suspend((handle)->vfs_next.handles.aio_suspend,(fsp),(aiocb),(n),(ts)))
#endif /* _VFS_MACROS_H */
diff --git a/source/lib/privileges.c b/source/lib/privileges.c
index 05dff33307c..8bb6108448b 100644
--- a/source/lib/privileges.c
+++ b/source/lib/privileges.c
@@ -758,7 +758,7 @@ char* luid_to_privilege_name(const LUID *set)
for ( i=0; !se_priv_equal(&privs[i].se_priv, &se_priv_end); i++ ) {
if ( set->low == privs[i].luid.low ) {
- fstrcpy( name, privs[set->low - 1].name );
+ fstrcpy( name, privs[i].name );
return name;
}
}
diff --git a/source/lib/smbldap.c b/source/lib/smbldap.c
index d1f3f82cb56..10bd56d0874 100644
--- a/source/lib/smbldap.c
+++ b/source/lib/smbldap.c
@@ -456,7 +456,7 @@ ATTRIB_MAP_ENTRY sidmap_attr_list[] = {
the old value, should it exist. */
if ((newval != NULL) && (strlen(newval) > 0)) {
- DEBUG(10,("smbldap_make_mod: adding attribute |%s| value |%s|\n", attribute));
+ DEBUG(10,("smbldap_make_mod: adding attribute |%s| value |%s|\n", attribute, newval));
smbldap_set_mod(mods, LDAP_MOD_ADD, attribute, newval);
}
}
diff --git a/source/lib/socket_wrapper.c b/source/lib/socket_wrapper.c
index 808d62601f8..9d65aa923af 100644
--- a/source/lib/socket_wrapper.c
+++ b/source/lib/socket_wrapper.c
@@ -94,6 +94,19 @@ struct socket_info
static struct socket_info *sockets = NULL;
+
+static const char *socket_wrapper_dir(void)
+{
+ const char *s = getenv("SOCKET_WRAPPER_DIR");
+ if (s == NULL) {
+ return NULL;
+ }
+ if (strncmp(s, "./", 2) == 0) {
+ s += 2;
+ }
+ return s;
+}
+
static int convert_un_in(const struct sockaddr_un *un, struct sockaddr_in *in, socklen_t *len)
{
unsigned int prt;
@@ -127,12 +140,12 @@ static int convert_in_un(struct socket_info *si, const struct sockaddr_in *in, s
prt = 5000;
do {
snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- getenv("SOCKET_WRAPPER_DIR"), type, ++prt);
+ socket_wrapper_dir(), type, ++prt);
} while (stat(un->sun_path, &st) == 0 && prt < 10000);
((struct sockaddr_in *)si->myname)->sin_port = htons(prt);
}
snprintf(un->sun_path, sizeof(un->sun_path), "%s/"SOCKET_FORMAT,
- getenv("SOCKET_WRAPPER_DIR"), type, prt);
+ socket_wrapper_dir(), type, prt);
return 0;
}
@@ -204,7 +217,7 @@ int swrap_socket(int domain, int type, int protocol)
struct socket_info *si;
int fd;
- if (!getenv("SOCKET_WRAPPER_DIR")) {
+ if (!socket_wrapper_dir()) {
return real_socket(domain, type, protocol);
}
@@ -279,7 +292,7 @@ static int swrap_auto_bind(struct socket_info *si)
for (i=0;i<1000;i++) {
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path),
- "%s/"SOCKET_FORMAT, getenv("SOCKET_WRAPPER_DIR"),
+ "%s/"SOCKET_FORMAT, socket_wrapper_dir(),
SOCK_DGRAM, i + 10000);
if (bind(si->fd, (struct sockaddr *)&un_addr,
sizeof(un_addr)) == 0) {
diff --git a/source/lib/substitute.c b/source/lib/substitute.c
index 15862f7a966..c6d61bce951 100644
--- a/source/lib/substitute.c
+++ b/source/lib/substitute.c
@@ -386,7 +386,7 @@ void standard_sub_basic(const char *smb_name, char *str,size_t len)
string_sub(p,"%i", client_socket_addr(),l);
break;
case 'L' :
- if (!StrnCaseCmp(p, "\%LOGONSERVER\%", 13)) {
+ if (!StrnCaseCmp(p, "%LOGONSERVER%", strlen("%LOGONSERVER%"))) {
p++;
break;
}
diff --git a/source/lib/time.c b/source/lib/time.c
index f7b0aefe4fe..5e0f5646fca 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -366,7 +366,7 @@ time_t nt_time_to_unix_abs(NTTIME *nt)
return(0);
if (nt->high==0x80000000 && nt->low==0)
- return -1;
+ return (time_t)-1;
/* reverse the time */
/* it's a negative value, turn it to positive */
@@ -421,7 +421,7 @@ void unix_to_nt_time(NTTIME *nt, time_t t)
nt->high = 0x7fffffff;
return;
}
- if (t == -1) {
+ if (t == (time_t)-1) {
nt->low = 0xffffffff;
nt->high = 0xffffffff;
return;
@@ -462,7 +462,7 @@ void unix_to_nt_time_abs(NTTIME *nt, time_t t)
return;
}
- if (t == -1) {
+ if (t == (time_t)-1) {
/* that's what NT uses for infinite */
nt->low = 0x0;
nt->high = 0x80000000;
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c
index b31e01474a8..6b29a0d26a7 100644
--- a/source/lib/util_unistr.c
+++ b/source/lib/util_unistr.c
@@ -815,7 +815,7 @@ int strcmp_wa(const smb_ucs2_t *a, const char *b)
a++;
b++;
}
- return (cp - UCS2_CHAR(*b));
+ return (*(COPY_UCS2_CHAR(&cp,a)) - UCS2_CHAR(*b));
}
int strncmp_wa(const smb_ucs2_t *a, const char *b, size_t len)
@@ -828,7 +828,7 @@ int strncmp_wa(const smb_ucs2_t *a, const char *b, size_t len)
b++;
n++;
}
- return (len - n)?(cp - UCS2_CHAR(*b)):0;
+ return (len - n)?(*(COPY_UCS2_CHAR(&cp,a)) - UCS2_CHAR(*b)):0;
}
smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p)
diff --git a/source/libads/authdata.c b/source/libads/authdata.c
index ccaf82124c6..2cc6c6ebae4 100644
--- a/source/libads/authdata.c
+++ b/source/libads/authdata.c
@@ -43,31 +43,31 @@ static DATA_BLOB unwrap_pac(DATA_BLOB *auth_data)
return pac_contents;
}
-static BOOL pac_io_unknown_type_10(const char *desc, UNKNOWN_TYPE_10 *type_10,
- prs_struct *ps, int depth)
+static BOOL pac_io_logon_name(const char *desc, PAC_LOGON_NAME *logon_name,
+ prs_struct *ps, int depth)
{
- if (NULL == type_10)
+ if (NULL == logon_name)
return False;
- prs_debug(ps, depth, desc, "pac_io_unknown_type_10");
+ prs_debug(ps, depth, desc, "pac_io_logon_name");
depth++;
- if (!smb_io_time("unknown_time", &type_10->unknown_time, ps, depth))
+ if (!smb_io_time("logon_time", &logon_name->logon_time, ps, depth))
return False;
- if (!prs_uint16("len", ps, depth, &type_10->len))
+ if (!prs_uint16("len", ps, depth, &logon_name->len))
return False;
- if (UNMARSHALLING(ps) && type_10->len) {
- type_10->username = PRS_ALLOC_MEM(ps, uint16, type_10->len);
- if (!type_10->username) {
+ if (UNMARSHALLING(ps) && logon_name->len) {
+ logon_name->username = PRS_ALLOC_MEM(ps, uint16, logon_name->len);
+ if (!logon_name->username) {
DEBUG(3, ("No memory available\n"));
return False;
}
}
- if (!prs_uint16s(True, "name", ps, depth, type_10->username,
- (type_10->len / sizeof(uint16))))
+ if (!prs_uint16s(True, "name", ps, depth, logon_name->username,
+ (logon_name->len / sizeof(uint16))))
return False;
return True;
@@ -499,15 +499,15 @@ static BOOL pac_io_pac_info_hdr_ctr(const char *desc, PAC_INFO_HDR *hdr,
return False;
break;
- case PAC_TYPE_UNKNOWN_10:
- DEBUG(5, ("PAC_TYPE_UNKNOWN_10\n"));
+ case PAC_TYPE_LOGON_NAME:
+ DEBUG(5, ("PAC_TYPE_LOGON_NAME\n"));
if (UNMARSHALLING(ps))
- hdr->ctr->pac.type_10 = PRS_ALLOC_MEM(ps, UNKNOWN_TYPE_10, 1);
- if (!hdr->ctr->pac.type_10) {
+ hdr->ctr->pac.logon_name = PRS_ALLOC_MEM(ps, PAC_LOGON_NAME, 1);
+ if (!hdr->ctr->pac.logon_name) {
DEBUG(3, ("No memory available\n"));
return False;
}
- if (!pac_io_unknown_type_10(desc, hdr->ctr->pac.type_10,
+ if (!pac_io_logon_name(desc, hdr->ctr->pac.logon_name,
ps, depth))
return False;
break;
diff --git a/source/libads/ldap_printer.c b/source/libads/ldap_printer.c
index 9773296ae08..f4ecbdd93ce 100644
--- a/source/libads/ldap_printer.c
+++ b/source/libads/ldap_printer.c
@@ -286,7 +286,7 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
return result;
}
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSDRIVER_KEY, NULL);
+ result = cli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSDRIVER_KEY, &dsdriver_ctr);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Unable to do enumdataex on %s, error is %s.\n",
@@ -300,7 +300,7 @@ WERROR get_remote_printer_publishing_data(struct cli_state *cli,
dsdriver_ctr.values[i]);
}
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSSPOOLER_KEY, NULL);
+ result = cli_spoolss_enumprinterdataex(cli, mem_ctx, &pol, SPOOL_DSSPOOLER_KEY, &dsspooler_ctr);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Unable to do enumdataex on %s, error is %s.\n",
diff --git a/source/libads/sasl.c b/source/libads/sasl.c
index 0164b0c7401..8fa62a5ade4 100644
--- a/source/libads/sasl.c
+++ b/source/libads/sasl.c
@@ -285,7 +285,7 @@ static ADS_STATUS ads_sasl_gssapi_bind(ADS_STRUCT *ads)
ENCTYPE_DES_CBC_MD5,
ENCTYPE_NULL};
gss_OID_desc nt_principal =
- {10, "\052\206\110\206\367\022\001\002\002\002"};
+ {10, CONST_DISCARD(char *, "\052\206\110\206\367\022\001\002\002\002")};
/* we need to fetch a service ticket as the ldap user in the
servers realm, regardless of our realm */
diff --git a/source/libsmb/credentials.c b/source/libsmb/credentials.c
index 0d521bae8ac..322b25ee43f 100644
--- a/source/libsmb/credentials.c
+++ b/source/libsmb/credentials.c
@@ -208,8 +208,36 @@ BOOL deal_with_creds(uchar sess_key[8],
DEBUG(5,("deal_with_creds: clnt_cred=%s\n", credstr(sto_clnt_cred->challenge.data)));
- /* store new seed in client credentials */
- SIVAL(sto_clnt_cred->challenge.data, 0, new_cred);
+ /* Bug #2953 - don't store new seed in client credentials
+ here, because we need to make sure we're moving forward first
+ */
return True;
}
+
+/*
+ stores new seed in client credentials
+ jmcd - Bug #2953 - moved this functionality out of deal_with_creds, because we're
+ not supposed to move to the next step in the chain if a nonexistent user tries to logon
+*/
+void reseed_client_creds(DOM_CRED *sto_clnt_cred, DOM_CRED *rcv_clnt_cred)
+{
+ UTIME new_clnt_time;
+ uint32 new_cred;
+
+ /* increment client time by one second */
+ new_clnt_time.time = rcv_clnt_cred->timestamp.time + 1;
+
+ /* first 4 bytes of the new seed is old client 4 bytes + clnt time + 1 */
+ new_cred = IVAL(sto_clnt_cred->challenge.data, 0);
+ new_cred += new_clnt_time.time;
+
+ DEBUG(5,("reseed_client_creds: new_cred[0]=%x\n", new_cred));
+ DEBUG(5,("reseed_client_creds: new_clnt_time=%x\n",
+ new_clnt_time.time));
+ DEBUG(5,("reseed_client_creds: clnt_cred=%s\n",
+ credstr(sto_clnt_cred->challenge.data)));
+
+ /* store new seed in client credentials */
+ SIVAL(sto_clnt_cred->challenge.data, 0, new_cred);
+}
diff --git a/source/nmbd/nmbd_workgroupdb.c b/source/nmbd/nmbd_workgroupdb.c
index 917116dd077..335d5220310 100644
--- a/source/nmbd/nmbd_workgroupdb.c
+++ b/source/nmbd/nmbd_workgroupdb.c
@@ -322,7 +322,7 @@ void expire_workgroups_and_servers(time_t t)
expire_servers(work, t);
if ((work->serverlist == NULL) && (work->death_time != PERMANENT_TTL) &&
- ((t == -1) || (work->death_time < t))) {
+ ((t == (time_t)-1) || (work->death_time < t))) {
DEBUG(3,("expire_workgroups_and_servers: Removing timed out workgroup %s\n",
work->work_group));
remove_workgroup_from_subnet(subrec, work);
diff --git a/source/passdb/pdb_pgsql.c b/source/passdb/pdb_pgsql.c
index e603bd6a536..fbafd70cb61 100644
--- a/source/passdb/pdb_pgsql.c
+++ b/source/passdb/pdb_pgsql.c
@@ -39,7 +39,7 @@ typedef struct pdb_pgsql_data {
const char *port ;
const char *user ;
const char *pass ;
-
+
const char *location ;
} pdb_pgsql_data ;
@@ -59,9 +59,10 @@ struct pdb_context *the_pdb_context;
DEBUG(0, ("invalid methods!\n")); \
return ; \
} \
- data = (struct pdb_pgsql_data *)methods->private_data;\
+ data = (struct pdb_pgsql_data *)methods->private_data; \
}
+
#define config_value( data, name, default_value ) \
lp_parm_const_string( GLOBAL_SECTION_SNUM, (data)->location, name, default_value )
diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c
index a7ba46cd511..f6e9e2306f5 100644
--- a/source/printing/nt_printing.c
+++ b/source/printing/nt_printing.c
@@ -2102,19 +2102,20 @@ static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr,
fstring *tddfs;
tddfs = SMB_REALLOC_ARRAY(driver.dependentfiles, fstring, i+2);
- if (tddfs == NULL) {
+ if ( !tddfs ) {
DEBUG(0,("get_a_printer_driver_3: failed to enlarge buffer!\n"));
break;
}
- else driver.dependentfiles = tddfs;
+ else
+ driver.dependentfiles = tddfs;
len += tdb_unpack(dbuf.dptr+len, dbuf.dsize-len, "f",
&driver.dependentfiles[i]);
i++;
}
- if (driver.dependentfiles != NULL)
- fstrcpy(driver.dependentfiles[i], "");
+ if ( driver.dependentfiles )
+ fstrcpy( driver.dependentfiles[i], "" );
SAFE_FREE(dbuf.dptr);
@@ -4944,6 +4945,7 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
{
int i = 0;
char *s;
+ pstring file;
connection_struct *conn;
DATA_BLOB null_pw;
NTSTATUS nt_status;
@@ -4985,45 +4987,50 @@ static BOOL delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct
if ( *info_3->driverpath ) {
if ( (s = strchr( &info_3->driverpath[1], '\\' )) != NULL ) {
- driver_unix_convert(s, conn, NULL, &bad_path, &st);
+ pstrcpy( file, s );
+ driver_unix_convert(file, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting driverfile [%s]\n", s));
- unlink_internals(conn, 0, s);
+ unlink_internals(conn, 0, file);
}
}
if ( *info_3->configfile ) {
if ( (s = strchr( &info_3->configfile[1], '\\' )) != NULL ) {
- driver_unix_convert(s, conn, NULL, &bad_path, &st);
+ pstrcpy( file, s );
+ driver_unix_convert(file, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting configfile [%s]\n", s));
- unlink_internals(conn, 0, s);
+ unlink_internals(conn, 0, file);
}
}
if ( *info_3->datafile ) {
if ( (s = strchr( &info_3->datafile[1], '\\' )) != NULL ) {
- driver_unix_convert(s, conn, NULL, &bad_path, &st);
+ pstrcpy( file, s );
+ driver_unix_convert(file, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting datafile [%s]\n", s));
- unlink_internals(conn, 0, s);
+ unlink_internals(conn, 0, file);
}
}
if ( *info_3->helpfile ) {
if ( (s = strchr( &info_3->helpfile[1], '\\' )) != NULL ) {
- driver_unix_convert(s, conn, NULL, &bad_path, &st);
+ pstrcpy( file, s );
+ driver_unix_convert(file, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting helpfile [%s]\n", s));
- unlink_internals(conn, 0, s);
+ unlink_internals(conn, 0, file);
}
}
/* check if we are done removing files */
if ( info_3->dependentfiles ) {
- while ( *info_3->dependentfiles[i] ) {
- char *file;
+ while ( info_3->dependentfiles[i][0] ) {
+ char *p;
/* bypass the "\print$" portion of the path */
- if ( (file = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL ) {
+ if ( (p = strchr( info_3->dependentfiles[i]+1, '\\' )) != NULL ) {
+ pstrcpy( file, p );
driver_unix_convert(file, conn, NULL, &bad_path, &st);
DEBUG(10,("deleting dependent file [%s]\n", file));
unlink_internals(conn, 0, file );
diff --git a/source/registry/reg_db.c b/source/registry/reg_db.c
index 6e3a989972f..77525e884f0 100644
--- a/source/registry/reg_db.c
+++ b/source/registry/reg_db.c
@@ -45,12 +45,16 @@ static const char *builtin_registry_paths[] = {
KEY_PRINTING,
KEY_SHARES,
KEY_EVENTLOG,
+ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib",
+ "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009",
"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
"HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
"HKLM\\SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
"HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters",
"HKU",
"HKCR",
+ "HKPD",
+ "HKPT",
NULL };
struct builtin_regkey_value {
@@ -64,12 +68,14 @@ struct builtin_regkey_value {
};
static struct builtin_regkey_value builtin_registry_values[] = {
- { "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
- "SystemRoot", REG_SZ, { "c:\\Windows" } },
- { "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports",
+ { KEY_PRINTING_PORTS,
SAMBA_PRINTER_PORT_NAME, REG_SZ, { "" } },
- { "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers",
+ { KEY_PRINTING_2K,
"DefaultSpoolDirectory", REG_SZ, { "C:\\Windows\\System32\\Spool\\Printers" } },
+ { KEY_EVENTLOG,
+ "DisplayName", REG_SZ, { "Event Log" } },
+ { KEY_EVENTLOG,
+ "ErrorControl", REG_DWORD, { (char*)0x00000001 } },
{ NULL, NULL, 0, { NULL } }
};
diff --git a/source/registry/reg_objects.c b/source/registry/reg_objects.c
index d6482e698b0..b5753fc6885 100644
--- a/source/registry/reg_objects.c
+++ b/source/registry/reg_objects.c
@@ -194,13 +194,18 @@ REGISTRY_VALUE* dup_registry_value( REGISTRY_VALUE *val )
/* copy all the non-pointer initial data */
memcpy( copy, val, sizeof(REGISTRY_VALUE) );
- if ( val->data_p )
+
+ copy->size = 0;
+ copy->data_p = NULL;
+
+ if ( val->data_p && val->size )
{
if ( !(copy->data_p = memdup( val->data_p, val->size )) ) {
DEBUG(0,("dup_registry_value: memdup() failed for [%d] bytes!\n",
val->size));
SAFE_FREE( copy );
}
+ copy->size = val->size;
}
return copy;
diff --git a/source/rpc_client/cli_spoolss.c b/source/rpc_client/cli_spoolss.c
index f2df763b4fe..4e57b763e26 100644
--- a/source/rpc_client/cli_spoolss.c
+++ b/source/rpc_client/cli_spoolss.c
@@ -1586,9 +1586,11 @@ WERROR cli_spoolss_enumprinterdata(struct cli_state *cli, TALLOC_CTX *mem_ctx,
spoolss_io_q_enumprinterdata,
spoolss_io_r_enumprinterdata,
WERR_GENERAL_FAILURE );
-
- *value_needed = out.realvaluesize;
- *data_needed = out.realdatasize;
+
+ if ( value_needed )
+ *value_needed = out.realvaluesize;
+ if ( data_needed )
+ *data_needed = out.realdatasize;
if (!W_ERROR_IS_OK(out.status))
return out.status;
diff --git a/source/rpc_parse/parse_net.c b/source/rpc_parse/parse_net.c
index ed95656fdae..a92f16d6485 100644
--- a/source/rpc_parse/parse_net.c
+++ b/source/rpc_parse/parse_net.c
@@ -792,7 +792,7 @@ BOOL net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth)
void init_q_auth_2(NET_Q_AUTH_2 *q_a,
const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name,
- DOM_CHAL *clnt_chal, uint32 clnt_flgs)
+ const DOM_CHAL *clnt_chal, uint32 clnt_flgs)
{
DEBUG(5,("init_q_auth_2: %d\n", __LINE__));
diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c
index 2663b093812..2677a4a2df0 100644
--- a/source/rpc_parse/parse_spoolss.c
+++ b/source/rpc_parse/parse_spoolss.c
@@ -631,6 +631,8 @@ BOOL spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE
int available_space; /* size of the device mode left to parse */
/* only important on unmarshalling */
int i = 0;
+ uint16 *unistr_buffer;
+ int j;
struct optional_fields {
fstring name;
@@ -662,12 +664,20 @@ BOOL spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE
depth++;
if (UNMARSHALLING(ps)) {
- devmode->devicename.buffer = PRS_ALLOC_MEM(ps, uint16, 32);
+ devmode->devicename.buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
if (devmode->devicename.buffer == NULL)
return False;
+ unistr_buffer = devmode->devicename.buffer;
}
-
- if (!prs_uint16uni(True,"devicename", ps, depth, devmode->devicename.buffer, MAXDEVICENAME))
+ else {
+ /* devicename is a static sized string but the buffer we set is not */
+ unistr_buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
+ memset( unistr_buffer, 0x0, MAXDEVICENAME );
+ for ( j=0; devmode->devicename.buffer[j]; j++ )
+ unistr_buffer[j] = devmode->devicename.buffer[j];
+ }
+
+ if (!prs_uint16uni(True,"devicename", ps, depth, unistr_buffer, MAXDEVICENAME))
return False;
if (!prs_uint16("specversion", ps, depth, &devmode->specversion))
@@ -709,12 +719,20 @@ BOOL spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE
return False;
if (UNMARSHALLING(ps)) {
- devmode->formname.buffer = PRS_ALLOC_MEM(ps, uint16, 32);
+ devmode->formname.buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
if (devmode->formname.buffer == NULL)
return False;
+ unistr_buffer = devmode->formname.buffer;
}
-
- if (!prs_uint16uni(True, "formname", ps, depth, devmode->formname.buffer, 32))
+ else {
+ /* devicename is a static sized string but the buffer we set is not */
+ unistr_buffer = PRS_ALLOC_MEM(ps, uint16, MAXDEVICENAME);
+ memset( unistr_buffer, 0x0, MAXDEVICENAME );
+ for ( j=0; devmode->formname.buffer[j]; j++ )
+ unistr_buffer[j] = devmode->formname.buffer[j];
+ }
+
+ if (!prs_uint16uni(True, "formname", ps, depth, unistr_buffer, MAXDEVICENAME))
return False;
if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels))
return False;
diff --git a/source/rpc_parse/parse_svcctl.c b/source/rpc_parse/parse_svcctl.c
index 85889d58890..b86ca23df15 100644
--- a/source/rpc_parse/parse_svcctl.c
+++ b/source/rpc_parse/parse_svcctl.c
@@ -714,7 +714,7 @@ BOOL svcctl_io_q_query_service_config2(const char *desc, SVCCTL_Q_QUERY_SERVICE_
void init_service_description_buffer(RPC_DATA_BLOB *str, const char *service_desc, int blob_length)
{
uint32 offset;
- char *bp;
+ uint8 *bp;
ZERO_STRUCTP(str);
@@ -808,8 +808,10 @@ BOOL svcctl_io_r_query_service_config2(const char *desc, SVCCTL_R_QUERY_SERVICE_
if (r_u->returned > 4) {
if (!prs_uint32("offset", ps, depth, &r_u->offset))
return False;
- if(!prs_unistr2(True, "description ", ps, depth, r_u->description))
+
+ if ( !prs_pointer( desc, ps, depth, (void**)&r_u->description, sizeof(UNISTR2), (PRS_POINTER_CAST)prs_io_unistr2 ) )
return False;
+
if(!prs_align(ps))
return False;
} else {
diff --git a/source/rpc_server/srv_dfs_nt.c b/source/rpc_server/srv_dfs_nt.c
index 938b01540f4..f61348ee05d 100644
--- a/source/rpc_server/srv_dfs_nt.c
+++ b/source/rpc_server/srv_dfs_nt.c
@@ -69,7 +69,7 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u)
pstrcat(altpath, sharename);
/* The following call can change the cwd. */
- if(get_referred_path(dfspath, &jn, NULL, NULL)) {
+ if(get_referred_path(p->mem_ctx, dfspath, &jn, NULL, NULL)) {
exists = True;
jn.referral_count += 1;
old_referral_list = jn.referral_list;
@@ -87,7 +87,6 @@ WERROR _dfs_add(pipes_struct *p, DFS_Q_DFS_ADD* q_u, DFS_R_DFS_ADD *r_u)
if(old_referral_list) {
memcpy(jn.referral_list, old_referral_list, sizeof(struct referral)*jn.referral_count-1);
- SAFE_FREE(old_referral_list);
}
jn.referral_list[jn.referral_count-1].proximity = 0;
@@ -140,7 +139,7 @@ WERROR _dfs_remove(pipes_struct *p, DFS_Q_DFS_REMOVE *q_u,
DEBUG(5,("init_reply_dfs_remove: Request to remove %s -> %s\\%s.\n",
dfspath, servername, sharename));
- if(!get_referred_path(dfspath, &jn, NULL, NULL)) {
+ if(!get_referred_path(p->mem_ctx, dfspath, &jn, NULL, NULL)) {
return WERR_DFS_NO_SUCH_VOL;
}
@@ -319,7 +318,7 @@ WERROR _dfs_enum(pipes_struct *p, DFS_Q_DFS_ENUM *q_u, DFS_R_DFS_ENUM *r_u)
struct junction_map jn[MAX_MSDFS_JUNCTIONS];
int num_jn = 0;
- num_jn = enum_msdfs_links(jn, ARRAY_SIZE(jn));
+ num_jn = enum_msdfs_links(p->mem_ctx, jn, ARRAY_SIZE(jn));
vfs_ChDir(p->conn,p->conn->connectpath);
DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n", num_jn, level));
@@ -358,7 +357,7 @@ WERROR _dfs_get_info(pipes_struct *p, DFS_Q_DFS_GET_INFO *q_u,
return WERR_DFS_NO_SUCH_SERVER;
/* The following call can change the cwd. */
- if(!get_referred_path(path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(path)) {
+ if(!get_referred_path(p->mem_ctx, path, &jn, &consumedcnt, NULL) || consumedcnt < strlen(path)) {
vfs_ChDir(p->conn,p->conn->connectpath);
return WERR_DFS_NO_SUCH_VOL;
}
diff --git a/source/rpc_server/srv_netlog_nt.c b/source/rpc_server/srv_netlog_nt.c
index 7880a724b5c..0af8b14fe21 100644
--- a/source/rpc_server/srv_netlog_nt.c
+++ b/source/rpc_server/srv_netlog_nt.c
@@ -449,6 +449,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->clnt_id.cred, &srv_cred)))
return NT_STATUS_INVALID_HANDLE;
+ reseed_client_creds(&p->dc.clnt_cred, &q_u->clnt_id.cred);
memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred));
DEBUG(5,("_net_srv_pwset: %d\n", __LINE__));
@@ -545,6 +546,8 @@ NTSTATUS _net_sam_logoff(pipes_struct *p, NET_Q_SAM_LOGOFF *q_u, NET_R_SAM_LOGOF
&q_u->sam_id.client.cred, &srv_cred)))
return NT_STATUS_INVALID_HANDLE;
+ /* what happens if we get a logoff for an unknown user? */
+ reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred);
memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred));
/* XXXX maybe we want to say 'no', reject the client's credentials */
@@ -603,11 +606,6 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *
if (!(p->dc.authenticated && deal_with_creds(p->dc.sess_key, &p->dc.clnt_cred, &q_u->sam_id.client.cred, &srv_cred)))
return NT_STATUS_INVALID_HANDLE;
- memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred));
-
- r_u->buffer_creds = 1; /* yes, we have valid server credentials */
- memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds));
-
/* find the username */
switch (q_u->sam_id.logon_level) {
@@ -719,6 +717,15 @@ NTSTATUS _net_sam_logon(pipes_struct *p, NET_Q_SAM_LOGON *q_u, NET_R_SAM_LOGON *
return status;
}
+ /* moved from right after deal_with_creds above, since we weren't
+ supposed to update unless logon was successful */
+
+ reseed_client_creds(&p->dc.clnt_cred, &q_u->sam_id.client.cred);
+ memcpy(&p->dc.srv_cred, &p->dc.clnt_cred, sizeof(p->dc.clnt_cred));
+
+ r_u->buffer_creds = 1; /* yes, we have valid server credentials */
+ memcpy(&r_u->srv_creds, &srv_cred, sizeof(r_u->srv_creds));
+
if (server_info->guest) {
/* We don't like guest domain logons... */
DEBUG(5,("_net_sam_logon: Attempted domain logon as GUEST denied.\n"));
diff --git a/source/rpc_server/srv_reg_nt.c b/source/rpc_server/srv_reg_nt.c
index db199634c50..feb89be5424 100644
--- a/source/rpc_server/srv_reg_nt.c
+++ b/source/rpc_server/srv_reg_nt.c
@@ -393,8 +393,6 @@ WERROR _reg_open_entry(pipes_struct *p, REG_Q_OPEN_ENTRY *q_u, REG_R_OPEN_ENTRY
uint32 access_granted;
WERROR result;
- DEBUG(5,("reg_open_entry: Enter\n"));
-
if ( !parent )
return WERR_BADFID;
@@ -440,8 +438,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL
REGVAL_CTR regvals;
int i;
- DEBUG(5,("_reg_info: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
@@ -470,8 +466,6 @@ WERROR _reg_query_value(pipes_struct *p, REG_Q_QUERY_VALUE *q_u, REG_R_QUERY_VAL
regval_ctr_destroy( &regvals );
free_registry_value( val );
- DEBUG(5,("_reg_info: Exit\n"));
-
return status;
}
@@ -485,8 +479,6 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_
WERROR status = WERR_OK;
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
- DEBUG(5,("_reg_query_key: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
@@ -508,8 +500,6 @@ WERROR _reg_query_key(pipes_struct *p, REG_Q_QUERY_KEY *q_u, REG_R_QUERY_KEY *r_
ZERO_STRUCT(r_u->mod_time);
- DEBUG(5,("_reg_query_key: Exit\n"));
-
return status;
}
@@ -523,15 +513,11 @@ WERROR _reg_getversion(pipes_struct *p, REG_Q_GETVERSION *q_u, REG_R_GETVERSION
WERROR status = WERR_OK;
REGISTRY_KEY *regkey = find_regkey_index_by_hnd( p, &q_u->pol );
- DEBUG(5,("_reg_getversion: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
r_u->win_version = 0x00000005; /* Windows 2000 registry API version */
- DEBUG(5,("_reg_getversion: Exit\n"));
-
return status;
}
@@ -547,8 +533,6 @@ WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u)
char *subkey = NULL;
- DEBUG(5,("_reg_enum_key: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
@@ -566,8 +550,6 @@ WERROR _reg_enum_key(pipes_struct *p, REG_Q_ENUM_KEY *q_u, REG_R_ENUM_KEY *r_u)
init_reg_r_enum_key( r_u, subkey );
- DEBUG(5,("_reg_enum_key: Exit\n"));
-
done:
SAFE_FREE( subkey );
return status;
@@ -584,12 +566,10 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE
REGISTRY_VALUE *val;
- DEBUG(5,("_reg_enum_value: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
- DEBUG(8,("_reg_enum_key: enumerating values for key [%s]\n", regkey->name));
+ DEBUG(8,("_reg_enum_value: enumerating values for key [%s]\n", regkey->name));
if ( !fetch_reg_values_specific( regkey, &val, q_u->val_index ) ) {
status = WERR_NO_MORE_ITEMS;
@@ -602,9 +582,6 @@ WERROR _reg_enum_value(pipes_struct *p, REG_Q_ENUM_VALUE *q_u, REG_R_ENUM_VALUE
init_reg_r_enum_val( r_u, val );
-
- DEBUG(5,("_reg_enum_value: Exit\n"));
-
done:
free_registry_value( val );
@@ -900,8 +877,6 @@ WERROR _reg_restore_key(pipes_struct *p, REG_Q_RESTORE_KEY *q_u, REG_R_RESTORE_
pstring filename;
int snum;
- DEBUG(5,("_reg_restore_key: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
@@ -1079,8 +1054,6 @@ WERROR _reg_save_key(pipes_struct *p, REG_Q_SAVE_KEY *q_u, REG_R_SAVE_KEY *r_u)
pstring filename;
int snum;
- DEBUG(5,("_reg_save_key: Enter\n"));
-
if ( !regkey )
return WERR_BADFID;
diff --git a/source/rpc_server/srv_samr_nt.c b/source/rpc_server/srv_samr_nt.c
index 2e73db28070..1eb4b1236d0 100644
--- a/source/rpc_server/srv_samr_nt.c
+++ b/source/rpc_server/srv_samr_nt.c
@@ -808,7 +808,7 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
struct samr_displayentry *entries = NULL;
DEBUG(5, ("samr_reply_query_dispinfo: %d\n", __LINE__));
- r_u->status = NT_STATUS_OK;
+ r_u->status = NT_STATUS_UNSUCCESSFUL;
/* find the policy handle. open a policy on it. */
if (!find_policy_by_hnd(p, &q_u->domain_pol, (void **)&info))
@@ -951,8 +951,10 @@ NTSTATUS _samr_query_dispinfo(pipes_struct *p, SAMR_Q_QUERY_DISPINFO *q_u,
/* calculate the total size */
total_data_size=num_account*struct_size;
- if (enum_context+max_entries < num_account)
+ if (num_account)
r_u->status = STATUS_MORE_ENTRIES;
+ else
+ r_u->status = NT_STATUS_OK;
DEBUG(5, ("_samr_query_dispinfo: %d\n", __LINE__));
@@ -1227,7 +1229,7 @@ static BOOL make_samr_lookup_rids(TALLOC_CTX *ctx, uint32 num_names,
}
for (i = 0; i < num_names; i++) {
- DEBUG(10, ("names[%d]:%s\n", i, *names[i] ? names[i] : ""));
+ DEBUG(10, ("names[%d]:%s\n", i, names[i] && *names[i] ? names[i] : ""));
init_unistr2(&uni_name[i], names[i], UNI_FLAGS_NONE);
init_uni_hdr(&hdr_name[i], &uni_name[i]);
}
diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c
index 7498a449c3b..692dacf1599 100644
--- a/source/rpc_server/srv_spoolss_nt.c
+++ b/source/rpc_server/srv_spoolss_nt.c
@@ -1488,19 +1488,23 @@ static void copy_printer_default(TALLOC_CTX *ctx, PRINTER_DEFAULT *new_def, PRIN
* SPOOL_Q_OPEN_PRINTER_EX structure
********************************************************************/
-static void convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX *q_u_ex, SPOOL_Q_OPEN_PRINTER *q_u)
+static WERROR convert_to_openprinterex(TALLOC_CTX *ctx, SPOOL_Q_OPEN_PRINTER_EX *q_u_ex, SPOOL_Q_OPEN_PRINTER *q_u)
{
if (!q_u_ex || !q_u)
- return;
+ return WERR_OK;
DEBUG(8,("convert_to_openprinterex\n"));
if ( q_u->printername ) {
- q_u_ex->printername = TALLOC_P( ctx, UNISTR2 );
+ q_u_ex->printername = TALLOC_ZERO_P( ctx, UNISTR2 );
+ if (q_u_ex->printername == NULL)
+ return WERR_NOMEM;
copy_unistr2(q_u_ex->printername, q_u->printername);
}
copy_printer_default(ctx, &q_u_ex->printer_default, &q_u->printer_default);
+
+ return WERR_OK;
}
/********************************************************************
@@ -1522,7 +1526,9 @@ WERROR _spoolss_open_printer(pipes_struct *p, SPOOL_Q_OPEN_PRINTER *q_u, SPOOL_R
/* convert the OpenPrinter() call to OpenPrinterEx() */
- convert_to_openprinterex(p->mem_ctx, &q_u_ex, q_u);
+ r_u_ex.status = convert_to_openprinterex(p->mem_ctx, &q_u_ex, q_u);
+ if (!W_ERROR_IS_OK(r_u_ex.status))
+ return r_u_ex.status;
r_u_ex.status = _spoolss_open_printer_ex(p, &q_u_ex, &r_u_ex);
@@ -2283,7 +2289,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "W3SvcInstalled")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC_ZERO(ctx, 4*sizeof(uint8) )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
*needed = 0x4;
return WERR_OK;
@@ -2291,7 +2297,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "BeepEnabled")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC(ctx, 4*sizeof(uint8) )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
SIVAL(*data, 0, 0x00);
*needed = 0x4;
@@ -2300,7 +2306,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "EventLog")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
/* formally was 0x1b */
SIVAL(*data, 0, 0x0);
@@ -2310,7 +2316,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "NetPopup")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
SIVAL(*data, 0, 0x00);
*needed = 0x4;
@@ -2319,7 +2325,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "MajorVersion")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
/* Windows NT 4.0 seems to not allow uploading of drivers
@@ -2338,7 +2344,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "MinorVersion")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
SIVAL(*data, 0, 0);
*needed = 0x4;
@@ -2356,7 +2362,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
*type = REG_BINARY;
*needed = 0x114;
- if ( !(*data = TALLOC_ZERO_ARRAY(ctx, uint8, *needed)) )
+ if ( !(*data = TALLOC_ZERO_ARRAY(ctx, uint8, (*needed > in_size) ? *needed:in_size )) )
return WERR_NOMEM;
SIVAL(*data, 0, *needed); /* size */
@@ -2402,7 +2408,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *ctx, fstring value, uint
if (!StrCaseCmp(value, "DsPresent")) {
*type = REG_DWORD;
- if((*data = (uint8 *)TALLOC(ctx, 4 )) == NULL)
+ if ( !(*data = TALLOC_ARRAY(ctx, uint8, sizeof(uint32) )) )
return WERR_NOMEM;
/* only show the publish check box if we are a
diff --git a/source/rpc_server/srv_svcctl_nt.c b/source/rpc_server/srv_svcctl_nt.c
index 3d345563409..6cdc71bf033 100644
--- a/source/rpc_server/srv_svcctl_nt.c
+++ b/source/rpc_server/srv_svcctl_nt.c
@@ -253,7 +253,6 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_
uint32 access_granted = 0;
NTSTATUS status;
pstring service;
- SERVICE_INFO *scm_info;
rpcstr_pull(service, q_u->servicename.buffer, sizeof(service), q_u->servicename.uni_str_len*2, 0);
@@ -262,7 +261,7 @@ WERROR _svcctl_open_service(pipes_struct *p, SVCCTL_Q_OPEN_SERVICE *q_u, SVCCTL_
/* based on my tests you can open a service if you have a valid scm handle */
- if ( !(scm_info = find_service_info_by_hnd( p, &q_u->handle )) )
+ if ( !find_service_info_by_hnd( p, &q_u->handle ) )
return WERR_BADFID;
/* perform access checks */
@@ -350,7 +349,7 @@ WERROR _svcctl_query_status(pipes_struct *p, SVCCTL_Q_QUERY_STATUS *q_u, SVCCTL_
we have to call the right status routine...
**********************************************************************/
-static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, int *added)
+static WERROR enum_internal_services(TALLOC_CTX *ctx,ENUM_SERVICES_STATUS **svc_ptr, int existing_services, uint32 *added)
{
int num_services = 2;
int i = 0;
@@ -361,24 +360,23 @@ static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_
services = *svc_ptr;
-#if 0
- /* *svc_ptr has the pointer to the array if there is one already. NULL if not. */
- if ((existing_services>0) && svc_ptr && *svc_ptr) { /* reallocate vs. allocate */
- DEBUG(8,("enum_internal_services: REALLOCing %d services\n", num_services));
- services = TALLOC_REALLOC_ARRAY(tcx,*svc_ptr,ENUM_SERVICES_STATUS,existing_services+num_services);
- if (!rsvcs)
+ if ( (existing_services > 0) && svc_ptr && *svc_ptr ) {
+ ENUM_SERVICES_STATUS *tmp_services = NULL;
+ uint32 total_svc = existing_services + num_services;
+
+ if ( !(tmp_services = TALLOC_REALLOC_ARRAY( ctx, services, ENUM_SERVICES_STATUS, total_svc )) )
return WERR_NOMEM;
- *svc_ptr = services;
- } else {
- if ( !(services = TALLOC_ARRAY( tcx, ENUM_SERVICES_STATUS, num_services )) )
+
+ services = tmp_services;
+ i += existing_services;
+ }
+ else {
+ if ( !(services = TALLOC_ARRAY( ctx, ENUM_SERVICES_STATUS, num_services )) )
return WERR_NOMEM;
}
-#endif
- if (existing_services > 0) {
- i += existing_services;
- }
- DEBUG(8,("enum_internal_services: Creating %d services, starting index %d\n", num_services,existing_services));
+ DEBUG(8,("enum_internal_services: Creating %d services, starting index %d\n",
+ num_services, existing_services));
init_unistr( &services[i].servicename, "Spooler" );
init_unistr( &services[i].displayname, "Print Spooler" );
@@ -410,7 +408,8 @@ static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_
else
services[i].status.state = SVCCTL_STOPPED;
- *added = num_services;
+ *added = num_services;
+ *svc_ptr = services;
return WERR_OK;
}
@@ -421,12 +420,10 @@ static WERROR enum_internal_services(TALLOC_CTX *tcx,ENUM_SERVICES_STATUS **svc_
WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STATUS *q_u, SVCCTL_R_ENUM_SERVICES_STATUS *r_u)
{
ENUM_SERVICES_STATUS *services = NULL;
- uint32 num_int_services = 0;
- uint32 num_ext_services = 0;
+ uint32 num_int_services, num_ext_services, total_services;
int i = 0;
- size_t buffer_size;
+ size_t buffer_size = 0;
WERROR result = WERR_OK;
- WERROR ext_result = WERR_OK;
SERVICE_INFO *info = find_service_info_by_hnd( p, &q_u->handle );
/* perform access checks */
@@ -437,48 +434,38 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT
if ( !(info->access_granted & SC_RIGHT_MGR_ENUMERATE_SERVICE) )
return WERR_ACCESS_DENIED;
+ num_int_services = 0;
+ num_ext_services = 0;
+
/* num_services = str_list_count( lp_enable_svcctl() ); */
/* here's where we'll read the db of external services */
/* _svcctl_read_LSB_data(NULL,NULL); */
/* init_svcctl_db(); */
- num_int_services = 0;
-
- /* num_int_services = num_internal_services(); */
-
- /* num_ext_services = num_external_services(); */
-
if ( !(services = TALLOC_ARRAY(p->mem_ctx, ENUM_SERVICES_STATUS, num_int_services+num_ext_services )) )
- return WERR_NOMEM;
-
- result = enum_internal_services(p->mem_ctx, &services, 0, &num_int_services);
+ return WERR_NOMEM;
- if (W_ERROR_IS_OK(result)) {
+ if ( W_ERROR_IS_OK(enum_internal_services(p->mem_ctx, &services, 0, &num_int_services)) )
DEBUG(8,("_svcctl_enum_services_status: Got %d internal services\n", num_int_services));
- }
-
- /* ext_result=enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services); */
- if (W_ERROR_IS_OK(ext_result)) {
+#if 0
+ if ( W_ERROR_IS_OK(enum_external_services(p->mem_ctx, &services, num_int_services, &num_ext_services)) )
DEBUG(8,("_svcctl_enum_services_status: Got %d external services\n", num_ext_services));
- }
+#endif
+
+ total_services = num_int_services + num_ext_services;
- DEBUG(8,("_svcctl_enum_services_status: total of %d services\n", num_int_services+num_ext_services));
+ DEBUG(8,("_svcctl_enum_services_status: total of %d services\n", total_services ));
- buffer_size = 0;
- for (i=0;i<num_int_services+num_ext_services;i++) {
- buffer_size += svcctl_sizeof_enum_services_status(&services[i]);
+ for ( i=0; i<total_services; i++ ) {
+ buffer_size += svcctl_sizeof_enum_services_status(&services[i]);
}
- /* */
buffer_size += buffer_size % 4;
- DEBUG(8,("_svcctl_enum_services_status: buffer size passed %d, we need %d\n",
- q_u->buffer_size, buffer_size));
if (buffer_size > q_u->buffer_size ) {
- num_int_services = 0;
- num_ext_services = 0;
+ total_services = 0;
result = WERR_MORE_DATA;
}
@@ -490,7 +477,7 @@ WERROR _svcctl_enum_services_status(pipes_struct *p, SVCCTL_Q_ENUM_SERVICES_STAT
}
r_u->needed = (buffer_size > q_u->buffer_size) ? buffer_size : q_u->buffer_size;
- r_u->returned = num_int_services+num_ext_services;
+ r_u->returned = total_services;
if ( !(r_u->resume = TALLOC_P( p->mem_ctx, uint32 )) )
return WERR_NOMEM;
diff --git a/source/rpcclient/cmd_samr.c b/source/rpcclient/cmd_samr.c
index bd150f2a353..acb39271050 100644
--- a/source/rpcclient/cmd_samr.c
+++ b/source/rpcclient/cmd_samr.c
@@ -1095,7 +1095,7 @@ static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli,
}
- while(1) {
+ do {
if (!got_params)
get_query_dispinfo_params(
@@ -1108,7 +1108,7 @@ static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli,
loop_count++;
- if (!NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
+ if (NT_STATUS_IS_ERR(result))
break;
if (num_entries == 0)
@@ -1133,7 +1133,7 @@ static NTSTATUS cmd_samr_query_dispinfo(struct cli_state *cli,
break;
}
}
- }
+ } while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
done:
return result;
diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c
index f774d408fe6..864722ffdc9 100644
--- a/source/rpcclient/cmd_spoolss.c
+++ b/source/rpcclient/cmd_spoolss.c
@@ -2233,8 +2233,7 @@ static WERROR cmd_spoolss_enum_data_ex( struct cli_state *cli,
/* Enumerate subkeys */
- result = cli_spoolss_enumprinterdataex(
- cli, mem_ctx, &hnd, keyname, NULL);
+ result = cli_spoolss_enumprinterdataex(cli, mem_ctx, &hnd, keyname, &ctr);
if (!W_ERROR_IS_OK(result))
goto done;
@@ -2297,7 +2296,7 @@ static WERROR cmd_spoolss_enum_printerkey( struct cli_state *cli,
/* Enumerate subkeys */
- result = cli_spoolss_enumprinterkey(cli, mem_ctx, &hnd, keyname, NULL, NULL);
+ result = cli_spoolss_enumprinterkey(cli, mem_ctx, &hnd, keyname, &keylist, NULL);
if (!W_ERROR_IS_OK(result))
goto done;
diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c
index feaeae4da68..3112db19ad9 100644
--- a/source/rpcclient/rpcclient.c
+++ b/source/rpcclient/rpcclient.c
@@ -667,11 +667,6 @@ out_free:
if (!interactive)
reopen_logs();
- /* Load smb.conf file */
-
- if (!lp_load(dyn_CONFIGFILE,True,False,False))
- fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
-
/* Parse options */
pc = poptGetContext("rpcclient", argc, (const char **) argv,
@@ -711,6 +706,11 @@ out_free:
if (!init_names())
return 1;
+ /* Load smb.conf file */
+
+ if (!lp_load(dyn_CONFIGFILE,True,False,False))
+ fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
+
/*
* Get password
* from stdin if necessary
diff --git a/source/script/mkversion.sh b/source/script/mkversion.sh
index d9d84a5337b..9d919cfe34b 100755
--- a/source/script/mkversion.sh
+++ b/source/script/mkversion.sh
@@ -18,6 +18,8 @@ SAMBA_VERSION_MAJOR=`sed -n 's/^SAMBA_VERSION_MAJOR=//p' $SOURCE_DIR$VERSION_FIL
SAMBA_VERSION_MINOR=`sed -n 's/^SAMBA_VERSION_MINOR=//p' $SOURCE_DIR$VERSION_FILE`
SAMBA_VERSION_RELEASE=`sed -n 's/^SAMBA_VERSION_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
+SAMBA_VERSION_REVISION=`sed -n 's/^SAMBA_VERSION_REVISION=//p' $SOURCE_DIR$VERSION_FILE`
+
SAMBA_VERSION_PRE_RELEASE=`sed -n 's/^SAMBA_VERSION_PRE_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
SAMBA_VERSION_RC_RELEASE=`sed -n 's/^SAMBA_VERSION_RC_RELEASE=//p' $SOURCE_DIR$VERSION_FILE`
@@ -36,7 +38,10 @@ echo "#define SAMBA_VERSION_RELEASE ${SAMBA_VERSION_RELEASE}" >> $OUTPUT_FILE
SAMBA_VERSION_STRING="${SAMBA_VERSION_MAJOR}.${SAMBA_VERSION_MINOR}.${SAMBA_VERSION_RELEASE}"
-if test -n "${SAMBA_VERSION_PRE_RELEASE}";then
+if test -n "${SAMBA_VERSION_REVISION}";then
+ SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}${SAMBA_VERSION_REVISION}"
+ echo "#define SAMBA_VERSION_REVISION \"${SAMBA_VERSION_REVISION}\"" >> $OUTPUT_FILE
+elif test -n "${SAMBA_VERSION_PRE_RELEASE}";then
SAMBA_VERSION_STRING="${SAMBA_VERSION_STRING}pre${SAMBA_VERSION_PRE_RELEASE}"
echo "#define SAMBA_VERSION_PRE_RELEASE ${SAMBA_VERSION_PRE_RELEASE}" >> $OUTPUT_FILE
elif test -n "${SAMBA_VERSION_RC_RELEASE}";then
diff --git a/source/smbd/conn.c b/source/smbd/conn.c
index 534a3367d48..b69868ecec1 100644
--- a/source/smbd/conn.c
+++ b/source/smbd/conn.c
@@ -225,10 +225,10 @@ void conn_clear_vuid_cache(uint16 vuid)
}
/****************************************************************************
- Free a conn structure.
+ Free a conn structure - internal part.
****************************************************************************/
-void conn_free(connection_struct *conn)
+void conn_free_internal(connection_struct *conn)
{
vfs_handle_struct *handle = NULL, *thandle = NULL;
TALLOC_CTX *mem_ctx = NULL;
@@ -243,8 +243,6 @@ void conn_free(connection_struct *conn)
handle = thandle;
}
- DLIST_REMOVE(Connections, conn);
-
if (conn->ngroups && conn->groups) {
SAFE_FREE(conn->groups);
conn->ngroups = 0;
@@ -264,15 +262,25 @@ void conn_free(connection_struct *conn)
string_free(&conn->connectpath);
string_free(&conn->origpath);
- bitmap_clear(bmap, conn->cnum);
- num_open--;
-
mem_ctx = conn->mem_ctx;
ZERO_STRUCTP(conn);
talloc_destroy(mem_ctx);
}
+/****************************************************************************
+ Free a conn structure.
+****************************************************************************/
+
+void conn_free(connection_struct *conn)
+{
+ DLIST_REMOVE(Connections, conn);
+ bitmap_clear(bmap, conn->cnum);
+ num_open--;
+
+ conn_free_internal(conn);
+}
+
/****************************************************************************
receive a smbcontrol message to forcibly unmount a share
the message contains just a share name and all instances of that
diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c
index d0438b01af1..2b13e2a4b5a 100644
--- a/source/smbd/msdfs.c
+++ b/source/smbd/msdfs.c
@@ -30,10 +30,10 @@ extern uint32 global_client_caps;
into the dfs_path structure
**********************************************************************/
-static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
+static BOOL parse_dfs_path(char *pathname, struct dfs_path *pdp)
{
pstring pathname_local;
- char* p,*temp;
+ char *p, *temp;
pstrcpy(pathname_local,pathname);
p = temp = pathname_local;
@@ -46,8 +46,9 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
/* now tokenize */
/* parse out hostname */
p = strchr_m(temp,'\\');
- if(p == NULL)
+ if(p == NULL) {
return False;
+ }
*p = '\0';
pstrcpy(pdp->hostname,temp);
DEBUG(10,("parse_dfs_path: hostname: %s\n",pdp->hostname));
@@ -76,10 +77,10 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
into the dfs_path structure
**********************************************************************/
-static BOOL parse_processed_dfs_path(char* pathname, struct dfs_path* pdp, BOOL allow_wcards)
+static BOOL parse_processed_dfs_path(char* pathname, struct dfs_path *pdp, BOOL allow_wcards)
{
pstring pathname_local;
- char* p,*temp;
+ char *p,*temp;
pstrcpy(pathname_local,pathname);
p = temp = pathname_local;
@@ -92,8 +93,9 @@ static BOOL parse_processed_dfs_path(char* pathname, struct dfs_path* pdp, BOOL
/* now tokenize */
/* parse out hostname */
p = strchr_m(temp,'/');
- if(p == NULL)
+ if(p == NULL) {
return False;
+ }
*p = '\0';
pstrcpy(pdp->hostname,temp);
DEBUG(10,("parse_processed_dfs_path: hostname: %s\n",pdp->hostname));
@@ -126,12 +128,15 @@ static BOOL parse_processed_dfs_path(char* pathname, struct dfs_path* pdp, BOOL
Note this CHANGES CWD !!!! JRA.
*********************************************************/
-static BOOL create_conn_struct( connection_struct *conn, int snum, char *path)
+static BOOL create_conn_struct(connection_struct *conn, int snum, char *path)
{
+ pstring connpath;
+
ZERO_STRUCTP(conn);
+
conn->service = snum;
- conn->connectpath = path;
- pstring_sub(conn->connectpath , "%S", lp_servicename(snum));
+ pstrcpy(connpath, path);
+ pstring_sub(connpath , "%S", lp_servicename(snum));
/* needed for smbd_vfs_init() */
@@ -140,9 +145,11 @@ static BOOL create_conn_struct( connection_struct *conn, int snum, char *path)
return False;
}
+ string_set(&conn->connectpath, connpath);
+
if (!smbd_vfs_init(conn)) {
DEBUG(0,("create_conn_struct: smbd_vfs_init failed.\n"));
- talloc_destroy( conn->mem_ctx );
+ conn_free_internal(conn);
return False;
}
@@ -155,47 +162,55 @@ static BOOL create_conn_struct( connection_struct *conn, int snum, char *path)
if (vfs_ChDir(conn,conn->connectpath) != 0) {
DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. Error was %s\n",
conn->connectpath, strerror(errno) ));
- talloc_destroy( conn->mem_ctx );
+ conn_free_internal(conn);
return False;
}
+
return True;
}
-
/**********************************************************************
Parse the contents of a symlink to verify if it is an msdfs referral
A valid referral is of the form: msdfs:server1\share1,server2\share2
+ talloc CTX can be NULL here if preflist and refcount pointers are null.
**********************************************************************/
-static BOOL parse_symlink(char* buf,struct referral** preflist,
- int* refcount)
+static BOOL parse_symlink(TALLOC_CTX *ctx, char *buf, struct referral **preflist, int *refcount)
{
pstring temp;
- char* prot;
- char* alt_path[MAX_REFERRAL_COUNT];
- int count=0, i;
- struct referral* reflist;
+ char *prot;
+ char *alt_path[MAX_REFERRAL_COUNT];
+ int count = 0, i;
+ struct referral *reflist;
pstrcpy(temp,buf);
prot = strtok(temp,":");
- if (!strequal(prot, "msdfs"))
+ if (!strequal(prot, "msdfs")) {
return False;
+ }
/* No referral list requested. Just yes/no. */
- if (!preflist)
+ if (!preflist) {
+ return True;
+ }
+
+ if (!ctx) {
+ DEBUG(0,("parse_symlink: logic error. TALLOC_CTX should not be null.\n"));
return True;
+ }
/* parse out the alternate paths */
- while(((alt_path[count] = strtok(NULL,",")) != NULL) && count<MAX_REFERRAL_COUNT)
+ while(((alt_path[count] = strtok(NULL,",")) != NULL) && count<MAX_REFERRAL_COUNT) {
count++;
+ }
DEBUG(10,("parse_symlink: count=%d\n", count));
- reflist = *preflist = SMB_MALLOC_ARRAY(struct referral, count);
+ reflist = *preflist = TALLOC_ARRAY(ctx, struct referral, count);
if(reflist == NULL) {
- DEBUG(0,("parse_symlink: Malloc failed!\n"));
+ DEBUG(0,("parse_symlink: talloc failed!\n"));
return False;
}
@@ -220,29 +235,33 @@ static BOOL parse_symlink(char* buf,struct referral** preflist,
DEBUG(10, ("parse_symlink: Created alt path: %s\n", reflist[i].alternate_path));
}
- if(refcount)
+ if(refcount) {
*refcount = count;
+ }
return True;
}
/**********************************************************************
Returns true if the unix path is a valid msdfs symlink
+ talloc CTX can be NULL here if reflistp and refcnt pointers are null.
**********************************************************************/
-BOOL is_msdfs_link(connection_struct* conn, char * path,
- struct referral** reflistp, int* refcnt,
+BOOL is_msdfs_link(TALLOC_CTX *ctx, connection_struct *conn, char *path,
+ struct referral **reflistp, int *refcnt,
SMB_STRUCT_STAT *sbufp)
{
SMB_STRUCT_STAT st;
pstring referral;
int referral_len = 0;
- if (!path || !conn)
+ if (!path || !conn) {
return False;
+ }
- if (sbufp == NULL)
+ if (sbufp == NULL) {
sbufp = &st;
+ }
if (SMB_VFS_LSTAT(conn, path, sbufp) != 0) {
DEBUG(5,("is_msdfs_link: %s does not exist.\n",path));
@@ -259,8 +278,9 @@ BOOL is_msdfs_link(connection_struct* conn, char * path,
referral[referral_len] = '\0';
DEBUG(5,("is_msdfs_link: %s -> %s\n",path,referral));
- if (parse_symlink(referral, reflistp, refcnt))
+ if (parse_symlink(ctx, referral, reflistp, refcnt)) {
return True;
+ }
}
return False;
}
@@ -278,13 +298,15 @@ they request referrals for dfs roots on a server.
consumedcntp: how much of the dfs path is being redirected. the client
should try the remaining path on the redirected server.
-
+
+TALLOC_CTX can be NULL here if struct referral **reflistpp, int *refcntp
+are also NULL.
*****************************************************************/
-static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
- connection_struct* conn, BOOL search_flag,
- struct referral** reflistpp, int* refcntp,
- BOOL* self_referralp, int* consumedcntp)
+static BOOL resolve_dfs_path(TALLOC_CTX *ctx, pstring dfspath, struct dfs_path *dp,
+ connection_struct *conn, BOOL search_flag,
+ struct referral **reflistpp, int *refcntp,
+ BOOL *self_referralp, int *consumedcntp)
{
pstring localpath;
int consumed_level = 1;
@@ -298,6 +320,10 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
return False;
}
+ if (!ctx && (reflistpp || refcntp)) {
+ DEBUG(0,("resolve_dfs_path: logic error. TALLOC_CTX must not be NULL.\n"));
+ }
+
if (dp->reqpath[0] == '\0') {
if (self_referralp) {
DEBUG(6,("resolve_dfs_path: self-referral. returning False\n"));
@@ -313,16 +339,17 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
pstrcpy(localpath, dp->reqpath);
/* check if need to redirect */
- if (is_msdfs_link(conn, localpath, reflistpp, refcntp, NULL)) {
+ if (is_msdfs_link(ctx, conn, localpath, reflistpp, refcntp, NULL)) {
if ( search_flag ) {
DEBUG(6,("resolve_dfs_path (FindFirst) No redirection "
"for dfs link %s.\n", dfspath));
return False;
}
-
+
DEBUG(6,("resolve_dfs_path: %s resolves to a valid Dfs link.\n", dfspath));
- if (consumedcntp)
+ if (consumedcntp) {
*consumedcntp = strlen(dfspath);
+ }
return True;
}
@@ -332,8 +359,7 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
while (p) {
*p = '\0';
pstrcpy(localpath, reqpath);
- if (is_msdfs_link(conn, localpath, reflistpp, refcntp, NULL)) {
-
+ if (is_msdfs_link(ctx, conn, localpath, reflistpp, refcntp, NULL)) {
DEBUG(4, ("resolve_dfs_path: Redirecting %s because parent %s is dfs link\n", dfspath, localpath));
/* To find the path consumed, we truncate the original
@@ -349,8 +375,9 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
trim_char(buf, '\0', '\\');
for (; consumed_level; consumed_level--) {
q = strrchr_m(buf, '\\');
- if (q)
+ if (q) {
*q = 0;
+ }
}
*consumedcntp = strlen(buf);
DEBUG(10, ("resolve_dfs_path: Path consumed: %s (%d)\n", buf, *consumedcntp));
@@ -361,7 +388,7 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
p = strrchr_m(reqpath, '/');
consumed_level++;
}
-
+
return False;
}
@@ -374,12 +401,13 @@ static BOOL resolve_dfs_path(pstring dfspath, struct dfs_path* dp,
for details.
*****************************************************************/
-BOOL dfs_redirect( pstring pathname, connection_struct* conn, BOOL search_wcard_flag )
+BOOL dfs_redirect( pstring pathname, connection_struct *conn, BOOL search_wcard_flag )
{
struct dfs_path dp;
- if (!conn || !pathname)
+ if (!conn || !pathname) {
return False;
+ }
parse_processed_dfs_path(pathname, &dp, search_wcard_flag);
@@ -390,10 +418,11 @@ BOOL dfs_redirect( pstring pathname, connection_struct* conn, BOOL search_wcard_
return False;
}
- if (!strequal(dp.servicename, lp_servicename(SNUM(conn)) ))
+ if (!strequal(dp.servicename, lp_servicename(SNUM(conn)) )) {
return False;
+ }
- if (resolve_dfs_path(pathname, &dp, conn, search_wcard_flag,
+ if (resolve_dfs_path(NULL, pathname, &dp, conn, search_wcard_flag,
NULL, NULL, NULL, NULL)) {
DEBUG(3,("dfs_redirect: Redirecting %s\n", pathname));
return True;
@@ -402,8 +431,7 @@ BOOL dfs_redirect( pstring pathname, connection_struct* conn, BOOL search_wcard_
/* Form non-dfs tcon-relative path */
pstrcpy(pathname, dp.reqpath);
- DEBUG(3,("dfs_redirect: Path converted to non-dfs path %s\n",
- pathname));
+ DEBUG(3,("dfs_redirect: Path converted to non-dfs path %s\n", pathname));
return False;
}
@@ -414,16 +442,17 @@ BOOL dfs_redirect( pstring pathname, connection_struct* conn, BOOL search_wcard_
Return a self referral.
**********************************************************************/
-static BOOL self_ref(char *pathname, struct junction_map *jucn,
+static BOOL self_ref(TALLOC_CTX *ctx, char *pathname, struct junction_map *jucn,
int *consumedcntp, BOOL *self_referralp)
{
struct referral *ref;
- if (self_referralp != NULL)
+ if (self_referralp != NULL) {
*self_referralp = True;
+ }
jucn->referral_count = 1;
- if((ref = SMB_MALLOC_P(struct referral)) == NULL) {
+ if((ref = TALLOC_P(ctx, struct referral)) == NULL) {
DEBUG(0,("self_ref: malloc failed for referral\n"));
return False;
}
@@ -432,38 +461,41 @@ static BOOL self_ref(char *pathname, struct junction_map *jucn,
ref->proximity = 0;
ref->ttl = REFERRAL_TTL;
jucn->referral_list = ref;
- if (consumedcntp)
+ if (consumedcntp) {
*consumedcntp = strlen(pathname);
+ }
return True;
}
/**********************************************************************
Gets valid referrals for a dfs path and fills up the
- junction_map structure
+ junction_map structure.
**********************************************************************/
-BOOL get_referred_path(char *pathname, struct junction_map *jucn,
+BOOL get_referred_path(TALLOC_CTX *ctx, char *pathname, struct junction_map *jucn,
int *consumedcntp, BOOL *self_referralp)
{
struct dfs_path dp;
struct connection_struct conns;
- struct connection_struct* conn = &conns;
+ struct connection_struct *conn = &conns;
pstring conn_path;
int snum;
BOOL ret = False;
BOOL self_referral = False;
- if (!pathname || !jucn)
+ if (!pathname || !jucn) {
return False;
+ }
ZERO_STRUCT(conns);
- if (self_referralp)
+ if (self_referralp) {
*self_referralp = False;
- else
+ } else {
self_referralp = &self_referral;
+ }
parse_dfs_path(pathname, &dp);
@@ -483,8 +515,9 @@ BOOL get_referred_path(char *pathname, struct junction_map *jucn,
/* Verify the share is a dfs root */
snum = lp_servicenumber(jucn->service_name);
if(snum < 0) {
- if ((snum = find_service(jucn->service_name)) < 0)
+ if ((snum = find_service(jucn->service_name)) < 0) {
return False;
+ }
}
if (!lp_msdfs_root(snum)) {
@@ -504,34 +537,37 @@ BOOL get_referred_path(char *pathname, struct junction_map *jucn,
struct referral* ref;
- if (*lp_msdfs_proxy(snum) == '\0')
- return self_ref(pathname, jucn, consumedcntp,
- self_referralp);
+ if (*lp_msdfs_proxy(snum) == '\0') {
+ return self_ref(ctx, pathname, jucn, consumedcntp, self_referralp);
+ }
jucn->referral_count = 1;
- if ((ref = SMB_MALLOC_P(struct referral)) == NULL) {
+ if ((ref = TALLOC_P(ctx, struct referral)) == NULL) {
DEBUG(0, ("malloc failed for referral\n"));
goto out;
}
pstrcpy(ref->alternate_path, lp_msdfs_proxy(snum));
- if (dp.reqpath[0] != '\0')
+ if (dp.reqpath[0] != '\0') {
pstrcat(ref->alternate_path, dp.reqpath);
+ }
ref->proximity = 0;
ref->ttl = REFERRAL_TTL;
jucn->referral_list = ref;
- if (consumedcntp)
+ if (consumedcntp) {
*consumedcntp = strlen(pathname);
+ }
ret = True;
goto out;
}
pstrcpy(conn_path, lp_pathname(snum));
- if (!create_conn_struct(conn, snum, conn_path))
+ if (!create_conn_struct(conn, snum, conn_path)) {
return False;
+ }
/* If not remote & not a self referral, return False */
- if (!resolve_dfs_path(pathname, &dp, conn, False,
+ if (!resolve_dfs_path(ctx, pathname, &dp, conn, False,
&jucn->referral_list, &jucn->referral_count,
self_referralp, consumedcntp)) {
if (!*self_referralp) {
@@ -542,7 +578,7 @@ BOOL get_referred_path(char *pathname, struct junction_map *jucn,
/* if self_referral, fill up the junction map */
if (*self_referralp) {
- if (self_ref(pathname, jucn, consumedcntp, self_referralp) == False) {
+ if (self_ref(ctx, pathname, jucn, consumedcntp, self_referralp) == False) {
goto out;
}
}
@@ -550,14 +586,13 @@ BOOL get_referred_path(char *pathname, struct junction_map *jucn,
ret = True;
out:
- if (conn->mem_ctx)
- talloc_destroy( conn->mem_ctx );
-
+
+ conn_free_internal(conn);
return ret;
}
-static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
- struct junction_map* junction,
+static int setup_ver2_dfs_referral(char *pathname, char **ppdata,
+ struct junction_map *junction,
int consumedcnt,
BOOL self_referral)
{
@@ -607,8 +642,9 @@ static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
if(pdata == NULL) {
DEBUG(0,("malloc failed for Realloc!\n"));
return -1;
- } else
+ } else {
*ppdata = pdata;
+ }
/* copy in the dfs requested paths.. required for offset calculations */
memcpy(pdata+uni_reqpathoffset1,uni_requestedpath,requestedpathlen);
@@ -617,10 +653,11 @@ static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
/* create the header */
SSVAL(pdata,0,consumedcnt * 2); /* path consumed */
SSVAL(pdata,2,junction->referral_count); /* number of referral in this pkt */
- if(self_referral)
+ if(self_referral) {
SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER);
- else
+ } else {
SIVAL(pdata,4,DFSREF_STORAGE_SERVER);
+ }
offset = 8;
/* add the referral elements */
@@ -630,10 +667,11 @@ static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
SSVAL(pdata,offset,2); /* version 2 */
SSVAL(pdata,offset+2,VERSION2_REFERRAL_SIZE);
- if(self_referral)
+ if(self_referral) {
SSVAL(pdata,offset+4,1);
- else
+ } else {
SSVAL(pdata,offset+4,0);
+ }
SSVAL(pdata,offset+6,0); /* ref_flags :use path_consumed bytes? */
SIVAL(pdata,offset+8,ref->proximity);
SIVAL(pdata,offset+12,ref->ttl);
@@ -654,8 +692,8 @@ static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
return reply_size;
}
-static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
- struct junction_map* junction,
+static int setup_ver3_dfs_referral(char *pathname, char **ppdata,
+ struct junction_map *junction,
int consumedcnt,
BOOL self_referral)
{
@@ -690,16 +728,18 @@ static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
if(pdata == NULL) {
DEBUG(0,("version3 referral setup: malloc failed for Realloc!\n"));
return -1;
- } else
+ } else {
*ppdata = pdata;
+ }
/* create the header */
SSVAL(pdata,0,consumedcnt * 2); /* path consumed */
SSVAL(pdata,2,junction->referral_count); /* number of referral */
- if(self_referral)
+ if(self_referral) {
SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER);
- else
+ } else {
SIVAL(pdata,4,DFSREF_STORAGE_SERVER);
+ }
/* copy in the reqpaths */
memcpy(pdata+uni_reqpathoffset1,uni_reqpath,reqpathlen);
@@ -712,10 +752,11 @@ static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
SSVAL(pdata,offset,3); /* version 3 */
SSVAL(pdata,offset+2,VERSION3_REFERRAL_SIZE);
- if(self_referral)
+ if(self_referral) {
SSVAL(pdata,offset+4,1);
- else
+ } else {
SSVAL(pdata,offset+4,0);
+ }
SSVAL(pdata,offset+6,0); /* ref_flags :use path_consumed bytes? */
SIVAL(pdata,offset+8,ref->ttl);
@@ -736,10 +777,10 @@ static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
}
/******************************************************************
- * Set up the Dfs referral for the dfs pathname
- ******************************************************************/
+ Set up the Dfs referral for the dfs pathname
+******************************************************************/
-int setup_dfs_referral(connection_struct *orig_conn, char *pathname, int max_referral_level, char** ppdata)
+int setup_dfs_referral(connection_struct *orig_conn, char *pathname, int max_referral_level, char **ppdata)
{
struct junction_map junction;
int consumedcnt;
@@ -747,23 +788,32 @@ int setup_dfs_referral(connection_struct *orig_conn, char *pathname, int max_ref
pstring buf;
int reply_size = 0;
char *pathnamep = pathname;
+ TALLOC_CTX *ctx;
+
+ if (!(ctx=talloc_init("setup_dfs_referral"))) {
+ return -1;
+ }
ZERO_STRUCT(junction);
/* get the junction entry */
- if (!pathnamep)
+ if (!pathnamep) {
+ talloc_destroy(ctx);
return -1;
+ }
/* Trim pathname sent by client so it begins with only one backslash.
Two backslashes confuse some dfs clients
*/
- while (pathnamep[0] == '\\' && pathnamep[1] == '\\')
+ while (pathnamep[0] == '\\' && pathnamep[1] == '\\') {
pathnamep++;
+ }
pstrcpy(buf, pathnamep);
/* The following call can change cwd. */
- if (!get_referred_path(buf, &junction, &consumedcnt, &self_referral)) {
+ if (!get_referred_path(ctx, buf, &junction, &consumedcnt, &self_referral)) {
vfs_ChDir(orig_conn,orig_conn->connectpath);
+ talloc_destroy(ctx);
return -1;
}
vfs_ChDir(orig_conn,orig_conn->connectpath);
@@ -782,30 +832,31 @@ int setup_dfs_referral(connection_struct *orig_conn, char *pathname, int max_ref
/* create the referral depeding on version */
DEBUG(10,("max_referral_level :%d\n",max_referral_level));
- if(max_referral_level<2 || max_referral_level>3)
+ if(max_referral_level<2 || max_referral_level>3) {
max_referral_level = 2;
+ }
switch(max_referral_level) {
case 2:
reply_size = setup_ver2_dfs_referral(pathnamep, ppdata, &junction,
consumedcnt, self_referral);
- SAFE_FREE(junction.referral_list);
break;
case 3:
reply_size = setup_ver3_dfs_referral(pathnamep, ppdata, &junction,
consumedcnt, self_referral);
- SAFE_FREE(junction.referral_list);
break;
default:
DEBUG(0,("setup_dfs_referral: Invalid dfs referral version: %d\n", max_referral_level));
+ talloc_destroy(ctx);
return -1;
}
if (DEBUGLVL(10)) {
- DEBUGADD(0,("DFS Referral pdata:\n"));
- dump_data(0,*ppdata,reply_size);
+ DEBUGADD(0,("DFS Referral pdata:\n"));
+ dump_data(0,*ppdata,reply_size);
}
+ talloc_destroy(ctx);
return reply_size;
}
@@ -813,11 +864,11 @@ int setup_dfs_referral(connection_struct *orig_conn, char *pathname, int max_ref
The following functions are called by the NETDFS RPC pipe functions
**********************************************************************/
-/**********************************************************************
+/*********************************************************************
Creates a junction structure from a Dfs pathname
- **********************************************************************/
+**********************************************************************/
-BOOL create_junction(char* pathname, struct junction_map* jucn)
+BOOL create_junction(char *pathname, struct junction_map *jucn)
{
struct dfs_path dp;
@@ -825,51 +876,52 @@ BOOL create_junction(char* pathname, struct junction_map* jucn)
/* check if path is dfs : validate first token */
if ( !strequal(get_local_machine_name(),dp.hostname) ) {
-
- /* Hostname mismatch, check if one of our IP addresses */
- if (!ismyip(*interpret_addr2(dp.hostname))) {
- DEBUG(4,("create_junction: Invalid hostname %s in dfs path %s\n",
- dp.hostname, pathname));
- return False;
- }
- }
+ /* Hostname mismatch, check if one of our IP addresses */
+ if (!ismyip(*interpret_addr2(dp.hostname))) {
+ DEBUG(4,("create_junction: Invalid hostname %s in dfs path %s\n",
+ dp.hostname, pathname));
+ return False;
+ }
+ }
- /* Check for a non-DFS share */
- if(!lp_msdfs_root(lp_servicenumber(dp.servicename))) {
- DEBUG(4,("create_junction: %s is not an msdfs root.\n",
- dp.servicename));
- return False;
- }
+ /* Check for a non-DFS share */
+ if(!lp_msdfs_root(lp_servicenumber(dp.servicename))) {
+ DEBUG(4,("create_junction: %s is not an msdfs root.\n", dp.servicename));
+ return False;
+ }
- pstrcpy(jucn->service_name,dp.servicename);
- pstrcpy(jucn->volume_name,dp.reqpath);
- return True;
+ pstrcpy(jucn->service_name,dp.servicename);
+ pstrcpy(jucn->volume_name,dp.reqpath);
+ return True;
}
/**********************************************************************
Forms a valid Unix pathname from the junction
**********************************************************************/
-static BOOL junction_to_local_path(struct junction_map* jucn, char* path,
+static BOOL junction_to_local_path(struct junction_map *jucn, char *path,
int max_pathlen, connection_struct *conn)
{
int snum;
pstring conn_path;
- if(!path || !jucn)
+ if(!path || !jucn) {
return False;
+ }
snum = lp_servicenumber(jucn->service_name);
- if(snum < 0)
+ if(snum < 0) {
return False;
+ }
safe_strcpy(path, lp_pathname(snum), max_pathlen-1);
safe_strcat(path, "/", max_pathlen-1);
safe_strcat(path, jucn->volume_name, max_pathlen-1);
pstrcpy(conn_path, lp_pathname(snum));
- if (!create_conn_struct(conn, snum, conn_path))
+ if (!create_conn_struct(conn, snum, conn_path)) {
return False;
+ }
return True;
}
@@ -884,8 +936,11 @@ BOOL create_msdfs_link(struct junction_map *jucn, BOOL exists)
BOOL insert_comma = False;
BOOL ret = False;
- if(!junction_to_local_path(jucn, path, sizeof(path), conn))
+ ZERO_STRUCT(conns);
+
+ if(!junction_to_local_path(jucn, path, sizeof(path), conn)) {
return False;
+ }
/* form the msdfs_link contents */
pstrcpy(msdfs_link, "msdfs:");
@@ -894,24 +949,28 @@ BOOL create_msdfs_link(struct junction_map *jucn, BOOL exists)
trim_char(refpath, '\\', '\\');
if(*refpath == '\0') {
- if (i == 0)
+ if (i == 0) {
insert_comma = False;
+ }
continue;
}
- if (i > 0 && insert_comma)
+ if (i > 0 && insert_comma) {
pstrcat(msdfs_link, ",");
+ }
pstrcat(msdfs_link, refpath);
- if (!insert_comma)
+ if (!insert_comma) {
insert_comma = True;
-
+ }
}
DEBUG(5,("create_msdfs_link: Creating new msdfs link: %s -> %s\n", path, msdfs_link));
- if(exists)
- if(SMB_VFS_UNLINK(conn,path)!=0)
+ if(exists) {
+ if(SMB_VFS_UNLINK(conn,path)!=0) {
goto out;
+ }
+ }
if(SMB_VFS_SYMLINK(conn, msdfs_link, path) < 0) {
DEBUG(1,("create_msdfs_link: symlink failed %s -> %s\nError: %s\n",
@@ -923,28 +982,32 @@ BOOL create_msdfs_link(struct junction_map *jucn, BOOL exists)
ret = True;
out:
- talloc_destroy( conn->mem_ctx );
+
+ conn_free_internal(conn);
return ret;
}
-BOOL remove_msdfs_link(struct junction_map* jucn)
+BOOL remove_msdfs_link(struct junction_map *jucn)
{
pstring path;
connection_struct conns;
connection_struct *conn = &conns;
BOOL ret = False;
+ ZERO_STRUCT(conns);
+
if( junction_to_local_path(jucn, path, sizeof(path), conn) ) {
- if( SMB_VFS_UNLINK(conn, path) == 0 )
+ if( SMB_VFS_UNLINK(conn, path) == 0 ) {
ret = True;
-
+ }
talloc_destroy( conn->mem_ctx );
}
-
+
+ conn_free_internal(conn);
return ret;
}
-static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
+static int form_junctions(TALLOC_CTX *ctx, int snum, struct junction_map *jucn, int jn_remain)
{
int cnt = 0;
DIR *dirp;
@@ -954,20 +1017,25 @@ static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
connection_struct conn;
struct referral *ref = NULL;
- if (jn_remain <= 0)
- return(0);
+ ZERO_STRUCT(conn);
+
+ if (jn_remain <= 0) {
+ return 0;
+ }
pstrcpy(connect_path,lp_pathname(snum));
- if(*connect_path == '\0')
+ if(*connect_path == '\0') {
return 0;
+ }
/*
* Fake up a connection struct for the VFS layer.
*/
- if (!create_conn_struct(&conn, snum, connect_path))
+ if (!create_conn_struct(&conn, snum, connect_path)) {
return 0;
+ }
/* form a junction for the msdfs root - convention
DO NOT REMOVE THIS: NT clients will not work with us
@@ -977,7 +1045,7 @@ static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
jucn[cnt].volume_name[0] = '\0';
jucn[cnt].referral_count = 1;
- ref = jucn[cnt].referral_list = SMB_MALLOC_P(struct referral);
+ ref = jucn[cnt].referral_list = TALLOC_P(ctx, struct referral);
if (jucn[cnt].referral_list == NULL) {
DEBUG(0, ("Malloc failed!\n"));
goto out;
@@ -996,8 +1064,9 @@ static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
/* Now enumerate all dfs links */
dirp = SMB_VFS_OPENDIR(&conn, ".", NULL, 0);
- if(!dirp)
+ if(!dirp) {
goto out;
+ }
while ((dname = vfs_readdirname(&conn, dirp)) != NULL) {
if (cnt >= jn_remain) {
@@ -1005,8 +1074,8 @@ static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
DEBUG(2, ("ran out of MSDFS junction slots"));
goto out;
}
- if (is_msdfs_link(&conn, dname, &(jucn[cnt].referral_list),
- &(jucn[cnt].referral_count), NULL)) {
+ if (is_msdfs_link(ctx, &conn, dname, &jucn[cnt].referral_list,
+ &jucn[cnt].referral_count, NULL)) {
pstrcpy(jucn[cnt].service_name, service_name);
pstrcpy(jucn[cnt].volume_name, dname);
cnt++;
@@ -1014,22 +1083,26 @@ static int form_junctions(int snum, struct junction_map* jucn, int jn_remain)
}
SMB_VFS_CLOSEDIR(&conn,dirp);
+
out:
- conn_free(&conn);
+
+ conn_free_internal(&conn);
return cnt;
}
-int enum_msdfs_links(struct junction_map* jucn, int jn_max)
+int enum_msdfs_links(TALLOC_CTX *ctx, struct junction_map *jucn, int jn_max)
{
int i=0;
int jn_count = 0;
- if(!lp_host_msdfs())
+ if(!lp_host_msdfs()) {
return 0;
+ }
for(i=0;i < lp_numservices() && (jn_max - jn_count) > 0;i++) {
- if(lp_msdfs_root(i))
- jn_count += form_junctions(i,jucn,jn_max - jn_count);
+ if(lp_msdfs_root(i)) {
+ jn_count += form_junctions(ctx, i,jucn,jn_max - jn_count);
+ }
}
return jn_count;
}
diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c
index de120039867..c0c9e989a99 100644
--- a/source/smbd/oplock.c
+++ b/source/smbd/oplock.c
@@ -757,8 +757,9 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_id,
if((outbuf = NewOutBuffer(&saved_outbuf))==NULL) {
DEBUG(0,("oplock_break: malloc fail for output buffer.\n"));
- set_InBuffer(saved_inbuf);
+ /* Free must be done before set.. */
free_InBuffer(inbuf);
+ set_InBuffer(saved_inbuf);
return False;
}
@@ -918,14 +919,15 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_id,
/* Restore the chain fnum. */
file_chain_restore();
- /* Restore the global In/Out buffers. */
- set_InBuffer(saved_inbuf);
- set_OutBuffer(saved_outbuf);
-
/* Free the buffers we've been using to recurse. */
+ /* Free must be done before set.. */
free_InBuffer(inbuf);
free_OutBuffer(outbuf);
+ /* Restore the global In/Out buffers. */
+ set_InBuffer(saved_inbuf);
+ set_OutBuffer(saved_outbuf);
+
/* We need this in case a readraw crossed on the wire. */
if(global_oplock_break)
global_oplock_break = False;
diff --git a/source/smbd/process.c b/source/smbd/process.c
index 19add7e0951..1deb4da2696 100644
--- a/source/smbd/process.c
+++ b/source/smbd/process.c
@@ -1527,6 +1527,7 @@ char *get_InBuffer(void)
void set_InBuffer(char *new_inbuf)
{
InBuffer = new_inbuf;
+ current_inbuf = InBuffer;
}
char *get_OutBuffer(void)
@@ -1547,6 +1548,9 @@ void set_OutBuffer(char *new_outbuf)
void free_InBuffer(char *inbuf)
{
if (!aio_inbuffer_in_use(inbuf)) {
+ if (current_inbuf == inbuf) {
+ current_inbuf = NULL;
+ }
SAFE_FREE(inbuf);
}
}
diff --git a/source/smbd/sesssetup.c b/source/smbd/sesssetup.c
index 8586ac1324f..bf7287aab9c 100644
--- a/source/smbd/sesssetup.c
+++ b/source/smbd/sesssetup.c
@@ -353,7 +353,8 @@ static int reply_spnego_kerberos(connection_struct *conn,
static BOOL reply_spnego_ntlmssp(connection_struct *conn, char *inbuf, char *outbuf,
uint16 vuid,
AUTH_NTLMSSP_STATE **auth_ntlmssp_state,
- DATA_BLOB *ntlmssp_blob, NTSTATUS nt_status)
+ DATA_BLOB *ntlmssp_blob, NTSTATUS nt_status,
+ BOOL wrap)
{
BOOL ret;
DATA_BLOB response;
@@ -406,9 +407,16 @@ static BOOL reply_spnego_ntlmssp(connection_struct *conn, char *inbuf, char *out
}
}
- response = spnego_gen_auth_response(ntlmssp_blob, nt_status, OID_NTLMSSP);
+ if (wrap) {
+ response = spnego_gen_auth_response(ntlmssp_blob, nt_status, OID_NTLMSSP);
+ } else {
+ response = *ntlmssp_blob;
+ }
+
ret = reply_sesssetup_blob(conn, outbuf, response, nt_status);
- data_blob_free(&response);
+ if (wrap) {
+ data_blob_free(&response);
+ }
/* NT_STATUS_MORE_PROCESSING_REQUIRED from our NTLMSSP code tells us,
and the other end, that we are not finished yet. */
@@ -504,8 +512,8 @@ static int reply_spnego_negotiate(connection_struct *conn,
data_blob_free(&secblob);
reply_spnego_ntlmssp(conn, inbuf, outbuf, vuid, auth_ntlmssp_state,
- &chal, nt_status);
-
+ &chal, nt_status, True);
+
data_blob_free(&chal);
/* already replied */
@@ -550,7 +558,7 @@ static int reply_spnego_auth(connection_struct *conn, char *inbuf, char *outbuf,
reply_spnego_ntlmssp(conn, inbuf, outbuf, vuid,
auth_ntlmssp_state,
- &auth_reply, nt_status);
+ &auth_reply, nt_status, True);
data_blob_free(&auth_reply);
@@ -652,6 +660,31 @@ static int reply_sesssetup_and_X_spnego(connection_struct *conn, char *inbuf,
return ret;
}
+ if (strncmp(blob1.data, "NTLMSSP", 7) == 0) {
+ DATA_BLOB chal;
+ NTSTATUS nt_status;
+ if (!vuser->auth_ntlmssp_state) {
+ nt_status = auth_ntlmssp_start(&vuser->auth_ntlmssp_state);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ /* Kill the intermediate vuid */
+ invalidate_vuid(vuid);
+
+ return ERROR_NT(nt_status);
+ }
+ }
+
+ nt_status = auth_ntlmssp_update(vuser->auth_ntlmssp_state,
+ blob1, &chal);
+
+ data_blob_free(&blob1);
+
+ reply_spnego_ntlmssp(conn, inbuf, outbuf, vuid,
+ &vuser->auth_ntlmssp_state,
+ &chal, nt_status, False);
+ data_blob_free(&chal);
+ return -1;
+ }
+
/* what sort of packet is this? */
DEBUG(1,("Unknown packet in reply_sesssetup_and_X_spnego\n"));
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 522d3c0f54c..e1462c01036 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -1122,7 +1122,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
if(lp_host_msdfs() &&
lp_msdfs_root(SNUM(conn)) &&
- is_msdfs_link(conn, pathreal, NULL, NULL,
+ is_msdfs_link(NULL,conn, pathreal, NULL, NULL,
&sbuf)) {
DEBUG(5,("get_lanman2_dir_entry: Masquerading msdfs link %s as a directory\n", pathreal));
diff --git a/source/tdb/tdb.c b/source/tdb/tdb.c
index 2c94f945875..d68df037768 100644
--- a/source/tdb/tdb.c
+++ b/source/tdb/tdb.c
@@ -560,6 +560,7 @@ static tdb_off tdb_dump_record(TDB_CONTEXT *tdb, tdb_off offset)
static int tdb_dump_chain(TDB_CONTEXT *tdb, int i)
{
tdb_off rec_ptr, top;
+ int hash_length = 0;
top = TDB_HASH_TOP(i);
@@ -574,8 +575,11 @@ static int tdb_dump_chain(TDB_CONTEXT *tdb, int i)
while (rec_ptr) {
rec_ptr = tdb_dump_record(tdb, rec_ptr);
+ hash_length += 1;
}
+ printf("chain %d length %d\n", i, hash_length);
+
return tdb_unlock(tdb, i, F_WRLCK);
}
diff --git a/source/utils/net.c b/source/utils/net.c
index d4c96e9db8f..e9332f58f7b 100644
--- a/source/utils/net.c
+++ b/source/utils/net.c
@@ -219,7 +219,7 @@ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS connect_pipe(struct cli_state **cli_dst, int pipe_num, BOOL *got_pipe)
+NTSTATUS connect_dst_pipe(struct cli_state **cli_dst, int pipe_num, BOOL *got_pipe)
{
NTSTATUS nt_status;
char *server_name = SMB_STRDUP("127.0.0.1");
diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c
index 1c44e79f302..d922b508231 100644
--- a/source/utils/net_rpc.c
+++ b/source/utils/net_rpc.c
@@ -2586,9 +2586,8 @@ static WERROR get_share_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
init_enum_hnd(&hnd, 0);
- result = cli_srvsvc_net_share_enum(cli, mem_ctx, level, ctr,
- preferred_len, &hnd);
- goto done;
+ return cli_srvsvc_net_share_enum(cli, mem_ctx, level, ctr,
+ preferred_len, &hnd);
}
/* request just one share */
@@ -2827,7 +2826,7 @@ rpc_share_migrate_shares_internals(const DOM_SID *domain_sid, const char *domain
goto done;
/* connect destination PI_SRVSVC */
- nt_status = connect_pipe(&cli_dst, PI_SRVSVC, &got_dst_srvsvc_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SRVSVC, &got_dst_srvsvc_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -3235,7 +3234,7 @@ rpc_share_migrate_security_internals(const DOM_SID *domain_sid, const char *doma
goto done;
/* connect destination PI_SRVSVC */
- nt_status = connect_pipe(&cli_dst, PI_SRVSVC, &got_dst_srvsvc_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SRVSVC, &got_dst_srvsvc_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -4975,7 +4974,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
return -1;
}
- if (push_ucs2_talloc(mem_ctx, &uni_domain_name, domain_name_pol) < 0) {
+ if (push_ucs2_talloc(mem_ctx, &uni_domain_name, domain_name_pol) == (size_t)-1) {
DEBUG(0, ("Could not convert domain name %s to unicode\n",
domain_name_pol));
return -1;
@@ -5129,7 +5128,7 @@ static NTSTATUS vampire_trusted_domain(struct cli_state *cli,
goto done;
}
- if (push_ucs2_talloc(mem_ctx, &uni_dom_name, trusted_dom_name) < 0) {
+ if (push_ucs2_talloc(mem_ctx, &uni_dom_name, trusted_dom_name) == (size_t)-1) {
DEBUG(0, ("Could not convert domain name %s to unicode\n",
trusted_dom_name));
nt_status = NT_STATUS_UNSUCCESSFUL;
diff --git a/source/utils/net_rpc_printer.c b/source/utils/net_rpc_printer.c
index e2080cdc285..6194f40b091 100644
--- a/source/utils/net_rpc_printer.c
+++ b/source/utils/net_rpc_printer.c
@@ -780,8 +780,10 @@ copy_print_driver_3(TALLOC_CTX *mem_ctx,
return nt_status;
while (valid) {
+
rpcstr_pull(dependentfiles, i1->dependentfiles+length, sizeof(dependentfiles), -1, STR_TERMINATE);
- length+=strlen(dependentfiles)+1;
+ length += strlen(dependentfiles)+1;
+
if (strlen(dependentfiles) > 0) {
nt_status = net_copy_driverfile(mem_ctx,
@@ -937,7 +939,7 @@ net_spoolss_enumprinterkey(struct cli_state *cli, TALLOC_CTX *mem_ctx,
WERROR result;
/* enumprinterkey call */
- result = cli_spoolss_enumprinterkey(cli, mem_ctx, hnd, keyname, NULL, NULL);
+ result = cli_spoolss_enumprinterkey(cli, mem_ctx, hnd, keyname, keylist, NULL);
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterkey failed: %s\n", dos_errstr(result));
@@ -1468,7 +1470,7 @@ NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid, const
DEBUG(3,("copying printer ACLs\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -1617,7 +1619,7 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid, const ch
DEBUG(3,("copying forms\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -1797,7 +1799,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, const
DEBUG(3,("copying printer-drivers\n"));
- nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
@@ -1806,7 +1808,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, const
nt_status = connect_to_service(&cli_share_src, &cli->dest_ip,
cli->desthost, "print$", "A:");
if (!NT_STATUS_IS_OK(nt_status))
- return nt_status;
+ goto done;
got_src_driver_share = True;
@@ -1826,7 +1828,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, const
goto done;
}
- if (!num_printers) {
+ if (num_printers == 0) {
printf ("no printers found on server.\n");
nt_status = NT_STATUS_OK;
goto done;
@@ -2002,13 +2004,13 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid, const
DEBUG(3,("copying printers\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* enum printers */
- if (!get_printer_info(cli, mem_ctx, 2, argc, argv, &num_printers, &ctr_enum)) {
+ if (!get_printer_info(cli, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
@@ -2169,7 +2171,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const
DEBUG(3,("copying printer settings\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;