Skip to content

Commit a587a03

Browse files
authored
Merge pull request #125 from oracle/move-tlshd.conf
tlshd: Relocate /etc/tlshd.conf
2 parents e83da47 + b8adcac commit a587a03

File tree

11 files changed

+85
-12
lines changed

11 files changed

+85
-12
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ AUTOMAKE_OPTIONS = foreign
2020

2121
EXTRA_DIST = autogen.sh CONTRIBUTING.md LICENSE.txt \
2222
README.md SECURITY.md
23-
SUBDIRS = man src systemd
23+
SUBDIRS = etc man src systemd
2424
MAINTAINERCLEANFILES = Makefile.in cscope.* ktls-utils*.tar.gz

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ fi
9595
AC_SUBST([AM_CPPFLAGS])
9696

9797
AC_CONFIG_FILES([Makefile \
98+
etc/Makefile \
99+
etc/tlshd/Makefile \
98100
man/Makefile \
99101
man/man5/Makefile \
100102
man/man8/Makefile \

etc/Makefile.am

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
SUBDIRS = tlshd
20+
21+
MAINTAINERCLEANFILES = Makefile.in

etc/tlshd/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+
MAINTAINERCLEANFILES = Makefile.in
24+
25+
install-exec-hook:
26+
mkdir -p $(DESTDIR)$(tlshdconfigdir)
27+
28+
uninstall-hook:
29+
rm -rf $(DESTDIR)$(tlshdconfigdir)
File renamed without changes.

man/man5/tlshd.conf.5

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
.\" tlshd.conf(5)
1919
.\"
2020
.\" Copyright (c) 2022 Oracle and/or its affiliates.
21-
.TH tlshd.conf 5 "20 Oct 2022"
21+
.TH tlshd.conf 5 "$(date +'%B %Y')"
2222
.SH NAME
2323
tlshd.conf \- tlshd configuration file
2424
.SH SYNOPSIS
25+
.I /etc/tlshd/config
26+
.br
2527
.I /etc/tlshd.conf
28+
(deprecated)
2629
.SH DESCRIPTION
2730
The
2831
.B tlshd

man/man8/tlshd.8

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ enabling decryption of recorded sessions.
7575
.B GNUTLS_FORCE_FIPS_MODE
7676
When set to `1', this variable forces the TLS library into FIPS mode
7777
if FIPS140-2 support is available.
78+
.SH FILES
79+
.TP
80+
.I /etc/tlshd/config
81+
Primary configuration file
82+
.TP
83+
.I /etc/tlshd.conf
84+
Legacy configuration file (deprecated)
7885
.SH SEE ALSO
7986
.BR tlshd.conf (5),
8087
.BR ssl (7)

src/tlshd/Makefile.am

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

19-
dist_sysconf_DATA = tlshd.conf
20-
2119
sbin_PROGRAMS = tlshd
2220
tlshd_CFLAGS = -Werror -Wall -Wextra $(LIBGNUTLS_CFLAGS) \
2321
$(LIBKEYUTILS_CFLAGS) $(GLIB_CFLAGS) $(LIBNL3_CFLAGS) \

src/tlshd/config.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ static GKeyFile *tlshd_configuration;
4949
/**
5050
* tlshd_config_init - Read tlshd's config file
5151
* @pathname: Pathname to config file
52+
* @legacy: Don't generate an error if the config file doesn't exist
5253
*
5354
* Return values:
5455
* %true: Config file read successfully
5556
* %false: Unable to read config file
5657
*/
57-
bool tlshd_config_init(const gchar *pathname)
58+
bool tlshd_config_init(const gchar *pathname, bool legacy)
5859
{
5960
gchar **keyrings;
6061
gsize i, length;
@@ -67,7 +68,8 @@ bool tlshd_config_init(const gchar *pathname)
6768
if (!g_key_file_load_from_file(tlshd_configuration, pathname,
6869
G_KEY_FILE_KEEP_COMMENTS,
6970
&error)) {
70-
tlshd_log_gerror("Failed to load config file", error);
71+
if (!legacy)
72+
tlshd_log_gerror("Failed to load config file", error);
7173
g_error_free(error);
7274
return false;
7375
}

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(const 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, false)) {
106+
tlshd_log_shutdown();
107+
tlshd_log_close();
108+
return EXIT_FAILURE;
109+
}
110+
} else {
111+
if (tlshd_config_init("/etc/tlshd.conf", true)) {
112+
tlshd_log_notice("Please relocate /etc/tlshd.conf to /etc/tlshd/config");
113+
} else if (!tlshd_config_init("/etc/tlshd/config", false)) {
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)