From: dv Date: Tue, 20 Apr 2021 21:11:56 +0000 (+0000) Subject: Move TAILQ initialization to files where they are used. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c5fa57f5fbfbc33fa4adf7b5fe3c690a2e0d2e27;p=openbsd 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@ --- diff --git a/sbin/iked/control.c b/sbin/iked/control.c index 4328f5a0208..17b72805de0 100644 --- a/sbin/iked/control.c +++ b/sbin/iked/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.30 2020/10/09 08:59:15 tobhe Exp $ */ +/* $OpenBSD: control.c,v 1.31 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -35,7 +35,7 @@ #define CONTROL_BACKLOG 5 -struct ctl_connlist ctl_conns; +struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns); void control_accept(int, short, void *); diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h index a58b08f9488..06c566d1dc2 100644 --- a/sbin/iked/iked.h +++ b/sbin/iked/iked.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iked.h,v 1.189 2021/03/05 22:26:04 tobhe Exp $ */ +/* $OpenBSD: iked.h,v 1.190 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2019 Tobias Heider @@ -97,7 +97,6 @@ struct ctl_conn { struct imsgev iev; }; TAILQ_HEAD(ctl_connlist, ctl_conn); -extern struct ctl_connlist ctl_conns; extern enum privsep_procid privsep_process; diff --git a/sbin/iked/proc.c b/sbin/iked/proc.c index ad89aa82e13..076fec43ade 100644 --- a/sbin/iked/proc.c +++ b/sbin/iked/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.34 2021/01/28 01:20:37 mortimer Exp $ */ +/* $OpenBSD: proc.c,v 1.35 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010 - 2014 Reyk Floeter @@ -431,7 +431,6 @@ proc_run(struct privsep *ps, struct privsep_proc *p, proc_listen(ps, procs, nproc); if (p->p_id == PROC_CONTROL && ps->ps_instance == 0) { - TAILQ_INIT(&ctl_conns); if (control_listen(&ps->ps_csock) == -1) fatalx(__func__); TAILQ_FOREACH(rcs, &ps->ps_rcsocks, cs_entry) diff --git a/usr.sbin/httpd/control.c b/usr.sbin/httpd/control.c index 7eea19a21d6..d282a85a316 100644 --- a/usr.sbin/httpd/control.c +++ b/usr.sbin/httpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.13 2017/01/09 14:49:22 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.14 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -34,7 +34,7 @@ #define CONTROL_BACKLOG 5 -struct ctl_connlist ctl_conns; +struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns); void control_accept(int, short, void *); void control_close(int, struct control_sock *); diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 39b10893588..b3a40b3af68 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.155 2021/04/10 10:10:07 claudio Exp $ */ +/* $OpenBSD: httpd.h,v 1.156 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -613,8 +613,6 @@ void control_imsg_forward(struct privsep *, struct imsg *); struct ctl_conn * control_connbyfd(int); -extern struct ctl_connlist ctl_conns; - /* parse.y */ int parse_config(const char *, struct httpd *); int load_config(const char *, struct httpd *); diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c index f1ac469f0d9..2444d50b55c 100644 --- a/usr.sbin/httpd/proc.c +++ b/usr.sbin/httpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.39 2020/08/03 10:57:21 benno Exp $ */ +/* $OpenBSD: proc.c,v 1.40 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -588,7 +588,6 @@ proc_run(struct privsep *ps, struct privsep_proc *p, proc_setup(ps, procs, nproc); proc_accept(ps, PROC_PARENT_SOCK_FILENO, PROC_PARENT, 0); if (p->p_id == PROC_CONTROL && ps->ps_instance == 0) { - TAILQ_INIT(&ctl_conns); if (control_listen(&ps->ps_csock) == -1) fatalx("%s: control_listen", __func__); TAILQ_FOREACH(rcs, &ps->ps_rcsocks, cs_entry) diff --git a/usr.sbin/ldapd/control.c b/usr.sbin/ldapd/control.c index fa48e1be862..ffeb80bf4c3 100644 --- a/usr.sbin/ldapd/control.c +++ b/usr.sbin/ldapd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.16 2018/05/15 11:19:21 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.17 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010 Martin Hedenfalk @@ -39,7 +39,7 @@ #define CONTROL_BACKLOG 5 -struct ctl_connlist ctl_conns; +struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns); struct ctl_conn *control_connbyfd(int); void control_close(int, struct control_sock *); diff --git a/usr.sbin/ldapd/ldapd.h b/usr.sbin/ldapd/ldapd.h index 257995e3b56..0f9988d7fac 100644 --- a/usr.sbin/ldapd/ldapd.h +++ b/usr.sbin/ldapd/ldapd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapd.h,v 1.34 2021/01/27 07:21:54 deraadt Exp $ */ +/* $OpenBSD: ldapd.h,v 1.35 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk @@ -229,7 +229,7 @@ struct conn { struct buffertls buftls; unsigned int s_flags; }; -extern TAILQ_HEAD(conn_list, conn) conn_list; +TAILQ_HEAD(conn_list, conn); struct ssl { SPLAY_ENTRY(ssl) ssl_nodes; @@ -316,8 +316,6 @@ struct ctl_conn { struct imsgev iev; }; TAILQ_HEAD(ctl_connlist, ctl_conn); -extern struct ctl_connlist ctl_conns; - struct control_sock { const char *cs_name; diff --git a/usr.sbin/ldapd/ldape.c b/usr.sbin/ldapd/ldape.c index 7756534a5db..4a716b9f9b0 100644 --- a/usr.sbin/ldapd/ldape.c +++ b/usr.sbin/ldapd/ldape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldape.c,v 1.33 2019/10/26 17:52:55 martijn Exp $ */ +/* $OpenBSD: ldape.c,v 1.34 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk @@ -373,7 +373,6 @@ ldape(int debug, int verbose, char *csockpath) csock.cs_name = csockpath; control_init(&csock); control_listen(&csock); - TAILQ_INIT(&ctl_conns); /* Initialize LDAP listeners. */ diff --git a/usr.sbin/relayd/control.c b/usr.sbin/relayd/control.c index 85a6f65ab25..b02cef71374 100644 --- a/usr.sbin/relayd/control.c +++ b/usr.sbin/relayd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.56 2017/01/09 14:49:21 reyk Exp $ */ +/* $OpenBSD: control.c,v 1.57 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -34,7 +34,7 @@ #define CONTROL_BACKLOG 5 -struct ctl_connlist ctl_conns; +struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns); void control_accept(int, short, void *); void control_close(int, struct control_sock *); diff --git a/usr.sbin/relayd/proc.c b/usr.sbin/relayd/proc.c index 55083dc29dd..1b26a5ed466 100644 --- a/usr.sbin/relayd/proc.c +++ b/usr.sbin/relayd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.40 2018/09/09 21:06:51 bluhm Exp $ */ +/* $OpenBSD: proc.c,v 1.41 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -588,7 +588,6 @@ proc_run(struct privsep *ps, struct privsep_proc *p, proc_setup(ps, procs, nproc); proc_accept(ps, PROC_PARENT_SOCK_FILENO, PROC_PARENT, 0); if (p->p_id == PROC_CONTROL && ps->ps_instance == 0) { - TAILQ_INIT(&ctl_conns); if (control_listen(&ps->ps_csock) == -1) fatalx("%s: control_listen", __func__); TAILQ_FOREACH(rcs, &ps->ps_rcsocks, cs_entry) diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 27a2d374e5e..d83ec825aa2 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.266 2021/03/23 16:34:31 claudio Exp $ */ +/* $OpenBSD: relayd.h,v 1.267 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2006 - 2016 Reyk Floeter @@ -1157,8 +1157,6 @@ void control_imsg_forward(struct privsep *ps, struct imsg *); struct ctl_conn * control_connbyfd(int); -extern struct ctl_connlist ctl_conns; - /* parse.y */ int parse_config(const char *, struct relayd *); int load_config(const char *, struct relayd *); diff --git a/usr.sbin/switchd/control.c b/usr.sbin/switchd/control.c index 1d12bcaa09c..50ceb10b459 100644 --- a/usr.sbin/switchd/control.c +++ b/usr.sbin/switchd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.9 2018/08/05 08:16:24 mestre Exp $ */ +/* $OpenBSD: control.c,v 1.10 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010-2016 Reyk Floeter @@ -39,7 +39,7 @@ #define CONTROL_BACKLOG 5 -struct ctl_connlist ctl_conns; +struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns); void control_accept(int, short, void *); diff --git a/usr.sbin/switchd/proc.c b/usr.sbin/switchd/proc.c index 3e1b1752d59..6f6a87f5095 100644 --- a/usr.sbin/switchd/proc.c +++ b/usr.sbin/switchd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.14 2018/09/10 13:21:39 akoshibe Exp $ */ +/* $OpenBSD: proc.c,v 1.15 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -585,7 +585,6 @@ proc_run(struct privsep *ps, struct privsep_proc *p, proc_setup(ps, procs, nproc); proc_accept(ps, PROC_PARENT_SOCK_FILENO, PROC_PARENT, 0); if (p->p_id == PROC_CONTROL && ps->ps_instance == 0) { - TAILQ_INIT(&ctl_conns); if (control_listen(&ps->ps_csock) == -1) fatalx("%s: control_listen", __func__); TAILQ_FOREACH(rcs, &ps->ps_rcsocks, cs_entry) diff --git a/usr.sbin/switchd/proc.h b/usr.sbin/switchd/proc.h index 37a1466a929..b79c51e9bfb 100644 --- a/usr.sbin/switchd/proc.h +++ b/usr.sbin/switchd/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.8 2018/09/10 13:21:39 akoshibe Exp $ */ +/* $OpenBSD: proc.h,v 1.9 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter @@ -123,7 +123,6 @@ struct ctl_conn { int restricted; }; TAILQ_HEAD(ctl_connlist, ctl_conn); -extern struct ctl_connlist ctl_conns; /* proc.c */ void proc_init(struct privsep *, struct privsep_proc *, unsigned int, int, diff --git a/usr.sbin/vmd/control.c b/usr.sbin/vmd/control.c index 50139daf9d3..d6b266ee7fd 100644 --- a/usr.sbin/vmd/control.c +++ b/usr.sbin/vmd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.33 2021/04/11 18:53:23 dv Exp $ */ +/* $OpenBSD: control.c,v 1.34 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter @@ -39,7 +39,7 @@ #define CONTROL_BACKLOG 5 -struct ctl_connlist ctl_conns; +struct ctl_connlist ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns); void control_accept(int, short, void *); diff --git a/usr.sbin/vmd/proc.c b/usr.sbin/vmd/proc.c index fde98994bc1..f1152107e0d 100644 --- a/usr.sbin/vmd/proc.c +++ b/usr.sbin/vmd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.18 2018/09/10 10:36:01 bluhm Exp $ */ +/* $OpenBSD: proc.c,v 1.19 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -585,7 +585,6 @@ proc_run(struct privsep *ps, struct privsep_proc *p, proc_setup(ps, procs, nproc); proc_accept(ps, PROC_PARENT_SOCK_FILENO, PROC_PARENT, 0); if (p->p_id == PROC_CONTROL && ps->ps_instance == 0) { - TAILQ_INIT(&ctl_conns); if (control_listen(&ps->ps_csock) == -1) fatalx("%s: control_listen", __func__); TAILQ_FOREACH(rcs, &ps->ps_rcsocks, cs_entry) diff --git a/usr.sbin/vmd/proc.h b/usr.sbin/vmd/proc.h index 454d5b07276..2e49694a5ff 100644 --- a/usr.sbin/vmd/proc.h +++ b/usr.sbin/vmd/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.18 2021/04/11 18:53:23 dv Exp $ */ +/* $OpenBSD: proc.h,v 1.19 2021/04/20 21:11:56 dv Exp $ */ /* * Copyright (c) 2010-2015 Reyk Floeter @@ -74,7 +74,6 @@ struct ctl_conn { struct sockpeercred peercred; }; TAILQ_HEAD(ctl_connlist, ctl_conn); -extern struct ctl_connlist ctl_conns; /* privsep */ enum privsep_procid {