comparison src/dhcpcd.h @ 5525:26b5d9bc2985 draft

privsep: Send all log messages to the privileged actioneer If dhcpcd starts and no syslogd implementation is running then various syscall filters could be triggered when dhcpcd wants to syslog and it's already in a chroot. Not all libc openlog implementations support LOG_NDELAY and openlog does not return an error code and can also mask errno back to 0. So we have no way of knowing if we have a syslog connection or not. This means we cannot cache the connection at startup because syslog itself will try and open if no connection. As such, all logging is now directed to the dhcpcd privileged actioneer process which will handle all the syslog and log file writing actions. The only downside of this approach (other than an extra fd per process) is that we no longer know which PID raised the message. While we could put the correct PID in the logfile as we control the API, we cannot put it into syslog as we cannot control that API. As all privsep errors should log which function they came from this will hopefully not be an issue as on the happy path only the master process will log stuff.
author Roy Marples <roy@marples.name>
date Fri, 30 Oct 2020 03:43:51 +0000
parents 6a2da5651841
children b1a3d9055662
comparison
equal deleted inserted replaced
5524:8c0e5dc34824 5525:26b5d9bc2985
197 197
198 #ifdef PRIVSEP 198 #ifdef PRIVSEP
199 struct passwd *ps_user; /* struct passwd for privsep user */ 199 struct passwd *ps_user; /* struct passwd for privsep user */
200 pid_t ps_root_pid; 200 pid_t ps_root_pid;
201 int ps_root_fd; /* Privileged Actioneer commands */ 201 int ps_root_fd; /* Privileged Actioneer commands */
202 int ps_syslog_fd; /* syslog(3) wrapper */
202 int ps_data_fd; /* Data from root spawned processes */ 203 int ps_data_fd; /* Data from root spawned processes */
203 struct eloop *ps_eloop; /* eloop for polling root data */ 204 struct eloop *ps_eloop; /* eloop for polling root data */
204 struct ps_process_head ps_processes; /* List of spawned processes */ 205 struct ps_process_head ps_processes; /* List of spawned processes */
205 pid_t ps_inet_pid; 206 pid_t ps_inet_pid;
206 int ps_inet_fd; /* Network Proxy commands and data */ 207 int ps_inet_fd; /* Network Proxy commands and data */