-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support automatic attachment of export devices #324
Conversation
it also looks like this attaches drives that are not encrypted right? just want to double check |
That's right; it attaches any storage or printer device. The script invoked by the udev rule could check the partition table and label, but they're supposed to be quick. Also, I'm not sure how we'd surface any errors in a nice way. I think it's better to do any validation in |
00efe43
to
a26c547
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rmol , I've experienced some issues in testing these changes: the files were actually copied in dom0
instead of sys-usb
. I have a theory for a fix, see comment inline.
Perhaps adding tests similar to https://github.com/freedomofpress/securedrop-workstation/blob/307-udev-export-devices/tests/test_sd_export.py#L12 would help ensure that the files are present on the correct VMs and prevent regressions during development.
Another improvement we should consider before merging is having the ability to remove these udev rules, in the case where the workstation for development, by perhaps creating a make remove-sys-usb
or equivalent target. What do you think?
Corrected the target in the Parroted the Qubes YubiKey configuration you found to get the udev rules to survive reboots. I'm not sure yet how best to undo this config. In addition to just removing it from |
good point, hadn't thought of that. We may need to handle this through conditional logic, maybe in an env var or config.json?. |
Also relevant:
So it sounds like we do need a more robust "clean" action. For instance, we leave the |
In my mind this is still a lot of code + configuration to maintain for auto attach. Doing it via Here we are adding a complete new qrexec service and we will have to manage the config etc. Also, we have things depending on |
See #337. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rmol for the changes, this works as expected. Tested as follows using the following steps, based on your test plan:
- (
make clean
)make all
andmake test
, all tests pass sys-usb
reboots are handled correctly: the attachment still works- When a device is connected,
sys-usb
startssd-export-usb
- Drives are not automounted
- Non printer/storage devices aren't connected: a mouse or keyboard, for example are not autoattached
- export to usb works as expected
There is one edge case (that will likely not happen is real-life scenarios, since sys-usb
is set to autostart): If sys-usb
is rebooted with a USB device connected to it, the rule will not file as sys-usb
is restarted, the device needs to be attached and detached. In those cases, The client requests the user to attach a device, Since the preflight checks return USB_NOT_CONNECTED
, I don't think it's worth addressing as part of this PR.
@kushaldas I brought up the issue you've raised in #159 (comment) , we can continue the discussion there and perhaps track any tests/code/results in that ticket from now on. Your findings and proof of concept will be especially helpful for the more general admin actions
There's also an issue with the Qubes USB Widget, that was raised in the November 14th engineering meeting (thanks @redshiftzero for flagging):
Manually running |
Dismissing for now to investigate/discuss #324 (comment)
@emkll Thanks. I'll need to investigate the boot-time udev handling. The problem with the devices widget seems to be that it isn't receiving or responding to the |
Another side effect of the changes introduced here that I forgot to note, is the increased likelihood of having multiple relevant (mass storage or printer) devices connected. We already do have an issue to track this: freedomofpress/securedrop-export#25 |
I tested this today and the auto-attachment logic is working nicely for me. I can reproduce that the devices widget currently used in qubes does not reflect the auto-attachment of USBs to our sd-export-usb VM, but regarding the last issue, @rmol has some wip resolving the issue (this branch currently has some experimental UI updates) in the qubes devices widget which resolves for me (next step is he's going to make a PR upstream). If anyone wants to test or make changes to the devices widget here's instructions on how to get started:
|
PR for the devices widget: QubesOS/qubes-desktop-linux-manager#87 |
df2f0bc
to
17f4c92
Compare
Due to changes in #387, this will need to be rebased on latest master. We should also deny-by-default outbound USB policies ( Upstream fix for the device widget will be released in qubes-usb-proxy 1.0.23 which is still currently in testing repos. |
27a4d34
to
a3638c4
Compare
Rebased, outbound denial added to policies. |
97cfc26
to
e36da80
Compare
I rebased, updated the naming, it seems to be working fine and in about a week the Qubes devices widget should be correctly showing the state of automatically attached devices. |
The upstream fix has made it to stable. |
e36da80
to
d791984
Compare
Add udev rules and scripts to sys-usb. Modify the qubes.USB RPC policy, and add qubes.USBAttach.
d791984
to
3703bd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pleased to report that usb autoattach is working as expected with up-to-date dom0 🎉 . Thank you for your patience on this. I have two small request before this is ready to merge, from my perspective:
make clean
currently does not remove the udev rules in sys-usb. I recommend we remove those configurations as part of thesd-cleanup-sys-firewall
task here. This behavior was changed after this PR was initially opened.- explicitly set permissions in rpm spec (see comment inline)
Two other (for discussion, let me know what you think)
- The makefile target
sys-usb
sounds confusing to me, I would recommendusb-autoattach
or something of the sort. - Should we have a
remove-
target? The current behavior, based on my local testing has not been annoying/invasive at all, but can you think of any situations where a user would want to disable autoattach?
Good catches and suggestions. I:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rmol , changes look great!
I've tested with 4 devices:
- 2 usb flash drives, they autoattach
- 1 yubikey, does not attach
- 1 printer, it auto-attaches
- Export and print work as expected
- Device is marked as attached by the GUI tool
- They can be re-attached using the GUI tool
-
make {add, remove}-usb-autoattach
work as expected (see comments inline, shouldn't block merge, imo but let me know what you think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the existing install scenario:
- make clone on this branch
- make add-usb-autoattach
- make test
✔️ autoattach works
✔️ all tests pass
Great work @rmol !
Support automatic attachment of export devices
Adds udev rules and scripts to
sys-usb
. Modifies the qubes.USB RPC policy and adds qubes.USBAttach.Testing
dom0
:make clone
make clean && make all
/etc/qubes-rpc/policy/qubes.USB
contains:/etc/qubes-rpc/policy/qubes.USBAttach
contains:sys-usb
, confirm the existence of:/etc/udev/rules.d/99-sd-export-usb.rules
/usr/local/bin/sd-attach-export-disk
/usr/local/bin/sd-attach-export-printer
Plug in a valid LUKS export stick. It should be automatically attached to
sd-export-usb
, and an export from the client or manually viaqvm-open-in-vm sd-export-usb "filename"
should succeed.