You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by hu...@apache.org on 2014/12/05 01:46:33 UTC

svn commit: r1643145 - in /httpd/httpd/trunk: CHANGES server/util_expr_eval.c

Author: humbedooh
Date: Fri Dec  5 00:46:33 2014
New Revision: 1643145

URL: http://svn.apache.org/viewvc?rev=1643145&view=rev
Log:
ap_expr: Add filemod function for checking file modification times.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/server/util_expr_eval.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1643145&r1=1643144&r2=1643145&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Fri Dec  5 00:46:33 2014
@@ -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.

Modified: httpd/httpd/trunk/server/util_expr_eval.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_expr_eval.c?rev=1643145&r1=1643144&r2=1643145&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_expr_eval.c (original)
+++ httpd/httpd/trunk/server/util_expr_eval.c Fri Dec  5 00:46:33 2014
@@ -1220,6 +1220,18 @@ static const char *filesize_func(ap_expr
         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
     { 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 },