Changeset 42069 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Jul 9, 2012 6:10:08 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/generic/AutostartDb-generic.cpp
r41999 r42069 32 32 #if defined(RT_OS_LINUX) 33 33 /** 34 * Return the username of the current process.35 *36 * @returns Pointer to the string containing the username of37 * NULL in case of an error. Free with RTMemFree().38 */39 static int autostartGetProcessUser(char **ppszUser)40 {41 int rc = VINF_SUCCESS;42 size_t cbUser = 128;43 char *pszUser = (char *)RTMemAllocZ(cbUser);44 45 if (pszUser)46 {47 rc = RTProcQueryUsername(RTProcSelf(), pszUser, cbUser, &cbUser);48 if (rc == VERR_BUFFER_OVERFLOW)49 {50 char *pszTmp = (char *)RTMemRealloc(pszUser, cbUser);51 if (pszTmp)52 {53 pszUser = pszTmp;54 rc = RTProcQueryUsername(RTProcSelf(), pszUser, cbUser, &cbUser);55 Assert(rc != VERR_BUFFER_OVERFLOW);56 }57 }58 59 if (RT_FAILURE(rc))60 {61 RTMemFree(pszUser);62 pszUser = NULL;63 }64 else65 *ppszUser = pszUser;66 }67 68 return rc;69 }70 71 /**72 34 * Modifies the autostart database. 73 35 * … … 81 43 char *pszUser = NULL; 82 44 83 rc = autostartGetProcessUser(&pszUser); 84 if ( RT_SUCCESS(rc) 85 && pszUser) 45 rc = RTProcQueryUsernameA(RTProcSelf(), &pszUser); 46 if (RT_SUCCESS(rc)) 86 47 { 87 48 char *pszFile; 88 49 uint64_t fOpen = RTFILE_O_DENY_ALL | RTFILE_O_READWRITE; 89 50 RTFILE hAutostartFile; 51 52 AssertPtr(pszUser); 90 53 91 54 if (fAddVM) … … 162 125 RTStrFree(pszFile); 163 126 } 127 128 RTStrFree(pszUser); 164 129 } 165 else if (pszUser)166 rc = VERR_NOT_SUPPORTED;167 130 168 131 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.