Rename sudo_parse_host_port -> iolog_parse_host_port and mv to lib/iolog
It is not used outside of the I/O log client and server and the host:port syntax may change in the future.
This commit is contained in:
4
MANIFEST
4
MANIFEST
@@ -102,12 +102,14 @@ include/sudo_rand.h
|
||||
include/sudo_util.h
|
||||
install-sh
|
||||
lib/iolog/Makefile.in
|
||||
lib/iolog/host_port.c
|
||||
lib/iolog/hostcheck.c
|
||||
lib/iolog/iolog_fileio.c
|
||||
lib/iolog/iolog_json.c
|
||||
lib/iolog/iolog_json.h
|
||||
lib/iolog/iolog_path.c
|
||||
lib/iolog/iolog_util.c
|
||||
lib/iolog/regress/host_port/host_port_test.c
|
||||
lib/iolog/regress/iolog_json/check_iolog_json.c
|
||||
lib/iolog/regress/iolog_json/test1.in
|
||||
lib/iolog/regress/iolog_json/test2.in
|
||||
@@ -150,7 +152,6 @@ lib/util/gettime.c
|
||||
lib/util/getusershell.c
|
||||
lib/util/gidlist.c
|
||||
lib/util/glob.c
|
||||
lib/util/host_port.c
|
||||
lib/util/inet_ntop.c
|
||||
lib/util/inet_pton.c
|
||||
lib/util/isblank.c
|
||||
@@ -182,7 +183,6 @@ lib/util/regress/getgrouplist/getgrouplist_test.c
|
||||
lib/util/regress/glob/files
|
||||
lib/util/regress/glob/globtest.c
|
||||
lib/util/regress/glob/globtest.in
|
||||
lib/util/regress/host_port/host_port_test.c
|
||||
lib/util/regress/mktemp/mktemp_test.c
|
||||
lib/util/regress/parse_gids/parse_gids_test.c
|
||||
lib/util/regress/progname/progname_test.c
|
||||
|
@@ -107,6 +107,9 @@ struct iolog_path_escape {
|
||||
size_t (*copy_fn)(char *, size_t, void *);
|
||||
};
|
||||
|
||||
/* host_port.c */
|
||||
bool iolog_parse_host_port(char *str, char **hostp, char **portp, bool *tlsp, char *defport, char *defport_tls);
|
||||
|
||||
/* iolog_path.c */
|
||||
bool expand_iolog_path(const char *inpath, char *path, size_t pathlen, const struct iolog_path_escape *escapes, void *closure);
|
||||
|
||||
|
@@ -207,10 +207,6 @@ __dso_public int sudo_parse_gids_v1(const char *gidstr, const gid_t *basegid, GE
|
||||
__dso_public int sudo_getgrouplist2_v1(const char *name, gid_t basegid, GETGROUPS_T **groupsp, int *ngroupsp);
|
||||
#define sudo_getgrouplist2(_a, _b, _c, _d) sudo_getgrouplist2_v1((_a), (_b), (_c), (_d))
|
||||
|
||||
/* host_port.c */
|
||||
__dso_public bool sudo_parse_host_port_v1(char *str, char **hostp, char **portp, bool *tlsp, char *defport, char *defport_tls);
|
||||
#define sudo_parse_host_port(_a, _b, _c, _d, _e, _f) sudo_parse_host_port_v1((_a), (_b), (_c), (_d), (_e), (_f))
|
||||
|
||||
/* key_val.c */
|
||||
__dso_public char *sudo_new_key_val_v1(const char *key, const char *value);
|
||||
#define sudo_new_key_val(_a, _b) sudo_new_key_val_v1((_a), (_b))
|
||||
|
@@ -75,7 +75,7 @@ PVS_IGNORE = 'V707,V011,V002,V536'
|
||||
PVS_LOG_OPTS = -a 'GA:1,2' -e -t errorfile -d $(PVS_IGNORE)
|
||||
|
||||
# Regression tests
|
||||
TEST_PROGS = check_iolog_json check_iolog_path check_iolog_util
|
||||
TEST_PROGS = check_iolog_json check_iolog_path check_iolog_util host_port_test
|
||||
TEST_LIBS = @LIBS@
|
||||
TEST_LDFLAGS = @LDFLAGS@
|
||||
|
||||
@@ -87,7 +87,7 @@ DEVEL = @DEVEL@
|
||||
SHELL = @SHELL@
|
||||
|
||||
LIBIOLOG_OBJS = iolog_fileio.lo iolog_json.lo iolog_path.lo iolog_util.lo \
|
||||
hostcheck.lo
|
||||
host_port.lo hostcheck.lo
|
||||
|
||||
IOBJS = $(LIBIOLOG_OBJS:.lo=.i)
|
||||
|
||||
@@ -99,6 +99,8 @@ CHECK_IOLOG_UTIL_OBJS = check_iolog_util.lo iolog_json.lo iolog_util.lo
|
||||
|
||||
CHECK_IOLOG_JSON_OBJS = check_iolog_json.lo iolog_json.lo
|
||||
|
||||
HOST_PORT_TEST_OBJS = host_port_test.lo host_port.lo
|
||||
|
||||
all: libsudo_iolog.la
|
||||
|
||||
pvs-log-files: $(POBJS)
|
||||
@@ -137,6 +139,9 @@ check_iolog_util: $(CHECK_IOLOG_UTIL_OBJS) libsudo_iolog.la
|
||||
check_iolog_json: $(CHECK_IOLOG_JSON_OBJS) libsudo_iolog.la
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(CHECK_IOLOG_JSON_OBJS) libsudo_iolog.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
|
||||
|
||||
host_port_test: $(HOST_PORT_TEST_OBJS) libsudo_iolog.la
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(HOST_PORT_TEST_OBJS) libsudo_iolog.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
|
||||
|
||||
pre-install:
|
||||
|
||||
install:
|
||||
@@ -167,6 +172,7 @@ check: $(TEST_PROGS)
|
||||
./check_iolog_json $(srcdir)/regress/iolog_json/*.in || rval=`expr $$rval + $$?`; \
|
||||
./check_iolog_path $(srcdir)/regress/iolog_path/data || rval=`expr $$rval + $$?`; \
|
||||
./check_iolog_util || rval=`expr $$rval + $$?`; \
|
||||
./host_port_test || rval=`expr $$rval + $$?`; \
|
||||
exit $$rval; \
|
||||
fi
|
||||
|
||||
@@ -226,6 +232,30 @@ check_iolog_util.i: $(srcdir)/regress/iolog_util/check_iolog_util.c \
|
||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||
check_iolog_util.plog: check_iolog_util.i
|
||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/regress/iolog_util/check_iolog_util.c --i-file $< --output-file $@
|
||||
host_port.lo: $(srcdir)/host_port.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/sudo_compat.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/host_port.c
|
||||
host_port.i: $(srcdir)/host_port.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/sudo_compat.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||
host_port.plog: host_port.i
|
||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/host_port.c --i-file $< --output-file $@
|
||||
host_port_test.lo: $(srcdir)/regress/host_port/host_port_test.c \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/regress/host_port/host_port_test.c
|
||||
host_port_test.i: $(srcdir)/regress/host_port/host_port_test.c \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||
host_port_test.plog: host_port_test.i
|
||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/regress/host_port/host_port_test.c --i-file $< --output-file $@
|
||||
hostcheck.lo: $(srcdir)/hostcheck.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/hostcheck.h $(incdir)/sudo_compat.h \
|
||||
$(incdir)/sudo_debug.h $(incdir)/sudo_queue.h \
|
||||
|
@@ -41,13 +41,13 @@
|
||||
* Fills in hostp and portp which may point within str, which is modified.
|
||||
*/
|
||||
bool
|
||||
sudo_parse_host_port_v1(char *str, char **hostp, char **portp, bool *tlsp,
|
||||
iolog_parse_host_port(char *str, char **hostp, char **portp, bool *tlsp,
|
||||
char *defport, char *defport_tls)
|
||||
{
|
||||
char *flags, *port, *host = str;
|
||||
bool ret = false;
|
||||
bool tls = false;
|
||||
debug_decl(sudo_parse_host_port, SUDO_DEBUG_UTIL);
|
||||
debug_decl(iolog_parse_host_port, SUDO_DEBUG_UTIL);
|
||||
|
||||
/* Check for IPv6 address like [::0] followed by optional port */
|
||||
if (*host == '[') {
|
@@ -32,15 +32,18 @@
|
||||
#else
|
||||
# include "compat/stdbool.h"
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sudo_compat.h"
|
||||
#include "sudo_fatal.h"
|
||||
#include "sudo_iolog.h"
|
||||
#include "sudo_util.h"
|
||||
|
||||
__dso_public int main(int argc, char *argv[]);
|
||||
|
||||
/*
|
||||
* Test that sudo_parse_host_port() works as expected.
|
||||
* Test that iolog_parse_host_port() works as expected.
|
||||
*/
|
||||
|
||||
struct host_port_test {
|
||||
@@ -95,7 +98,7 @@ main(int argc, char *argv[])
|
||||
sudo_fatal_nodebug(NULL);
|
||||
|
||||
ntests++;
|
||||
ret = sudo_parse_host_port(copy, &host, &port, &tls,
|
||||
ret = iolog_parse_host_port(copy, &host, &port, &tls,
|
||||
test_data[i].defport, test_data[i].defport_tls);
|
||||
if (ret != test_data[i].ret) {
|
||||
sudo_warnx_nodebug("test #%d: %s: returned %s, expected %s",
|
@@ -104,7 +104,7 @@ PVS_LOG_OPTS = -a 'GA:1,2' -e -t errorfile -d $(PVS_IGNORE)
|
||||
# Regression tests
|
||||
TEST_PROGS = conf_test hltq_test parseln_test progname_test strsplit_test \
|
||||
strtobool_test strtoid_test strtomode_test strtonum_test \
|
||||
parse_gids_test getgrouplist_test host_port_test @COMPAT_TEST_PROGS@
|
||||
parse_gids_test getgrouplist_test @COMPAT_TEST_PROGS@
|
||||
TEST_LIBS = @LIBS@
|
||||
TEST_LDFLAGS = @LDFLAGS@
|
||||
|
||||
@@ -120,7 +120,7 @@ DEVEL = @DEVEL@
|
||||
SHELL = @SHELL@
|
||||
|
||||
LTOBJS = @DIGEST@ event.lo fatal.lo key_val.lo gethostname.lo gettime.lo \
|
||||
getgrouplist.lo gidlist.lo host_port.lo json.lo lbuf.lo locking.lo \
|
||||
getgrouplist.lo gidlist.lo json.lo lbuf.lo locking.lo \
|
||||
logfac.lo logpri.lo mkdir_parents.lo parseln.lo progname.lo \
|
||||
roundup.lo secure_path.lo setgroups.lo strsplit.lo strtobool.lo \
|
||||
strtoid.lo strtomode.lo strtonum.lo sudo_conf.lo \
|
||||
@@ -161,8 +161,6 @@ PARSE_GIDS_TEST_OBJS = parse_gids_test.lo gidlist.lo
|
||||
|
||||
GETGROUPLIST_TEST_OBJS = getgrouplist_test.lo getgrouplist.lo
|
||||
|
||||
HOST_PORT_TEST_OBJS = host_port_test.lo host_port.lo
|
||||
|
||||
STRSIG_TEST_OBJS = strsig_test.lo sig2str.lo str2sig.lo @SIGNAME@
|
||||
|
||||
VSYSLOG_TEST_OBJS = vsyslog_test.lo vsyslog.lo
|
||||
@@ -259,9 +257,6 @@ parse_gids_test: $(PARSE_GIDS_TEST_OBJS) libsudo_util.la
|
||||
getgrouplist_test: $(GETGROUPLIST_TEST_OBJS) libsudo_util.la
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(GETGROUPLIST_TEST_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
|
||||
|
||||
host_port_test: $(HOST_PORT_TEST_OBJS) libsudo_util.la
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(HOST_PORT_TEST_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
|
||||
|
||||
strsplit_test: $(STRSPLIT_TEST_OBJS) libsudo_util.la
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(STRSPLIT_TEST_OBJS) libsudo_util.la $(ASAN_LDFLAGS) $(PIE_LDFLAGS) $(SSP_LDFLAGS) $(TEST_LDFLAGS) $(TEST_LIBS)
|
||||
|
||||
@@ -351,7 +346,6 @@ check: $(TEST_PROGS)
|
||||
./strsig_test || rval=`expr $$rval + $$?`; \
|
||||
fi; \
|
||||
./getgrouplist_test || rval=`expr $$rval + $$?`; \
|
||||
./host_port_test || rval=`expr $$rval + $$?`; \
|
||||
./strtobool_test || rval=`expr $$rval + $$?`; \
|
||||
./strtoid_test || rval=`expr $$rval + $$?`; \
|
||||
./strtomode_test || rval=`expr $$rval + $$?`; \
|
||||
@@ -766,30 +760,6 @@ hltq_test.i: $(srcdir)/regress/tailq/hltq_test.c $(incdir)/compat/stdbool.h \
|
||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||
hltq_test.plog: hltq_test.i
|
||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/regress/tailq/hltq_test.c --i-file $< --output-file $@
|
||||
host_port.lo: $(srcdir)/host_port.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/sudo_compat.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/host_port.c
|
||||
host_port.i: $(srcdir)/host_port.c $(incdir)/compat/stdbool.h \
|
||||
$(incdir)/sudo_compat.h $(incdir)/sudo_debug.h \
|
||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||
host_port.plog: host_port.i
|
||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/host_port.c --i-file $< --output-file $@
|
||||
host_port_test.lo: $(srcdir)/regress/host_port/host_port_test.c \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/regress/host_port/host_port_test.c
|
||||
host_port_test.i: $(srcdir)/regress/host_port/host_port_test.c \
|
||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_util.h \
|
||||
$(top_builddir)/config.h
|
||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||
host_port_test.plog: host_port_test.i
|
||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/regress/host_port/host_port_test.c --i-file $< --output-file $@
|
||||
inet_pton.lo: $(srcdir)/inet_pton.c $(incdir)/sudo_compat.h \
|
||||
$(top_builddir)/config.h
|
||||
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/inet_pton.c
|
||||
|
@@ -108,7 +108,6 @@ sudo_logpri2str_v1
|
||||
sudo_mkdir_parents_v1
|
||||
sudo_new_key_val_v1
|
||||
sudo_parse_gids_v1
|
||||
sudo_parse_host_port_v1
|
||||
sudo_parseln_v1
|
||||
sudo_parseln_v2
|
||||
sudo_pow2_roundup_v1
|
||||
|
@@ -382,7 +382,7 @@ cb_listen_address(struct logsrvd_config *config, const char *str)
|
||||
}
|
||||
|
||||
/* Parse host[:port] */
|
||||
if (!sudo_parse_host_port(copy, &host, &port, &tls, DEFAULT_PORT,
|
||||
if (!iolog_parse_host_port(copy, &host, &port, &tls, DEFAULT_PORT,
|
||||
DEFAULT_PORT_TLS))
|
||||
goto done;
|
||||
if (host[0] == '*' && host[1] == '\0')
|
||||
|
@@ -60,6 +60,7 @@
|
||||
|
||||
#include "sudoers.h"
|
||||
#include "sudo_event.h"
|
||||
#include "sudo_iolog.h"
|
||||
#include "iolog_plugin.h"
|
||||
#include "hostcheck.h"
|
||||
|
||||
@@ -549,7 +550,7 @@ log_server_connect(struct client_closure *closure)
|
||||
STAILQ_FOREACH(server, closure->log_details->log_servers, entries) {
|
||||
free(copy);
|
||||
copy = strdup(server->str);
|
||||
if (!sudo_parse_host_port(copy, &host, &port, &tls, DEFAULT_PORT,
|
||||
if (!iolog_parse_host_port(copy, &host, &port, &tls, DEFAULT_PORT,
|
||||
DEFAULT_PORT_TLS)) {
|
||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||
"unable to parse %s", copy);
|
||||
|
Reference in New Issue
Block a user