1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <fcntl.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <unistd.h>
20
21 #include "appspawn.h"
22 #include "appspawn_manager.h"
23 #include "appspawn_msg.h"
24 #include "appspawn_utils.h"
25 #include "securec.h"
26
GetAppSpawnMsgInfo(const AppSpawnMsgNode * message,int type)27 void *GetAppSpawnMsgInfo(const AppSpawnMsgNode *message, int type)
28 {
29 APPSPAWN_CHECK(type < TLV_MAX, return NULL, "Invalid tlv type %{public}u", type);
30 APPSPAWN_CHECK_ONLY_EXPER(message != NULL && message->buffer != NULL, return NULL);
31 APPSPAWN_CHECK_ONLY_EXPER(message->tlvOffset != NULL, return NULL);
32 APPSPAWN_CHECK_ONLY_EXPER(message->tlvOffset[type] != INVALID_OFFSET, return NULL);
33 return (void *)(message->buffer + message->tlvOffset[type] + sizeof(AppSpawnTlv));
34 }
35
GetAppSpawnMsgExtInfo(const AppSpawnMsgNode * message,const char * name,uint32_t * len)36 void *GetAppSpawnMsgExtInfo(const AppSpawnMsgNode *message, const char *name, uint32_t *len)
37 {
38 APPSPAWN_CHECK(name != NULL, return NULL, "Invalid name ");
39 APPSPAWN_CHECK_ONLY_EXPER(message != NULL && message->buffer != NULL, return NULL);
40 APPSPAWN_CHECK_ONLY_EXPER(message->tlvOffset != NULL, return NULL);
41
42 APPSPAWN_LOGV("GetAppSpawnMsgExtInfo tlvCount %{public}d name %{public}s", message->tlvCount, name);
43 for (uint32_t index = TLV_MAX; index < (TLV_MAX + message->tlvCount); index++) {
44 if (message->tlvOffset[index] == INVALID_OFFSET) {
45 return NULL;
46 }
47 uint8_t *data = message->buffer + message->tlvOffset[index];
48 if (((AppSpawnTlv *)data)->tlvType != TLV_MAX) {
49 continue;
50 }
51 AppSpawnTlvExt *tlv = (AppSpawnTlvExt *)data;
52 if (strcmp(tlv->tlvName, name) != 0) {
53 continue;
54 }
55 if (len != NULL) {
56 *len = tlv->dataLen;
57 }
58 return data + sizeof(AppSpawnTlvExt);
59 }
60 return NULL;
61 }
62
CheckAppSpawnMsgFlag(const AppSpawnMsgNode * message,uint32_t type,uint32_t index)63 int CheckAppSpawnMsgFlag(const AppSpawnMsgNode *message, uint32_t type, uint32_t index)
64 {
65 APPSPAWN_CHECK(type == TLV_MSG_FLAGS || type == TLV_PERMISSION, return 0, "Invalid tlv %{public}u ", type);
66 AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, type);
67 APPSPAWN_CHECK(msgFlags != NULL, return 0, "No tlv %{public}u in msg", type);
68 uint32_t blockIndex = index / 32; // 32 max bit in int
69 uint32_t bitIndex = index % 32; // 32 max bit in int
70 APPSPAWN_CHECK(blockIndex < msgFlags->count, return 0,
71 "Invalid index %{public}d max: %{public}d", index, msgFlags->count);
72 return CHECK_FLAGS_BY_INDEX(msgFlags->flags[blockIndex], bitIndex);
73 }
74
SetSpawnMsgFlags(AppSpawnMsgFlags * msgFlags,uint32_t index)75 static inline int SetSpawnMsgFlags(AppSpawnMsgFlags *msgFlags, uint32_t index)
76 {
77 uint32_t blockIndex = index / 32; // 32 max bit in int
78 uint32_t bitIndex = index % 32; // 32 max bit in int
79 APPSPAWN_CHECK(blockIndex < msgFlags->count, return APPSPAWN_ARG_INVALID,
80 "Invalid index %{public}u blockIndex %{public}u %{public}u ", index, blockIndex, msgFlags->count);
81 msgFlags->flags[blockIndex] |= (1 << bitIndex);
82 return 0;
83 }
84
SetAppSpawnMsgFlag(const AppSpawnMsgNode * message,uint32_t type,uint32_t index)85 int SetAppSpawnMsgFlag(const AppSpawnMsgNode *message, uint32_t type, uint32_t index)
86 {
87 APPSPAWN_CHECK(type == TLV_MSG_FLAGS || type == TLV_PERMISSION,
88 return APPSPAWN_ARG_INVALID, "Invalid tlv %{public}u ", type);
89 AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, type);
90 APPSPAWN_CHECK(msgFlags != NULL, return APPSPAWN_ARG_INVALID, "No tlv %{public}d in msg", type);
91 return SetSpawnMsgFlags(msgFlags, index);
92 }
93
CreateAppSpawnMsg(void)94 AppSpawnMsgNode *CreateAppSpawnMsg(void)
95 {
96 AppSpawnMsgNode *message = (AppSpawnMsgNode *)calloc(1, sizeof(AppSpawnMsgNode));
97 APPSPAWN_CHECK(message != NULL, return NULL, "Failed to create message");
98 message->buffer = NULL;
99 message->tlvOffset = NULL;
100 return message;
101 }
102
DeleteAppSpawnMsg(AppSpawnMsgNode * msgNode)103 void DeleteAppSpawnMsg(AppSpawnMsgNode *msgNode)
104 {
105 if (msgNode == NULL) {
106 return;
107 }
108 if (msgNode->buffer) {
109 free(msgNode->buffer);
110 msgNode->buffer = NULL;
111 }
112 if (msgNode->tlvOffset) {
113 free(msgNode->tlvOffset);
114 msgNode->tlvOffset = NULL;
115 }
116 free(msgNode);
117 }
118
CheckRecvMsg(const AppSpawnMsg * msg)119 static inline int CheckRecvMsg(const AppSpawnMsg *msg)
120 {
121 APPSPAWN_CHECK(msg != NULL, return -1, "Invalid msg");
122 APPSPAWN_CHECK(msg->magic == APPSPAWN_MSG_MAGIC, return -1, "Invalid magic 0x%{public}x", msg->magic);
123 APPSPAWN_CHECK(msg->msgLen < MAX_MSG_TOTAL_LENGTH, return -1, "Message too long %{public}u", msg->msgLen);
124 APPSPAWN_CHECK(msg->msgLen >= sizeof(AppSpawnMsg), return -1, "Message too long %{public}u", msg->msgLen);
125 APPSPAWN_CHECK(msg->tlvCount < MAX_TLV_COUNT, return -1, "Message too long %{public}u", msg->tlvCount);
126 APPSPAWN_CHECK(msg->tlvCount < (msg->msgLen / sizeof(AppSpawnTlv)),
127 return -1, "Message too long %{public}u", msg->tlvCount);
128 return 0;
129 }
130
AppSpawnMsgRebuild(AppSpawnMsgNode * message,const AppSpawnMsg * msg)131 static int AppSpawnMsgRebuild(AppSpawnMsgNode *message, const AppSpawnMsg *msg)
132 {
133 APPSPAWN_CHECK_ONLY_EXPER(CheckRecvMsg(&message->msgHeader) == 0, return APPSPAWN_MSG_INVALID);
134 if (msg->msgLen == sizeof(message->msgHeader)) { // only has msg header
135 return 0;
136 }
137 if (message->buffer == NULL) {
138 message->buffer = calloc(1, msg->msgLen - sizeof(message->msgHeader));
139 APPSPAWN_CHECK(message->buffer != NULL, return -1, "Failed to alloc memory for recv message");
140 }
141 if (message->tlvOffset == NULL) {
142 uint32_t totalCount = msg->tlvCount + TLV_MAX;
143 message->tlvOffset = malloc(totalCount * sizeof(uint32_t));
144 APPSPAWN_CHECK(message->tlvOffset != NULL, return -1, "Failed to alloc memory for recv message");
145 for (uint32_t i = 0; i < totalCount; i++) {
146 message->tlvOffset[i] = INVALID_OFFSET;
147 }
148 }
149 return 0;
150 }
151
RebuildAppSpawnMsgNode(AppSpawnMsgNode * message,AppSpawnedProcess * appInfo)152 AppSpawnMsgNode *RebuildAppSpawnMsgNode(AppSpawnMsgNode *message, AppSpawnedProcess *appInfo)
153 {
154 #ifdef DEBUG_BEGETCTL_BOOT
155 APPSPAWN_CHECK(message != NULL && appInfo != NULL, return NULL, "params is null");
156 uint32_t bufferLen = 0;
157 AppSpawnMsgNode *node = CreateAppSpawnMsg();
158 APPSPAWN_CHECK(message != NULL, return NULL, "Failed to create AppSpawnMsgNode");
159 int ret = memcpy_s(&node->msgHeader, sizeof(AppSpawnMsg), &message->msgHeader, sizeof(AppSpawnMsg));
160 APPSPAWN_CHECK(ret == 0, return NULL, "Failed to memcpy_s node->msgHeader");
161 bufferLen = message->msgHeader.msgLen + appInfo->message->msgHeader.msgLen - sizeof(AppSpawnMsg);
162 node->msgHeader.msgLen = bufferLen;
163 node->msgHeader.msgType = MSG_SPAWN_NATIVE_PROCESS;
164 node->msgHeader.tlvCount += message->msgHeader.tlvCount;
165 ret = AppSpawnMsgRebuild(node, &node->msgHeader);
166 APPSPAWN_CHECK(ret == 0, return NULL, "Failed to alloc memory for recv message");
167 uint32_t appInfoBufLen = appInfo->message->msgHeader.msgLen - sizeof(AppSpawnMsg);
168 uint32_t msgBufLen = message->msgHeader.msgLen - sizeof(AppSpawnMsg);
169 ret = memcpy_s(node->buffer, bufferLen, appInfo->message->buffer, appInfoBufLen);
170 APPSPAWN_CHECK(ret == 0, return NULL, "Failed to memcpy_s appInfo buffer");
171 ret = memcpy_s(node->buffer + appInfoBufLen, bufferLen - appInfoBufLen, message->buffer, msgBufLen);
172 APPSPAWN_CHECK(ret == 0, return NULL, "Failed to memcpy_s message->buffer");
173 return node;
174 #endif
175 return NULL;
176 }
177
CheckAppSpawnMsg(const AppSpawnMsgNode * message)178 int CheckAppSpawnMsg(const AppSpawnMsgNode *message)
179 {
180 APPSPAWN_CHECK_ONLY_EXPER(message != NULL, return APPSPAWN_MSG_INVALID);
181 APPSPAWN_CHECK(strlen(message->msgHeader.processName) > 0,
182 return APPSPAWN_MSG_INVALID, "Invalid property processName %{public}s", message->msgHeader.processName);
183 APPSPAWN_CHECK(message->tlvOffset != NULL,
184 return APPSPAWN_MSG_INVALID, "Invalid property tlv offset for %{public}s", message->msgHeader.processName);
185 APPSPAWN_CHECK(message->buffer != NULL,
186 return APPSPAWN_MSG_INVALID, "Invalid property buffer for %{public}s", message->msgHeader.processName);
187
188 if (message->tlvOffset[TLV_BUNDLE_INFO] == INVALID_OFFSET ||
189 message->tlvOffset[TLV_MSG_FLAGS] == INVALID_OFFSET ||
190 message->tlvOffset[TLV_ACCESS_TOKEN_INFO] == INVALID_OFFSET ||
191 message->tlvOffset[TLV_DOMAIN_INFO] == INVALID_OFFSET ||
192 message->tlvOffset[TLV_DAC_INFO] == INVALID_OFFSET) {
193 APPSPAWN_LOGE("No must tlv bundle: %{public}u flags: %{public}u token: %{public}u domain %{public}u %{public}u",
194 message->tlvOffset[TLV_BUNDLE_INFO], message->tlvOffset[TLV_MSG_FLAGS],
195 message->tlvOffset[TLV_ACCESS_TOKEN_INFO],
196 message->tlvOffset[TLV_DOMAIN_INFO], message->tlvOffset[TLV_DAC_INFO]);
197 return APPSPAWN_MSG_INVALID;
198 }
199 AppSpawnMsgBundleInfo *bundleInfo = (AppSpawnMsgBundleInfo *)GetAppSpawnMsgInfo(message, TLV_BUNDLE_INFO);
200 if (bundleInfo != NULL) {
201 if (strstr(bundleInfo->bundleName, "\\") != NULL || strstr(bundleInfo->bundleName, "/") != NULL) {
202 APPSPAWN_LOGE("Invalid bundle name %{public}s", bundleInfo->bundleName);
203 return APPSPAWN_MSG_INVALID;
204 }
205 }
206 return 0;
207 }
208
CheckExtTlvInfo(const AppSpawnTlv * tlv,uint32_t remainLen)209 static int CheckExtTlvInfo(const AppSpawnTlv *tlv, uint32_t remainLen)
210 {
211 AppSpawnTlvExt *tlvExt = (AppSpawnTlvExt *)(tlv);
212 APPSPAWN_LOGV("Recv type [%{public}s %{public}u] real len: %{public}u",
213 tlvExt->tlvName, tlvExt->tlvLen, tlvExt->dataLen);
214 if (tlvExt->dataLen > tlvExt->tlvLen - sizeof(AppSpawnTlvExt)) {
215 APPSPAWN_LOGE("Invalid tlv [%{public}s %{public}u] real len: %{public}u %{public}zu",
216 tlvExt->tlvName, tlvExt->tlvLen, tlvExt->dataLen, sizeof(AppSpawnTlvExt));
217 return APPSPAWN_MSG_INVALID;
218 }
219 return 0;
220 }
221
CheckMsgTlv(const AppSpawnTlv * tlv,uint32_t remainLen)222 static int CheckMsgTlv(const AppSpawnTlv *tlv, uint32_t remainLen)
223 {
224 uint32_t tlvLen = 0;
225 switch (tlv->tlvType) {
226 case TLV_MSG_FLAGS:
227 tlvLen = ((AppSpawnMsgFlags *)(tlv + 1))->count * sizeof(uint32_t);
228 break;
229 case TLV_ACCESS_TOKEN_INFO:
230 tlvLen = sizeof(AppSpawnMsgAccessToken);
231 break;
232 case TLV_DAC_INFO:
233 tlvLen = sizeof(AppSpawnMsgDacInfo);
234 break;
235 case TLV_BUNDLE_INFO:
236 APPSPAWN_CHECK((tlv->tlvLen - sizeof(AppSpawnTlv)) <= (sizeof(AppSpawnMsgBundleInfo) + APP_LEN_BUNDLE_NAME),
237 return APPSPAWN_MSG_INVALID, "Invalid property tlv %{public}d %{public}d ", tlv->tlvType, tlv->tlvLen);
238 break;
239 case TLV_OWNER_INFO:
240 APPSPAWN_CHECK((tlv->tlvLen - sizeof(AppSpawnTlv)) <= APP_OWNER_ID_LEN,
241 return APPSPAWN_MSG_INVALID, "Invalid property tlv %{public}d %{public}d ", tlv->tlvType, tlv->tlvLen);
242 break;
243 case TLV_DOMAIN_INFO:
244 APPSPAWN_CHECK((tlv->tlvLen - sizeof(AppSpawnTlv)) <= (APP_APL_MAX_LEN + sizeof(AppSpawnMsgDomainInfo)),
245 return APPSPAWN_MSG_INVALID, "Invalid property tlv %{public}d %{public}d ", tlv->tlvType, tlv->tlvLen);
246 break;
247 case TLV_MAX:
248 return CheckExtTlvInfo(tlv, remainLen);
249 default:
250 break;
251 }
252 APPSPAWN_CHECK(tlvLen <= tlv->tlvLen,
253 return APPSPAWN_MSG_INVALID, "Invalid property tlv %{public}d %{public}d ", tlv->tlvType, tlv->tlvLen);
254 return 0;
255 }
256
DecodeAppSpawnMsg(AppSpawnMsgNode * message)257 int DecodeAppSpawnMsg(AppSpawnMsgNode *message)
258 {
259 APPSPAWN_CHECK_ONLY_EXPER(message != NULL, return APPSPAWN_MSG_INVALID);
260 int ret = 0;
261 uint32_t tlvCount = 0;
262 uint32_t bufferLen = message->msgHeader.msgLen - sizeof(AppSpawnMsg);
263 uint32_t currLen = 0;
264 while (currLen < bufferLen) {
265 AppSpawnTlv *tlv = (AppSpawnTlv *)(message->buffer + currLen);
266 APPSPAWN_CHECK(tlv->tlvLen <= (bufferLen - currLen), break,
267 "Invalid tlv [%{public}d %{public}d] curr: %{public}zu",
268 tlv->tlvType, tlv->tlvLen, currLen + sizeof(AppSpawnMsg));
269
270 APPSPAWN_LOGV("DecodeAppSpawnMsg tlv %{public}u %{public}u start: %{public}zu ",
271 tlv->tlvType, tlv->tlvLen, currLen + sizeof(AppSpawnMsg)); // show in msg offset
272 ret = CheckMsgTlv(tlv, bufferLen - currLen);
273 APPSPAWN_CHECK_ONLY_EXPER(ret == 0, break);
274
275 if (tlv->tlvType < TLV_MAX) { // normal
276 message->tlvOffset[tlv->tlvType] = currLen;
277 currLen += tlv->tlvLen;
278 } else {
279 APPSPAWN_CHECK(tlvCount < message->msgHeader.tlvCount, break,
280 "Invalid tlv number tlv %{public}d tlvCount: %{public}d", tlv->tlvType, tlvCount);
281 message->tlvOffset[TLV_MAX + tlvCount] = currLen;
282 tlvCount++;
283 currLen += tlv->tlvLen;
284 }
285 }
286 APPSPAWN_CHECK_ONLY_EXPER(currLen >= bufferLen, return APPSPAWN_MSG_INVALID);
287 // save real ext tlv count
288 message->tlvCount = tlvCount;
289 return 0;
290 }
291
GetAppSpawnMsgFromBuffer(const uint8_t * buffer,uint32_t bufferLen,AppSpawnMsgNode ** outMsg,uint32_t * msgRecvLen,uint32_t * reminder)292 int GetAppSpawnMsgFromBuffer(const uint8_t *buffer, uint32_t bufferLen,
293 AppSpawnMsgNode **outMsg, uint32_t *msgRecvLen, uint32_t *reminder)
294 {
295 APPSPAWN_CHECK_ONLY_EXPER(buffer != NULL && outMsg != NULL, return APPSPAWN_MSG_INVALID);
296 APPSPAWN_CHECK_ONLY_EXPER(msgRecvLen != NULL && reminder != NULL, return APPSPAWN_MSG_INVALID);
297 *reminder = 0;
298 AppSpawnMsgNode *message = *outMsg;
299 if (message == NULL) {
300 message = CreateAppSpawnMsg();
301 APPSPAWN_CHECK(message != NULL, return APPSPAWN_SYSTEM_ERROR, "Failed to create message");
302 *outMsg = message;
303 }
304
305 uint32_t reminderLen = bufferLen;
306 const uint8_t *reminderBuffer = buffer;
307 if (*msgRecvLen < sizeof(AppSpawnMsg)) { // recv partial message
308 if ((bufferLen + *msgRecvLen) >= sizeof(AppSpawnMsg)) {
309 int ret = memcpy_s(((uint8_t *)&message->msgHeader) + *msgRecvLen,
310 sizeof(message->msgHeader) - *msgRecvLen,
311 buffer, sizeof(message->msgHeader) - *msgRecvLen);
312 APPSPAWN_CHECK(ret == EOK, return -1, "Failed to copy recv buffer");
313
314 ret = AppSpawnMsgRebuild(message, &message->msgHeader);
315 APPSPAWN_CHECK(ret == 0, return -1, "Failed to alloc buffer for receive msg");
316 reminderLen = bufferLen - (sizeof(message->msgHeader) - *msgRecvLen);
317 reminderBuffer = buffer + sizeof(message->msgHeader) - *msgRecvLen;
318 *msgRecvLen = sizeof(message->msgHeader);
319 } else {
320 int ret = memcpy_s(((uint8_t *)&message->msgHeader) + *msgRecvLen,
321 sizeof(message->msgHeader) - *msgRecvLen, buffer, bufferLen);
322 APPSPAWN_CHECK(ret == EOK, return -1, "Failed to copy recv buffer");
323 *msgRecvLen += bufferLen;
324 return 0;
325 }
326 }
327 // do not copy msg header
328 uint32_t realCopy = (reminderLen + *msgRecvLen) > message->msgHeader.msgLen ?
329 message->msgHeader.msgLen - *msgRecvLen : reminderLen;
330 if (message->buffer == NULL) { // only has msg header
331 return 0;
332 }
333 APPSPAWN_LOGV("HandleRecvBuffer msgRecvLen: %{public}u reminderLen %{public}u realCopy %{public}u",
334 *msgRecvLen, reminderLen, realCopy);
335 int ret = memcpy_s(message->buffer + *msgRecvLen - sizeof(message->msgHeader),
336 message->msgHeader.msgLen - *msgRecvLen, reminderBuffer, realCopy);
337 APPSPAWN_CHECK(ret == EOK, return -1, "Failed to copy recv buffer");
338 *msgRecvLen += realCopy;
339 if (realCopy < reminderLen) {
340 *reminder = reminderLen - realCopy;
341 }
342 return 0;
343 }
344
DumpMsgFlags(const char * info,const AppSpawnMsgFlags * msgFlags)345 static inline void DumpMsgFlags(const char *info, const AppSpawnMsgFlags *msgFlags)
346 {
347 APPSPAPWN_DUMP("%{public}s count: %{public}u ", info, msgFlags->count);
348 for (uint32_t i = 0; i < msgFlags->count; i++) {
349 APPSPAPWN_DUMP("%{public}s flags: 0x%{public}x", info, msgFlags->flags[i]);
350 }
351 }
352
DumpMsgExtInfo(const AppSpawnTlv * tlv)353 static inline void DumpMsgExtInfo(const AppSpawnTlv *tlv)
354 {
355 if (tlv->tlvType != TLV_MAX) {
356 APPSPAPWN_DUMP("App tlv info: [%{public}d %{public}d]", tlv->tlvType, tlv->tlvLen);
357 return;
358 }
359 AppSpawnTlvExt *tlvExt = (AppSpawnTlvExt *)(tlv);
360 APPSPAPWN_DUMP("App extend info name: %{public}s len: %{public}u", tlvExt->tlvName, tlvExt->dataLen);
361 if (tlvExt->dataType == DATA_TYPE_STRING) {
362 APPSPAPWN_DUMP("App extend info value: '%{public}s'", (char *)(tlvExt + 1));
363 }
364 }
365
DumpAppSpawnMsg(const AppSpawnMsgNode * message)366 void DumpAppSpawnMsg(const AppSpawnMsgNode *message)
367 {
368 APPSPAWN_CHECK_ONLY_EXPER(message != NULL, return);
369 APPSPAPWN_DUMP("App spawn msg msgId: %{public}u msgLen: %{public}u tlvCount: %{public}u",
370 message->msgHeader.msgId, message->msgHeader.msgLen, message->tlvCount);
371 APPSPAPWN_DUMP("App spawn msg process name: %{public}s", message->msgHeader.processName);
372
373 AppSpawnMsgFlags *msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, TLV_MSG_FLAGS);
374 APPSPAWN_ONLY_EXPER(msgFlags != NULL, DumpMsgFlags("App flags", msgFlags));
375 msgFlags = (AppSpawnMsgFlags *)GetAppSpawnMsgInfo(message, TLV_PERMISSION);
376 APPSPAWN_ONLY_EXPER(msgFlags != NULL, DumpMsgFlags("App permission bits", msgFlags));
377
378 AppSpawnMsgDacInfo *dacInfo = (AppSpawnMsgDacInfo *)GetAppSpawnMsgInfo(message, TLV_DAC_INFO);
379 if (dacInfo != NULL) {
380 APPSPAPWN_DUMP("App dac info uid: %{public}d gid: %{public}d count: %{public}d",
381 dacInfo->uid, dacInfo->gid, dacInfo->gidCount);
382 for (uint32_t i = 0; i < dacInfo->gidCount; i++) {
383 APPSPAPWN_DUMP("gid group[%{public}d]: %{public}d", i, dacInfo->gidTable[i]);
384 }
385 }
386 AppSpawnMsgBundleInfo *bundleInfo = (AppSpawnMsgBundleInfo *)GetAppSpawnMsgInfo(message, TLV_BUNDLE_INFO);
387 APPSPAWN_ONLY_EXPER(bundleInfo != NULL,
388 APPSPAPWN_DUMP("App bundle info name: \"%{public}s\" index: %{public}d",
389 bundleInfo->bundleName, bundleInfo->bundleIndex));
390
391 AppSpawnMsgDomainInfo *domainInfo = (AppSpawnMsgDomainInfo *)GetAppSpawnMsgInfo(message, TLV_DOMAIN_INFO);
392 APPSPAWN_ONLY_EXPER(domainInfo != NULL,
393 APPSPAPWN_DUMP("App domain info hap: 0x%{public}x apl: \"%{public}s\"", domainInfo->hapFlags, domainInfo->apl));
394
395 AppSpawnMsgOwnerId *owner = (AppSpawnMsgOwnerId *)GetAppSpawnMsgInfo(message, TLV_OWNER_INFO);
396 APPSPAWN_ONLY_EXPER(owner != NULL, APPSPAPWN_DUMP("App owner info: \"%{public}s\" ", owner->ownerId));
397
398 AppSpawnMsgAccessToken *t = (AppSpawnMsgAccessToken *)GetAppSpawnMsgInfo(message, TLV_ACCESS_TOKEN_INFO);
399 APPSPAWN_ONLY_EXPER(t != NULL,
400 APPSPAPWN_DUMP("App access token info: %{public}" PRId64 "", t->accessTokenIdEx));
401
402 AppSpawnMsgInternetInfo *info = (AppSpawnMsgInternetInfo *)GetAppSpawnMsgInfo(message, TLV_INTERNET_INFO);
403 APPSPAWN_ONLY_EXPER(info != NULL,
404 APPSPAPWN_DUMP("App internet permission info [%{public}d %{public}d]",
405 info->setAllowInternet, info->allowInternet));
406
407 for (uint32_t i = TLV_MAX; i < TLV_MAX + message->tlvCount; i++) {
408 if (message->tlvOffset[i] == INVALID_OFFSET) {
409 continue;
410 }
411 DumpMsgExtInfo((AppSpawnTlv *)(message->buffer + message->tlvOffset[i]));
412 }
413 }