Skip to contentSkip to conversation

proftpd: Add ftp user creation

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 proftpd: Add ftp user creation

In order to remove '/home/ftp' and the ftp user from the 'skeleton' package, we need to add the creation of the ftp users to the package so it still work out of the box (with an anonymous user).

Signed-off-by Maxime Hadjinlian <[email protected]>

---
 package/proftpd/proftpd.mk | 4 ++++
 1 file changed, 4 insertions(+)
package/proftpd/proftpd.mk +4 -0
index dec243d..d040b8c 100644
@@ -51,6 +51,10 @@ define PROFTPD_INSTALL_TARGET_CMDS
 	$(INSTALL) -m 0644 -D $(@D)/sample-configurations/basic.conf $(TARGET_DIR)/etc/proftpd.conf
 endef
 
+define PROFTPD_USERS
+	ftp -1 ftp -1 * /home/ftp - - Anonymous FTP User
+endef
+
 define PROFTPD_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 0755 package/proftpd/S50proftpd $(TARGET_DIR)/etc/init.d/S50proftpd
 endef
Signature · 1 line
2.5.3
#1 lore raw

PATCH 2/3 vsftpd: Add ftp user creation

In order to remove '/home/ftp' and the ftp user from the 'skeleton' package, we need to add the creation of the ftp users to the package so it still work out of the box (with an anonymous user).

---
 package/vsftpd/vsftpd.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
package/vsftpd/vsftpd.mk +14 -0
index 1e48264..976d397 100644
@@ -43,9 +43,22 @@ define VSFTPD_BUILD_CMDS
 		LDFLAGS="$(TARGET_LDFLAGS)" LIBS="$(VSFTPD_LIBS)" -C $(@D)
 endef
 
+define VSFTPD_USERS
+	ftp -1 ftp -1 * /home/ftp - - Anonymous FTP User
+endef
+
 define VSFTPD_INSTALL_INIT_SYSV
 	$(INSTALL) -D -m 755 package/vsftpd/S70vsftpd $(TARGET_DIR)/etc/init.d/S70vsftpd
 endef
+#
+# VSFTPD won't work if the jail directory is writable, it has to be readable
+# only
+# Otherwise you get the following error:
+# 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
+# That's why we have to chmod /home/ftp
+define VSFTPD_FIX_HOME_PERMISSIONS
+	$(INSTALL) -d -m 555 $(TARGET_DIR)/home/ftp
+endef
 
 define VSFTPD_INSTALL_TARGET_CMDS
 	$(INSTALL) -D -m 755 $(@D)/vsftpd $(TARGET_DIR)/usr/sbin/vsftpd
@@ -53,6 +66,7 @@ define VSFTPD_INSTALL_TARGET_CMDS
 		$(INSTALL) -D -m 644 $(@D)/vsftpd.conf \
 			$(TARGET_DIR)/etc/vsftpd.conf
 	$(INSTALL) -d -m 700 $(TARGET_DIR)/usr/share/empty
+	$(VSFTPD_FIX_HOME_PERMISSIONS)
 endef
 
 $(eval $(generic-package))
Signature · 1 line
2.5.3
#3 lore raw

PATCH 2/3 vsftpd: Add ftp user creation

In reply to Maxime Hadjinlian

Maxime,

package/vsftpd/vsftpd.mk define VSFTPD_BUILD_CMDS · line 61

Quoted 9 lines · Maxime Hadjinlian
package/vsftpd/vsftpd.mk +9 -0
+#
+# VSFTPD won't work if the jail directory is writable, it has to be readable
+# only
+# Otherwise you get the following error:
+# 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
+# That's why we have to chmod /home/ftp
+define VSFTPD_FIX_HOME_PERMISSIONS
+	$(INSTALL) -d -m 555 $(TARGET_DIR)/home/ftp
+endef

Can we use VSFTPD_PERMISSIONS instead ? The only drawback is that you will have to set a fixed UID/GID for ftp:ftp in VSFTPD_USERS.

Thomas

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

PATCH 2/3 vsftpd: Add ftp user creation

Maxime, All,

On 2015-10-04 15:44 +0100, Thomas Petazzoni spake thusly:

Quoted 5 lines · Maxime Hadjinlian
Quoted 4 lines
package/vsftpd/vsftpd.mk +4 -0
+#
+# VSFTPD won't work if the jail directory is writable, it has to be readable
+# only
+# Otherwise you get the following error:
Quoted 8 lines

package/vsftpd/vsftpd.mk define VSFTPD_BUILD_CMDS · line 61

Quoted 5 lines
package/vsftpd/vsftpd.mk +5 -0
+# 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
+# That's why we have to chmod /home/ftp
+define VSFTPD_FIX_HOME_PERMISSIONS
+	$(INSTALL) -d -m 555 $(TARGET_DIR)/home/ftp
+endef

Can we use VSFTPD_PERMISSIONS instead ? The only drawback is that you will have to set a fixed UID/GID for ftp:ftp in VSFTPD_USERS.

Canyoucheck if it is possible to:
- check if it is possible to create a premission table with no UID or GID, only a mode,
- if so:
- move the mkuser script call before th makedev call in fs/common.mk
- use a permission table as suggested by Thomas.

If it's not possible to not specify UID/GID in a permission table, then we'll have to do with your solution.

Thanks.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 2/3 vsftpd: Add ftp user creation

Hi Yann, all

Quoted 25 lines · Yann E. MORIN

Maxime, All,

On 2015-10-04 15:44 +0100, Thomas Petazzoni spake thusly:

Quoted 3 lines · Maxime Hadjinlian

Review

Quoted 2 lines
(quoted diff) +2 -0
+#
+# VSFTPD won't work if the jail directory is writable, it has to be

readable

Quoted 10 lines

package/vsftpd/vsftpd.mk define VSFTPD_BUILD_CMDS · line 61

Quoted 7 lines
package/vsftpd/vsftpd.mk +7 -0
+# only
+# Otherwise you get the following error:
+# 500 OOPS: vsftpd: refusing to run with writable root inside chroot()
+# That's why we have to chmod /home/ftp
+define VSFTPD_FIX_HOME_PERMISSIONS
+   $(INSTALL) -d -m 555 $(TARGET_DIR)/home/ftp
+endef

Can we use VSFTPD_PERMISSIONS instead ? The only drawback is that you will have to set a fixed UID/GID for ftp:ftp in VSFTPD_USERS.

Canyoucheck if it is possible to:
- check if it is possible to create a premission table with no UID or GID, only a mode,
- if so:
- move the mkuser script call before th makedev call in fs/common.mk
- use a permission table as suggested by Thomas.

Quoted 4 lines

If it's not possible to not specify UID/GID in a permission table, then we'll have to do with your solution.

Unfortunately, it doesn't seem to work, I get the following error:

makedevs: unknown group name: -

Quoted 17 lines

Thanks.

Regards,
Yann E. MORIN.

--

.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There
is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |
Quoted 2 lines

'------------------------------^-------^------------------^--------------------'

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20151004/2e7a1def/attachment.html>

#6 lore raw

PATCH 2/3 vsftpd: Add ftp user creation

In reply to Maxime Hadjinlian

Dear Maxime Hadjinlian,

Quoted 8 lines · Maxime Hadjinlian

In order to remove '/home/ftp' and the ftp user from the 'skeleton' package, we need to add the creation of the ftp users to the package so it still work out of the box (with an anonymous user).

---
 package/vsftpd/vsftpd.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Even though I dislike the solution as I would prefer to use the <pkg>_PERMISSIONS mechanism, I've applied this patch. I believe that the fact that we can't do this with our <pkg>_PERMISSIONS mechanism indicates a deficiency in our implementation.

Also, I've done some minor tweaks to your patch before applying:

[Thomas:
- remove the VSFTPD_FIX_HOME_PERMISSIONS variable, and simply put the additional command in VSFTPD_INSTALL_TARGET_CMDS.
- slightly tweak the comment.]

Thanks!

Thomas

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

PATCH 3/3 skeleton: Remove ftp user and /home/ftp

In reply to Maxime Hadjinlian
---
 system/skeleton/etc/group       | 1 -
 system/skeleton/etc/passwd      | 1 -
 system/skeleton/home/ftp/.empty | 0
 3 files changed, 2 deletions(-)
 delete mode 100644 system/skeleton/home/ftp/.empty
system/skeleton/etc/group +0 -1
index c1dc11f..ba20e90 100644
@@ -21,6 +21,5 @@ plugdev:x:46:
 staff:x:50:
 lock:x:54:
 netdev:x:82:
-ftp:x:83:
 nogroup:x:99:
 users:x:100:
system/skeleton/etc/passwd +0 -1
index 3a80341..883265a 100644
@@ -6,5 +6,4 @@ sync:x:4:100:sync:/bin:/bin/sync
 mail:x:8:8:mail:/var/spool/mail:/bin/false
 www-data:x:33:33:www-data:/var/www:/bin/false
 operator:x:37:37:Operator:/var:/bin/false
-ftp:x:83:83:ftp:/home/ftp:/bin/false
 nobody:x:99:99:nobody:/home:/bin/false
system/skeleton/home/ftp/.empty deleted +0 -0
deleted file mode 100644
index e69de29..0000000
Signature · 1 line
2.5.3
#9 lore raw

PATCH 3/3 skeleton: Remove ftp user and /home/ftp

In reply to Maxime Hadjinlian

Dear Maxime Hadjinlian,

Quoted 7 lines · Maxime Hadjinlian
---
 system/skeleton/etc/group       | 1 -
 system/skeleton/etc/passwd      | 1 -
 system/skeleton/home/ftp/.empty | 0
 3 files changed, 2 deletions(-)
 delete mode 100644 system/skeleton/home/ftp/.empty

Applied, thanks.

Thomas

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

PATCH 1/3 proftpd: Add ftp user creation

In reply to Maxime Hadjinlian

Dear Maxime Hadjinlian,

Quoted 8 lines · Maxime Hadjinlian

In order to remove '/home/ftp' and the ftp user from the 'skeleton' package, we need to add the creation of the ftp users to the package so it still work out of the box (with an anonymous user).

Signed-off-by Maxime Hadjinlian <[email protected]>

---
 package/proftpd/proftpd.mk | 4 ++++
 1 file changed, 4 insertions(+)

Applied, thanks.

Thomas

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