From f95c1bb38b174b6c5901efc4291706c230d3bdcb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 10 Dec 2003 04:34:09 +0000 Subject: sync source for 3.0.1rc2 --- source/Makefile.in | 18 ++++++++++------ source/VERSION | 2 +- source/auth/auth_util.c | 20 +++++++++++++++--- source/configure.in | 32 ++++++++++++++++++++++++++-- source/lib/access.c | 2 +- source/lib/substitute.c | 7 ++++++ source/lib/util.c | 24 ++++++++++++--------- source/lib/util_sock.c | 14 +++++++++--- source/libsmb/namequery.c | 4 ++-- source/rpc_parse/parse_net.c | 8 +++---- source/rpcclient/cmd_spoolss.c | 2 +- source/smbd/sesssetup.c | 48 ++++++++++++++++++++++++++++++++++-------- source/tdb/spinlock.c | 45 +++++++++++++++++++++++++++++++++++++++ 13 files changed, 183 insertions(+), 43 deletions(-) diff --git a/source/Makefile.in b/source/Makefile.in index 7ac07dbad72..e1087b9eb58 100644 --- a/source/Makefile.in +++ b/source/Makefile.in @@ -9,7 +9,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ -mandir=@mandir@ LIBS=@LIBS@ CC=@CC@ @@ -1244,6 +1243,7 @@ installswat: installdirs installmsg @$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)$(SWATDIR) $(srcdir) installclientlib: installdirs libsmbclient + @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)${prefix}/lib -$(INSTALLCLIENTCMD_SH) bin/libsmbclient.@SHLIBEXT@ $(DESTDIR)${prefix}/lib -$(INSTALLCLIENTCMD_A) bin/libsmbclient.a $(DESTDIR)${prefix}/lib @$(SHELL) $(srcdir)/script/installdirs.sh $(DESTDIR)${prefix}/include @@ -1292,12 +1292,16 @@ installman: installdirs showlayout: @echo "Samba will be installed into:" - @echo " basedir: $(BASEDIR)" - @echo " bindir: $(BINDIR)" - @echo " sbindir: $(SBINDIR)" - @echo " libdir: $(LIBDIR)" - @echo " vardir: $(VARDIR)" - @echo " mandir: $(MANDIR)" + @echo " basedir: $(BASEDIR)" + @echo " bindir: $(BINDIR)" + @echo " sbindir: $(SBINDIR)" + @echo " libdir: $(LIBDIR)" + @echo " vardir: $(VARDIR)" + @echo " mandir: $(MANDIR)" + @echo " privatedir: $(PRIVATE_DIR)" + @echo " configdir: $(CONFIGDIR)" + @echo " lockdir: $(LOCKDIR)" + @echo " piddir: $(PIDDIR)" uninstall: uninstallman uninstallbin uninstallscripts uninstallmodules diff --git a/source/VERSION b/source/VERSION index d727326a6ac..24e340b7b3b 100644 --- a/source/VERSION +++ b/source/VERSION @@ -51,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 ######################################################## # For 'beta' releases the version will be # diff --git a/source/auth/auth_util.c b/source/auth/auth_util.c index 5d3f8f02777..3dc0fdbe464 100644 --- a/source/auth/auth_util.c +++ b/source/auth/auth_util.c @@ -965,7 +965,7 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx, struct passwd *smb_getpwnam( char *domuser ) { - struct passwd *pw; + struct passwd *pw = NULL; char *p; fstring mapped_username; @@ -981,10 +981,24 @@ struct passwd *smb_getpwnam( char *domuser ) p += 1; fstrcpy( mapped_username, p ); map_username( mapped_username ); - return Get_Pwnam(mapped_username); + pw = Get_Pwnam(mapped_username); + if (!pw) { + /* Don't add a machine account. */ + if (mapped_username[strlen(mapped_username)-1] == '$') + return NULL; + + /* Create local user if requested. */ + p = strchr( mapped_username, *lp_winbind_separator() ); + if (p) + p += 1; + else + p = mapped_username; + auth_add_user_script(NULL, p); + return Get_Pwnam(p); + } } - return NULL; + return pw; } /*************************************************************************** diff --git a/source/configure.in b/source/configure.in index 174a48b87e3..15defbe8f12 100644 --- a/source/configure.in +++ b/source/configure.in @@ -17,8 +17,9 @@ AC_PREFIX_DEFAULT(/usr/local/samba) AC_ARG_WITH(fhs, [ --with-fhs Use FHS-compliant paths (default=no)], configdir="${sysconfdir}/samba" - lockdir="\${VARDIR}/cache/samba" - piddir="\${VARDIR}/run/samba" + lockdir="\${VARDIR}/lib/samba" + piddir="\${VARDIR}/run" + mandir="\${prefix}/share/man" logfilebase="\${VARDIR}/log/samba" privatedir="\${CONFIGDIR}/private" libdir="\${prefix}/lib/samba" @@ -27,6 +28,7 @@ AC_ARG_WITH(fhs, logfilebase="\${VARDIR}" lockdir="\${VARDIR}/locks" piddir="\${VARDIR}/locks" + mandir="\${prefix}/man" privatedir="\${prefix}/private" swatdir="\${prefix}/swat") @@ -78,6 +80,23 @@ AC_ARG_WITH(piddir, ;; esac]) +################################################# +# set pid directory location +AC_ARG_WITH(piddir, +[ --with-mandir=DIR Where to put man pages ($ac_default_prefix/man)], +[ case "$withval" in + yes|no) + # + # Just in case anybody calls it without argument + # + AC_MSG_WARN([--with-mandir called without argument - will use default]) + ;; + * ) + piddir="$withval" + ;; + esac]) + + ################################################# # set SWAT directory location AC_ARG_WITH(swatdir, @@ -148,6 +167,7 @@ done AC_SUBST(configdir) AC_SUBST(lockdir) AC_SUBST(piddir) +AC_SUBST(mandir) AC_SUBST(logfilebase) AC_SUBST(privatedir) AC_SUBST(swatdir) @@ -1993,6 +2013,14 @@ if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available]) fi +AC_CACHE_CHECK([for sysconf(_SC_NPROC_ONLN)],samba_cv_SYSCONF_SC_NPROC_ONLN,[ +AC_TRY_RUN([#include +main() { exit(sysconf(_SC_NPROC_ONLN) == -1 ? 1 : 0); }], +samba_cv_SYSCONF_SC_NPROC_ONLN=yes,samba_cv_SYSCONF_SC_NPROC_ONLN=no,samba_cv_SYSCONF_SC_NPROC_ONLN=cross)]) +if test x"$samba_cv_SYSCONF_SC_NPROC_ONLN" = x"yes"; then + AC_DEFINE(SYSCONF_SC_NPROC_ONLN,1,[Whether sysconf(_SC_NPROC_ONLN) is available]) +fi + AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[ AC_TRY_RUN([main() { exit(getuid() != 0); }], samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)]) diff --git a/source/lib/access.c b/source/lib/access.c index 81eab7c738e..f03f5daf333 100644 --- a/source/lib/access.c +++ b/source/lib/access.c @@ -43,7 +43,7 @@ static BOOL masked_match(const char *tok, const char *slash, const char *s) return (False); } - return ((addr & mask) == net); + return ((addr & mask) == (net & mask)); } /* string_match - match string against token */ diff --git a/source/lib/substitute.c b/source/lib/substitute.c index ee342964d0f..5dec9808101 100644 --- a/source/lib/substitute.c +++ b/source/lib/substitute.c @@ -494,6 +494,13 @@ char *alloc_sub_basic(const char *smb_name, const char *str) struct passwd *pass; const char *local_machine_name = get_local_machine_name(); + /* workaround to prevent a crash while lookinf at bug #687 */ + + if ( !str ) { + DEBUG(0,("alloc_sub_basic: NULL source string! This should not happen\n")); + return NULL; + } + a_string = strdup(str); if (a_string == NULL) { DEBUG(0, ("alloc_sub_specified: Out of memory!\n")); diff --git a/source/lib/util.c b/source/lib/util.c index 39515c65991..4f4e0eb5d7b 100644 --- a/source/lib/util.c +++ b/source/lib/util.c @@ -1751,13 +1751,15 @@ BOOL is_myworkgroup(const char *s) Win2k => "Windows 2000 5.0" NT4 => "Windows NT 4.0" Win9x => "Windows 4.0" + Windows 2003 doesn't set the native lan manager string but + they do set the domain to "Windows 2003 5.2" (probably a bug). ********************************************************************/ void ra_lanman_string( const char *native_lanman ) { - if ( 0 == strcmp( native_lanman, "Windows 2002 5.1" ) ) + if ( strcmp( native_lanman, "Windows 2002 5.1" ) == 0 ) set_remote_arch( RA_WINXP ); - else if ( 0 == strcmp( native_lanman, "Windows .NET 5.2" ) ) + else if ( strcmp( native_lanman, "Windows Server 2003 5.2" ) == 0 ) set_remote_arch( RA_WIN2K3 ); } @@ -1772,33 +1774,35 @@ void set_remote_arch(enum remote_arch_types type) switch( type ) { case RA_WFWG: fstrcpy(remote_arch, "WfWg"); - return; + break; case RA_OS2: fstrcpy(remote_arch, "OS2"); - return; + break; case RA_WIN95: fstrcpy(remote_arch, "Win95"); - return; + break; case RA_WINNT: fstrcpy(remote_arch, "WinNT"); - return; + break; case RA_WIN2K: fstrcpy(remote_arch, "Win2K"); - return; + break; case RA_WINXP: fstrcpy(remote_arch, "WinXP"); - return; + break; case RA_WIN2K3: fstrcpy(remote_arch, "Win2K3"); - return; + break; case RA_SAMBA: fstrcpy(remote_arch,"Samba"); - return; + break; default: ra_type = RA_UNKNOWN; fstrcpy(remote_arch, "UNKNOWN"); break; } + + DEBUG(10,("set_remote_arch: Client arch is \'%s\'\n", remote_arch)); } /******************************************************************* diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c index 1d62da53c5b..328ca927277 100644 --- a/source/lib/util_sock.c +++ b/source/lib/util_sock.c @@ -874,6 +874,7 @@ static BOOL matchname(char *remotehost,struct in_addr addr) char *get_peer_name(int fd, BOOL force_lookup) { static pstring name_buf; + pstring tmp_name; static fstring addr_buf; struct hostent *hp; struct in_addr addr; @@ -890,10 +891,12 @@ char *get_peer_name(int fd, BOOL force_lookup) p = get_peer_addr(fd); /* it might be the same as the last one - save some DNS work */ - if (strcmp(p, addr_buf) == 0) return name_buf; + if (strcmp(p, addr_buf) == 0) + return name_buf; pstrcpy(name_buf,"UNKNOWN"); - if (fd == -1) return name_buf; + if (fd == -1) + return name_buf; fstrcpy(addr_buf, p); @@ -911,7 +914,12 @@ char *get_peer_name(int fd, BOOL force_lookup) } } - alpha_strcpy(name_buf, name_buf, "_-.", sizeof(name_buf)); + /* can't pass the same source and dest strings in when you + use --enable-developer or the clobber_region() call will + get you */ + + pstrcpy( tmp_name, name_buf ); + alpha_strcpy(name_buf, tmp_name, "_-.", sizeof(name_buf)); if (strstr(name_buf,"..")) { pstrcpy(name_buf, "UNKNOWN"); } diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c index 1de74137117..c7cc4848b70 100644 --- a/source/libsmb/namequery.c +++ b/source/libsmb/namequery.c @@ -1006,9 +1006,9 @@ static BOOL internal_resolve_name(const char *name, int name_type, } } else { (*return_iplist)->ip.s_addr = allones ? 0xFFFFFFFF : 0; - *return_count = 1; } - return True; + *return_count = 1; + return True; } /* Check name cache */ diff --git a/source/rpc_parse/parse_net.c b/source/rpc_parse/parse_net.c index ad0a91e7ea5..5df75fc5f6e 100644 --- a/source/rpc_parse/parse_net.c +++ b/source/rpc_parse/parse_net.c @@ -2283,12 +2283,12 @@ static BOOL net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * inf if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members)) return False; + if (ps->data_offset + 16 > ps->buffer_size) + return False; + ps->data_offset += 16; + if (info->ptr_members != 0) { - if (ps->data_offset + 16 > ps->buffer_size) - return False; - ps->data_offset += 16; - if (!prs_uint32("num_sids", ps, depth, &info->num_sids)) return False; if (info->num_sids != info->num_members) diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c index 798949fae92..f5a440c024c 100644 --- a/source/rpcclient/cmd_spoolss.c +++ b/source/rpcclient/cmd_spoolss.c @@ -1336,7 +1336,7 @@ static WERROR cmd_spoolss_addprinterex(struct cli_state *cli, slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost); strupper_m(servername); - /* Fill in the DRIVER_INFO_3 struct */ + /* Fill in the DRIVER_INFO_2 struct */ ZERO_STRUCT(info2); #if 0 /* JERRY */ init_unistr( &info2.servername, servername); diff --git a/source/smbd/sesssetup.c b/source/smbd/sesssetup.c index ec01a330ee2..da48c81fc19 100644 --- a/source/smbd/sesssetup.c +++ b/source/smbd/sesssetup.c @@ -463,7 +463,7 @@ static int reply_sesssetup_and_X_spnego(connection_struct *conn, char *inbuf, DATA_BLOB blob1; int ret; size_t bufrem; - fstring native_os, native_lanman; + fstring native_os, native_lanman, primary_domain; char *p2; uint16 data_blob_len = SVAL(inbuf, smb_vwv7); enum remote_arch_types ra_type = get_remote_arch(); @@ -497,11 +497,20 @@ static int reply_sesssetup_and_X_spnego(connection_struct *conn, char *inbuf, p2 = inbuf + smb_vwv13 + data_blob_len; p2 += srvstr_pull_buf(inbuf, native_os, p2, sizeof(native_os), STR_TERMINATE); p2 += srvstr_pull_buf(inbuf, native_lanman, p2, sizeof(native_lanman), STR_TERMINATE); - DEBUG(3,("NativeOS=[%s] NativeLanMan=[%s]\n", native_os, native_lanman)); - - if ( ra_type == RA_WIN2K ) - ra_lanman_string( native_lanman ); + p2 += srvstr_pull_buf(inbuf, primary_domain, p2, sizeof(primary_domain), STR_TERMINATE); + DEBUG(3,("NativeOS=[%s] NativeLanMan=[%s] PrimaryDomain=[%s]\n", + native_os, native_lanman, primary_domain)); + if ( ra_type == RA_WIN2K ) { + /* Windows 2003 doesn't set the native lanman string, + but does set primary domain which is a bug I think */ + + if ( !strlen(native_lanman) ) + ra_lanman_string( primary_domain ); + else + ra_lanman_string( native_lanman ); + } + if (blob1.data[0] == ASN1_APPLICATION(0)) { /* its a negTokenTarg packet */ ret = reply_spnego_negotiate(conn, inbuf, outbuf, length, bufsize, blob1); @@ -556,6 +565,7 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf, fstring domain; fstring native_os; fstring native_lanman; + fstring primary_domain; static BOOL done_sesssetup = False; extern BOOL global_encrypted_passwords_negotiated; extern BOOL global_spnego_negotiated; @@ -619,6 +629,9 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf, uint16 passlen2 = SVAL(inbuf,smb_vwv8); enum remote_arch_types ra_type = get_remote_arch(); char *p = smb_buf(inbuf); + char *save_p = smb_buf(inbuf); + uint16 byte_count; + if(global_client_caps == 0) { global_client_caps = IVAL(inbuf,smb_vwv11); @@ -689,11 +702,28 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf, p += srvstr_pull_buf(inbuf, domain, p, sizeof(domain), STR_TERMINATE); p += srvstr_pull_buf(inbuf, native_os, p, sizeof(native_os), STR_TERMINATE); p += srvstr_pull_buf(inbuf, native_lanman, p, sizeof(native_lanman), STR_TERMINATE); - DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s]\n", - domain,native_os,native_lanman)); - if ( ra_type == RA_WIN2K ) - ra_lanman_string( native_lanman ); + /* not documented or decoded by Ethereal but there is one more string + in the extra bytes which is the same as the PrimaryDomain when using + extended security. Windows NT 4 and 2003 use this string to store + the native lanman string. Windows 9x does not include a string here + at all so we have to check if we have any extra bytes left */ + + byte_count = SVAL(inbuf, smb_vwv13); + if ( PTR_DIFF(p, save_p) < byte_count) + p += srvstr_pull_buf(inbuf, primary_domain, p, sizeof(primary_domain), STR_TERMINATE); + else + fstrcpy( primary_domain, "null" ); + + DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s] PrimaryDomain=[%s]\n", + domain, native_os, native_lanman, primary_domain)); + + if ( ra_type == RA_WIN2K ) { + if ( strlen(native_lanman) == 0 ) + ra_lanman_string( primary_domain ); + else + ra_lanman_string( native_lanman ); + } } diff --git a/source/tdb/spinlock.c b/source/tdb/spinlock.c index 3fddeafb2c1..3b3ebefded3 100644 --- a/source/tdb/spinlock.c +++ b/source/tdb/spinlock.c @@ -143,6 +143,47 @@ static inline int __spin_is_locked(spinlock_t *lock) return (*lock != 1); } +#elif defined(MIPS_SPINLOCKS) && defined(sgi) && (_COMPILER_VERSION >= 730) + +/* Implement spinlocks on IRIX using the MIPSPro atomic fetch operations. See + * sync(3) for the details of the intrinsic operations. + * + * "sgi" and "_COMPILER_VERSION" are always defined by MIPSPro. + */ + +#if defined(STANDALONE) + +/* MIPSPro 7.3 has "__inline" as an extension, but not "inline. */ +#define inline __inline + +#endif /* STANDALONE */ + +/* Returns 0 if the lock is acquired, EBUSY otherwise. */ +static inline int __spin_trylock(spinlock_t *lock) +{ + unsigned int val; + val = __lock_test_and_set(lock, 1); + return val == 0 ? 0 : EBUSY; +} + +static inline void __spin_unlock(spinlock_t *lock) +{ + __lock_release(lock); +} + +static inline void __spin_lock_init(spinlock_t *lock) +{ + __lock_release(lock); +} + +/* Returns 1 if the lock is held, 0 otherwise. */ +static inline int __spin_is_locked(spinlock_t *lock) +{ + unsigned int val; + val = __add_and_fetch(lock, 0); + return val; +} + #elif defined(MIPS_SPINLOCKS) static inline unsigned int load_linked(unsigned long addr) @@ -221,7 +262,11 @@ static void yield_cpu(void) static int this_is_smp(void) { +#if defined(HAVE_SYSCONF) && defined(SYSCONF_SC_NPROC_ONLN) + return (sysconf(_SC_NPROC_ONLN) > 1) ? 1 : 0; +#else return 0; +#endif } /* -- cgit v1.2.1