diff options
Diffstat (limited to 'meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/022-add-close-on-exec-descriptors.patch')
-rw-r--r-- | meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/022-add-close-on-exec-descriptors.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/022-add-close-on-exec-descriptors.patch b/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/022-add-close-on-exec-descriptors.patch new file mode 100644 index 0000000000..011ae74cde --- /dev/null +++ b/meta/recipes-devtools/unfs-server/unfs-server-2.2beta47/022-add-close-on-exec-descriptors.patch | |||
@@ -0,0 +1,61 @@ | |||
1 | # Force socket fds to close on exec when used in conjunction with pseudo | ||
2 | # Patch origin: Wind River | ||
3 | |||
4 | --- | ||
5 | nfsd.c | 8 ++++++++ | ||
6 | rpcmisc.c | 9 +++++++++ | ||
7 | ugidd.c | 8 ++++++++ | ||
8 | 3 files changed, 25 insertions(+) | ||
9 | |||
10 | --- a/nfsd.c | ||
11 | +++ b/nfsd.c | ||
12 | @@ -630,6 +630,14 @@ nfsd_nfsproc_create_2(createargs *argp, | ||
13 | if (S_ISSOCK(argp->attributes.mode)) { | ||
14 | if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) | ||
15 | return(nfs_errno()); | ||
16 | + /* if there is a pseudo exec mark the socket to be | ||
17 | + * closed automatically | ||
18 | + */ | ||
19 | + { | ||
20 | + long f_flags; | ||
21 | + f_flags = fcntl(s, F_GETFD); | ||
22 | + f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC); | ||
23 | + } | ||
24 | sa.sun_family = AF_UNIX; | ||
25 | strncpy(sa.sun_path, pathbuf, sizeof(sa.sun_path)); | ||
26 | sa.sun_path[sizeof(sa.sun_path)-1] = '\0'; | ||
27 | --- a/rpcmisc.c | ||
28 | +++ b/rpcmisc.c | ||
29 | @@ -197,6 +197,15 @@ makesock(int port, int proto, int socksz | ||
30 | Dprintf(L_FATAL, "Could not make a %s socket: %s\n", | ||
31 | prot_name, strerror(errno)); | ||
32 | |||
33 | + /* if there is a pseudo exec mark the socket to be | ||
34 | + * closed automatically | ||
35 | + */ | ||
36 | + { | ||
37 | + long f_flags; | ||
38 | + f_flags = fcntl(s, F_GETFD); | ||
39 | + f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC); | ||
40 | + } | ||
41 | + fcntl(s, FD_CLOEXEC, 1); | ||
42 | memset((char *) &sin, 0, sizeof(sin)); | ||
43 | sin.sin_family = AF_INET; | ||
44 | sin.sin_addr.s_addr = INADDR_ANY; | ||
45 | --- a/ugidd.c | ||
46 | +++ b/ugidd.c | ||
47 | @@ -195,6 +195,14 @@ authenticate_1_svc(argp, rqstp) | ||
48 | destaddr.sin_port = htons(*argp); | ||
49 | if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) | ||
50 | goto bad; | ||
51 | + /* if there is a pseudo exec mark the socket to be | ||
52 | + * closed automatically | ||
53 | + */ | ||
54 | + { | ||
55 | + long f_flags; | ||
56 | + f_flags = fcntl(s, F_GETFD); | ||
57 | + f_flags = fcntl(s, F_SETFD, f_flags | FD_CLOEXEC); | ||
58 | + } | ||
59 | setsockopt(s, SOL_SOCKET, SO_LINGER, 0, 0); | ||
60 | bzero((char *) &sendaddr, sizeof sendaddr); | ||
61 | /* find a reserved port */ | ||