From 4f62ab5b2f3ca829ed71a224d89d45b632fad10c Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 21 Sep 2005 14:43:14 +0000 Subject: [PATCH] r10391: * setting version to 3.0.20a * adding patches from www.samba.org/samba/patches --- examples/VFS/skel_opaque.c | 12 ++++++------ examples/VFS/skel_transparent.c | 12 ++++++------ source/VERSION | 2 +- source/client/client.c | 10 +++++----- source/client/smbspool.c | 6 ++++-- source/configure.in | 16 +++++++++++++++- source/include/includes.h | 12 ++++++++++++ source/include/rpc_reg.h | 7 +++++-- source/include/vfs.h | 15 ++++++++------- source/lib/system.c | 16 ++++++++-------- source/modules/vfs_audit.c | 6 +++--- source/modules/vfs_cap.c | 4 ++-- source/modules/vfs_catia.c | 4 ++-- source/modules/vfs_extd_audit.c | 6 +++--- source/modules/vfs_full_audit.c | 26 ++++++++++++------------- source/modules/vfs_netatalk.c | 10 +++++----- source/modules/vfs_shadow_copy.c | 18 +++++++++--------- source/nsswitch/winbindd_dual.c | 6 ++---- source/nsswitch/winbindd_group.c | 4 +++- source/nsswitch/winbindd_user.c | 5 ++++- source/nsswitch/winbindd_util.c | 2 ++ source/passdb/pdb_ldap.c | 29 ++++++++++++++-------------- source/printing/nt_printing.c | 3 ++- source/registry/reg_db.c | 14 ++++++++++---- source/rpc_parse/parse_reg.c | 32 ++++++++++++++++++++++--------- source/rpc_parse/parse_shutdown.c | 18 ++++++++++++++++-- source/rpc_server/srv_samr_nt.c | 40 +++++++++++++++++++++++++++++++-------- source/script/mkproto.awk | 2 +- source/smbd/chgpasswd.c | 8 ++++---- source/smbd/dir.c | 9 +++++++-- source/smbd/msdfs.c | 2 +- source/smbd/open.c | 2 +- source/smbd/reply.c | 2 +- source/smbd/vfs-wrap.c | 14 +++++++------- 34 files changed, 238 insertions(+), 136 deletions(-) diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index a3aab55c3ea..065c9ecbc1a 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -71,27 +71,27 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fs return vfswrap_get_shadow_copy_data(NULL, fsp, shadow_copy_data, labels); } -static DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { return vfswrap_opendir(NULL, conn, fname, mask, attr); } -static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { return vfswrap_readdir(NULL, conn, dirp); } -static void skel_seekdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp, long offset) +static void skel_seekdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp, long offset) { return vfswrap_seekdir(NULL, conn, dirp, offset); } -static long skel_telldir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static long skel_telldir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { return vfswrap_telldir(NULL, conn, dirp); } -static void skel_rewinddir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static void skel_rewinddir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { return vfswrap_rewinddir(NULL, conn, dirp); } @@ -106,7 +106,7 @@ static int skel_rmdir(vfs_handle_struct *handle, connection_struct *conn, const return vfswrap_rmdir(NULL, conn, path); } -static int skel_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *dir) +static int skel_closedir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dir) { return vfswrap_closedir(NULL, conn, dir); } diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index 81069765d0e..0879683fdcd 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -70,27 +70,27 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fs return SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data, labels); } -static DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +static SMB_STRUCT_DIR *skel_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { return SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr); } -static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static SMB_STRUCT_DIRENT *skel_readdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { return SMB_VFS_NEXT_READDIR(handle, conn, dirp); } -static void skel_seekdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp, long offset) +static void skel_seekdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp, long offset) { return SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset); } -static long skel_telldir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static long skel_telldir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { return SMB_VFS_NEXT_TELLDIR(handle, conn, dirp); } -static void skel_rewinddir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static void skel_rewinddir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { return SMB_VFS_NEXT_REWINDDIR(handle, conn, dirp); } @@ -105,7 +105,7 @@ static int skel_rmdir(vfs_handle_struct *handle, connection_struct *conn, const return SMB_VFS_NEXT_RMDIR(handle, conn, path); } -static int skel_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *dir) +static int skel_closedir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dir) { return SMB_VFS_NEXT_CLOSEDIR(handle, conn, dir); } diff --git a/source/VERSION b/source/VERSION index 66e04052693..e8b23731ecc 100644 --- a/source/VERSION +++ b/source/VERSION @@ -31,7 +31,7 @@ SAMBA_VERSION_RELEASE=20 # e.g. SAMBA_VERSION_REVISION=a # # -> "2.2.8a" # ######################################################## -SAMBA_VERSION_REVISION= +SAMBA_VERSION_REVISION=a ######################################################## # For 'pre' releases the version will be # diff --git a/source/client/client.c b/source/client/client.c index d22f1245fac..61c4c8e4beb 100644 --- a/source/client/client.c +++ b/source/client/client.c @@ -1379,7 +1379,7 @@ static int cmd_select(void) static int file_find(struct file_list **list, const char *directory, const char *expression, BOOL match) { - DIR *dir; + SMB_STRUCT_DIR *dir; struct file_list *entry; struct stat statbuf; int ret; @@ -1387,7 +1387,7 @@ static int file_find(struct file_list **list, const char *directory, BOOL isdir; const char *dname; - dir = opendir(directory); + dir = sys_opendir(directory); if (!dir) return -1; @@ -1416,14 +1416,14 @@ static int file_find(struct file_list **list, const char *directory, if (ret == -1) { SAFE_FREE(path); - closedir(dir); + sys_closedir(dir); return -1; } } entry = SMB_MALLOC_P(struct file_list); if (!entry) { d_printf("Out of memory in file_find\n"); - closedir(dir); + sys_closedir(dir); return -1; } entry->file_path = path; @@ -1434,7 +1434,7 @@ static int file_find(struct file_list **list, const char *directory, } } - closedir(dir); + sys_closedir(dir); return 0; } diff --git a/source/client/smbspool.c b/source/client/smbspool.c index 16b071af193..b1c17a26fcd 100644 --- a/source/client/smbspool.c +++ b/source/client/smbspool.c @@ -288,7 +288,7 @@ list_devices(void) static char * get_ticket_cache( uid_t uid ) { - DIR *tcdir; /* directory where ticket caches are stored */ + SMB_STRUCT_DIR *tcdir; /* directory where ticket caches are stored */ SMB_STRUCT_DIRENT *dirent; /* directory entry */ char *filename = NULL; /* holds file names on the tmp directory */ SMB_STRUCT_STAT buf; @@ -298,7 +298,7 @@ char * get_ticket_cache( uid_t uid ) time_t t = 0; snprintf(user_cache_prefix, CC_MAX_FILE_LEN, "%s%d", CC_PREFIX, uid ); - tcdir = opendir( TICKET_CC_DIR ); + tcdir = sys_opendir( TICKET_CC_DIR ); if ( tcdir == NULL ) return NULL; @@ -331,6 +331,8 @@ char * get_ticket_cache( uid_t uid ) } } + sys_closedir(tcdir); + if ( ticket_file == NULL ) { /* no ticket cache found */ diff --git a/source/configure.in b/source/configure.in index 1ce4394ec8a..40a681f5671 100644 --- a/source/configure.in +++ b/source/configure.in @@ -1089,8 +1089,9 @@ AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent) AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath) AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64) -AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64) +AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64) AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf) +AC_CHECK_FUNCS(opendir64 readdir64 seekdir64 telldir64 rewinddir64 closedir64) AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink) AC_CHECK_FUNCS(syslog vsyslog timegm) AC_CHECK_FUNCS(setlocale nl_langinfo) @@ -1594,6 +1595,19 @@ if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available]) fi +AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIR64,[ +AC_TRY_COMPILE([ +#if defined(HAVE_UNISTD_H) +#include +#endif +#include +#include ], +[DIR64 de;], +samba_cv_HAVE_STRUCT_DIR64=yes,samba_cv_HAVE_STRUCT_DIR64=no)]) +if test x"$samba_cv_HAVE_STRUCT_DIR64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then + AC_DEFINE(HAVE_STRUCT_DIR64,1,[Whether the 'DIR64' abstract data type is available]) +fi + AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[ AC_TRY_COMPILE([ #if defined(HAVE_UNISTD_H) diff --git a/source/include/includes.h b/source/include/includes.h index 6cab2525b00..c9208d2b259 100644 --- a/source/include/includes.h +++ b/source/include/includes.h @@ -744,6 +744,18 @@ typedef int socklen_t; #endif /* + * Type for DIR structure. + */ + +#ifndef SMB_STRUCT_DIR +# if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_STRUCT_DIR64) +# define SMB_STRUCT_DIR DIR64 +# else +# define SMB_STRUCT_DIR DIR +# endif +#endif + +/* * Defines for 64 bit fcntl locks. */ diff --git a/source/include/rpc_reg.h b/source/include/rpc_reg.h index bbbb1acf8c1..f6ddf5b9adf 100644 --- a/source/include/rpc_reg.h +++ b/source/include/rpc_reg.h @@ -217,14 +217,17 @@ typedef struct { POLICY_HND handle; UNISTR4 name; UNISTR4 key_class; - uint32 reserved; + uint32 options; uint32 access; + + /* FIXME! collapse all this into one structure */ uint32 *sec_info; uint32 ptr2; BUFHDR hdr_sec; uint32 ptr3; SEC_DESC_BUF *data; - uint32 unknown_2; /* 0x0000 0000 */ + + uint32 *disposition; } REG_Q_CREATE_KEY_EX; typedef struct { diff --git a/source/include/vfs.h b/source/include/vfs.h index c7c7575d904..3bd0fda9a43 100644 --- a/source/include/vfs.h +++ b/source/include/vfs.h @@ -59,7 +59,8 @@ /* Changed to version 12 to add mask and attributes to opendir(). JRA Also include aio calls. JRA. */ /* Changed to version 13 as the internal structure of files_struct has changed. JRA */ -#define SMB_VFS_INTERFACE_VERSION 13 +/* Changed to version 14 as the we had to change DIR to SMB_STRUCT_DIR. JRA */ +#define SMB_VFS_INTERFACE_VERSION 14 /* to bug old modules which are trying to compile with the old functions */ @@ -224,14 +225,14 @@ struct vfs_ops { /* Directory operations */ - DIR *(*opendir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attributes); - SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); - void (*seekdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp, long offset); - long (*telldir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); - void (*rewind_dir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dirp); + SMB_STRUCT_DIR *(*opendir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attributes); + SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *dirp); + void (*seekdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *dirp, long offset); + long (*telldir)(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *dirp); + void (*rewind_dir)(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *dirp); int (*mkdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, mode_t mode); int (*rmdir)(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path); - int (*closedir)(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *dir); + int (*closedir)(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *dir); /* File operations */ diff --git a/source/lib/system.c b/source/lib/system.c index 2565f92c668..caad95840c6 100644 --- a/source/lib/system.c +++ b/source/lib/system.c @@ -366,7 +366,7 @@ FILE *sys_fopen(const char *path, const char *type) An opendir wrapper that will deal with 64 bit filesizes. ********************************************************************/ -DIR *sys_opendir(const char *name) +SMB_STRUCT_DIR *sys_opendir(const char *name) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OPENDIR64) return opendir64(name); @@ -379,7 +379,7 @@ DIR *sys_opendir(const char *name) A readdir wrapper that will deal with 64 bit filesizes. ********************************************************************/ -SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp) +SMB_STRUCT_DIRENT *sys_readdir(SMB_STRUCT_DIR *dirp) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64) return readdir64(dirp); @@ -392,7 +392,7 @@ SMB_STRUCT_DIRENT *sys_readdir(DIR *dirp) A seekdir wrapper that will deal with 64 bit filesizes. ********************************************************************/ -void sys_seekdir(DIR *dirp, long offset) +void sys_seekdir(SMB_STRUCT_DIR *dirp, long offset) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_SEEKDIR64) seekdir64(dirp, offset); @@ -405,7 +405,7 @@ void sys_seekdir(DIR *dirp, long offset) A telldir wrapper that will deal with 64 bit filesizes. ********************************************************************/ -long sys_telldir(DIR *dirp) +long sys_telldir(SMB_STRUCT_DIR *dirp) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_TELLDIR64) return (long)telldir64(dirp); @@ -418,7 +418,7 @@ long sys_telldir(DIR *dirp) A rewinddir wrapper that will deal with 64 bit filesizes. ********************************************************************/ -void sys_rewinddir(DIR *dirp) +void sys_rewinddir(SMB_STRUCT_DIR *dirp) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_REWINDDIR64) rewinddir64(dirp); @@ -431,7 +431,7 @@ void sys_rewinddir(DIR *dirp) A close wrapper that will deal with 64 bit filesizes. ********************************************************************/ -int sys_closedir(DIR *dirp) +int sys_closedir(SMB_STRUCT_DIR *dirp) { #if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_CLOSEDIR64) return closedir64(dirp); @@ -960,7 +960,7 @@ FILE *wsys_fopen(const smb_ucs2_t *wfname, const char *type) Wide opendir. Just narrow and call sys_xxx. ****************************************************************************/ -DIR *wsys_opendir(const smb_ucs2_t *wfname) +SMB_STRUCT_DIR *wsys_opendir(const smb_ucs2_t *wfname) { pstring fname; return opendir(unicode_to_unix(fname,wfname,sizeof(fname))); @@ -970,7 +970,7 @@ DIR *wsys_opendir(const smb_ucs2_t *wfname) Wide readdir. Return a structure pointer containing a wide filename. ****************************************************************************/ -SMB_STRUCT_WDIRENT *wsys_readdir(DIR *dirp) +SMB_STRUCT_WDIRENT *wsys_readdir(SMB_STRUCT_DIR *dirp) { static SMB_STRUCT_WDIRENT retval; SMB_STRUCT_DIRENT *dirval = sys_readdir(dirp); diff --git a/source/modules/vfs_audit.c b/source/modules/vfs_audit.c index 952cb1eddf6..7d97962db04 100644 --- a/source/modules/vfs_audit.c +++ b/source/modules/vfs_audit.c @@ -31,7 +31,7 @@ static int audit_connect(vfs_handle_struct *handle, connection_struct *conn, const char *svc, const char *user); static void audit_disconnect(vfs_handle_struct *handle, connection_struct *conn); -static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr); +static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr); static int audit_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode); static int audit_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path); static int audit_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode); @@ -119,9 +119,9 @@ static void audit_disconnect(vfs_handle_struct *handle, connection_struct *conn) return; } -static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { - DIR *result; + SMB_STRUCT_DIR *result; result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr); diff --git a/source/modules/vfs_cap.c b/source/modules/vfs_cap.c index 6ee63a577d1..b1bfcd75f2f 100644 --- a/source/modules/vfs_cap.c +++ b/source/modules/vfs_cap.c @@ -38,14 +38,14 @@ static SMB_BIG_UINT cap_disk_free(vfs_handle_struct *handle, connection_struct * dfree, dsize); } -static DIR *cap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +static SMB_STRUCT_DIR *cap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { pstring capname; capencode(capname, fname); return SMB_VFS_NEXT_OPENDIR(handle, conn, capname, mask, attr); } -static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { SMB_STRUCT_DIRENT *result; DEBUG(3,("cap: cap_readdir\n")); diff --git a/source/modules/vfs_catia.c b/source/modules/vfs_catia.c index d4420884ddd..69735de3f43 100644 --- a/source/modules/vfs_catia.c +++ b/source/modules/vfs_catia.c @@ -71,7 +71,7 @@ static void to_unix(char *s) catia_string_replace(s, '\xb1', ' '); } -static DIR *catia_opendir(vfs_handle_struct *handle, connection_struct +static SMB_STRUCT_DIR *catia_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { pstring name; @@ -82,7 +82,7 @@ static DIR *catia_opendir(vfs_handle_struct *handle, connection_struct } static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle, - connection_struct *conn, DIR *dirp) + connection_struct *conn, SMB_STRUCT_DIR *dirp) { SMB_STRUCT_DIRENT *result = SMB_VFS_NEXT_READDIR(handle, conn, dirp); diff --git a/source/modules/vfs_extd_audit.c b/source/modules/vfs_extd_audit.c index e3b90b293b6..d7bb9805851 100644 --- a/source/modules/vfs_extd_audit.c +++ b/source/modules/vfs_extd_audit.c @@ -34,7 +34,7 @@ static int vfs_extd_audit_debug_level = DBGC_VFS; static int audit_connect(vfs_handle_struct *handle, connection_struct *conn, const char *svc, const char *user); static void audit_disconnect(vfs_handle_struct *handle, connection_struct *conn); -static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr); +static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr); static int audit_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode); static int audit_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path); static int audit_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode); @@ -125,9 +125,9 @@ static void audit_disconnect(vfs_handle_struct *handle, connection_struct *conn) return; } -static DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { - DIR *result; + SMB_STRUCT_DIR *result; result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr); diff --git a/source/modules/vfs_full_audit.c b/source/modules/vfs_full_audit.c index aa9e047f0ae..d79e2e8f1cc 100644 --- a/source/modules/vfs_full_audit.c +++ b/source/modules/vfs_full_audit.c @@ -86,22 +86,22 @@ static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels); -static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn, +static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr); static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, - connection_struct *conn, DIR *dirp); + connection_struct *conn, SMB_STRUCT_DIR *dirp); static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp, long offset); + SMB_STRUCT_DIR *dirp, long offset); static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp); + SMB_STRUCT_DIR *dirp); static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp); + SMB_STRUCT_DIR *dirp); static int smb_full_audit_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode); static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path); static int smb_full_audit_closedir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp); + SMB_STRUCT_DIR *dirp); static int smb_full_audit_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode); static int smb_full_audit_close(vfs_handle_struct *handle, files_struct *fsp, int fd); @@ -845,10 +845,10 @@ static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, return result; } -static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn, +static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { - DIR *result; + SMB_STRUCT_DIR *result; result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr); @@ -858,7 +858,7 @@ static DIR *smb_full_audit_opendir(vfs_handle_struct *handle, connection_struct } static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, - connection_struct *conn, DIR *dirp) + connection_struct *conn, SMB_STRUCT_DIR *dirp) { SMB_STRUCT_DIRENT *result; @@ -873,7 +873,7 @@ static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, } static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp, long offset) + SMB_STRUCT_DIR *dirp, long offset) { SMB_VFS_NEXT_SEEKDIR(handle, conn, dirp, offset); @@ -882,7 +882,7 @@ static void smb_full_audit_seekdir(vfs_handle_struct *handle, connection_struct } static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp) + SMB_STRUCT_DIR *dirp) { long result; @@ -894,7 +894,7 @@ static long smb_full_audit_telldir(vfs_handle_struct *handle, connection_struct } static void smb_full_audit_rewinddir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp) + SMB_STRUCT_DIR *dirp) { SMB_VFS_NEXT_REWINDDIR(handle, conn, dirp); @@ -927,7 +927,7 @@ static int smb_full_audit_rmdir(vfs_handle_struct *handle, connection_struct *co } static int smb_full_audit_closedir(vfs_handle_struct *handle, connection_struct *conn, - DIR *dirp) + SMB_STRUCT_DIR *dirp) { int result; diff --git a/source/modules/vfs_netatalk.c b/source/modules/vfs_netatalk.c index 02ce5300ae7..e9d4360cd80 100644 --- a/source/modules/vfs_netatalk.c +++ b/source/modules/vfs_netatalk.c @@ -148,11 +148,11 @@ static void atalk_rrmdir(TALLOC_CTX *ctx, char *path) { char *dpath; SMB_STRUCT_DIRENT *dent = 0; - DIR *dir; + SMB_STRUCT_DIR *dir; if (!path) return; - dir = opendir(path); + dir = sys_opendir(path); if (!dir) return; while (NULL != (dent = sys_readdir(dir))) { @@ -165,16 +165,16 @@ static void atalk_rrmdir(TALLOC_CTX *ctx, char *path) atalk_unlink_file(dpath); } - closedir(dir); + sys_closedir(dir); } /* Disk operations */ /* Directory operations */ -DIR *atalk_opendir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attr) +SMB_STRUCT_DIR *atalk_opendir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *fname, const char *mask, uint32 attr) { - DIR *ret = 0; + SMB_STRUCT_DIR *ret = 0; ret = SMB_VFS_NEXT_OPENDIR(handle, conn, fname, mask, attr); diff --git a/source/modules/vfs_shadow_copy.c b/source/modules/vfs_shadow_copy.c index 005e2f1fbae..8bb4598ea3d 100644 --- a/source/modules/vfs_shadow_copy.c +++ b/source/modules/vfs_shadow_copy.c @@ -72,10 +72,10 @@ static BOOL shadow_copy_match_name(const char *name) return False; } -static DIR *shadow_copy_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +static SMB_STRUCT_DIR *shadow_copy_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { shadow_copy_Dir *dirp; - DIR *p = SMB_VFS_NEXT_OPENDIR(handle,conn,fname,mask,attr); + SMB_STRUCT_DIR *p = SMB_VFS_NEXT_OPENDIR(handle,conn,fname,mask,attr); if (!p) { DEBUG(0,("shadow_copy_opendir: SMB_VFS_NEXT_OPENDIR() failed for [%s]\n",fname)); @@ -119,10 +119,10 @@ static DIR *shadow_copy_opendir(vfs_handle_struct *handle, connection_struct *co } SMB_VFS_NEXT_CLOSEDIR(handle,conn,p); - return((DIR *)dirp); + return((SMB_STRUCT_DIR *)dirp); } -SMB_STRUCT_DIRENT *shadow_copy_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *_dirp) +SMB_STRUCT_DIRENT *shadow_copy_readdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *_dirp) { shadow_copy_Dir *dirp = (shadow_copy_Dir *)_dirp; @@ -133,7 +133,7 @@ SMB_STRUCT_DIRENT *shadow_copy_readdir(vfs_handle_struct *handle, connection_str return NULL; } -static void shadow_copy_seekdir(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *_dirp, long offset) +static void shadow_copy_seekdir(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *_dirp, long offset) { shadow_copy_Dir *dirp = (shadow_copy_Dir *)_dirp; @@ -142,19 +142,19 @@ static void shadow_copy_seekdir(struct vfs_handle_struct *handle, struct connect } } -static long shadow_copy_telldir(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *_dirp) +static long shadow_copy_telldir(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *_dirp) { shadow_copy_Dir *dirp = (shadow_copy_Dir *)_dirp; return( dirp->pos ) ; } -static void shadow_copy_rewinddir(struct vfs_handle_struct *handle, struct connection_struct *conn, DIR *_dirp) +static void shadow_copy_rewinddir(struct vfs_handle_struct *handle, struct connection_struct *conn, SMB_STRUCT_DIR *_dirp) { shadow_copy_Dir *dirp = (shadow_copy_Dir *)_dirp; dirp->pos = 0 ; } -int shadow_copy_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *_dirp) +int shadow_copy_closedir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *_dirp) { shadow_copy_Dir *dirp = (shadow_copy_Dir *)_dirp; @@ -166,7 +166,7 @@ int shadow_copy_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, BOOL labels) { - DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn,fsp->conn->connectpath,NULL,0); + SMB_STRUCT_DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn,fsp->conn->connectpath,NULL,0); shadow_copy_data->num_volumes = 0; shadow_copy_data->labels = NULL; diff --git a/source/nsswitch/winbindd_dual.c b/source/nsswitch/winbindd_dual.c index d4bcf4e3841..c55b5914d25 100644 --- a/source/nsswitch/winbindd_dual.c +++ b/source/nsswitch/winbindd_dual.c @@ -158,7 +158,6 @@ static void async_reply_recv(void *private_data, BOOL success) return; } - if (state->response->result == WINBINDD_OK) SMB_ASSERT(cache_retrieve_response(child->pid, state->response)); @@ -486,12 +485,11 @@ static BOOL fork_domain_child(struct winbindd_child *child) DEBUG(4,("child daemon request %d\n", (int)state.request.cmd)); + ZERO_STRUCT(state.response); state.request.null_term = '\0'; child_process_request(child->domain, &state); - if (state.response.result == WINBINDD_OK) - cache_store_response(sys_getpid(), - &state.response); + cache_store_response(sys_getpid(), &state.response); SAFE_FREE(state.response.extra_data); diff --git a/source/nsswitch/winbindd_group.c b/source/nsswitch/winbindd_group.c index eb2adde98bd..cc8af6adcf6 100644 --- a/source/nsswitch/winbindd_group.c +++ b/source/nsswitch/winbindd_group.c @@ -1148,7 +1148,9 @@ enum winbindd_result winbindd_dual_getuserdomgroups(struct winbindd_domain *doma DOM_SID user_sid; NTSTATUS status; - int i, num_groups, len, bufsize; + int i, num_groups; + size_t bufsize; + ssize_t len; DOM_SID *groups; /* Ensure null termination */ diff --git a/source/nsswitch/winbindd_user.c b/source/nsswitch/winbindd_user.c index ab5da3edd06..0b88d5eee5f 100644 --- a/source/nsswitch/winbindd_user.c +++ b/source/nsswitch/winbindd_user.c @@ -230,6 +230,7 @@ static void getpwsid_queryuser_recv(void *private_data, BOOL success, const char *shell, uint32 group_rid) { + fstring username; struct getpwsid_state *s = talloc_get_type_abort(private_data, struct getpwsid_state); @@ -240,7 +241,9 @@ static void getpwsid_queryuser_recv(void *private_data, BOOL success, return; } - s->username = talloc_strdup(s->state->mem_ctx, acct_name); + fstrcpy( username, acct_name ); + strlower_m( username ); + s->username = talloc_strdup(s->state->mem_ctx, username); s->fullname = talloc_strdup(s->state->mem_ctx, full_name); s->homedir = talloc_strdup(s->state->mem_ctx, homedir); s->shell = talloc_strdup(s->state->mem_ctx, shell); diff --git a/source/nsswitch/winbindd_util.c b/source/nsswitch/winbindd_util.c index 2be1520250a..fec29fa3ff2 100644 --- a/source/nsswitch/winbindd_util.c +++ b/source/nsswitch/winbindd_util.c @@ -444,7 +444,9 @@ enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domai state->request.data.init_conn.dcname [sizeof(state->request.data.init_conn.dcname)-1]='\0'; + if (strlen(state->request.data.init_conn.dcname) > 0) { fstrcpy(domain->dcname, state->request.data.init_conn.dcname); + } if (strlen(domain->dcname) > 0) { if (!resolve_name(domain->dcname, &ipaddr, 0x20)) { diff --git a/source/passdb/pdb_ldap.c b/source/passdb/pdb_ldap.c index ee7a1f5b4cb..99f6670653b 100644 --- a/source/passdb/pdb_ldap.c +++ b/source/passdb/pdb_ldap.c @@ -3692,23 +3692,24 @@ static BOOL ldapgroup2displayentry(struct ldap_search_state *state, return False; } - vals = ldap_get_values(ld, entry, "cn"); - if ((vals == NULL) || (vals[0] == NULL)) { - DEBUG(5, ("\"cn\" not found\n")); - return False; - } - pull_utf8_talloc(mem_ctx, - CONST_DISCARD(char **, &result->account_name), - vals[0]); - ldap_value_free(vals); + /* display name is the NT group name */ vals = ldap_get_values(ld, entry, "displayName"); - if ((vals == NULL) || (vals[0] == NULL)) + if ((vals == NULL) || (vals[0] == NULL)) { DEBUG(8, ("\"displayName\" not found\n")); - else - pull_utf8_talloc(mem_ctx, - CONST_DISCARD(char **, &result->fullname), - vals[0]); + + /* fallback to the 'cn' attribute */ + vals = ldap_get_values(ld, entry, "cn"); + if ((vals == NULL) || (vals[0] == NULL)) { + DEBUG(5, ("\"cn\" not found\n")); + return False; + } + pull_utf8_talloc(mem_ctx, CONST_DISCARD(char **, &result->account_name), vals[0]); + } + else { + pull_utf8_talloc(mem_ctx, CONST_DISCARD(char **, &result->account_name), vals[0]); + } + ldap_value_free(vals); vals = ldap_get_values(ld, entry, "description"); diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index f6e9e2306f5..7260cb3a581 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -342,7 +342,8 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key, SEC_DESC *sec, *new_sec; TALLOC_CTX *ctx = state; int result, i; - uint32 sd_size, size_new_sec; + uint32 sd_size; + size_t size_new_sec; DOM_SID sid; if (!data.dptr || data.dsize == 0) diff --git a/source/registry/reg_db.c b/source/registry/reg_db.c index 77525e884f0..888f7ca7357 100644 --- a/source/registry/reg_db.c +++ b/source/registry/reg_db.c @@ -49,6 +49,7 @@ static const char *builtin_registry_paths[] = { "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009", "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors", "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions", + "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server\\DefaultUserConfiguration", "HKLM\\SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters", "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters", "HKU", @@ -149,6 +150,11 @@ static BOOL init_registry_data( void ) regval_ctr_init( &values ); regdb_fetch_values( builtin_registry_values[i].path, &values ); + + /* preserve existing values across restarts. Only add new ones */ + + if ( !regval_ctr_key_exists( &values, builtin_registry_values[i].valuename ) ) + { switch( builtin_registry_values[i].type ) { case REG_DWORD: regval_ctr_addvalue( &values, @@ -172,6 +178,7 @@ static BOOL init_registry_data( void ) builtin_registry_values[i].type)); } regdb_store_values( builtin_registry_values[i].path, &values ); + } regval_ctr_destroy( &values ); } @@ -191,8 +198,6 @@ BOOL init_registry_db( void ) if ( tdb_reg ) return True; - /* placeholder tdb; reinit upon startup */ - if ( !(tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) ) { tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600); @@ -209,14 +214,15 @@ BOOL init_registry_db( void ) vers_id = tdb_fetch_int32(tdb_reg, vstring); if ( vers_id != REGVER_V1 ) { + /* any upgrade code here if needed */ + } - /* create the registry here */ + /* always setup the necessary keys and values */ if ( !init_registry_data() ) { DEBUG(0,("init_registry: Failed to initiailize data in registry!\n")); return False; } - } return True; } diff --git a/source/rpc_parse/parse_reg.c b/source/rpc_parse/parse_reg.c index 3d586b3779f..08eec9ee10c 100644 --- a/source/rpc_parse/parse_reg.c +++ b/source/rpc_parse/parse_reg.c @@ -227,7 +227,7 @@ void init_reg_q_create_key_ex(REG_Q_CREATE_KEY_EX *q_c, POLICY_HND *hnd, q_c->ptr2 = 1; init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len); q_c->ptr3 = 1; - q_c->unknown_2 = 0x00000000; + q_c->disposition = TALLOC_P( get_talloc_ctx(), uint32 ); } /******************************************************************* @@ -259,7 +259,7 @@ BOOL reg_io_q_create_key_ex(const char *desc, REG_Q_CREATE_KEY_EX *q_u, if(!prs_align(ps)) return False; - if(!prs_uint32("reserved", ps, depth, &q_u->reserved)) + if(!prs_uint32("options", ps, depth, &q_u->options)) return False; if(!prs_uint32("access", ps, depth, &q_u->access)) return False; @@ -267,16 +267,15 @@ BOOL reg_io_q_create_key_ex(const char *desc, REG_Q_CREATE_KEY_EX *q_u, if(!prs_pointer("sec_info", ps, depth, (void**)&q_u->sec_info, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; + if ( q_u->sec_info ) { if(!prs_uint32("ptr2", ps, depth, &q_u->ptr2)) return False; - if(!reg_io_hdrbuf_sec(q_u->ptr2, &q_u->ptr3, &q_u->hdr_sec, q_u->data, - ps, depth)) + if(!reg_io_hdrbuf_sec(q_u->ptr2, &q_u->ptr3, &q_u->hdr_sec, q_u->data, ps, depth)) return False; + } -#if 0 - if(!prs_uint32("unknown_2", ps, depth, &q_u->unknown_2)) + if(!prs_pointer("disposition", ps, depth, (void**)&q_u->disposition, sizeof(uint32), (PRS_POINTER_CAST)prs_uint32)) return False; -#endif return True; } @@ -1485,8 +1484,17 @@ void init_reg_q_shutdown(REG_Q_SHUTDOWN *q_u, const char *msg, q_u->server = TALLOC_P( get_talloc_ctx(), uint16 ); *q_u->server = 0x1; - q_u->message = TALLOC_P( get_talloc_ctx(), UNISTR4 ); - init_unistr4( q_u->message, msg, UNI_FLAGS_NONE ); + if ( msg && *msg ) { + q_u->message = TALLOC_P( get_talloc_ctx(), UNISTR4 ); + init_unistr4( q_u->message, msg, UNI_FLAGS_NONE ); + + /* Win2000 is apparently very sensitive to these lengths */ + /* do a special case here */ + + q_u->message->string->uni_max_len++; + q_u->message->size += 2; + + } q_u->timeout = timeout; @@ -1536,6 +1544,8 @@ BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN *q_u, prs_struct *ps, if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; + if (!prs_align(ps)) + return False; if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) return False; @@ -1594,6 +1604,8 @@ BOOL reg_io_q_shutdown_ex(const char *desc, REG_Q_SHUTDOWN_EX *q_u, prs_struct * if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; + if (!prs_align(ps)) + return False; if (!prs_pointer("message", ps, depth, (void**)&q_u->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) return False; @@ -1667,6 +1679,8 @@ BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN *q_u, if (!prs_pointer("server", ps, depth, (void**)&q_u->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; + if (!prs_align(ps)) + return False; return True; } diff --git a/source/rpc_parse/parse_shutdown.c b/source/rpc_parse/parse_shutdown.c index 00daeaaaee7..62c23a243c6 100644 --- a/source/rpc_parse/parse_shutdown.c +++ b/source/rpc_parse/parse_shutdown.c @@ -34,8 +34,16 @@ void init_shutdown_q_init(SHUTDOWN_Q_INIT *q_s, const char *msg, q_s->server = TALLOC_P( get_talloc_ctx(), uint16 ); *q_s->server = 0x1; - q_s->message = TALLOC_P( get_talloc_ctx(), UNISTR4 ); - init_unistr4( q_s->message, msg, UNI_FLAGS_NONE ); + if ( msg && *msg ) { + q_s->message = TALLOC_P( get_talloc_ctx(), UNISTR4 ); + init_unistr4( q_s->message, msg, UNI_FLAGS_NONE ); + + /* Win2000 is apparently very sensitive to these lengths */ + /* do a special case here */ + + q_s->message->string->uni_max_len++; + q_s->message->size += 2; + } q_s->timeout = timeout; @@ -84,6 +92,8 @@ BOOL shutdown_io_q_init(const char *desc, SHUTDOWN_Q_INIT *q_s, prs_struct *ps, if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; + if (!prs_align(ps)) + return False; if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) return False; @@ -142,6 +152,8 @@ BOOL shutdown_io_q_init_ex(const char *desc, SHUTDOWN_Q_INIT_EX * q_s, prs_struc if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; + if (!prs_align(ps)) + return False; if (!prs_pointer("message", ps, depth, (void**)&q_s->message, sizeof(UNISTR4), (PRS_POINTER_CAST)prs_unistr4)) return False; @@ -214,6 +226,8 @@ BOOL shutdown_io_q_abort(const char *desc, SHUTDOWN_Q_ABORT *q_s, if (!prs_pointer("server", ps, depth, (void**)&q_s->server, sizeof(uint16), (PRS_POINTER_CAST)prs_uint16)) return False; + if (!prs_align(ps)) + return False; return True; } diff --git a/source/rpc_server/srv_samr_nt.c b/source/rpc_server/srv_samr_nt.c index 1eb4b1236d0..2a3d351f67e 100644 --- a/source/rpc_server/srv_samr_nt.c +++ b/source/rpc_server/srv_samr_nt.c @@ -3927,6 +3927,8 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ GROUP_MAP map; GROUP_INFO_CTR *ctr; uint32 acc_granted; + BOOL ret; + BOOL can_mod_accounts; if (!get_lsa_policy_samr_sid(p, &q_u->pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -3951,11 +3953,21 @@ NTSTATUS _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!pdb_update_group_mapping_entry(&map)) { - return NT_STATUS_NO_SUCH_GROUP; - } + can_mod_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - return NT_STATUS_OK; + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_mod_accounts ) + become_root(); + + ret = pdb_update_group_mapping_entry(&map); + + if ( can_mod_accounts ) + unbecome_root(); + + /******** End SeAddUsers BLOCK *********/ + + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* @@ -3970,6 +3982,8 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ struct acct_info info; ALIAS_INFO_CTR *ctr; uint32 acc_granted; + BOOL ret; + BOOL can_mod_accounts; if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid, &acc_granted)) return NT_STATUS_INVALID_HANDLE; @@ -3992,11 +4006,21 @@ NTSTATUS _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_ return NT_STATUS_INVALID_INFO_CLASS; } - if(!pdb_set_aliasinfo(&group_sid, &info)) { - return NT_STATUS_ACCESS_DENIED; - } + can_mod_accounts = user_has_privileges( p->pipe_user.nt_user_token, &se_add_users ); - return NT_STATUS_OK; + /******** BEGIN SeAddUsers BLOCK *********/ + + if ( can_mod_accounts ) + become_root(); + + ret = pdb_set_aliasinfo( &group_sid, &info ); + + if ( can_mod_accounts ) + unbecome_root(); + + /******** End SeAddUsers BLOCK *********/ + + return ret ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED; } /********************************************************************* diff --git a/source/script/mkproto.awk b/source/script/mkproto.awk index 3c482675872..3940c34700a 100644 --- a/source/script/mkproto.awk +++ b/source/script/mkproto.awk @@ -136,7 +136,7 @@ END { gotstart = 1; } - if( $0 ~ /^NODE_STATUS_STRUCT/ ) { + if( $0 ~ /^NODE_STATUS_STRUCT|SMB_STRUCT_DIR/ ) { gotstart = 1; } diff --git a/source/smbd/chgpasswd.c b/source/smbd/chgpasswd.c index f445ca3365b..374c57a083a 100644 --- a/source/smbd/chgpasswd.c +++ b/source/smbd/chgpasswd.c @@ -64,7 +64,7 @@ static int findpty(char **slave) { int master; static fstring line; - DIR *dirp; + SMB_STRUCT_DIR *dirp; const char *dpname; #if defined(HAVE_GRANTPT) @@ -93,7 +93,7 @@ static int findpty(char **slave) fstrcpy(line, "/dev/ptyXX"); - dirp = opendir("/dev"); + dirp = sys_opendir("/dev"); if (!dirp) return (-1); while ((dpname = readdirname(dirp)) != NULL) @@ -110,12 +110,12 @@ static int findpty(char **slave) DEBUG(3, ("pty: opened %s\n", line)); line[5] = 't'; *slave = line; - closedir(dirp); + sys_closedir(dirp); return (master); } } } - closedir(dirp); + sys_closedir(dirp); return (-1); } diff --git a/source/smbd/dir.c b/source/smbd/dir.c index a0df924dc7c..11b1df347b5 100644 --- a/source/smbd/dir.c +++ b/source/smbd/dir.c @@ -42,7 +42,7 @@ struct name_cache_entry { struct smb_Dir { connection_struct *conn; - DIR *dir; + SMB_STRUCT_DIR *dir; long offset; char *dir_path; struct name_cache_entry *name_cache; @@ -1098,6 +1098,9 @@ const char *ReadDirName(struct smb_Dir *dirp, long *poffset) } dirp->file_number++; return n; + } else if (*poffset == END_OF_DIRECTORY_OFFSET) { + *poffset = dirp->offset = END_OF_DIRECTORY_OFFSET; + return NULL; } else { /* A real offset, seek to it. */ SeekDir(dirp, *poffset); @@ -1120,7 +1123,7 @@ const char *ReadDirName(struct smb_Dir *dirp, long *poffset) dirp->file_number++; return e->name; } - dirp->offset = END_OF_DIRECTORY_OFFSET; + *poffset = dirp->offset = END_OF_DIRECTORY_OFFSET; return NULL; } @@ -1145,6 +1148,8 @@ void SeekDir(struct smb_Dir *dirp, long offset) if (offset != dirp->offset) { if (offset == START_OF_DIRECTORY_OFFSET || offset == DOT_DOT_DIRECTORY_OFFSET) { RewindDir(dirp, &offset); + } else if (offset == END_OF_DIRECTORY_OFFSET) { + ; /* Don't seek in this case. */ } else { SMB_VFS_SEEKDIR(dirp->conn, dirp->dir, offset); } diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c index 2b13e2a4b5a..1e6306382aa 100644 --- a/source/smbd/msdfs.c +++ b/source/smbd/msdfs.c @@ -1010,7 +1010,7 @@ BOOL remove_msdfs_link(struct junction_map *jucn) static int form_junctions(TALLOC_CTX *ctx, int snum, struct junction_map *jucn, int jn_remain) { int cnt = 0; - DIR *dirp; + SMB_STRUCT_DIR *dirp; char* dname; pstring connect_path; char* service_name = lp_servicename(snum); diff --git a/source/smbd/open.c b/source/smbd/open.c index 3cd553f55b5..99a284832f3 100644 --- a/source/smbd/open.c +++ b/source/smbd/open.c @@ -1046,13 +1046,13 @@ BOOL map_open_params_to_ntcreate(const char *fname, int deny_mode, int open_func /* Create the NT compatible access_mask. */ switch (GET_OPENX_MODE(deny_mode)) { + case DOS_OPEN_EXEC: /* Implies read-only - used to be FILE_READ_DATA */ case DOS_OPEN_RDONLY: access_mask = FILE_GENERIC_READ; break; case DOS_OPEN_WRONLY: access_mask = FILE_GENERIC_WRITE; break; - case DOS_OPEN_EXEC: /* This used to be FILE_READ_DATA... */ case DOS_OPEN_RDWR: case DOS_OPEN_FCB: access_mask = FILE_GENERIC_READ|FILE_GENERIC_WRITE; diff --git a/source/smbd/reply.c b/source/smbd/reply.c index e96c3dc01ff..66ea5d64f87 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -1610,7 +1610,7 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, create_disposition = FILE_CREATE; } else { /* Create if file doesn't exist, truncate if it does. */ - create_disposition = FILE_OPEN_IF; + create_disposition = FILE_OVERWRITE_IF; } /* Open file using ntcreate. */ diff --git a/source/smbd/vfs-wrap.c b/source/smbd/vfs-wrap.c index 39ac402f346..2129cf85417 100644 --- a/source/smbd/vfs-wrap.c +++ b/source/smbd/vfs-wrap.c @@ -88,9 +88,9 @@ int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_ /* Directory operations */ -DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) +SMB_STRUCT_DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname, const char *mask, uint32 attr) { - DIR *result; + SMB_STRUCT_DIR *result; START_PROFILE(syscall_opendir); result = sys_opendir(fname); @@ -98,7 +98,7 @@ DIR *vfswrap_opendir(vfs_handle_struct *handle, connection_struct *conn, const c return result; } -SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { SMB_STRUCT_DIRENT *result; @@ -108,14 +108,14 @@ SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle, connection_struct return result; } -void vfswrap_seekdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp, long offset) +void vfswrap_seekdir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp, long offset) { START_PROFILE(syscall_seekdir); sys_seekdir(dirp, offset); END_PROFILE(syscall_seekdir); } -long vfswrap_telldir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +long vfswrap_telldir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { long result; START_PROFILE(syscall_telldir); @@ -124,7 +124,7 @@ long vfswrap_telldir(vfs_handle_struct *handle, connection_struct *conn, DIR *di return result; } -void vfswrap_rewinddir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +void vfswrap_rewinddir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { START_PROFILE(syscall_rewinddir); sys_rewinddir(dirp); @@ -170,7 +170,7 @@ int vfswrap_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char return result; } -int vfswrap_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) +int vfswrap_closedir(vfs_handle_struct *handle, connection_struct *conn, SMB_STRUCT_DIR *dirp) { int result; -- 2.11.4.GIT