@@ -299,6 +299,14 @@ async function updateActiveTerminalFiles(pipePath: string) {
299299 }
300300}
301301
302+ async function setOwnerOnlyPermissions ( filePath : string ) : Promise < void > {
303+ if ( process . platform === 'win32' ) {
304+ return ;
305+ }
306+
307+ await fs . chmod ( filePath , 0o600 ) ;
308+ }
309+
302310function makePipePath ( ) : string {
303311 const suffix = crypto . randomBytes ( 8 ) . toString ( 'hex' ) ;
304312 if ( process . platform === 'win32' ) {
@@ -381,10 +389,12 @@ export async function getGlobalPipePath(): Promise<string> {
381389 } ) ;
382390
383391 server . listen ( pipePath , ( ) => {
384- globalPipePath = pipePath ;
385- globalSessionServer = server ;
386- console . info ( `[SessionServer] Listening on ${ pipePath } ` ) ;
387- resolve ( pipePath ) ;
392+ void setOwnerOnlyPermissions ( pipePath ) . then ( ( ) => {
393+ globalPipePath = pipePath ;
394+ globalSessionServer = server ;
395+ console . info ( `[SessionServer] Listening on ${ pipePath } ` ) ;
396+ resolve ( pipePath ) ;
397+ } ) . catch ( reject ) ;
388398 } ) ;
389399 } ) ;
390400}
@@ -429,7 +439,8 @@ export async function getAttachSessionCommand(): Promise<string> {
429439 const sessPath = extensionContext . asAbsolutePath ( 'sess' ) . replace ( / \\ / g, '/' ) ;
430440 const installSessScriptPath = extensionContext . asAbsolutePath ( path . join ( 'R' , 'install_sess.R' ) ) . replace ( / \\ / g, '/' ) ;
431441 const scriptPath = getAttachSessionScriptPath ( pipePath ) ;
432- await fs . writeFile ( scriptPath , buildAttachSessionScript ( pipePath , sessPath , installSessScriptPath ) , { encoding : 'utf-8' } ) ;
442+ await fs . writeFile ( scriptPath , buildAttachSessionScript ( pipePath , sessPath , installSessScriptPath ) , { encoding : 'utf-8' , mode : 0o600 } ) ;
443+ await setOwnerOnlyPermissions ( scriptPath ) ;
433444 attachSessionScriptPath = scriptPath ;
434445
435446 return `source(${ asRStringLiteral ( scriptPath ) } )` ;
0 commit comments