OpenBSD CVS

CVS log for src/usr.sbin/httpd/proc.c


[BACK] Up to [local] / src / usr.sbin / httpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.45 / (download) - annotate - [select for diffs], Tue Apr 9 15:48:01 2024 UTC (8 weeks, 4 days ago) by tobhe
Branch: MAIN
CVS Tags: HEAD
Changes since 1.44: +4 -21 lines
Diff to previous 1.44 (colored)

Sync removal of setsid(), setpgid() and a few dup2() from relayd. They are
redundant since we call daemon() earlier.

ok bluhm@

Revision 1.44 / (download) - annotate - [select for diffs], Mon Apr 8 12:45:18 2024 UTC (2 months ago) by tobhe
Branch: MAIN
Changes since 1.43: +4 -1 lines
Diff to previous 1.43 (colored)

Call daemon() only in parent and before proc_exec() to avoid orphaning child
processes. Synced from relayd.

ok kn@

Revision 1.43 / (download) - annotate - [select for diffs], Wed Jan 17 08:22:40 2024 UTC (4 months, 3 weeks ago) by claudio
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.42: +3 -3 lines
Diff to previous 1.42 (colored)

Convert to use imsg_get_fd() since proc_forward_imsg() never forwards a
file descriptor just use -1 there.
OK tb@

Revision 1.42 / (download) - annotate - [select for diffs], Wed Feb 15 20:44:01 2023 UTC (15 months, 3 weeks ago) by tobhe
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.41: +1 -14 lines
Diff to previous 1.41 (colored)

proc_ispeer() is not used anywhere anymore so remove it everywhere.

ok florian@ bluhm@
ok for vmd mlarkin@

Revision 1.41 / (download) - annotate - [select for diffs], Sat Dec 4 06:52:58 2021 UTC (2 years, 6 months ago) by florian
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.40: +5 -1 lines
Diff to previous 1.40 (colored)

Do not setup pipes between SERVER processes, they don't talk to each
other. Since this generates a full mesh, the amount of filedescriptors
needed grows quadratically with the amount of configured prefork
processes.

Might fix an out of filedescriptor bug that beck is seeing.
OK benno

Revision 1.40 / (download) - annotate - [select for diffs], Tue Apr 20 21:11:56 2021 UTC (3 years, 1 month ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.39: +1 -2 lines
Diff to previous 1.39 (colored)

Move TAILQ initialization to files where they are used.

These priv-sep daemons all follow a similar design and use TAILQs
for tracking control process connections. In most cases, the TAILQs
are initialized separate from where they are used. Since the scope
of use is generally confined to a specific control process file,
this commit also removes any extern definitions and exposing the
TAILQ structures to other compilation units.

ok bluhm@, tb@

Revision 1.39 / (download) - annotate - [select for diffs], Mon Aug 3 10:57:21 2020 UTC (3 years, 10 months ago) by benno
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.38: +2 -2 lines
Diff to previous 1.38 (colored)

remove tautological condition
from Ross L Richardson <openbsd AT rlr DOT id DOT au>, Thanks
ok claudio@

Revision 1.38 / (download) - annotate - [select for diffs], Sun Sep 9 21:06:51 2018 UTC (5 years, 9 months ago) by bluhm
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.37: +16 -5 lines
Diff to previous 1.37 (colored)

During the fork+exec implementation, daemon(3) was moved after
proc_init().  As a consequence httpd(8) and relayd(8) child processes
did not detach from the terminal anymore.  Dup /dev/null to the
stdio file descriptors in the children.
OK benno@

Revision 1.37 / (download) - annotate - [select for diffs], Sun May 28 10:37:26 2017 UTC (7 years ago) by benno
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.36: +5 -5 lines
Diff to previous 1.36 (colored)

use __func__ in log messages.
From Hiltjo Posthuma hiltjo -AT codemadness -DOT- org, thanks!
ok florian, claudio

Revision 1.36 / (download) - annotate - [select for diffs], Tue Jan 17 22:10:55 2017 UTC (7 years, 4 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.35: +2 -2 lines
Diff to previous 1.35 (colored)

Nuke some whitespace that keeps poking me in the eye as I try to
steal code.

Revision 1.35 / (download) - annotate - [select for diffs], Mon Jan 9 14:49:22 2017 UTC (7 years, 5 months ago) by reyk
Branch: MAIN
Changes since 1.34: +2 -2 lines
Diff to previous 1.34 (colored)

Stop accessing verbose and debug variables from log.c directly.

This replaces log_verbose() and "extern int verbose" with the two functions
log_setverbose() and log_getverbose().

Pointed out by benno@
OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)

Revision 1.34 / (download) - annotate - [select for diffs], Wed Oct 12 10:57:30 2016 UTC (7 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.33: +25 -6 lines
Diff to previous 1.33 (colored)

Prevent fd exhaustion in the parent when loading the listening server
sockets by sending the fd one-by-one.  This allows to start httpd with
max 32 server instances and many server sockets without changing the
default rlimits in any way.

OK rzalamena@

Revision 1.33 / (download) - annotate - [select for diffs], Mon Oct 10 21:53:46 2016 UTC (7 years, 7 months ago) by rzalamena
Branch: MAIN
Changes since 1.32: +74 -67 lines
Diff to previous 1.32 (colored)

Modify httpd(8)'s proc.c to use less file descriptors during the daemon
start up. To achieve this proc_init() initiates only the necessary pipes
between child and parent, allocate and distribute fds in proc_connect().

In case of configuration checks ('-n') we do nothing in proc_init() and
proc_connect().

ok reyk@

Revision 1.32 / (download) - annotate - [select for diffs], Mon Oct 10 16:31:35 2016 UTC (7 years, 8 months ago) by rzalamena
Branch: MAIN
Changes since 1.31: +8 -2 lines
Diff to previous 1.31 (colored)

Fix msgbuf_write() usage idiom and modify the treatment for socket close
to exit gracefully instead of fatal()ing.

ok reyk@

Revision 1.31 / (download) - annotate - [select for diffs], Mon Oct 10 11:13:48 2016 UTC (7 years, 8 months ago) by rzalamena
Branch: MAIN
Changes since 1.30: +11 -12 lines
Diff to previous 1.30 (colored)

Add more context to fatal*() messages so it makes easier to debug proc.c
internals.

ok phessler@

Revision 1.30 / (download) - annotate - [select for diffs], Wed Oct 5 17:13:53 2016 UTC (7 years, 8 months ago) by rzalamena
Branch: MAIN
Changes since 1.29: +8 -2 lines
Diff to previous 1.29 (colored)

Check if oldd == newd before dup2(), if that is the case we need to remove
the CLOEXEC flag ourselves.

ok bluhm@, deraadt@

Revision 1.29 / (download) - annotate - [select for diffs], Wed Oct 5 17:09:59 2016 UTC (7 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.28: +5 -1 lines
Diff to previous 1.28 (colored)

Call setsid() to create a new session for the executed processes.

From deraadt@
OK rzalamena@

Revision 1.28 / (download) - annotate - [select for diffs], Wed Oct 5 16:58:19 2016 UTC (7 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.27: +9 -3 lines
Diff to previous 1.27 (colored)

sync proc.c with vmd: add p_pw to specify a non-standard user for a process.

OK rzalamena@

Revision 1.27 / (download) - annotate - [select for diffs], Wed Sep 28 12:01:04 2016 UTC (7 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.26: +2 -3 lines
Diff to previous 1.26 (colored)

sync proc.c from switchd, includes minor cast qual fix and removal of p_env.

Revision 1.26 / (download) - annotate - [select for diffs], Sat Sep 3 14:44:21 2016 UTC (7 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.25: +3 -3 lines
Diff to previous 1.25 (colored)

Replace [RELAY|SERVER]_MAXPROC with the new PROC_MAX_INSTANCES
variable and limit it from 128 to 32 instances (the old value).
While here, move a few PROC_ defines around.

OK rzalamena@

Revision 1.25 / (download) - annotate - [select for diffs], Sat Sep 3 10:02:11 2016 UTC (7 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.24: +2 -4 lines
Diff to previous 1.24 (colored)

Use DPRINTF instead of #ifdef DEBUG + log_debug().

Pointed out by benno@

Revision 1.24 / (download) - annotate - [select for diffs], Fri Sep 2 11:25:14 2016 UTC (7 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.23: +43 -23 lines
Diff to previous 1.23 (colored)

proc.c tweaks: Rename proc_listento() to proc_accept() as it is the
receiving side of proc_connect().  Move some code from main into
proc_init(), the function is now called by parent and children, not
just the parent and it is less copy + paste for other daemons.

OK florian@

Revision 1.23 / (download) - annotate - [select for diffs], Thu Sep 1 14:50:05 2016 UTC (7 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.22: +5 -3 lines
Diff to previous 1.22 (colored)

Don't print "lost child" if the child process exited okay.  This is
the old behaviour and unbreaks the regress tests.

Revision 1.22 / (download) - annotate - [select for diffs], Thu Sep 1 10:59:38 2016 UTC (7 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.21: +3 -2 lines
Diff to previous 1.21 (colored)

spacing

Revision 1.21 / (download) - annotate - [select for diffs], Thu Sep 1 10:57:03 2016 UTC (7 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.20: +6 -4 lines
Diff to previous 1.20 (colored)

Adjust log message, use process title now that it works again

Revision 1.20 / (download) - annotate - [select for diffs], Thu Sep 1 09:47:03 2016 UTC (7 years, 9 months ago) by rzalamena
Branch: MAIN
Changes since 1.19: +271 -160 lines
Diff to previous 1.19 (colored)

Teach httpd/proc.c how to fork+exec.

This commit implemented the basic functions to proc.c to make it not rely
on global variables, malloc()ed memory and CLOEXEC pipes.

Fix child proc titles from reyk@
ok reyk@, florian@

Revision 1.19 / (download) - annotate - [select for diffs], Tue Aug 30 14:31:53 2016 UTC (7 years, 9 months ago) by rzalamena
Branch: MAIN
Changes since 1.18: +2 -3 lines
Diff to previous 1.18 (colored)

Kill (remove) the ps_pid from privsep struct since it is not being used
anymore. Also fix the process initialization prototypes.

ok reyk@

Revision 1.18 / (download) - annotate - [select for diffs], Tue Aug 30 13:46:37 2016 UTC (7 years, 9 months ago) by rzalamena
Branch: MAIN
Changes since 1.17: +24 -10 lines
Diff to previous 1.17 (colored)

Terminate daemon using the socket status instead of watching SIGCHLD or
kill()ing child process.

"Looks good to me" millert@
ok benno@

Revision 1.17 / (download) - annotate - [select for diffs], Sat Aug 27 11:13:16 2016 UTC (7 years, 9 months ago) by rzalamena
Branch: MAIN
Changes since 1.16: +6 -7 lines
Diff to previous 1.16 (colored)

Kill p_instance from proc.c and remove static proc_id unused variables.

To keep the debug functionality intact and correct we'll use the pid
field in the imsg header to pass the instance number. Remember to always
pass 'ps_instance + 1' otherwise libutil will fill imsg header pid field
with the imsgbuf pid (which is the current process pid).

ok reyk@

Revision 1.16 / (download) - annotate - [select for diffs], Fri Aug 26 12:24:21 2016 UTC (7 years, 9 months ago) by rzalamena
Branch: MAIN
Changes since 1.15: +12 -10 lines
Diff to previous 1.15 (colored)

Kill the ps_ninstances from proc.c.

We got the same information in ps_instances[proc] (more accurate) and
we avoid allocating unnecessary memory for pipe storage.

ok reyk@

Revision 1.15 / (download) - annotate - [select for diffs], Mon Dec 7 16:05:56 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.14: +7 -5 lines
Diff to previous 1.14 (colored)

Add imsg "peerid" to debug messages (only within -DDEBUG).

Revision 1.14 / (download) - annotate - [select for diffs], Sat Dec 5 13:15:27 2015 UTC (8 years, 6 months ago) by claudio
Branch: MAIN
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

EAGAIN handling for imsg_read. OK henning@ benno@

Revision 1.13 / (download) - annotate - [select for diffs], Wed Dec 2 15:13:00 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.12: +20 -6 lines
Diff to previous 1.12 (colored)

sync with relayd, use proc_compose()

Revision 1.12 / (download) - annotate - [select for diffs], Mon Nov 23 20:56:14 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.11: +2 -4 lines
Diff to previous 1.11 (colored)

Retire socket_set_blockmode() in favor of the SOCK_NONBLOCK type flag.
As done in iked and snmpd.

OK jung@

Revision 1.11 / (download) - annotate - [select for diffs], Mon Nov 23 16:43:02 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.10: +13 -4 lines
Diff to previous 1.10 (colored)

Sync proc.c with iked.

Revision 1.10 / (download) - annotate - [select for diffs], Sun Nov 22 13:27:13 2015 UTC (8 years, 6 months ago) by reyk
Branch: MAIN
Changes since 1.9: +11 -9 lines
Diff to previous 1.9 (colored)

Update log.c: change fatal() and fatalx() into variadic functions,
include the process name, and replace all calls of fatal*(NULL) with
fatal(__func__) for better debugging.

OK benno@

Revision 1.9 / (download) - annotate - [select for diffs], Thu Aug 20 13:00:23 2015 UTC (8 years, 9 months ago) by reyk
Branch: MAIN
Changes since 1.8: +19 -18 lines
Diff to previous 1.8 (colored)

Change httpd(8) to use C99-style fixed-width integers (uintN_t instead
of u_intN_t) and replace u_int with unsigned int.  Mixing both
variants is a bad style and most contributors seem to prefer this
style; it also helps us to get used to it, portability, and
standardization.

Theoretically no binary change, except one in practice: httpd.o has a
different checksum because gcc with -O2 pads/optimizes "struct
privsep" differently when using "unsigned int" instead "u_int" for the
affected members.  "u_int" is just a typedef of "unsigned int", -O0
doesn't build the difference and clang with -O2 doesn't do it either -
it is just another curiosity from gcc-land.

OK semarie@

Revision 1.8 / (download) - annotate - [select for diffs], Wed Jan 21 22:21:05 2015 UTC (9 years, 4 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.7: +2 -6 lines
Diff to previous 1.7 (colored)

httpd is based on relayd and had included many headers that are only
needed by its ancestor.  jsg@, include-what-you-use, and some manual
review helped to cleanup the headers (take iwyu with a grain of salt).
Based on common practice, httpd.h now also includes the necessary
headers for itself.

OK florian@

Revision 1.7 / (download) - annotate - [select for diffs], Sun Dec 21 00:54:49 2014 UTC (9 years, 5 months ago) by guenther
Branch: MAIN
Changes since 1.6: +1 -2 lines
Diff to previous 1.6 (colored)

Stop pulling in <arpa/inet.h> or <arpa/nameser.h> when unnecessary.
*Do* pull it in when in_{port,addr}_h is needed and <netinet/in.h> isn't.

ok reyk@

Revision 1.6 / (download) - annotate - [select for diffs], Tue Dec 16 03:35:49 2014 UTC (9 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored)

Replace setpgrp(0, getpid()) with setpgid(0, 0).  OK deraadt@ tedu@

Revision 1.5 / (download) - annotate - [select for diffs], Sat Oct 25 03:23:49 2014 UTC (9 years, 7 months ago) by lteo
Branch: MAIN
Changes since 1.4: +1 -2 lines
Diff to previous 1.4 (colored)

Remove unnecessary netinet/in_systm.h include.

ok millert@

Revision 1.4 / (download) - annotate - [select for diffs], Mon Aug 4 15:49:28 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.3: +4 -1 lines
Diff to previous 1.3 (colored)

Add initial support for log files in /var/www/logs/.  Logging with
syslog is still supported but disabled by default.

ok deraadt@

Revision 1.3 / (download) - annotate - [select for diffs], Mon Aug 4 11:09:25 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.2: +1 -3 lines
Diff to previous 1.2 (colored)

httpd doesn't support SSL/TLS yet, remove the remaining bits.
The secrect plan is to add it later using the ressl wrapper library.

Revision 1.2 / (download) - annotate - [select for diffs], Mon Aug 4 06:35:10 2014 UTC (9 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.1: +2 -2 lines
Diff to previous 1.1 (colored)

whitespace

Revision 1.1 / (download) - annotate - [select for diffs], Sat Jul 12 23:34:54 2014 UTC (9 years, 10 months ago) by reyk
Branch: MAIN

Add httpd(8), an attempt to turn the relayd(8) codebase into a simple
web server.  It is not finished yet and I just started it today, but
the goal is to provide an HTTP server that a) provides minimal
features, b) serves static files, c) provides FastCGI support, and d)
follows common coding practices of OpenBSD.

It will neither support plugins, nor custom memory allocators, EBCDIC
support, PCRE or any other things that can be found elsewhere.
httpd(8) is not intended to provide a fully-featured replacement for
nginx(8) or the Apache, but it will provide enough functionality that
is needed in the OpenBSD base system.

ok deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.