This repository was archived by the owner on Feb 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -210,13 +210,13 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
210210 fprintf (stdout , "try to find the user: %s\n" , user );
211211 struct passwd * pwd = hyper_getpwnam (user );
212212 if (pwd == NULL ) {
213- perror ("can't find the user" );
214213 unsigned long id ;
215- if (!hyper_name_to_id (user , & id ))
214+ if (!hyper_name_to_id (user , & id )) {
215+ perror ("can't find the user" );
216216 return -1 ;
217+ }
217218 uid = id ;
218- gid = 0 ;
219- goto setup ;
219+ goto get_gid ;
220220 }
221221 uid = pwd -> pw_uid ;
222222 gid = pwd -> pw_gid ;
@@ -255,15 +255,21 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
255255 }
256256 }
257257
258+ get_gid :
258259 // get gid
259260 if (group ) {
260261 fprintf (stdout , "try to find the group: %s\n" , group );
261262 struct group * gr = hyper_getgrnam (group );
262263 if (gr == NULL ) {
263- perror ("can't find the group" );
264- goto fail ;
264+ unsigned long id ;
265+ if (!hyper_name_to_id (group , & id )) {
266+ perror ("can't find the group" );
267+ goto fail ;
268+ }
269+ gid = id ;
270+ } else {
271+ gid = gr -> gr_gid ;
265272 }
266- gid = gr -> gr_gid ;
267273 }
268274
269275 // append additional groups to supplementary groups
@@ -288,7 +294,6 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
288294 ngroups ++ ;
289295 }
290296
291- setup :
292297 // setup the owner of tty
293298 if (exec -> tty ) {
294299 char ptmx [512 ];
You can’t perform that action at this time.
0 commit comments