[tex-live] time zone in \pdffilemoddate

Karl Berry karl at freefriends.org
Tue Nov 13 23:03:35 CET 2018


    Could \pdffilemoddate be changed to always us the "Z" time zone if
    SOURCE_DATE_EPOCH is set?

I committed changes to pdftex (r808) and tl (r49145) for this. It won't
show up in native TL until the 2019 release, though some distros may
pick it up soon. Thanks for the suggestion (and to Akira for sending me
the basic patch.)

I took the opportunity to add a check for kpse_in_name_ok on the found
filename, too. (This needs to be checked in other pdf* primitives, and
also done in other engines.) --karl

--- texmfmp.c	(revision 806)
+++ texmfmp.c	(working copy)
@@ -2219,6 +2219,9 @@
 static boolean start_time_set = false;
 static time_t start_time = 0;
 
+static boolean SOURCE_DATE_EPOCH_set = false;
+static boolean FORCE_SOURCE_DATE_set = false;
+
 void init_start_time() {
     char *source_date_epoch;
     unsigned long long epoch;
@@ -2239,6 +2242,7 @@
                 epoch = 32535291599ULL;
 #endif
             start_time = epoch;
+            SOURCE_DATE_EPOCH_set = true;
         } else
 #endif /* not onlyTeX */
         {
@@ -2263,6 +2267,7 @@
   if (sde_texprim && STREQ (sde_texprim, "1")) {
     init_start_time ();
     tmptr = gmtime (&start_time);
+    FORCE_SOURCE_DATE_set = true;
   } else
 #endif /* not onlyTeX */
     {
@@ -3150,10 +3155,14 @@
 {
     struct stat file_data;
 
-    char *file_name = kpse_find_tex(makecfilename(s));
+    const_string orig_name = makecfilename(s);
+    char *file_name = kpse_find_tex(orig_name);
     if (file_name == NULL) {
         return;                 /* empty string */
     }
+    if (! kpse_in_name_ok(file_name)) {
+       return;                  /* no permission */
+    }
 
     recorder_record_input(file_name);
     /* get file status */
@@ -3163,8 +3172,8 @@
     if (stat(file_name, &file_data) == 0) {
 #endif
         size_t len;
-
-        makepdftime(file_data.st_mtime, time_str, /* utc= */false);
+	boolean use_utc = FORCE_SOURCE_DATE_set && SOURCE_DATE_EPOCH_set;
+        makepdftime(file_data.st_mtime, time_str, use_utc);
         len = strlen(time_str);
         if ((unsigned) (poolptr + len) >= (unsigned) (poolsize)) {
             poolptr = poolsize;


More information about the tex-live mailing list