diff options
-rw-r--r-- | src/kmscon_main.c | 8 | ||||
-rw-r--r-- | src/kmscon_seat.c | 8 | ||||
-rw-r--r-- | src/uterm.h | 5 | ||||
-rw-r--r-- | src/uterm_vt.c | 11 | ||||
-rw-r--r-- | tests/test_vt.c | 3 |
5 files changed, 29 insertions, 6 deletions
diff --git a/src/kmscon_main.c b/src/kmscon_main.c index 6992719..246df93 100644 --- a/src/kmscon_main.c +++ b/src/kmscon_main.c @@ -189,8 +189,12 @@ static int app_seat_new(struct kmscon_app *app, struct app_seat **out, ret = kmscon_seat_new(&seat->seat, app->conf_ctx, app->eloop, app->vtm, sname, app_seat_event, seat); if (ret) { - log_error("cannot create seat object on seat %s: %d", - sname, ret); + if (ret == -ERANGE) + log_debug("ignoring seat %s as it already has a seat manager", + sname); + else + log_error("cannot create seat object on seat %s: %d", + sname, ret); goto err_name; } seat->conf_ctx = kmscon_seat_get_conf(seat->seat); diff --git a/src/kmscon_seat.c b/src/kmscon_seat.c index 43ccd74..0493f84 100644 --- a/src/kmscon_seat.c +++ b/src/kmscon_seat.c @@ -638,6 +638,7 @@ int kmscon_seat_new(struct kmscon_seat **out, struct kmscon_seat *seat; int ret; struct kmscon_session *s; + unsigned int allowed_types; if (!out || !eloop || !vtm || !seatname) return -EINVAL; @@ -688,7 +689,12 @@ int kmscon_seat_new(struct kmscon_seat **out, if (ret) goto err_input; - ret = uterm_vt_allocate(seat->vtm, &seat->vt, seat->name, + allowed_types = UTERM_VT_FAKE; + if (!seat->conf->listen) + allowed_types |= UTERM_VT_REAL; + + ret = uterm_vt_allocate(seat->vtm, &seat->vt, + allowed_types, seat->name, seat->input, seat->conf->vt, seat_vt_event, seat); if (ret) diff --git a/src/uterm.h b/src/uterm.h index 0844a9c..1330f85 100644 --- a/src/uterm.h +++ b/src/uterm.h @@ -337,8 +337,8 @@ struct uterm_vt_event { }; enum uterm_vt_type { - UTERM_VT_REAL, - UTERM_VT_FAKE, + UTERM_VT_REAL = 0x01, + UTERM_VT_FAKE = 0x02, }; typedef int (*uterm_vt_cb) (struct uterm_vt *vt, struct uterm_vt_event *ev, @@ -353,6 +353,7 @@ int uterm_vt_master_activate_all(struct uterm_vt_master *vtm); int uterm_vt_master_deactivate_all(struct uterm_vt_master *vtm); int uterm_vt_allocate(struct uterm_vt_master *vt, struct uterm_vt **out, + unsigned int allowed_types, const char *seat, struct uterm_input *input, const char *vt_name, uterm_vt_cb cb, void *data); void uterm_vt_deallocate(struct uterm_vt *vt); diff --git a/src/uterm_vt.c b/src/uterm_vt.c index 42af3c6..8a00052 100644 --- a/src/uterm_vt.c +++ b/src/uterm_vt.c @@ -790,6 +790,7 @@ static int seat_find_vt(const char *seat, char **out) int uterm_vt_allocate(struct uterm_vt_master *vtm, struct uterm_vt **out, + unsigned int allowed_types, const char *seat, struct uterm_input *input, const char *vt_name, @@ -840,9 +841,19 @@ int uterm_vt_allocate(struct uterm_vt_master *vtm, } if (vt_name || path) { + if (!(allowed_types & UTERM_VT_REAL)) { + ret = -ERANGE; + free(path); + goto err_input; + } vt->mode = UTERM_VT_REAL; ret = real_open(vt, vt_name ? vt_name : path); } else { + if (!(allowed_types & UTERM_VT_FAKE)) { + ret = -ERANGE; + free(path); + goto err_input; + } vt->mode = UTERM_VT_FAKE; ret = fake_open(vt); } diff --git a/tests/test_vt.c b/tests/test_vt.c index dd6ee67..25ffe5e 100644 --- a/tests/test_vt.c +++ b/tests/test_vt.c @@ -116,7 +116,8 @@ int main(int argc, char **argv) if (ret) goto err_vtm; - ret = uterm_vt_allocate(vtm, &vt, "seat0", input, vtpath, NULL, NULL); + ret = uterm_vt_allocate(vtm, &vt, UTERM_VT_FAKE | UTERM_VT_REAL, + "seat0", input, vtpath, NULL, NULL); if (ret) goto err_input; |