summaryrefslogtreecommitdiff
path: root/security/ssh/files/patch-bo
blob: 941fef6346e73dd3deccf437cb87bba85a05aeee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
--- servconf.c.orig	Thu Jan 17 05:35:34 2002
+++ servconf.c	Fri Jun 21 16:22:56 2002
@@ -88,8 +88,8 @@
 void initialize_server_options(ServerOptions *options)
 {
   memset(options, 0, sizeof(*options));
-  options->port = -1;
-  options->listen_addr.s_addr = INADDR_ANY;
+  options->num_ports = 0;
+  options->listen_addrs = NULL;
   options->host_key_file = NULL;
   options->random_seed_file = NULL;
   options->pid_file = NULL;
@@ -99,6 +99,9 @@
   options->permit_root_login = -1;
   options->ignore_rhosts = -1;
   options->ignore_root_rhosts = -1;
+#ifdef ENABLE_LOG_AUTH
+  options->log_auth = -1;
+#endif /* ENABLE_LOG_AUTH */
   options->quiet_mode = -1;
   options->fascist_logging = -1;
   options->print_motd = -1;
@@ -145,17 +148,33 @@
 
 void fill_default_server_options(ServerOptions *options)
 {
-  if (options->port == -1)
+  struct addrinfo hints, *ai, *aitop;
+  char strport[PORTSTRLEN];
+  int i;
+
+  if (options->num_ports == 0)
+    options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
+  if (options->listen_addrs == NULL)
     {
-      struct servent *sp;
+      for (i = 0; i < options->num_ports; i++)
+	{
+	  memset(&hints, 0, sizeof(hints));
+	  hints.ai_flags = AI_PASSIVE;
+	  hints.ai_family = IPv4or6;
+	  hints.ai_socktype = SOCK_STREAM;
+	  sprintf(strport, "%d", options->ports[i]);
+	  if (getaddrinfo(NULL, strport, &hints, &aitop) != 0)
+	    {
+	      fprintf(stderr, "fatal: getaddrinfo: Cannot get anyaddr.\n");
+	      exit(1);
+	    }
+	  for (ai = aitop; ai->ai_next; ai = ai->ai_next);
+	  ai->ai_next = options->listen_addrs;
+	  options->listen_addrs = aitop;
+	}
+      /* freeaddrinfo(options->listen_addrs) in sshd.c */
+      }
 
-      sp = getservbyname(SSH_SERVICE_NAME, "tcp");
-      if (sp)
-        options->port = ntohs(sp->s_port);
-      else
-        options->port = SSH_DEFAULT_PORT;
-      endservent();
-    }
   if (options->host_key_file == NULL)
     options->host_key_file = HOST_KEY_FILE;
   if (options->random_seed_file == NULL)
@@ -250,6 +269,9 @@
 {
   sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime,
   sPermitRootLogin, sQuietMode, sFascistLogging, sLogFacility,
+#ifdef ENABLE_LOG_AUTH
+  sLogAuth,
+#endif /* ENABLE_LOG_AUTH */
   sRhostsAuthentication, sRhostsRSAAuthentication, sRSAAuthentication,
   sTISAuthentication, sPasswordAuthentication, sAllowHosts, sDenyHosts,
   sListenAddress, sPrintMotd, sIgnoreRhosts, sX11Forwarding, sX11DisplayOffset,
@@ -282,6 +304,9 @@
   { "quietmode", sQuietMode },
   { "fascistlogging", sFascistLogging },
   { "syslogfacility", sLogFacility },
+#ifdef ENABLE_LOG_AUTH
+  { "logauth", sLogAuth },
+#endif /* ENABLE_LOG_AUTH */
   { "rhostsauthentication", sRhostsAuthentication },
   { "rhostsrsaauthentication", sRhostsRSAAuthentication },
   { "rsaauthentication", sRSAAuthentication },
@@ -375,6 +400,9 @@
   char *cp, **charptr;
   int linenum, *intptr, i, value;
   ServerOpCodes opcode;
+  struct addrinfo hints, *ai, *aitop;
+  char strport[PORTSTRLEN];
+  int gaierr;
 
   f = fopen(filename, "r");
   if (!f)
@@ -397,7 +425,14 @@
       switch (opcode)
         {
         case sPort:
-          intptr = &options->port;
+	  if (options->num_ports >= MAX_PORTS)
+	    {
+	      fprintf(stderr, "%s line %d: too many ports.\n",
+		      filename, linenum);
+	      exit(1);
+	    }
+	  options->ports[options->num_ports] = -1;
+	  intptr = &options->ports[options->num_ports++];
         parse_int:
           cp = strtok(NULL, WHITESPACE);
           if (!cp)
@@ -460,12 +495,26 @@
                       filename, linenum);
               exit(1);
             }
-#ifdef BROKEN_INET_ADDR
-          options->listen_addr.s_addr = inet_network(cp);
-#else /* BROKEN_INET_ADDR */
-          options->listen_addr.s_addr = inet_addr(cp);
-#endif /* BROKEN_INET_ADDR */
-          break;
+	  if (options->num_ports == 0)
+	    options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
+	  for (i = 0; i < options->num_ports; i++)
+	    {
+	      memset(&hints, 0, sizeof(hints));
+	      hints.ai_family = IPv4or6;
+	      hints.ai_socktype = SOCK_STREAM;
+	      sprintf(strport, "%d", options->ports[i]);
+	      if ((gaierr = getaddrinfo(cp, strport, &hints, &aitop)) != 0)
+		{
+		  fprintf(stderr, "%s line %d: bad addr or host. (%s)\n",
+			  filename, linenum, gai_strerror(gaierr));
+		  exit(1);
+		}
+	      for (ai = aitop; ai->ai_next; ai = ai->ai_next);
+	      ai->ai_next = options->listen_addrs;
+	      options->listen_addrs = aitop;
+	    }
+	  strtok(cp, WHITESPACE);	/* getaddrinfo() may use strtok() */
+  	  break;
 
         case sHostKeyFile:
           charptr = &options->host_key_file;
@@ -539,6 +588,12 @@
           if (*intptr == -1)
             *intptr = value;
           break;
+
+#ifdef ENABLE_LOG_AUTH
+	case sLogAuth:
+	  intptr = &options->log_auth;
+	  goto parse_flag;
+#endif /* ENABLE_LOG_AUTH */
 
         case sIgnoreRhosts:
           intptr = &options->ignore_rhosts;