Lines Matching refs:daemon
19 struct daemon *daemon; variable
117 if (daemon->edns_pktsz < PACKETSZ) in main()
118 daemon->edns_pktsz = PACKETSZ; in main()
119 daemon->packet_buff_sz = daemon->edns_pktsz > DNSMASQ_PACKETSZ ? in main()
120 daemon->edns_pktsz : DNSMASQ_PACKETSZ; in main()
121 daemon->packet = safe_malloc(daemon->packet_buff_sz); in main()
124 if (!daemon->lease_file) in main()
126 if (daemon->dhcp) in main()
127 daemon->lease_file = LEASEFILE; in main()
141 if (!(daemon->options & OPT_NOWILD)) in main()
144 daemon->options |= OPT_NOWILD; in main()
149 if (daemon->options & OPT_TFTP) in main()
154 if (daemon->max_logs != 0) in main()
163 if (daemon->dhcp) in main()
176 if (daemon->options & OPT_NOWILD) in main()
178 daemon->listeners = create_bound_listeners(); in main()
180 for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) in main()
184 for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next) in main()
187 prettyprint_addr(&if_tmp->addr, daemon->namebuff); in main()
188 die(_("no interface with address %s"), daemon->namebuff, EC_BADNET); in main()
191 else if ((daemon->port != 0 || (daemon->options & OPT_TFTP)) && in main()
192 !(daemon->listeners = create_wildcard_listeners())) in main()
195 if (daemon->port != 0) in main()
198 if (daemon->options & OPT_DBUS) in main()
202 daemon->dbus = NULL; in main()
203 daemon->watches = NULL; in main()
211 if (daemon->port != 0) in main()
216 if (daemon->dhcp && daemon->lease_change_command && daemon->scriptuser) in main()
218 if ((ent_pw = getpwnam(daemon->scriptuser))) in main()
224 baduser = daemon->scriptuser; in main()
228 if (daemon->username && !(ent_pw = getpwnam(daemon->username))) in main()
229 baduser = daemon->username; in main()
230 else if (daemon->groupname && !(gp = getgrnam(daemon->groupname))) in main()
231 baduser = daemon->groupname; in main()
237 if (!daemon->group_set && !gp) in main()
244 daemon->groupname = gp->gr_name; in main()
283 if (!(daemon->options & OPT_DEBUG)) in main()
296 if (!(daemon->options & OPT_NO_FORK)) in main()
337 if (daemon->runfile) in main()
342 if ((pidfile = fopen(daemon->runfile, "w"))) in main()
367 daemon->helperfd = -1; in main()
369 if (daemon->dhcp && daemon->lease_change_command) in main()
370 daemon->helperfd = create_helper(pipewrite, err_pipe[1], script_uid, script_gid, max_fd); in main()
373 if (!(daemon->options & OPT_DEBUG) && getuid() == 0) in main()
457 if (daemon->options & OPT_DEBUG) in main()
461 if (daemon->port == 0) in main()
463 else if (daemon->cachesize != 0) in main()
464 my_syslog(LOG_INFO, _("started, version %s cachesize %d"), VERSION, daemon->cachesize); in main()
471 if (daemon->options & OPT_DBUS) in main()
473 if (daemon->dbus) in main()
482 daemon->log_file, strerror(log_err)); in main()
487 if (!(daemon->options & OPT_NOWILD)) in main()
488 for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next) in main()
492 if (daemon->port != 0 && (daemon->options & OPT_NO_RESOLV)) in main()
494 if (daemon->resolv_files && !daemon->resolv_files->is_default) in main()
496 daemon->resolv_files = NULL; in main()
497 if (!daemon->servers) in main()
501 if (daemon->max_logs != 0) in main()
502 …my_syslog(LOG_INFO, _("asynchronous logging enabled, queue limit is %d messages"), daemon->max_log… in main()
505 if (daemon->dhcp) in main()
509 for (dhcp_tmp = daemon->dhcp; dhcp_tmp; dhcp_tmp = dhcp_tmp->next) in main()
511 prettyprint_time(daemon->dhcp_buff2, dhcp_tmp->lease_time); in main()
512 strcpy(daemon->dhcp_buff, inet_ntoa(dhcp_tmp->start)); in main()
519 daemon->dhcp_buff, inet_ntoa(dhcp_tmp->end), daemon->dhcp_buff2); in main()
525 if (daemon->options & OPT_TFTP) in main()
533 daemon->tftp_prefix ? _("root is ") : _("enabled"), in main()
534 daemon->tftp_prefix ? daemon->tftp_prefix: "", in main()
535 daemon->options & OPT_TFTP_SECURE ? _("secure mode") : ""); in main()
553 if (daemon->start_tftp_port != 0 && in main()
554 daemon->end_tftp_port - daemon->start_tftp_port + 1 < max_fd) in main()
555 max_fd = daemon->end_tftp_port - daemon->start_tftp_port + 1; in main()
557 if (daemon->tftp_max > max_fd) in main()
559 daemon->tftp_max = max_fd; in main()
562 daemon->tftp_max); in main()
571 if (daemon->port != 0) in main()
599 if (daemon->tftp_trans || in main()
600 ((daemon->options & OPT_DBUS) && !daemon->dbus)) in main()
612 if (daemon->dhcp) in main()
614 FD_SET(daemon->dhcpfd, &rset); in main()
615 bump_maxfd(daemon->dhcpfd, &maxfd); in main()
620 FD_SET(daemon->netlinkfd, &rset); in main()
621 bump_maxfd(daemon->netlinkfd, &maxfd); in main()
633 FD_SET(daemon->helperfd, &wset); in main()
634 bump_maxfd(daemon->helperfd, &maxfd); in main()
658 if (daemon->last_resolv == 0 || in main()
659 difftime(now, daemon->last_resolv) > 1.0 || in main()
660 difftime(now, daemon->last_resolv) < -1.0) in main()
662 daemon->last_resolv = now; in main()
664 if (daemon->port != 0 && !(daemon->options & OPT_NO_POLL)) in main()
672 if (FD_ISSET(daemon->netlinkfd, &rset)) in main()
678 if ((daemon->options & OPT_DBUS) && !daemon->dbus) in main()
683 if (daemon->dbus) in main()
700 if (daemon->dhcp && FD_ISSET(daemon->dhcpfd, &rset)) in main()
704 if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset)) in main()
789 ev->event == EVENT_USER_ERR ? daemon->username : daemon->scriptuser, in fatal_event()
793 die(_("failed to change group-id to %s: %s"), daemon->groupname, EC_MISC); in fatal_event()
796 die(_("failed to open pidfile %s: %s"), daemon->runfile, EC_FILE); in fatal_event()
799 die(_("cannot open %s: %s"), daemon->log_file ? daemon->log_file : "log", EC_FILE); in fatal_event()
814 if (daemon->port != 0 && daemon->resolv_files && (daemon->options & OPT_NO_POLL)) in async_event()
816 reload_servers(daemon->resolv_files->name); in async_event()
825 if (daemon->port != 0) in async_event()
831 if (daemon->dhcp) in async_event()
849 if (daemon->tcp_pids[i] == p) in async_event()
850 daemon->tcp_pids[i] = 0; in async_event()
863 daemon->lease_change_command, strerror(ev.data)); in async_event()
876 if (daemon->log_file != NULL) in async_event()
877 log_reopen(daemon->log_file); in async_event()
883 if (daemon->tcp_pids[i] != 0) in async_event()
884 kill(daemon->tcp_pids[i], SIGALRM); in async_event()
888 if (daemon->helperfd != -1) in async_event()
891 if ((i = fcntl(daemon->helperfd, F_GETFL)) != -1) in async_event()
892 fcntl(daemon->helperfd, F_SETFL, i & ~O_NONBLOCK); in async_event()
896 close(daemon->helperfd); in async_event()
900 if (daemon->lease_stream) in async_event()
901 fclose(daemon->lease_stream); in async_event()
903 if (daemon->runfile) in async_event()
904 unlink(daemon->runfile); in async_event()
920 for (latest = NULL, res = daemon->resolv_files; res; res = res->next) in poll_resolv()
949 if (daemon->options & OPT_RELOAD) in poll_resolv()
966 if (daemon->port != 0) in clear_cache_and_reload()
970 if (daemon->dhcp) in clear_cache_and_reload()
972 if (daemon->options & OPT_ETHERS) in clear_cache_and_reload()
975 dhcp_update_configs(daemon->dhcp_conf); in clear_cache_and_reload()
1046 for (transfer = daemon->tftp_trans; transfer; transfer = transfer->next) in set_dns_listeners()
1055 if (daemon->port != 0) in set_dns_listeners()
1058 for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next) in set_dns_listeners()
1064 if (daemon->port != 0 && !daemon->osport) in set_dns_listeners()
1066 if (daemon->randomsocks[i].refcount != 0) in set_dns_listeners()
1068 FD_SET(daemon->randomsocks[i].fd, set); in set_dns_listeners()
1069 bump_maxfd(daemon->randomsocks[i].fd, maxfdp); in set_dns_listeners()
1072 for (listener = daemon->listeners; listener; listener = listener->next) in set_dns_listeners()
1085 if (daemon->tcp_pids[i] == 0) in set_dns_listeners()
1093 if (tftp <= daemon->tftp_max && listener->tftpfd != -1) in set_dns_listeners()
1111 for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next) in check_dns_listeners()
1115 if (daemon->port != 0 && !daemon->osport) in check_dns_listeners()
1117 if (daemon->randomsocks[i].refcount != 0 && in check_dns_listeners()
1118 FD_ISSET(daemon->randomsocks[i].fd, set)) in check_dns_listeners()
1119 reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now); in check_dns_listeners()
1121 for (listener = daemon->listeners; listener; listener = listener->next) in check_dns_listeners()
1142 if (daemon->options & OPT_NOWILD) in check_dns_listeners()
1157 for (iface = daemon->interfaces; iface; iface = iface->next) in check_dns_listeners()
1168 else if (!(daemon->options & OPT_DEBUG) && (p = fork()) != 0) in check_dns_listeners()
1174 if (daemon->tcp_pids[i] == 0) in check_dns_listeners()
1176 daemon->tcp_pids[i] = p; in check_dns_listeners()
1194 if (!(daemon->options & OPT_DEBUG)) in check_dns_listeners()
1198 for (s = daemon->servers; s; s = s->next) in check_dns_listeners()
1218 for (s = daemon->servers; s; s = s->next) in check_dns_listeners()
1225 if (!(daemon->options & OPT_DEBUG)) in check_dns_listeners()
1280 fd = daemon->dhcp_icmp_fd; in icmp_ping()