chiark / gitweb /
cgi-fcgi-interp: Provide -E option.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 29 Mar 2016 22:54:56 +0000 (23:54 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 29 Mar 2016 22:54:56 +0000 (23:54 +0100)
cprogs/cgi-fcgi-interp.c
debian/changelog

index d77d0ac3bad726bda521ad7c90058cf01edbc46e..6b0585b54f4a9b46e0464d80458c28f4f88b28c7 100644 (file)
  *          Add <ident-info> to the unique identifying information for
  *          this fcgi program.  May be repeated; order is significant.
  *
  *          Add <ident-info> to the unique identifying information for
  *          this fcgi program.  May be repeated; order is significant.
  *
+ *  -E<ident-info-env-var>
+ *          Look <ident-info-env-var> up in the environment and add
+ *          <ident-info-env-var>=<value> as if specified with -G.  If
+ *          the variable is unset in the environment, it is as if
+ *          -G<ident-info-env-var> was specified.
+ *
  *  -g<ident>
  *          Use <ident> rather than hex(sha256(<interp>\0<script>\0))
  *          as the basename of the leafname of the fcgi rendezvous
  *  -g<ident>
  *          Use <ident> rather than hex(sha256(<interp>\0<script>\0))
  *          as the basename of the leafname of the fcgi rendezvous
@@ -189,12 +195,24 @@ static void ident_addstring(const struct cmdinfo *ci, const char *string) {
   sha256_update(&identsc,strlen(string)+1,string);
 }
 
   sha256_update(&identsc,strlen(string)+1,string);
 }
 
+static void off_ident_addenv(const struct cmdinfo *ci, const char *name) {
+  const char *val = getenv(name);
+  if (val) {
+    sha256_update(&identsc,strlen(name),name); /* no nul */
+    sha256_update(&identsc,1,"=");
+    ident_addstring(0,val);
+  } else {
+    ident_addstring(0,name);
+  }
+}
+
 #define MAX_OPTS 5
 
 static const struct cmdinfo cmdinfos[]= {
   { "help",   0, .call=of_help                                         },
   { 0, 'g',   1,                    .sassignto= &ident                 },
   { 0, 'G',   1, .call= ident_addstring                                },
 #define MAX_OPTS 5
 
 static const struct cmdinfo cmdinfos[]= {
   { "help",   0, .call=of_help                                         },
   { 0, 'g',   1,                    .sassignto= &ident                 },
   { 0, 'G',   1, .call= ident_addstring                                },
+  { 0, 'E',   1, .call= off_ident_addenv                               },
   { 0, 'M',   1, .call=of_iassign,  .iassignto= &numservers            },
   { 0, 'D',   0,                    .iassignto= &debugmode,    .arg= 1 },
   { 0, 'c',   1, .call=of_iassign,  .iassignto= &check_interval        },
   { 0, 'M',   1, .call=of_iassign,  .iassignto= &numservers            },
   { 0, 'D',   0,                    .iassignto= &debugmode,    .arg= 1 },
   { 0, 'c',   1, .call=of_iassign,  .iassignto= &check_interval        },
index 16e212b40c0c337ffb522f08e805227527a95a12..e6c808de024e8918fc84488f11897e689f908002 100644 (file)
@@ -2,6 +2,7 @@ chiark-utils (4.5.0~iwj2) UNRELEASED; urgency=medium
 
   * cgi-fcgi-interp: mkdir ~/.cgi-fcgi-interp if necessary.
   * cgi-fcgi-interp: Provide -G option.
 
   * cgi-fcgi-interp: mkdir ~/.cgi-fcgi-interp if necessary.
   * cgi-fcgi-interp: Provide -G option.
+  * cgi-fcgi-interp: Provide -E option.
 
  -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Tue, 29 Mar 2016 23:09:45 +0100
 
 
  -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Tue, 29 Mar 2016 23:09:45 +0100