adns-ocloexec
[platform/upstream/adns.git] / packaging / adns-ocloexec.patch
1 --- src/setup.c.orig
2 +++ src/setup.c
3 @@ -464,7 +464,7 @@ static const char *instrum_getenv(adns_s
4  static void readconfig(adns_state ads, const char *filename, int warnmissing) {
5    getline_ctx gl_ctx;
6    
7 -  gl_ctx.file= fopen(filename,"r");
8 +  gl_ctx.file= fopen(filename,"re");
9    if (!gl_ctx.file) {
10      if (errno == ENOENT) {
11        if (warnmissing)
12 @@ -572,7 +572,7 @@ static int init_finish(adns_state ads) {
13    }
14  
15    proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; }
16 -  ads->udpsocket= socket(AF_INET,SOCK_DGRAM,proto->p_proto);
17 +  ads->udpsocket= socket(AF_INET,SOCK_DGRAM|SOCK_CLOEXEC,proto->p_proto);
18    if (ads->udpsocket<0) { r= errno; goto x_free; }
19  
20    r= adns__setnonblock(ads,ads->udpsocket);
21 --- src/event.c.orig
22 +++ src/event.c
23 @@ -123,7 +123,7 @@ void adns__tcp_tryconnect(adns_state ads
24        adns__diag(ads,-1,0,"unable to find protocol no. for TCP !");
25        return;
26      }
27 -    fd= socket(AF_INET,SOCK_STREAM,proto->p_proto);
28 +    fd= socket(AF_INET,SOCK_STREAM|SOCK_CLOEXEC,proto->p_proto);
29      if (fd<0) {
30        adns__diag(ads,-1,0,"cannot create TCP socket: %s",strerror(errno));
31        return;