@@ -355,26 +355,30 @@ setPassengerTempDir(const string &dir) {
355
355
static void
356
356
createNonWritableFifo (const string &filename) {
357
357
int ret, e;
358
+ bool ignoreChmodErrors = false ;
358
359
359
360
do {
360
361
ret = mkfifo (filename.c_str (), 0 );
361
362
} while (ret == -1 && errno == EINTR);
362
363
if (ret == -1 ) {
363
- if (errno == EEXIST && geteuid () != 0 ) {
364
- // Don't try to change the permissions on the FIFO file;
365
- // it was likely created by root, but after lowering privilege
366
- // createPassengerTempDir() is called again, and this time
367
- // we won't be able to set permissions.
368
- return ;
364
+ if (errno == EEXIST) {
365
+ /* The FIFO file was likely created by root, but after lowering
366
+ * privilege createPassengerTempDir() is called again, and this
367
+ * time we won't be able to set permissions. So in this case
368
+ * we'll want to ignore any chmod errors.
369
+ */
370
+ ignoreChmodErrors = geteuid () != 0 ;
371
+ } else {
372
+ e = errno;
373
+ throw FileSystemException (" Cannot create FIFO file " + filename,
374
+ e, filename);
369
375
}
370
- e = errno;
371
- throw FileSystemException (" Cannot create FIFO file " + filename, e, filename);
372
376
}
373
377
374
378
do {
375
379
ret = chmod (filename.c_str (), 0 );
376
380
} while (ret == -1 && errno == EINTR);
377
- if (ret == -1 ) {
381
+ if (ret == -1 && !ignoreChmodErrors ) {
378
382
e = errno;
379
383
throw FileSystemException (" Cannot set permissions on file " + filename, e, filename);
380
384
}
0 commit comments