summaryrefslogtreecommitdiff
path: root/staging
diff options
context:
space:
mode:
authorJon Schipp <jonschipp@gmail.com>2014-07-29 20:51:08 +0000
committerTobias Klauser <tklauser@distanz.ch>2014-08-04 10:28:32 +0200
commit29a7c9ee6fd3c353282150c6a8039473d69a7d44 (patch)
tree00ef06dbc78c452b7cc24adba9f670a342870db6 /staging
parent0678fa12400b54f4da054f1c6057a81f9cc8e041 (diff)
mausezahn: provide port option to configuration file
Specify the port for the CLI in /etc/netsniff-ng/mausezahn.conf like so: $ grep port /etc/netsniff-ng/mausezahn.conf port = 65000 $ mausezahn -V -x -l 127.0.0.1 Mausezahn 0.40 - (C) 2007-2010 by Herbert Haas - http://www.perihel.at/sec/mz/ Use at your own risk and responsibility! -- Verbose mode -- ... Opening config file /etc/netsniff-ng/mausezahn.conf... ... Mausezahn accepts incoming Telnet connections on 127.0.0.1:65000. Signed-off-by: Jon Schipp <jonschipp@gmail.com> [tklauser: Fixed whitespace issues for patch to apply cleanly] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'staging')
-rw-r--r--staging/cli.c13
-rw-r--r--staging/mausezahn.c4
2 files changed, 10 insertions, 7 deletions
diff --git a/staging/cli.c b/staging/cli.c
index 9abc648..a5ce174 100644
--- a/staging/cli.c
+++ b/staging/cli.c
@@ -56,7 +56,7 @@ int cli_read_cfg(char *str)
char dev[256];
FILE *fd;
int i, j=0, len, found=0, nonspc=0;
- int user=0, pass=0, ena=0, amp=0, mgmt_only=0, cli=0;
+ int user=0, pass=0, ena=0, amp=0, mgmt_only=0, cli=0, port=0;
strncpy(filename, str, 255);
@@ -79,6 +79,7 @@ int cli_read_cfg(char *str)
if (!user) user = sscanf(line, " user = %s ", mz_username);
if (!pass) pass = sscanf(line, " password = %s ", mz_password);
if (!ena) ena = sscanf(line, " enable = %s ", mz_enable);
+ if (!port) port = sscanf(line, " port = %i ", &mz_port);
if (!cli) cli = sscanf(line, " cli-device = %s ", dev);
if (cli==1) {
for (i=0; i<device_list_entries; i++) {
@@ -131,7 +132,7 @@ int cli_read_cfg(char *str)
}
}
fclose(fd);
-
+
if (verbose) {
if (user!=1)
fprintf(stderr, "%s: No user name specified - will use default.\n", filename);
@@ -141,6 +142,9 @@ int cli_read_cfg(char *str)
if (ena!=1)
fprintf(stderr, "%s: No enable password specified - will use default.\n", filename);
+
+ if (port!=1)
+ fprintf(stderr, "%s: No port specified - will use default.\n", filename);
}
cli_debug = 0;
@@ -528,7 +532,6 @@ int cli()
}
}
-
// Listen on port mz_port (default: 25542, towel day)
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
@@ -536,6 +539,10 @@ int cli()
servaddr.sin_port = htons(mz_port);
bind(s, (struct sockaddr *)&servaddr, sizeof(servaddr));
+ if (!quiet) {
+ fprintf(stderr, "Mausezahn accepts incoming Telnet connections on %s:%i.\n", mz_listen_addr, mz_port);
+ }
+
// Wait for a connection
listen(s, 50);
diff --git a/staging/mausezahn.c b/staging/mausezahn.c
index 0c0296e..46b7428 100644
--- a/staging/mausezahn.c
+++ b/staging/mausezahn.c
@@ -727,10 +727,6 @@ int getopts (int argc, char *argv[])
mz_port = (int) str2int (tx.arg_string);
}
- if (!quiet) {
- fprintf(stderr, "Mausezahn accepts incoming Telnet connections on port %i.\n", mz_port);
- }
-
mz_cli_init();
cli();
}