Skip to content
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

Keepassx fails to compile on FreeBSD due to libusb implementation differences #10736

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Keepassx fails to compile on FreeBSD due to libusb implementation differences #10736

merged 3 commits into from
Jun 19, 2024

Conversation

madpilot78
Copy link
Contributor

On FreeBSD the libusb_hotplug_register_callback() function uses a pointer to a struct as an handle.

I'm changing the methods to use this as expected by the system library.

This now compiles fine but fails at runtime.

Not sure why this patch is not working and I must admit I do not understand what is being done using qintptr in

typedef qintptr Handle;
.

This has been noticed here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277652

The failures with my patch are described here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277652#c10

I do not have a yubikey so I cannot do testing myself.

Thanks in advance for any help!

Testing strategy

As said, with this changes the source compiles on FreeBSD, and the resulting binary works, except when exercising the modified code.

Type of change

  • ✅ Bug fix (non-breaking change that fixes an issue)

@madpilot78 madpilot78 marked this pull request as draft May 11, 2024 21:18
@madpilot78 madpilot78 changed the title Keepassx fails ti compile on FReeBSD due to libusb implementation differences Keepassx fails ti compile on FreeBSD due to libusb implementation differences May 11, 2024
Copy link
Member

@phoerious phoerious left a comment

Choose a reason for hiding this comment

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

Instead of adding all the ifdefs, you should cast libusb_hotplug_callback_handle to qintptr instead. This should already be an opaque pointer type that needs no additional logic.

@madpilot78 madpilot78 changed the title Keepassx fails ti compile on FreeBSD due to libusb implementation differences Keepassx fails to compile on FreeBSD due to libusb implementation differences May 12, 2024
@madpilot78
Copy link
Contributor Author

@phoerious Thanks for the feedback!

So, if I understand correctly, there is an existing bug in the code that uses ints where it should be using qintptr. This makes some sense to me, now I can understand why qintptr was used to start with.

I'll do some testing hoping I can make sense of all this.

Thanks again for your suggestions.

@phoerious
Copy link
Member

On a normal 64 bit system it shouldn't make a difference, but with smaller word lengths it may.

@madpilot78
Copy link
Contributor Author

@phoerious Problem is, the code as is fails to compile on FreeBSD. FreeBSD is using recent clang by default, which tends to be less permissive about this kind of casts.

Putting the correct types in the correct place should be enough to make it compile and work then.

On FreeBSD the libusb_hotplug_register_callback() function uses a
pointer to a struct as an handle.

I'm changing the methods to use this as expected by the system library.

This now compiles fine but fails at runtime.
@madpilot78
Copy link
Contributor Author

Hi again,

I experimented a little but made little progress.

I uploaded what I have now, following suggestion to use qintptr.

This fails to compile. If I use classic C style casts in place of static_cast it does compile but fails at runtime.

I'm asking for help on how to fix this. My limited C++ knowledge has already reached its limit.

Thanks in advance.

@droidmonkey droidmonkey added this to the v2.7.9 milestone May 22, 2024
@droidmonkey
Copy link
Member

@phoerious what do you want to do here?

@madpilot78
Copy link
Contributor Author

For completeness, these bugs have been created regarding FreeBSD:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277799

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279556

But they apply to base system and resolution cannot be fast, most probably nothing can get released before the next major release at the earliest.

@phoerious
Copy link
Member

phoerious commented Jun 17, 2024

I've pushed a commit that should make it work on both Linux and FreeBSD, though I cannot test the latter. If it works, we should rebase and squash the commits.

Do you know whether any other *BSD will be affected as well? I checked OpenBSD, but they don't seem to have a custom libusb in their tree.

@phoerious phoerious marked this pull request as ready for review June 17, 2024 11:44
@droidmonkey
Copy link
Member

Looks reasonable to me

@madpilot78
Copy link
Contributor Author

@phoerious Thanks a lot for your patch!

I've compiled and am running keepassxc with it locally, it works fine, but I am unable to test the USB functionality.

I've posted a patch against the ports tree including your patch so others can test on FreeBSD, I hope to have feedback in a few days at most.

@phoerious
Copy link
Member

You should be able to test it to some degree even without a YubiKey. Open two tabs and switch between them. You should see a green progress bar appear for a short time below the password field. If that's the case and the app doesn't crash, it most likely works.

@madpilot78
Copy link
Contributor Author

@phoerious

I performed a quick test you suggest by creating a new DB. Unluckily changing tabs causes a lockup of the program, I am unable to do anything else. I need to kill it with xkill.

@phoerious
Copy link
Member

That is strange, though probably not related to this change. It may, however, be a problem with that libusb implementation.

@droidmonkey droidmonkey merged commit f4b91c1 into keepassxreboot:develop Jun 19, 2024
11 checks passed
droidmonkey pushed a commit that referenced this pull request Jun 19, 2024
Change type of Handle on FreeBSD. On FreeBSD the libusb_hotplug_register_callback() function uses a pointer to a struct as a handle.

---------

Co-authored-by: Janek Bevendorff <[email protected]>
libf-de pushed a commit to libf-de/keepassxc-secretservice-dbus that referenced this pull request Jun 20, 2024
Release 2.7.9

* Passkeys: Ability to easily remove a passkey from an entry [keepassxreboot#10777]
* Snap: Use new desktop portal for native messaging integration [keepassxreboot#10906]

* Improve entry placeholder/reference feature [keepassxreboot#10846]
* Improve CSV importing when title field isn't specified [keepassxreboot#10843]
* Improve encrypted Bitwarden importing [keepassxreboot#10800]
* Improve database settings UX [keepassxreboot#10821]
* Improve handling of clipboard actions from entry preview [keepassxreboot#10810]
* Improve group/entry view resize behavior and set sensible defaults [keepassxreboot#10641]
* Passkeys: Fix incorrect username fill [keepassxreboot#10874]
* Passkeys: Return additional data to the extension [keepassxreboot#10857]
* Fix password clear timer inconsistency on unlock view [keepassxreboot#10708]
* Fix portability check [keepassxreboot#10760]
* Fix page overflow on HTML exports [keepassxreboot#10735]
* Fix broken builds when using system provided zxcvbn [keepassxreboot#10717]
* Fix copy password button when text is selected [keepassxreboot#10853]
* Fix tab ordering on application settings pages [keepassxreboot#10907]
* SSH Agent: Fix broken decrypt button [keepassxreboot#10638]
* Windows: Fix ALT Auto-Type modifier [keepassxreboot#10795]
* Windows: Fix wrong DACL memory size allocation [keepassxreboot#10712]
* macOS: Fix monospace font sizing [keepassxreboot#10739]
* Flatpak: Fix configuration settings off-by-one error [keepassxreboot#10688]
* BSD: Fix compiling with libusb implementation [keepassxreboot#10736]

# -----BEGIN PGP SIGNATURE-----
#
# iQEzBAABCAAdFiEENIkEDB8MPuq41ValRA/GXy4MbgEFAmZzTogACgkQRA/GXy4M
# bgHahggAg+hzMTiM0uDaw5yfxhv6GEfQQBPHMhX3JDyHEC+i7Pq6OjlxQkdUrRdu
# f4w74od5jSul0Al/ehu9L2eZwNPMnU87FWDn16o1btYHsG9n24v5S0DuQoLXUjde
# Y9nJNKeRNoWAlVKWbUG2YGvy9hF9YbtrFaiBksaQ+g3w8Xz82PzLY0VaUu4Xa/LO
# RXAhryJC+8T3T479dXpHxJcUmEWkoY4bqj1i6R8tEK5Kz9y1c0kqzqwWysKMj+rD
# WxTb2V4y9s57pO35zt9yxMLg66xx9bdcQHbSULa2vZNMFd9qdqk8WJmWFle112yG
# UCBXv2ZIjd3lghPt0IrD+WKcuL85Aw==
# =rbfs
# -----END PGP SIGNATURE-----
# gpg: directory '/home/runner/.gnupg' created
# gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
# gpg: Signature made Wed Jun 19 21:32:56 2024 UTC
# gpg:                using RSA key 3489040C1F0C3EEAB8D556A5440FC65F2E0C6E01
# gpg: Can't check signature: No public key
@madpilot78 madpilot78 deleted the fix/FreeBSD-libusb branch June 21, 2024 19:40
pull bot pushed a commit to tigerwill90/keepassxc that referenced this pull request Jun 23, 2024
Change type of Handle on FreeBSD. On FreeBSD the libusb_hotplug_register_callback() function uses a pointer to a struct as a handle.

---------

Co-authored-by: Janek Bevendorff <[email protected]>
Perlover added a commit to Perlover/keepassxc that referenced this pull request Jul 24, 2024
Release 2.7.9

* Passkeys: Ability to easily remove a passkey from an entry [keepassxreboot#10777]
* Snap: Use new desktop portal for native messaging integration [keepassxreboot#10906]

* Improve entry placeholder/reference feature [keepassxreboot#10846]
* Improve CSV importing when title field isn't specified [keepassxreboot#10843]
* Improve encrypted Bitwarden importing [keepassxreboot#10800]
* Improve database settings UX [keepassxreboot#10821]
* Improve handling of clipboard actions from entry preview [keepassxreboot#10810]
* Improve group/entry view resize behavior and set sensible defaults [keepassxreboot#10641]
* Passkeys: Fix incorrect username fill [keepassxreboot#10874]
* Passkeys: Return additional data to the extension [keepassxreboot#10857]
* Fix password clear timer inconsistency on unlock view [keepassxreboot#10708]
* Fix portability check [keepassxreboot#10760]
* Fix page overflow on HTML exports [keepassxreboot#10735]
* Fix broken builds when using system provided zxcvbn [keepassxreboot#10717]
* Fix copy password button when text is selected [keepassxreboot#10853]
* Fix tab ordering on application settings pages [keepassxreboot#10907]
* SSH Agent: Fix broken decrypt button [keepassxreboot#10638]
* Windows: Fix ALT Auto-Type modifier [keepassxreboot#10795]
* Windows: Fix wrong DACL memory size allocation [keepassxreboot#10712]
* macOS: Fix monospace font sizing [keepassxreboot#10739]
* Flatpak: Fix configuration settings off-by-one error [keepassxreboot#10688]
* BSD: Fix compiling with libusb implementation [keepassxreboot#10736]
BryanJacobs added a commit to BryanJacobs/keepassxc that referenced this pull request Jul 26, 2024
* upstream/develop: (57 commits)
  Fix typos in tooltips from EditEntryWidgetBrowser.ui
  Refactor: separate GUI sources from core sources
  Database key settings: fix UI bug
  tests: gui: Fix NULL dereference in GUI tests
  Docs: explain how to generate passwords with the browser extension (keepassxreboot#9242)
  Fix a couple more Qt 5.15 deprecation warnings (keepassxreboot#10953)
  Update URLs to Chrome Web Store page for `KeePassXC-Browser` extension
  Update browser extension icon states in documentation (keepassxreboot#10875)
  Fix сentering icon and text on buttons
  Fix backup file path substitution
  Verify USB listener callback handle
  Refactor Database Settings (keepassxreboot#9485)
  Fix all Qt 5.15 deprecation warnings (keepassxreboot#7783)
  Passkey importer: fix file picker parent
  Require Qt >= 5.12
  Passkeys: Fix showing correct username in the reports
  Show character count in password generator dialog (keepassxreboot#10940)
  Increase the time interval for window show workaround
  Snap: Remove $HOME access from keepassxc-proxy
  Correct libusb usage on FreeBSD (keepassxreboot#10736)
  ...

# Conflicts:
#	src/CMakeLists.txt
#	src/core/Database.cpp
#	src/core/Database.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants