summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-08-23 13:51:26 +0200
committerJeremy Allison <jra@samba.org>2018-11-09 00:47:22 +0100
commit593fdd21923b1065b7cfbedc69a214720f190e03 (patch)
tree257824b0229b5e4d41ab04c9e86d5d1950a0c298
parent2d512b278e5905964c1294c587ba405678c3d10c (diff)
downloadsamba-593fdd21923b1065b7cfbedc69a214720f190e03.tar.gz
smbd: Add "hide new files" option
See the manpage for the description Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--docs-xml/smbdotconf/filename/hidenewfilestimeout.xml15
-rw-r--r--source3/smbd/dir.c18
2 files changed, 32 insertions, 1 deletions
diff --git a/docs-xml/smbdotconf/filename/hidenewfilestimeout.xml b/docs-xml/smbdotconf/filename/hidenewfilestimeout.xml
new file mode 100644
index 00000000000..ca93e726c33
--- /dev/null
+++ b/docs-xml/smbdotconf/filename/hidenewfilestimeout.xml
@@ -0,0 +1,15 @@
+<samba:parameter name="hide new files timeout"
+ context="S"
+ type="integer"
+ xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
+ <description>
+ <para>Setting this parameter to something but 0 hides files
+ that have been modified less than N seconds ago.</para>
+ <para>It can be used for ingest/process queue style workloads. A
+ processing application should only see files that are definitely
+ finished. As many applications do not have proper external workflow
+ control, this can be a way to make sure processing does not
+ interfere with file ingest.</para>
+</description>
+<value type="default">0</value>
+</samba:parameter>
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index c3af5233e98..f05d7a290e5 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1536,6 +1536,7 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
bool hide_unreadable = lp_hide_unreadable(SNUM(conn));
bool hide_unwriteable = lp_hide_unwriteable_files(SNUM(conn));
bool hide_special = lp_hide_special_files(SNUM(conn));
+ int hide_new_files_timeout = lp_hide_new_files_timeout(SNUM(conn));
char *entry = NULL;
struct smb_filename *smb_fname_base = NULL;
bool ret = false;
@@ -1550,7 +1551,11 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
return False;
}
- if (hide_unreadable || hide_unwriteable || hide_special) {
+ if (hide_unreadable ||
+ hide_unwriteable ||
+ hide_special ||
+ (hide_new_files_timeout != 0))
+ {
entry = talloc_asprintf(talloc_tos(), "%s/%s", dir_path, name);
if (!entry) {
ret = false;
@@ -1603,6 +1608,17 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
ret = false;
goto out;
}
+
+ if (hide_new_files_timeout != 0) {
+
+ double age = timespec_elapsed(
+ &smb_fname_base->st.st_ex_mtime);
+
+ if (age < (double)hide_new_files_timeout) {
+ ret = false;
+ goto out;
+ }
+ }
}
ret = true;