chiark / gitweb /
Cope with moved changelogs.
[userv.git] / debug.c
diff --git a/debug.c b/debug.c
index 9174d83..6612545 100644 (file)
--- a/debug.c
+++ b/debug.c
 #include "lib.h"
 #include "tokens.h"
 
-#ifdef DEBUG
-
-static const char *sl_ident= "UNSET";
-static int sl_option=0, sl_facility=0;
-
-void openlog(const char *ident, int option, int facility) {
-  sl_ident= ident;
-  sl_option= option;
-  sl_facility= facility;
-}
-
-void syslog(int priority, const char *fmt, ...) {
-  va_list al;
-  fprintf(stderr,"syslog: %s<%d.%d>(%d): ",sl_ident,sl_facility,priority,sl_option);
-  va_start(al,fmt);
-  vfprintf(stderr,fmt,al);
-  va_end(al);
-  fputc('\n',stderr);
-}
-
-void closelog(void) {
-  sl_ident= "CLOSED";
-  sl_option= sl_facility= 0;
-}
-
 static void fdwantdumprwhead(int *donehead, const char *whichstr, const char *rwstr) {
   if (*donehead) return;
   printf("fds %s%s%s:",whichstr,rwstr?" ":"",rwstr?rwstr:"");
@@ -96,6 +71,69 @@ static void truefalsedump(const char *whichstr, int val) {
   printf("%s: %s\n",whichstr,val?"yes":"no");
 }
 
+void always_dumpparameter(const char *parm, char **values) {
+  printf("config parameter `%s':",parm);
+  while (*values) printf(" `%s'",*values++);
+  printf("\n");
+}
+
+void always_dumpexecsettings(void) {
+  char **cpp;
+  
+  if (userrcfile) printf("user-rcfile: `%s'\n",userrcfile);
+  else printf("user-rcfile: <none>\n");
+  fdwantdump("required",tokv_word_requirefd,"ERROR");
+  fdwantdump("allowed",tokv_word_allowfd,"either");
+  fdwantdump("ignored",tokv_word_ignorefd,0);
+  fdwantdump("null",tokv_word_nullfd,"both");
+  fdwantdump("rejected",tokv_word_rejectfd,0);
+  fputs("execute: ",stdout);
+  switch (execute) {
+  case tokv_word_reject: printf("reject"); break;
+  case tokv_word_execute: printf("`%s'",execpath); break;
+  case tokv_word_executefromdirectory: printf("from directory, `%s'",execpath); break;
+  case tokv_word_executefrompath: printf("from path"); break;
+  case tokv_word_executebuiltin: printf("builtin %s",execpath); break;
+  default: abort();
+  }
+  if (execargs) {
+    fputs("\n" "no exec arguments\n",stdout);
+  } else {
+    fputs("\n" "exec arguments:",stdout);
+    for (cpp= execargs; cpp; cpp++) printf(" `%s'",*cpp);
+    putchar('\n');
+  }
+  truefalsedump("set-environment",setenvironment);
+  truefalsedump("suppress-args",suppressargs);
+  truefalsedump("disconnect-hup",disconnecthup);
+  truefalsedump("set-environment",setenvironment);
+}
+
+#ifdef DEBUG
+
+static const char *sl_ident= "UNSET";
+static int sl_option=0, sl_facility=0;
+
+void openlog(const char *ident, int option, int facility) {
+  sl_ident= ident;
+  sl_option= option;
+  sl_facility= facility;
+}
+
+void syslog(int priority, const char *fmt, ...) {
+  va_list al;
+  fprintf(stderr,"syslog: %s<%d.%d>(%d): ",sl_ident,sl_facility,priority,sl_option);
+  va_start(al,fmt);
+  vfprintf(stderr,fmt,al);
+  va_end(al);
+  fputc('\n',stderr);
+}
+
+void closelog(void) {
+  sl_ident= "CLOSED";
+  sl_option= sl_facility= 0;
+}
+
 static void groupsdump(int ngids, const gid_t *gids, const char *const *groups) {
   int i;
   
@@ -136,39 +174,20 @@ void debug_dumprequest(pid_t mypid) {
   for (i=0; i<request_mbuf.nargs; i++) printf(" `%s'",argarray[i]);
   printf("\n" "variables:");
   for (i=0; i<request_mbuf.nvars; i++)
-    printf(" `%s'=`%s'",defvararray[i][0],defvararray[i][1]);
+    printf(" `%s'=`%s'",defvararray[i].key,defvararray[i].value);
   printf("\n");
+  if (overridedata) printf("override data: `%s'\n",overridedata);
+  else printf("not overridden\n");
   if (getenv("USERVD_SLEEP")) sleep(atoi(getenv("USERVD_SLEEP")));
 }
 
 void debug_dumpexecsettings(void) {
   printf("configuration parsed\n");
-  if (userrcfile) printf("user-rcfile: `%s'\n",userrcfile);
-  else printf("user-rcfile: <none>\n");
-  fdwantdump("required",tokv_word_requirefd,"ERROR");
-  fdwantdump("allowed",tokv_word_allowfd,"either");
-  fdwantdump("ignored",tokv_word_ignorefd,0);
-  fdwantdump("null",tokv_word_nullfd,"both");
-  fdwantdump("rejected",tokv_word_rejectfd,0);
-  printf("execute: ");
-  switch (execute) {
-  case tokv_word_reject: printf("reject"); break;
-  case tokv_word_execute: printf("`%s'",execpath); break;
-  case tokv_word_executefromdirectory: printf("from directory, `%s'",execpath); break;
-  case tokv_word_executefrompath: printf("from path"); break;
-  default: abort();
-  }
-  printf("\n");
-  truefalsedump("set-environment",setenvironment);
-  truefalsedump("suppress-args",suppressargs);
-  truefalsedump("disconnect-hup",disconnecthup);
-  truefalsedump("set-environment",setenvironment);
+  always_dumpexecsettings();
 }
 
 void debug_dumpparameter(const char *parm, char **values) {
-  printf("config parameter `%s':",parm);
-  while (*values) printf(" `%s'",*values++);
-  printf("\n");
+  always_dumpparameter(parm,values);
 }
 
 static int groupsallin(int na, const gid_t *lista,