Imported Upstream version 2.6.3
This commit is contained in:
parent
45043b58d0
commit
fad6ced6f6
255 changed files with 11081 additions and 4629 deletions
|
|
@ -23,7 +23,7 @@ EXTRA_PROGRAMS = sockdebug
|
|||
|
||||
upsd_SOURCES = upsd.c user.c conf.c ssl.c sstate.c desc.c \
|
||||
netget.c netmisc.c netlist.c netuser.c netset.c netinstcmd.c \
|
||||
conf.h ctype.h desc.h netcmds.h neterr.h netget.h netinstcmd.h \
|
||||
conf.h nut_ctype.h desc.h netcmds.h neterr.h netget.h netinstcmd.h \
|
||||
netlist.h netmisc.h netset.h netuser.h ssl.h sstate.h stype.h upsd.h \
|
||||
upstype.h user-data.h user.h
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
|
|||
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libgd.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libhal.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libltdl.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libneon.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
|
||||
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
|
||||
|
|
@ -131,6 +132,7 @@ CYGPATH_W = @CYGPATH_W@
|
|||
DBLATEX = @DBLATEX@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DOC_BUILD_LIST = @DOC_BUILD_LIST@
|
||||
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
|
||||
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
|
||||
|
|
@ -163,6 +165,8 @@ LIBHAL_CFLAGS = @LIBHAL_CFLAGS@
|
|||
LIBHAL_LIBS = @LIBHAL_LIBS@
|
||||
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
|
||||
LIBIPMI_LIBS = @LIBIPMI_LIBS@
|
||||
LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@
|
||||
LIBLTDL_LIBS = @LIBLTDL_LIBS@
|
||||
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
|
||||
LIBNEON_LIBS = @LIBNEON_LIBS@
|
||||
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
|
||||
|
|
@ -183,6 +187,7 @@ LN_S = @LN_S@
|
|||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NETLIBS = @NETLIBS@
|
||||
NM = @NM@
|
||||
|
|
@ -214,12 +219,14 @@ SHELL = @SHELL@
|
|||
STATEPATH = @STATEPATH@
|
||||
STRIP = @STRIP@
|
||||
SUN_LIBUSB = @SUN_LIBUSB@
|
||||
TREE_VERSION = @TREE_VERSION@
|
||||
VERSION = @VERSION@
|
||||
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
|
|
@ -255,7 +262,6 @@ libdir = @libdir@
|
|||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
|
|
@ -288,7 +294,7 @@ LDADD = ../common/libcommon.la ../common/libparseconf.la $(NETLIBS) \
|
|||
$(am__append_3) $(am__append_4)
|
||||
upsd_SOURCES = upsd.c user.c conf.c ssl.c sstate.c desc.c \
|
||||
netget.c netmisc.c netlist.c netuser.c netset.c netinstcmd.c \
|
||||
conf.h ctype.h desc.h netcmds.h neterr.h netget.h netinstcmd.h \
|
||||
conf.h nut_ctype.h desc.h netcmds.h neterr.h netget.h netinstcmd.h \
|
||||
netlist.h netmisc.h netset.h netuser.h ssl.h sstate.h stype.h upsd.h \
|
||||
upstype.h user-data.h user.h
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "ctype.h"
|
||||
#include "nut_ctype.h"
|
||||
|
||||
#include "ssl.h"
|
||||
#include "netget.h"
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
struct {
|
||||
const char *name;
|
||||
void (*func)(ctype_t *client, int numargs, const char **arg);
|
||||
void (*func)(nut_ctype_t *client, int numargs, const char **arg);
|
||||
int flags;
|
||||
} netcmds[] = {
|
||||
{ "VER", net_ver, 0 },
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "netget.h"
|
||||
|
||||
static void get_numlogins(ctype_t *client, const char *upsname)
|
||||
static void get_numlogins(nut_ctype_t *client, const char *upsname)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ static void get_numlogins(ctype_t *client, const char *upsname)
|
|||
sendback(client, "NUMLOGINS %s %d\n", upsname, ups->numlogins);
|
||||
}
|
||||
|
||||
static void get_upsdesc(ctype_t *client, const char *upsname)
|
||||
static void get_upsdesc(nut_ctype_t *client, const char *upsname)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
char esc[SMALLBUF];
|
||||
|
|
@ -69,7 +69,7 @@ static void get_upsdesc(ctype_t *client, const char *upsname)
|
|||
}
|
||||
}
|
||||
|
||||
static void get_desc(ctype_t *client, const char *upsname, const char *var)
|
||||
static void get_desc(nut_ctype_t *client, const char *upsname, const char *var)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
const char *desc;
|
||||
|
|
@ -92,7 +92,7 @@ static void get_desc(ctype_t *client, const char *upsname, const char *var)
|
|||
sendback(client, "DESC %s %s \"Description unavailable\"\n", upsname, var);
|
||||
}
|
||||
|
||||
static void get_cmddesc(ctype_t *client, const char *upsname, const char *cmd)
|
||||
static void get_cmddesc(nut_ctype_t *client, const char *upsname, const char *cmd)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
const char *desc;
|
||||
|
|
@ -116,7 +116,7 @@ static void get_cmddesc(ctype_t *client, const char *upsname, const char *cmd)
|
|||
upsname, cmd);
|
||||
}
|
||||
|
||||
static void get_type(ctype_t *client, const char *upsname, const char *var)
|
||||
static void get_type(nut_ctype_t *client, const char *upsname, const char *var)
|
||||
{
|
||||
char buf[SMALLBUF];
|
||||
const upstype_t *ups;
|
||||
|
|
@ -159,7 +159,7 @@ static void get_type(ctype_t *client, const char *upsname, const char *var)
|
|||
sendback(client, "TYPE %s %s UNKNOWN\n", upsname, var);
|
||||
}
|
||||
|
||||
static void get_var_server(ctype_t *client, const char *upsname, const char *var)
|
||||
static void get_var_server(nut_ctype_t *client, const char *upsname, const char *var)
|
||||
{
|
||||
if (!strcasecmp(var, "server.info")) {
|
||||
sendback(client, "VAR %s server.info "
|
||||
|
|
@ -178,7 +178,7 @@ static void get_var_server(ctype_t *client, const char *upsname, const char *var
|
|||
send_err(client, NUT_ERR_VAR_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
static void get_var(ctype_t *client, const char *upsname, const char *var)
|
||||
static void get_var(nut_ctype_t *client, const char *upsname, const char *var)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
const char *val;
|
||||
|
|
@ -213,7 +213,7 @@ static void get_var(ctype_t *client, const char *upsname, const char *var)
|
|||
sendback(client, "VAR %s %s \"%s\"\n", upsname, var, val);
|
||||
}
|
||||
|
||||
void net_get(ctype_t *client, int numarg, const char **arg)
|
||||
void net_get(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg < 2) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
void net_get(ctype_t *client, int numarg, const char **arg);
|
||||
void net_get(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "netinstcmd.h"
|
||||
|
||||
static void send_instcmd(ctype_t *client, const char *upsname,
|
||||
static void send_instcmd(nut_ctype_t *client, const char *upsname,
|
||||
const char *cmdname, const char *value)
|
||||
{
|
||||
int found;
|
||||
|
|
@ -95,7 +95,7 @@ static void send_instcmd(ctype_t *client, const char *upsname,
|
|||
sendback(client, "OK\n");
|
||||
}
|
||||
|
||||
void net_instcmd(ctype_t *client, int numarg, const char **arg)
|
||||
void net_instcmd(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg < 2) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
void net_instcmd(ctype_t *client, int numarg, const char **arg);
|
||||
void net_instcmd(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
extern upstype_t *firstups; /* for list_ups */
|
||||
|
||||
static int tree_dump(st_tree_t *node, ctype_t *client, const char *ups,
|
||||
static int tree_dump(st_tree_t *node, nut_ctype_t *client, const char *ups,
|
||||
int rw, int fsd)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -78,7 +78,7 @@ static int tree_dump(st_tree_t *node, ctype_t *client, const char *ups,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void list_rw(ctype_t *client, const char *upsname)
|
||||
static void list_rw(nut_ctype_t *client, const char *upsname)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ static void list_rw(ctype_t *client, const char *upsname)
|
|||
sendback(client, "END LIST RW %s\n", upsname);
|
||||
}
|
||||
|
||||
static void list_var(ctype_t *client, const char *upsname)
|
||||
static void list_var(nut_ctype_t *client, const char *upsname)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ static void list_var(ctype_t *client, const char *upsname)
|
|||
sendback(client, "END LIST VAR %s\n", upsname);
|
||||
}
|
||||
|
||||
static void list_cmd(ctype_t *client, const char *upsname)
|
||||
static void list_cmd(nut_ctype_t *client, const char *upsname)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
cmdlist_t *ctmp;
|
||||
|
|
@ -150,7 +150,7 @@ static void list_cmd(ctype_t *client, const char *upsname)
|
|||
sendback(client, "END LIST CMD %s\n", upsname);
|
||||
}
|
||||
|
||||
static void list_enum(ctype_t *client, const char *upsname, const char *var)
|
||||
static void list_enum(nut_ctype_t *client, const char *upsname, const char *var)
|
||||
{
|
||||
const upstype_t *ups;
|
||||
const st_tree_t *node;
|
||||
|
|
@ -185,7 +185,7 @@ static void list_enum(ctype_t *client, const char *upsname, const char *var)
|
|||
sendback(client, "END LIST ENUM %s %s\n", upsname, var);
|
||||
}
|
||||
|
||||
static void list_ups(ctype_t *client)
|
||||
static void list_ups(nut_ctype_t *client)
|
||||
{
|
||||
upstype_t *utmp;
|
||||
char esc[SMALLBUF];
|
||||
|
|
@ -217,7 +217,7 @@ static void list_ups(ctype_t *client)
|
|||
sendback(client, "END LIST UPS\n");
|
||||
}
|
||||
|
||||
void net_list(ctype_t *client, int numarg, const char **arg)
|
||||
void net_list(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg < 1) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
void net_list(ctype_t *client, int numarg, const char **arg);
|
||||
void net_list(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "netmisc.h"
|
||||
|
||||
void net_ver(ctype_t *client, int numarg, const char **arg)
|
||||
void net_ver(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg != 0) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
@ -38,7 +38,7 @@ void net_ver(ctype_t *client, int numarg, const char **arg)
|
|||
UPS_VERSION);
|
||||
}
|
||||
|
||||
void net_help(ctype_t *client, int numarg, const char **arg)
|
||||
void net_help(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg != 0) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
@ -49,7 +49,7 @@ void net_help(ctype_t *client, int numarg, const char **arg)
|
|||
" USERNAME PASSWORD STARTTLS\n");
|
||||
}
|
||||
|
||||
void net_fsd(ctype_t *client, int numarg, const char **arg)
|
||||
void net_fsd(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
upstype_t *ups;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
void net_ver(ctype_t *client, int numarg, const char **arg);
|
||||
void net_help(ctype_t *client, int numarg, const char **arg);
|
||||
void net_fsd(ctype_t *client, int numarg, const char **arg);
|
||||
void net_ver(nut_ctype_t *client, int numarg, const char **arg);
|
||||
void net_help(nut_ctype_t *client, int numarg, const char **arg);
|
||||
void net_fsd(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "netset.h"
|
||||
|
||||
static void set_var(ctype_t *client, const char *upsname, const char *var,
|
||||
static void set_var(nut_ctype_t *client, const char *upsname, const char *var,
|
||||
const char *newval)
|
||||
{
|
||||
upstype_t *ups;
|
||||
|
|
@ -125,7 +125,7 @@ static void set_var(ctype_t *client, const char *upsname, const char *var,
|
|||
sendback(client, "OK\n");
|
||||
}
|
||||
|
||||
void net_set(ctype_t *client, int numarg, const char **arg)
|
||||
void net_set(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg < 4) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
void net_set(ctype_t *client, int numarg, const char **arg);
|
||||
void net_set(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "netuser.h"
|
||||
|
||||
/* LOGIN <ups> */
|
||||
void net_login(ctype_t *client, int numarg, const char **arg)
|
||||
void net_login(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
upstype_t *ups;
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ void net_login(ctype_t *client, int numarg, const char **arg)
|
|||
sendback(client, "OK\n");
|
||||
}
|
||||
|
||||
void net_logout(ctype_t *client, int numarg, const char **arg)
|
||||
void net_logout(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg != 0) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
@ -83,7 +83,7 @@ void net_logout(ctype_t *client, int numarg, const char **arg)
|
|||
}
|
||||
|
||||
/* MASTER <upsname> */
|
||||
void net_master(ctype_t *client, int numarg, const char **arg)
|
||||
void net_master(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
upstype_t *ups;
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ void net_master(ctype_t *client, int numarg, const char **arg)
|
|||
}
|
||||
|
||||
/* USERNAME <username> */
|
||||
void net_username(ctype_t *client, int numarg, const char **arg)
|
||||
void net_username(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg != 1) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
@ -130,7 +130,7 @@ void net_username(ctype_t *client, int numarg, const char **arg)
|
|||
}
|
||||
|
||||
/* PASSWORD <password> */
|
||||
void net_password(ctype_t *client, int numarg, const char **arg)
|
||||
void net_password(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (numarg != 1) {
|
||||
send_err(client, NUT_ERR_INVALID_ARGUMENT);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
void net_login(ctype_t *client, int numarg, const char **arg);
|
||||
void net_logout(ctype_t *client, int numarg, const char **arg);
|
||||
void net_master(ctype_t *client, int numarg, const char **arg);
|
||||
void net_username(ctype_t *client, int numarg, const char **arg);
|
||||
void net_password(ctype_t *client, int numarg, const char **arg);
|
||||
void net_login(nut_ctype_t *client, int numarg, const char **arg);
|
||||
void net_logout(nut_ctype_t *client, int numarg, const char **arg);
|
||||
void net_master(nut_ctype_t *client, int numarg, const char **arg);
|
||||
void net_username(nut_ctype_t *client, int numarg, const char **arg);
|
||||
void net_password(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
/* ctype.h - client data definitions for upsd
|
||||
/* nut_ctype.h - client data definitions for upsd
|
||||
|
||||
Copyright (C)
|
||||
2002 Russell Kroll <rkroll@exploits.org>
|
||||
2008 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
2011 Arnaud Quette <arnaud.quette@free.fr>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -19,8 +20,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef CTYPE_H_SEEN
|
||||
#define CTYPE_H_SEEN 1
|
||||
#ifndef NUT_CTYPE_H_SEEN
|
||||
#define NUT_CTYPE_H_SEEN 1
|
||||
|
||||
#ifdef HAVE_SSL
|
||||
#include <openssl/err.h>
|
||||
|
|
@ -30,7 +31,7 @@
|
|||
#include "parseconf.h"
|
||||
|
||||
/* client structure */
|
||||
typedef struct ctype_s {
|
||||
typedef struct nut_ctype_s {
|
||||
char *addr;
|
||||
int sock_fd;
|
||||
time_t last_heard;
|
||||
|
|
@ -48,8 +49,8 @@ typedef struct ctype_s {
|
|||
PCONF_CTX_t ctx;
|
||||
|
||||
/* doubly linked list */
|
||||
struct ctype_s *prev;
|
||||
struct ctype_s *next;
|
||||
} ctype_t;
|
||||
struct nut_ctype_s *prev;
|
||||
struct nut_ctype_s *next;
|
||||
} nut_ctype_t;
|
||||
|
||||
#endif /* CTYPE_H_SEEN */
|
||||
#endif /* NUT_CTYPE_H_SEEN */
|
||||
18
server/ssl.c
18
server/ssl.c
|
|
@ -38,19 +38,19 @@ static int ssl_initialized = 0;
|
|||
#ifndef HAVE_SSL
|
||||
|
||||
/* stubs for non-ssl compiles */
|
||||
void net_starttls(ctype_t *client, int numarg, const char **arg)
|
||||
void net_starttls(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
send_err(client, NUT_ERR_FEATURE_NOT_SUPPORTED);
|
||||
return;
|
||||
}
|
||||
|
||||
int ssl_write(ctype_t *client, const char *buf, size_t buflen)
|
||||
int ssl_write(nut_ctype_t *client, const char *buf, size_t buflen)
|
||||
{
|
||||
upslogx(LOG_ERR, "ssl_write called but SSL wasn't compiled in");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ssl_read(ctype_t *client, char *buf, size_t buflen)
|
||||
int ssl_read(nut_ctype_t *client, char *buf, size_t buflen)
|
||||
{
|
||||
upslogx(LOG_ERR, "ssl_read called but SSL wasn't compiled in");
|
||||
return -1;
|
||||
|
|
@ -61,7 +61,7 @@ void ssl_init(void)
|
|||
ssl_initialized = 0; /* keep gcc quiet */
|
||||
}
|
||||
|
||||
void ssl_finish(ctype_t *client)
|
||||
void ssl_finish(nut_ctype_t *client)
|
||||
{
|
||||
if (client->ssl) {
|
||||
upslogx(LOG_ERR, "ssl_finish found active SSL connection but SSL wasn't compiled in");
|
||||
|
|
@ -83,7 +83,7 @@ static void ssl_debug(void)
|
|||
}
|
||||
}
|
||||
|
||||
void net_starttls(ctype_t *client, int numarg, const char **arg)
|
||||
void net_starttls(nut_ctype_t *client, int numarg, const char **arg)
|
||||
{
|
||||
if (client->ssl) {
|
||||
send_err(client, NUT_ERR_ALREADY_SSL_MODE);
|
||||
|
|
@ -196,7 +196,7 @@ static int ssl_error(SSL *ssl, int ret)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int ssl_accept(ctype_t *client)
|
||||
static int ssl_accept(nut_ctype_t *client)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ static int ssl_accept(ctype_t *client)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int ssl_read(ctype_t *client, char *buf, size_t buflen)
|
||||
int ssl_read(nut_ctype_t *client, char *buf, size_t buflen)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
@ -237,7 +237,7 @@ int ssl_read(ctype_t *client, char *buf, size_t buflen)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ssl_write(ctype_t *client, const char *buf, size_t buflen)
|
||||
int ssl_write(nut_ctype_t *client, const char *buf, size_t buflen)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ int ssl_write(ctype_t *client, const char *buf, size_t buflen)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void ssl_finish(ctype_t *client)
|
||||
void ssl_finish(nut_ctype_t *client)
|
||||
{
|
||||
if (client->ssl) {
|
||||
SSL_free(client->ssl);
|
||||
|
|
|
|||
10
server/ssl.h
10
server/ssl.h
|
|
@ -25,16 +25,16 @@
|
|||
#include <openssl/ssl.h>
|
||||
#endif
|
||||
|
||||
#include "ctype.h"
|
||||
#include "nut_ctype.h"
|
||||
|
||||
extern char *certfile;
|
||||
|
||||
void ssl_init(void);
|
||||
void ssl_finish(ctype_t *client);
|
||||
void ssl_finish(nut_ctype_t *client);
|
||||
|
||||
int ssl_read(ctype_t *client, char *buf, size_t buflen);
|
||||
int ssl_write(ctype_t *client, const char *buf, size_t buflen);
|
||||
int ssl_read(nut_ctype_t *client, char *buf, size_t buflen);
|
||||
int ssl_write(nut_ctype_t *client, const char *buf, size_t buflen);
|
||||
|
||||
void net_starttls(ctype_t *client, int numarg, const char **arg);
|
||||
void net_starttls(nut_ctype_t *client, int numarg, const char **arg);
|
||||
|
||||
#endif /* SSL_H_SEEN */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
Copyright (C)
|
||||
1999 Russell Kroll <rkroll@exploits.org>
|
||||
2008 Arjen de Korte <adkorte-guest@alioth.debian.org>
|
||||
2011 Arnaud Quette <arnaud.quette.free.fr>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -32,7 +33,7 @@
|
|||
#include <poll.h>
|
||||
|
||||
#include "user.h"
|
||||
#include "ctype.h"
|
||||
#include "nut_ctype.h"
|
||||
#include "stype.h"
|
||||
#include "ssl.h"
|
||||
#include "sstate.h"
|
||||
|
|
@ -64,8 +65,8 @@ int deny_severity = LOG_WARNING;
|
|||
/* everything else */
|
||||
const char *progname;
|
||||
|
||||
static ctype_t *firstclient = NULL;
|
||||
/* static ctype_t *lastclient = NULL; */
|
||||
static nut_ctype_t *firstclient = NULL;
|
||||
/* static nut_ctype_t *lastclient = NULL; */
|
||||
|
||||
/* default is to listen on all local interfaces */
|
||||
static stype_t *firstaddr = NULL;
|
||||
|
|
@ -234,9 +235,10 @@ static void setuptcp(stype_t *server)
|
|||
|
||||
freeaddrinfo(res);
|
||||
|
||||
/* don't fail silently */
|
||||
/* leave up to the caller, server_load(), to fail silently if there is
|
||||
* no other valid LISTEN interface */
|
||||
if (server->sock_fd < 0) {
|
||||
fatalx(EXIT_FAILURE, "not listening on %s port %s", server->addr, server->port);
|
||||
upslogx(LOG_ERR, "not listening on %s port %s", server->addr, server->port);
|
||||
} else {
|
||||
upslogx(LOG_INFO, "listening on %s port %s", server->addr, server->port);
|
||||
}
|
||||
|
|
@ -264,7 +266,7 @@ static void declogins(const char *upsname)
|
|||
}
|
||||
|
||||
/* disconnect a client connection and free all related memory */
|
||||
static void client_disconnect(ctype_t *client)
|
||||
static void client_disconnect(nut_ctype_t *client)
|
||||
{
|
||||
if (!client) {
|
||||
return;
|
||||
|
|
@ -307,7 +309,7 @@ static void client_disconnect(ctype_t *client)
|
|||
}
|
||||
|
||||
/* send the buffer <sendbuf> of length <sendlen> to host <dest> */
|
||||
int sendback(ctype_t *client, const char *fmt, ...)
|
||||
int sendback(nut_ctype_t *client, const char *fmt, ...)
|
||||
{
|
||||
int res, len;
|
||||
char ans[NUT_NET_ANSWER_MAX+1];
|
||||
|
|
@ -341,7 +343,7 @@ int sendback(ctype_t *client, const char *fmt, ...)
|
|||
}
|
||||
|
||||
/* just a simple wrapper for now */
|
||||
int send_err(ctype_t *client, const char *errtype)
|
||||
int send_err(nut_ctype_t *client, const char *errtype)
|
||||
{
|
||||
if (!client) {
|
||||
return -1;
|
||||
|
|
@ -355,7 +357,7 @@ int send_err(ctype_t *client, const char *errtype)
|
|||
/* disconnect anyone logged into this UPS */
|
||||
void kick_login_clients(const char *upsname)
|
||||
{
|
||||
ctype_t *client, *cnext;
|
||||
nut_ctype_t *client, *cnext;
|
||||
|
||||
for (client = firstclient; client; client = cnext) {
|
||||
|
||||
|
|
@ -374,7 +376,7 @@ void kick_login_clients(const char *upsname)
|
|||
}
|
||||
|
||||
/* make sure a UPS is sane - connected, with fresh data */
|
||||
int ups_available(const upstype_t *ups, ctype_t *client)
|
||||
int ups_available(const upstype_t *ups, nut_ctype_t *client)
|
||||
{
|
||||
if (ups->sock_fd < 0) {
|
||||
send_err(client, NUT_ERR_DRIVER_NOT_CONNECTED);
|
||||
|
|
@ -391,7 +393,7 @@ int ups_available(const upstype_t *ups, ctype_t *client)
|
|||
}
|
||||
|
||||
/* check flags and access for an incoming command from the network */
|
||||
static void check_command(int cmdnum, ctype_t *client, int numarg,
|
||||
static void check_command(int cmdnum, nut_ctype_t *client, int numarg,
|
||||
const char **arg)
|
||||
{
|
||||
if (netcmds[cmdnum].flags & FLAG_USER) {
|
||||
|
|
@ -426,7 +428,7 @@ static void check_command(int cmdnum, ctype_t *client, int numarg,
|
|||
}
|
||||
|
||||
/* parse requests from the network */
|
||||
static void parse_net(ctype_t *client)
|
||||
static void parse_net(nut_ctype_t *client)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -458,7 +460,7 @@ static void client_connect(stype_t *server)
|
|||
socklen_t clen;
|
||||
#endif
|
||||
int fd;
|
||||
ctype_t *client;
|
||||
nut_ctype_t *client;
|
||||
|
||||
clen = sizeof(csock);
|
||||
fd = accept(server->sock_fd, (struct sockaddr *) &csock, &clen);
|
||||
|
|
@ -496,7 +498,7 @@ static void client_connect(stype_t *server)
|
|||
}
|
||||
|
||||
/* read tcp messages and handle them */
|
||||
static void client_readline(ctype_t *client)
|
||||
static void client_readline(nut_ctype_t *client)
|
||||
{
|
||||
char buf[SMALLBUF];
|
||||
int i, ret;
|
||||
|
|
@ -561,6 +563,11 @@ void server_load(void)
|
|||
for (server = firstaddr; server; server = server->next) {
|
||||
setuptcp(server);
|
||||
}
|
||||
|
||||
/* check if we have at least 1 valid LISTEN interface */
|
||||
if (firstaddr->sock_fd < 0) {
|
||||
fatalx(EXIT_FAILURE, "no listening interface available");
|
||||
}
|
||||
}
|
||||
|
||||
void server_free(void)
|
||||
|
|
@ -585,7 +592,7 @@ void server_free(void)
|
|||
|
||||
static void client_free(void)
|
||||
{
|
||||
ctype_t *client, *cnext;
|
||||
nut_ctype_t *client, *cnext;
|
||||
|
||||
/* cleanup client fds */
|
||||
for (client = firstclient; client; client = cnext) {
|
||||
|
|
@ -663,7 +670,7 @@ static void mainloop(void)
|
|||
int i, ret, nfds = 0;
|
||||
|
||||
upstype_t *ups;
|
||||
ctype_t *client, *cnext;
|
||||
nut_ctype_t *client, *cnext;
|
||||
stype_t *server;
|
||||
time_t now;
|
||||
|
||||
|
|
@ -765,7 +772,7 @@ static void mainloop(void)
|
|||
sstate_disconnect((upstype_t *)handler[i].data);
|
||||
break;
|
||||
case CLIENT:
|
||||
client_disconnect((ctype_t *)handler[i].data);
|
||||
client_disconnect((nut_ctype_t *)handler[i].data);
|
||||
break;
|
||||
case SERVER:
|
||||
upsdebugx(2, "%s: server disconnected", __func__);
|
||||
|
|
@ -786,7 +793,7 @@ static void mainloop(void)
|
|||
sstate_readline((upstype_t *)handler[i].data);
|
||||
break;
|
||||
case CLIENT:
|
||||
client_readline((ctype_t *)handler[i].data);
|
||||
client_readline((nut_ctype_t *)handler[i].data);
|
||||
break;
|
||||
case SERVER:
|
||||
client_connect((stype_t *)handler[i].data);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include <sys/file.h>
|
||||
|
||||
#include "parseconf.h"
|
||||
#include "ctype.h"
|
||||
#include "nut_ctype.h"
|
||||
#include "upstype.h"
|
||||
|
||||
#define NUT_NET_ANSWER_MAX SMALLBUF
|
||||
|
|
@ -48,14 +48,14 @@
|
|||
/* prototypes from upsd.c */
|
||||
|
||||
upstype_t *get_ups_ptr(const char *upsname);
|
||||
int ups_available(const upstype_t *ups, ctype_t *client);
|
||||
int ups_available(const upstype_t *ups, nut_ctype_t *client);
|
||||
|
||||
void listen_add(const char *addr, const char *port);
|
||||
|
||||
void kick_login_clients(const char *upsname);
|
||||
int sendback(ctype_t *client, const char *fmt, ...)
|
||||
int sendback(nut_ctype_t *client, const char *fmt, ...)
|
||||
__attribute__ ((__format__ (__printf__, 2, 3)));
|
||||
int send_err(ctype_t *client, const char *errtype);
|
||||
int send_err(nut_ctype_t *client, const char *errtype);
|
||||
|
||||
void server_load(void);
|
||||
void server_free(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue