summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/server.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-06-30 03:03:38 +0000
committerbrian <brian@FreeBSD.org>1997-06-30 03:03:38 +0000
commitef60b19dcaace9c184fff55869ae9f9a7a110d31 (patch)
treeee15160bdfecab36ae85204a2b33cf221517e1ab /usr.sbin/ppp/server.c
parent0a91728bd30aa3a8c095b9aaccd62ee440e4f096 (diff)
downloadFreeBSD-src-ef60b19dcaace9c184fff55869ae9f9a7a110d31.zip
FreeBSD-src-ef60b19dcaace9c184fff55869ae9f9a7a110d31.tar.gz
Allow specification of a umask for local socket
creation in "set server" command.
Diffstat (limited to 'usr.sbin/ppp/server.c')
-rw-r--r--usr.sbin/ppp/server.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c
index d6bd5d6..ddff807 100644
--- a/usr.sbin/ppp/server.c
+++ b/usr.sbin/ppp/server.c
@@ -1,4 +1,5 @@
#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
@@ -20,7 +21,7 @@ static struct sockaddr_un ifsun;
static char *rm;
int
-ServerLocalOpen(const char *name)
+ServerLocalOpen(const char *name, mode_t mask)
{
int s;
@@ -39,7 +40,9 @@ ServerLocalOpen(const char *name)
}
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s);
+ mask = umask(mask);
if (bind(s, (struct sockaddr *) &ifsun, sizeof(ifsun)) < 0) {
+ umask(mask);
LogPrintf(LogERROR, "Local: bind: %s\n", strerror(errno));
if (errno == EADDRINUSE && VarTerm)
fprintf(VarTerm, "Wait for a while, then try again.\n");
@@ -47,6 +50,7 @@ ServerLocalOpen(const char *name)
unlink(name);
return 3;
}
+ umask(mask);
if (listen(s, 5) != 0) {
LogPrintf(LogERROR, "Local: Unable to listen to socket - OS overload?\n");
close(s);
OpenPOWER on IntegriCloud