* userv - ddebug.c
* routines which are different for -DDEBUG
*
- * Copyright (C)1996-1997 Ian Jackson
+ * userv is
+ * Copyright 1996-2017 Ian Jackson <ian@davenant.greenend.org.uk>.
+ * Copyright 2000 Ben Harris <bjh21@cam.ac.uk>
+ * Copyright 2016-2017 Peter Benie <pjb1008@cam.ac.uk>
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with userv; if not, write to the Free Software
- * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * along with userv; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
#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:"");
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;
"calling uid: %ld\n"
"calling user shell: `%s'\n"
"calling groups:",
- logname, (long)request_mbuf.callinguid,
+ loginname, (long)request_mbuf.callinguid,
callinguser_shell);
groupsdump(request_mbuf.ngids,calling_gids,calling_groups);
printf("\n"
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,