VirtualBox

Changeset 92679 in vbox


Ignore:
Timestamp:
Dec 1, 2021 3:46:06 PM (3 years ago)
Author:
vboxsync
Message:

iprt: Local Ipc Server: put synchronization primitives into rtLocalIpcSessionQueryUcred(), bugref:10134

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/localipc-posix.cpp

    r92678 r92679  
    10671067    struct ucred PeerCred   = { (pid_t)NIL_RTPROCESS, (uid_t)NIL_RTUID, (gid_t)NIL_RTGID };
    10681068    socklen_t    cbPeerCred = sizeof(PeerCred);
    1069     if (getsockopt(RTSocketToNative(pThis->hSocket), SOL_SOCKET, SO_PEERCRED, &PeerCred, &cbPeerCred) >= 0)
     1069
     1070    rtLocalIpcSessionRetain(pThis);
     1071
     1072    int rc = RTCritSectEnter(&pThis->CritSect);;
     1073    if (RT_SUCCESS(rc))
    10701074    {
    1071         if (pProcess)
    1072             *pProcess = PeerCred.pid;
    1073         if (pUid)
    1074             *pUid = PeerCred.uid;
    1075         if (pGid)
    1076             *pGid = PeerCred.gid;
    1077         return VINF_SUCCESS;
     1075        if (getsockopt(RTSocketToNative(pThis->hSocket), SOL_SOCKET, SO_PEERCRED, &PeerCred, &cbPeerCred) >= 0)
     1076        {
     1077            if (pProcess)
     1078                *pProcess = PeerCred.pid;
     1079            if (pUid)
     1080                *pUid = PeerCred.uid;
     1081            if (pGid)
     1082                *pGid = PeerCred.gid;
     1083            rc = VINF_SUCCESS;
     1084        }
     1085        else
     1086        {
     1087            rc = RTErrConvertFromErrno(errno);
     1088        }
     1089
     1090        int rc2 = RTCritSectLeave(&pThis->CritSect);
     1091        AssertStmt(RT_SUCCESS(rc2), rc = RT_SUCCESS(rc) ? rc2 : rc);
    10781092    }
    1079     return RTErrConvertFromErrno(errno);
     1093
     1094    rtLocalIpcSessionRelease(pThis);
     1095
     1096    return rc;
    10801097
    10811098#else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette