Changeset 29582 in vbox for trunk/src/VBox
- Timestamp:
- May 17, 2010 7:40:34 PM (15 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r29534 r29582 1060 1060 VBoxRT_LIBS += lzo2 1061 1061 endif 1062 VBoxRT_LIBS.linux = \ 1063 crypt 1062 1064 VBoxRT_LIBS.darwin = \ 1063 1065 iconv -
trunk/src/VBox/Runtime/r3/posix/process-posix.cpp
r29328 r29582 39 39 #include <fcntl.h> 40 40 #include <signal.h> 41 #if defined(RT_OS_LINUX) 42 # include <pwd.h> 43 # include <shadow.h> 44 #endif 41 45 #if defined(RT_OS_LINUX) || defined(RT_OS_OS2) 42 46 # define HAVE_POSIX_SPAWN 1 … … 61 65 #include "internal/process.h" 62 66 67 68 /** 69 * Check the credentials and return the gid/uid of user. 70 * 71 * @param pszUser username 72 * @param pszPasswd password 73 * @param gid where to store the GID of the user 74 * @param uid where to store the UID of the user 75 * @returns IPRT status code 76 */ 77 static int rtCheckCredentials(const char *pszUser, const char *pszPasswd, gid_t *gid, uid_t *uid) 78 { 79 #if defined(RT_OS_LINUX) 80 struct passwd *pw; 81 82 pw = getpwnam(pszUser); 83 if (!pw) 84 return VERR_PERMISSION_DENIED; 85 86 if (!pszPasswd) 87 pszPasswd = ""; 88 89 struct spwd *spwd; 90 /* works only if /etc/shadow is accessible */ 91 spwd = getspnam(pszUser); 92 if (spwd) 93 pw->pw_passwd = spwd->sp_pwdp; 94 95 char *pszEncPasswd = crypt(pszPasswd, pw->pw_passwd); 96 if (strcmp(pszEncPasswd, pw->pw_passwd)) 97 return VERR_PERMISSION_DENIED; 98 99 *gid = pw->pw_gid; 100 *uid = pw->pw_uid; 101 return VINF_SUCCESS; 102 #else 103 return VERR_PERMISSION_DENIED; 104 #endif 105 } 63 106 64 107 … … 148 191 if (pszAsUser) 149 192 { 150 AssertMsgFailed(("Implement get uid by name lookup\n")); 151 return VERR_NOT_IMPLEMENTED; 193 rc = rtCheckCredentials(pszAsUser, pszPassword, &gid, &uid); 194 if (RT_FAILURE(rc)) 195 return rc; 152 196 } 153 197
Note:
See TracChangeset
for help on using the changeset viewer.