summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/.cvsignore1
-rw-r--r--source3/smbd/build_options.c532
-rw-r--r--source3/smbd/chgpasswd.c13
-rw-r--r--source3/smbd/mangle_hash.c4
-rw-r--r--source3/smbd/oplock.c2
-rw-r--r--source3/smbd/password.c11
-rw-r--r--source3/smbd/posix_acls.c10
-rw-r--r--source3/smbd/reply.c23
-rw-r--r--source3/smbd/server.c10
-rw-r--r--source3/smbd/session.c11
-rw-r--r--source3/smbd/uid.c419
-rw-r--r--source3/smbd/utmp.c10
12 files changed, 472 insertions, 574 deletions
diff --git a/source3/smbd/.cvsignore b/source3/smbd/.cvsignore
index 5f2a5c4cf7..d2b1fd5b2e 100644
--- a/source3/smbd/.cvsignore
+++ b/source3/smbd/.cvsignore
@@ -1,2 +1,3 @@
*.po
*.po32
+build_options.c
diff --git a/source3/smbd/build_options.c b/source3/smbd/build_options.c
deleted file mode 100644
index 43335666a6..0000000000
--- a/source3/smbd/build_options.c
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Build Options for Samba Suite
- Copyright (C) Vance Lankhaar <vlankhaar@hotmail.com> 2001
- Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-#include "build_env.h"
-#include "dynconfig.h"
-
-static void output(BOOL screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-
-/*
-#define OUTPUT(x) snprintf(outstring,sizeof(outstring),x); output(screen,outstring);
-*/
-/****************************************************************************
-helper function for build_options
-****************************************************************************/
-static void output(BOOL screen, const char *format, ...)
-{
- char *ptr;
- va_list ap;
-
- va_start(ap, format);
- vasprintf(&ptr,format,ap);
- va_end(ap);
-
- if (screen) {
- d_printf("%s", ptr);
- } else {
- DEBUG(4,("%s", ptr));
- }
-
- SAFE_FREE(ptr);
-}
-
-/****************************************************************************
-options set at build time for the samba suite
-****************************************************************************/
-void build_options(BOOL screen)
-{
- if ((DEBUGLEVEL < 4) && (!screen)) {
- return;
- }
-
-#ifdef _BUILD_ENV_H
- /* Output information about the build environment */
- output(screen,"Build environment:\n");
- output(screen," Built by: %s@%s\n",BUILD_ENV_USER,BUILD_ENV_HOST);
- output(screen," Built on: %s\n",BUILD_ENV_DATE);
-
- output(screen," Built using: %s\n",BUILD_ENV_COMPILER);
- output(screen," Build host: %s\n",BUILD_ENV_UNAME);
- output(screen," SRCDIR: %s\n",BUILD_ENV_SRCDIR);
- output(screen," BUILDDIR: %s\n",BUILD_ENV_BUILDDIR);
-
-
-#endif
-
- /* Output various options (most correspond to --with options) */
- output(screen,"\nBuild options:\n");
-#ifdef WITH_SMBWRAPPER
- output(screen," WITH_SMBWRAPPER\n");
-#endif
-#ifdef WITH_AFS
- output(screen," WITH_AFS\n");
-#endif
-#ifdef WITH_DFS
- output(screen," WITH_DFS\n");
-#endif
-#ifdef KRB4_AUTH
- output(screen," KRB4_AUTH");
-#endif
-#ifdef HAVE_KRB5
- output(screen," HAVE_KRB5");
-#endif
-#ifdef HAVE_GSSAPI
- output(screen," HAVE_GSSAPI");
-#endif
-#ifdef HAVE_LDAP
- output(screen," HAVE_LDAP");
-#endif
-#ifdef WITH_AUTOMOUNT
- output(screen," WITH_AUTOMOUNT\n");
-#endif
-#ifdef WITH_SMBMOUNT
- output(screen," WITH_SMBMOUNT\n");
-#endif
-#ifdef WITH_PAM
- output(screen," WITH_PAM\n");
-#endif
-#ifdef WITH_NISPLUS_HOME
- output(screen," WITH_NISPLUS_HOME\n");
-#endif
-#ifdef WITH_SYSLOG
- output(screen," WITH_SYSLOG\n");
-#endif
-#ifdef WITH_PROFILE
- output(screen," WITH_PROFILE\n");
-#endif
-#ifdef WITH_QUOTAS
- output(screen," WITH_QUOTAS\n");
-#endif
-#ifdef WITH_VFS
- output(screen," WITH_VFS\n");
-#endif
-#ifdef USE_SPINLOCKS
- output(screen," USE_SPINLOCKS\n");
-#endif
-#ifdef SPARC_SPINLOCKS
- output(screen," SPARC_SPINLOCKS\n");
-#endif
-#ifdef INTEL_SPINLOCKS
- output(screen," INTEL_SPINLOCKS\n");
-#endif
-#ifdef MIPS_SPINLOCKS
- output(screen," MIPS_SPINLOCKS\n");
-#endif
-#ifdef POWERPC_SPINLOCKS
- output(screen," POWERPC_SPINLOCKS\n");
-#endif
-#ifdef HAVE_UNIXWARE_ACLS
- output(screen," HAVE_UNIXWARE_ACLS\n");
-#endif
-#ifdef HAVE_SOLARIS_ACLS
- output(screen," HAVE_SOLARIS_ACLS\n");
-#endif
-#ifdef HAVE_IRIX_ACLS
- output(screen," HAVE_IRIX_ACLS\n");
-#endif
-#ifdef HAVE_AIX_ACLS
- output(screen," HAVE_AIX_ACLS\n");
-#endif
-#ifdef HAVE_POSIX_ACLS
- output(screen," HAVE_POSIX_ACLS\n");
-#endif
-#ifdef HAVE_TRU64_ACLS
- output(screen," HAVE_TRU64_ACLS\n");
-#endif
-
-#ifdef HAVE_ACL_GET_PERM_NP
- output(screen," HAVE_ACL_GET_PERM_NP\n");
-#endif
-#ifdef HAVE_NO_ACLS
- output(screen," HAVE_NO_ACLS\n");
-#endif
-#ifdef HAVE_LIBREADLINE
- output(screen," HAVE_LIBREADLINE\n");
-#endif
-#ifdef WITH_LIBICONV
- output(screen," WITH_LIBICONV: %s\n",WITH_LIBICONV);
-#endif
-
-
- /* Output various paths to files and directories */
- output(screen,"\nPaths:\n");
- output(screen," CONFIGFILE: %s\n", dyn_CONFIGFILE);
-#ifdef PRIVATE_DIR
- output(screen," PRIVATE_DIR: %s\n",PRIVATE_DIR);
-#endif
-#ifdef LMHOSTSFILE
- output(screen," LMHOSTSFILE: %s\n",LMHOSTSFILE);
-#endif
- output(screen," SBINDIR: %s\n", dyn_SBINDIR);
- output(screen," BINDIR: %s\n", dyn_BINDIR);
- output(screen," LOCKDIR: %s\n",dyn_LOCKDIR);
- output(screen," LOGFILEBASE: %s\n", dyn_LOGFILEBASE);
-
- /*Output various other options (most map to defines in the configure script*/
- output(screen,"\nOther Build Options:\n");
-#ifdef HAVE_VOLATILE
- output(screen," HAVE_VOLATILE\n");
-#endif
-#ifdef HAVE_SHADOW_H
- output(screen," HAVE_SHADOW_H\n");
-#endif
-#ifdef HAVE_CRYPT
- output(screen," HAVE_CRYPT\n");
-#endif
-#ifdef USE_BOTH_CRYPT_CALLS
- output(screen," USE_BOTH_CRYPT_CALLS\n");
-#endif
-#ifdef HAVE_TRUNCATED_SALT
- output(screen," HAVE_TRUNCATED_SALT\n");
-#endif
-#ifdef HAVE_CUPS
- output(screen," HAVE_CUPS\n");
-#endif
-#ifdef HAVE_CUPS_CUPS_H
- output(screen," HAVE_CUPS_CUPS_H\n");
-#endif
-#ifdef HAVE_CUPS_LANGUAGE_H
- output(screen," HAVE_CUPS_LANGUAGE_H\n");
-#endif
-#ifdef HAVE_DLOPEN
- output(screen," HAVE_DLOPEN\n");
-#endif
-#ifdef HAVE_DLCLOSE
- output(screen," HAVE_DLCLOSE\n");
-#endif
-#ifdef HAVE_DLSYM
- output(screen," HAVE_DLSYM\n");
-#endif
-#ifdef HAVE_DLERROR
- output(screen," HAVE_DLERROR\n");
-#endif
-#ifdef HAVE_UNIXSOCKET
- output(screen," HAVE_UNIXSOCKET\n");
-#endif
-#ifdef HAVE_SOCKLEN_T_TYPE
- output(screen," HAVE_SOCKLEN_T_TYPE\n");
-#endif
-#ifdef HAVE_SIG_ATOMIC_T_TYPE
- output(screen," HAVE_SIG_ATOMIC_T_TYPE\n");
-#endif
-#ifdef HAVE_SETRESUID
- output(screen," HAVE_SETRESUID\n");
-#endif
-#ifdef HAVE_SETRESGID
- output(screen," HAVE_SETRESGID\n");
-#endif
-#ifdef HAVE_CONNECT
- output(screen," HAVE_CONNECT\n");
-#endif
-#ifdef HAVE_YP_GET_DEFAULT_DOMAIN
- output(screen," HAVE_YP_GET_DEFAULT_DOMAIN\n");
-#endif
-#ifdef HAVE_STAT64
- output(screen," HAVE_STAT64\n");
-#endif
-#ifdef HAVE_LSTAT64
- output(screen," HAVE_LSTAT64\n");
-#endif
-#ifdef HAVE_FSTAT64
- output(screen," HAVE_FSTAT64\n");
-#endif
-#ifdef HAVE_STRCASECMP
- output(screen," HAVE_STRCASECMP\n");
-#endif
-#ifdef HAVE_MEMSET
- output(screen," HAVE_MEMSET\n");
-#endif
-#ifdef HAVE_LONGLONG
- output(screen," HAVE_LONGLONG\n");
-#endif
-#ifdef COMPILER_SUPPORTS_LL
- output(screen," COMPILER_SUPPORTS_LL\n");
-#endif
-#ifdef SIZEOF_OFF_T
- output(screen," SIZEOF_OFF_T: %d\n",SIZEOF_OFF_T);
-#endif
-#ifdef HAVE_OFF64_T
- output(screen," HAVE_OFF64_T\n");
-#endif
-#ifdef SIZEOF_INO_T
- output(screen," SIZEOF_INO_T: %d\n",SIZEOF_INO_T);
-#endif
-#ifdef HAVE_INO64_T
- output(screen," HAVE_INO64_T\n");
-#endif
-#ifdef HAVE_STRUCT_DIRENT64
- output(screen," HAVE_STRUCT_DIRENT64\n");
-#endif
-#ifdef HAVE_UNSIGNED_CHAR
- output(screen," HAVE_UNSIGNED_CHAR\n");
-#endif
-#ifdef HAVE_SOCK_SIN_LEN
- output(screen," HAVE_SOCK_SIN_LEN\n");
-#endif
-#ifdef SEEKDIR_RETURNS_VOID
- output(screen," SEEKDIR_RETURNS_VOID\n");
-#endif
-#ifdef HAVE_FUNCTION_MACRO
- output(screen," HAVE_FUNCTION_MACRO\n");
-#endif
-#ifdef HAVE_GETTIMEOFDAY
- output(screen," HAVE_GETTIMEOFDAY\n");
-#endif
-#ifdef HAVE_C99_VSNPRINTF
- output(screen," HAVE_C99_VSNPRINTF\n");
-#endif
-#ifdef HAVE_BROKEN_READDIR
- output(screen," HAVE_BROKEN_READDIR\n");
-#endif
-#ifdef HAVE_NATIVE_ICONV
- output(screen," HAVE_NATIVE_ICONV\n");
-#endif
-#ifdef HAVE_KERNEL_OPLOCKS_LINUX
- output(screen," HAVE_KERNEL_OPLOCKS_LINUX\n");
-#endif
-#ifdef HAVE_KERNEL_CHANGE_NOTIFY
- output(screen," HAVE_KERNEL_CHANGE_NOTIFY\n");
-#endif
-#ifdef HAVE_KERNEL_SHARE_MODES
- output(screen," HAVE_KERNEL_SHARE_MODES\n");
-#endif
-#ifdef HAVE_KERNEL_OPLOCKS_IRIX
- output(screen," HAVE_KERNEL_OPLOCKS_IRIX\n");
-#endif
-#ifdef HAVE_IRIX_SPECIFIC_CAPABILITIES
- output(screen," HAVE_IRIX_SPECIFIC_CAPABILITIES\n");
-#endif
-#ifdef HAVE_INT16_FROM_RPC_RPC_H
- output(screen," HAVE_INT16_FROM_RPC_RPC_H\n");
-#endif
-#ifdef HAVE_UINT16_FROM_RPC_RPC_H
- output(screen," HAVE_UINT16_FROM_RPC_RPC_H\n");
-#endif
-#ifdef HAVE_INT32_FROM_RPC_RPC_H
- output(screen," HAVE_INT16_FROM_RPC_RPC_H\n");
-#endif
-#ifdef HAVE_UINT32_FROM_RPC_RPC_H
- output(screen," HAVE_UINT32_FROM_RPC_RPC_H\n");
-#endif
-#ifdef HAVE_RPC_AUTH_ERROR_CONFLICT
- output(screen," HAVE_RPC_AUTH_ERROR_CONFLICT\n");
-#endif
-#ifdef HAVE_FTRUNCATE_EXTEND
- output(screen," HAVE_FTRUNCATE_EXTEND\n");
-#endif
-#ifdef HAVE_WORKING_AF_LOCAL
- output(screen," HAVE_WORKING_AF_LOCAL\n");
-#endif
-#ifdef HAVE_BROKEN_GETGROUPS
- output(screen," HAVE_BROKEN_GETGROUPS\n");
-#endif
-#ifdef REPLACE_GETPASS
- output(screen," REPLACE_GETPASS\n");
-#endif
-#ifdef REPLACE_INET_NTOA
- output(screen," REPLACE_INET_NTOA\n");
-#endif
-#ifdef HAVE_SECURE_MKSTEMP
- output(screen," HAVE_SECURE_MKSTEMP\n");
-#endif
-#ifdef SYSCONF_SC_NGROUPS_MAX
- output(screen," SYSCONF_SC_NGROUPS_MAX\n");
-#endif
-#ifdef HAVE_IFACE_AIX
- output(screen," HAVE_IFACE_AIX\n");
-#endif
-#ifdef HAVE_IFACE_IFCONF
- output(screen," HAVE_IFACE_IFCONF\n");
-#endif
-#ifdef HAVE_IFACE_IFREQ
- output(screen," HAVE_IFACE_IFREQ\n");
-#endif
-#ifdef USE_SETRESUID
- output(screen," USE_SETRESUID\n");
-#endif
-#ifdef USE_SETRESGID
- output(screen," USE_SETREUID\n");
-#endif
-#ifdef USE_SETEUID
- output(screen," USE_SETEUID\n");
-#endif
-#ifdef USE_SETUIDX
- output(screen," USE_SETUIDX\n");
-#endif
-#ifdef HAVE_MMAP
- output(screen," HAVE_MMAP\n");
-#endif
-#ifdef MMAP_BLACKLIST
- output(screen," MMAP_BLACKLIST\n");
-#endif
-#ifdef FTRUNCATE_NEEDS_ROOT
- output(screen," FTRUNCATE_NEEDS_ROOT\n");
-#endif
-#ifdef HAVE_FCNTL_LOCK
- output(screen," HAVE_FCNTL_LOCK\n");
-#endif
-#ifdef HAVE_BROKEN_FCNTL64_LOCKS
- output(screen," HAVE_BROKEN_FCNTL64_LOCKS\n");
-#endif
-#ifdef HAVE_STRUCT_FLOCK64
- output(screen," HAVE_STRUCT_FLOCK64\n");
-#endif
-#ifdef BROKEN_NISPLUS_INCLUDE_FILES
- output(screen," BROKEN_NISPLUS_INCLUDE_FILES\n");
-#endif
-#ifdef HAVE_LIBPAM
- output(screen," HAVE_LIBPAM\n");
-#endif
-#ifdef STAT_STATVFS64
- output(screen," STAT_STATVFS64\n");
-#endif
-#ifdef STAT_STATVFS
- output(screen," STAT_STATVFS\n");
-#endif
-#ifdef STAT_STATFS3_OSF1
- output(screen," STAT_STATFS3_OSF1\n");
-#endif
-#ifdef STAT_STATFS2_BSIZE
- output(screen," STAT_STATFS2_BSIZE\n");
-#endif
-#ifdef STAT_STATFS4
- output(screen," STAT_STATFS4\n");
-#endif
-#ifdef STAT_STATFS2_FSIZE
- output(screen," STAT_STATFS2_FSIZE\n");
-#endif
-#ifdef STAT_STATFS2_FS_DATA
- output(screen," STAT_STATFS2_FS_DATA\n");
-#endif
-#ifdef HAVE_EXPLICIT_LARGEFILE_SUPPORT
- output(screen," HAVE_EXPLICIT_LARGEFILE_SUPPORT\n");
-#endif
-
-#ifdef WITH_UTMP
- /* Output UTMP Stuff */
- output(screen,"\nUTMP Related:\n");
- output(screen," WITH_UTMP\n");
-
-#ifdef HAVE_UTIMBUF
- output(screen," HAVE_UTIMBUF\n");
-#endif
-#ifdef HAVE_UT_UT_NAME
- output(screen," HAVE_UT_UT_NAME\n");
-#endif
-#ifdef HAVE_UT_UT_USER
- output(screen," HAVE_UT_UT_USER\n");
-#endif
-#ifdef HAVE_UT_UT_ID
- output(screen," HAVE_UT_UT_ID\n");
-#endif
-#ifdef HAVE_UT_UT_HOST
- output(screen," HAVE_UT_UT_HOST\n");
-#endif
-#ifdef HAVE_UT_UT_TIME
- output(screen," HAVE_UT_UT_TIME\n");
-#endif
-#ifdef HAVE_UT_UT_TV
- output(screen," HAVE_UT_UT_TV\n");
-#endif
-#ifdef HAVE_UT_UT_TYPE
- output(screen," HAVE_UT_UT_TYPE\n");
-#endif
-#ifdef HAVE_UT_UT_PID
- output(screen," HAVE_UT_UT_PID\n");
-#endif
-#ifdef HAVE_UT_UT_EXIT
- output(screen," HAVE_UT_UT_EXIT\n");
-#endif
-#ifdef HAVE_UT_UT_ADDR
- output(screen," HAVE_UT_UT_ADDR\n");
-#endif
-#ifdef PUTUTLINE_RETURNS_UTMP
- output(screen," PUTUTLINE_RETURNS_UTMP\n");
-#endif
-#ifdef HAVE_UX_UT_SYSLEN
- output(screen," HAVE_UX_UT_SYSLEN\n");
-#endif
-#endif /* WITH_UTMP */
-
- /* Output Build OS */
- output(screen,"\nBuilt for host os:\n");
-#ifdef LINUX
- output(screen," LINUX\n");
-#endif
-#ifdef SUNOS5
- output(screen," SUNOS5\n");
-#endif
-#ifdef SUNOS4
- output(screen," SUNOS4\n");
-#endif
- /* BSD Isn't Defined in the configure script, but there is something about it in include/config.h.in (and I guess acconfig.h) */
-#ifdef BSD
- output(screen," BSD\n");
-#endif
-#ifdef IRIX
- output(screen," IRIX\n");
-#endif
-#ifdef IRIX6
- output(screen," IRIX6\n");
-#endif
-#ifdef AIX
- output(screen," AIX\n");
-#endif
-#ifdef HPUX
- output(screen," HPUX\n");
-#endif
-#ifdef QNX
- output(screen," QNX\n");
-#endif
-#ifdef OSF1
- output(screen," OSF1\n");
-#endif
-#ifdef SCO
- output(screen," SCO\n");
-#endif
-#ifdef UNIXWARE
- output(screen," UNIXWARE\n");
-#endif
-#ifdef NEXT2
- output(screen," NEXT2\n");
-#endif
-#ifdef RELIANTUNIX
- output(screen," RELIANTUNIX\n");
-#endif
-
- /* Output the sizes of the various types */
- output(screen,"\nType sizes:\n");
- output(screen," sizeof(char): %d\n",sizeof(char));
- output(screen," sizeof(int): %d\n",sizeof(int));
- output(screen," sizeof(long): %d\n",sizeof(long));
- output(screen," sizeof(uint8): %d\n",sizeof(uint8));
- output(screen," sizeof(uint16): %d\n",sizeof(uint16));
- output(screen," sizeof(uint32): %d\n",sizeof(uint32));
- output(screen," sizeof(short): %d\n",sizeof(short));
- output(screen," sizeof(void*): %d\n",sizeof(void*));
-
- output(screen,"\nBuiltin modules:\n");
- output(screen,"%s\n", STRING_STATIC_MODULES);
-}
-
-
-
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c
index 3d25f33f45..31c4fa7cc9 100644
--- a/source3/smbd/chgpasswd.c
+++ b/source3/smbd/chgpasswd.c
@@ -478,12 +478,6 @@ BOOL chgpasswd(const char *name, const char *oldpass, const char *newpass, BOOL
if (!name) {
DEBUG(1, ("NULL username specfied to chgpasswd()!\n"));
}
-
- pass = Get_Pwnam(name);
- if (!pass) {
- DEBUG(1, ("Username does not exist in system passwd!\n"));
- return False;
- }
if (!oldpass) {
oldpass = "";
@@ -534,6 +528,8 @@ BOOL chgpasswd(const char *name, const char *oldpass, const char *newpass, BOOL
}
}
+ pass = Get_Pwnam(name);
+
#ifdef WITH_PAM
if (lp_pam_password_change()) {
BOOL ret;
@@ -987,8 +983,9 @@ NTSTATUS change_oem_password(SAM_ACCOUNT *hnd, char *old_passwd, char *new_passw
* to touch the unix db unless we have admin permission.
*/
- if(lp_unix_password_sync() &&
- !chgpasswd(pdb_get_username(hnd), old_passwd, new_passwd, False)) {
+ if(lp_unix_password_sync() && IS_SAM_UNIX_USER(hnd)
+ && !chgpasswd(pdb_get_username(hnd),
+ old_passwd, new_passwd, False)) {
return NT_STATUS_ACCESS_DENIED;
}
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index e220d2f6d2..d2eb996899 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -556,8 +556,8 @@ static void cache_mangled_name( char *mangled_name, char *raw_name )
/* Fill the new cache entry, and add it to the cache. */
s1 = (char *)(new_entry + 1);
s2 = (char *)&(s1[mangled_len + 1]);
- (void)StrnCpy( s1, mangled_name, mangled_len );
- (void)StrnCpy( s2, raw_name, raw_len );
+ safe_strcpy( s1, mangled_name, mangled_len );
+ safe_strcpy( s2, raw_name, raw_len );
ubi_cachePut( mangled_cache, i, new_entry, s1 );
}
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 632dfe9e29..8525687793 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -391,7 +391,7 @@ pid %d, port %d, dev = %x, inode = %.0f, file_id = %lu\n",
/*
* Keep this as a debug case - eventually we can remove it.
*/
- case (CMD_REPLY | KERNEL_OPLOCK_BREAK_CMD):
+ case 0x8001:
DEBUG(0,("process_local_message: Received unsolicited break \
reply - dumping info.\n"));
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index c4f813b00c..8dff42471f 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -68,6 +68,7 @@ void invalidate_vuid(uint16 vuid)
SAFE_FREE(vuser->logon_script);
session_yield(vuser);
+ SAFE_FREE(vuser->session_keystr);
free_server_info(&vuser->server_info);
@@ -141,9 +142,15 @@ int register_vuid(auth_serversupplied_info *server_info, const char *smb_name)
/* the next functions should be done by a SID mapping system (SMS) as
* the new real sam db won't have reference to unix uids or gids
*/
+ if (!IS_SAM_UNIX_USER(server_info->sam_account)) {
+ DEBUG(0,("Attempted session setup with invalid user. No uid/gid in SAM_ACCOUNT\n"));
+ free(vuser);
+ free_server_info(&server_info);
+ return UID_FIELD_INVALID;
+ }
- vuser->uid = server_info->uid;
- vuser->gid = server_info->gid;
+ vuser->uid = pdb_get_uid(server_info->sam_account);
+ vuser->gid = pdb_get_gid(server_info->sam_account);
vuser->n_groups = server_info->n_groups;
if (vuser->n_groups) {
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 6925b35246..a38acc437d 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -443,6 +443,7 @@ static BOOL unpack_nt_owners(SMB_STRUCT_STAT *psbuf, uid_t *puser, gid_t *pgrp,
{
DOM_SID owner_sid;
DOM_SID grp_sid;
+ enum SID_NAME_USE sid_type;
*puser = (uid_t)-1;
*pgrp = (gid_t)-1;
@@ -468,7 +469,7 @@ static BOOL unpack_nt_owners(SMB_STRUCT_STAT *psbuf, uid_t *puser, gid_t *pgrp,
if (security_info_sent & OWNER_SECURITY_INFORMATION) {
sid_copy(&owner_sid, psd->owner_sid);
- if (NT_STATUS_IS_ERR(sid_to_uid(&owner_sid, puser))) {
+ if (!sid_to_uid( &owner_sid, puser, &sid_type)) {
#if ACL_FORCE_UNMAPPABLE
/* this allows take ownership to work reasonably */
extern struct current_user current_user;
@@ -488,7 +489,7 @@ static BOOL unpack_nt_owners(SMB_STRUCT_STAT *psbuf, uid_t *puser, gid_t *pgrp,
if (security_info_sent & GROUP_SECURITY_INFORMATION) {
sid_copy(&grp_sid, psd->grp_sid);
- if (NT_STATUS_IS_ERR(sid_to_gid( &grp_sid, pgrp))) {
+ if (!sid_to_gid( &grp_sid, pgrp, &sid_type)) {
#if ACL_FORCE_UNMAPPABLE
/* this allows take group ownership to work reasonably */
extern struct current_user current_user;
@@ -937,6 +938,7 @@ static BOOL create_canon_ace_lists(files_struct *fsp,
}
for(i = 0; i < dacl->num_aces; i++) {
+ enum SID_NAME_USE sid_type;
SEC_ACE *psa = &dacl->ace[i];
/*
@@ -1001,10 +1003,10 @@ static BOOL create_canon_ace_lists(files_struct *fsp,
if (nt4_compatible_acls())
psa->flags |= SEC_ACE_FLAG_INHERIT_ONLY;
- } else if (NT_STATUS_IS_OK(sid_to_gid( &current_ace->trustee, &current_ace->unix_ug.gid))) {
+ } else if (sid_to_gid( &current_ace->trustee, &current_ace->unix_ug.gid, &sid_type)) {
current_ace->owner_type = GID_ACE;
current_ace->type = SMB_ACL_GROUP;
- } else if (NT_STATUS_IS_OK(sid_to_uid( &current_ace->trustee, &current_ace->unix_ug.uid))) {
+ } else if (sid_to_uid( &current_ace->trustee, &current_ace->unix_ug.uid, &sid_type)) {
current_ace->owner_type = UID_ACE;
current_ace->type = SMB_ACL_USER;
} else {
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index b2dab2fea2..9577196bfe 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -148,7 +148,7 @@ int reply_tcon(connection_struct *conn,
const char *service;
pstring service_buf;
pstring password;
- fstring dev;
+ pstring dev;
int outsize = 0;
uint16 vuid = SVAL(inbuf,smb_uid);
int pwlen=0;
@@ -204,7 +204,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
{
fstring service;
DATA_BLOB password;
-
+
/* what the cleint thinks the device is */
fstring client_devicetype;
/* what the server tells the client the share represents */
@@ -283,15 +283,16 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
set_message_end(outbuf,p);
} else {
/* NT sets the fstype of IPC$ to the null string */
- const char *fsname = IS_IPC(conn) ? "" : lp_fstype(SNUM(conn));
+ const char *fstype = IS_IPC(conn) ? "" : lp_fstype(SNUM(conn));
set_message(outbuf,3,0,True);
-
- p = smb_buf(outbuf);
+
+ p = smb_buf(outbuf);
p += srvstr_push(outbuf, p, server_devicetype, -1,
- STR_TERMINATE|STR_ASCII);
- p += srvstr_push(outbuf, p, fsname, -1,
- STR_TERMINATE);
+ STR_TERMINATE|STR_ASCII);
+ p += srvstr_push(outbuf, p, fstype, -1,
+ STR_TERMINATE);
+
set_message_end(outbuf,p);
/* what does setting this bit do? It is set by NT4 and
@@ -1463,6 +1464,7 @@ void send_file_readbraw(connection_struct *conn, files_struct *fsp, SMB_OFF_T st
int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
{
+ extern struct current_user current_user;
ssize_t maxcount,mincount;
size_t nread = 0;
SMB_OFF_T startpos;
@@ -2360,6 +2362,7 @@ int reply_exit(connection_struct *conn,
int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
int dum_buffsize)
{
+ extern struct current_user current_user;
int outsize = 0;
time_t mtime;
int32 eclass = 0, err = 0;
@@ -2380,7 +2383,7 @@ int reply_close(connection_struct *conn, char *inbuf,char *outbuf, int size,
* We can only use CHECK_FSP if we know it's not a directory.
*/
- if(!fsp || (fsp->conn != conn)) {
+ if(!fsp || (fsp->conn != conn) || (fsp->vuid != current_user.vuid)) {
END_PROFILE(SMBclose);
return ERROR_DOS(ERRDOS,ERRbadfid);
}
@@ -3104,7 +3107,7 @@ static BOOL resolve_wildcards(const char *name1, char *name2)
if (ext2[0]) {
snprintf(pname2, available_space - 1, "%s.%s", root2, ext2);
} else {
- StrnCpy(pname2, root2, available_space - 1);
+ pstrcpy_base(pname2, root2, name2);
}
return(True);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index ef27f0b7a4..ffffa3cce3 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -836,12 +836,6 @@ static BOOL init_structs(void )
if(!initialize_password_db(False))
exit(1);
- if (!idmap_init())
- exit(1);
-
- if (!idmap_init_wellknown_sids())
- exit(1);
-
static_init_rpc;
init_modules();
@@ -874,10 +868,6 @@ static BOOL init_structs(void )
if (!init_change_notify())
exit(1);
- /* Setup privileges database */
- if (!privilege_init())
- exit(1);
-
/* re-initialise the timezone */
TimeInit();
diff --git a/source3/smbd/session.c b/source3/smbd/session.c
index 54b7a24b07..ac06b9872d 100644
--- a/source3/smbd/session.c
+++ b/source3/smbd/session.c
@@ -33,6 +33,8 @@ BOOL session_claim(user_struct *vuser)
{
int i = 0;
TDB_DATA data;
+ struct sockaddr sa;
+ struct in_addr *client_ip;
struct sessionid sessionid;
uint32 pid = (uint32)sys_getpid();
TDB_DATA key;
@@ -117,6 +119,8 @@ BOOL session_claim(user_struct *vuser)
fstrcpy(sessionid.remote_machine, get_remote_machine_name());
fstrcpy(sessionid.ip_addr, client_addr());
+ client_ip = client_inaddr(&sa);
+
if (!smb_pam_claim_session(sessionid.username, sessionid.id_str, sessionid.hostname)) {
DEBUG(1,("pam_session rejected the session for %s [%s]\n",
sessionid.username, sessionid.id_str));
@@ -136,6 +140,7 @@ BOOL session_claim(user_struct *vuser)
#if WITH_UTMP
if (lp_utmp()) {
sys_utmp_claim(sessionid.username, sessionid.hostname,
+ client_ip,
sessionid.id_str, sessionid.id_num);
}
#endif
@@ -153,7 +158,8 @@ void session_yield(user_struct *vuser)
{
TDB_DATA dbuf;
struct sessionid sessionid;
- TDB_DATA key;
+ struct in_addr *client_ip;
+ TDB_DATA key;
if (!tdb) return;
@@ -171,11 +177,14 @@ void session_yield(user_struct *vuser)
memcpy(&sessionid, dbuf.dptr, sizeof(sessionid));
+ client_ip = interpret_addr2(sessionid.ip_addr);
+
SAFE_FREE(dbuf.dptr);
#if WITH_UTMP
if (lp_utmp()) {
sys_utmp_yield(sessionid.username, sessionid.hostname,
+ client_ip,
sessionid.id_str, sessionid.id_num);
}
#endif
diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c
index c68d00025c..b9cf0de3bd 100644
--- a/source3/smbd/uid.c
+++ b/source3/smbd/uid.c
@@ -405,9 +405,10 @@ void add_supplementary_nt_login_groups(int *n_groups, gid_t **pp_groups, NT_USER
memcpy(final_groups, *pp_groups, current_n_groups * sizeof(gid_t));
for (i = 0; i < ptok->num_sids; i++) {
+ enum SID_NAME_USE sid_type;
gid_t new_grp;
- if (NT_STATUS_IS_OK(sid_to_gid(&ptok->user_sids[i], &new_grp))) {
+ if (sid_to_gid(&ptok->user_sids[i], &new_grp, &sid_type)) {
/*
* Don't add the gid_t if it is already in the current group
* list. Some UNIXen don't like the same group more than once.
@@ -529,3 +530,419 @@ BOOL lookup_sid(DOM_SID *sid, fstring dom_name, fstring name, enum SID_NAME_USE
}
return True;
}
+
+/*****************************************************************
+ Id mapping cache. This is to avoid Winbind mappings already
+ seen by smbd to be queried too frequently, keeping winbindd
+ busy, and blocking smbd while winbindd is busy with other
+ stuff. Written by Michael Steffens <michael.steffens@hp.com>,
+ modified to use linked lists by jra.
+*****************************************************************/
+
+#define MAX_UID_SID_CACHE_SIZE 100
+#define TURNOVER_UID_SID_CACHE_SIZE 10
+#define MAX_GID_SID_CACHE_SIZE 100
+#define TURNOVER_GID_SID_CACHE_SIZE 10
+
+static size_t n_uid_sid_cache = 0;
+static size_t n_gid_sid_cache = 0;
+
+static struct uid_sid_cache {
+ struct uid_sid_cache *next, *prev;
+ uid_t uid;
+ DOM_SID sid;
+ enum SID_NAME_USE sidtype;
+} *uid_sid_cache_head;
+
+static struct gid_sid_cache {
+ struct gid_sid_cache *next, *prev;
+ gid_t gid;
+ DOM_SID sid;
+ enum SID_NAME_USE sidtype;
+} *gid_sid_cache_head;
+
+/*****************************************************************
+ Find a SID given a uid.
+*****************************************************************/
+
+static BOOL fetch_sid_from_uid_cache(DOM_SID *psid, enum SID_NAME_USE *psidtype, uid_t uid)
+{
+ struct uid_sid_cache *pc;
+
+ for (pc = uid_sid_cache_head; pc; pc = pc->next) {
+ if (pc->uid == uid) {
+ fstring sid;
+ *psid = pc->sid;
+ *psidtype = pc->sidtype;
+ DEBUG(3,("fetch sid from uid cache %u -> %s\n",
+ (unsigned int)uid, sid_to_string(sid, psid)));
+ DLIST_PROMOTE(uid_sid_cache_head, pc);
+ return True;
+ }
+ }
+ return False;
+}
+
+/*****************************************************************
+ Find a uid given a SID.
+*****************************************************************/
+
+static BOOL fetch_uid_from_cache(uid_t *puid, const DOM_SID *psid, enum SID_NAME_USE sidtype)
+{
+ struct uid_sid_cache *pc;
+
+ for (pc = uid_sid_cache_head; pc; pc = pc->next) {
+ if (sid_compare(&pc->sid, psid) == 0) {
+ fstring sid;
+ *puid = pc->uid;
+ DEBUG(3,("fetch uid from cache %u -> %s\n",
+ (unsigned int)*puid, sid_to_string(sid, psid)));
+ DLIST_PROMOTE(uid_sid_cache_head, pc);
+ return True;
+ }
+ }
+ return False;
+}
+
+/*****************************************************************
+ Store uid to SID mapping in cache.
+*****************************************************************/
+
+static void store_uid_sid_cache(const DOM_SID *psid, const enum SID_NAME_USE sidtype, uid_t uid)
+{
+ struct uid_sid_cache *pc;
+
+ if (n_uid_sid_cache >= MAX_UID_SID_CACHE_SIZE && n_uid_sid_cache > TURNOVER_UID_SID_CACHE_SIZE) {
+ /* Delete the last TURNOVER_UID_SID_CACHE_SIZE entries. */
+ struct uid_sid_cache *pc_next;
+ size_t i;
+
+ for (i = 0, pc = uid_sid_cache_head; i < (n_uid_sid_cache - TURNOVER_UID_SID_CACHE_SIZE); i++, pc = pc->next)
+ ;
+ for(; pc; pc = pc_next) {
+ pc_next = pc->next;
+ DLIST_REMOVE(uid_sid_cache_head,pc);
+ SAFE_FREE(pc);
+ n_uid_sid_cache--;
+ }
+ }
+
+ pc = (struct uid_sid_cache *)malloc(sizeof(struct uid_sid_cache));
+ if (!pc)
+ return;
+ pc->uid = uid;
+ sid_copy(&pc->sid, psid);
+ pc->sidtype = sidtype;
+ DLIST_ADD(uid_sid_cache_head, pc);
+ n_uid_sid_cache++;
+}
+
+/*****************************************************************
+ Find a SID given a gid.
+*****************************************************************/
+
+static BOOL fetch_sid_from_gid_cache(DOM_SID *psid, enum SID_NAME_USE *psidtype, gid_t gid)
+{
+ struct gid_sid_cache *pc;
+
+ for (pc = gid_sid_cache_head; pc; pc = pc->next) {
+ if (pc->gid == gid) {
+ fstring sid;
+ *psid = pc->sid;
+ *psidtype = pc->sidtype;
+ DEBUG(3,("fetch sid from gid cache %u -> %s\n",
+ (unsigned int)gid, sid_to_string(sid, psid)));
+ DLIST_PROMOTE(gid_sid_cache_head, pc);
+ return True;
+ }
+ }
+ return False;
+}
+
+/*****************************************************************
+ Find a gid given a SID.
+*****************************************************************/
+
+static BOOL fetch_gid_from_cache(gid_t *pgid, const DOM_SID *psid, enum SID_NAME_USE sidtype)
+{
+ struct gid_sid_cache *pc;
+
+ for (pc = gid_sid_cache_head; pc; pc = pc->next) {
+ if (sid_compare(&pc->sid, psid) == 0) {
+ fstring sid;
+ *pgid = pc->gid;
+ DEBUG(3,("fetch uid from cache %u -> %s\n",
+ (unsigned int)*pgid, sid_to_string(sid, psid)));
+ DLIST_PROMOTE(gid_sid_cache_head, pc);
+ return True;
+ }
+ }
+ return False;
+}
+
+/*****************************************************************
+ Store gid to SID mapping in cache.
+*****************************************************************/
+
+static void store_gid_sid_cache(const DOM_SID *psid, const enum SID_NAME_USE sidtype, gid_t gid)
+{
+ struct gid_sid_cache *pc;
+
+ if (n_gid_sid_cache >= MAX_GID_SID_CACHE_SIZE && n_gid_sid_cache > TURNOVER_GID_SID_CACHE_SIZE) {
+ /* Delete the last TURNOVER_GID_SID_CACHE_SIZE entries. */
+ struct gid_sid_cache *pc_next;
+ size_t i;
+
+ for (i = 0, pc = gid_sid_cache_head; i < (n_gid_sid_cache - TURNOVER_GID_SID_CACHE_SIZE); i++, pc = pc->next)
+ ;
+ for(; pc; pc = pc_next) {
+ pc_next = pc->next;
+ DLIST_REMOVE(gid_sid_cache_head,pc);
+ SAFE_FREE(pc);
+ n_gid_sid_cache--;
+ }
+ }
+
+ pc = (struct gid_sid_cache *)malloc(sizeof(struct gid_sid_cache));
+ if (!pc)
+ return;
+ pc->gid = gid;
+ sid_copy(&pc->sid, psid);
+ pc->sidtype = sidtype;
+ DLIST_ADD(gid_sid_cache_head, pc);
+ n_gid_sid_cache++;
+}
+
+
+/*****************************************************************
+ *THE CANONICAL* convert uid_t to SID function.
+ Tries winbind first - then uses local lookup.
+ Returns SID pointer.
+*****************************************************************/
+
+DOM_SID *uid_to_sid(DOM_SID *psid, uid_t uid)
+{
+ uid_t low, high;
+ enum SID_NAME_USE sidtype;
+ fstring sid;
+
+ if (fetch_sid_from_uid_cache(psid, &sidtype, uid))
+ return psid;
+
+ if (lp_winbind_uid(&low, &high) && uid >= low && uid <= high) {
+ if (winbind_uid_to_sid(psid, uid)) {
+
+ DEBUG(10,("uid_to_sid: winbindd %u -> %s\n",
+ (unsigned int)uid, sid_to_string(sid, psid)));
+
+ if (psid)
+ store_uid_sid_cache(psid, SID_NAME_USER, uid);
+ return psid;
+ }
+ }
+
+ /* Make sure we report failure, (when psid == NULL) */
+ become_root();
+ psid = local_uid_to_sid(psid, uid);
+ unbecome_root();
+
+ DEBUG(10,("uid_to_sid: local %u -> %s\n", (unsigned int)uid, sid_to_string(sid, psid)));
+ if (psid)
+ store_uid_sid_cache(psid, SID_NAME_USER, uid);
+
+ return psid;
+}
+
+/*****************************************************************
+ *THE CANONICAL* convert gid_t to SID function.
+ Tries winbind first - then uses local lookup.
+ Returns SID pointer.
+*****************************************************************/
+
+DOM_SID *gid_to_sid(DOM_SID *psid, gid_t gid)
+{
+ gid_t low, high;
+ enum SID_NAME_USE sidtype;
+ fstring sid;
+
+ if (fetch_sid_from_gid_cache(psid, &sidtype, gid))
+ return psid;
+
+ if (lp_winbind_gid(&low, &high) && gid >= low && gid <= high) {
+ if (winbind_gid_to_sid(psid, gid)) {
+
+ DEBUG(10,("gid_to_sid: winbindd %u -> %s\n",
+ (unsigned int)gid, sid_to_string(sid, psid)));
+
+ if (psid)
+ store_gid_sid_cache(psid, SID_NAME_DOM_GRP, gid);
+ return psid;
+ }
+ }
+
+ /* Make sure we report failure, (when psid == NULL) */
+ become_root();
+ psid = local_gid_to_sid(psid, gid);
+ unbecome_root();
+ DEBUG(10,("gid_to_sid: local %u -> %s\n", (unsigned int)gid, sid_to_string(sid, psid)));
+ if (psid)
+ store_gid_sid_cache(psid, SID_NAME_DOM_GRP, gid);
+
+ return psid;
+}
+
+/*****************************************************************
+ *THE CANONICAL* convert SID to uid function.
+ Tries winbind first - then uses local lookup.
+ Returns True if this name is a user sid and the conversion
+ was done correctly, False if not. sidtype is set by this function.
+*****************************************************************/
+
+BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype)
+{
+ fstring sid_str;
+
+ if (fetch_uid_from_cache(puid, psid, *sidtype))
+ return True;
+
+ /* if we know its local then don't try winbindd */
+ if (sid_compare_domain(get_global_sam_sid(), psid) == 0) {
+ BOOL result;
+ become_root();
+ result = local_sid_to_uid(puid, psid, sidtype);
+ unbecome_root();
+ if (result)
+ store_uid_sid_cache(psid, *sidtype, *puid);
+ return result;
+ }
+
+/* (tridge) I commented out the slab of code below in order to support foreign SIDs
+ Do we really need to validate the type of SID we have in this case?
+*/
+#if 0
+ fstring dom_name, name;
+ enum SID_NAME_USE name_type;
+
+ *sidtype = SID_NAME_UNKNOWN;
+ /*
+ * First we must look up the name and decide if this is a user sid.
+ */
+
+ if ( (!winbind_lookup_sid(psid, dom_name, name, &name_type)) || (name_type != SID_NAME_USER) ) {
+ BOOL result;
+ DEBUG(10,("sid_to_uid: winbind lookup for sid %s failed - trying local.\n",
+ sid_to_string(sid_str, psid) ));
+
+ become_root();
+ result = local_sid_to_uid(puid, psid, sidtype);
+ unbecome_root();
+ return result;
+ }
+
+ /*
+ * Ensure this is a user sid.
+ */
+
+ if (name_type != SID_NAME_USER) {
+ DEBUG(10,("sid_to_uid: winbind lookup succeeded but SID is not a uid (%u)\n",
+ (unsigned int)name_type ));
+ return False;
+ }
+#endif
+ *sidtype = SID_NAME_USER;
+
+ /*
+ * Get the uid for this SID.
+ */
+
+ if (!winbind_sid_to_uid(puid, psid)) {
+ BOOL result;
+ DEBUG(10,("sid_to_uid: winbind lookup for sid %s failed.\n",
+ sid_to_string(sid_str, psid) ));
+ become_root();
+ result = local_sid_to_uid(puid, psid, sidtype);
+ unbecome_root();
+ if (result)
+ store_uid_sid_cache(psid, *sidtype, *puid);
+ return result;
+ }
+
+ DEBUG(10,("sid_to_uid: winbindd %s -> %u\n",
+ sid_to_string(sid_str, psid),
+ (unsigned int)*puid ));
+
+ store_uid_sid_cache(psid, *sidtype, *puid);
+ return True;
+}
+
+/*****************************************************************
+ *THE CANONICAL* convert SID to gid function.
+ Tries winbind first - then uses local lookup.
+ Returns True if this name is a user sid and the conversion
+ was done correctly, False if not.
+*****************************************************************/
+
+BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype)
+{
+ fstring dom_name, name, sid_str;
+ enum SID_NAME_USE name_type;
+
+ *sidtype = SID_NAME_UNKNOWN;
+
+ if (fetch_gid_from_cache(pgid, psid, *sidtype))
+ return True;
+
+ /*
+ * First we must look up the name and decide if this is a group sid.
+ */
+
+ /* if we know its local then don't try winbindd */
+ if (sid_compare_domain(get_global_sam_sid(), psid) == 0) {
+ BOOL result;
+ become_root();
+ result = local_sid_to_gid(pgid, psid, sidtype);
+ unbecome_root();
+ if (result)
+ store_gid_sid_cache(psid, *sidtype, *pgid);
+ return result;
+ }
+
+ if (!winbind_lookup_sid(psid, dom_name, name, &name_type)) {
+ DEBUG(10,("sid_to_gid: winbind lookup for sid %s failed.\n",
+ sid_to_string(sid_str, psid) ));
+ /* this was probably a foreign sid - assume its a group rid
+ and continue */
+ name_type = SID_NAME_DOM_GRP;
+ }
+
+ /*
+ * Ensure this is a group sid.
+ */
+
+ if ((name_type != SID_NAME_DOM_GRP) && (name_type != SID_NAME_ALIAS) && (name_type != SID_NAME_WKN_GRP)) {
+ DEBUG(10,("sid_to_gid: winbind lookup succeeded but SID is not a known group (%u)\n",
+ (unsigned int)name_type ));
+
+ return False;
+ }
+
+ *sidtype = name_type;
+
+ /*
+ * Get the gid for this SID.
+ */
+
+ if (!winbind_sid_to_gid(pgid, psid)) {
+ DEBUG(10,("sid_to_gid: winbind lookup for sid %s failed.\n",
+ sid_to_string(sid_str, psid) ));
+ return False;
+ }
+
+ DEBUG(10,("sid_to_gid: winbindd %s -> %u\n",
+ sid_to_string(sid_str, psid),
+ (unsigned int)*pgid ));
+
+ store_gid_sid_cache(psid, *sidtype, *pgid);
+ return True;
+}
+
diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c
index 6c12cfac62..84ec364654 100644
--- a/source3/smbd/utmp.c
+++ b/source3/smbd/utmp.c
@@ -484,6 +484,7 @@ static int ut_id_encode(int i, char *fourbyte)
*/
static BOOL sys_utmp_fill(struct utmp *u,
const char *username, const char *hostname,
+ struct in_addr *ipaddr,
const char *id_str, int id_num)
{
struct timeval timeval;
@@ -538,8 +539,9 @@ static BOOL sys_utmp_fill(struct utmp *u,
#if defined(HAVE_UT_UT_HOST)
utmp_strcpy(u->ut_host, hostname, sizeof(u->ut_host));
#endif
-
#if defined(HAVE_UT_UT_ADDR)
+ if (ipaddr)
+ u->ut_addr = ipaddr->s_addr;
/*
* "(unsigned long) ut_addr" apparently exists on at least HP-UX 10.20.
* Volunteer to implement, please ...
@@ -561,6 +563,7 @@ static BOOL sys_utmp_fill(struct utmp *u,
****************************************************************************/
void sys_utmp_yield(const char *username, const char *hostname,
+ struct in_addr *ipaddr,
const char *id_str, int id_num)
{
struct utmp u;
@@ -576,7 +579,7 @@ void sys_utmp_yield(const char *username, const char *hostname,
u.ut_type = DEAD_PROCESS;
#endif
- if (!sys_utmp_fill(&u, username, hostname, id_str, id_num)) return;
+ if (!sys_utmp_fill(&u, username, hostname, ipaddr, id_str, id_num)) return;
sys_utmp_update(&u, NULL, False);
}
@@ -586,6 +589,7 @@ void sys_utmp_yield(const char *username, const char *hostname,
****************************************************************************/
void sys_utmp_claim(const char *username, const char *hostname,
+ struct in_addr *ipaddr,
const char *id_str, int id_num)
{
struct utmp u;
@@ -596,7 +600,7 @@ void sys_utmp_claim(const char *username, const char *hostname,
u.ut_type = USER_PROCESS;
#endif
- if (!sys_utmp_fill(&u, username, hostname, id_str, id_num)) return;
+ if (!sys_utmp_fill(&u, username, hostname, ipaddr, id_str, id_num)) return;
sys_utmp_update(&u, hostname, True);
}