chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v234: Apply missing upstream fixes in src/login (3/6)
[elogind.git]
/
src
/
login
/
logind-seat.c
diff --git
a/src/login/logind-seat.c
b/src/login/logind-seat.c
index 1be8713754c3fec5503c8c8e06a6b8a9273fc3c4..de27e713747af54953c4d7d6dea6fbddebcf8a96 100644
(file)
--- a/
src/login/logind-seat.c
+++ b/
src/login/logind-seat.c
@@
-1,5
+1,3
@@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-20,17
+18,24
@@
***/
#include <errno.h>
***/
#include <errno.h>
-#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <fcntl.h>
#include <string.h>
+#include <unistd.h>
#include "sd-messages.h"
#include "sd-messages.h"
-#include "logind-seat.h"
+
+#include "alloc-util.h"
+#include "fd-util.h"
+#include "fileio.h"
+#include "format-util.h"
#include "logind-acl.h"
#include "logind-acl.h"
-#include "
util
.h"
+#include "
logind-seat
.h"
#include "mkdir.h"
#include "mkdir.h"
-#include "formats-util.h"
+#include "parse-util.h"
+#include "stdio-util.h"
+#include "string-util.h"
#include "terminal-util.h"
#include "terminal-util.h"
+#include "util.h"
Seat *seat_new(Manager *m, const char *id) {
Seat *s;
Seat *seat_new(Manager *m, const char *id) {
Seat *s;
@@
-43,18
+48,15
@@
Seat *seat_new(Manager *m, const char *id) {
return NULL;
s->state_file = strappend("/run/systemd/seats/", id);
return NULL;
s->state_file = strappend("/run/systemd/seats/", id);
- if (!s->state_file) {
- free(s);
- return NULL;
- }
+ if (!s->state_file)
+ return mfree(s);
s->id = basename(s->state_file);
s->manager = m;
if (hashmap_put(m->seats, s->id, s) < 0) {
free(s->state_file);
s->id = basename(s->state_file);
s->manager = m;
if (hashmap_put(m->seats, s->id, s) < 0) {
free(s->state_file);
- free(s);
- return NULL;
+ return mfree(s);
}
return s;
}
return s;
@@
-169,15
+171,14
@@
int seat_load(Seat *s) {
return 0;
}
return 0;
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
static int vt_allocate(unsigned int vtnr) {
char p[sizeof("/dev/tty") + DECIMAL_STR_MAX(unsigned int)];
_cleanup_close_ int fd = -1;
assert(vtnr >= 1);
static int vt_allocate(unsigned int vtnr) {
char p[sizeof("/dev/tty") + DECIMAL_STR_MAX(unsigned int)];
_cleanup_close_ int fd = -1;
assert(vtnr >= 1);
-
snprintf(p, sizeof(p)
, "/dev/tty%u", vtnr);
+
xsprintf(p
, "/dev/tty%u", vtnr);
fd = open_terminal(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
return -errno;
fd = open_terminal(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0)
return -errno;
@@
-364,9
+365,7
@@
int seat_active_vt_changed(Seat *s, unsigned int vtnr) {
}
r = seat_set_active(s, new_active);
}
r = seat_set_active(s, new_active);
-
-/// elogind does not spawn autovt
-#if 0
+#if 0 /// elogind does not spawn autovt
manager_spawn_autovt(s->manager, vtnr);
#endif // 0
manager_spawn_autovt(s->manager, vtnr);
#endif // 0
@@
-384,7
+383,8
@@
int seat_read_active_vt(Seat *s) {
if (!seat_has_vts(s))
return 0;
if (!seat_has_vts(s))
return 0;
- lseek(s->manager->console_active_fd, SEEK_SET, 0);
+ if (lseek(s->manager->console_active_fd, SEEK_SET, 0) < 0)
+ return log_error_errno(errno, "lseek on console_active_fd failed: %m");
k = read(s->manager->console_active_fd, t, sizeof(t)-1);
if (k <= 0) {
k = read(s->manager->console_active_fd, t, sizeof(t)-1);
if (k <= 0) {
@@
-401,10
+401,8
@@
int seat_read_active_vt(Seat *s) {
}
r = safe_atou(t+3, &vtnr);
}
r = safe_atou(t+3, &vtnr);
- if (r < 0) {
- log_error("Failed to parse VT number %s", t+3);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse VT number \"%s\": %m", t+3);
if (!vtnr) {
log_error("VT number invalid: %s", t+3);
if (!vtnr) {
log_error("VT number invalid: %s", t+3);
@@
-421,14
+419,13
@@
int seat_start(Seat *s) {
return 0;
log_struct(LOG_INFO,
return 0;
log_struct(LOG_INFO,
-
LOG_MESSAGE_ID(SD_MESSAGE_SEAT_START)
,
+
"MESSAGE_ID=" SD_MESSAGE_SEAT_START_STR
,
"SEAT_ID=%s", s->id,
LOG_MESSAGE("New seat %s.", s->id),
NULL);
/* Initialize VT magic stuff */
"SEAT_ID=%s", s->id,
LOG_MESSAGE("New seat %s.", s->id),
NULL);
/* Initialize VT magic stuff */
-/// elogind does not support autospawning vts
-#if 0
+#if 0 /// elogind does not support autospawning vts
seat_preallocate_vts(s);
#endif // 0
seat_preallocate_vts(s);
#endif // 0
@@
-452,7
+449,7
@@
int seat_stop(Seat *s, bool force) {
if (s->started)
log_struct(LOG_INFO,
if (s->started)
log_struct(LOG_INFO,
-
LOG_MESSAGE_ID(SD_MESSAGE_SEAT_STOP)
,
+
"MESSAGE_ID=" SD_MESSAGE_SEAT_STOP_STR
,
"SEAT_ID=%s", s->id,
LOG_MESSAGE("Removed seat %s.", s->id),
NULL);
"SEAT_ID=%s", s->id,
LOG_MESSAGE("Removed seat %s.", s->id),
NULL);
@@
-549,8
+546,6
@@
int seat_attach_session(Seat *s, Session *session) {
LIST_PREPEND(sessions_by_seat, s->sessions, session);
seat_assign_position(s, session);
LIST_PREPEND(sessions_by_seat, s->sessions, session);
seat_assign_position(s, session);
- seat_send_changed(s, "Sessions", NULL);
-
/* On seats with VTs, the VT logic defines which session is active. On
* seats without VTs, we automatically activate new sessions. */
if (!seat_has_vts(s))
/* On seats with VTs, the VT logic defines which session is active. On
* seats without VTs, we automatically activate new sessions. */
if (!seat_has_vts(s))