darrylb123 / usbrelay

Control usb relay - based on hidapi
GNU General Public License v2.0
316 stars 98 forks source link

Debian changes #87

Closed wentasah closed 2 years ago

wentasah commented 2 years ago

Hi, this PR contains a few changes that resulted from packaging the recent version for Debian. Most of them should be harmless.

But commit fee8cdffe7ae296e490eea4561dfad070b631087 might affect other distributions. With it it is not necessary to create a special user for running usbrelayd. The user is created automatically by systemd only when needed and removed when unneeded. On Debian, which uses plugdev group for accessing plugable devices, this means that neither the user nor the group has to be created statically. On distributions without plugdev group (Fedora? cc @mefuller), the group still needs to be created but the user needs not. And because DynamicUser in systemd requires that either both user and group are statically created or they both do not exist, we run the service under a different (dynamically created) user called usbrelayd (with d at the end). This could theoretically break some advanced setups, but I believe it is unlikely.

darrylb123 commented 2 years ago

This all looks good. I have copied it to Mark to see what he thinks. I'll test DynamicUser before merging as I've never used it before. If the group is created in Fedora then this should be seamless. Won't the group be plugdev on Debian?

Darryl

On Thu, May 5, 2022 at 7:37 AM Michal Sojka @.***> wrote:

Hi, this PR contains a few changes that resulted from packaging the recent version for Debian. Most of them should be harmless.

But commit fee8cdf https://github.com/darrylb123/usbrelay/commit/fee8cdffe7ae296e490eea4561dfad070b631087 might affect other distributions. With it it is not necessary to create a special user for running usbrelayd. The user is created automatically by systemd only when needed and removed when unneeded. On Debian, which uses plugdev group for accessing plugable devices, this means that neither the user nor the group has to be created statically. On distributions without plugdev group (Fedora? cc @mefuller https://github.com/mefuller), the group still needs to be created but the user needs not. And because DynamicUser in systemd requires https://www.freedesktop.org/software/systemd/man/systemd.exec.html#DynamicUser= that either both user and group are statically created or they both do not exist, we run the service under a different (dynamically created) user called usbrelayd (with d at the end). This could theoretically break some advanced setups, but I believe it is unlikely.

You can view, comment on, or merge this pull request online at:

https://github.com/darrylb123/usbrelay/pull/87 Commit Summary

File Changes

(4 files https://github.com/darrylb123/usbrelay/pull/87/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/usbrelay/pull/87, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVM5ZZNCPBALWDUUXNDVILUYZANCNFSM5VDIWRSA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

darrylb123 commented 2 years ago

Ok, Dynamic user shows the process thus on Fedora: usbrela+ 2312 1 0 16:34 ? 00:00:00 /usr/bin/python3 /usr/sbin/usbrelayd

The udev rule sets the group to usbrelay as expected: crw-rw----. 1 root usbrelay 241, 1 May 5 16:34 /dev/hidraw1

I shall merge it once Mark agrees.

Darryl

On Thu, May 5, 2022 at 4:30 PM Darryl Bond @.***> wrote:

This all looks good. I have copied it to Mark to see what he thinks. I'll test DynamicUser before merging as I've never used it before. If the group is created in Fedora then this should be seamless. Won't the group be plugdev on Debian?

Darryl

On Thu, May 5, 2022 at 7:37 AM Michal Sojka @.***> wrote:

Hi, this PR contains a few changes that resulted from packaging the recent version for Debian. Most of them should be harmless.

But commit fee8cdf https://github.com/darrylb123/usbrelay/commit/fee8cdffe7ae296e490eea4561dfad070b631087 might affect other distributions. With it it is not necessary to create a special user for running usbrelayd. The user is created automatically by systemd only when needed and removed when unneeded. On Debian, which uses plugdev group for accessing plugable devices, this means that neither the user nor the group has to be created statically. On distributions without plugdev group (Fedora? cc @mefuller https://github.com/mefuller), the group still needs to be created but the user needs not. And because DynamicUser in systemd requires https://www.freedesktop.org/software/systemd/man/systemd.exec.html#DynamicUser= that either both user and group are statically created or they both do not exist, we run the service under a different (dynamically created) user called usbrelayd (with d at the end). This could theoretically break some advanced setups, but I believe it is unlikely.

You can view, comment on, or merge this pull request online at:

https://github.com/darrylb123/usbrelay/pull/87 Commit Summary

File Changes

(4 files https://github.com/darrylb123/usbrelay/pull/87/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/usbrelay/pull/87, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVM5ZZNCPBALWDUUXNDVILUYZANCNFSM5VDIWRSA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

wentasah commented 2 years ago

Won't the group be plugdev on Debian?

Yes, it will. We will patch it in Debian-specific patches like this: https://salsa.debian.org/wentasah/usbrelay/-/blob/master/debian/patches/0003-Use-DynamicUser-for-usbrelayd.service.patch Since other distros might already use the usbrelay group, I don't want to break it for them.

-Michal

darrylb123 commented 2 years ago

Mark created an rpm directory, I'll create a deb directory for the debian stuff. The patches can go there.

wentasah commented 2 years ago

Mark created an rpm directory, I'll create a deb directory for the debian stuff. The patches can go there.

I don't think it's necessary to create a separate directory. The files in this PR would be useful for all distributions (if they are interested). I think that with this merged, Debian will need just a single patch changing usbrelay group to plugdev. And this does not need to live here.

I've got access to https://salsa.debian.org/debian/usbrelay, which is the official source of debian packaging. It's also planned that I will become "uploader" for the usbrelay package so future releases should appear in Debian faster than now.

mefuller commented 2 years ago

Great - I was just about to give my approval here Thanks all

darrylb123 commented 2 years ago

Ok, sounds good.

On Sat, May 7, 2022 at 3:28 AM Mark E Fuller @.***> wrote:

Great - I was just about to give my approval here Thanks all

— Reply to this email directly, view it on GitHub https://github.com/darrylb123/usbrelay/pull/87#issuecomment-1119836686, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTSUVNPCJXRVY27XS2PGQDVIVJCBANCNFSM5VDIWRSA . You are receiving this because you modified the open/close state.Message ID: @.***>