Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:hlin
opensuse
openssh-4.1p1-addrlist.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File openssh-4.1p1-addrlist.dif of Package opensuse
--- sshd.c +++ sshd.c @@ -222,6 +222,62 @@ static void do_ssh1_kex(void); static void do_ssh2_kex(void); +char * isaddr(struct addrinfo *addr, char *name); +void remove_duplicities(struct addrinfo *addr, char *port); + +/* + * returns port if addr equals name + */ + +char* +isaddr(struct addrinfo *addr, char *name) +{ + char ntop[NI_MAXHOST]; + char *strport; + + strport = (char*) malloc(NI_MAXSERV+1); + if (getnameinfo(addr->ai_addr, addr->ai_addrlen, + ntop, sizeof(ntop), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV) != 0) { + error("getnameinfo failed"); + free(strport); + return NULL; + } + if (!strcmp(ntop,name)) + return strport; + else{ + free(strport); + return NULL; + } + +} + +/* + * it removes all "0.0.0.0" elements with given port + * from the list + */ + +void +remove_duplicities(struct addrinfo *ai_start, char *port) +{ + struct addrinfo *ai, *ai1, *aiprev, *ainext; + char *port1; + + aiprev=ai_start; + for (ai = ai_start->ai_next; ai; ai = ainext) { + ainext = ai->ai_next; + port1 = isaddr(ai, "0.0.0.0"); + if (port1 && !strcmp(port,port1)){ + aiprev->ai_next = ainext; + free(ai); + free(port1); + } else { + if (port1) + free(port1); + aiprev = ai; + } + } +} /* * Close all listening sockets @@ -890,6 +946,7 @@ Authctxt *authctxt; int ret, key_used = 0; Buffer cfg; + char *port; #ifdef HAVE_SECUREWARE (void)set_auth_parameters(ac, av); @@ -1303,12 +1360,16 @@ /* Bind the socket to the desired port. */ if (bind(listen_sock, ai->ai_addr, ai->ai_addrlen) < 0) { - if (!ai->ai_next) - error("Bind to port %s on %s failed: %.200s.", - strport, ntop, strerror(errno)); + error("Bind to port %s on %s failed: %.200s.", + strport, ntop, strerror(errno)); close(listen_sock); continue; } + port=isaddr(ai,"::"); + if (port){ + remove_duplicities(ai, port); + free(port); + } listen_socks[num_listen_socks] = listen_sock; num_listen_socks++;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor