VirtualBox

Changeset 93019 in vbox


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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/localipc.h

    r82968 r93019  
    9696
    9797/**
     98 * Grant the specified group access to the local IPC server socket.
     99 *
     100 * @returns IPRT status code.
     101 * @param   hServer     The server handle.
     102 * @param   gid         Group ID.
     103 */
     104RTDECL(int) RTLocalIpcServerGrantGroupAccess(RTLOCALIPCSERVER hServer, RTGID gid);
     105
     106/**
    98107 * Listen for clients.
    99108 *
  • trunk/include/iprt/mangling.h

    r92507 r93019  
    13501350# define RTLocalIpcServerCreate                         RT_MANGLER(RTLocalIpcServerCreate)
    13511351# define RTLocalIpcServerDestroy                        RT_MANGLER(RTLocalIpcServerDestroy)
     1352# define RTLocalIpcServerGrantGroupAccess               RT_MANGLER(RTLocalIpcServerGrantGroupAccess)
    13521353# define RTLocalIpcServerCancel                         RT_MANGLER(RTLocalIpcServerCancel)
    13531354# define RTLocalIpcServerListen                         RT_MANGLER(RTLocalIpcServerListen)
  • 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
  • trunk/src/VBox/Runtime/r3/win/localipc-win.cpp

    r86536 r93019  
    564564
    565565    return rtLocalIpcServerReleaseAndUnlock(pThis);
     566}
     567
     568
     569RTDECL(int) RTLocalIpcServerGrantGroupAccess(RTLOCALIPCSERVER hServer, RTGID gid)
     570{
     571    RT_NOREF_PV(hServer); RT_NOREF(gid);
     572    return VERR_NOT_SUPPORTED;
    566573}
    567574
Note: See TracChangeset for help on using the changeset viewer.

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