提交 92801490 编写于 作者: C cheng_jinsong

begetctl cmd can show users in group

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
Change-Id: If1f522a7ac49d9e94e586f7693396d578fa0c486
上级 d62787cc
......@@ -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.
先完成此消息的编辑!
想要评论请 注册