summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/pppoe
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2012-01-13 12:38:26 +0400
committerKozlov Dmitry <xeb@mail.ru>2012-01-13 12:38:26 +0400
commitbf1ccc7f6e7a9dc5a8ba3d8d02b25ad446458840 (patch)
tree4e53a7f2990e40436f6ae98434f72c3db14434c0 /accel-pppd/ctrl/pppoe
parent03a466f1b0f7549c2ef89c1e544c2c86c3958ad4 (diff)
downloadaccel-ppp-bf1ccc7f6e7a9dc5a8ba3d8d02b25ad446458840.tar.gz
accel-ppp-bf1ccc7f6e7a9dc5a8ba3d8d02b25ad446458840.zip
set FD_CLOEXEC on opened file descriptors
Diffstat (limited to 'accel-pppd/ctrl/pppoe')
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index a32c8f5..3742c87 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -305,6 +305,8 @@ static void connect_channel(struct pppoe_conn_t *conn)
log_error("pppoe: socket(PPPOX): %s\n", strerror(errno));
goto out_err;
}
+
+ fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
memset(&sp, 0, sizeof(sp));
@@ -1155,6 +1157,8 @@ void pppoe_server_start(const char *opt, void *cli)
_free(serv);
return;
}
+
+ fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &f, sizeof(f))) {
if (cli)
@@ -1322,23 +1326,13 @@ void __export pppoe_get_stat(unsigned int **starting, unsigned int **active)
static int init_secret(struct pppoe_serv_t *serv)
{
- int fd;
DES_cblock key;
- fd = open("/dev/urandom", O_RDONLY);
- if (fd < 0) {
- log_emerg("pppoe: cann't open /dev/urandom: %s\n", strerror(errno));
- return -1;
- }
-
- if (read(fd, serv->secret, SECRET_LENGTH) < 0) {
+ if (read(urandom_fd, serv->secret, SECRET_LENGTH) < 0) {
log_emerg("pppoe: faild to read /dev/urandom\n", strerror(errno));
- close(fd);
return -1;
}
- close(fd);
-
memset(key, 0, sizeof(key));
DES_random_key(&key);
DES_set_key(&key, &serv->des_ks);