comparison src/os/bsd/vm/attachListener_bsd.cpp @ 5945:77591ef8983a

7152800: All tests using the attach API fail with "well-known file is not secure" on Mac OS X Summary: Create well-known file with effective group of the current process Reviewed-by: kamg, dcubed
author sla
date Mon, 19 Mar 2012 20:13:17 +0100
parents f08d439fab8c
children 0af5da0c9d9d
comparison
equal deleted inserted replaced
5944:a142c661f6b1 5945:77591ef8983a
1 /* 1 /*
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
204 } 204 }
205 205
206 // put in listen mode, set permissions, and rename into place 206 // put in listen mode, set permissions, and rename into place
207 res = ::listen(listener, 5); 207 res = ::listen(listener, 5);
208 if (res == 0) { 208 if (res == 0) {
209 RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res); 209 RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
210 if (res == 0) {
211 // make sure the file is owned by the effective user and effective group
212 // (this is the default on linux, but not on mac os)
213 RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res);
210 if (res == 0) { 214 if (res == 0) {
211 res = ::rename(initial_path, path); 215 res = ::rename(initial_path, path);
212 } 216 }
217 }
213 } 218 }
214 if (res == -1) { 219 if (res == -1) {
215 RESTARTABLE(::close(listener), res); 220 RESTARTABLE(::close(listener), res);
216 ::unlink(initial_path); 221 ::unlink(initial_path);
217 return -1; 222 return -1;