The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e1849d9a8db44087f04b3ecb11a4df9c308b08ac
commit e1849d9a8db44087f04b3ecb11a4df9c308b08ac Author: John Baldwin <j...@freebsd.org> AuthorDate: 2025-08-04 19:38:06 +0000 Commit: John Baldwin <j...@freebsd.org> CommitDate: 2025-08-04 19:38:06 +0000 ctld: Use a bool to track if a target uses a private auth_group Sponsored by: Chelsio Communications Pull Request: https://github.com/freebsd/freebsd-src/pull/1794 --- usr.sbin/ctld/conf.cc | 11 ++++++----- usr.sbin/ctld/ctld.hh | 1 + usr.sbin/ctld/login.cc | 11 ++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/usr.sbin/ctld/conf.cc b/usr.sbin/ctld/conf.cc index 10ce75237e35..4354d25147a4 100644 --- a/usr.sbin/ctld/conf.cc +++ b/usr.sbin/ctld/conf.cc @@ -519,7 +519,7 @@ static bool target_use_private_auth(const char *keyword) { if (target->t_auth_group != NULL) { - if (target->t_auth_group->ag_name != NULL) { + if (!target->t_private_auth) { log_warnx("cannot use both auth-group and " "%s for target \"%s\"", keyword, target->t_name); return (false); @@ -528,6 +528,7 @@ target_use_private_auth(const char *keyword) target->t_auth_group = auth_group_new(conf, target); if (target->t_auth_group == NULL) return (false); + target->t_private_auth = true; } return (true); } @@ -644,12 +645,12 @@ bool target_set_auth_group(const char *name) { if (target->t_auth_group != NULL) { - if (target->t_auth_group->ag_name != NULL) - log_warnx("auth-group for target \"%s\" " - "specified more than once", target->t_name); - else + if (target->t_private_auth) log_warnx("cannot use both auth-group and explicit " "authorisations for target \"%s\"", target->t_name); + else + log_warnx("auth-group for target \"%s\" " + "specified more than once", target->t_name); return (false); } target->t_auth_group = auth_group_find(conf, name); diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh index 06b932a65453..fa0b2256f8be 100644 --- a/usr.sbin/ctld/ctld.hh +++ b/usr.sbin/ctld/ctld.hh @@ -195,6 +195,7 @@ struct target { char *t_redirection; /* Name of this target's physical port, if any, i.e. "isp0" */ char *t_pport; + bool t_private_auth; }; struct isns { diff --git a/usr.sbin/ctld/login.cc b/usr.sbin/ctld/login.cc index 549fa0c397ad..a282103e0b62 100644 --- a/usr.sbin/ctld/login.cc +++ b/usr.sbin/ctld/login.cc @@ -990,14 +990,15 @@ login(struct ctld_connection *conn) ag = conn->conn_port->p_auth_group; if (ag == NULL) ag = conn->conn_target->t_auth_group; - if (ag->ag_name != NULL) { + if (conn->conn_port->p_auth_group == NULL && + conn->conn_target->t_private_auth) { log_debugx("initiator requests to connect " - "to target \"%s\"; auth-group \"%s\"", - conn->conn_target->t_name, - ag->ag_name); + "to target \"%s\"", conn->conn_target->t_name); } else { log_debugx("initiator requests to connect " - "to target \"%s\"", conn->conn_target->t_name); + "to target \"%s\"; %s", + conn->conn_target->t_name, + ag->ag_label); } } else { assert(conn->conn_session_type == CONN_SESSION_TYPE_DISCOVERY);