未验证 提交 e3f2294c 编写于 作者: O openharmony_ci 提交者: Gitee

!1622 begetctl dac gid 命令展示group组下所有成员

Merge pull request !1622 from Mupceet/master_cc_add_dac_cmd
......@@ -114,6 +114,18 @@ static int32_t GetUidByName(BShellHandle shell, int argc, char **argv)
return 0;
}
static void ShowUserInGroup(struct group *data)
{
int index = 0;
printf("users in this group:");
while (data->gr_mem[index]) { // user in this group
printf(" %s", data->gr_mem[index]);
index++;
}
printf("\n");
return;
}
static int32_t GetGidByName(BShellHandle shell, int argc, char **argv)
{
if (argc != 2) { // 2 is dac get gid parameter number
......@@ -126,12 +138,14 @@ static int32_t GetGidByName(BShellHandle shell, int argc, char **argv)
printf("getgrnam gid failed\n");
} else {
printf("getgrnam gid %s : %d\n", argv[1], data->gr_gid);
ShowUserInGroup(data);
}
data = NULL;
while ((data = getgrent()) != NULL) {
if ((data->gr_name != NULL) && (strcmp(data->gr_name, argv[1]) == 0)) {
printf("getgrent gid %s : %d\n", argv[1], data->gr_gid);
ShowUserInGroup(data);
break;
}
}
......
......@@ -494,8 +494,9 @@ static void DoCriticalServiceAbnormal(void) {
ExecReboot("reboot");
return;
}
#ifndef STARTUP_INIT_TEST
fwrite((void *)"c", 1, 1, panic);
#endif
fclose(panic);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册