Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 4ed10ee

Browse files
committed
always set the group of the pts to tty
Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
1 parent 4845347 commit 4ed10ee

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/exec.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,15 @@ static int hyper_setup_exec_user(struct hyper_exec *exec)
278278

279279
// setup the owner of tty
280280
if (exec->tty) {
281+
gid_t tty_gid = gid;
281282
char ptmx[512];
282283
sprintf(ptmx, "/dev/pts/%d", exec->ptyno);
283-
if (chown(ptmx, uid, gid) < 0) {
284+
285+
struct group *gr = hyper_getgrnam("tty");
286+
if (gr != NULL) {
287+
tty_gid = gr->gr_gid;
288+
}
289+
if (chown(ptmx, uid, tty_gid) < 0) {
284290
perror("failed to change the owner for the slave pty file");
285291
goto fail;
286292
}

0 commit comments

Comments
 (0)