mirror of
https://kernel.googlesource.com/pub/scm/network/tftp/tftp-hpa
synced 2025-04-26 01:49:52 +03:00
tftpd: make it possible to adjust the remap deadman
Allow the user to tweak the remap deadman counter if it is necessary for whatever reason. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
ac7f98e4d8
commit
9a92dec1dc
4 changed files with 27 additions and 4 deletions
|
@ -39,6 +39,8 @@
|
|||
#define RULE_WRQ 0x400 /* Put (write) only */
|
||||
#define RULE_SEDG 0x800 /* sed-style global */
|
||||
|
||||
int deadman_max_steps = DEADMAN_MAX_STEPS;
|
||||
|
||||
struct rule {
|
||||
struct rule *next;
|
||||
int nrule;
|
||||
|
@ -397,7 +399,7 @@ char *rewrite_string(const struct formats *pf,
|
|||
int i;
|
||||
int len, newlen;
|
||||
int was_match = 0;
|
||||
int deadman = DEADMAN_MAX_STEPS;
|
||||
int deadman = deadman_max_steps;
|
||||
int matchsense;
|
||||
int pmatches;
|
||||
unsigned int bad_flags;
|
||||
|
@ -534,9 +536,9 @@ char *rewrite_string(const struct formats *pf,
|
|||
return current;
|
||||
|
||||
dead: /* Deadman expired */
|
||||
syslog(LOG_WARNING,
|
||||
"remap: Breaking loop, input = %s, last = %s", input,
|
||||
current);
|
||||
syslog(LOG_ERR,
|
||||
"remap: Breaking loop after %d steps, input = %s, last = %s",
|
||||
deadman_max_steps, input, current);
|
||||
free(current);
|
||||
return NULL; /* Did not terminate! */
|
||||
}
|
||||
|
|
|
@ -40,5 +40,8 @@ char *rewrite_string(const struct formats *, const char *,
|
|||
const struct rule *, int, int,
|
||||
match_pattern_callback, const char **);
|
||||
|
||||
/* Remapping deadman counter */
|
||||
extern int deadman_max_steps;
|
||||
|
||||
#endif /* WITH_REGEX */
|
||||
#endif /* TFTPD_REMAP_H */
|
||||
|
|
|
@ -163,6 +163,10 @@ remapping below. This option may not be compiled in, see the output of
|
|||
.B "in.tftpd \-V"
|
||||
to verify whether or not it is available.
|
||||
.TP
|
||||
.\fB\-\-map-steps\fP \fIsteps\fP
|
||||
Specify the number of remapping rules that may be executed before the
|
||||
filename mapping fails. The default is 4096.
|
||||
.TP
|
||||
\fB\-\-verbose\fP, \fB\-v\fP
|
||||
Increase the logging verbosity of
|
||||
.BR tftpd .
|
||||
|
|
|
@ -325,6 +325,7 @@ static int split_port(char **ap, char **pp)
|
|||
|
||||
enum long_only_options {
|
||||
OPT_VERBOSITY = 256,
|
||||
OPT_MAP_STEPS
|
||||
};
|
||||
|
||||
static struct option long_options[] = {
|
||||
|
@ -347,6 +348,7 @@ static struct option long_options[] = {
|
|||
{ "retransmit", 1, NULL, 'T' },
|
||||
{ "port-range", 1, NULL, 'R' },
|
||||
{ "map-file", 1, NULL, 'm' },
|
||||
{ "map-steps", 1, NULL, OPT_MAP_STEPS },
|
||||
{ "pidfile", 1, NULL, 'P' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
@ -495,6 +497,18 @@ int main(int argc, char **argv)
|
|||
}
|
||||
rewrite_file = optarg;
|
||||
break;
|
||||
case OPT_MAP_STEPS:
|
||||
{
|
||||
char *ep;
|
||||
unsigned long steps = strtoul(optarg, &ep, 0);
|
||||
if (*optarg && *ep && steps > 0 && steps <= INT_MAX) {
|
||||
deadman_max_steps = steps;
|
||||
} else {
|
||||
syslog(LOG_ERR, "Bad --map-steps option: %s", optarg);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case 'v':
|
||||
verbosity++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue