Magellan Linux

Annotation of /trunk/proftpd/patches/proftpd-1.3.0a-ctrls-restart.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 265 - (hide annotations) (download)
Wed Jul 11 23:16:10 2007 UTC (16 years, 11 months ago) by niro
File size: 3274 byte(s)
- proftpd-1.3.0a-r1

1 niro 265 Index: modules/mod_ctrls.c
2     ===================================================================
3     RCS file: /cvsroot/proftp/proftpd/modules/mod_ctrls.c,v
4     retrieving revision 1.30
5     diff -u -r1.30 mod_ctrls.c
6     --- modules/mod_ctrls.c 11 Nov 2005 21:05:32 -0000 1.30
7     +++ modules/mod_ctrls.c 23 May 2006 17:31:51 -0000
8     @@ -3,7 +3,7 @@
9     * server, as well as several utility functions for other Controls
10     * modules
11     *
12     - * Copyright (c) 2000-2005 TJ Saunders
13     + * Copyright (c) 2000-2006 TJ Saunders
14     *
15     * This program is free software; you can redistribute it and/or modify
16     * it under the terms of the GNU General Public License as published by
17     @@ -34,7 +34,7 @@
18     #include "privs.h"
19     #include "mod_ctrls.h"
20    
21     -#define MOD_CTRLS_VERSION "mod_ctrls/0.9.3"
22     +#define MOD_CTRLS_VERSION "mod_ctrls/0.9.4"
23    
24     /* Master daemon in standalone mode? (from src/main.c) */
25     extern unsigned char is_master;
26     @@ -518,7 +518,7 @@
27     } else if (res == PR_LOG_WRITABLE_DIR) {
28     pr_log_pri(PR_LOG_NOTICE, MOD_CTRLS_VERSION
29     ": unable to open ControlsLog '%s': "
30     - "containing directory is world writeable", ctrls_logname);
31     + "containing directory is world writable", ctrls_logname);
32    
33     } else if (res == PR_LOG_SYMLINK) {
34     pr_log_pri(PR_LOG_NOTICE, MOD_CTRLS_VERSION
35     @@ -1476,7 +1476,7 @@
36    
37     if (res == -2)
38     CONF_ERROR(cmd, pstrcat(cmd->tmp_pool,
39     - "unable to log to a world-writeable directory", NULL));
40     + "unable to log to a world-writable directory", NULL));
41     }
42    
43     return HANDLED(cmd);
44     @@ -1506,10 +1506,12 @@
45     CONF_ERROR(cmd, "must be an absolute path");
46    
47     /* Close the socket. */
48     - pr_log_debug(DEBUG3, MOD_CTRLS_VERSION ": closing ctrls socket '%s'",
49     - ctrls_sock_file);
50     - close(ctrls_sockfd);
51     - ctrls_sockfd = -1;
52     + if (ctrls_sockfd >= 0) {
53     + pr_log_debug(DEBUG3, MOD_CTRLS_VERSION ": closing ctrls socket '%s' (%d)",
54     + ctrls_sock_file, ctrls_sockfd);
55     + close(ctrls_sockfd);
56     + ctrls_sockfd = -1;
57     + }
58    
59     /* Change the path. */
60     if (strcmp(cmd->argv[1], ctrls_sock_file) != 0)
61     @@ -1608,9 +1610,28 @@
62     PRIVS_ROOT
63     ctrls_sockfd = ctrls_listen(ctrls_sock_file);
64     PRIVS_RELINQUISH
65     - if (ctrls_sockfd < 0)
66     + if (ctrls_sockfd < 0) {
67     pr_log_pri(PR_LOG_NOTICE, "notice: unable to listen to local socket: %s",
68     strerror(errno));
69     +
70     + } else {
71     + /* Ensure that the listen socket used is not one of the major three
72     + * (stdin, stdout, or stderr).
73     + */
74     + if (ctrls_sockfd < 3) {
75     + if (dup2(ctrls_sockfd, 3) < 0) {
76     + pr_log_pri(PR_LOG_NOTICE, MOD_CTRLS_VERSION
77     + ": error duplicating listen socket: %s", strerror(errno));
78     + (void) close(ctrls_sockfd);
79     + ctrls_sockfd = -1;
80     +
81     + } else {
82     + (void) close(ctrls_sockfd);
83     + ctrls_sockfd = 3;
84     + }
85     + }
86     + }
87     +
88     }
89    
90     static void ctrls_restart_ev(const void *event_data, void *user_data) {
91     @@ -1633,10 +1654,11 @@
92     cl_list = NULL;
93     cl_listlen = 0;
94    
95     - pr_log_debug(DEBUG3, MOD_CTRLS_VERSION ": closing ctrls socket '%s'",
96     - ctrls_sock_file);
97     + pr_log_debug(DEBUG3, MOD_CTRLS_VERSION ": closing ctrls socket '%s' (%d)",
98     + ctrls_sock_file, ctrls_sockfd);
99     close(ctrls_sockfd);
100     ctrls_sockfd = -1;
101     +
102     ctrls_closelog();
103    
104     /* Clear the existing pool */