[MacPorts] #56185: npth requires unnamed semaphores; provide those for Darwin 9 and earlier

MacPorts noreply at macports.org
Thu Mar 29 18:08:26 UTC 2018

#56185: npth requires unnamed semaphores; provide those for Darwin 9 and earlier
 Reporter:  ccorn   |      Owner:
     Type:  defect  |     Status:  new
 Priority:  Normal  |  Milestone:
Component:  ports   |    Version:
 Keywords:          |       Port:  npth
 `npth`is used by `gpg-agent` which is now part of the `gnupg2` port.

 Both ports compile on `darwin9-powerpc`, but trying to start `gpg-agent`
 triggers an assertion error by `npth`:
 $ gpg-agent --homedir=~/.gnupg --daemon
 Assertion failed: (!res), function leave_npth, file npth.c, line 200.
 Since `gnupg2` now requires a running `gpg-agent` for everything that
 requires passphrases, this error makes `gnupg2` essentially unusable for
 signing as well as decryption.

 Digging a bit, I have found that `leave_npth`uses `sem_wait` to wait for
 an unnamed, statically allocated semaphore. `sem_wait` then returns `-1`
 and sets `errno = EBADF`. I conclude that Darwin 9 does not support such
 use. (I suppose that this issue is OS version specific but not dependent
 on architecture.)

 Other projects in need of support for unnamed semaphores have provided an
 implementation for Darwin, e.g.
 here]. I have added those files to the `npth` sources and done a little
 patching to ensure that those files are used. The result is that `gpg-
 agent` now runs fine.

 The added files `darwin_compat.{h,c}` have comments indicating that they
 are based on code from `glibc` which is under GPL-2+. This matches the
 `npth` license and should therefore be unproblematic. However, I have no
 judgement about the code itself except that it solves my problem. Which is
 what keeps me from opening a direct pull request.

 I have a working MacPorts patch for `npth` [https://github.com/ccorn
 /macports-ports/commit/66b8f2f076f38982eb886ee4809a815a0a5865d8 on my
 Darwin9-PPC64 branch]. If you are in pressing need for a working MacPorts
 `gnupg2`on Darwin < 10, you can use that.

 I have chosen a MacPorts-based patch for convenience: Portfiles have easy-
 to-use commands for platform-specific actions. However, the proper
 approach would be to modify `npth`s `configure.ac` to test for Darwin < 10
 and set an autoconf variable and `config.h` macro that is used in
 `src/Makefile.am`and `src/npth.c` respectively. Such a patch should then
 be offered upstream. I have not come to that yet, and I do not know the
 chances of success.

 For the time being, I just want to let you know that there is a problem
 with current `npth` (and therefore `gnupg2`) on Darwin < 10 which
 indirectly prevents users from accessing or signing their mails, and that
 there is a solution that seems to work. No need to panic!

Ticket URL: <https://trac.macports.org/ticket/56185>
MacPorts <https://www.macports.org/>
Ports system for macOS

More information about the macports-tickets mailing list