telnet/netkit-telnet-0.17-nodns.patch

64 lines
1.8 KiB
Diff
Raw Normal View History

--- netkit-telnet-0.17/telnetd/telnetd.8.nodns 2000-07-31 01:57:10.000000000 +0200
+++ netkit-telnet-0.17/telnetd/telnetd.8 2007-04-13 10:58:27.000000000 +0200
@@ -123,6 +123,8 @@
.Xr login 1
program.
.El
+.It Fl c
+This option disables reverse dns checking. Of course that security is lower with this option
.It Fl D Ar debugmode
This option may be used for debugging purposes. This allows
.Nm telnetd
--- netkit-telnet-0.17/telnetd/telnetd.c.nodns 2007-04-13 10:49:57.000000000 +0200
+++ netkit-telnet-0.17/telnetd/telnetd.c 2007-04-13 10:49:57.000000000 +0200
@@ -83,6 +83,7 @@
int debug = 0;
int keepalive = 1;
+int nodns = 0;
char *loginprg = _PATH_LOGIN;
char *progname;
@@ -111,7 +112,7 @@
progname = *argv;
- while ((ch = getopt(argc, argv, "d:a:e:lhnr:I:D:B:sS:a:X:L:")) != EOF) {
+ while ((ch = getopt(argc, argv, "cd:a:e:lhnr:I:D:B:sS:a:X:L:")) != EOF) {
switch(ch) {
#ifdef AUTHENTICATE
@@ -147,7 +148,9 @@
bftpd++;
break;
#endif /* BFTPDAEMON */
-
+ case 'c':
+ nodns++;
+ break;
case 'd':
if (strcmp(optarg, "ebug") == 0) {
debug++;
@@ -652,6 +655,9 @@
char namebuf[255];
error = getnameinfo(who, wholen, namebuf, sizeof(namebuf), NULL, 0, 0);
+
+ if ((error == EAI_AGAIN) && nodns)
+ error = getnameinfo(who, wholen, namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
if (error) {
perror("getnameinfo: localhost");
@@ -688,7 +694,10 @@
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_ADDRCONFIG;
- gethostname(host_name, sizeof(host_name));
+ if(nodns)
+ sprintf(host_name, "localhost", sizeof(host_name));
+ else
+ gethostname(host_name, sizeof(host_name));
if ((e = getaddrinfo(host_name, NULL, &hints, &res)) != 0) {
perror("getaddrinfo: localhost");
perror(gai_strerror(e));