freebsd-src/usr.sbin/ctld
Alan Somers 5f89aea7b7 ctld: fix several process setup/teardown bugs
All of the below bugs could result in a system where ctld is not
running, but LUNs and targets still exist in the kernel; a difficult
situation to recover from.

* open the pidfile earlier.  Open the pidfile before reading the
  kernel's current state, so two racing ctld processes won't step on
  each others' toes.

* close the pidfile later.  Close it after tearing down the
  configuration, for the same reason.

* If the configured pidfile changes, then rename it on SIGHUP rather
  than remove and recreate it.

* When running in debug mode, don't close the pidfile while handling a
  new connection.  Only do that in non-debug mode, in the child of the
  fork.

* Register signal handlers earlier.  Otherwise a SIGTERM signal received
  during startup could kill ctld without tearing down the configuration.

MFC after:	2 weeks
PR:		271460
Sponsored by:	Axcient
Reviewed by:	mav
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1370
2024-09-18 14:06:31 -06:00
..
ctl.conf.5 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
ctld.8 Remove $FreeBSD$: two-line nroff pattern 2023-08-16 11:55:10 -06:00
ctld.c ctld: fix several process setup/teardown bugs 2024-09-18 14:06:31 -06:00
ctld.h ctld: parse config file independently of getting kernel info 2024-08-07 08:36:52 -06:00
discovery.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
isns.c ctld: Consistently use item count as the first argument to calloc 2024-07-19 13:07:22 -04:00
isns.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
kernel.c ctld: parse config file independently of getting kernel info 2024-08-07 08:36:52 -06:00
login.c Remove $FreeBSD$: one-line .c pattern 2023-08-16 11:54:42 -06:00
Makefile Remove residual blank line at start of Makefile 2024-07-15 16:43:39 -06:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
parse.y ctld: parse config file independently of getting kernel info 2024-08-07 08:36:52 -06:00
token.l Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
uclparse.c ctld: parse config file independently of getting kernel info 2024-08-07 08:36:52 -06:00