Skip to content

Commit 8f973d9

Browse files
committed
clients/upsclient.{c,h}, docs/man/upscli_init.txt: introduce upscli_init_authconf() [#3329]
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
1 parent 7374a78 commit 8f973d9

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

clients/upsclient.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,21 @@ int upscli_init(int certverify, const char *certpath,
757757
return upscli_init2(certverify, certpath, certname, certpasswd, NULL);
758758
}
759759

760+
/* NOTE: Maybe eventually these two methods below will invert:
761+
* who is implementation of whom.
762+
* TODO: Consider a method that parses our collection from
763+
* upscli_get_authconf_list() to upscli_add_host_cert() and
764+
* set up the one most applicable set of client identity data
765+
* for that [user@host:port] combo.
766+
*/
767+
int upscli_init_authconf(upscli_autoconf_t *ac)
768+
{
769+
if (!ac)
770+
return -1;
771+
772+
return upscli_init2(ac->certverify, ac->certpath, ac->certident, ac->certpasswd, ac->certfile);
773+
}
774+
760775
int upscli_init2(int certverify, const char *certpath,
761776
const char *certname, const char *certpasswd,
762777
const char *certfile)

clients/upsclient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ struct timeval *upscli_upslog_start_sync(struct timeval *tv, const void *cookie)
152152
* client certificate file. Equivalent to prefer upscli_init2(..., NULL) */
153153
int upscli_init(int certverify, const char *certpath, const char *certname, const char *certpasswd);
154154
int upscli_init2(int certverify, const char *certpath, const char *certname, const char *certpasswd, const char *certfile);
155+
int upscli_init_authconf(upscli_autoconf_t *ac);
155156
int upscli_cleanup(void);
156157

157158
int upscli_tryconnect(UPSCONN_t *ups, const char *host, uint16_t port, int flags, struct timeval *tv);

docs/man/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ INST_MAN_DEV_API_PAGES = \
811811
nutscan_init.$(MAN_SECTION_API)
812812

813813
# Alias page for one text describing two commands:
814-
UPSCLI_INIT_DEPS = upscli_init2.$(MAN_SECTION_API)
814+
UPSCLI_INIT_DEPS = upscli_init2.$(MAN_SECTION_API) upscli_init_authconf.$(MAN_SECTION_API)
815815
$(UPSCLI_INIT_DEPS): upscli_init.$(MAN_SECTION_API)
816816
touch $@
817817

docs/man/upscli_init.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ SYNOPSIS
2626
const char *certname,
2727
const char *certpasswd,
2828
const char *certfile);
29+
30+
int upscli_init_authconf(upscli_autoconf_t *ac);
2931
------
3032

3133
DESCRIPTION
@@ -86,6 +88,10 @@ In both cases, the 'certname' (if not empty) can be used to verify that the
8688
specified file provides a certificate with expected subject name, or possibly
8789
matches the expected host name or IP address.
8890

91+
The *upscli_init_authconf()* function uses the `upscli_autoconf_t` structure
92+
populated by linkman:upscli_read_authconf[3] to pass equivalent information
93+
from linkman:nutauth.conf[5] file(s).
94+
8995
Other nuances
9096
-------------
9197

0 commit comments

Comments
 (0)