226
234
mprintf_send_timeout = optget(opts, "SendBufTimeout")->numarg;
228
236
do { /* logger initialized */
230
if((opt = optget(opts, "LogFile"))->enabled) {
232
logg_file = opt->strarg;
233
if(!cli_is_abspath(logg_file)) {
234
fprintf(stderr, "ERROR: LogFile requires full path.\n");
239
if(logg("#+++ Started at %s", cli_ctime(&currtime, timestr, sizeof(timestr)))) {
240
fprintf(stderr, "ERROR: Can't initialize the internal logger\n");
247
if (optget(opts,"DevLiblog")->enabled)
248
cl_set_clcb_msg(msg_callback);
249
if((ret = cl_init(CL_INIT_DEFAULT))) {
250
logg("!Can't initialize libclamav: %s\n", cl_strerror(ret));
255
if(optget(opts, "Debug")->enabled) /* enable debug messages in libclamav */ {
237
if((opt = optget(opts, "LogFile"))->enabled) {
239
logg_file = opt->strarg;
240
if(!cli_is_abspath(logg_file)) {
241
fprintf(stderr, "ERROR: LogFile requires full path.\n");
246
if(logg("#+++ Started at %s", cli_ctime(&currtime, timestr, sizeof(timestr)))) {
247
fprintf(stderr, "ERROR: Can't initialize the internal logger\n");
255
if (optget(opts,"DevLiblog")->enabled)
256
cl_set_clcb_msg(msg_callback);
258
if((ret = cl_init(CL_INIT_DEFAULT))) {
259
logg("!Can't initialize libclamav: %s\n", cl_strerror(ret));
264
if(optget(opts, "Debug")->enabled) {
265
/* enable debug messages in libclamav */
260
270
#if defined(USE_SYSLOG) && !defined(C_AIX)
261
if(optget(opts, "LogSyslog")->enabled) {
262
int fac = LOG_LOCAL6;
264
opt = optget(opts, "LogFacility");
265
if((fac = logg_facility(opt->strarg)) == -1) {
266
logg("!LogFacility: %s: No such facility.\n", opt->strarg);
271
openlog("clamd", LOG_PID, fac);
271
if(optget(opts, "LogSyslog")->enabled) {
272
int fac = LOG_LOCAL6;
274
opt = optget(opts, "LogFacility");
275
if((fac = logg_facility(opt->strarg)) == -1) {
276
logg("!LogFacility: %s: No such facility.\n", opt->strarg);
281
openlog("clamd", LOG_PID, fac);
278
if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
288
if(CLAMSTAT("/proc", &sb) != -1 && !sb.st_size)
282
/* check socket type */
284
if(optget(opts, "TCPSocket")->enabled)
287
if(optget(opts, "LocalSocket")->enabled)
290
if(!tcpsock && !localsock) {
291
logg("!Please define server type (local and/or TCP).\n");
296
logg("#clamd daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version());
292
/* check socket type */
294
if(optget(opts, "TCPSocket")->enabled)
297
if(optget(opts, "LocalSocket")->enabled)
300
if(!tcpsock && !localsock) {
301
logg("!Please define server type (local and/or TCP).\n");
306
logg("#clamd daemon %s (OS: "TARGET_OS_TYPE", ARCH: "TARGET_ARCH_TYPE", CPU: "TARGET_CPU_TYPE")\n", get_version());
300
logg("#Running as user %s (UID %u, GID %u)\n", user->pw_name, user->pw_uid, user->pw_gid);
310
logg("#Running as user %s (UID %u, GID %u)\n", user->pw_name, user->pw_uid, user->pw_gid);
303
313
#if defined(RLIMIT_DATA) && defined(C_BSD)
304
if (getrlimit(RLIMIT_DATA, &rlim) == 0) {
306
* On 32-bit FreeBSD if you set ulimit -d to >2GB then mmap() will fail
307
* too soon (after ~120 MB).
308
* Set limit lower than 2G if on 32-bit */
309
uint64_t lim = rlim.rlim_cur;
310
if (sizeof(void*) == 4 &&
311
lim > (1ULL << 31)) {
312
rlim.rlim_cur = 1ULL << 31;
313
if (setrlimit(RLIMIT_DATA, &rlim) < 0)
314
logg("!setrlimit(RLIMIT_DATA) failed: %s\n", strerror(errno));
316
logg("Running on 32-bit system, and RLIMIT_DATA > 2GB, lowering to 2GB!\n");
314
if (getrlimit(RLIMIT_DATA, &rlim) == 0) {
316
* On 32-bit FreeBSD if you set ulimit -d to >2GB then mmap() will fail
317
* too soon (after ~120 MB).
318
* Set limit lower than 2G if on 32-bit */
319
uint64_t lim = rlim.rlim_cur;
320
if (sizeof(void*) == 4 &&
321
lim > (1ULL << 31)) {
322
rlim.rlim_cur = 1ULL << 31;
323
if (setrlimit(RLIMIT_DATA, &rlim) < 0)
324
logg("!setrlimit(RLIMIT_DATA) failed: %s\n", strerror(errno));
326
logg("Running on 32-bit system, and RLIMIT_DATA > 2GB, lowering to 2GB!\n");
323
logg("#Log file size limited to %u bytes.\n", logg_size);
325
logg("#Log file size limit disabled.\n");
327
min_port = optget(opts, "StreamMinPort")->numarg;
328
max_port = optget(opts, "StreamMaxPort")->numarg;
329
if (min_port < 1024 || min_port > max_port || max_port > 65535) {
330
logg("!Invalid StreamMinPort/StreamMaxPort: %d, %d\n", min_port, max_port);
335
if(!(engine = cl_engine_new())) {
336
logg("!Can't initialize antivirus engine\n");
341
/* load the database(s) */
342
dbdir = optget(opts, "DatabaseDirectory")->strarg;
343
logg("#Reading databases from %s\n", dbdir);
345
if(optget(opts, "DetectPUA")->enabled) {
346
dboptions |= CL_DB_PUA;
348
if((opt = optget(opts, "ExcludePUA"))->enabled) {
349
dboptions |= CL_DB_PUA_EXCLUDE;
351
logg("#Excluded PUA categories:");
353
if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
354
logg("!Can't allocate memory for pua_cats\n");
355
cl_engine_free(engine);
359
logg("# %s", opt->strarg);
360
sprintf(pua_cats + i, ".%s", opt->strarg);
361
i += strlen(opt->strarg) + 1;
372
if((opt = optget(opts, "IncludePUA"))->enabled) {
374
logg("!ExcludePUA and IncludePUA cannot be used at the same time\n");
379
dboptions |= CL_DB_PUA_INCLUDE;
381
logg("#Included PUA categories:");
383
if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
384
logg("!Can't allocate memory for pua_cats\n");
388
logg("# %s", opt->strarg);
389
sprintf(pua_cats + i, ".%s", opt->strarg);
390
i += strlen(opt->strarg) + 1;
402
if((ret = cl_engine_set_str(engine, CL_ENGINE_PUA_CATEGORIES, pua_cats))) {
403
logg("!cli_engine_set_str(CL_ENGINE_PUA_CATEGORIES) failed: %s\n", cl_strerror(ret));
411
logg("#Not loading PUA signatures.\n");
414
if(optget(opts, "OfficialDatabaseOnly")->enabled) {
415
dboptions |= CL_DB_OFFICIAL_ONLY;
416
logg("#Only loading official signatures.\n");
419
/* set the temporary dir */
420
if((opt = optget(opts, "TemporaryDirectory"))->enabled) {
421
if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, opt->strarg))) {
422
logg("!cli_engine_set_str(CL_ENGINE_TMPDIR) failed: %s\n", cl_strerror(ret));
428
cl_engine_set_clcb_hash(engine, hash_callback);
431
if(optget(opts, "LeaveTemporaryFiles")->enabled)
432
cl_engine_set_num(engine, CL_ENGINE_KEEPTMP, 1);
434
if(optget(opts, "ForceToDisk")->enabled)
435
cl_engine_set_num(engine, CL_ENGINE_FORCETODISK, 1);
437
if(optget(opts, "PhishingSignatures")->enabled)
438
dboptions |= CL_DB_PHISHING;
440
logg("#Not loading phishing signatures.\n");
442
if(optget(opts,"Bytecode")->enabled) {
443
dboptions |= CL_DB_BYTECODE;
444
if((opt = optget(opts,"BytecodeSecurity"))->enabled) {
445
enum bytecode_security s;
446
if (!strcmp(opt->strarg, "TrustSigned")) {
447
s = CL_BYTECODE_TRUST_SIGNED;
448
logg("#Bytecode: Security mode set to \"TrustSigned\".\n");
449
} else if (!strcmp(opt->strarg, "Paranoid")) {
450
s = CL_BYTECODE_TRUST_NOTHING;
451
logg("#Bytecode: Security mode set to \"Paranoid\".\n");
453
logg("!Unable to parse bytecode security setting:%s\n",
458
if ((ret = cl_engine_set_num(engine, CL_ENGINE_BYTECODE_SECURITY, s))) {
459
logg("^Invalid bytecode security setting %s: %s\n", opt->strarg, cl_strerror(ret));
464
if((opt = optget(opts,"BytecodeUnsigned"))->enabled) {
465
dboptions |= CL_DB_BYTECODE_UNSIGNED;
466
logg("#Bytecode: Enabled support for unsigned bytecode.\n");
468
if((opt = optget(opts,"BytecodeMode"))->enabled) {
469
enum bytecode_mode mode;
470
if (!strcmp(opt->strarg, "ForceJIT"))
471
mode = CL_BYTECODE_MODE_JIT;
472
else if(!strcmp(opt->strarg, "ForceInterpreter"))
473
mode = CL_BYTECODE_MODE_INTERPRETER;
474
else if(!strcmp(opt->strarg, "Test"))
475
mode = CL_BYTECODE_MODE_TEST;
477
mode = CL_BYTECODE_MODE_AUTO;
478
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_MODE, mode);
480
if((opt = optget(opts,"BytecodeTimeout"))->enabled) {
481
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
484
logg("#Bytecode support disabled.\n");
486
if(optget(opts,"PhishingScanURLs")->enabled)
487
dboptions |= CL_DB_PHISHING_URLS;
489
logg("#Disabling URL based phishing detection.\n");
491
if(optget(opts,"DevACOnly")->enabled) {
492
logg("#Only using the A-C matcher.\n");
493
cl_engine_set_num(engine, CL_ENGINE_AC_ONLY, 1);
496
if((opt = optget(opts, "DevACDepth"))->enabled) {
497
cl_engine_set_num(engine, CL_ENGINE_AC_MAXDEPTH, opt->numarg);
498
logg("#Max A-C depth set to %u\n", (unsigned int) opt->numarg);
501
if((ret = cl_load(dbdir, engine, &sigs, dboptions))) {
502
logg("!%s\n", cl_strerror(ret));
507
if (optget(opts, "DisableCertCheck")->enabled)
508
engine->dconf->pe |= PE_CONF_DISABLECERT;
510
logg("#Loaded %u signatures.\n", sigs);
511
if((ret = cl_engine_compile(engine)) != 0) {
512
logg("!Database initialization error: %s\n", cl_strerror(ret));
518
if ((lsockets[nlsockets] = tcpserver(opts)) == -1) {
333
logg("#Log file size limited to %u bytes.\n", logg_size);
335
logg("#Log file size limit disabled.\n");
337
min_port = optget(opts, "StreamMinPort")->numarg;
338
max_port = optget(opts, "StreamMaxPort")->numarg;
339
if (min_port < 1024 || min_port > max_port || max_port > 65535) {
340
logg("!Invalid StreamMinPort/StreamMaxPort: %d, %d\n", min_port, max_port);
345
if(!(engine = cl_engine_new())) {
346
logg("!Can't initialize antivirus engine\n");
351
if (optget(opts, "disable-cache")->enabled)
352
cl_engine_set_num(engine, CL_ENGINE_DISABLE_CACHE, 1);
354
/* load the database(s) */
355
dbdir = optget(opts, "DatabaseDirectory")->strarg;
356
logg("#Reading databases from %s\n", dbdir);
358
if(optget(opts, "DetectPUA")->enabled) {
359
dboptions |= CL_DB_PUA;
361
if((opt = optget(opts, "ExcludePUA"))->enabled) {
362
dboptions |= CL_DB_PUA_EXCLUDE;
364
logg("#Excluded PUA categories:");
367
if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
368
logg("!Can't allocate memory for pua_cats\n");
369
cl_engine_free(engine);
374
logg("# %s", opt->strarg);
376
sprintf(pua_cats + i, ".%s", opt->strarg);
377
i += strlen(opt->strarg) + 1;
390
if((opt = optget(opts, "IncludePUA"))->enabled) {
392
logg("!ExcludePUA and IncludePUA cannot be used at the same time\n");
398
dboptions |= CL_DB_PUA_INCLUDE;
400
logg("#Included PUA categories:");
402
if(!(pua_cats = realloc(pua_cats, i + strlen(opt->strarg) + 3))) {
403
logg("!Can't allocate memory for pua_cats\n");
408
logg("# %s", opt->strarg);
410
sprintf(pua_cats + i, ".%s", opt->strarg);
411
i += strlen(opt->strarg) + 1;
425
if((ret = cl_engine_set_str(engine, CL_ENGINE_PUA_CATEGORIES, pua_cats))) {
426
logg("!cli_engine_set_str(CL_ENGINE_PUA_CATEGORIES) failed: %s\n", cl_strerror(ret));
434
logg("#Not loading PUA signatures.\n");
437
if (optget(opts, "StatsEnabled")->enabled) {
438
cl_engine_stats_enable(engine);
441
if (optget(opts, "StatsPEDisabled")->enabled) {
442
cl_engine_set_num(engine, CL_ENGINE_DISABLE_PE_STATS, 1);
445
if (optget(opts, "StatsTimeout")->enabled) {
446
cl_engine_set_num(engine, CL_ENGINE_STATS_TIMEOUT, optget(opts, "StatsTimeout")->numarg);
449
if (optget(opts, "StatsHostID")->enabled) {
450
char *p = optget(opts, "StatsHostID")->strarg;
452
if (strcmp(p, "default")) {
453
if (!strcmp(p, "none")) {
454
cl_engine_set_clcb_stats_get_hostid(engine, NULL);
455
} else if (!strcmp(p, "anonymous")) {
456
strcpy(hostid, STATS_ANON_UUID);
458
if (strlen(p) > 36) {
459
logg("!Invalid HostID\n");
460
cl_engine_set_clcb_stats_submit(engine, NULL);
461
cl_engine_free(engine);
469
cl_engine_set_clcb_stats_get_hostid(engine, get_hostid);
473
if(optget(opts, "OfficialDatabaseOnly")->enabled) {
474
dboptions |= CL_DB_OFFICIAL_ONLY;
475
logg("#Only loading official signatures.\n");
478
/* set the temporary dir */
479
if((opt = optget(opts, "TemporaryDirectory"))->enabled) {
480
if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, opt->strarg))) {
481
logg("!cli_engine_set_str(CL_ENGINE_TMPDIR) failed: %s\n", cl_strerror(ret));
487
cl_engine_set_clcb_hash(engine, hash_callback);
489
if(optget(opts, "LeaveTemporaryFiles")->enabled)
490
cl_engine_set_num(engine, CL_ENGINE_KEEPTMP, 1);
492
if(optget(opts, "ForceToDisk")->enabled)
493
cl_engine_set_num(engine, CL_ENGINE_FORCETODISK, 1);
495
if(optget(opts, "PhishingSignatures")->enabled)
496
dboptions |= CL_DB_PHISHING;
498
logg("#Not loading phishing signatures.\n");
500
if(optget(opts,"Bytecode")->enabled) {
501
dboptions |= CL_DB_BYTECODE;
502
if((opt = optget(opts,"BytecodeSecurity"))->enabled) {
503
enum bytecode_security s;
505
if (!strcmp(opt->strarg, "TrustSigned")) {
506
s = CL_BYTECODE_TRUST_SIGNED;
507
logg("#Bytecode: Security mode set to \"TrustSigned\".\n");
508
} else if (!strcmp(opt->strarg, "Paranoid")) {
509
s = CL_BYTECODE_TRUST_NOTHING;
510
logg("#Bytecode: Security mode set to \"Paranoid\".\n");
512
logg("!Unable to parse bytecode security setting:%s\n",
518
if ((ret = cl_engine_set_num(engine, CL_ENGINE_BYTECODE_SECURITY, s))) {
519
logg("^Invalid bytecode security setting %s: %s\n", opt->strarg, cl_strerror(ret));
524
if((opt = optget(opts,"BytecodeUnsigned"))->enabled) {
525
dboptions |= CL_DB_BYTECODE_UNSIGNED;
526
logg("#Bytecode: Enabled support for unsigned bytecode.\n");
529
if((opt = optget(opts,"BytecodeMode"))->enabled) {
530
enum bytecode_mode mode;
532
if (!strcmp(opt->strarg, "ForceJIT"))
533
mode = CL_BYTECODE_MODE_JIT;
534
else if(!strcmp(opt->strarg, "ForceInterpreter"))
535
mode = CL_BYTECODE_MODE_INTERPRETER;
536
else if(!strcmp(opt->strarg, "Test"))
537
mode = CL_BYTECODE_MODE_TEST;
539
mode = CL_BYTECODE_MODE_AUTO;
540
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_MODE, mode);
543
if((opt = optget(opts,"BytecodeTimeout"))->enabled) {
544
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
547
logg("#Bytecode support disabled.\n");
550
if(optget(opts,"PhishingScanURLs")->enabled)
551
dboptions |= CL_DB_PHISHING_URLS;
553
logg("#Disabling URL based phishing detection.\n");
555
if(optget(opts,"DevACOnly")->enabled) {
556
logg("#Only using the A-C matcher.\n");
557
cl_engine_set_num(engine, CL_ENGINE_AC_ONLY, 1);
560
if((opt = optget(opts, "DevACDepth"))->enabled) {
561
cl_engine_set_num(engine, CL_ENGINE_AC_MAXDEPTH, opt->numarg);
562
logg("#Max A-C depth set to %u\n", (unsigned int) opt->numarg);
565
if((ret = cl_load(dbdir, engine, &sigs, dboptions))) {
566
logg("!%s\n", cl_strerror(ret));
571
if (optget(opts, "DisableCertCheck")->enabled)
572
engine->dconf->pe |= PE_CONF_DISABLECERT;
574
logg("#Loaded %u signatures.\n", sigs);
576
if((ret = cl_engine_compile(engine)) != 0) {
577
logg("!Database initialization error: %s\n", cl_strerror(ret));
585
opt = optget(opts, "TCPAddr");
589
while (opt && opt->strarg) {
590
char *ipaddr = (!strcmp(opt->strarg, "all") ? NULL : opt->strarg);
592
if (tcpserver(&lsockets, &nlsockets, ipaddr, opts) == -1) {
604
if (tcpserver(&lsockets, &nlsockets, NULL, opts) == -1) {
526
mode_t sock_mode, umsk = umask(0777); /* socket is created with 000 to avoid races */
527
if ((lsockets[nlsockets] = localserver(opts)) == -1) {
532
umask(umsk); /* restore umask */
533
if(optget(opts, "LocalSocketGroup")->enabled) {
534
char *gname = optget(opts, "LocalSocketGroup")->strarg, *end;
535
gid_t sock_gid = strtol(gname, &end, 10);
537
struct group *pgrp = getgrnam(gname);
539
logg("!Unknown group %s\n", gname);
543
sock_gid = pgrp->gr_gid;
545
if(chown(optget(opts, "LocalSocket")->strarg, -1, sock_gid)) {
546
logg("!Failed to change socket ownership to group %s\n", gname);
551
if(optget(opts, "LocalSocketMode")->enabled) {
553
sock_mode = strtol(optget(opts, "LocalSocketMode")->strarg, &end, 8);
555
logg("!Invalid LocalSocketMode %s\n", optget(opts, "LocalSocketMode")->strarg);
560
sock_mode = 0777 /* & ~umsk*/; /* conservative default: umask was 0 in clamd < 0.96 */
562
if(chmod(optget(opts, "LocalSocket")->strarg, sock_mode & 0666)) {
563
logg("!Cannot set socket permission to %s\n", optget(opts, "LocalSocketMode")->strarg);
571
/* fork into background */
572
if(!optget(opts, "Foreground")->enabled) {
613
mode_t sock_mode, umsk = umask(0777); /* socket is created with 000 to avoid races */
615
t = realloc(lsockets, sizeof(int) * (nlsockets + 1));
622
if ((lsockets[nlsockets] = localserver(opts)) == -1) {
627
umask(umsk); /* restore umask */
629
if(optget(opts, "LocalSocketGroup")->enabled) {
630
char *gname = optget(opts, "LocalSocketGroup")->strarg, *end;
631
gid_t sock_gid = strtol(gname, &end, 10);
634
struct group *pgrp = getgrnam(gname);
637
logg("!Unknown group %s\n", gname);
642
sock_gid = pgrp->gr_gid;
644
if(chown(optget(opts, "LocalSocket")->strarg, -1, sock_gid)) {
645
logg("!Failed to change socket ownership to group %s\n", gname);
650
if(optget(opts, "LocalSocketMode")->enabled) {
653
sock_mode = strtol(optget(opts, "LocalSocketMode")->strarg, &end, 8);
656
logg("!Invalid LocalSocketMode %s\n", optget(opts, "LocalSocketMode")->strarg);
661
sock_mode = 0777 /* & ~umsk*/; /* conservative default: umask was 0 in clamd < 0.96 */
664
if(chmod(optget(opts, "LocalSocket")->strarg, sock_mode & 0666)) {
665
logg("!Cannot set socket permission to %s\n", optget(opts, "LocalSocketMode")->strarg);
673
/* fork into background */
674
if(!optget(opts, "Foreground")->enabled) {
574
/* workaround for OpenBSD bug, see https://wwws.clamav.net/bugzilla/show_bug.cgi?id=885 */
575
for(ret=0;ret<nlsockets;ret++) {
576
if (fcntl(lsockets[ret], F_SETFL, fcntl(lsockets[ret], F_GETFL) | O_NONBLOCK) == -1) {
577
logg("!fcntl for lsockets[] failed\n");
578
close(lsockets[ret]);
676
/* workaround for OpenBSD bug, see https://wwws.clamav.net/bugzilla/show_bug.cgi?id=885 */
677
for(ret=0;ret<nlsockets;ret++) {
678
if (fcntl(lsockets[ret], F_SETFL, fcntl(lsockets[ret], F_GETFL) | O_NONBLOCK) == -1) {
679
logg("!fcntl for lsockets[] failed\n");
680
close(lsockets[ret]);
586
if(daemonize() == -1) {
587
logg("!daemonize() failed: %s\n", strerror(errno));
688
if(daemonize() == -1) {
689
logg("!daemonize() failed: %s\n", strerror(errno));
593
for(ret=0;ret<nlsockets;ret++) {
594
if (fcntl(lsockets[ret], F_SETFL, fcntl(lsockets[ret], F_GETFL) & ~O_NONBLOCK) == -1) {
595
logg("!fcntl for lsockets[] failed\n");
596
close(lsockets[ret]);
695
for(ret=0;ret<nlsockets;ret++) {
696
if (fcntl(lsockets[ret], F_SETFL, fcntl(lsockets[ret], F_GETFL) & ~O_NONBLOCK) == -1) {
697
logg("!fcntl for lsockets[] failed\n");
698
close(lsockets[ret]);
706
logg("^Can't change current working directory to root\n");
713
if (nlsockets == 0) {
714
logg("!Not listening on any interfaces\n");
604
logg("^Can't change current working directory to root\n");
610
ret = recvloop_th(lsockets, nlsockets, engine, dboptions, opts);
719
ret = recvloop_th(lsockets, nlsockets, engine, dboptions, opts);
614
723
logg("*Closing the main socket%s.\n", (nlsockets > 1) ? "s" : "");
616
725
for (i = 0; i < nlsockets; i++) {
617
closesocket(lsockets[i]);
726
closesocket(lsockets[i]);
621
730
if(nlsockets && localsock) {
622
opt = optget(opts, "LocalSocket");
623
if(unlink(opt->strarg) == -1)
624
logg("!Can't unlink the socket file %s\n", opt->strarg);
626
logg("Socket file removed.\n");
731
opt = optget(opts, "LocalSocket");
733
if(unlink(opt->strarg) == -1)
734
logg("!Can't unlink the socket file %s\n", opt->strarg);
736
logg("Socket file removed.\n");
750
int is_valid_hostid(void)
754
if (strlen(hostid) != 36)
758
for (i=0; i < 36; i++)
759
if (hostid[i] == '-')
765
if (hostid[8] != '-' || hostid[13] != '-' || hostid[18] != '-' || hostid[23] != '-')
771
char *get_hostid(void *cbdata)
773
if (!strcmp(hostid, "none"))
776
if (!is_valid_hostid())
777
return strdup(STATS_ANON_UUID);
779
return strdup(hostid);