Opened 7 years ago

Closed 22 months ago

#56185 closed defect (fixed)

npth requires unnamed semaphores; provide those for Darwin 9 and earlier

Reported by: ccorn Owned by: barracuda156
Priority: Normal Milestone:
Component: ports Version:
Keywords: legacysupport Cc: ballapete (Peter "Pete" Dyballa), kencu (Ken), evanmiller (Evan Miller)
Port: npth

Description

npthis 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_npthuses 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 on my Darwin9-PPC64 branch. If you are in pressing need for a working MacPorts gnupg2on 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 npths configure.ac to test for Darwin < 10 and set an autoconf variable and config.h macro that is used in src/Makefile.amand 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!

Change History (11)

comment:1 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

I tried your additions on Tiger, MacOS X 10.4.11, Darwin8. It runs on a 32 bit PPC 7447A. And it works! I can use gpg2.

The next try on Leopard, Mac OS X 10.5.8, Darwin9, same hardware is just starting.

comment:2 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Cc: ballapete added

comment:3 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

On PPC Leopard success as well!

comment:4 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

I created a new ticket, #61115, that requests an enhancement of npth (and potentially gnupg2 because it builds but is useless and does not work and since it substitutes gnupg the user has no working GnuPG implementation installed, except when from a third party).

comment:5 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: kencu added

Should this be added to our legacy support library instead?

comment:6 in reply to:  5 Changed 4 years ago by ballapete (Peter "Pete" Dyballa)

Replying to ryandesign:

Should this be added to our legacy support library instead?

The C files, that might be a splendid idea. This way a few ports could use a uniform legacy support instead of individual solutions for unnamed (therefore safer?) semaphores. My wish is that npth is enhanced soon that GnuPG 2 can be used on older systems. As I mention in #61115 there can be a number of users that have installed GnuPG 2 and have now an unusable software. I found this by trying to use GnuPG 2 – and it failed completely and I did not understand why. It took a long time until I found this explanatory ticket…

comment:7 Changed 3 years ago by evanmiller (Evan Miller)

Cc: evanmiller added

comment:8 Changed 22 months ago by barracuda156

What happened to this? gnupg2 is still unusable, as of now.

comment:9 Changed 22 months ago by kencu (Ken)

basically, nobody was motivated to move it along. I never used npth or gpu-agent, so didn't come across it.

Looking at the header and the source file, it would seem to be a trivial addition to legacysupport. But someone would need to figure out how this made it's way into Darwin, what systems need it, and (ideally) how to make a simple test for it.

comment:10 Changed 22 months ago by kencu (Ken)

Keywords: legacysupport added

comment:11 Changed 22 months ago by barracuda156

Owner: set to barracuda156
Resolution: fixed
Status: newclosed

In c811f064de5dab620de65f44effd081ac91c97d4/macports-ports (master):

npth: fix for old systems
Fixes: #56185
Fixes: #61115

Note: See TracTickets for help on using tickets.