Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions clients/upsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
# define SOLARIS_i386_NBCONNECT_ENOENT(status) ( (!strcmp("i386", CPU_TYPE)) ? (ENOENT == (status)) : 0 )
#else
# define SOLARIS_i386_NBCONNECT_ENOENT(status) (0)
#endif /* end of Solaris/i386 WA for non-blocking connect */
#endif /* end of Solaris/i386 WA for non-blocking connect */

/* WA for AIX bug: non-blocking connect sets errno to 0 */
#if (defined NUT_PLATFORM_AIX)
# define AIX_NBCONNECT_0(status) (0 == (status))
#else
# define AIX_NBCONNECT_0(status) (0)
#endif /* end of AIX WA for non-blocking connect */
#endif /* end of AIX WA for non-blocking connect */

#ifdef WITH_NSS
# include <prerror.h>
Expand All @@ -84,16 +84,16 @@
# include <prtypes.h>
# include <ssl.h>
# include <private/pprio.h>
#endif /* WITH_NSS */
#endif /* WITH_NSS */

#define UPSCLIENT_MAGIC 0x19980308
#define UPSCLIENT_MAGIC 0x19980308

#define SMALLBUF 512

#ifdef SHUT_RDWR
#define shutdown_how SHUT_RDWR
# define shutdown_how SHUT_RDWR
#else
#define shutdown_how 2
# define shutdown_how 2
#endif

static struct {
Expand Down Expand Up @@ -378,30 +378,30 @@ int upscli_init(int certverify, const char *certpath,

#ifdef WITH_OPENSSL

#if OPENSSL_VERSION_NUMBER < 0x10100000L
# if OPENSSL_VERSION_NUMBER < 0x10100000L
SSL_load_error_strings();
SSL_library_init();

ssl_ctx = SSL_CTX_new(SSLv23_client_method());
#else
# else
ssl_ctx = SSL_CTX_new(TLS_client_method());
#endif
# endif

if (!ssl_ctx) {
upslogx(LOG_ERR, "Can not initialize SSL context");
return -1;
}

#if OPENSSL_VERSION_NUMBER < 0x10100000L
# if OPENSSL_VERSION_NUMBER < 0x10100000L
/* set minimum protocol TLSv1 */
SSL_CTX_set_options(ssl_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3);
#else
# else
ret = SSL_CTX_set_min_proto_version(ssl_ctx, TLS1_VERSION);
if (ret != 1) {
upslogx(LOG_ERR, "Can not set minimum protocol to TLSv1");
return -1;
}
#endif
# endif

if (!certpath) {
if (certverify == 1) {
Expand Down Expand Up @@ -681,7 +681,7 @@ static ssize_t net_read(UPSCONN_t *ups, char *buf, size_t buflen, const time_t t

#ifdef WITH_SSL
if (ups->ssl) {
#ifdef WITH_OPENSSL
# ifdef WITH_OPENSSL
/* SSL_* routines deal with int type for return and buflen
* We might need to window our I/O if we exceed 2GB (in
* 32-bit builds)... Not likely to exceed in 64-bit builds,
Expand All @@ -692,20 +692,20 @@ static ssize_t net_read(UPSCONN_t *ups, char *buf, size_t buflen, const time_t t
iret = SSL_read(ups->ssl, buf, (int)buflen);
assert(iret <= SSIZE_MAX);
ret = (ssize_t)iret;
#elif defined(WITH_NSS) /* WITH_OPENSSL */
# elif defined(WITH_NSS) /* WITH_OPENSSL */
/* PR_* routines deal in PRInt32 type
* We might need to window our I/O if we exceed 2GB :) */
assert(buflen <= PR_INT32_MAX);
ret = PR_Read(ups->ssl, buf, (PRInt32)buflen);
#endif /* WITH_OPENSSL | WITH_NSS*/
# endif /* WITH_OPENSSL | WITH_NSS*/

if (ret < 1) {
ups->upserror = UPSCLI_ERR_SSLERR;
}

return ret;
}
#endif
#endif /* WITH_SSL */

ret = upscli_select_read(ups->fd, buf, buflen, timeout, 0);

Expand Down Expand Up @@ -766,7 +766,7 @@ static ssize_t net_write(UPSCONN_t *ups, const char *buf, size_t buflen, const t

#ifdef WITH_SSL
if (ups->ssl) {
#ifdef WITH_OPENSSL
# ifdef WITH_OPENSSL
/* SSL_* routines deal with int type for return and buflen
* We might need to window our I/O if we exceed 2GB (in
* 32-bit builds)... Not likely to exceed in 64-bit builds,
Expand All @@ -777,20 +777,20 @@ static ssize_t net_write(UPSCONN_t *ups, const char *buf, size_t buflen, const t
iret = SSL_write(ups->ssl, buf, (int)buflen);
assert(iret <= SSIZE_MAX);
ret = (ssize_t)iret;
#elif defined(WITH_NSS) /* WITH_OPENSSL */
# elif defined(WITH_NSS) /* WITH_OPENSSL */
/* PR_* routines deal in PRInt32 type
* We might need to window our I/O if we exceed 2GB :) */
assert(buflen <= PR_INT32_MAX);
ret = PR_Write(ups->ssl, buf, (PRInt32)buflen);
#endif /* WITH_OPENSSL | WITH_NSS */
# endif /* WITH_OPENSSL | WITH_NSS */

if (ret < 1) {
ups->upserror = UPSCLI_ERR_SSLERR;
}

return ret;
}
#endif
#endif /* WITH_SSL */

ret = upscli_select_write(ups->fd, buf, buflen, timeout, 0);

Expand Down Expand Up @@ -1820,13 +1820,13 @@ int upscli_disconnect(UPSCONN_t *ups)
SSL_free(ups->ssl);
ups->ssl = NULL;
}
#elif defined(WITH_NSS) /* WITH_OPENSSL */
#elif defined(WITH_NSS) /* !WITH_OPENSSL */
if (ups->ssl) {
PR_Shutdown(ups->ssl, PR_SHUTDOWN_BOTH);
PR_Close(ups->ssl);
ups->ssl = NULL;
}
#endif /* WITH_OPENSSL | WITH_NSS */
#endif /* WITH_OPENSSL | WITH_NSS */

shutdown(ups->fd, shutdown_how);

Expand Down Expand Up @@ -1876,7 +1876,7 @@ int upscli_ssl(UPSCONN_t *ups)
if (ups->ssl) {
return 1;
}
#endif /* WITH_SSL */
#endif /* WITH_SSL */

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion conf/upsd.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
# you can enter the certificate file here.
# The certificates must be in PEM format and must be sorted starting with
# the subject's certificate (server certificate), followed by intermediate
# CA certificates (if applicable_ and the highest level (root) CA. It should
# CA certificates (if applicable) and the highest level (root) CA. It should
# end with the server key. See 'docs/security.txt' or the Security chapter of
# NUT user manual for more information on the SSL support in NUT.
#
Expand Down
3 changes: 2 additions & 1 deletion docs/config-prereqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ variants, e.g. `--with-ssl=nss` vs. `--with-ssl=openssl`
For reproducible runs of various pre-sets of configuration during
development, take a look at `ci_build.sh` script and different `BUILD_TYPE`
(and other) environment variable settings that it supports. A minimal run
with it is just to call the script, e.g.:
with it is just to call the script, possibly using an alternate source
code branch of interest, e.g.:

------
:; mkdir -p nut && cd nut && \
Expand Down
11 changes: 10 additions & 1 deletion docs/download.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,19 @@ link:https://github.com/networkupstools/nut/wiki/Links-to-distribution-packaging
link:https://ci.appveyor.com/project/nut-travis/nut/build/artifacts[Appveyor
CI] -- but it may be difficult to locate specifically the master-branch builds.
See link:https://github.com/networkupstools/nut/wiki/NUT-for-Windows[NUT
for Windows wiki article] for these details, and more.
for Windows wiki article] for these details, and more. These builds are
location-agnostic, you can place their directory trees into any non-UNC
Windows path you deem fit (the built-in `mingw{32,64}` prefix directory
is also not required).
+
The latest release's automated build archive is available here:
link:https://www.networkupstools.org/package/windows/NUT-for-Windows-x86_64-RELEASE-{revision}.7z[NUT-for-Windows-x86_64-RELEASE-{revision}.7z]
+
------
[NOTE]
Windows binaries may be quite large but sparse, so it may be useful to
enable compression on the folder where you have unpacked a NUT tarball.
------

* link:https://www.networkupstools.org/package/windows/NUT-Installer-2.6.5-6.msi[(OBSOLETE) Windows MSI installer 2.6.5-6]

Expand Down
Loading
Loading