mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Fix PAM module loading path for bundled npm package (#396)
This commit is contained in:
parent
39d35d0655
commit
70ea0f299b
1 changed files with 31 additions and 17 deletions
|
|
@ -27,7 +27,10 @@ if (fs.existsSync(seaPamPath) || fs.existsSync(seaNativePamPath)) {
|
||||||
const possiblePaths = [
|
const possiblePaths = [
|
||||||
seaPamPath,
|
seaPamPath,
|
||||||
seaNativePamPath,
|
seaNativePamPath,
|
||||||
path.join(__dirname, '..', '..', '..', 'native', 'authenticate_pam.node'),
|
// Try different parent levels for native directory
|
||||||
|
...[1, 2, 3].map((levels) =>
|
||||||
|
path.join(__dirname, ...Array(levels).fill('..'), 'native', 'authenticate_pam.node')
|
||||||
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
|
|
@ -77,27 +80,38 @@ if (fs.existsSync(seaPamPath) || fs.existsSync(seaNativePamPath)) {
|
||||||
|
|
||||||
// If normal require failed, try the optional-modules location
|
// If normal require failed, try the optional-modules location
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
const optionalModulePath = path.join(
|
// Try different parent directory levels for various contexts:
|
||||||
__dirname,
|
// 1 level up: bundled context (dist-npm/lib/)
|
||||||
'..',
|
// 3 levels up: development context (src/server/services/)
|
||||||
'..',
|
// 2 levels up: alternative bundled location
|
||||||
'..',
|
const parentLevels = [1, 3, 2];
|
||||||
|
const modulePath = [
|
||||||
'optional-modules',
|
'optional-modules',
|
||||||
'authenticate-pam',
|
'authenticate-pam',
|
||||||
'build',
|
'build',
|
||||||
'Release',
|
'Release',
|
||||||
'authenticate_pam.node'
|
'authenticate_pam.node',
|
||||||
);
|
];
|
||||||
if (fs.existsSync(optionalModulePath)) {
|
|
||||||
try {
|
for (const levels of parentLevels) {
|
||||||
const nativeModule = loadNativeModule(optionalModulePath);
|
const pathSegments = [__dirname, ...Array(levels).fill('..'), ...modulePath];
|
||||||
if (nativeModule.authenticate) {
|
const optionalModulePath = path.join(...pathSegments);
|
||||||
authenticate = nativeModule.authenticate;
|
|
||||||
loaded = true;
|
if (fs.existsSync(optionalModulePath)) {
|
||||||
console.log('Loaded authenticate-pam from optional-modules location');
|
try {
|
||||||
|
const nativeModule = loadNativeModule(optionalModulePath);
|
||||||
|
if (nativeModule.authenticate) {
|
||||||
|
authenticate = nativeModule.authenticate;
|
||||||
|
loaded = true;
|
||||||
|
console.log(
|
||||||
|
'Loaded authenticate-pam from optional-modules location:',
|
||||||
|
optionalModulePath
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (_loadError) {
|
||||||
|
// Continue to next path
|
||||||
}
|
}
|
||||||
} catch (_loadError) {
|
|
||||||
// Continue to stub
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue