diff --git a/README b/README index 3222804..f1360b9 100644 --- a/README +++ b/README @@ -118,7 +118,7 @@ support, although I made a fair amount of mostly stylistic changes to their code. Adding the -r option (disable a specific option), the "timeout" -option, and converting to using autoconf for setup was my own code, as -are any bugs introduced in this merge, and any features added to the -Changes list above. +option, converting to using autoconf for setup, and any additions +listed in the Changes list above, has all been my own code, as are any +bugs introduced in the merge. diff --git a/configure.in b/configure.in index 05bc17a..6a4ccad 100644 --- a/configure.in +++ b/configure.in @@ -3,6 +3,7 @@ dnl autoconf input file to generate MCONFIG dnl AC_INIT(MCONFIG.in) +AC_PREFIX_DEFAULT(/usr) AC_PROG_CC AC_C_CONST diff --git a/tftpd/remap.c b/tftpd/remap.c index 9281383..424611c 100644 --- a/tftpd/remap.c +++ b/tftpd/remap.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "tftpd.h" #include "remap.h" @@ -249,6 +250,10 @@ char *rewrite_string(const char *input, const struct rule *rules, int is_put) int was_match = 0; int deadman = DEADMAN_MAX_STEPS; + if ( verbosity >= 3 ) { + syslog(LOG_INFO, "remap: input: %s", current); + } + for ( ruleptr = rules ; ruleptr ; ruleptr = ruleptr->next ) { if ( ((ruleptr->rule_flags & RULE_GETONLY) && is_put) || ((ruleptr->rule_flags & RULE_PUTONLY) && !is_put) ) { @@ -256,6 +261,8 @@ char *rewrite_string(const char *input, const struct rule *rules, int is_put) } if ( ! deadman-- ) { + syslog(LOG_WARNING, "remap: Breaking loop, input = %s, last = %s", + input, current); free(current); return NULL; /* Did not terminate! */ } @@ -266,6 +273,10 @@ char *rewrite_string(const char *input, const struct rule *rules, int is_put) was_match = 1; if ( ruleptr->rule_flags & RULE_ABORT ) { + if ( verbosity >= 3 ) { + syslog(LOG_INFO, "remap: rule %d: abort", + ruleptr->nrule, current); + } free(current); return(NULL); } @@ -276,6 +287,10 @@ char *rewrite_string(const char *input, const struct rule *rules, int is_put) genmatchstring(newstr, ruleptr->pattern, current, pmatch); free(current); current = newstr; + if ( verbosity >= 3 ) { + syslog(LOG_INFO, "remap: rule %d: rewrite: %s", + ruleptr->nrule, current); + } } } else { break; /* No match, terminate unconditionally */ @@ -287,12 +302,21 @@ char *rewrite_string(const char *input, const struct rule *rules, int is_put) was_match = 0; if ( ruleptr->rule_flags & RULE_EXIT ) { - break; /* Exit here, we're done */ + if ( verbosity >= 3 ) { + syslog(LOG_INFO, "remap: rule %d: exit", ruleptr->nrule); + } + return current; /* Exit here, we're done */ } else if ( ruleptr->rule_flags & RULE_RESTART ) { ruleptr = rules; /* Start from the top */ + if ( verbosity >= 3 ) { + syslog(LOG_INFO, "remap: rule %d: restart", ruleptr->nrule); + } } } } + if ( verbosity >= 3 ) { + syslog(LOG_INFO, "remap: done"); + } return current; } diff --git a/tftpd/tftpd.h b/tftpd/tftpd.h index 511cf26..22499c6 100644 --- a/tftpd/tftpd.h +++ b/tftpd/tftpd.h @@ -51,6 +51,8 @@ void set_signal(int, void (*)(int), int); void *tfmalloc(size_t); char *tfstrdup(const char *); +extern int verbosity; + #ifdef __GNUC__ #define UNUSED __attribute__((unused)) #else