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

feat(NODE-5746): allow runtime linking against system kerberos library #165

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ functions:
env:
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
PROJECT: ${project}
GYP_DEFINES: ${GYP_DEFINES|}
NPM_OPTIONS: ${NPM_OPTIONS|}
args:
- run
- '--interactive'
Expand All @@ -76,6 +78,10 @@ functions:
- /app
- '--env'
- PROJECT_DIRECTORY=/app
- '--env'
- GYP_DEFINES
- '--env'
- NPM_OPTIONS
- 'ubuntu:22.04'
- /bin/bash
- /app/.evergreen/run-tests-ubuntu.sh
Expand Down Expand Up @@ -122,6 +128,12 @@ tasks:
- name: run-tests-ubuntu
commands:
- func: run tests ubuntu
- name: run-tests-ubuntu-rtld
commands:
- func: run tests ubuntu
vars:
GYP_DEFINES: kerberos_use_rtld=true
NPM_OPTIONS: --build-from-source
- name: run-prebuild
commands:
- func: install dependencies
Expand Down Expand Up @@ -194,6 +206,7 @@ buildvariants:
packager_arch: x86_64
tasks:
- run-tests-ubuntu
- run-tests-ubuntu-rtld
- name: ubuntu2204-arm64
display_name: 'Ubuntu 22.04 arm64'
run_on: ubuntu2204-arm64-small
Expand All @@ -203,3 +216,4 @@ buildvariants:
packager_arch: arm64
tasks:
- run-tests-ubuntu
- run-tests-ubuntu-rtld
1 change: 1 addition & 0 deletions .evergreen/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ echo "npm location: $(which npm)"
echo "npm version: $(npm -v)"

npm install "${NPM_OPTIONS}"
ldd build/*/kerberos.node || true
18 changes: 16 additions & 2 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
'sources': [
'src/kerberos.cc'
],
'variables': {
'kerberos_use_rtld%': 'false'
},
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LIBRARY': 'libc++',
Expand Down Expand Up @@ -36,11 +39,14 @@
'src/unix/base64.cc',
'src/unix/kerberos_gss.cc',
'src/unix/kerberos_unix.cc'
],
]
}],
['(OS=="mac" or OS=="linux") and (kerberos_use_rtld!="true")', {
'link_settings': {
'libraries': [
'-lkrb5',
'-lgssapi_krb5'
'-lgssapi_krb5',
'-lcom_err'
nbbeeken marked this conversation as resolved.
Show resolved Hide resolved
]
},
'conditions': [
Expand All @@ -53,6 +59,14 @@
}]
]
}],
['(OS=="mac" or OS=="linux") and (kerberos_use_rtld=="true")', {
'defines': ['KERBEROS_USE_RTLD=1'],
'link_settings': {
'libraries': [
'-ldl',
]
},
}],
['OS=="win"', {
'sources': [
'src/win32/kerberos_sspi.cc',
Expand Down
4 changes: 4 additions & 0 deletions src/kerberos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ void TestMethod(const CallbackInfo& info) {
}

static Object Init(Env env, Object exports) {
std::string libraries_unavailable_error;
if (!kerberos_libraries_available(&libraries_unavailable_error)) {
throw Error::New(env, libraries_unavailable_error);
}
Function KerberosClientCtor = KerberosClient::Init(env);
Function KerberosServerCtor = KerberosServer::Init(env);
exports["KerberosClient"] = KerberosClientCtor;
Expand Down
2 changes: 2 additions & 0 deletions src/kerberos.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace node_kerberos {

bool kerberos_libraries_available(std::string* error_out);

class KerberosServer : public Napi::ObjectWrap<KerberosServer> {
public:
static Napi::Function Init(Napi::Env env);
Expand Down
Loading