1 / 14

Unix Network Programming Chapter 13: Daemon processes and the inetd superserver

Unix Network Programming Chapter 13: Daemon processes and the inetd superserver. 22.4.2005 Jani Peusaari. Contents. Daemons. Processes without a controlling terminal Generally started via startup scripts with superuser priviliges Perform administrative duties, networked or local services etc

erich-rice
Download Presentation

Unix Network Programming Chapter 13: Daemon processes and the inetd superserver

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix Network ProgrammingChapter 13: Daemon processes and the inetd superserver 22.4.2005 Jani Peusaari

  2. Contents

  3. Daemons • Processes without a controlling terminal • Generally started via startup scripts with superuser priviliges • Perform administrative duties, networked or local services etc • Output using syslog daemon, syslogd

  4. Syslogd daemon • Collects kernel, service and user specific log information to system specific files • Used through UDP socket port 514 • Directly by sending a datagram • syslog function • UDP disabled by default, DoS possibilities

  5. syslog function #include <syslog.h> void syslog(int priority, const char *message, …); • Priority is ORred from level and facility • Second argument is format (as in e.g. printf) with %m, error message (derived from errno) • In addition, openlog and closelog functions

  6. Syslog Levels • Described in RFC 3164 • Seven levels • 0 is the highest, LOG_EMERG • 7 lowest, LOG_DEBUG • Level 5 (LOG_NOTICE) is the default • man syslog

  7. Facilities • LOG_USER is the default • LOG_AUTH for security, LOG_DAEMON for system daemons etc • 8 local messages for user services (e.g. LOG_LOCAL0)

  8. Why syslog • Daemons detach themselves, even if started from the console • No stdin, stdout, stderr • Different levels of output (Debug, notice, warning, emergency) • Collect messages in an uniform way • Portability, no need to know to which file to write messages to

  9. Daemons • SIGHUP

  10. How to make a daemon • Some systems have daemon() function • Fork -> Parent exits • Child becomes session leader • Ignore SIGHUP signal • Fork -> Child 1 exits • Change working directory (/), close file descriptors, std(in|out|err) to /dev/null

  11. Inetd, xinetd • Many inet services (ftp, rlogin, etc) are needed, but are not used often • They all require similar functionality (daemonize, listen to sockets) • Inetd listens to the sockets, forks the service on their behalf • Only one process in the process list

  12. Service types • Multi-threaded • Inetd forks a daemon with a new socket to service the client • Inetd listens to the original socket • Single-threaded • Inetd forks a daemon, and the daemon handles all incoming requests, old or new (Datagram services)

  13. Benefits • Saves system resources, only one process listening to several sockets • Simplifies service creation, as inetd handles lots of common features on their behalf • Centralized access control to all inetd based services (xinetd) • Centralized logging (xinetd) • User services that are not in /etc/services (xinetd)

More Related