Skip to contentSkip to conversation

vsftpd: Add systemd services

PATCH New Maxime Hadjinlian 2 participants 3 messages Oct 4, 2015 – Oct 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vsftpd: Add systemd services

The systemd services were taken from Arch Linux's repository:
https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/vsftpd

---
 package/vsftpd/vsftpd-ssl.service  | 10 ++++++++++
 package/vsftpd/vsftpd-ssl.socket   |  9 +++++++++
 package/vsftpd/vsftpd-ssl at .service |  9 +++++++++
 package/vsftpd/vsftpd.mk           | 17 +++++++++++++++++
 package/vsftpd/vsftpd.service      | 11 +++++++++++
 package/vsftpd/vsftpd.socket       |  9 +++++++++
 package/vsftpd/vsftpd at .service     |  8 ++++++++
 7 files changed, 73 insertions(+)
 create mode 100644 package/vsftpd/vsftpd-ssl.service
 create mode 100644 package/vsftpd/vsftpd-ssl.socket
 create mode 100644 package/vsftpd/vsftpd-ssl at .service
 create mode 100644 package/vsftpd/vsftpd.service
 create mode 100644 package/vsftpd/vsftpd.socket
 create mode 100644 package/vsftpd/vsftpd at .service
package/vsftpd/vsftpd-ssl.service new file +10 -0
new file mode 100644
index 0000000..3343bc9
@@ -0,0 +1,10 @@
+[Unit]
+Description=vsftpd daemon (legacy implicit SSL)
+
+[Service]
+ExecStart=/usr/bin/vsftpd -oimplicit_ssl=yes
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+
+[Install]
+WantedBy=multi-user.target
package/vsftpd/vsftpd-ssl.socket new file +9 -0
new file mode 100644
index 0000000..b18b639
@@ -0,0 +1,9 @@
+[Unit]
+Conflicts=vsftpd.service
+
+[Socket]
+ListenStream=990
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
package/vsftpd/vsftpd-ssl at .service new file +9 -0
new file mode 100644
index 0000000..8bcf78e
@@ -0,0 +1,9 @@
+[Unit]
+Description=vsftpd per-connection server (legacy implicit SSL)
+
+[Service]
+ExecStart=-/usr/bin/vsftpd -oimplicit_ssl=yes
+ExecReload=/bin/kill -HUP $MAINPID
+StandardInput=socket
+StandardOutput=socket
+StandardError=syslog
package/vsftpd/vsftpd.mk +17 -0
index 1e48264..823ad66 100644
@@ -47,6 +47,23 @@ define VSFTPD_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 755 package/vsftpd/S70vsftpd $(TARGET_DIR)/etc/init.d/S70vsftpd
 endef
 
+define VSFTPD_INSTALL_INIT_SYSTEMD
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/sockets.target.wants
+
+	for f in vsftpd.service vsftpd.socket vsftpd at .service \
+		vsftpd-ssl.service vsftpd-ssl.socket vsftpd-ssl at .service; do \
+		$(INSTALL) -D -m 644 package/vsftpd/$$f \
+			$(TARGET_DIR)/usr/lib/systemd/system/$$f; \
+		wanted_by="multi-user.target.wants"; \
+		if [ $${f##*.} = "socket" ]; then \
+			wanted_by="sockets.target.wants"; \
+		fi; \
+		ln -sf ../../../../usr/lib/systemd/system/$$f \
+			$(TARGET_DIR)/etc/systemd/system/$$wanted_by/$$f; \
+	done
+endef
+
 define VSFTPD_INSTALL_TARGET_CMDS
 	$(INSTALL) -D -m 755 $(@D)/vsftpd $(TARGET_DIR)/usr/sbin/vsftpd
 	test -f $(TARGET_DIR)/etc/vsftpd.conf || \
package/vsftpd/vsftpd.service new file +11 -0
new file mode 100644
index 0000000..cc7645f
@@ -0,0 +1,11 @@
+[Unit]
+Description=vsftpd daemon
+After=network.target
+
+[Service]
+ExecStart=/usr/bin/vsftpd
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+
+[Install]
+WantedBy=multi-user.target
package/vsftpd/vsftpd.socket new file +9 -0
new file mode 100644
index 0000000..cdc0d33
@@ -0,0 +1,9 @@
+[Unit]
+Conflicts=vsftpd.service
+
+[Socket]
+ListenStream=21
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
package/vsftpd/vsftpd at .service new file +8 -0
new file mode 100644
index 0000000..81e1429
@@ -0,0 +1,8 @@
+[Unit]
+Description=vsftpd per-connection server
+
+[Service]
+ExecStart=-/usr/bin/vsftpd
+ExecReload=/bin/kill -HUP $MAINPID
+StandardInput=socket
+StandardError=syslog
Signature · 1 line
2.5.3
#1 lore raw

PATCH 1/1 vsftpd: Add systemd services

Dear Maxime Hadjinlian,

Quoted 2 lines · Maxime Hadjinlian

The systemd services were taken from Arch Linux's repository:
https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/vsftpd

Can this support be submitted upstream?

Quoted 1 line

I've tested this, and it doesn't seem to work here:

Starting Serial Getty on ttyAMA0...
Starting Login Service...
systemd[1]: vsftpd at multi-user.service: Failed to run 'start' task: Invalid argument [FAILED] Failed to start vsftpd per-connection server.
See 'systemctl status vsftpd at multi-user.service' for details. systemd[1]: vsftpd at multi-user.service: Unit entered failed state. systemd[1]: vsftpd at multi-user.service: Failed with result 'resources'.
Starting vsftpd per-connection server...
[ OK ] Started D-Bus System Message Bus.
Starting D-Bus System Message Bus...
[ OK ] Started vsftpd daemon (legacy implicit SSL).
Starting vsftpd daemon (legacy implicit SSL)...
[FAILED] Failed to start vsftpd per-connection server (legacy implicit SSL). See 'systemctl status vsftpd-ssl at multi-user.service' for details.
Starting vsftpd per-connection server (legacy implicit SSL)...

Quoted 5 lines
package/vsftpd/vsftpd.mk +5 -0
+define VSFTPD_INSTALL_INIT_SYSTEMD
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/sockets.target.wants
+
+	for f in vsftpd.service vsftpd.socket vsftpd at .service \

package/vsftpd/vsftpd.mk define VSFTPD_INSTALL_INIT_SYSV · line 64

Quoted 10 lines
package/vsftpd/vsftpd.mk +10 -0
+		vsftpd-ssl.service vsftpd-ssl.socket vsftpd-ssl at .service; do \
+		$(INSTALL) -D -m 644 package/vsftpd/$$f \
+			$(TARGET_DIR)/usr/lib/systemd/system/$$f; \
+		wanted_by="multi-user.target.wants"; \
+		if [ $${f##*.} = "socket" ]; then \
+			wanted_by="sockets.target.wants"; \
+		fi; \
+		ln -sf ../../../../usr/lib/systemd/system/$$f \
+			$(TARGET_DIR)/etc/systemd/system/$$wanted_by/$$f; \
+	done

You could also write this in pure make, though I don't know if it's really more readable:

	$(foreach f,$(wildcard package/vsftpd/*.service),\
		$(INSTALL) -D -m 644 $(f) $(TARGET_DIR)/usr/lib/systemd/system/$(notdir $(f)) && \
		ln -sf ../../../../usr/lib/systemd/system/$(notdir $(f)) \
			$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/$(notdir $(f))$(sep))
	$(foreach f,$(wildcard package/vsftpd/*.socket),\
		$(INSTALL) -D -m 644 $(f) $(TARGET_DIR)/usr/lib/systemd/system/$(notdir $(f)) && \
		ln -sf ../../../../usr/lib/systemd/system/$(notdir $(f)) \
			$(TARGET_DIR)/etc/systemd/system/sockets.target.wants/$(notdir $(f))$(sep))

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 vsftpd: Add systemd services

Hello Thomas, all

Quoted 9 lines · Thomas Petazzoni

Dear Maxime Hadjinlian,

Quoted 2 lines · Maxime Hadjinlian

The systemd services were taken from Arch Linux's repository:

https://projects.archlinux.org/svntogit/community.git/tree/trunk?h=packages/vsftpd

Can this support be submitted upstream?

I will try, I've asked how to do it on the IRC channel.

Quoted 54 lines
Quoted 2 lines

I've tested this, and it doesn't seem to work here:

Starting Serial Getty on ttyAMA0...
Starting Login Service...
systemd[1]: vsftpd at multi-user.service: Failed to run 'start' task:
Invalid argument
[FAILED] Failed to start vsftpd per-connection server.
See 'systemctl status vsftpd at multi-user.service' for details. systemd[1]: vsftpd at multi-user.service: Unit entered failed state. systemd[1]: vsftpd at multi-user.service: Failed with result 'resources'.
Starting vsftpd per-connection server...
[ OK ] Started D-Bus System Message Bus.
Starting D-Bus System Message Bus...
[ OK ] Started vsftpd daemon (legacy implicit SSL).
Starting vsftpd daemon (legacy implicit SSL)...
[FAILED] Failed to start vsftpd per-connection server (legacy implicit SSL).
See 'systemctl status vsftpd-ssl at multi-user.service' for details.
Starting vsftpd per-connection server (legacy implicit SSL)...

I'll take a look at that.

package/vsftpd/vsftpd.mk define VSFTPD_INSTALL_INIT_SYSV

Quoted 6 lines
package/vsftpd/vsftpd.mk +6 -0
+define VSFTPD_INSTALL_INIT_SYSTEMD
+     mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+     mkdir -p $(TARGET_DIR)/etc/systemd/system/sockets.target.wants
+
+     for f in vsftpd.service vsftpd.socket vsftpd at .service \
+             vsftpd-ssl.service vsftpd-ssl.socket vsftpd-ssl at .service;

do \

package/vsftpd/vsftpd.mk define VSFTPD_INSTALL_INIT_SYSV · line 64

Quoted 9 lines
package/vsftpd/vsftpd.mk +9 -0
+             $(INSTALL) -D -m 644 package/vsftpd/$$f \
+                     $(TARGET_DIR)/usr/lib/systemd/system/$$f; \
+             wanted_by="multi-user.target.wants"; \
+             if [ $${f##*.} = "socket" ]; then \
+                     wanted_by="sockets.target.wants"; \
+             fi; \
+             ln -sf ../../../../usr/lib/systemd/system/$$f \
+                     $(TARGET_DIR)/etc/systemd/system/$$wanted_by/$$f; \
+     done

You could also write this in pure make, though I don't know if it's really more readable:

        $(foreach f,$(wildcard package/vsftpd/*.service),\
                $(INSTALL) -D -m 644 $(f)
$(TARGET_DIR)/usr/lib/systemd/system/$(notdir $(f)) && \
                ln -sf ../../../../usr/lib/systemd/system/$(notdir $(f)) \

$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/$(notdir $(f))$(sep))

Quoted 8 lines
        $(foreach f,$(wildcard package/vsftpd/*.socket),\
                $(INSTALL) -D -m 644 $(f)
$(TARGET_DIR)/usr/lib/systemd/system/$(notdir $(f)) && \
                ln -sf ../../../../usr/lib/systemd/system/$(notdir $(f)) \

$(TARGET_DIR)/etc/systemd/system/sockets.target.wants/$(notdir $(f))$(sep))

I am cleary more of a shel script guy, so I prefer the shell script way,

but if the make way is preferred, I'll adapt :).

Quoted 8 lines

Best regards,

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151012/533c1256/attachment.html>