Lines 138-143
Link Here
|
138 |
# include <seccomp.h> |
138 |
# include <seccomp.h> |
139 |
#endif /* LIBSECCOMP and KERN_SECCOMP */ |
139 |
#endif /* LIBSECCOMP and KERN_SECCOMP */ |
140 |
|
140 |
|
|
|
141 |
#ifdef __FreeBSD_cc_version |
142 |
#include <sys/types.h> |
143 |
#include <sys/sysctl.h> |
144 |
#include <sys/procctl.h> |
145 |
extern char **environ; |
146 |
#endif |
147 |
|
141 |
#ifdef HAVE_DNSREGISTRATION |
148 |
#ifdef HAVE_DNSREGISTRATION |
142 |
# include <dns_sd.h> |
149 |
# include <dns_sd.h> |
143 |
DNSServiceRef mdns; |
150 |
DNSServiceRef mdns; |
Lines 402-407
main(
Link Here
|
402 |
char *argv[] |
409 |
char *argv[] |
403 |
) |
410 |
) |
404 |
{ |
411 |
{ |
|
|
412 |
#ifdef __FreeBSD_cc_version |
413 |
#ifdef _LP64 |
414 |
#define ASLR_ENABLE "kern.elf64.aslr.enable" |
415 |
#define ASLR_STACK_GAP "kern.elf64.aslr.stack_gap" |
416 |
#else |
417 |
#define ASLR_ENABLE "kern.elf32.aslr.enable" |
418 |
#define ASLR_STACK_GAP "kern.elf32.aslr.stack_gap" |
419 |
#endif |
420 |
{ |
421 |
int aslr, stack_gap, aslr_var; |
422 |
size_t aslr_len = sizeof(aslr); |
423 |
size_t stack_gap_len = sizeof(stack_gap); |
424 |
|
425 |
pid_t my_pid = getpid(); |
426 |
|
427 |
if (sysctlbyname(ASLR_ENABLE, &aslr, &aslr_len, NULL, 0) != 0) { |
428 |
msyslog(LOG_ERR,"sysctlbyname aslr failed"); |
429 |
exit(255); |
430 |
} |
431 |
if (sysctlbyname(ASLR_STACK_GAP, &stack_gap, &stack_gap_len, NULL, 0) != 0) { |
432 |
msyslog(LOG_ERR,"sysctlbyname stack gap failed"); |
433 |
exit(254); |
434 |
} |
435 |
if (procctl(P_PID, my_pid, PROC_ASLR_STATUS, &aslr_var) != 0) { |
436 |
msyslog(LOG_ERR,"procctl get aslr status failed"); |
437 |
exit(253); |
438 |
} |
439 |
|
440 |
if ((aslr != 0 && stack_gap != 0 && |
441 |
!(aslr_var & PROC_ASLR_FORCE_DISABLE)) || |
442 |
(aslr_var & PROC_ASLR_FORCE_ENABLE)) { |
443 |
aslr_var = PROC_ASLR_FORCE_DISABLE; |
444 |
if (procctl(P_PID, my_pid, PROC_ASLR_CTL, &aslr_var) != 0) { |
445 |
msyslog(LOG_ERR,"procctl set aslr mode failed"); |
446 |
exit(252); |
447 |
} |
448 |
if (execve(argv[0], argv, environ) != 0) { |
449 |
msyslog(LOG_ERR,"ntpd reload failed"); |
450 |
exit(251); |
451 |
} |
452 |
} |
453 |
} |
454 |
#endif |
405 |
return ntpdmain(argc, argv); |
455 |
return ntpdmain(argc, argv); |
406 |
} |
456 |
} |
407 |
#endif /* !SYS_WINNT */ |
457 |
#endif /* !SYS_WINNT */ |