aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--FLOW.md6
-rw-r--r--Makefile21
-rw-r--r--README.md6
-rw-r--r--avahi/pacserve.service.in15
-rw-r--r--config.def.h6
-rwxr-xr-xnetworkmanager/80-pacredir2
-rw-r--r--pacredir.c12
-rw-r--r--pacredir.h2
-rw-r--r--pacserve.conf4
-rw-r--r--systemd/pacredir.service4
-rw-r--r--systemd/pacserve-announce.service.in23
-rw-r--r--systemd/pacserve.service7
-rw-r--r--systemd/sysusers.conf2
14 files changed, 65 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
index bf69658..1d55889 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
arch
pacredir
config.h
-avahi/pacserve.service
+systemd/pacserve-announce.service
version.h
pacredir-*.tar.xz
pacredir-*.tar.xz.asc
diff --git a/FLOW.md b/FLOW.md
index 7fd1f9b..067bb5e 100644
--- a/FLOW.md
+++ b/FLOW.md
@@ -1,7 +1,7 @@
pacredir - request flow
=======================
-[◀ Go back to main README](README.md)
+[⬅️ Go back to main README](README.md)
Whenever `pacman` sends a request to `pacredir` a number of requests
(increasing with the number of hosts found) is sent through the network.
@@ -34,5 +34,5 @@ All requests made by `pacredir` are answered with http code `404`, thus
`pacman` receives the same. Finally `pacman` falls back to the next mirror.
---
-[◀ Go back to main README](README.md)
-[▲ Go back to top](#top)
+[⬅️ Go back to main README](README.md)
+[⬆️ Go back to top](#top)
diff --git a/Makefile b/Makefile
index bb6ac24..c4301db 100644
--- a/Makefile
+++ b/Makefile
@@ -23,17 +23,17 @@ CFLAGS_EXTRA += $(shell pkg-config --libs --cflags iniparser)
LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
# the distribution ID
-ARCH := $(shell shopt -u extglob && source /etc/makepkg.conf && echo $$CARCH)
-ID := $(shell shopt -u extglob && source /etc/os-release && echo $$ID)
+ARCH := $(shell shopt -u extglob && source /etc/makepkg.conf && echo $${CARCH//_/-})
+ID := $(shell shopt -u extglob && source /etc/os-release && echo $${ID//_/-})
# this is just a fallback in case you do not use git but downloaded
# a release tarball...
-VERSION := 0.4.7
+VERSION := 0.5.0
MARKDOWN = $(wildcard *.md)
HTML = $(MARKDOWN:.md=.html)
-all: pacredir avahi/pacserve.service $(HTML)
+all: pacredir systemd/pacserve-announce.service $(HTML)
pacredir: pacredir.c pacredir.h config.h version.h
$(CC) pacredir.c $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -DREPRODUCIBLE=$(REPRODUCIBLE) -DARCH=\"$(ARCH)\" -DID=\"$(ID)\" -o pacredir
@@ -44,22 +44,23 @@ config.h:
version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
printf "#ifndef VERSION\n#define VERSION \"%s\"\n#endif\n" $(shell git describe --long 2>/dev/null || echo ${VERSION}) > $@
-avahi/pacserve.service: avahi/pacserve.service.in
- $(SED) 's/%ARCH%/$(ARCH)/;s/%ID%/$(ID)/' avahi/pacserve.service.in > avahi/pacserve.service
+systemd/pacserve-announce.service: systemd/pacserve-announce.service.in
+ $(SED) 's/%ARCH%/$(ARCH)/;s/%ID%/$(ID)/' systemd/pacserve-announce.service.in > systemd/pacserve-announce.service
%.html: %.md Makefile
markdown $< | sed 's/href="\([-[:alnum:]]*\)\.md"/href="\1.html"/g' > $@
install: install-bin install-doc
-install-bin: pacredir avahi/pacserve.service
+install-bin: pacredir systemd/pacserve-announce.service
$(INSTALL) -D -m0755 pacredir $(DESTDIR)$(PREFIX)/bin/pacredir
$(LN) -s darkhttpd $(DESTDIR)$(PREFIX)/bin/pacserve
$(INSTALL) -D -m0644 pacredir.conf $(DESTDIR)/etc/pacredir.conf
+ $(INSTALL) -D -m0644 pacserve.conf $(DESTDIR)/etc/pacserve.conf
$(INSTALL) -D -m0644 pacman/pacredir $(DESTDIR)/etc/pacman.d/pacredir
- $(INSTALL) -D -m0644 avahi/pacserve.service $(DESTDIR)/etc/avahi/services/pacserve.service
$(INSTALL) -D -m0644 systemd/pacredir.service $(DESTDIR)$(PREFIX)/lib/systemd/system/pacredir.service
$(INSTALL) -D -m0644 systemd/pacserve.service $(DESTDIR)$(PREFIX)/lib/systemd/system/pacserve.service
+ $(INSTALL) -D -m0644 systemd/pacserve-announce.service $(DESTDIR)$(PREFIX)/lib/systemd/system/pacserve-announce.service
$(INSTALL) -D -m0644 systemd/sysusers.conf $(DESTDIR)$(PREFIX)/lib/sysusers.d/pacredir.conf
$(INSTALL) -D -m0644 systemd/tmpfiles.conf $(DESTDIR)$(PREFIX)/lib/tmpfiles.d/pacredir.conf
$(INSTALL) -D -m0644 initcpio/hooks/pacredir $(DESTDIR)$(PREFIX)/lib/initcpio/hooks/pacredir
@@ -74,10 +75,10 @@ install-doc: $(HTML)
$(INSTALL) -D -m0644 $(wildcard FLOW/*) -t $(DESTDIR)$(PREFIX)/share/doc/pacredir/FLOW/
clean:
- $(RM) -f *.o *~ pacredir avahi/pacserve.service $(HTML) version.h
+ $(RM) -f *.o *~ pacredir systemd/pacserve-announce.service $(HTML) version.h
distclean:
- $(RM) -f *.o *~ pacredir avahi/pacserve.service $(HTML) version.h config.h
+ $(RM) -f *.o *~ pacredir systemd/pacserve-announce.service $(HTML) version.h config.h
release:
git archive --format=tar.xz --prefix=pacredir-$(VERSION)/ $(VERSION) > pacredir-$(VERSION).tar.xz
diff --git a/README.md b/README.md
index c86fa9a..760ea88 100644
--- a/README.md
+++ b/README.md
@@ -42,8 +42,7 @@ followed by:
This will place an executable at `/usr/bin/pacredir`,
documentation can be found in `/usr/share/doc/pacredir/`.
Additionally systemd service files are installed to
-`/usr/lib/systemd/system/` and avahi service files go to
-`/etc/avahi/services/`.
+`/usr/lib/systemd/system/`.
Usage
-----
@@ -106,3 +105,6 @@ URL:
Mirror:
[eworm.de](https://git.eworm.de/cgit.cgi/pacredir/about/)
[GitLab.com](https://gitlab.com/eworm-de/pacredir#pacredir)
+
+---
+[⬆️ Go back to top](#top)
diff --git a/avahi/pacserve.service.in b/avahi/pacserve.service.in
deleted file mode 100644
index 4a39e6d..0000000
--- a/avahi/pacserve.service.in
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
-<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
-
-<!-- See avahi.service(5) for more information about this configuration file -->
-
-<service-group>
-
- <name replace-wildcards="yes">%h</name>
-
- <service>
- <type>_pacserve_%ID%_%ARCH%._tcp</type>
- <port>7078</port>
- </service>
-
-</service-group>
diff --git a/config.def.h b/config.def.h
index 5fd7c13..825c420 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2024 by Christian Hesse <mail@eworm.de>
+ * (C) 2013-2025 by Christian Hesse <mail@eworm.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
#define DROP_PRIV_GID 65534
/* website url */
-#define WEBSITE "https://github.com/eworm-de/pacredir#pacredir"
+#define WEBSITE "https://pacredir.eworm.de/"
/* This is used for default documents. Usually you will not see this anyway. */
#define PAGE307 "<html><head><title>307 temporary redirect</title>" \
@@ -38,7 +38,7 @@
#define PORT_PACSERVE 7078
/* avahi service names */
-#define PACSERVE "_pacserve_" ID "_" ARCH "._tcp"
+#define PACSERVE "_pacserve-" ID "-" ARCH "._tcp"
/* path to the config file */
#define CONFIGFILE "/etc/pacredir.conf"
diff --git a/networkmanager/80-pacredir b/networkmanager/80-pacredir
index 32114ae..fa9e1e1 100755
--- a/networkmanager/80-pacredir
+++ b/networkmanager/80-pacredir
@@ -1,6 +1,6 @@
#!/bin/sh
-if [ "${2}" == "up" ]; then
+if [ "${2}" = "up" ]; then
if systemctl is-active -q pacredir.service; then
systemctl reload pacredir.service
fi
diff --git a/pacredir.c b/pacredir.c
index 4bfb16c..674b88c 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2024 by Christian Hesse <mail@eworm.de>
+ * (C) 2013-2025 by Christian Hesse <mail@eworm.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -184,10 +184,10 @@ static void resolve_callback(AvahiServiceResolver *r,
avahi_address_snprint(ipaddress, AVAHI_ADDRESS_STR_MAX, address);
if (verbose > 0)
- write_log(stdout, "Found service %s on host %s (%s) on interface %s\n",
- type, host, ipaddress, intname);
+ write_log(stdout, "Found service %s (port %d) on host %s (%s) on interface %s\n",
+ type, port, host, ipaddress, intname);
- add_host(host, protocol, ipaddress, PORT_PACSERVE, type);
+ add_host(host, protocol, ipaddress, port, type);
break;
}
@@ -487,7 +487,7 @@ static mhd_result ahc_echo(void * cls,
request->last_modified = 0;
if (verbose > 0)
- write_log(stdout, "Trying %s: %s\n", request->host, request->url);
+ write_log(stdout, "Trying %s: %s\n", request->host->host, request->url);
if ((error = pthread_create(&tid[req_count], NULL, get_http_code, (void *)request)) != 0)
write_log(stderr, "Could not run thread number %d, errno %d\n", req_count, error);
@@ -776,7 +776,7 @@ int main(int argc, char ** argv) {
/* prepare struct to make microhttpd listen on localhost only */
address.sin_family = AF_INET;
address.sin_port = htons(PORT_PACREDIR);
- address.sin_addr.s_addr = htonl(0x7f000001);
+ address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
/* start http server */
if ((mhd = MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_TCP_FASTOPEN, PORT_PACREDIR,
diff --git a/pacredir.h b/pacredir.h
index 5be6295..3537625 100644
--- a/pacredir.h
+++ b/pacredir.h
@@ -1,5 +1,5 @@
/*
- * (C) 2013-2024 by Christian Hesse <mail@eworm.de>
+ * (C) 2013-2025 by Christian Hesse <mail@eworm.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/pacserve.conf b/pacserve.conf
new file mode 100644
index 0000000..6a0a279
--- /dev/null
+++ b/pacserve.conf
@@ -0,0 +1,4 @@
+# pacserve configuration file
+
+# Port to listen on
+PORT=7078
diff --git a/systemd/pacredir.service b/systemd/pacredir.service
index ed5e45a..9a5801f 100644
--- a/systemd/pacredir.service
+++ b/systemd/pacredir.service
@@ -1,4 +1,4 @@
-# (C) 2013-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2013-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -7,9 +7,9 @@
[Unit]
Description=Redirect pacman requests via avahi service
+Documentation=https://pacredir.eworm.de/
Requires=avahi-daemon.service
After=avahi-daemon.service network.target network-online.target
-Documentation=https://github.com/eworm-de/pacredir#pacredir
[Service]
Type=notify
diff --git a/systemd/pacserve-announce.service.in b/systemd/pacserve-announce.service.in
new file mode 100644
index 0000000..c6f9828
--- /dev/null
+++ b/systemd/pacserve-announce.service.in
@@ -0,0 +1,23 @@
+# (C) 2013-2025 by Christian Hesse <mail@eworm.de>
+# Markus Weippert <markus@gekmihesg.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Announce pacman database files and package archives
+Documentation=https://pacredir.eworm.de/
+After=avahi-daemon.service pacserve.service
+BindsTo=pacserve.service
+Requisite=avahi-daemon.service
+
+[Service]
+EnvironmentFile=/etc/pacserve.conf
+ExecStart=/usr/bin/avahi-publish -s "pacserve on %l" _pacserve-%ID%-%ARCH%._tcp ${PORT}
+DynamicUser=on
+ProtectSystem=full
+ProtectHome=on
+PrivateDevices=on
+NoNewPrivileges=on
diff --git a/systemd/pacserve.service b/systemd/pacserve.service
index d5e064d..2af4c1e 100644
--- a/systemd/pacserve.service
+++ b/systemd/pacserve.service
@@ -1,4 +1,4 @@
-# (C) 2013-2024 by Christian Hesse <mail@eworm.de>
+# (C) 2013-2025 by Christian Hesse <mail@eworm.de>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -7,10 +7,13 @@
[Unit]
Description=Serve pacman database files and package archives
+Documentation=https://pacredir.eworm.de/
After=systemd-tmpfiles-setup.service network.target
+Upholds=pacserve-announce.service
[Service]
-ExecStart=/usr/bin/pacserve /run/pacserve/ --ipv6 --port 7078 --no-listing --index empty
+EnvironmentFile=/etc/pacserve.conf
+ExecStart=/usr/bin/pacserve /run/pacserve/ --ipv6 --port ${PORT} --no-listing --index empty
BindReadOnlyPaths=/var/cache/pacman/pkg:/run/pacserve/pkg /var/lib/pacman/sync:/run/pacserve/db
DynamicUser=on
ProtectSystem=full
diff --git a/systemd/sysusers.conf b/systemd/sysusers.conf
index cd2e81c..ced5210 100644
--- a/systemd/sysusers.conf
+++ b/systemd/sysusers.conf
@@ -1 +1 @@
-u pacredir - "redirect pacman requests"
+u! pacredir - "redirect pacman requests"