]> granicus.if.org Git - apache/commitdiff
ap_expr: Add filemod function for checking file modification times.
authorDaniel Gruno <humbedooh@apache.org>
Fri, 5 Dec 2014 00:46:33 +0000 (00:46 +0000)
committerDaniel Gruno <humbedooh@apache.org>
Fri, 5 Dec 2014 00:46:33 +0000 (00:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1643145 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/util_expr_eval.c

diff --git a/CHANGES b/CHANGES
index 5743938860acca6398413c2d95d2ed63acead8f7..b7338acfd10fe432cfd52c49d8115c0037dd6c3b 100644 (file)
--- 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.
index 9b1ea884521a33650969bf3c7947abfaca459c5c..6af88466fda60ba8f84f16401f117516edac5757 100644 (file)
@@ -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 },