src/os/bsd/vm/attachListener_bsd.cpp

changeset 3648
77591ef8983a
parent 3156
f08d439fab8c
child 4229
0af5da0c9d9d
     1.1 --- a/src/os/bsd/vm/attachListener_bsd.cpp	Sat Mar 17 00:27:39 2012 -0700
     1.2 +++ b/src/os/bsd/vm/attachListener_bsd.cpp	Mon Mar 19 20:13:17 2012 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -206,10 +206,15 @@
    1.11    // put in listen mode, set permissions, and rename into place
    1.12    res = ::listen(listener, 5);
    1.13    if (res == 0) {
    1.14 -      RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
    1.15 +    RESTARTABLE(::chmod(initial_path, S_IREAD|S_IWRITE), res);
    1.16 +    if (res == 0) {
    1.17 +      // make sure the file is owned by the effective user and effective group
    1.18 +      // (this is the default on linux, but not on mac os)
    1.19 +      RESTARTABLE(::chown(initial_path, geteuid(), getegid()), res);
    1.20        if (res == 0) {
    1.21 -          res = ::rename(initial_path, path);
    1.22 +        res = ::rename(initial_path, path);
    1.23        }
    1.24 +    }
    1.25    }
    1.26    if (res == -1) {
    1.27      RESTARTABLE(::close(listener), res);

mercurial