Skip to content

Commit 1c6cc41

Browse files
committed
tlshd: Relocate /etc/tlshd.conf
To support TLS session tags, additional configuration files, outside of /etc/tlshd.conf, will be needed. So create a tlshd configuration directory: /etc/tlshd/ And move /etc/tlshd.conf into that directory as: /etc/tlshd/config For now, tlshd will look for /etc/tlshd.conf first, and warn that the new file name should be used instead. XXX: I'm not sure what to rename tlshd.conf.man to. Signed-off-by: Chuck Lever <[email protected]>
1 parent 59ecb97 commit 1c6cc41

File tree

6 files changed

+49
-11
lines changed

6 files changed

+49
-11
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ AC_CHECK_LIB([gnutls], [gnutls_psk_allocate_client_credentials2],
8181
[Define to 1 if you have the gnutls_psk_allocate_client_credentials2 function.])])
8282
AC_SUBST([AM_CPPFLAGS])
8383

84-
AC_CONFIG_FILES([Makefile src/Makefile src/tlshd/Makefile systemd/Makefile])
84+
AC_CONFIG_FILES([Makefile src/Makefile src/tlshd/Makefile src/tlshd/etc/Makefile systemd/Makefile])
8585
AC_OUTPUT

src/tlshd/Makefile.am

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
# 02110-1301, USA.
1717
#
1818

19-
dist_sysconf_DATA = tlshd.conf
20-
21-
man5_MANS = tlshd.conf.man
2219
man8_MANS = tlshd.man
23-
EXTRA_DIST = $(man5_MANS) $(man8_MANS)
20+
EXTRA_DIST = $(man8_MANS)
2421

2522
sbin_PROGRAMS = tlshd
2623
tlshd_CFLAGS = -Werror -Wall -Wextra $(LIBGNUTLS_CFLAGS) \
@@ -31,4 +28,5 @@ tlshd_SOURCES = client.c config.c handshake.c keyring.c ktls.c log.c \
3128
tlshd_LDADD = $(LIBGNUTLS_LIBS) $(LIBKEYUTILS_LIBS) $(GLIB_LIBS) \
3229
$(LIBNL3_LIBS) $(LIBNL_GENL3_LIBS)
3330

31+
SUBDIRS = etc
3432
MAINTAINERCLEANFILES = Makefile.in cscope.out

src/tlshd/etc/Makefile.am

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Copyright (c) 2025 Oracle and/or its affiliates.
3+
#
4+
# ktls-utils is free software; you can redistribute it and/or
5+
# modify it under the terms of the GNU General Public License as
6+
# published by the Free Software Foundation; version 2.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
# General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU General Public License
14+
# along with this program; if not, write to the Free Software
15+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16+
# 02110-1301, USA.
17+
#
18+
19+
tlshdconfigdir = $(sysconfdir)/tlshd
20+
21+
dist_tlshdconfig_DATA = config
22+
23+
man5_MANS = tlshd.conf.man
24+
EXTRA_DIST = $(man5_MANS)
25+
26+
MAINTAINERCLEANFILES = Makefile.in
27+
28+
install-exec-hook:
29+
mkdir -p $(DESTDIR)$(tlshdconfigdir)
File renamed without changes.

src/tlshd/tlshd.conf.man renamed to src/tlshd/etc/tlshd.conf.man

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
.SH NAME
2323
tlshd.conf \- tlshd configuration file
2424
.SH SYNOPSIS
25-
.B /etc/tlshd.conf
25+
.B /etc/tlshd/config
2626
.SH DESCRIPTION
2727
The
2828
.B tlshd

src/tlshd/main.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ static void usage(char *progname)
6363

6464
int main(int argc, char **argv)
6565
{
66-
static gchar config_file[PATH_MAX + 1] = "/etc/tlshd.conf";
66+
static gchar config_file[PATH_MAX + 1];
6767
char *progname;
6868
int c;
6969
size_t len;
7070

7171
tlshd_tls_debug = 0;
7272
progname = basename(argv[0]);
73+
config_file[0] = '\0';
7374
while ((c = getopt_long(argc, argv, optstring, longopts, NULL)) != -1) {
7475
switch (c) {
7576
case 'c':
@@ -100,10 +101,20 @@ int main(int argc, char **argv)
100101

101102
tlshd_log_init(progname);
102103

103-
if (!tlshd_config_init(config_file)) {
104-
tlshd_log_shutdown();
105-
tlshd_log_close();
106-
return EXIT_FAILURE;
104+
if (config_file[0] != '\0') {
105+
if (!tlshd_config_init(config_file)) {
106+
tlshd_log_shutdown();
107+
tlshd_log_close();
108+
return EXIT_FAILURE;
109+
}
110+
} else {
111+
if (tlshd_config_init("/etc/tlshd.conf")) {
112+
tlshd_log_notice("Please relocate /etc/tlshd.conf to /etc/tlshd/config");
113+
} else if (!tlshd_config_init("/etc/tlshd/config")) {
114+
tlshd_log_shutdown();
115+
tlshd_log_close();
116+
return EXIT_FAILURE;
117+
}
107118
}
108119

109120
if (tlshd_gnutls_priority_init()) {

0 commit comments

Comments
 (0)