Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
module: check env NODE_PRELOAD for preload modules#11888
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -411,8 +411,38 @@ | ||
| // Load preload modules | ||
| functionpreloadModules(){ | ||
| if(process._preload_modules){ | ||
| NativeModule.require('module')._preloadModules(process._preload_modules); | ||
| varallPreloads=process._preload_modules; | ||
| varisSetUidRoot=false; | ||
| if(process.platform!=='win32'){ | ||
| isSetUidRoot=process.getuid()!==process.geteuid()|| | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why aren't you using Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure how. Can you tell me please? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Look for how OPENSSL_CONF is loaded from env, in such a way that its ignored if the IDs aren't safe, much as you are manually trying to check here. | ||
| process.getgid()!==process.getegid(); | ||
| } | ||
| if(!isSetUidRoot&&process.env.NODE_PRELOAD){ | ||
| constpath=NativeModule.require('path'); | ||
| constaddPreload=(nmDir,preloads)=>{ | ||
| constaddNmDir=(m)=>{ | ||
| returnpath.isAbsolute(m) ? m : path.join(nmDir,m); | ||
| }; | ||
| if(preloads&&preloads.length>0){ | ||
| preloads=preloads.map((m)=>addNmDir(m.trim())) | ||
| .filter((m)=>(m.length>nmDir.length&&m.startsWith(nmDir))); | ||
| if(preloads.length>0){ | ||
| allPreloads=(allPreloads||[]).concat(preloads); | ||
| } | ||
| } | ||
| }; | ||
| constglobalNm=path.join(process.argv[0],'../../lib/node_modules/'); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't make any sense to disallow requiring a packages own dependencies, please remove this. Resolution should be identical to Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment I am waiting for an approach that everyone can at least not put a -1 on first. If @nodejs/ctc have an approach that's acceptable, I'd implement that. | ||
| addPreload(globalNm,process.env.NODE_PRELOAD.split(path.delimiter)); | ||
| } | ||
| if(allPreloads){ | ||
| NativeModule.require('module')._preloadModules(allPreloads); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is going to happen, this var should be called
isSetUid