VirtualBox

Changeset 93019 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Dec 17, 2021 2:52:57 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
149013
Message:

iprt: local ipc server: add interface to grant r/w access to a server socket for a specified group, bugref:10134.

File:
1 edited

Legend:

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

    r92679 r93019  
    5555#include <signal.h>
    5656#include <unistd.h>
     57#include <sys/stat.h>
    5758
    5859#include "internal/magics.h"
     
    270271    Log(("RTLocalIpcServerCreate: failed, rc=%Rrc\n", rc));
    271272    return rc;
     273}
     274
     275
     276
     277RTDECL(int) RTLocalIpcServerGrantGroupAccess(RTLOCALIPCSERVER hServer, RTGID gid)
     278{
     279    PRTLOCALIPCSERVERINT pThis = (PRTLOCALIPCSERVERINT)hServer;
     280
     281    AssertReturn(pThis,                VERR_INVALID_PARAMETER);
     282    AssertReturn(pThis->Name.sun_path, VERR_INVALID_PARAMETER);
     283
     284    if (chown(pThis->Name.sun_path, -1, gid) == 0)
     285    {
     286        if (chmod(pThis->Name.sun_path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == 0)
     287        {
     288            LogRel(("RTLocalIpcServerGrantGroupAccess: IPC socket %s access has been granted to group %RTgid\n",
     289                    pThis->Name.sun_path, gid));
     290
     291            return VINF_SUCCESS;
     292        }
     293        else
     294            LogRel(("RTLocalIpcServerGrantGroupAccess: cannot grant IPC socket %s write permission to group %RTgid, rc=%Rrc\n",
     295                    pThis->Name.sun_path, gid, RTErrConvertFromErrno(errno)));
     296    }
     297    else
     298        LogRel(("RTLocalIpcServerGrantGroupAccess: cannot change IPC socket %s group ownership to %RTgid, rc=%Rrc\n",
     299                pThis->Name.sun_path, gid, RTErrConvertFromErrno(errno)));
     300
     301    return VERR_ACCESS_DENIED;
    272302}
    273303
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