summaryrefslogtreecommitdiffstats
path: root/debian/get_user
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:53:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:53:35 +0000
commit46ec4c5ae30e9137e303a1f7187da16da6378eb4 (patch)
tree94a4a825604057e5fda94b7249d8310605fe1c62 /debian/get_user
parentAdding upstream version 2.7.6. (diff)
downloadknot-46ec4c5ae30e9137e303a1f7187da16da6378eb4.tar.xz
knot-46ec4c5ae30e9137e303a1f7187da16da6378eb4.zip
Adding debian version 2.7.6-2.debian/2.7.6-2debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/get_user')
-rwxr-xr-xdebian/get_user28
1 files changed, 28 insertions, 0 deletions
diff --git a/debian/get_user b/debian/get_user
new file mode 100755
index 0000000..1e0f258
--- /dev/null
+++ b/debian/get_user
@@ -0,0 +1,28 @@
+#!/usr/bin/python3
+
+import yaml, sys
+
+conf_file = '/etc/knot/knot.conf' if len(sys.argv) < 2 else sys.argv[1]
+ip_fields = ['listen', 'address', 'via', 'whitelist', 'network']
+
+try:
+ conf = yaml.load(open(conf_file, 'r'))
+except (yaml.scanner.ScannerError, yaml.parser.ParserError):
+ conf = False
+
+if not conf:
+ import io
+ conf_io = io.StringIO()
+ with open(conf_file) as f:
+ for line in f:
+ if line.split(':')[0].strip() not in ip_fields:
+ conf_io.write(line)
+ conf_io.seek(0)
+ try:
+ conf = yaml.load(conf_io)
+ except (yaml.scanner.ScannerError, yaml.parser.ParserError):
+ sys.exit(1)
+
+if "server" in conf and conf["server"]:
+ if "user" in conf["server"] and conf["server"]["user"]:
+ print(conf["server"]["user"].split(":")[0].split(".")[0])