From: Timo Sirainen Date: Thu, 8 Jun 2023 20:26:03 +0000 (+0300) Subject: lib-ssl-iostream, login-common: Rename ssl_iostream_get_peer_name() to _get_peer_user... X-Git-Tag: 2.4.1~1529 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92420a784831af7e2c921eb91c8fcf07a5ba2db9;p=thirdparty%2Fdovecot%2Fcore.git lib-ssl-iostream, login-common: Rename ssl_iostream_get_peer_name() to _get_peer_username() It's always using the ssl_cert_username_field to get it, so make it explicit. --- diff --git a/src/lib-ssl-iostream/iostream-openssl.c b/src/lib-ssl-iostream/iostream-openssl.c index 8423094853..78c2da093a 100644 --- a/src/lib-ssl-iostream/iostream-openssl.c +++ b/src/lib-ssl-iostream/iostream-openssl.c @@ -821,7 +821,7 @@ openssl_iostream_has_broken_client_cert(struct ssl_iostream *ssl_io) } static const char * -openssl_iostream_get_peer_name(struct ssl_iostream *ssl_io) +openssl_iostream_get_peer_username(struct ssl_iostream *ssl_io) { X509 *x509; char *name; @@ -970,7 +970,7 @@ static const struct iostream_ssl_vfuncs ssl_vfuncs = { .has_valid_client_cert = openssl_iostream_has_valid_client_cert, .has_broken_client_cert = openssl_iostream_has_broken_client_cert, .cert_match_name = openssl_iostream_cert_match_name, - .get_peer_name = openssl_iostream_get_peer_name, + .get_peer_username = openssl_iostream_get_peer_username, .get_server_name = openssl_iostream_get_server_name, .get_compression = openssl_iostream_get_compression, .get_security_string = openssl_iostream_get_security_string, diff --git a/src/lib-ssl-iostream/iostream-ssl-private.h b/src/lib-ssl-iostream/iostream-ssl-private.h index 97f13d4e51..73b39ff5ff 100644 --- a/src/lib-ssl-iostream/iostream-ssl-private.h +++ b/src/lib-ssl-iostream/iostream-ssl-private.h @@ -42,7 +42,7 @@ struct iostream_ssl_vfuncs { bool (*has_broken_client_cert)(struct ssl_iostream *ssl_io); bool (*cert_match_name)(struct ssl_iostream *ssl_io, const char *name, const char **reason_r); - const char *(*get_peer_name)(struct ssl_iostream *ssl_io); + const char *(*get_peer_username)(struct ssl_iostream *ssl_io); const char *(*get_server_name)(struct ssl_iostream *ssl_io); const char *(*get_compression)(struct ssl_iostream *ssl_io); const char *(*get_security_string)(struct ssl_iostream *ssl_io); diff --git a/src/lib-ssl-iostream/iostream-ssl.c b/src/lib-ssl-iostream/iostream-ssl.c index 6a545d3f7f..5b4148653f 100644 --- a/src/lib-ssl-iostream/iostream-ssl.c +++ b/src/lib-ssl-iostream/iostream-ssl.c @@ -244,9 +244,9 @@ int ssl_iostream_check_cert_validity(struct ssl_iostream *ssl_io, return 0; } -const char *ssl_iostream_get_peer_name(struct ssl_iostream *ssl_io) +const char *ssl_iostream_get_peer_username(struct ssl_iostream *ssl_io) { - return ssl_vfuncs->get_peer_name(ssl_io); + return ssl_vfuncs->get_peer_username(ssl_io); } const char *ssl_iostream_get_server_name(struct ssl_iostream *ssl_io) diff --git a/src/lib-ssl-iostream/iostream-ssl.h b/src/lib-ssl-iostream/iostream-ssl.h index cf0e0737de..f5abe60d2c 100644 --- a/src/lib-ssl-iostream/iostream-ssl.h +++ b/src/lib-ssl-iostream/iostream-ssl.h @@ -122,9 +122,10 @@ int ssl_iostream_check_cert_validity(struct ssl_iostream *ssl_io, will always return FALSE before even checking the hostname. */ bool ssl_iostream_cert_match_name(struct ssl_iostream *ssl_io, const char *name, const char **reason_r); -/* Returns name of the peer if available, NULL if not. Usually used to retrieve - username from certificate. */ -const char *ssl_iostream_get_peer_name(struct ssl_iostream *ssl_io); +/* Returns username from the received certificate of the peer (client) if + available, NULL if not. The username is based on cert_username_field + setting. */ +const char *ssl_iostream_get_peer_username(struct ssl_iostream *ssl_io); /* Returns used compression, if any. Returns NULL if not available. */ const char *ssl_iostream_get_compression(struct ssl_iostream *ssl_io); /* Returns TLS extension server_name(0) requested by client, or NULL if not diff --git a/src/login-common/sasl-server.c b/src/login-common/sasl-server.c index efad47c32b..5b221eb26b 100644 --- a/src/login-common/sasl-server.c +++ b/src/login-common/sasl-server.c @@ -444,7 +444,7 @@ get_cert_username(struct client *client, const char **username_r, } /* get peer name */ - const char *username = ssl_iostream_get_peer_name(client->ssl_iostream); + const char *username = ssl_iostream_get_peer_username(client->ssl_iostream); /* if we wanted peer name, but it was not there, fail */ if (client->set->auth_ssl_username_from_cert &&