View | Details | Raw Unified | Return to bug 35707 | Differences between
and this patch

Collapse All | Expand All

(-)a/management/univention-directory-listener/src/handlers.c (-1 / +1 lines)
 Lines 268-274   static int handler_import(char *filename) { Link Here 
268
	} else {
268
	} else {
269
		rv = fscanf(state_fp, "%u", &handler->state);
269
		rv = fscanf(state_fp, "%u", &handler->state);
270
		if (rv != 1)
270
		if (rv != 1)
271
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed reading %s: %s", state_filename, strerror(errno));
271
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed reading %s: %s", state_filename, strerror(errno));
272
		fclose(state_fp);
272
		fclose(state_fp);
273
	}
273
	}
274
274
(-)a/management/univention-directory-listener/src/main.c (-5 / +5 lines)
 Lines 146-156   static void daemonize(int lock_fd) { Link Here 
146
			abort();
146
			abort();
147
		rv = write(fd, buf, rv);
147
		rv = write(fd, buf, rv);
148
		if (rv)
148
		if (rv)
149
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to write %s: %s", pidfile, strerror(errno));
149
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to write %s: %s", pidfile, strerror(errno));
150
	}
150
	}
151
	rv = close(fd);
151
	rv = close(fd);
152
	if (rv)
152
	if (rv)
153
		univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to close %s: %s", pidfile, strerror(errno));
153
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to close %s: %s", pidfile, strerror(errno));
154
154
155
	// Set new file permissions
155
	// Set new file permissions
156
	umask(0);
156
	umask(0);
 Lines 158-164   static void daemonize(int lock_fd) { Link Here 
158
	// Change the working directory to the root directory
158
	// Change the working directory to the root directory
159
	rv = chdir("/");
159
	rv = chdir("/");
160
	if (rv)
160
	if (rv)
161
		univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to change directory: %s", strerror(errno));
161
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to change directory: %s", strerror(errno));
162
162
163
	if ((null = open("/dev/null", O_RDWR)) == -1) {
163
	if ((null = open("/dev/null", O_RDWR)) == -1) {
164
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not open /dev/null: %s", strerror(errno));
164
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ERROR, "could not open /dev/null: %s", strerror(errno));
 Lines 170-182   static void daemonize(int lock_fd) { Link Here 
170
		dup2(log, STDERR_FILENO);
170
		dup2(log, STDERR_FILENO);
171
		rv = close(log);
171
		rv = close(log);
172
		if (rv)
172
		if (rv)
173
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to close /var/log/univention/listener.log: %s", strerror(errno));
173
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to close /var/log/univention/listener.log: %s", strerror(errno));
174
	} else {
174
	} else {
175
		dup2(null, STDERR_FILENO);
175
		dup2(null, STDERR_FILENO);
176
	}
176
	}
177
	rv = close(null);
177
	rv = close(null);
178
	if (rv)
178
	if (rv)
179
		univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to close /dev/null: %s", strerror(errno));
179
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to close /dev/null: %s", strerror(errno));
180
180
181
	// Close all open file descriptors
181
	// Close all open file descriptors
182
	for (fd = sysconf(_SC_OPEN_MAX); fd > STDERR_FILENO; fd--)
182
	for (fd = sysconf(_SC_OPEN_MAX); fd > STDERR_FILENO; fd--)
(-)a/management/univention-directory-listener/src/transfile.c (-6 / +5 lines)
 Lines 60-66   static FILE *fopen_lock(const char *name, const char *type, FILE **l_file) { Link Here 
60
	snprintf(buf, sizeof(buf), "%s.lock", name);
60
	snprintf(buf, sizeof(buf), "%s.lock", name);
61
61
62
	if ((*l_file = fopen(buf, "a")) == NULL) {
62
	if ((*l_file = fopen(buf, "a")) == NULL) {
63
		univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Could not open lock file [%s]", buf);
63
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Could not open lock file [%s]", buf);
64
		return NULL;
64
		return NULL;
65
	}
65
	}
66
66
 Lines 69-75   static FILE *fopen_lock(const char *name, const char *type, FILE **l_file) { Link Here 
69
		int rc = lockf(l_fd, F_TLOCK, 0);
69
		int rc = lockf(l_fd, F_TLOCK, 0);
70
		if (!rc)
70
		if (!rc)
71
			break;
71
			break;
72
		univention_debug(UV_DEBUG_LDAP, UV_DEBUG_INFO, "Could not get lock for file [%s]; count=%d", buf, count);
72
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_INFO, "Could not get lock for file [%s]; count=%d", buf, count);
73
		count++;
73
		count++;
74
		if (count > listener_lock_count) {
74
		if (count > listener_lock_count) {
75
			univention_debug(UV_DEBUG_TRANSFILE, UV_DEBUG_ERROR, "Could not get lock for file [%s]; exit", buf);
75
			univention_debug(UV_DEBUG_TRANSFILE, UV_DEBUG_ERROR, "Could not get lock for file [%s]; exit", buf);
 Lines 79-89   static FILE *fopen_lock(const char *name, const char *type, FILE **l_file) { Link Here 
79
	}
79
	}
80
80
81
	if ((file = fopen(name, type)) == NULL) {
81
	if ((file = fopen(name, type)) == NULL) {
82
		univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Could not open file [%s]", name);
82
		univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Could not open file [%s]", name);
83
83
84
		int rc = lockf(l_fd, F_ULOCK, 0);
84
		int rc = lockf(l_fd, F_ULOCK, 0);
85
		if (rc)
85
		if (rc)
86
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_WARN, "Failed to unlock %s: %s", buf, strerror(errno));
86
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_WARN, "Failed to unlock %s: %s", buf, strerror(errno));
87
		fclose(*l_file);
87
		fclose(*l_file);
88
		*l_file = NULL;
88
		*l_file = NULL;
89
	}
89
	}
 Lines 105-111   static int fclose_lock(FILE **file, FILE **l_file) { Link Here 
105
		int l_fd = fileno(*l_file);
105
		int l_fd = fileno(*l_file);
106
		int rc = lockf(l_fd, F_ULOCK, 0);
106
		int rc = lockf(l_fd, F_ULOCK, 0);
107
		if (rc)
107
		if (rc)
108
			univention_debug(UV_DEBUG_LDAP, UV_DEBUG_ALL, "unlockf(): %d", rc);
108
			univention_debug(UV_DEBUG_LISTENER, UV_DEBUG_ALL, "unlockf(): %d", rc);
109
		rv |= fclose(*l_file);
109
		rv |= fclose(*l_file);
110
		*l_file = NULL;
110
		*l_file = NULL;
111
	}
111
	}
112
- 

Return to bug 35707