]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add "dates_as_integer" configuration
authorAlan T. DeKok <aland@freeradius.org>
Fri, 15 Sep 2023 12:00:14 +0000 (08:00 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 15 Sep 2023 12:00:14 +0000 (08:00 -0400)
raddb/mods-available/detail
src/modules/rlm_detail/rlm_detail.c

index ccf65f9c839a6d9ea35fae4d9cd208ddca1a0acd..665b67797532f70c026dced1aa8e22a83010c8d9 100644 (file)
@@ -94,6 +94,39 @@ detail {
        #
 #      log_packet_header = yes
 
+
+       #
+       #  There are many, many, issues with dates being printed as
+       #  humanly-readable strings.  The server tries hard to both
+       #  print and parse dates correctly, however this is not always
+       #  possible.
+       #
+       #  The detail files may be generated on one machine, and read
+       #  on another.  The two systems may have different languages,
+       #  so the names of the month may not be parseable.  The two
+       #  systems may have different time zones.  Time zone parsing
+       #  is pretty much impossible, as there are multiple time zones
+       #  with the same name!
+       #
+       #  In some cases, the local libraries may not be able to
+       #  correctly parse the time zone it printed!  i.e. the system
+       #  documentation for the C library time functions sometimes
+       #  even says that the time zones are ignored, and the dates
+       #  are parsed as UTC.
+       #
+       #  All of these issues can be avoided by printing the dates as
+       #  integer.  In nearly all cases, the integer printed is
+       #  exactly what was received in the packet.
+       #
+       #  This may resolve some issues, but it's not perfect.  The
+       #  dates received by FreeRADIUS are sent by the NAS, and
+       #  created on the NAS.  So if the time on the NAS is wrong,
+       #  the dates printed by FreeRADIUS will also be wrong.  The
+       #  only solution is to make sure that the NAS is using the
+       #  correct time.
+       #
+#      dates_as_integer = yes
+
        #
        # Certain attributes such as User-Password may be
        # "sensitive", so they should not be printed in the
index 036549f820fed13342c960506e9088a805cb25f8..949811cd4ac68c1c15fd7634842fa508052dc256 100644 (file)
@@ -64,6 +64,8 @@ typedef struct detail_instance {
 
        bool            escape;         //!< do filename escaping, yes / no
 
+       bool            dates_as_integer;
+
        xlat_escape_t escape_func; //!< escape function
 
        exfile_t        *ef;            //!< Log file handler
@@ -79,6 +81,7 @@ static const CONF_PARSER module_config[] = {
        { "permissions", FR_CONF_OFFSET(PW_TYPE_INTEGER, rlm_detail_t, perm), "0600" },
        { "group", FR_CONF_OFFSET(PW_TYPE_STRING, rlm_detail_t, group), NULL },
        { "locking", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_detail_t, locking), "no" },
+       { "dates_as_integer", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_detail_t, dates_as_integer), "no" },
        { "escape_filenames", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_detail_t, escape), "no" },
        { "log_packet_header", FR_CONF_OFFSET(PW_TYPE_BOOLEAN, rlm_detail_t, log_srcdst), "no" },
        CONF_PARSER_TERMINATOR
@@ -317,7 +320,12 @@ static int detail_write(FILE *out, rlm_detail_t *inst, REQUEST *request, RADIUS_
                         */
                        op = vp->op;
                        vp->op = T_OP_EQ;
-                       vp_print(out, vp);
+
+                       if ((vp->da->type == PW_TYPE_DATE) && inst->dates_as_integer) {
+                               WRITE("\t%s = %u\n", vp->da->name, vp->vp_date);
+                       } else {
+                               vp_print(out, vp);
+                       }
                        vp->op = op;
                }
        }
@@ -336,7 +344,7 @@ static int detail_write(FILE *out, rlm_detail_t *inst, REQUEST *request, RADIUS_
                }
 #endif
        }
-       WRITE("\tTimestamp = %ld\n", (unsigned long) request->timestamp);
+       WRITE("\tTimestamp = %lu\n", (unsigned long) request->timestamp);
 
        WRITE("\n");