From f1d7ed9cde11f11fe38e9f4d2bc64c0586babe92 Mon Sep 17 00:00:00 2001 From: Daniel Gruno Date: Fri, 5 Dec 2014 00:46:33 +0000 Subject: [PATCH] ap_expr: Add filemod function for checking file modification times. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643145 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ server/util_expr_eval.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGES b/CHANGES index 5743938860..b7338acfd1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) ap_expr: Add filemod function for checking file modification dates + [Daniel Gruno] + *) SECURITY: CVE-2014-8109 (cve.mitre.org) mod_lua: Fix handling of the Require line when a LuaAuthzProvider is used in multiple Require directives with different arguments. diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index 9b1ea88452..6af88466fd 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -1220,6 +1220,18 @@ static const char *filesize_func(ap_expr_eval_ctx_t *ctx, const void *data, return "0"; } +static const char *filemod_func(ap_expr_eval_ctx_t *ctx, const void *data, + char *arg) +{ + apr_finfo_t sb; + if (apr_stat(&sb, arg, APR_FINFO_MIN, ctx->p) == APR_SUCCESS + && sb.filetype == APR_REG && sb.mtime > 0) + return apr_psprintf(ctx->p, "%" APR_OFF_T_FMT, sb.mtime); + else + return "0"; +} + + static const char *unescape_func(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg) { @@ -1743,6 +1755,7 @@ static const struct expr_provider_single string_func_providers[] = { { unescape_func, "unescape", NULL, 0 }, { file_func, "file", NULL, 1 }, { filesize_func, "filesize", NULL, 1 }, + { filemod_func, "filemod", NULL, 1 }, { base64_func, "base64", NULL, 0 }, { unbase64_func, "unbase64", NULL, 0 }, { sha1_func, "sha1", NULL, 0 }, -- 2.40.0