bebcb6453c54164564b24899c6f407310b551a93
max
  Thu Jan 5 06:37:34 2023 -0800
first go at s3:// support, refs #30445

adding cache file to UDC protocol support, refs #30445

handling expired presigned URLs in udc protocol, refs #30445

diff --git src/hg/lib/customFactory.c src/hg/lib/customFactory.c
index 3ff42f0..9634832 100644
--- src/hg/lib/customFactory.c
+++ src/hg/lib/customFactory.c
@@ -165,45 +165,50 @@
  */
 {
 if ((startsWith("http://", url)
    || startsWith("https://", url)
    || startsWith("ftp://", url)))
 return TRUE;
 
 // we allow bigDataUrl's to point to trash (or sessionDataDir, if configured)
 char *sessionDataDir = cfgOption("sessionDataDir");
 char *sessionDataDirOld = cfgOption("sessionDataDirOld");
 if (startsWith(trashDir(), url) ||
     (isNotEmpty(sessionDataDir) && startsWith(sessionDataDir, url)) ||
     (isNotEmpty(sessionDataDirOld) && startsWith(sessionDataDirOld, url)))
     return TRUE;
 
+if (udcIsResolvable(url))
+    return TRUE;
+
 char *prefix = cfgOption("udc.localDir");
 if (prefix == NULL)
     {
     if (doAbort)
         errAbort("Only network protocols http, https, or ftp allowed in bigDataUrl: '%s'", url);
     return FALSE;
     }
-
-if (!startsWith(prefix, url))
+else if (!startsWith(prefix, url))
     {
     if (doAbort)
-        errAbort("bigDataUrl '%s' on local file system has to start with '%s' (see udc.localDir directive in cgi-bin/hg.conf)", url, prefix);
+        errAbort("bigDataUrl '%s' is not an internet URL but udc.localDir is set in cgi-bin/hg.conf of this " \
+                "UCSC Genome Browser, so the bigDataUrl can be a file " \
+                "on the local hard disk of this UCSC Genome Browser instance. However, for such a file path to be acceptable from  "
+                "the local file system, bigDataUrl has to start with the prefix set by udc.localDir, which is '%s' on this Genome Browser.", url, prefix);
     return FALSE;
     }
-
+else
     return TRUE;
 }
 
 static void checkAllowedBigDataUrlProtocols(char *url)
 /* Abort if url is not using one of the allowed bigDataUrl network protocols.
  * In particular, do not allow a local file reference, unless explicitely
  * allowed by hg.conf's udc.localDir directive. */
 {
 isValidBigDataUrl(url, TRUE);
 }
 
 static char *bigDataDocPath(char *type)
 /* If type is a bigData type, provide a relative path to its custom track/format doc page. */
 {
 char *docUrl = NULL;
@@ -4188,31 +4193,32 @@
 struct customPp *cpp = customPpNew(lf);
 lf = NULL;
 
 /* Loop through this once for each track. */
 while ((line = customPpNextReal(cpp)) != NULL)
     {
     /* Parse out track line and save it in track var.
      * First time through make up track var from thin air
      * if no track line. Find out explicit type setting if any.
      * Also make sure settingsHash is set up. */
     lf = cpp->fileStack;
     char *dataUrl = NULL;
     if (lf->fileName && (
             startsWith("http://" , lf->fileName) ||
             startsWith("https://", lf->fileName) ||
-            startsWith("ftp://"  , lf->fileName)
+            startsWith("ftp://"  , lf->fileName) ||
+            udcIsResolvable(lf->fileName)
             ))
         dataUrl = cloneString(lf->fileName);
     if (startsWithWord("track", line))
         {
 	track = trackLineToTrack(genomeDb, line, cpp->fileStack->lineIx);
         }
     else if (trackList == NULL)
     /* In this case we handle simple files with a single track
      * and no track line. */
         {
         char defaultLine[256];
         safef(defaultLine, sizeof defaultLine,
                         "track name='%s' description='%s'",
                         CT_DEFAULT_TRACK_NAME, CT_DEFAULT_TRACK_DESCR);
         track = trackLineToTrack(genomeDb, defaultLine, 1);