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 +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -210,7 +210,12 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
210210 struct passwd * pwd = hyper_getpwnam (user );
211211 if (pwd == NULL ) {
212212 perror ("can't find the user" );
213- return -1 ;
213+ unsigned long id ;
214+ if (!hyper_name_to_id (user , & id ))
215+ return -1 ;
216+ uid = id ;
217+ gid = 0 ;
218+ goto setup ;
214219 }
215220 uid = pwd -> pw_uid ;
216221 gid = pwd -> pw_gid ;
@@ -282,6 +287,7 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
282287 ngroups ++ ;
283288 }
284289
290+ setup :
285291 // setup the owner of tty
286292 if (exec -> tty ) {
287293 char ptmx [512 ];
@@ -293,7 +299,7 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
293299 }
294300
295301 // apply
296- if (setgroups (ngroups , groups ) < 0 ) {
302+ if (groups && setgroups (ngroups , groups ) < 0 ) {
297303 perror ("setgroups() fails" );
298304 goto fail ;
299305 }
@@ -306,9 +312,7 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
306312 goto fail ;
307313 }
308314 free (groups );
309-
310315 return 0 ;
311-
312316fail :
313317 free (groups );
314318 return -1 ;
You can’t perform that action at this time.
0 commit comments