@@ -26,7 +26,7 @@ import { isValidUUID } from "@cocalc/util/misc";
26
26
import { reuseInFlight } from "@cocalc/util/reuse-in-flight" ;
27
27
import getLogger from "@cocalc/backend/logger" ;
28
28
import { root } from "@cocalc/backend/data" ;
29
- import { dirname , join } from "node:path" ;
29
+ import { basename , dirname , join } from "node:path" ;
30
30
import { userInfo } from "node:os" ;
31
31
import { ensureConfFilesExists , setupDataPath , writeSecretToken } from "./util" ;
32
32
import { getEnvironment } from "./env" ;
@@ -61,6 +61,7 @@ const MOUNTS = {
61
61
"-B" : [ "/dev" ] ,
62
62
} ;
63
63
64
+ let nodePath = process . execPath ;
64
65
async function initMounts ( ) {
65
66
for ( const type in MOUNTS ) {
66
67
const v : string [ ] = [ ] ;
@@ -77,12 +78,9 @@ async function initMounts() {
77
78
// version of node's install available
78
79
if ( ! process . execPath . startsWith ( "/usr/" ) ) {
79
80
// not already in an obvious system-wide place we included above
80
- if ( process . execPath . includes ( "nvm/versions/node/" ) ) {
81
- const j = process . execPath . lastIndexOf ( "/bin/node" ) ;
82
- if ( j != - 1 ) {
83
- MOUNTS [ "-R" ] . push ( process . execPath . slice ( 0 , j ) ) ;
84
- }
85
- }
81
+ // IMPORTANT: take care not to put the binary next to sensitive info!
82
+ MOUNTS [ "-R" ] . push ( `${ dirname ( process . execPath ) } :/cocalc/bin` ) ;
83
+ nodePath = join ( "/cocalc/bin" , basename ( process . execPath ) ) ;
86
84
}
87
85
}
88
86
@@ -138,7 +136,6 @@ async function start({
138
136
env : config ?. env ,
139
137
HOME : home ,
140
138
} ) ;
141
- env . PATH = dirname ( process . argv [ 0 ] ) + ":" + ( env . PATH ?? "" ) ;
142
139
await setupDataPath ( home ) ;
143
140
if ( config ?. secret ) {
144
141
await writeSecretToken ( home , config . secret ) ;
@@ -187,7 +184,7 @@ async function start({
187
184
args . push ( "-B" , `${ home } :${ env . HOME } ` ) ;
188
185
args . push ( ...limits ( config ) ) ;
189
186
args . push ( "--" ) ;
190
- args . push ( process . execPath ) ;
187
+ args . push ( nodePath ) ;
191
188
cmd = nsjail ;
192
189
}
193
190
0 commit comments