summaryrefslogtreecommitdiff
path: root/lib/smbconf
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2023-01-26 09:39:10 -0800
committerAndreas Schneider <asn@cryptomilk.org>2023-01-27 08:30:35 +0000
commit7e0eb0f31a24ef6d1742363d70090875d1037dc2 (patch)
tree695449110fa5ac68c49018710ec4049b7e5bd470 /lib/smbconf
parent96154a26fee79a496e86b7fa134223487ba7c6a3 (diff)
downloadsamba-7e0eb0f31a24ef6d1742363d70090875d1037dc2.tar.gz
s3:lib: Change file_modtime() to return an error code and a struct timespec.
Removes need for external stat() code when checking for timechange. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Fri Jan 27 08:30:35 UTC 2023 on atb-devel-224
Diffstat (limited to 'lib/smbconf')
-rw-r--r--lib/smbconf/smbconf_txt.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 5c4bd27b9df..70a35ec4304 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -184,12 +184,23 @@ static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx)
{
sbcErr err;
uint64_t new_csn;
+ int rc;
+ struct timespec mt = {0};
if (!file_exist(ctx->path)) {
return SBC_ERR_BADFILE;
}
- new_csn = (uint64_t)file_modtime(ctx->path);
+ rc = file_modtime(ctx->path, &mt);
+ if (rc != 0) {
+ /*
+ * Not worth mapping errno returned
+ * in rc to SBC_ERR_XXX. Just assume
+ * access denied.
+ */
+ return SBC_ERR_ACCESS_DENIED;
+ }
+ new_csn = (uint64_t)mt.tv_sec;
if (new_csn == pd(ctx)->csn) {
return SBC_ERR_OK;
}
@@ -275,11 +286,14 @@ static void smbconf_txt_get_csn(struct smbconf_ctx *ctx,
struct smbconf_csn *csn,
const char *service, const char *param)
{
+ struct timespec mt = {0};
+
if (csn == NULL) {
return;
}
- csn->csn = (uint64_t)file_modtime(ctx->path);
+ (void)file_modtime(ctx->path, &mt);
+ csn->csn = (uint64_t)mt.tv_sec;
}
/**