summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1999-03-08 22:35:38 +0000
committerbrian <brian@cvs.openbsd.org>1999-03-08 22:35:38 +0000
commit2500ee86fb2951ab1563cd206f075f33c9ce384a (patch)
tree25d8e9c064e18a768afab2f80815b20dfe25c0a4 /usr.sbin
parent5b18ca0b67397412ae754906a2c2525bf7b75284 (diff)
Don't destroy the old server socket another ``set server''
call fails.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/ppp/server.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/ppp/ppp/server.c b/usr.sbin/ppp/ppp/server.c
index c91cab9742d..7b5c058fe45 100644
--- a/usr.sbin/ppp/ppp/server.c
+++ b/usr.sbin/ppp/ppp/server.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: server.c,v 1.3 1999/03/07 11:55:27 brian Exp $
+ * $Id: server.c,v 1.4 1999/03/08 22:35:37 brian Exp $
*/
#include <sys/types.h>
@@ -191,7 +191,6 @@ server_LocalOpen(struct bundle *bundle, const char *name, mode_t mask)
return 0;
}
- server_Close(bundle);
memset(&server.ifsun, '\0', sizeof server.ifsun);
server.ifsun.sun_len = strlen(name);
if (server.ifsun.sun_len > sizeof server.ifsun.sun_path - 1) {
@@ -224,6 +223,7 @@ server_LocalOpen(struct bundle *bundle, const char *name, mode_t mask)
ID0unlink(name);
return 5;
}
+ server_Close(bundle);
server.fd = s;
server.rm = server.ifsun.sun_path;
log_Printf(LogPHASE, "Listening at local socket %s.\n", name);
@@ -255,7 +255,8 @@ server_TcpOpen(struct bundle *bundle, int port)
return 8;
}
if (listen(s, 5) != 0) {
- log_Printf(LogERROR, "Tcp: Unable to listen to socket - BUNDLE overload?\n");
+ log_Printf(LogERROR, "Tcp: Unable to listen to socket: %s\n",
+ strerror(errno));
close(s);
return 9;
}
@@ -270,11 +271,16 @@ int
server_Close(struct bundle *bundle)
{
if (server.fd >= 0) {
- close(server.fd);
if (server.rm) {
- ID0unlink(server.rm);
+ struct sockaddr_un un;
+ int sz = sizeof un;
+
+ if (getsockname(server.fd, (struct sockaddr *)&un, &sz) == 0 &&
+ un.sun_family == AF_LOCAL && sz == sizeof un)
+ ID0unlink(un.sun_path);
server.rm = NULL;
}
+ close(server.fd);
server.fd = -1;
server.port = 0;
/* Drop associated prompts */