diff options
Diffstat (limited to 'meta-oe/recipes-connectivity/inetutils/inetutils-1.8/inetutils-1.8-1005-ftpd-add-daemon-D-nommu-support.patch')
-rw-r--r-- | meta-oe/recipes-connectivity/inetutils/inetutils-1.8/inetutils-1.8-1005-ftpd-add-daemon-D-nommu-support.patch | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/meta-oe/recipes-connectivity/inetutils/inetutils-1.8/inetutils-1.8-1005-ftpd-add-daemon-D-nommu-support.patch b/meta-oe/recipes-connectivity/inetutils/inetutils-1.8/inetutils-1.8-1005-ftpd-add-daemon-D-nommu-support.patch new file mode 100644 index 000000000..844905b9a --- /dev/null +++ b/meta-oe/recipes-connectivity/inetutils/inetutils-1.8/inetutils-1.8-1005-ftpd-add-daemon-D-nommu-support.patch | |||
@@ -0,0 +1,109 @@ | |||
1 | From 1dee55b90d2971859377156e6210efdfdf1bac84 Mon Sep 17 00:00:00 2001 | ||
2 | From: Mike Frysinger <vapier at gentoo.org> | ||
3 | Date: Fri, 19 Nov 2010 20:26:48 -0500 | ||
4 | Subject: [PATCH] ftpd: add daemon (-D) nommu support | ||
5 | |||
6 | The current daemon design of ftpd is to: | ||
7 | - loop in server_mode() waiting for a connection | ||
8 | - fork a child and return to main() to process like inetd | ||
9 | - have parent continue looping in server_mode() | ||
10 | |||
11 | On a nommu system where we can only vfork(), the child returning | ||
12 | from server_mode() corrupts the stack and messes up the the parent. | ||
13 | So rather than having the child return, exec a new ftpd process in | ||
14 | the normal inetd mode. This also fixes the problem in nommu where | ||
15 | a vfork-ed child pauses the parent until it either exits or execs | ||
16 | something. | ||
17 | |||
18 | Signed-off-by: Mike Frysinger <vapier at gentoo.org> | ||
19 | --- | ||
20 | ftpd/extern.h | 3 ++- | ||
21 | ftpd/ftpd.c | 17 ++++++++++++++--- | ||
22 | ftpd/server_mode.c | 9 ++++++++- | ||
23 | 3 files changed, 24 insertions(+), 5 deletions(-) | ||
24 | |||
25 | diff --git a/ftpd/extern.h b/ftpd/extern.h | ||
26 | index 2483fe6..81182e0 100644 | ||
27 | --- a/ftpd/extern.h | ||
28 | +++ b/ftpd/extern.h | ||
29 | @@ -110,7 +110,8 @@ extern char tmpline[]; | ||
30 | extern off_t restart_point; | ||
31 | |||
32 | /* Exported from server_mode.c. */ | ||
33 | -extern int server_mode (const char *pidfile, struct sockaddr_in *phis_addr); | ||
34 | +extern int server_mode (const char *pidfile, struct sockaddr_in *phis_addr, | ||
35 | + char *argv[]); | ||
36 | |||
37 | /* Credential for the request. */ | ||
38 | struct credentials | ||
39 | diff --git a/ftpd/ftpd.c b/ftpd/ftpd.c | ||
40 | index aed74e6..c5c4c90 100644 | ||
41 | --- a/ftpd/ftpd.c | ||
42 | +++ b/ftpd/ftpd.c | ||
43 | @@ -424,8 +424,7 @@ main (int argc, char *argv[], char **envp) | ||
44 | argp_parse (&argp, argc, argv, 0, &index, NULL); | ||
45 | |||
46 | /* Bail out, wrong usage */ | ||
47 | - argc -= index; | ||
48 | - if (argc != 0) | ||
49 | + if (argc - index != 0) | ||
50 | error (1, 0, "surplus arguments; try `%s --help' for more info", | ||
51 | program_name); | ||
52 | |||
53 | @@ -438,7 +437,19 @@ main (int argc, char *argv[], char **envp) | ||
54 | fd = accept(). tcpd is check if compile with the support */ | ||
55 | if (daemon_mode) | ||
56 | { | ||
57 | - if (server_mode (pid_file, &his_addr) < 0) | ||
58 | +#ifndef HAVE_FORK | ||
59 | + /* Shift out the daemon option in subforks */ | ||
60 | + int i; | ||
61 | + for (i = 0; i < argc; ++i) | ||
62 | + if (strcmp (argv[i], "-D") == 0) | ||
63 | + { | ||
64 | + int j; | ||
65 | + for (j = i; j < argc; ++j) | ||
66 | + argv[j] = argv[j + 1]; | ||
67 | + argv[--argc] = NULL; | ||
68 | + } | ||
69 | +#endif | ||
70 | + if (server_mode (pid_file, &his_addr, argv) < 0) | ||
71 | exit (1); | ||
72 | } | ||
73 | else | ||
74 | diff --git a/ftpd/server_mode.c b/ftpd/server_mode.c | ||
75 | index 3d3a498..605e13e 100644 | ||
76 | --- a/ftpd/server_mode.c | ||
77 | +++ b/ftpd/server_mode.c | ||
78 | @@ -37,6 +37,8 @@ | ||
79 | # include <tcpd.h> | ||
80 | #endif | ||
81 | |||
82 | +#include <libinetutils.h> | ||
83 | + | ||
84 | static void reapchild (int); | ||
85 | |||
86 | #define DEFPORT 21 | ||
87 | @@ -92,7 +94,7 @@ reapchild (int signo ARG_UNUSED) | ||
88 | } | ||
89 | |||
90 | int | ||
91 | -server_mode (const char *pidfile, struct sockaddr_in *phis_addr) | ||
92 | +server_mode (const char *pidfile, struct sockaddr_in *phis_addr, char *argv[]) | ||
93 | { | ||
94 | int ctl_sock, fd; | ||
95 | struct servent *sv; | ||
96 | @@ -176,5 +178,10 @@ server_mode (const char *pidfile, struct sockaddr_in *phis_addr) | ||
97 | if (!check_host ((struct sockaddr *) phis_addr)) | ||
98 | return -1; | ||
99 | #endif | ||
100 | + | ||
101 | +#ifndef HAVE_FORK | ||
102 | + _exit(execvp(argv[0], argv)); | ||
103 | +#endif | ||
104 | + | ||
105 | return fd; | ||
106 | } | ||
107 | -- | ||
108 | 1.7.3.2 | ||
109 | |||