VirtualBox

Changeset 29624 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 18, 2010 12:36:13 PM (15 years ago)
Author:
vboxsync
Message:

posix/process-posix: rtCheckCredentials for Solaris.

File:
1 edited

Legend:

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

    r29602 r29624  
    3939#include <fcntl.h>
    4040#include <signal.h>
    41 #if defined(RT_OS_LINUX)
     41#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
    4242# include <crypt.h>
    4343# include <pwd.h>
     
    101101    *gid = pw->pw_gid;
    102102    *uid = pw->pw_uid;
     103    return VINF_SUCCESS;
     104#elif defined(RT_OS_SOLARIS)
     105    struct passwd *ppw, pw;
     106    char szBuf[1024];
     107
     108    if (getpwnam_r(pszUser, &pw, szBuf, sizeof(szBuf), &ppw) != 0 || ppw == NULL)
     109        return VERR_PERMISSION_DENIED;
     110
     111    if (!pszPasswd)
     112        pszPasswd = "";
     113
     114    struct spwd spwd;
     115    char szPwdBuf[1024];
     116    /* works only if /etc/shadow is accessible */
     117    if (getspnam_r(pszUser, &spwd, szPwdBuf, sizeof(szPwdBuf)) != NULL)
     118        ppw->pw_passwd = spwd.sp_pwdp;
     119
     120    char *pszEncPasswd = crypt(pszPasswd, ppw->pw_passwd);
     121    if (strcmp(pszEncPasswd, ppw->pw_passwd))
     122        return VERR_PERMISSION_DENIED;
     123
     124    *gid = ppw->pw_gid;
     125    *uid = ppw->pw_uid;
    103126    return VINF_SUCCESS;
    104127#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