Index: contrib/mod_ban.c
===================================================================
RCS file: /cvsroot/proftp/proftpd/contrib/mod_ban.c,v
retrieving revision 1.55
diff -u -r1.55 mod_ban.c
--- contrib/mod_ban.c 12 Dec 2011 19:14:45 -0000 1.55
+++ contrib/mod_ban.c 15 Feb 2012 19:20:45 -0000
@@ -2819,39 +2819,21 @@
pr_event_unregister(&ban_module, "mod_auth.max-users-per-host", NULL);
pr_event_unregister(&ban_module, "mod_ban.client-connect-rate", NULL);
- /* "Bounce" the log file descriptor */
+ /* Close the BanLog file descriptor; it will be reopened by the postparse
+ * event listener.
+ */
close(ban_logfd);
ban_logfd = -1;
- if (ban_log &&
- strcasecmp(ban_log, "none") != 0) {
- int res;
-
- PRIVS_ROOT
- res = pr_log_openfile(ban_log, &ban_logfd, 0660);
- PRIVS_RELINQUISH
-
- switch (res) {
- case 0:
- break;
-
- case -1:
- pr_log_debug(DEBUG1, MOD_BAN_VERSION ": unable to open BanLog '%s': %s",
- ban_log, strerror(errno));
- break;
-
- case PR_LOG_SYMLINK:
- pr_log_debug(DEBUG1, MOD_BAN_VERSION ": unable to open BanLog '%s': %s",
- ban_log, "is a symlink");
- break;
-
- case PR_LOG_WRITABLE_DIR:
- pr_log_debug(DEBUG1, MOD_BAN_VERSION ": unable to open BanLog '%s': %s",
- ban_log, "parent directory is world-writable");
- break;
- }
+ /* Close the BanTable file descriptor; it will be reopened by the postparse
+ * event listener.
+ */
+ if (ban_tabfh != NULL) {
+ pr_fsio_close(ban_tabfh);
+ ban_tabfh = NULL;
}
+ /* Remove the timer. */
if (ban_timerno > 0) {
(void) pr_timer_remove(ban_timerno, &ban_module);
ban_timerno = -1;
Index: contrib/mod_ban.c
===================================================================
RCS file: /cvsroot/proftp/proftpd/contrib/mod_ban.c,v
retrieving revision 1.55
diff -u -r1.55 mod_ban.c
--- contrib/mod_ban.c 12 Dec 2011 19:14:45 -0000 1.55
+++ contrib/mod_ban.c 22 Feb 2012 01:53:52 -0000
@@ -2762,12 +2763,27 @@
ban_tabfh = pr_fsio_open(ban_table, O_RDWR|O_CREAT);
PRIVS_RELINQUISH
- if (!ban_tabfh) {
+ if (ban_tabfh == NULL) {
pr_log_pri(PR_LOG_NOTICE, MOD_BAN_VERSION
": unable to open BanTable '%s': %s", ban_table, strerror(errno));
pr_session_disconnect(&ban_module, PR_SESS_DISCONNECT_BAD_CONFIG, NULL);
}
+ if (ban_tabfh->fh_fd <= STDERR_FILENO) {
+ int usable_fd;
+
+ usable_fd = pr_fs_get_usable_fd(ban_tabfh->fh_fd);
+ if (usable_fd < 0) {
+ pr_log_debug(DEBUG0, MOD_BAN_VERSION
+ "warning: unable to find good fd for BanTable %s: %s", ban_table,
+ strerror(errno));
+
+ } else {
+ close(ban_tabfh->fh_fd);
+ ban_tabfh->fh_fd = usable_fd;
+ }
+ }
+
/* Get the shm for storing all of our ban info. */
lists = ban_get_shm(ban_tabfh);
if (lists == NULL &&
--- src/log.c
+++ src/log.c
@@ -363,6 +363,16 @@ int log_opensyslog(const char *fn) {
if (syslog_sockfd < 0)
return -1;
+ /* Find a usable fd for the just-opened socket fd. */
+ if (syslog_sockfd <= STDERR_FILENO) {
+ res = pr_fs_get_usable_fd(syslog_sockfd);
+ if (res > 0) {
+ (void) close(syslog_sockfd);
+ syslog_sockfd = res;
+ }
+ }
+
+ fcntl(syslog_sockfd, F_SETFD, FD_CLOEXEC);
systemlog_fd = -1;
} else if ((res = pr_log_openfile(systemlog_fn, &systemlog_fd,