[SCM] Samba Shared Repository - branch v3-2-stable updated -
release-3-2-3-31-g709bb41
Karolin Seeger
kseeger at samba.org
Mon Sep 1 15:17:03 GMT 2008
The branch, v3-2-stable has been updated
via 709bb4106ae927ae2260d4499f5b246b854627bf (commit)
via ff7c52994aaba701dbe95b52b154d46d1865971f (commit)
via 280bbc0a674fcc5ad878b452f1a1a60ae01b4bdc (commit)
from 5221acfa459d7cdeaf17fc784d896864114c1e63 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-stable
- Log -----------------------------------------------------------------
commit 709bb4106ae927ae2260d4499f5b246b854627bf
Author: Jeremy Allison <jra at samba.org>
Date: Fri Aug 29 09:29:35 2008 -0700
Deal with systems that don't initialize birthtime correctly.
Pointed out by SATOH Fumiyasu <fumiyas at osstech.jp>.
Jeremy.
(cherry picked from commit 4876e4ffe9f5142bf90dc14b105436eaca35d3f4)
commit ff7c52994aaba701dbe95b52b154d46d1865971f
Author: Jeremy Allison <jra at samba.org>
Date: Thu Aug 28 16:04:30 2008 -0700
Clarify usage of "force create mode".
Jeremy.
(cherry picked from commit 10f036829aca0b6b4cde03893f71effbf4d30a91)
commit 280bbc0a674fcc5ad878b452f1a1a60ae01b4bdc
Author: Jeremy Allison <jra at samba.org>
Date: Thu Aug 28 12:09:06 2008 -0700
Add st_birthtime and friends for accurate create times on systems that support it (*BSD and MacOSX). This really needs to be in 3.2.x.
Should have done this ages ago, sorry.
Jeremy.
(cherry picked from commit 0cba30073410ba499834ac26dee3f81a75c8de4f)
-----------------------------------------------------------------------
Summary of changes:
docs-xml/smbdotconf/security/forcecreatemode.xml | 17 ++--
source/configure.in | 90 ++++++++++++++++++++++
source/lib/time.c | 46 +++++++++---
source/smbd/reply.c | 7 +-
4 files changed, 138 insertions(+), 22 deletions(-)
Changeset truncated at 500 lines:
diff --git a/docs-xml/smbdotconf/security/forcecreatemode.xml b/docs-xml/smbdotconf/security/forcecreatemode.xml
index 8a6449f..a3f1c2c 100644
--- a/docs-xml/smbdotconf/security/forcecreatemode.xml
+++ b/docs-xml/smbdotconf/security/forcecreatemode.xml
@@ -2,17 +2,16 @@
context="S"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
- <para>This parameter specifies a set of UNIX mode bit
- permissions that will <emphasis>always</emphasis> be set on a
- file created by Samba. This is done by bitwise 'OR'ing these bits onto
- the mode bits of a file that is being created or having its
- permissions changed. The default for this parameter is (in octal)
- 000. The modes in this parameter are bitwise 'OR'ed onto the file
- mode after the mask set in the <parameter moreinfo="none">create mask</parameter>
+ <para>This parameter specifies a set of UNIX mode bit
+ permissions that will <emphasis>always</emphasis> be set on a
+ file created by Samba. This is done by bitwise 'OR'ing these bits onto
+ the mode bits of a file that is being created. The default for this parameter is (in octal)
+ 000. The modes in this parameter are bitwise 'OR'ed onto the file
+ mode after the mask set in the <parameter moreinfo="none">create mask</parameter>
parameter is applied.</para>
- <para>The example below would force all created files to have read and execute
- permissions set for 'group' and 'other' as well as the
+ <para>The example below would force all newly created files to have read and execute
+ permissions set for 'group' and 'other' as well as the
read/write/execute bits set for the 'user'.</para>
</description>
diff --git a/source/configure.in b/source/configure.in
index 0086be7..3c699d5 100644
--- a/source/configure.in
+++ b/source/configure.in
@@ -1334,6 +1334,96 @@ if test x"$samba_cv_stat_hires_notimespec" = x"yes" ; then
[whether struct stat has sub-second timestamps without struct timespec])
fi
+AC_CACHE_CHECK([whether struct stat has st_birthtimespec], samba_cv_stat_st_birthtimespec,
+ [
+ AC_TRY_COMPILE(
+ [
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+ ],
+ [
+ struct timespec t;
+ struct stat s = {0};
+ t = s.st_birthtimespec;
+ ],
+ samba_cv_stat_st_birthtimespec=yes, samba_cv_stat_birthtimespec=no)
+ ])
+
+if test x"$samba_cv_stat_st_birthtimespec" = x"yes" ; then
+ AC_DEFINE(HAVE_STAT_ST_BIRTHTIMESPEC, 1, [whether struct stat contains st_birthtimespec])
+fi
+
+AC_CACHE_CHECK([whether struct stat has st_birthtimensec], samba_cv_stat_st_birthtimensec,
+ [
+ AC_TRY_COMPILE(
+ [
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+ ],
+ [
+ struct timespec t;
+ struct stat s = {0};
+ t.tv_nsec = s.st_birthtimensec;
+ ],
+ samba_cv_stat_st_birthtimensec=yes, samba_cv_stat_birthtimensec=no)
+ ])
+
+if test x"$samba_cv_stat_st_birthtimensec" = x"yes" ; then
+ AC_DEFINE(HAVE_STAT_ST_BIRTHTIMENSEC, 1, [whether struct stat contains st_birthtimensec])
+fi
+
+AC_CACHE_CHECK([whether struct stat has st_birthtime], samba_cv_stat_st_birthtime,
+ [
+ AC_TRY_COMPILE(
+ [
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+ ],
+ [
+ struct time_t t;
+ struct stat s = {0};
+ t = s.st_birthtime;
+ ],
+ samba_cv_stat_st_birthtime=yes, samba_cv_stat_birthtime=no)
+ ])
+
+if test x"$samba_cv_stat_st_birthtime" = x"yes" ; then
+ AC_DEFINE(HAVE_STAT_ST_BIRTHTIME, 1, [whether struct stat contains st_birthtime])
+fi
+
#####################################
# needed for SRV lookups
AC_CHECK_LIB(resolv, dn_expand)
diff --git a/source/lib/time.c b/source/lib/time.c
index 17990b9..425539c 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -826,14 +826,10 @@ void put_long_date(char *p, time_t t)
structure.
****************************************************************************/
-time_t get_create_time(const SMB_STRUCT_STAT *st,bool fake_dirs)
+static time_t calc_create_time(const SMB_STRUCT_STAT *st)
{
time_t ret, ret1;
- if(S_ISDIR(st->st_mode) && fake_dirs) {
- return (time_t)315493200L; /* 1/1/1980 */
- }
-
ret = MIN(st->st_ctime, st->st_mtime);
ret1 = MIN(ret, st->st_atime);
@@ -848,12 +844,42 @@ time_t get_create_time(const SMB_STRUCT_STAT *st,bool fake_dirs)
return ret;
}
-struct timespec get_create_timespec(const SMB_STRUCT_STAT *st,bool fake_dirs)
+/****************************************************************************
+ Return the 'create time' from a stat struct if it exists (birthtime) or else
+ use the best approximation.
+****************************************************************************/
+
+struct timespec get_create_timespec(const SMB_STRUCT_STAT *pst,bool fake_dirs)
{
- struct timespec ts;
- ts.tv_sec = get_create_time(st, fake_dirs);
- ts.tv_nsec = 0;
- return ts;
+ struct timespec ret;
+
+ if(S_ISDIR(pst->st_mode) && fake_dirs) {
+ ret.tv_sec = 315493200L; /* 1/1/1980 */
+ ret.tv_nsec = 0;
+ return ret;
+ }
+
+#if defined(HAVE_STAT_ST_BIRTHTIMESPEC)
+ ret = pst->st_birthtimespec;
+#elif defined(HAVE_STAT_ST_BIRTHTIMENSEC)
+ ret.tv_sec = pst->st_birthtime;
+ ret.tv_nsec = pst->st_birthtimenspec;
+#elif defined(HAVE_STAT_ST_BIRTHTIME)
+ ret.tv_sec = pst->st_birthtime;
+ ret.tv_nsec = 0;
+#else
+ ret.tv_sec = calc_create_time(pst);
+ ret.tv_nsec = 0;
+#endif
+
+ /* Deal with systems that don't initialize birthtime correctly.
+ * Pointed out by SATOH Fumiyasu <fumiyas at osstech.jp>.
+ */
+ if (null_timespec(ret)) {
+ ret.tv_sec = calc_create_time(pst);
+ ret.tv_nsec = 0;
+ }
+ return ret;
}
/****************************************************************************
diff --git a/source/smbd/reply.c b/source/smbd/reply.c
index 31844c5..67b382d 100644
--- a/source/smbd/reply.c
+++ b/source/smbd/reply.c
@@ -7096,6 +7096,7 @@ void reply_getattrE(struct smb_request *req)
SMB_STRUCT_STAT sbuf;
int mode;
files_struct *fsp;
+ struct timespec create_ts;
START_PROFILE(SMBgetattrE);
@@ -7130,9 +7131,9 @@ void reply_getattrE(struct smb_request *req)
reply_outbuf(req, 11, 0);
- srv_put_dos_date2((char *)req->outbuf, smb_vwv0,
- get_create_time(&sbuf,
- lp_fake_dir_create_times(SNUM(conn))));
+ create_ts = get_create_timespec(&sbuf,
+ lp_fake_dir_create_times(SNUM(conn)));
+ srv_put_dos_date2((char *)req->outbuf, smb_vwv0, create_ts.tv_sec);
srv_put_dos_date2((char *)req->outbuf, smb_vwv2, sbuf.st_atime);
/* Should we check pending modtime here ? JRA */
srv_put_dos_date2((char *)req->outbuf, smb_vwv4, sbuf.st_mtime);
--
Samba Shared Repository
More information about the samba-cvs
mailing list