d738b9
From 087bd1bdff17025af6e5189898209035ec8d75da Mon Sep 17 00:00:00 2001
d738b9
From: Greg Hudson <ghudson@mit.edu>
d738b9
Date: Thu, 4 May 2017 17:03:35 -0400
d738b9
Subject: [PATCH] Add y2038 documentation
d738b9
d738b9
ticket: 8352
d738b9
(cherry picked from commit 85d64c43dbf7a7faa56a1999494cdfa49e8bd2c9)
d738b9
---
d738b9
 doc/appdev/index.rst |  1 +
d738b9
 doc/appdev/y2038.rst | 28 ++++++++++++++++++++++++++++
d738b9
 2 files changed, 29 insertions(+)
d738b9
 create mode 100644 doc/appdev/y2038.rst
d738b9
d738b9
diff --git a/doc/appdev/index.rst b/doc/appdev/index.rst
d738b9
index 3d62045ca..961bb1e9e 100644
d738b9
--- a/doc/appdev/index.rst
d738b9
+++ b/doc/appdev/index.rst
d738b9
@@ -5,6 +5,7 @@ For application developers
d738b9
    :maxdepth: 1
d738b9
 
d738b9
    gssapi.rst
d738b9
+   y2038.rst
d738b9
    h5l_mit_apidiff.rst
d738b9
    init_creds.rst
d738b9
    princ_handle.rst
d738b9
diff --git a/doc/appdev/y2038.rst b/doc/appdev/y2038.rst
d738b9
new file mode 100644
d738b9
index 000000000..bc4122dad
d738b9
--- /dev/null
d738b9
+++ b/doc/appdev/y2038.rst
d738b9
@@ -0,0 +1,28 @@
d738b9
+Year 2038 considerations for uses of krb5_timestamp
d738b9
+===================================================
d738b9
+
d738b9
+POSIX time values, which measure the number of seconds since January 1
d738b9
+1970, will exceed the maximum value representable in a signed 32-bit
d738b9
+integer in January 2038.  This documentation describes considerations
d738b9
+for consumers of the MIT krb5 libraries.
d738b9
+
d738b9
+Applications or libraries which use libkrb5 and consume the timestamps
d738b9
+included in credentials or other structures make use of the
d738b9
+:c:type:`krb5_timestamp` type.  For historical reasons, krb5_timestamp
d738b9
+is a signed 32-bit integer, even on platforms where a larger type is
d738b9
+natively used to represent time values.  To behave properly for time
d738b9
+values after January 2038, calling code should cast krb5_timestamp
d738b9
+values to uint32_t, and then to time_t::
d738b9
+
d738b9
+    (time_t)(uint32_t)timestamp
d738b9
+
d738b9
+Used in this way, krb5_timestamp values can represent time values up
d738b9
+until February 2106, provided that the platform uses a 64-bit or
d738b9
+larger time_t type.  This usage will also remain safe if a later
d738b9
+version of MIT krb5 changes krb5_timestamp to an unsigned 32-bit
d738b9
+integer.
d738b9
+
d738b9
+The GSSAPI only uses representations of time intervals, not absolute
d738b9
+times.  Callers of the GSSAPI should require no changes to behave
d738b9
+correctly after January 2038, provided that they use MIT krb5 release
d738b9
+1.16 or later.