From eca67162c64db061e4b589ce0ce908cc4baee875 Mon Sep 17 00:00:00 2001
From: Julian Rother <julian@jrother.eu>
Date: Fri, 3 Dec 2021 23:30:23 +0100
Subject: [PATCH] Renaming to uffd-ldapd and cleanup of Debian package

---
 .gitlab-ci.yml                                     | 14 +++++++-------
 .pylintrc                                          |  1 +
 README.md                                          | 13 +++++++++----
 debian/contrib/{uffd-ldap.conf => uffd-ldapd.conf} |  0
 .../{uffd-ldap.service => uffd-ldapd.service}      | 10 +++++-----
 .../{uffd-ldap.socket => uffd-ldapd.socket}        |  2 +-
 debian/control                                     | 10 +++++-----
 debian/install                                     |  8 ++++----
 debian/links                                       |  1 -
 debian/postinst                                    |  2 +-
 server.py => uffd-ldapd                            |  0
 11 files changed, 33 insertions(+), 28 deletions(-)
 rename debian/contrib/{uffd-ldap.conf => uffd-ldapd.conf} (100%)
 rename debian/contrib/{uffd-ldap.service => uffd-ldapd.service} (77%)
 rename debian/contrib/{uffd-ldap.socket => uffd-ldapd.socket} (50%)
 delete mode 100644 debian/links
 rename server.py => uffd-ldapd (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2ca9800..6eace1b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,7 +21,7 @@ before_script:
 build:apt:
   extends: .build
   script:
-  - ./debian/create_changelog.py uffd-ldap > debian/changelog
+  - ./debian/create_changelog.py uffd-ldapd > debian/changelog
   - dpkg-buildpackage -us -uc
   - mv ../*.deb ./
   - dpkg-deb -I *.deb
@@ -36,9 +36,9 @@ linter:buster:
   script:
   - pip3 install $PYLINT_PIN pylint-gitlab # this force-updates jinja2 and some other packages!
   - pip3 install -r requirements.txt
-  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter 'server.py' > codeclimate.json
-  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter 'server.py' > pylint.html
-  - python3 -m pylint --rcfile .pylintrc --output-format=text 'server.py'
+  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter 'uffd-ldapd' > codeclimate.json
+  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter 'uffd-ldapd' > pylint.html
+  - python3 -m pylint --rcfile .pylintrc --output-format=text 'uffd-ldapd'
   artifacts:
     when: always
     paths:
@@ -52,9 +52,9 @@ linter:bullseye:
   script:
   - pip3 install $PYLINT_PIN pylint-gitlab # this force-updates jinja2 and some other packages!
   - pip3 install -r requirements.txt
-  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter 'server.py' > codeclimate.json
-  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter 'server.py' > pylint.html
-  - python3 -m pylint --rcfile .pylintrc --output-format=text 'server.py'
+  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabCodeClimateReporter 'uffd-ldapd' > codeclimate.json
+  - python3 -m pylint --exit-zero --rcfile .pylintrc --output-format=pylint_gitlab.GitlabPagesHtmlReporter 'uffd-ldapd' > pylint.html
+  - python3 -m pylint --rcfile .pylintrc --output-format=text 'uffd-ldapd'
   artifacts:
     when: always
     paths:
diff --git a/.pylintrc b/.pylintrc
index 9745cc6..86c7c86 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -65,6 +65,7 @@ disable=missing-module-docstring,
         missing-function-docstring,
         too-few-public-methods,
         too-many-arguments,
+        invalid-name,
 
 # Enable the message, report, category or checker with the given id(s). You can
 # either give multiple identifier separated by comma (,) or put this option
diff --git a/README.md b/README.md
index c496b54..60fb62d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,11 @@
-LDAP Proxy for Uffd
-===================
+Uffd LDAP Proxy Server
+======================
 
-LDAP server that provides user and group data exposed by uffd's API. Based on python-ldapserver.
+Proxy server to provide uffd user and group data via LDAP.
+Based on [python-ldapserver](https://git.cccv.de/uffd/python-ldapserver).
 
-Requires at least uffd v1.2.0!
+To install uffd-ldapd on Debian, add the [uffd Debian repository](https://packages.cccv.de/uffd/) to `/etc/sources.list` and install the package `uffd-ldapd`.
+Update the config file `/etc/uffd-ldapd.conf` and restart the service with `systemctl restart uffd-ldapd`.
+The proxy server listens on `ldap://127.0.0.1:389/`.
+
+uffd-ldapd requires at least uffd v1.2.0!
diff --git a/debian/contrib/uffd-ldap.conf b/debian/contrib/uffd-ldapd.conf
similarity index 100%
rename from debian/contrib/uffd-ldap.conf
rename to debian/contrib/uffd-ldapd.conf
diff --git a/debian/contrib/uffd-ldap.service b/debian/contrib/uffd-ldapd.service
similarity index 77%
rename from debian/contrib/uffd-ldap.service
rename to debian/contrib/uffd-ldapd.service
index c905a43..ad84cb6 100644
--- a/debian/contrib/uffd-ldap.service
+++ b/debian/contrib/uffd-ldapd.service
@@ -1,16 +1,16 @@
 [Unit]
-Description=LDAP server to integrate uffd users/groups with LDAP applications
+Description=Proxy server to provide uffd user and group data via LDAP
 After=network.target
-BindsTo=uffd-ldap.socket
+BindsTo=uffd-ldapd.socket
 
 [Service]
-ExecStart=/usr/bin/uffd-ldap --socket-fd 3
+ExecStart=/usr/sbin/uffd-ldapd --socket-fd 3
 
 Restart=always
 RestartSec=10
 StandardOutput=journal
 StandardError=journal
-SyslogIdentifier=uffd-ldap
+SyslogIdentifier=uffd-ldapd
 
 DynamicUser=true
 PrivateUsers=true
@@ -37,7 +37,7 @@ SystemCallArchitectures=native
 SystemCallFilter=@system-service
 MemoryDenyWriteExecute=true
 
-EnvironmentFile=/etc/uffd-ldap.conf
+EnvironmentFile=/etc/uffd-ldapd.conf
 
 [Install]
 WantedBy=default.target
diff --git a/debian/contrib/uffd-ldap.socket b/debian/contrib/uffd-ldapd.socket
similarity index 50%
rename from debian/contrib/uffd-ldap.socket
rename to debian/contrib/uffd-ldapd.socket
index 01552cf..7928a81 100644
--- a/debian/contrib/uffd-ldap.socket
+++ b/debian/contrib/uffd-ldapd.socket
@@ -1,5 +1,5 @@
 [Unit]
-Description=LDAP server to integrate uffd users/groups with LDAP applications
+Description=Proxy server to provide uffd user and group data via LDAP
 
 [Socket]
 ListenStream=127.0.0.1:389
diff --git a/debian/control b/debian/control
index 446b49f..8f88951 100644
--- a/debian/control
+++ b/debian/control
@@ -1,14 +1,14 @@
-Source: uffd-ldap
+Source: uffd-ldapd
 Section: python
 Priority: optional
 Maintainer: CCCV <it@cccv.de>
 Build-Depends:
  debhelper-compat (= 12),
 Standards-Version: 4.5.0
-Homepage: https://git.cccv.de/uffd/ldap-proxy
-Vcs-Git: https://git.cccv.de/uffd/ldap-proxy.git
+Homepage: https://git.cccv.de/uffd/uffd-ldapd
+Vcs-Git: https://git.cccv.de/uffd/uffd-ldapd.git
 
-Package: uffd-ldap
+Package: uffd-ldapd
 Architecture: all
 Depends:
  ${misc:Depends},
@@ -16,4 +16,4 @@ Depends:
  python3-requests,
  python3-cachecontrol,
  python3-click,
-Description: LDAP server to integrate uffd users/groups with LDAP applications
+Description: Proxy server to provide uffd user and group data via LDAP
diff --git a/debian/install b/debian/install
index 554842b..944fa15 100644
--- a/debian/install
+++ b/debian/install
@@ -1,4 +1,4 @@
-server.py /usr/lib/uffd-ldap/
-debian/contrib/uffd-ldap.service /usr/lib/systemd/system/
-debian/contrib/uffd-ldap.socket /usr/lib/systemd/system/
-debian/contrib/uffd-ldap.conf /etc/
+uffd-ldapd /usr/sbin/
+debian/contrib/uffd-ldapd.service /usr/lib/systemd/system/
+debian/contrib/uffd-ldapd.socket /usr/lib/systemd/system/
+debian/contrib/uffd-ldapd.conf /etc/
diff --git a/debian/links b/debian/links
deleted file mode 100644
index 90e1e14..0000000
--- a/debian/links
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/uffd-ldap/server.py /usr/bin/uffd-ldap
diff --git a/debian/postinst b/debian/postinst
index e0121c1..a89c052 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -4,7 +4,7 @@ set -e
 
 case "$1" in
 	configure)
-		chmod 0640 /etc/uffd-ldap.conf
+		chmod 0640 /etc/uffd-ldapd.conf
 	;;
 
 	abort-upgrade|abort-remove|abort-deconfigure)
diff --git a/server.py b/uffd-ldapd
similarity index 100%
rename from server.py
rename to uffd-ldapd
-- 
GitLab