@@ -284,22 +284,23 @@ function removeAsync(dir) {
284284}
285285
286286{
287+ // IBMi has a different access permission mechanism
288+ // This test should not be run as `root`
287289 if ( ! common . isIBMi && ( common . isWindows || process . getuid ( ) !== 0 ) ) {
288290 function makeDirectoryReadOnly ( dir ) {
289291 let accessErrorCode = 'EACCES' ;
290292 if ( common . isWindows ) {
291293 accessErrorCode = 'EPERM' ;
292- execSync ( `icacls ${ dir } /inheritance:r` ) ;
293- execSync ( `icacls ${ dir } /deny "everyone":W` ) ;
294+ execSync ( `icacls ${ dir } /deny "everyone:(OI)(CI)(DE,DC)"` ) ;
294295 } else {
295- fs . chmodSync ( dir , '444' ) ;
296+ fs . chmodSync ( dir , 0o444 ) ;
296297 }
297298 return accessErrorCode ;
298299 }
299300
300301 function makeDirectoryWritable ( dir ) {
301302 if ( common . isWindows ) {
302- execSync ( `icacls ${ dir } /grant "everyone":W ` ) ;
303+ execSync ( `icacls ${ dir } /remove:d "everyone"` ) ;
303304 } else {
304305 fs . chmodSync ( dirname , 0o777 ) ;
305306 }
@@ -311,11 +312,11 @@ function removeAsync(dir) {
311312 try {
312313 fs . mkdirSync ( dirname , { recursive : true } ) ;
313314 fs . writeFileSync ( filePath , 'hello' ) ;
314- const errorCode = makeDirectoryReadOnly ( dirname ) ;
315+ const code = makeDirectoryReadOnly ( dirname ) ;
315316 assert . throws ( ( ) => {
316317 fs . rmSync ( filePath , { force : true } ) ;
317318 } , {
318- code : errorCode ,
319+ code,
319320 name : 'Error' ,
320321 } ) ;
321322 } finally {
0 commit comments