-/* $OpenBSD: monitor.c,v 1.250 2025/12/16 08:32:50 dtucker Exp $ */
+/* $OpenBSD: monitor.c,v 1.251 2025/12/19 00:56:34 djm Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
(r = sshbuf_put_cstring(m, options.x)) != 0) \
fatal_fr(r, "assemble %s", #x); \
} while (0)
-#define M_CP_STRARRAYOPT(x, nx) do { \
+#define M_CP_STRARRAYOPT(x, nx, clobber) do { \
for (i = 0; i < options.nx; i++) { \
if ((r = sshbuf_put_cstring(m, options.x[i])) != 0) \
fatal_fr(r, "assemble %s", #x); \
-/* $OpenBSD: monitor_wrap.c,v 1.143 2025/10/09 03:23:33 djm Exp $ */
+/* $OpenBSD: monitor_wrap.c,v 1.144 2025/12/19 00:56:34 djm Exp $ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* Copyright 2002 Markus Friedl <markus@openbsd.org>
(r = sshbuf_get_cstring(m, &newopts->x, NULL)) != 0) \
fatal_fr(r, "parse %s", #x); \
} while (0)
-#define M_CP_STRARRAYOPT(x, nx) do { \
+#define M_CP_STRARRAYOPT(x, nx, clobber) do { \
newopts->x = newopts->nx == 0 ? \
NULL : xcalloc(newopts->nx, sizeof(*newopts->x)); \
for (i = 0; i < newopts->nx; i++) { \
/* use the macro hell to clean up too */
#define M_CP_STROPT(x) free(newopts->x)
-#define M_CP_STRARRAYOPT(x, nx) do { \
+#define M_CP_STRARRAYOPT(x, nx, clobber) do { \
for (i = 0; i < newopts->nx; i++) \
free(newopts->x[i]); \
free(newopts->x); \
-/* $OpenBSD: servconf.c,v 1.441 2025/12/19 00:48:04 djm Exp $ */
+/* $OpenBSD: servconf.c,v 1.442 2025/12/19 00:56:34 djm Exp $ */
/*
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
dst->n = xstrdup(src->n); \
} \
} while(0)
-#define M_CP_STRARRAYOPT(s, num_s) do {\
+#define M_CP_STRARRAYOPT(s, num_s, clobber) do {\
u_int i; \
if (src->num_s != 0) { \
for (i = 0; i < dst->num_s; i++) \
dst->s = xcalloc(src->num_s, sizeof(*dst->s)); \
for (i = 0; i < src->num_s; i++) \
dst->s[i] = xstrdup(src->s[i]); \
- dst->num_s = src->num_s; \
+ if (clobber) \
+ dst->num_s = src->num_s; \
} \
} while(0)
-/* $OpenBSD: servconf.h,v 1.172 2025/12/16 08:32:50 dtucker Exp $ */
+/* $OpenBSD: servconf.h,v 1.173 2025/12/19 00:56:34 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
M_CP_STROPT(routing_domain); \
M_CP_STROPT(permit_user_env_allowlist); \
M_CP_STROPT(pam_service_name); \
- M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
- M_CP_STRARRAYOPT(allow_users, num_allow_users); \
- M_CP_STRARRAYOPT(deny_users, num_deny_users); \
- M_CP_STRARRAYOPT(allow_groups, num_allow_groups); \
- M_CP_STRARRAYOPT(deny_groups, num_deny_groups); \
- M_CP_STRARRAYOPT(accept_env, num_accept_env); \
- M_CP_STRARRAYOPT(setenv, num_setenv); \
- M_CP_STRARRAYOPT(auth_methods, num_auth_methods); \
- M_CP_STRARRAYOPT(permitted_opens, num_permitted_opens); \
- M_CP_STRARRAYOPT(permitted_listens, num_permitted_listens); \
- M_CP_STRARRAYOPT(channel_timeouts, num_channel_timeouts); \
- M_CP_STRARRAYOPT(log_verbose, num_log_verbose); \
- M_CP_STRARRAYOPT(subsystem_name, num_subsystems); \
- M_CP_STRARRAYOPT(subsystem_command, num_subsystems); \
- M_CP_STRARRAYOPT(subsystem_args, num_subsystems); \
+ M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files, 1);\
+ M_CP_STRARRAYOPT(allow_users, num_allow_users, 1); \
+ M_CP_STRARRAYOPT(deny_users, num_deny_users, 1); \
+ M_CP_STRARRAYOPT(allow_groups, num_allow_groups, 1); \
+ M_CP_STRARRAYOPT(deny_groups, num_deny_groups, 1); \
+ M_CP_STRARRAYOPT(accept_env, num_accept_env, 1); \
+ M_CP_STRARRAYOPT(setenv, num_setenv, 1); \
+ M_CP_STRARRAYOPT(auth_methods, num_auth_methods, 1); \
+ M_CP_STRARRAYOPT(permitted_opens, num_permitted_opens, 1); \
+ M_CP_STRARRAYOPT(permitted_listens, num_permitted_listens, 1); \
+ M_CP_STRARRAYOPT(channel_timeouts, num_channel_timeouts, 1); \
+ M_CP_STRARRAYOPT(log_verbose, num_log_verbose, 1); \
+ /* Note: don't clobber num_subsystems until all copies */ \
+ M_CP_STRARRAYOPT(subsystem_name, num_subsystems, 0); \
+ M_CP_STRARRAYOPT(subsystem_command, num_subsystems, 0); \
+ M_CP_STRARRAYOPT(subsystem_args, num_subsystems, 1); \
} while (0)
void initialize_server_options(ServerOptions *);