Skip to content

python3/usb_scan: Read policy rules from drop-in directory - #7253

Open
gthvn1 wants to merge 1 commit into
xapi-project:masterfrom
xcp-ng:gtn-usb-policy-dropin
Open

python3/usb_scan: Read policy rules from drop-in directory#7253
gthvn1 wants to merge 1 commit into
xapi-project:masterfrom
xcp-ng:gtn-usb-policy-dropin

Conversation

@gthvn1

@gthvn1 gthvn1 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

/etc/xensource/usb-policy.conf is owned by the RPM manager. A customer who edits it to allow/deny some USB devices loses their changes on the next RPM uprade.

usb_scan.py now also reads any *.conf files found in /etc/xensource/usb-policy.conf.d, in alphabetical order before it reads the main policy file. Since the first match wins the user rule always override the main file rule. If the drop-in dir doesn't exist, behaviour is unchanged.

Tracking-reference: XCPNG-2952

@gthvn1
gthvn1 force-pushed the gtn-usb-policy-dropin branch 2 times, most recently from d9aa4ef to 3450ee5 Compare September 7, 2026 12:13
Comment thread python3/libexec/usb_scan.py
@gthvn1
gthvn1 force-pushed the gtn-usb-policy-dropin branch 2 times, most recently from 00f0c45 to 63b619f Compare September 10, 2026 14:44
Comment thread scripts/usb-policy.conf Outdated
@gthvn1
gthvn1 force-pushed the gtn-usb-policy-dropin branch from 63b619f to e27a62a Compare September 10, 2026 14:53
/etc/xensource/usb-policy.conf is owned by the RPM manager. A customer who
edits it to allow/deny some USB devices loses their changes on the next RPM
uprade.

usb_scan.py now also reads any *.conf files found in
/etc/xensource/usb-policy.conf.d, in alphabetical order before it reads the
main policy file. Since the first match wins the user rule always override the
main file rule. If the drop-in dir doesn't exist, behaviour is unchanged.

Tracking-reference: XCPNG-2952
Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@vates.tech>

@last-genius last-genius left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR will also require changes to the specfile, could you provide an exact diff for them?

I think it should at least require lines like

%install
...
mkdir $RPM_BUILD_ROOT/etc/xapi.conf.d

%files
...
%dir /etc/xapi.conf.d

but it should be tested

@gthvn1

gthvn1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

This PR will also require changes to the specfile, could you provide an exact diff for them?

I think it should at least require lines like

%install
...
mkdir $RPM_BUILD_ROOT/etc/xapi.conf.d

%files
...
%dir /etc/xapi.conf.d

but it should be tested

what is this doing? You mean that by default if we don't do anything then "/etc/xensource/usb-policy.conf.d" is not preserved. You need to explicitly modify the RPMs ?

@gthvn1

gthvn1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

But at least I can test an upgrade and check if it is preserved or not this part is easy :)

@last-genius

Copy link
Copy Markdown
Contributor

what is this doing? You mean that by default if we don't do anything then "/etc/xensource/usb-policy.conf.d" is not preserved. You need to explicitly modify the RPMs ?

no, it's just that the directory won't exist by default. we usually pre-create these directories for users

@gthvn1

gthvn1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Oh ok got it. I will do that.

@gthvn1

gthvn1 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Are you thinking about something like xcp-ng-rpms/xapi@9383181 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants