Home | History | Annotate | Download | only in src

Lines Matching full:daemon

19 struct daemon *daemon;
117 if (daemon->edns_pktsz < PACKETSZ)
118 daemon->edns_pktsz = PACKETSZ;
119 daemon->packet_buff_sz = daemon->edns_pktsz > DNSMASQ_PACKETSZ ?
120 daemon->edns_pktsz : DNSMASQ_PACKETSZ;
121 daemon->packet = safe_malloc(daemon->packet_buff_sz);
124 if (!daemon->lease_file)
126 if (daemon->dhcp)
127 daemon->lease_file = LEASEFILE;
141 if (!(daemon->options & OPT_NOWILD))
144 daemon->options |= OPT_NOWILD;
149 if (daemon->options & OPT_TFTP)
154 if (daemon->max_logs != 0)
163 if (daemon->dhcp)
176 if (daemon->options & OPT_NOWILD)
178 daemon->listeners = create_bound_listeners();
180 for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
184 for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
187 prettyprint_addr(&if_tmp->addr, daemon->namebuff);
188 die(_("no interface with address %s"), daemon->namebuff, EC_BADNET);
191 else if ((daemon->port != 0 || (daemon->options & OPT_TFTP)) &&
192 !(daemon->listeners = create_wildcard_listeners()))
195 if (daemon->port != 0)
198 if (daemon->options & OPT_DBUS)
202 daemon->dbus = NULL;
203 daemon->watches = NULL;
211 if (daemon->port != 0)
216 if (daemon->dhcp && daemon->lease_change_command && daemon->scriptuser)
218 if ((ent_pw = getpwnam(daemon->scriptuser)))
224 baduser = daemon->scriptuser;
228 if (daemon->username && !(ent_pw = getpwnam(daemon->username)))
229 baduser = daemon->username;
230 else if (daemon->groupname && !(gp = getgrnam(daemon->groupname)))
231 baduser = daemon->groupname;
237 if (!daemon->group_set && !gp)
244 daemon->groupname = gp->gr_name;
273 in a race-free manner and another to carry errors to daemon-invoking process */
283 if (!(daemon->options & OPT_DEBUG))
296 if (!(daemon->options & OPT_NO_FORK))
337 if (daemon->runfile)
342 if ((pidfile = fopen(daemon->runfile, "w")))
367 daemon->helperfd = -1;
369 if (daemon->dhcp && daemon->lease_change_command)
370 daemon->helperfd = create_helper(pipewrite, err_pipe[1], script_uid, script_gid, max_fd);
373 if (!(daemon->options & OPT_DEBUG) && getuid() == 0)
451 if (daemon->options & OPT_DEBUG)
455 if (daemon->port == 0)
457 else if (daemon->cachesize != 0)
458 my_syslog(LOG_INFO, _("started, version %s cachesize %d"), VERSION, daemon->cachesize);
465 if (daemon->options & OPT_DBUS)
467 if (daemon->dbus)
476 daemon->log_file, strerror(log_err));
481 if (!(daemon->options & OPT_NOWILD))
482 for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
486 if (daemon->port != 0 && (daemon->options & OPT_NO_RESOLV))
488 if (daemon->resolv_files && !daemon->resolv_files->is_default)
490 daemon->resolv_files = NULL;
491 if (!daemon->servers)
495 if (daemon->max_logs != 0)
496 my_syslog(LOG_INFO, _("asynchronous logging enabled, queue limit is %d messages"), daemon->max_logs);
499 if (daemon->dhcp)
503 for (dhcp_tmp = daemon->dhcp; dhcp_tmp; dhcp_tmp = dhcp_tmp->next)
505 prettyprint_time(daemon->dhcp_buff2, dhcp_tmp->lease_time);
506 strcpy(daemon->dhcp_buff, inet_ntoa(dhcp_tmp->start));
513 daemon->dhcp_buff, inet_ntoa(dhcp_tmp->end), daemon->dhcp_buff2);
519 if (daemon->options & OPT_TFTP)
527 daemon->tftp_prefix ? _("root is ") : _("enabled"),
528 daemon->tftp_prefix ? daemon->tftp_prefix: "",
529 daemon->options & OPT_TFTP_SECURE ? _("secure mode") : "");
547 if (daemon->start_tftp_port != 0 &&
548 daemon->end_tftp_port - daemon->start_tftp_port + 1 < max_fd)
549 max_fd = daemon->end_tftp_port - daemon->start_tftp_port + 1;
551 if (daemon->tftp_max > max_fd)
553 daemon->tftp_max = max_fd;
556 daemon->tftp_max);
565 if (daemon->port != 0)
593 if (daemon->tftp_trans ||
594 ((daemon->options & OPT_DBUS) && !daemon->dbus))
606 if (daemon->dhcp)
608 FD_SET(daemon
609 bump_maxfd(daemon->dhcpfd, &maxfd);
614 FD_SET(daemon->netlinkfd, &rset);
615 bump_maxfd(daemon->netlinkfd, &maxfd);
627 FD_SET(daemon->helperfd, &wset);
628 bump_maxfd(daemon->helperfd, &maxfd);
652 if (daemon->last_resolv == 0 ||
653 difftime(now, daemon->last_resolv) > 1.0 ||
654 difftime(now, daemon->last_resolv) < -1.0)
656 daemon->last_resolv = now;
658 if (daemon->port != 0 && !(daemon->options & OPT_NO_POLL))
666 if (FD_ISSET(daemon->netlinkfd, &rset))
672 if ((daemon->options & OPT_DBUS) && !daemon->dbus)
677 if (daemon->dbus)
694 if (daemon->dhcp && FD_ISSET(daemon->dhcpfd, &rset))
698 if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset))
783 ev->event == EVENT_USER_ERR ? daemon->username : daemon->scriptuser,
787 die(_("failed to change group-id to %s: %s"), daemon->groupname, EC_MISC);
790 die(_("failed to open pidfile %s: %s"), daemon->runfile, EC_FILE);
793 die(_("cannot open %s: %s"), daemon->log_file ? daemon->log_file : "log", EC_FILE);
808 if (daemon->port != 0 && daemon->resolv_files && (daemon->options & OPT_NO_POLL))
810 reload_servers(daemon->resolv_files->name);
819 if (daemon->port != 0)
825 if (daemon->dhcp)
843 if (daemon->tcp_pids[i] == p)
844 daemon->tcp_pids[i] = 0;
857 daemon->lease_change_command, strerror(ev.data));
870 if (daemon->log_file != NULL)
871 log_reopen(daemon->log_file);
877 if (daemon->tcp_pids[i] != 0)
878 kill(daemon->tcp_pids[i], SIGALRM);
882 if (daemon->helperfd != -1)
885 if ((i = fcntl(daemon->helperfd, F_GETFL)) != -1)
886 fcntl(daemon->helperfd, F_SETFL, i & ~O_NONBLOCK);
890 close(daemon->helperfd);
894 if (daemon->lease_stream)
895 fclose(daemon->lease_stream);
897 if (daemon->runfile)
898 unlink(daemon->runfile);
914 for (latest = NULL, res = daemon->resolv_files; res; res = res->next)
943 if (daemon->options & OPT_RELOAD)
960 if (daemon->port != 0)
964 if (daemon->dhcp)
966 if (daemon->options & OPT_ETHERS)
969 dhcp_update_configs(daemon->dhcp_conf);
1025 for (transfer = daemon->tftp_trans; transfer; transfer = transfer->next)
1034 if (daemon->port != 0)
1037 for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
1043 if (daemon->port != 0 && !daemon->osport)
1045 if (daemon->randomsocks[i].refcount != 0)
1047 FD_SET(daemon->randomsocks[i].fd, set);
1048 bump_maxfd(daemon->randomsocks[i].fd, maxfdp);
1051 for (listener = daemon->listeners; listener; listener = listener->next)
1064 if (daemon->tcp_pids[i] == 0)
1072 if (tftp <= daemon->tftp_max && listener->tftpfd != -1)
1090 for (serverfdp = daemon->sfds; serverfdp; serverfdp = serverfdp->next)
1094 if (daemon->port != 0 && !daemon->osport)
1096 if (daemon->randomsocks[i].refcount != 0 &&
1097 FD_ISSET(daemon->randomsocks[i].fd, set))
1098 reply_query(daemon->randomsocks[i].fd, daemon->randomsocks[i].family, now);
1100 for (listener = daemon->listeners; listener; listener = listener->next)
1121 if (daemon->options & OPT_NOWILD)
1136 for (iface = daemon->interfaces; iface; iface = iface->next)
1147 else if (!(daemon->options & OPT_DEBUG) && (p = fork()) != 0)
1153 if (daemon->tcp_pids[i] == 0)
1155 daemon->tcp_pids[i] = p;
1173 if (!(daemon->options & OPT_DEBUG))
1177 for (s = daemon->servers; s; s = s->next)
1197 for (s = daemon->servers; s; s = s->next)
1204 if (!(daemon->options & OPT_DEBUG))
1259 fd = daemon->dhcp_icmp_fd;