Skip to contentSkip to conversation

iputils: set the permissions with IPUTILS_PERMISSIONS

PATCH New Petr Vorel 3 participants 13 messages Jun 9, 2019 – Jun 19, 2019

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

for arping, clockdiff and ping. These require root permission for socket(). Upstream solution (script setcap-setuid.sh) requires setcap binary on the host and cap_net_raw+ep + libcap or setting setuid root executable which is dangerous).

This restores behavior used for version s20180629 (which was used for ping and traceroute6, but we don't build traceroute6 since s20190515).

---
Hi,

it'd be great also create symlink ping -> ping6, but don't know how.

Kind regards,
Petr

---
 package/iputils/iputils.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/iputils/iputils.mk +8 -0
index d9a51ece2a..8be54b4788 100644
@@ -52,4 +52,12 @@ endif
 # XSL Stylesheets for DocBook 5 not packaged for buildroot
 IPUTILS_CONF_OPTS += -DBUILD_MANS=false -DBUILD_HTML_MANS=false
 
+# handle permissions ourselves
+IPUTILS_CONF_OPTS += -DNO_SETCAP_OR_SUID=true
+define IPUTILS_PERMISSIONS
+	/bin/arping      f 4755 0 0 - - - - -
+	/bin/clockdiff   f 4755 0 0 - - - - -
+	/bin/ping        f 4755 0 0 - - - - -
+endef
+
 $(eval $(meson-package))
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Quoted 9 lines · Petr Vorel

for arping, clockdiff and ping. These require root permission for socket(). Upstream solution (script setcap-setuid.sh) requires setcap binary on the host and cap_net_raw+ep + libcap or setting setuid root executable which is dangerous).

This restores behavior used for version s20180629 (which was used for ping and traceroute6, but we don't build traceroute6 since s20190515).

Applied to master, thanks. I updated the commit message a little.

Quoted 4 lines

---
Hi,

it'd be great also create symlink ping -> ping6, but don't know how.

This can be done with a post-install hook.

Also, the bump to s20190515 should not have removed the traceroute6 program.
Could you make a second patch that adds it back?

Regards,
Arnout

Quoted 25 lines

Kind regards,
Petr

---
 package/iputils/iputils.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/iputils/iputils.mk +8 -0
index d9a51ece2a..8be54b4788 100644
@@ -52,4 +52,12 @@ endif
 # XSL Stylesheets for DocBook 5 not packaged for buildroot
 IPUTILS_CONF_OPTS += -DBUILD_MANS=false -DBUILD_HTML_MANS=false
 
+# handle permissions ourselves
+IPUTILS_CONF_OPTS += -DNO_SETCAP_OR_SUID=true
+define IPUTILS_PERMISSIONS
+	/bin/arping      f 4755 0 0 - - - - -
+	/bin/clockdiff   f 4755 0 0 - - - - -
+	/bin/ping        f 4755 0 0 - - - - -
+endef
+
 $(eval $(meson-package))
author
#2 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Hi Arnout,

Quoted 1 line

Applied to master, thanks. I updated the commit message a little.

Thanks! You've been faster, I might try to think about setcap (xattr) use if USE_CAP=true, and setuid if USE_CAP=false. Is there an easy way to detect iso9660 usage? (+ setcap being available on host).
I'm not aware any other xattr limitations thatn iso9660.

Quoted 3 lines
Quoted 1 line

it'd be great also create symlink ping -> ping6, but don't know how.

This can be done with a post-install hook.

Thanks, I'll do it in separate patch sometimes this week.

Quoted 2 lines

Also, the bump to s20190515 should not have removed the traceroute6 program.
Could you make a second patch that adds it back?

Sure, I'll try to do it this week.

Quoted 2 lines

Regards,
Arnout

Kind regards,
Petr

#3 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Quoted 5 lines · Petr Vorel

Hi Arnout,

Quoted 1 line

Applied to master, thanks. I updated the commit message a little.

Thanks! You've been faster, I might try to think about setcap (xattr) use if USE_CAP=true, and setuid if USE_CAP=false.

Great!

Quoted 2 lines

Is there an easy way to detect
iso9660 usage?

BR2_TARGET_ROOTFS_ISO9660 of course. Well, that one is special actually because
in case of BR2_TARGET_ROOTFS_INITRAMFS or BR2_TARGET_ROOTFS_ISO9660_INITRD, the rootfs is not actually stored in the iso9660.

But I don't know which other filesystems lack support for xattrs.

So maybe just assume the filesystem supports xattrs, we can fix things later if
needed.

Quoted 1 line

(+ setcap being available on host).

setcap can't be used, since setting xattrs can only be done by root and we're
not root while building. It could be used when running in a fakeroot environment, but I believe fakeroot is a bit flakey when it comes to capabilities. So the appropriate xattrs should instead be set with IPUTILS_PERMISSIONS.

Regards,
Arnout

Quoted 17 lines

I'm not aware any other xattr limitations thatn iso9660.

Quoted 3 lines
Quoted 1 line

it'd be great also create symlink ping -> ping6, but don't know how.

This can be done with a post-install hook.

Thanks, I'll do it in separate patch sometimes this week.

Quoted 2 lines

Also, the bump to s20190515 should not have removed the traceroute6 program.
Could you make a second patch that adds it back?

Sure, I'll try to do it this week.

Quoted 2 lines

Regards,
Arnout

Kind regards,
Petr

#4 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 5 lines · Petr Vorel

Hi Arnout,

Quoted 1 line

Applied to master, thanks. I updated the commit message a little.

Thanks! You've been faster, I might try to think about setcap (xattr) use if USE_CAP=true, and setuid if USE_CAP=false.

Great!

Quoted 8 lines
Quoted 2 lines

Is there an easy way to detect
iso9660 usage?

BR2_TARGET_ROOTFS_ISO9660 of course. Well, that one is special actually because
in case of BR2_TARGET_ROOTFS_INITRAMFS or BR2_TARGET_ROOTFS_ISO9660_INITRD, the rootfs is not actually stored in the iso9660.

But I don't know which other filesystems lack support for xattrs.

axfs, cramfs, romfs and yaffs2 as well afaik.

Signature · 1 line
Bye, Peter Korsgaard
author
#5 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Hi Peter,

Quoted 10 lines
Quoted 8 lines
Quoted 2 lines

Is there an easy way to detect
iso9660 usage?

BR2_TARGET_ROOTFS_ISO9660 of course. Well, that one is special actually because
in case of BR2_TARGET_ROOTFS_INITRAMFS or BR2_TARGET_ROOTFS_ISO9660_INITRD, the rootfs is not actually stored in the iso9660.

But I don't know which other filesystems lack support for xattrs.

axfs, cramfs, romfs and yaffs2 as well afaik.

Thanks a lot.

I guess BR2_TARGET_ROOTFS_TAR (and other tarballs supported) supports xattrs (--xattrs-include='*' in fs/tar/tar.mk).

It'd be nice if buildroot has BR2_TARGET_ROOTFS_HAS_XATTRS.

Kind regards,
Petr

#6 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Petr" == Petr Vorel <[email protected]> writes:

Hi Peter,

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Is there an easy way to detect
iso9660 usage?

BR2_TARGET_ROOTFS_ISO9660 of course. Well, that one is special actually because
in case of BR2_TARGET_ROOTFS_INITRAMFS or BR2_TARGET_ROOTFS_ISO9660_INITRD, the rootfs is not actually stored in the iso9660.

But I don't know which other filesystems lack support for xattrs.

Quoted 7 lines
Quoted 1 line

axfs, cramfs, romfs and yaffs2 as well afaik.

Thanks a lot.

I guess BR2_TARGET_ROOTFS_TAR (and other tarballs supported) supports xattrs (--xattrs-include='*' in fs/tar/tar.mk).

It'd be nice if buildroot has BR2_TARGET_ROOTFS_HAS_XATTRS.

The problem is that you can enable several rootfs formats at the same time (E.G. tar and cramfs), so we would need to only use xattrs if no file system without xattrs support is enabled.

And things would break if you do a build with E.G. only tar rootfs support and then afterwards enable cramfs without doing a clean rebuild - Yes, I know you are not supposed to do that, but it does happen.

Signature · 1 line
Bye, Peter Korsgaard
author
#7 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Hi Peter,

Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Is there an easy way to detect
iso9660 usage?

BR2_TARGET_ROOTFS_ISO9660 of course. Well, that one is special actually because
in case of BR2_TARGET_ROOTFS_INITRAMFS or BR2_TARGET_ROOTFS_ISO9660_INITRD, the rootfs is not actually stored in the iso9660.

But I don't know which other filesystems lack support for xattrs.

Quoted 7 lines
Quoted 1 line

axfs, cramfs, romfs and yaffs2 as well afaik.

Thanks a lot.

I guess BR2_TARGET_ROOTFS_TAR (and other tarballs supported) supports xattrs (--xattrs-include='*' in fs/tar/tar.mk).

It'd be nice if buildroot has BR2_TARGET_ROOTFS_HAS_XATTRS.

Quoted 8 lines

The problem is that you can enable several rootfs formats at the same time (E.G. tar and cramfs), so we would need to only use xattrs if no file system without xattrs support is enabled.

And things would break if you do a build with E.G. only tar rootfs support and then afterwards enable cramfs without doing a clean rebuild - Yes, I know you are not supposed to do that, but it does happen.

Thanks for detailed info. I guess in that case is setuid really the only option.

Kind regards,
Petr

#8 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Quoted 22 lines · Petr Vorel

Hi Peter,

Quoted 20 lines
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines

Is there an easy way to detect
iso9660 usage?

BR2_TARGET_ROOTFS_ISO9660 of course. Well, that one is special actually because
in case of BR2_TARGET_ROOTFS_INITRAMFS or BR2_TARGET_ROOTFS_ISO9660_INITRD, the rootfs is not actually stored in the iso9660.

But I don't know which other filesystems lack support for xattrs.

Quoted 7 lines
Quoted 1 line

axfs, cramfs, romfs and yaffs2 as well afaik.

Thanks a lot.

I guess BR2_TARGET_ROOTFS_TAR (and other tarballs supported) supports xattrs (--xattrs-include='*' in fs/tar/tar.mk).

It'd be nice if buildroot has BR2_TARGET_ROOTFS_HAS_XATTRS.

The problem is that you can enable several rootfs formats at the same time (E.G. tar and cramfs), so we would need to only use xattrs if no file system without xattrs support is enabled.

So maybe we could add a system option BR2_SYSTEM_XATTR that enables the use of
xattr.

Currently we have nothing using xattr, but there are quite a few packages that
could benefit from it, e.g. libpcap, and SELinux stuff.

We could use that option to enable xattr instead of setuid where relevant, and
to disable filesystems that don't support xattr.

Quoted 4 lines
Quoted 4 lines

And things would break if you do a build with E.G. only tar rootfs support and then afterwards enable cramfs without doing a clean rebuild - Yes, I know you are not supposed to do that, but it does happen.

I don't think we need to worry about that. But actually, with the
BR2_SYSTEM_XATTR option, it would even work since it's only taken into account during finalize.

Quoted 1 line

Thanks for detailed info. I guess in that case is setuid really the only option.

It isn't, but the alternatives are a lot of work :-)

Regards,
Arnout

author
#9 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Hi Arnout,

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

It'd be nice if buildroot has BR2_TARGET_ROOTFS_HAS_XATTRS.

The problem is that you can enable several rootfs formats at the same time (E.G. tar and cramfs), so we would need to only use xattrs if no file system without xattrs support is enabled.

So maybe we could add a system option BR2_SYSTEM_XATTR that enables the use of
xattr.

+1

Quoted 2 lines

Currently we have nothing using xattr, but there are quite a few packages that
could benefit from it, e.g. libpcap, and SELinux stuff.

And IMA+EVM kernel features.

Quoted 9 lines

We could use that option to enable xattr instead of setuid where relevant, and
to disable filesystems that don't support xattr.

Quoted 4 lines
Quoted 4 lines

And things would break if you do a build with E.G. only tar rootfs support and then afterwards enable cramfs without doing a clean rebuild - Yes, I know you are not supposed to do that, but it does happen.

Quoted 8 lines

I don't think we need to worry about that. But actually, with the
BR2_SYSTEM_XATTR option, it would even work since it's only taken into account during finalize.

Quoted 1 line

Thanks for detailed info. I guess in that case is setuid really the only option.

It isn't, but the alternatives are a lot of work :-)

:-). Do you plan to work on it? If not, I might do in next few weeks (I'm quite busy during summer).

Quoted 2 lines

Regards,
Arnout

Kind regards,
Petr

#10 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Quoted 30 lines · Petr Vorel

Hi Arnout,

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

It'd be nice if buildroot has BR2_TARGET_ROOTFS_HAS_XATTRS.

The problem is that you can enable several rootfs formats at the same time (E.G. tar and cramfs), so we would need to only use xattrs if no file system without xattrs support is enabled.

So maybe we could add a system option BR2_SYSTEM_XATTR that enables the use of
xattr.

+1

Quoted 2 lines

Currently we have nothing using xattr, but there are quite a few packages that
could benefit from it, e.g. libpcap, and SELinux stuff.

And IMA+EVM kernel features.

Quoted 12 lines

We could use that option to enable xattr instead of setuid where relevant, and
to disable filesystems that don't support xattr.

Quoted 4 lines
Quoted 4 lines

And things would break if you do a build with E.G. only tar rootfs support and then afterwards enable cramfs without doing a clean rebuild - Yes, I know you are not supposed to do that, but it does happen.

I don't think we need to worry about that. But actually, with the
BR2_SYSTEM_XATTR option, it would even work since it's only taken into account during finalize.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Thanks for detailed info. I guess in that case is setuid really the only option.

It isn't, but the alternatives are a lot of work :-)

:-). Do you plan to work on it? If not, I might do in next few weeks (I'm quite busy during summer).

I don't do any work myself, I just occasionally apply patches :-) And I think
for Peter it's pretty much the same thing.

Regards,
Arnout

author
#11 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

Hi Arnout,

...

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Thanks for detailed info. I guess in that case is setuid really the only option.

It isn't, but the alternatives are a lot of work :-)

:-). Do you plan to work on it? If not, I might do in next few weeks (I'm quite busy during summer).

I don't do any work myself, I just occasionally apply patches :-) And I think
for Peter it's pretty much the same thing.

Thanks for info. Adding into my todo list :)

Quoted 2 lines

Regards,
Arnout

Kind regards,
Petr

#12 lore raw

PATCH 1/1 iputils: set the permissions with IPUTILS_PERMISSIONS

In reply to Arnout Vandecappelle
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Hi,

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

It isn't, but the alternatives are a lot of work :-)

:-). Do you plan to work on it? If not, I might do in next few weeks (I'm quite busy during summer).

I don't do any work myself, I just occasionally apply patches :-) And I think
for Peter it's pretty much the same thing.

I do actual development once in a while ;) - But I also don't have any immediate plans for working on improving our xattrs support.

Signature · 1 line
Bye, Peter Korsgaard