Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package pam
#cgo CFLAGS: -Wall -Wno-unused-variable -std=c99
#cgo LDFLAGS: -ldl -lpam

#define _GNU_SOURCE
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be only in #ifdef __linux__ and other UNIX systems using glibc?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Otherwise you can define _GNU_SOURCE for all, then you add an #ifndef RTLD_NEXT that sets it to 0 if unset? I'm not aware of platforms where that is not set, but it's safer to go this way.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Or #if defined(__GLIBC__) maybe?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry for the delayed response

Not obvious what the best solution is here,
GLIBC is defined in features.h, which I could include to test the define, however features.h sets defines based on _GNU_SOURCE, so its not really correct.

I'll update the request with the second suggestion, define _GNU_SOURCE and add the ifndef, from the include file: -

define RTLD_NEXT ((void *) -1l)

I'm assuming this is what you mean (rather than set to zero).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

sorry, the define text being really large is a copy-paste error.

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.

I ran into this issue recently as well. May I suggest placing these changes into transaction_linux.go, and perhaps use #cgo CFLAGS: -D_GNU_SOURCE, which seems to be the preferred method.

#include <dlfcn.h>
#include <security/pam_appl.h>
#include <stdlib.h>
Expand All @@ -18,6 +19,10 @@ package pam
#define BINARY_PROMPT_IS_SUPPORTED 0
#endif

#ifndef RTLD_NEXT
# define RTLD_NEXT ((void *) -1l)
#endif

void init_pam_conv(struct pam_conv *conv, uintptr_t);

typedef int (*pam_start_confdir_fn)(const char *service_name, const char *user, const struct pam_conv *pam_conversation, const char *confdir, pam_handle_t **pamh);
Expand Down