[SCM] Samba Shared Repository - branch v3-5-stable updated

Karolin Seeger kseeger at samba.org
Mon Dec 14 00:51:16 MST 2009


The branch, v3-5-stable has been updated
       via  ea24a32... WHATSNEW: Update changes since Samba 3.5.0pre1.
       via  9b94aec... s3: Fix a very embarrassing build failure (cherry picked from commit d2453d9a944e2d8ecebeecb94014057dd4fc0fd6)
       via  f364a3c... s3:docs: document ldap deref (cherry picked from commit 54d072b83c53f393253052efd5197b48fac61acb)
       via  66a64e4... s3: add LDAP Alias Dereferencing support
       via  ab21c2c... s3: keep subsecond times on cross-filesystem moves and don't follow links (cherry picked from commit faccec7b97b469b170932f27d8b7e0baf985a909)
       via  32aa54b... s3:packaging: Fix version detection.
       via  ae6e1fe... s3:packaging: Fix source dir.
       via  8805cb6... s3:packaging: Fix typo in comment.
       via  1980094... s3: check for PAM_RADIO_TYPE.
       via  6552778... s3: Fix build on non-linux platform.
       via  95d0192... s3: Give the user a chance to change password when password will expire soon.
       via  19ed997... s3:doc: make dos filetimes description less contradictory (cherry picked from commit 2a6391bc43cf2550731039bf158d561b307c9c58)
       via  3647eb0... s3: make sys_posix_fallocate more generic
       via  925e825... s3: allocate only "new" space, not "old" sparse space in the posix_fallocate path
      from  352adf3... WHATSNEW: Add changes since 3.5.0pre1.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-5-stable


- Log -----------------------------------------------------------------
commit ea24a32d4511a643b26c4abd69e5c40ec924ac5d
Author: Karolin Seeger <kseeger at samba.org>
Date:   Mon Dec 14 08:39:54 2009 +0100

    WHATSNEW: Update changes since Samba 3.5.0pre1.
    
    Karolin
    (cherry picked from commit 8804b13c96dd0d8334762f968a349d1e432a1acc)

commit 9b94aec3d9415330a88aeff0261eab1f9c3aaae7
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Dec 12 16:58:31 2009 +0100

    s3: Fix a very embarrassing build failure
    (cherry picked from commit d2453d9a944e2d8ecebeecb94014057dd4fc0fd6)

commit f364a3cdfaf3f658f5f33d24a9ce55bf5ed0cf15
Author: Björn Jacke <bj at sernet.de>
Date:   Fri Dec 11 13:28:31 2009 +0100

    s3:docs: document ldap deref
    (cherry picked from commit 54d072b83c53f393253052efd5197b48fac61acb)

commit 66a64e4ebf56fc7eb61de25896a0a8adb7ec3d5d
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Dec 10 21:00:26 2009 +0100

    s3: add LDAP Alias Dereferencing support
    
    Thanks to Dan Cox for initial patch for 3.0. This closes #2350.
    
    The default for "ldap deref" is "auto" which means the LDAP library's default
    behaviour will be used and samba does not set any dereferencing parameter by
    itself.
    (cherry picked from commit 8adbc166b230b37ff18ba70f2280a9a729240ff1)

commit ab21c2c274f1a5d1e405da4be36c194a02141311
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Dec 9 02:06:17 2009 +0100

    s3: keep subsecond times on cross-filesystem moves and don't follow links
    (cherry picked from commit faccec7b97b469b170932f27d8b7e0baf985a909)

commit 32aa54bec778f13f0c69d91f61a322c3739f6b84
Author: Karolin Seeger <kseeger at samba.org>
Date:   Thu Dec 10 14:57:08 2009 +0100

    s3:packaging: Fix version detection.
    
    Adapted from 728b01fc03.
    Thanks god I was not root! It would have delted /*!
    
    Karolin
    (cherry picked from commit 0604c696a05773a439538d88f1b45aa6637766a7)
    (cherry picked from commit fd30552aab88572b2d5944b9b87ee8ca76d29b35)

commit ae6e1fee100e12b88cc258f4dfebfcbbf33bac06
Author: Karolin Seeger <kseeger at samba.org>
Date:   Thu Dec 10 14:26:58 2009 +0100

    s3:packaging: Fix source dir.
    
    Karolin
    (cherry picked from commit 85e79a2a03e8c1c6275363c39b0fa71283214562)
    (cherry picked from commit 1ed3172d10ca96816ec548996953579ec55da660)

commit 8805cb66d802e16630440d0abdded526ac8891e6
Author: Karolin Seeger <kseeger at samba.org>
Date:   Thu Dec 10 14:08:43 2009 +0100

    s3:packaging: Fix typo in comment.
    
    Karolin
    (cherry picked from commit b5011ba2c897fa177f1e22dde075055b9ffd271d)
    (cherry picked from commit 3b812b134d819097df51bb20bdb4fd856f4ad00d)

commit 1980094125fb02ebb81960d4632adace29c32d1f
Author: Bo Yang <boyang at samba.org>
Date:   Thu Dec 10 19:29:24 2009 +0800

    s3: check for PAM_RADIO_TYPE.
    
    Signed-off-by: Bo Yang <boyang at samba.org>
    (cherry picked from commit c7e3a2dc319cc6504356be7fa7970917404a69b5)
    (cherry picked from commit fa572721577732c1b5d1cd32de4479a34c895919)

commit 6552778ed65a65268b14dc0ef88a0fd9da3e62b3
Author: Bo Yang <boyang at samba.org>
Date:   Thu Dec 10 17:20:03 2009 +0800

    s3: Fix build on non-linux platform.
    
    Signed-off-by: Bo Yang <boyang at samba.org>
    (cherry picked from commit b386c3311d8c05ccbd075ab86be2ddace335b73b)
    (cherry picked from commit 9a522cd96d66f6a6cf5f483fb8928982bbe95ea4)

commit 95d0192706b5f8caf2aa091a401aa6990d70986f
Author: Bo Yang <boyang at samba.org>
Date:   Thu Dec 10 14:30:13 2009 +0800

    s3: Give the user a chance to change password when password will expire soon.
    
    Signed-off-by: Bo Yang <boyang at samba.org>
    (cherry picked from commit f7723293a07d1b7a4f3476939590fa8db6080d06)
    (cherry picked from commit 7097f6101e52220f7ff0ef821efa5b1810b2604d)

commit 19ed99744cc55149f361e2ea65a354a1b0bddc1c
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Dec 8 21:32:51 2009 +0100

    s3:doc: make dos filetimes description less contradictory
    (cherry picked from commit 2a6391bc43cf2550731039bf158d561b307c9c58)

commit 3647eb0bd2a77ab1182b52d6e113f60b30b8ab59
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Dec 8 21:13:19 2009 +0100

    s3: make sys_posix_fallocate more generic
    
    this is in preparation for other preallocation methods to be introduced.
    (cherry picked from commit 39be2d18a24176b9300834a0552180cdfb11ca5f)

commit 925e825944c27f9f11796df8d7937a30537a3869
Author: Björn Jacke <bj at sernet.de>
Date:   Tue Dec 8 10:30:03 2009 +0100

    s3: allocate only "new" space, not "old" sparse space in the posix_fallocate path
    
    this makes the posix_fallocate path work analogous to the manual allocate path.
    (cherry picked from commit e9fb2807037919a598e17d24def4897e0cbfe19c)

-----------------------------------------------------------------------

Summary of changes:
 WHATSNEW.txt                              |    5 +
 docs-xml/smbdotconf/ldap/ldapderef.xml    |   21 +++++
 docs-xml/smbdotconf/misc/dosfiletimes.xml |    8 +-
 nsswitch/pam_winbind.c                    |  126 ++++++++++++++++++++++++++---
 packaging/RHEL/makerpms.git.sh            |    6 +-
 packaging/RHEL/makerpms.sh.tmpl           |    2 +-
 source3/configure.in                      |   33 ++++++++
 source3/include/proto.h                   |    1 +
 source3/lib/smbldap.c                     |   11 +++
 source3/lib/system.c                      |    8 +-
 source3/modules/vfs_default.c             |   50 ++++++++----
 source3/param/loadparm.c                  |   26 ++++++
 source3/smbd/quotas.c                     |    4 +-
 13 files changed, 260 insertions(+), 41 deletions(-)
 create mode 100644 docs-xml/smbdotconf/ldap/ldapderef.xml


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 7dcafd5..9a18f60 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -116,6 +116,10 @@ o   Jeremy Allison <jra at samba.org>
     * Refactor reply_rmdir to use handle based code.
 
 
+o   Dan Cox <dan at wep.net>
+    * BUG 2350: Add LDAP Alias Dereferencing support.
+
+
 o   Günther Deschner <gd at samba.org>
     * BUG 6929: Fix build with recent heimdal.
     * Fix several printing issues.
@@ -163,6 +167,7 @@ o   Karolin Seeger <kseeger at samba.org>
 o   Bo Yang <boyang at samba.org>
     * BUG 6879: Fix crash in Winbind.
     * Fix crash in free_file_list().
+    * Give the user a chance to change password when password will expire soon.
 
 
 ######################################################################
diff --git a/docs-xml/smbdotconf/ldap/ldapderef.xml b/docs-xml/smbdotconf/ldap/ldapderef.xml
new file mode 100644
index 0000000..e4868a6
--- /dev/null
+++ b/docs-xml/smbdotconf/ldap/ldapderef.xml
@@ -0,0 +1,21 @@
+<samba:parameter name="ldap deref" context="G" type="enum"
+	advanced="1" developer="1"
+	xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+
+<description>
+
+	<para>This option controls whether Samba should tell the LDAP library
+	to use a certain alias dereferencing method. The default is
+	<emphasis>auto</emphasis>, which means that the default setting of the
+	ldap client library will be kept. Other possible values are
+	<emphasis>never</emphasis>, </emphasis>finding</emphasis>,
+	</emphasis>searching</emphasis> and <emphasis>always</emphasis>. Grab
+	your LDAP manual for more information.
+	</para>
+
+</description>
+
+<value type="default">auto</value>
+<value type="example">searching</value>
+
+</samba:parameter>
diff --git a/docs-xml/smbdotconf/misc/dosfiletimes.xml b/docs-xml/smbdotconf/misc/dosfiletimes.xml
index 90f93a0..423b13c 100644
--- a/docs-xml/smbdotconf/misc/dosfiletimes.xml
+++ b/docs-xml/smbdotconf/misc/dosfiletimes.xml
@@ -6,12 +6,10 @@
 	<para>Under DOS and Windows, if a user can write to a 
 	file they can change the timestamp on it. Under POSIX semantics, 
 	only the owner of the file or root may change the timestamp. By 
-	default, Samba runs with POSIX semantics and refuses to change the 
+	default, Samba emulates the DOS semantics and allows to change the 
 	timestamp on a file if the user <command moreinfo="none">smbd</command> is acting 
-	on behalf of is not the file owner. Setting this option to <constant>
-	yes</constant> allows DOS semantics and <citerefentry><refentrytitle>smbd</refentrytitle>
-	<manvolnum>8</manvolnum></citerefentry> will change the file 
-	timestamp as DOS requires. Due to changes in Microsoft Office 2000 and beyond,
+	on behalf has write permissions.
+	Due to changes in Microsoft Office 2000 and beyond,
 	the default for this parameter has been changed from "no" to "yes" in Samba 3.0.14
 	and above. Microsoft Excel will display dialog box warnings about the file being
 	changed by another user if this parameter is not set to "yes" and files are being
diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index be9468c..3e13517 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -807,6 +807,43 @@ static int wbc_auth_error_to_pam_error(struct pwb_context *ctx,
 	return pam_winbind_request_log(ctx, ret, username, fn);
 }
 
+#if defined(HAVE_PAM_RADIO_TYPE)
+static bool _pam_winbind_change_pwd(struct pwb_context *ctx)
+{
+	struct pam_message msg, *pmsg;
+	struct pam_response *resp = NULL;
+	const char *prompt;
+	int ret;
+	bool retval = false;
+	prompt = _("Do you want to change your password now?");
+	pmsg = &msg;
+	msg.msg_style = PAM_RADIO_TYPE;
+	msg.msg = prompt;
+	ret = converse(ctx->pamh, 1, &pmsg, &resp);
+	if (resp == NULL) {
+		if (ret == PAM_SUCCESS) {
+			_pam_log(ctx, LOG_CRIT, "pam_winbind: system error!\n");
+			return false;
+		}
+	}
+	if (ret != PAM_SUCCESS) {
+		return false;
+	}
+	_pam_log(ctx, LOG_CRIT, "Received [%s] reply from application.\n", resp->resp);
+
+	if (strcasecmp(resp->resp, "yes") == 0) {
+		retval = true;
+	}
+
+	_pam_drop_reply(resp, 1);
+	return retval;
+}
+#else
+static bool _pam_winbind_change_pwd(struct pwb_context *ctx)
+{
+	return false;
+}
+#endif
 
 /**
  * send a password expiry message if required
@@ -823,15 +860,22 @@ static bool _pam_send_password_expiry_message(struct pwb_context *ctx,
 					      time_t next_change,
 					      time_t now,
 					      int warn_pwd_expire,
-					      bool *already_expired)
+					      bool *already_expired,
+					      bool *change_pwd)
 {
 	int days = 0;
 	struct tm tm_now, tm_next_change;
+	bool retval = false;
+	int ret;
 
 	if (already_expired) {
 		*already_expired = false;
 	}
 
+	if (change_pwd) {
+		*change_pwd = false;
+	}
+
 	if (next_change <= now) {
 		PAM_WB_REMARK_DIRECT(ctx, "NT_STATUS_PASSWORD_EXPIRED");
 		if (already_expired) {
@@ -854,15 +898,61 @@ static bool _pam_send_password_expiry_message(struct pwb_context *ctx,
 	       (tm_now.tm_yday+tm_now.tm_year*365);
 
 	if (days == 0) {
-		_make_remark(ctx, PAM_TEXT_INFO,
-			     _("Your password expires today"));
+		ret = _make_remark(ctx, PAM_TEXT_INFO,
+				_("Your password expires today.\n"));
+
+		/*
+		 * If change_pwd and already_expired is null.
+		 * We are just sending a notification message.
+		 * We don't expect any response in this case.
+		 */
+
+		if (!change_pwd && !already_expired) {
+			return true;
+		}
+
+		/*
+		 * successfully sent the warning message.
+		 * Give the user a chance to change pwd.
+		 */
+		if (ret == PAM_SUCCESS) {
+			if (change_pwd) {
+				retval = _pam_winbind_change_pwd(ctx);
+				if (retval) {
+					*change_pwd = true;
+				}
+			}
+		}
 		return true;
 	}
 
 	if (days > 0 && days < warn_pwd_expire) {
-		_make_remark_format(ctx, PAM_TEXT_INFO,
-				    _("Your password will expire in %d %s"),
-				    days, (days > 1) ? _("days"):_("day"));
+
+		ret = _make_remark_format(ctx, PAM_TEXT_INFO,
+					_("Your password will expire in %d %s.\n"),
+					days, (days > 1) ? _("days"):_("day"));
+		/*
+		 * If change_pwd and already_expired is null.
+		 * We are just sending a notification message.
+		 * We don't expect any response in this case.
+		 */
+
+		if (!change_pwd && !already_expired) {
+			return true;
+		}
+
+		/*
+		 * successfully sent the warning message.
+		 * Give the user a chance to change pwd.
+		 */
+		if (ret == PAM_SUCCESS) {
+			if (change_pwd) {
+				retval = _pam_winbind_change_pwd(ctx);
+				if (retval) {
+					*change_pwd = true;
+				}
+			}
+		}
 		return true;
 	}
 
@@ -883,7 +973,8 @@ static void _pam_warn_password_expiry(struct pwb_context *ctx,
 				      const struct wbcAuthUserInfo *info,
 				      const struct wbcUserPasswordPolicyInfo *policy,
 				      int warn_pwd_expire,
-				      bool *already_expired)
+				      bool *already_expired,
+				      bool *change_pwd)
 {
 	time_t now = time(NULL);
 	time_t next_change = 0;
@@ -896,6 +987,10 @@ static void _pam_warn_password_expiry(struct pwb_context *ctx,
 		*already_expired = false;
 	}
 
+	if (change_pwd) {
+		*change_pwd = false;
+	}
+
 	/* accounts with WBC_ACB_PWNOEXP set never receive a warning */
 	if (info->acct_flags & WBC_ACB_PWNOEXP) {
 		return;
@@ -911,7 +1006,8 @@ static void _pam_warn_password_expiry(struct pwb_context *ctx,
 
 	if (_pam_send_password_expiry_message(ctx, next_change, now,
 					      warn_pwd_expire,
-					      already_expired)) {
+					      already_expired,
+					      change_pwd)) {
 		return;
 	}
 
@@ -927,7 +1023,8 @@ static void _pam_warn_password_expiry(struct pwb_context *ctx,
 
 	if (_pam_send_password_expiry_message(ctx, next_change, now,
 					      warn_pwd_expire,
-					      already_expired)) {
+					      already_expired,
+					      change_pwd)) {
 		return;
 	}
 
@@ -1744,11 +1841,13 @@ static int winbind_auth_request(struct pwb_context *ctx,
 	if ((ret == PAM_SUCCESS) && user_info && policy && info) {
 
 		bool already_expired = false;
+		bool change_pwd = false;
 
 		/* warn a user if the password is about to expire soon */
 		_pam_warn_password_expiry(ctx, user_info, policy,
 					  warn_pwd_expire,
-					  &already_expired);
+					  &already_expired,
+					  &change_pwd);
 
 		if (already_expired == true) {
 
@@ -1767,6 +1866,11 @@ static int winbind_auth_request(struct pwb_context *ctx,
 			return PAM_AUTHTOK_EXPIRED;
 		}
 
+		if (change_pwd) {
+			ret = PAM_NEW_AUTHTOK_REQD;
+			goto done;
+		}
+
 		/* inform about logon type */
 		_pam_warn_logon_type(ctx, user, user_info->user_flags);
 
@@ -3123,7 +3227,7 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags,
 				 * expire soon */
 				_pam_warn_password_expiry(ctx, user_info, policy,
 							  warn_pwd_expire,
-							  NULL);
+							  NULL, NULL);
 
 				/* set some info3 info for other modules in the
 				 * stack */
diff --git a/packaging/RHEL/makerpms.git.sh b/packaging/RHEL/makerpms.git.sh
index a8cb477..68f9d96 100755
--- a/packaging/RHEL/makerpms.git.sh
+++ b/packaging/RHEL/makerpms.git.sh
@@ -29,7 +29,7 @@ GRPID=`id -g`
 
 DIRNAME=$(dirname $0)
 TOPDIR=${DIRNAME}/../..
-SRCDIR=${TOPDIR}/source
+SRCDIR=${TOPDIR}/source3
 VERSION_H=${SRCDIR}/include/version.h
 
 SPECFILE="samba.spec"
@@ -61,8 +61,8 @@ if [ ! -f ${VERSION_H} ] ; then
 	exit 1
 fi
 
-VERSION=`grep SAMBA_VERSION_OFFICIAL_STRING ${VERSION_H} | awk '{print $3}'`
-vendor_version=`grep SAMBA_VERSION_VENDOR_SUFFIX ${VERSION_H} | awk '{print $3}'`
+VERSION=`grep "^#define SAMBA_VERSION_OFFICIAL_STRING " ${VERSION_H} | awk '{print $3}'`
+vendor_version=`grep "^#define SAMBA_VERSION_VENDOR_SUFFIX " ${VERSION_H} | awk '{print $3}'`
 if test "x${vendor_version}"  != "x" ; then
 	VERSION="${VERSION}-${vendor_version}"
 fi
diff --git a/packaging/RHEL/makerpms.sh.tmpl b/packaging/RHEL/makerpms.sh.tmpl
index 93d2d82..03e56f5 100644
--- a/packaging/RHEL/makerpms.sh.tmpl
+++ b/packaging/RHEL/makerpms.sh.tmpl
@@ -16,7 +16,7 @@ EXTRA_OPTIONS="$1"
 SPECDIR=`rpm --eval %_specdir`
 SRCDIR=`rpm --eval %_sourcedir`
 
-# At this point the SPECDIR and SRCDIR vaiables must have a value!
+# At this point the SPECDIR and SRCDIR variables must have a value!
 
 USERID=`id -u`
 GRPID=`id -g`
diff --git a/source3/configure.in b/source3/configure.in
index 20293ea..2da1f9e 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -4441,6 +4441,39 @@ if test x"${try_pam}" != x"no";then
 fi # try_pam != no
 
 #################################################
+# check for PAM_RADIO_TYPE
+AC_TRY_COMPILE([
+#if (!defined(LINUX))
+
+#define PAM_EXTERN extern
+#if defined(HAVE_SECURITY_PAM_APPL_H)
+#include <security/pam_appl.h>
+#elif defined(HAVE_PAM_PAM_APPL_H)
+#include <pam/pam_appl.h>
+#endif
+
+#endif
+
+#if defined(HAVE_SECURITY_PAM_MODULES_H)
+#include <security/pam_modules.h>
+#elif defined(HAVE_PAM_PAM_MODULES_H)
+#include <pam/pam_modules.h>
+#endif
+
+#if defined(HAVE_SECURITY__PAM_MACROS_H)
+#include <security/_pam_macros.h>
+#elif defined(HAVE_PAM__PAM_MACROS_H)
+#include <pam/_pam_macros.h>
+#endif
+
+#ifdef HAVE_SECURITY_PAM_EXT_H
+#include <security/pam_ext.h>
+#endif
+],
+[int i; i = PAM_RADIO_TYPE; ],
+AC_DEFINE(HAVE_PAM_RADIO_TYPE, 1, [Define to 1 if PAM_RADIO_TYPE is available]),[])
+
+#################################################
 # check for pam_smbpass support
 PAM_MODULES=""
 INSTALL_PAM_MODULES=""
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7b575ca..56505ba 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3993,6 +3993,7 @@ char *lp_ldap_suffix(void);
 char *lp_ldap_admin_dn(void);
 int lp_ldap_ssl(void);
 bool lp_ldap_ssl_ads(void);
+int lp_ldap_deref(void);
 int lp_ldap_follow_referral(void);
 int lp_ldap_passwd_sync(void);
 bool lp_ldap_delete_dn(void);
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index f7ca1c1..4727c15 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -877,6 +877,7 @@ static int smbldap_open_connection (struct smbldap_state *ldap_state)
 {
 	int rc = LDAP_SUCCESS;
 	int version;
+	int deref;
 	LDAP **ldap_struct = &ldap_state->ldap_struct;
 
 	rc = smb_ldap_setup_conn(ldap_struct, ldap_state->uri);
@@ -902,6 +903,16 @@ static int smbldap_open_connection (struct smbldap_state *ldap_state)
 		return rc;
 	}
 
+	/* Set alias dereferencing method */
+	deref = lp_ldap_deref();
+	if (deref != -1) {
+		if (ldap_set_option (*ldap_struct, LDAP_OPT_DEREF, &deref) != LDAP_OPT_SUCCESS) {
+			DEBUG(1,("smbldap_open_connection: Failed to set dereferencing method: %d\n", deref));
+		} else {
+			DEBUG(5,("Set dereferencing method: %d\n", deref));
+		}
+	}
+
 	DEBUG(2, ("smbldap_open_connection: connection opened\n"));
 	return rc;
 }
diff --git a/source3/lib/system.c b/source3/lib/system.c
index a2dd899..a58d903 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -621,16 +621,16 @@ int sys_lstat(const char *fname,SMB_STRUCT_STAT *sbuf,
 /*******************************************************************
  An posix_fallocate() wrapper that will deal with 64 bit filesizes.
 ********************************************************************/
-#if (defined(HAVE_POSIX_FALLOCATE64) || defined(HAVE_POSIX_FALLOCATE)) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
 int sys_posix_fallocate(int fd, SMB_OFF_T offset, SMB_OFF_T len)
 {
-#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_POSIX_FALLOCATE64)
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OFF64_T) && defined(HAVE_POSIX_FALLOCATE64) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
 	return posix_fallocate64(fd, offset, len);
-#else
+#elif defined(HAVE_POSIX_FALLOCATE) && !defined(HAVE_BROKEN_POSIX_FALLOCATE)
 	return posix_fallocate(fd, offset, len);
+#else
+	return ENOSYS;
 #endif
 }
-#endif
 
 /*******************************************************************
  An ftruncate() wrapper that will deal with 64 bit filesizes.
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 3691fb0..6e2a571 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -540,6 +540,27 @@ static int copy_reg(const char *source, const char *dest)
 		return -1;
 
 	/* Try to copy the old file's modtime and access time.  */
+#if defined(HAVE_UTIMENSAT)
+	{
+		struct timespec ts[2];
+
+		ts[0] = source_stats.st_ex_atime;
+		ts[1] = source_stats.st_ex_mtime;
+		utimensat(AT_FDCWD, dest, ts, AT_SYMLINK_NOFOLLOW);
+	}
+#elif defined(HAVE_UTIMES)
+	{
+		struct timeval tv[2];
+
+		tv[0] = convert_timespec_to_timeval(source_stats.st_ex_atime);
+		tv[1] = convert_timespec_to_timeval(source_stats.st_ex_mtime);
+#ifdef HAVE_LUTIMES
+		lutimes(dest, tv);
+#else
+		utimes(dest, tv);
+#endif
+	}
+#elif defined(HAVE_UTIME)
 	{
 		struct utimbuf tv;
 
@@ -547,6 +568,7 @@ static int copy_reg(const char *source, const char *dest)
 		tv.modtime = convert_timespec_to_time_t(source_stats.st_ex_mtime);
 		utime(dest, &tv);
 	}
+#endif
 
 	if (unlink (source) == -1)
 		return -1;
@@ -917,6 +939,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
 	SMB_OFF_T space_to_write;
 	uint64_t space_avail;
 	uint64_t bsize,dfree,dsize;
+	int ret;
 
 	if (currpos == -1)
 		return -1;
@@ -936,28 +959,25 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
 	if (st.st_ex_size > len)
 		return sys_ftruncate(fsp->fh->fd, len);
 
+	space_to_write = len - st.st_ex_size;
+
 	/* for allocation try posix_fallocate first. This can fail on some
 	   platforms e.g. when the filesystem doesn't support it and no
 	   emulation is being done by the libc (like on AIX with JFS1). In that
 	   case we do our own emulation. posix_fallocate implementations can
 	   return ENOTSUP or EINVAL in cases like that. */
-#if defined(HAVE_POSIX_FALLOCATE)
-	{
-		int ret = sys_posix_fallocate(fsp->fh->fd, 0, len);
-		if (ret == ENOSPC) {
-			errno = ENOSPC;
-			return -1;
-		}
-		if (ret == 0) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list