comparison src/os/aix/vm/perfMemory_aix.cpp @ 23455:9f8038f83a6e

8130910: hsperfdata file is created in wrong directory and not cleaned up if /tmp/hsperfdata_<username> has wrong permissions Summary: Add check for fchir() failure and disable shared PerfMemory in that case. Reviewed-by: dcubed, simonis, gthornbr
author clanger
date Tue, 17 Nov 2015 09:39:45 -0800
parents b9c06f87e476
children 2d23269a45a0
comparison
equal deleted inserted replaced
23454:714096aec397 23455:9f8038f83a6e
1 /* 1 /*
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2012, 2013 SAP AG. All rights reserved. 3 * Copyright 2012, 2013 SAP AG. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * 5 *
6 * This code is free software; you can redistribute it and/or modify it 6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as 7 * under the terms of the GNU General Public License version 2 only, as
452 *saved_cwd_fd = -1; 452 *saved_cwd_fd = -1;
453 } else { 453 } else {
454 *saved_cwd_fd = result; 454 *saved_cwd_fd = result;
455 } 455 }
456 456
457 // Set the current directory to dirname by using the fd of the directory. 457 // Set the current directory to dirname by using the fd of the directory and
458 // handle errors, otherwise shared memory files will be created in cwd.
458 result = fchdir(fd); 459 result = fchdir(fd);
459 460 if (result == OS_ERR) {
460 return dirp; 461 if (PrintMiscellaneous && Verbose) {
462 warning("could not change to directory %s", dirname);
463 }
464 if (*saved_cwd_fd != -1) {
465 ::close(*saved_cwd_fd);
466 *saved_cwd_fd = -1;
467 }
468 // Close the directory.
469 os::closedir(dirp);
470 return NULL;
471 } else {
472 return dirp;
473 }
461 } 474 }
462 475
463 // Close the directory and restore the current working directory. 476 // Close the directory and restore the current working directory.
477 //
464 static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) { 478 static void close_directory_secure_cwd(DIR* dirp, int saved_cwd_fd) {
465 479
466 int result; 480 int result;
467 // If we have a saved cwd change back to it and close the fd. 481 // If we have a saved cwd change back to it and close the fd.
468 if (saved_cwd_fd != -1) { 482 if (saved_cwd_fd != -1) {