Changeset 92618 in vbox for trunk/src/VBox/Runtime/r3/posix/process-creation-posix.cpp
- Timestamp:
- Nov 29, 2021 1:47:56 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148510
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/posix/process-creation-posix.cpp
r92617 r92618 563 563 && (!(fFlags & RTPROC_FLAGS_ENV_CHANGE_RECORD) || RTEnvExistEx(hEnv, "TMPDIR")) ) 564 564 { 565 char szValue[ _4K];565 char szValue[RTPATH_MAX]; 566 566 size_t cbNeeded = confstr(_CS_DARWIN_USER_TEMP_DIR, szValue, sizeof(szValue)); 567 567 if (cbNeeded > 0 && cbNeeded < sizeof(szValue)) … … 690 690 * can guess to accurately up front, so we don't do any guessing and 691 691 * hope everyone is sensible and use UTF-8. 692 * 692 693 * @param hEnvToUse The basic environment to extend with what we manage 693 694 * to parse here. … … 810 811 * @returns IPRT status code. Not all error statuses will be returned and the 811 812 * caller should just continue with whatever is in hEnvToUse. 813 * 812 814 * @param hEnvToUse On input this is the basic user environment, on success 813 815 * in is fleshed out with stuff from the login shell dump. 814 * @param pszAsUser The user name for the profile. NULL if the current 815 * user. 816 * @param uid The UID corrsponding to @a pszAsUser, ~0 if NULL. 817 * @param gid The GID corrsponding to @a pszAsUser, ~0 if NULL. 816 * @param pszAsUser The user name for the profile. 817 * @param uid The UID corrsponding to @a pszAsUser, ~0 if current user. 818 * @param gid The GID corrsponding to @a pszAsUser, ~0 if current user. 818 819 * @param pszShell The login shell. This is a writable string to avoid 819 820 * needing to make a copy of it when examining the path … … 1047 1048 static int rtProcPosixCreateProfileEnv(PRTENV phEnvToUse, const char *pszAsUser, uid_t uid, gid_t gid, uint32_t fFlags) 1048 1049 { 1050 /* 1051 * Get the passwd entry for the user. 1052 */ 1049 1053 struct passwd Pwd; 1050 1054 struct passwd *pPwd = NULL; … … 1058 1062 if (rc == 0 && pPwd) 1059 1063 { 1064 /* 1065 * Convert stuff to UTF-8 since the environment is UTF-8. 1066 */ 1060 1067 char *pszDir; 1061 1068 rc = RTStrCurrentCPToUtf8(&pszDir, pPwd->pw_dir); … … 1078 1085 if (RT_SUCCESS(rc)) 1079 1086 { 1087 /* 1088 * Create and populate the environment. 1089 */ 1080 1090 rc = RTEnvCreate(phEnvToUse); 1081 1091 if (RT_SUCCESS(rc)) 1082 1092 { 1083 1093 RTENV hEnvToUse = *phEnvToUse; 1084 1085 1094 rc = RTEnvSetEx(hEnvToUse, "HOME", pszDir); 1086 1095 if (RT_SUCCESS(rc)) … … 1090 1099 if (RT_SUCCESS(rc)) 1091 1100 rc = RTEnvSetEx(hEnvToUse, "LOGNAME", pszAsUser); 1092 1093 1101 if (RT_SUCCESS(rc)) 1094 1102 rc = RTEnvSetEx(hEnvToUse, "PATH", pPwd->pw_uid == 0 ? _PATH_STDPATH : _PATH_DEFPATH); 1095 1103 char szTmpPath[RTPATH_MAX]; 1096 1104 if (RT_SUCCESS(rc)) 1097 1105 { 1098 RTStrPrintf( achBuf, sizeof(achBuf), "%s/%s", _PATH_MAILDIR, pszAsUser);1099 rc = RTEnvSetEx(hEnvToUse, "MAIL", achBuf);1106 RTStrPrintf(szTmpPath, sizeof(szTmpPath), "%s/%s", _PATH_MAILDIR, pszAsUser); 1107 rc = RTEnvSetEx(hEnvToUse, "MAIL", szTmpPath); 1100 1108 } 1101 1102 1109 #ifdef RT_OS_DARWIN 1110 /** @todo r=bird: we should do this for pszAsUserFree == NULL too! */ 1103 1111 if (RT_SUCCESS(rc) && !pszAsUserFree) 1104 1112 { 1105 size_t cbNeeded = confstr(_CS_DARWIN_USER_TEMP_DIR, achBuf, sizeof(achBuf)); 1106 if (cbNeeded > 0 && cbNeeded < sizeof(achBuf)) 1113 /* We put the "wrong" TMPDIR here now and then let 1114 rtProcPosixAdjustProfileEnvFromChild fix it later on. See 1115 https://opensource.apple.com/source/Libc/Libc-997.1.1/darwin/_dirhelper.c 1116 for the implemntation of this query. */ 1117 size_t cbNeeded = confstr(_CS_DARWIN_USER_TEMP_DIR, szTmpPath, sizeof(szTmpPath)); 1118 if (cbNeeded > 0 && cbNeeded < sizeof(szTmpPath)) 1107 1119 { 1108 1120 char *pszTmp; 1109 rc = RTStrCurrentCPToUtf8(&pszTmp, achBuf);1121 rc = RTStrCurrentCPToUtf8(&pszTmp, szTmpPath); 1110 1122 if (RT_SUCCESS(rc)) 1111 1123 {
Note:
See TracChangeset
for help on using the changeset viewer.