blob: 0cb26dcb1a00d9392c58ba77f1e55425fd64c6be [file] [log] [blame]
Mark Salyzyn0175b072014-02-26 09:50:16 -08001/*
2 * Copyright (C) 2012-2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <dirent.h>
18#include <errno.h>
19#include <fcntl.h>
Mark Salyzyn11e55cb2015-03-10 16:45:17 -070020#include <poll.h>
Mark Salyzyn882f8562013-12-26 15:13:36 -080021#include <sched.h>
Mark Salyzyn11e55cb2015-03-10 16:45:17 -070022#include <semaphore.h>
23#include <signal.h>
Mark Salyzyn0175b072014-02-26 09:50:16 -080024#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <sys/capability.h>
Mark Salyzyneb06de72014-10-13 09:59:37 -070028#include <sys/klog.h>
Elliott Hughese5a0f202014-07-18 17:39:41 -070029#include <sys/prctl.h>
Riley Andrewsd98f4e82015-06-08 23:36:34 -070030#include <sys/resource.h>
Mark Salyzyn0175b072014-02-26 09:50:16 -080031#include <sys/stat.h>
32#include <sys/types.h>
Mark Salyzynccbadc62015-03-12 12:25:35 -070033#include <syslog.h>
Mark Salyzyne457b742014-02-19 17:18:31 -080034#include <unistd.h>
Mark Salyzyn0175b072014-02-26 09:50:16 -080035
William Robertsaeca97b2015-07-31 13:10:36 -070036#include <cstdbool>
Mark Salyzynd5600fd2015-06-12 14:59:42 -070037#include <memory>
38
Jorge Lucangeli Obes2bbdbe82016-07-15 13:57:08 -040039#include <android-base/macros.h>
Mark Salyzyne457b742014-02-19 17:18:31 -080040#include <cutils/properties.h>
Mark Salyzyn56ba4b52015-01-30 15:19:48 -080041#include <cutils/sched_policy.h>
Mark Salyzyn11e55cb2015-03-10 16:45:17 -070042#include <cutils/sockets.h>
Jorge Lucangeli Obes2bbdbe82016-07-15 13:57:08 -040043#include <libminijail.h>
Mark Salyzynff32f3c2015-04-13 14:24:45 -070044#include <log/event_tag_map.h>
William Robertsaeca97b2015-07-31 13:10:36 -070045#include <packagelistparser/packagelistparser.h>
Mark Salyzyne3aeeee2015-03-17 07:56:32 -070046#include <private/android_filesystem_config.h>
Mark Salyzyn5740a462016-03-28 15:42:08 -070047#include <private/android_logger.h>
Jorge Lucangeli Obes2bbdbe82016-07-15 13:57:08 -040048#include <scoped_minijail.h>
Riley Andrewsd98f4e82015-06-08 23:36:34 -070049#include <utils/threads.h>
Mark Salyzyne457b742014-02-19 17:18:31 -080050
Mark Salyzyn0175b072014-02-26 09:50:16 -080051#include "CommandListener.h"
52#include "LogBuffer.h"
53#include "LogListener.h"
William Roberts29d238d2013-02-08 09:45:26 +090054#include "LogAudit.h"
Mark Salyzyna1aacb72014-10-15 08:49:39 -070055#include "LogKlog.h"
Mark Salyzyn5ac5c6b2015-08-28 08:02:59 -070056#include "LogUtils.h"
Mark Salyzyn0175b072014-02-26 09:50:16 -080057
Mark Salyzynccbadc62015-03-12 12:25:35 -070058#define KMSG_PRIORITY(PRI) \
59 '<', \
60 '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) / 10, \
61 '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) % 10, \
62 '>'
63
Mark Salyzyndfc47e82014-03-24 10:26:47 -070064//
Jorge Lucangeli Obes2bbdbe82016-07-15 13:57:08 -040065// The service is designed to be run by init, it does not respond well
Mark Salyzyndfc47e82014-03-24 10:26:47 -070066// to starting up manually. When starting up manually the sockets will
67// fail to open typically for one of the following reasons:
68// EADDRINUSE if logger is running.
69// EACCESS if started without precautions (below)
70//
71// Here is a cookbook procedure for starting up logd manually assuming
Jorge Lucangeli Obes2bbdbe82016-07-15 13:57:08 -040072// init is out of the way, pedantically all permissions and SELinux
Mark Salyzyndfc47e82014-03-24 10:26:47 -070073// security is put back in place:
74//
75// setenforce 0
76// rm /dev/socket/logd*
77// chmod 777 /dev/socket
78// # here is where you would attach the debugger or valgrind for example
79// runcon u:r:logd:s0 /system/bin/logd </dev/null >/dev/null 2>&1 &
80// sleep 1
81// chmod 755 /dev/socket
82// chown logd.logd /dev/socket/logd*
83// restorecon /dev/socket/logd*
84// setenforce 1
85//
86// If minimalism prevails, typical for debugging and security is not a concern:
87//
88// setenforce 0
89// chmod 777 /dev/socket
90// logd
91//
92
Mark Salyzyn0175b072014-02-26 09:50:16 -080093static int drop_privs() {
Mark Salyzyn882f8562013-12-26 15:13:36 -080094 struct sched_param param;
95 memset(&param, 0, sizeof(param));
96
Mark Salyzyn56ba4b52015-01-30 15:19:48 -080097 if (set_sched_policy(0, SP_BACKGROUND) < 0) {
98 return -1;
99 }
100
Mark Salyzyn882f8562013-12-26 15:13:36 -0800101 if (sched_setscheduler((pid_t) 0, SCHED_BATCH, &param) < 0) {
102 return -1;
103 }
104
Riley Andrewsd98f4e82015-06-08 23:36:34 -0700105 if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) {
106 return -1;
107 }
108
Nick Kralevichc39ba5a2015-11-07 16:52:17 -0800109 gid_t groups[] = { AID_READPROC };
Jorge Lucangeli Obes2bbdbe82016-07-15 13:57:08 -0400110 ScopedMinijail j(minijail_new());
111 minijail_set_supplementary_gids(j.get(), arraysize(groups), groups);
112 minijail_change_uid(j.get(), AID_LOGD);
113 minijail_change_gid(j.get(), AID_LOGD);
114 minijail_use_caps(j.get(), CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_AUDIT_CONTROL));
115 minijail_enter(j.get());
Mark Salyzyn0175b072014-02-26 09:50:16 -0800116 return 0;
117}
118
Mark Salyzyne0fa2912014-04-28 16:39:04 -0700119// Property helper
Mark Salyzyn9c66a582015-12-14 16:40:12 -0800120static bool check_flag(const char *prop, const char *flag) {
121 const char *cp = strcasestr(prop, flag);
122 if (!cp) {
Mark Salyzyne0fa2912014-04-28 16:39:04 -0700123 return false;
124 }
Mark Salyzyn9c66a582015-12-14 16:40:12 -0800125 // We only will document comma (,)
126 static const char sep[] = ",:;|+ \t\f";
127 if ((cp != prop) && !strchr(sep, cp[-1])) {
128 return false;
129 }
130 cp += strlen(flag);
131 return !*cp || !!strchr(sep, *cp);
132}
Mark Salyzyne0fa2912014-04-28 16:39:04 -0700133
Mark Salyzynccbadc62015-03-12 12:25:35 -0700134static int fdDmesg = -1;
Mark Salyzyn36a87112016-07-15 09:55:41 -0700135void android::prdebug(const char *fmt, ...) {
Mark Salyzynd048f112016-02-08 10:28:12 -0800136 if (fdDmesg < 0) {
137 return;
138 }
139
140 static const char message[] = {
141 KMSG_PRIORITY(LOG_DEBUG), 'l', 'o', 'g', 'd', ':', ' '
142 };
143 char buffer[256];
144 memcpy(buffer, message, sizeof(message));
145
146 va_list ap;
147 va_start(ap, fmt);
148 int n = vsnprintf(buffer + sizeof(message),
149 sizeof(buffer) - sizeof(message), fmt, ap);
150 va_end(ap);
151 if (n > 0) {
152 buffer[sizeof(buffer) - 1] = '\0';
153 if (!strchr(buffer, '\n')) {
154 buffer[sizeof(buffer) - 2] = '\0';
155 strlcat(buffer, "\n", sizeof(buffer));
156 }
157 write(fdDmesg, buffer, strlen(buffer));
158 }
159}
Mark Salyzynccbadc62015-03-12 12:25:35 -0700160
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700161static sem_t uidName;
162static uid_t uid;
163static char *name;
164
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700165static sem_t reinit;
166static bool reinit_running = false;
167static LogBuffer *logBuf = NULL;
Mark Salyzyne0fa2912014-04-28 16:39:04 -0700168
William Robertsaeca97b2015-07-31 13:10:36 -0700169static bool package_list_parser_cb(pkg_info *info, void * /* userdata */) {
170
171 bool rc = true;
172 if (info->uid == uid) {
173 name = strdup(info->name);
174 // false to stop processing
175 rc = false;
176 }
177
178 packagelist_free(info);
179 return rc;
180}
181
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700182static void *reinit_thread_start(void * /*obj*/) {
183 prctl(PR_SET_NAME, "logd.daemon");
184 set_sched_policy(0, SP_BACKGROUND);
Riley Andrewsd98f4e82015-06-08 23:36:34 -0700185 setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND);
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700186
Mark Salyzyn07522c62016-03-02 07:51:48 -0800187 // If we are AID_ROOT, we should drop to AID_SYSTEM, if we are anything
188 // else, we have even lesser privileges and accept our fate. Not worth
189 // checking for error returns setting this thread's privileges.
190 (void)setgid(AID_SYSTEM);
191 (void)setuid(AID_SYSTEM);
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700192
193 while (reinit_running && !sem_wait(&reinit) && reinit_running) {
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700194
195 // uidToName Privileged Worker
196 if (uid) {
197 name = NULL;
198
William Robertsaeca97b2015-07-31 13:10:36 -0700199 packagelist_parse(package_list_parser_cb, NULL);
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700200
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700201 uid = 0;
202 sem_post(&uidName);
203 continue;
204 }
205
Mark Salyzynccbadc62015-03-12 12:25:35 -0700206 if (fdDmesg >= 0) {
207 static const char reinit_message[] = { KMSG_PRIORITY(LOG_INFO),
208 'l', 'o', 'g', 'd', '.', 'd', 'a', 'e', 'm', 'o', 'n', ':',
209 ' ', 'r', 'e', 'i', 'n', 'i', 't', '\n' };
210 write(fdDmesg, reinit_message, sizeof(reinit_message));
211 }
212
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700213 // Anything that reads persist.<property>
214 if (logBuf) {
215 logBuf->init();
Mark Salyzyn932f7ac2015-08-28 08:02:59 -0700216 logBuf->initPrune(NULL);
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700217 }
218 }
219
220 return NULL;
221}
222
Mark Salyzyn95108f12015-04-20 07:26:27 -0700223static sem_t sem_name;
224
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700225char *android::uidToName(uid_t u) {
226 if (!u || !reinit_running) {
227 return NULL;
228 }
229
Mark Salyzyn95108f12015-04-20 07:26:27 -0700230 sem_wait(&sem_name);
231
232 // Not multi-thread safe, we use sem_name to protect
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700233 uid = u;
234
235 name = NULL;
236 sem_post(&reinit);
237 sem_wait(&uidName);
Mark Salyzyn95108f12015-04-20 07:26:27 -0700238 char *ret = name;
239
240 sem_post(&sem_name);
241
242 return ret;
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700243}
244
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700245// Serves as a global method to trigger reinitialization
246// and as a function that can be provided to signal().
247void reinit_signal_handler(int /*signal*/) {
248 sem_post(&reinit);
249}
250
Mark Salyzynff32f3c2015-04-13 14:24:45 -0700251// tagToName converts an events tag into a name
Mark Salyzyn807e40e2016-09-22 09:56:51 -0700252const char *android::tagToName(size_t *len, uint32_t tag) {
Mark Salyzynff32f3c2015-04-13 14:24:45 -0700253 static const EventTagMap *map;
254
255 if (!map) {
256 sem_wait(&sem_name);
257 if (!map) {
258 map = android_openEventTagMap(EVENT_TAG_MAP_FILE);
259 }
260 sem_post(&sem_name);
261 if (!map) {
Mark Salyzyn807e40e2016-09-22 09:56:51 -0700262 if (len) len = 0;
Mark Salyzynff32f3c2015-04-13 14:24:45 -0700263 return NULL;
264 }
265 }
Mark Salyzyn807e40e2016-09-22 09:56:51 -0700266 return android_lookupEventTag_len(map, len, tag);
Mark Salyzynff32f3c2015-04-13 14:24:45 -0700267}
268
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700269static void readDmesg(LogAudit *al, LogKlog *kl) {
270 if (!al && !kl) {
271 return;
272 }
273
Mark Salyzynea1a2412015-09-02 07:39:53 -0700274 int rc = klogctl(KLOG_SIZE_BUFFER, NULL, 0);
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700275 if (rc <= 0) {
276 return;
277 }
278
Mark Salyzynea1a2412015-09-02 07:39:53 -0700279 size_t len = rc + 1024; // Margin for additional input race or trailing nul
280 std::unique_ptr<char []> buf(new char[len]);
281
282 rc = klogctl(KLOG_READ_ALL, buf.get(), len);
283 if (rc <= 0) {
284 return;
285 }
286
287 if ((size_t)rc < len) {
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700288 len = rc + 1;
289 }
Mark Salyzynea1a2412015-09-02 07:39:53 -0700290 buf[--len] = '\0';
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700291
Mark Salyzynb6bee332015-09-08 08:56:32 -0700292 if (kl && kl->isMonotonic()) {
Mark Salyzyn151beac2015-09-04 11:37:42 -0700293 kl->synchronize(buf.get(), len);
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700294 }
295
Mark Salyzynea1a2412015-09-02 07:39:53 -0700296 size_t sublen;
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700297 for (char *ptr = NULL, *tok = buf.get();
Mark Salyzynea1a2412015-09-02 07:39:53 -0700298 (rc >= 0) && ((tok = log_strntok_r(tok, &len, &ptr, &sublen)));
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700299 tok = NULL) {
300 if (al) {
Mark Salyzyn151beac2015-09-04 11:37:42 -0700301 rc = al->log(tok, sublen);
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700302 }
303 if (kl) {
Mark Salyzyn151beac2015-09-04 11:37:42 -0700304 rc = kl->log(tok, sublen);
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700305 }
306 }
307}
308
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700309// Foreground waits for exit of the main persistent threads
310// that are started here. The threads are created to manage
311// UNIX domain client sockets for writing, reading and
312// controlling the user space logger, and for any additional
313// logging plugins like auditd and restart control. Additional
314// transitory per-client threads are created for each reader.
315int main(int argc, char *argv[]) {
Mark Salyzyna1aacb72014-10-15 08:49:39 -0700316 int fdPmesg = -1;
Mark Salyzynf10e2732016-09-27 13:08:23 -0700317 bool klogd = __android_logger_property_get_bool("logd.kernel",
318 BOOL_DEFAULT_TRUE |
319 BOOL_DEFAULT_FLAG_PERSIST |
320 BOOL_DEFAULT_FLAG_ENG |
321 BOOL_DEFAULT_FLAG_SVELTE);
Mark Salyzyna1aacb72014-10-15 08:49:39 -0700322 if (klogd) {
323 fdPmesg = open("/proc/kmsg", O_RDONLY | O_NDELAY);
324 }
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700325 fdDmesg = open("/dev/kmsg", O_WRONLY);
326
327 // issue reinit command. KISS argument parsing.
328 if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) {
329 int sock = TEMP_FAILURE_RETRY(
330 socket_local_client("logd",
331 ANDROID_SOCKET_NAMESPACE_RESERVED,
332 SOCK_STREAM));
333 if (sock < 0) {
334 return -errno;
335 }
336 static const char reinit[] = "reinit";
337 ssize_t ret = TEMP_FAILURE_RETRY(write(sock, reinit, sizeof(reinit)));
338 if (ret < 0) {
339 return -errno;
340 }
341 struct pollfd p;
342 memset(&p, 0, sizeof(p));
343 p.fd = sock;
344 p.events = POLLIN;
Mark Salyzynf011a332015-12-10 11:27:03 -0800345 ret = TEMP_FAILURE_RETRY(poll(&p, 1, 1000));
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700346 if (ret < 0) {
347 return -errno;
348 }
349 if ((ret == 0) || !(p.revents & POLLIN)) {
350 return -ETIME;
351 }
352 static const char success[] = "success";
353 char buffer[sizeof(success) - 1];
354 memset(buffer, 0, sizeof(buffer));
355 ret = TEMP_FAILURE_RETRY(read(sock, buffer, sizeof(buffer)));
356 if (ret < 0) {
357 return -errno;
358 }
359 return strncmp(buffer, success, sizeof(success) - 1) != 0;
360 }
361
362 // Reinit Thread
363 sem_init(&reinit, 0, 0);
Mark Salyzyn08739ba2015-03-16 08:26:05 -0700364 sem_init(&uidName, 0, 0);
Mark Salyzyn95108f12015-04-20 07:26:27 -0700365 sem_init(&sem_name, 0, 1);
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700366 pthread_attr_t attr;
367 if (!pthread_attr_init(&attr)) {
368 struct sched_param param;
369
370 memset(&param, 0, sizeof(param));
371 pthread_attr_setschedparam(&attr, &param);
372 pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
373 if (!pthread_attr_setdetachstate(&attr,
374 PTHREAD_CREATE_DETACHED)) {
375 pthread_t thread;
376 reinit_running = true;
377 if (pthread_create(&thread, &attr, reinit_thread_start, NULL)) {
378 reinit_running = false;
379 }
380 }
381 pthread_attr_destroy(&attr);
Mark Salyzyne9bebd02014-04-03 09:55:26 -0700382 }
383
Mark Salyzyn0175b072014-02-26 09:50:16 -0800384 if (drop_privs() != 0) {
385 return -1;
386 }
387
388 // Serves the purpose of managing the last logs times read on a
389 // socket connection, and as a reader lock on a range of log
390 // entries.
391
392 LastLogTimes *times = new LastLogTimes();
393
394 // LogBuffer is the object which is responsible for holding all
395 // log entries.
396
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700397 logBuf = new LogBuffer(times);
398
399 signal(SIGHUP, reinit_signal_handler);
Mark Salyzyn0175b072014-02-26 09:50:16 -0800400
Mark Salyzynf10e2732016-09-27 13:08:23 -0700401 if (__android_logger_property_get_bool("logd.statistics",
402 BOOL_DEFAULT_TRUE |
403 BOOL_DEFAULT_FLAG_PERSIST |
404 BOOL_DEFAULT_FLAG_ENG |
405 BOOL_DEFAULT_FLAG_SVELTE)) {
Mark Salyzyna1aacb72014-10-15 08:49:39 -0700406 logBuf->enableStatistics();
Mark Salyzynf5fc5092014-09-21 14:22:18 -0700407 }
Mark Salyzyne457b742014-02-19 17:18:31 -0800408
Mark Salyzyn0175b072014-02-26 09:50:16 -0800409 // LogReader listens on /dev/socket/logdr. When a client
410 // connects, log entries in the LogBuffer are written to the client.
411
412 LogReader *reader = new LogReader(logBuf);
413 if (reader->startListener()) {
414 exit(1);
415 }
416
417 // LogListener listens on /dev/socket/logdw for client
418 // initiated log messages. New log entries are added to LogBuffer
419 // and LogReader is notified to send updates to connected clients.
420
421 LogListener *swl = new LogListener(logBuf, reader);
Mark Salyzyn581edc12013-11-20 13:38:52 -0800422 // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
Mark Salyzyn39944c82015-09-08 11:24:07 -0700423 if (swl->startListener(600)) {
Mark Salyzyn0175b072014-02-26 09:50:16 -0800424 exit(1);
425 }
426
427 // Command listener listens on /dev/socket/logd for incoming logd
428 // administrative commands.
429
430 CommandListener *cl = new CommandListener(logBuf, reader, swl);
431 if (cl->startListener()) {
432 exit(1);
433 }
434
William Roberts29d238d2013-02-08 09:45:26 +0900435 // LogAudit listens on NETLINK_AUDIT socket for selinux
436 // initiated log messages. New log entries are added to LogBuffer
437 // and LogReader is notified to send updates to connected clients.
438
Mark Salyzynf10e2732016-09-27 13:08:23 -0700439 bool auditd = __android_logger_property_get_bool("logd.auditd",
440 BOOL_DEFAULT_TRUE |
441 BOOL_DEFAULT_FLAG_PERSIST);
Sami Tolvanena742d102016-06-14 18:04:43 +0000442 LogAudit *al = NULL;
443 if (auditd) {
444 al = new LogAudit(logBuf, reader,
Mark Salyzynf10e2732016-09-27 13:08:23 -0700445 __android_logger_property_get_bool(
446 "logd.auditd.dmesg",
447 BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_PERSIST)
448 ? fdDmesg
449 : -1);
Sami Tolvanena742d102016-06-14 18:04:43 +0000450 }
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700451
Mark Salyzyna1aacb72014-10-15 08:49:39 -0700452 LogKlog *kl = NULL;
453 if (klogd) {
Sami Tolvanena742d102016-06-14 18:04:43 +0000454 kl = new LogKlog(logBuf, reader, fdDmesg, fdPmesg, al != NULL);
Mark Salyzyna1aacb72014-10-15 08:49:39 -0700455 }
Mark Salyzyneb06de72014-10-13 09:59:37 -0700456
Sami Tolvanena742d102016-06-14 18:04:43 +0000457 readDmesg(al, kl);
Mark Salyzyneb06de72014-10-13 09:59:37 -0700458
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700459 // failure is an option ... messages are in dmesg (required by standard)
Mark Salyzyneb06de72014-10-13 09:59:37 -0700460
Mark Salyzynd5600fd2015-06-12 14:59:42 -0700461 if (kl && kl->startListener()) {
462 delete kl;
463 }
Mark Salyzyneb06de72014-10-13 09:59:37 -0700464
Sami Tolvanena742d102016-06-14 18:04:43 +0000465 if (al && al->startListener()) {
466 delete al;
William Roberts29d238d2013-02-08 09:45:26 +0900467 }
468
Mark Salyzyn11e55cb2015-03-10 16:45:17 -0700469 TEMP_FAILURE_RETRY(pause());
470
Mark Salyzyn0175b072014-02-26 09:50:16 -0800471 exit(0);
472}