Skip to content

Commit 40a423b

Browse files
authored
Merge pull request #5994 from amousset/date-2038
CFE-4620: Adapt date constraints to allow dates after Y2038
2 parents 3eb71c7 + 411749d commit 40a423b

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ AC_CHECK_TYPES(socklen_t, [], [], [[
848848
#include <sys/socket.h>
849849
]])
850850

851+
AC_CHECK_SIZEOF(time_t)
852+
if test "x$ac_cv_sizeof_time_t" = "x8"; then
853+
AC_DEFINE(HAVE_64BIT_TIME_T, 1, [Define if time_t is 64-bit])
854+
fi
855+
851856
dnl ######################################################################
852857
dnl Checks for typedefs, structures, and compiler characteristics.
853858
dnl ######################################################################

libpromises/cf3.defs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,12 @@ typedef enum
562562

563563
#define CF_BOOL "true,false,yes,no,on,off"
564564
#define CF_LINKRANGE "symlink,hardlink,relative,absolute"
565-
#define CF_TIMERANGE "0,2147483647" /* i.e. "0,0x7fffffff" */
565+
566+
#ifdef HAVE_64BIT_TIME_T
567+
# define CF_TIMERANGE "0,99999999999" /* Same as other max int values */
568+
#else
569+
# define CF_TIMERANGE "0,2147483647" /* i.e. "0,0x7fffffff" */
570+
#endif
566571

567572
/* Syntax checker accepts absurdly big numbers for backwards
568573
* compatibility. WARNING: internally they are stored as longs, possibly
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
body common control
2+
{
3+
inputs => {
4+
"../../default.cf.sub",
5+
};
6+
bundlesequence => { default("$(this.promise_filename)") };
7+
version => "1.0";
8+
}
9+
10+
bundle agent init
11+
{
12+
commands:
13+
# Ensure there is a file with a date in the future beyond 2038
14+
"/usr/bin/touch -t 204201010000 $(this.promise_filename).sub.file-with-mtime-after-2038";
15+
}
16+
17+
bundle agent test
18+
{
19+
meta:
20+
"description" string => "Test that the agent does not crash on dates after 2038.";
21+
22+
}
23+
24+
bundle agent check
25+
{
26+
meta:
27+
"test_skip_unsupported" string => "!64_bit";
28+
29+
classes:
30+
"ok" expression => "class_defined_from_included_bundle";
31+
methods:
32+
"" usebundle => dcs_passif_output(".*Pass.*", "", "$(sys.cf_agent) -Kf $(this.promise_filename).sub", $(this.promise_filename));
33+
34+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
bundle agent main {
2+
files:
3+
4+
"$(this.promise_filename).sub.file-with-mtime-after-2038"
5+
file_select => y2042,
6+
perms => m( "o+r" ),
7+
classes => kept_or_repaired("y2038_ok");
8+
9+
reports:
10+
y2038_ok::
11+
"Pass";
12+
}
13+
14+
body file_select y2042 {
15+
# January 1, 2042 at 12:00:00 AM December 31, 2042 at 11:59:59 PM
16+
mtime => irange(2272896000, 2304431999);
17+
file_result => "mtime.leaf_name";
18+
}
19+
20+
body perms m (x)
21+
{
22+
mode => "$(x)";
23+
}
24+
25+
body classes kept_or_repaired(x)
26+
{
27+
promise_repaired => { "$(x)" };
28+
promise_kept => { "$(x)" };
29+
repair_failed => { "NOT_$(x)" };
30+
repair_denied => { "NOT_$(x)" };
31+
repair_timeout => { "NOT_$(x)" };
32+
}

0 commit comments

Comments
 (0)