if (getttyname_malloc(STDIN_FILENO, &q) >= 0)
tty = strjoina("/dev/", q);
- else
- /* If everything else failed then let's just use value "systemd". This will cause that session
- * isn't going to be marked as "background" and user manager will be started. */
- tty = "systemd";
}
- pam_code = pam_set_item(handle, PAM_TTY, tty);
- if (pam_code != PAM_SUCCESS)
- goto fail;
+ if (tty) {
+ pam_code = pam_set_item(handle, PAM_TTY, tty);
+ if (pam_code != PAM_SUCCESS)
+ goto fail;
+ }
STRV_FOREACH(nv, *env) {
pam_code = pam_putenv(handle, *nv);
return r;
if (manager_add_user_by_uid(m, uid, &u) >= 0)
- user_start(u, /* want_user_instance= */ true);
+ user_start(u);
} else {
User *u;
after = strv_new("systemd-logind.service",
s->user->runtime_dir_service,
!uid_is_system(s->user->user_record->uid) ? "systemd-user-sessions.service" : STRV_IGNORE,
- s->class != SESSION_BACKGROUND ? s->user->service : STRV_IGNORE);
+ s->user->service);
if (!after)
return log_oom();
description,
/* These two have StopWhenUnneeded= set, hence add a dep towards them */
STRV_MAKE(s->user->runtime_dir_service,
- s->class != SESSION_BACKGROUND ? s->user->service : NULL),
+ s->user->service),
after,
user_record_home_directory(s->user->user_record),
properties,
if (s->started)
return 0;
- r = user_start(s->user, /* want_user_instance= */ s->class != SESSION_BACKGROUND);
+ r = user_start(s->user);
if (r < 0)
return r;
return 0;
}
-int user_start(User *u, bool want_user_instance) {
+int user_start(User *u) {
assert(u);
if (u->started && !u->stopping)
(void) user_update_slice(u);
/* Start user@UID.service */
- if (want_user_instance)
- user_start_service(u);
+ user_start_service(u);
if (!u->started) {
if (!dual_timestamp_is_set(&u->timestamp))
bool user_may_gc(User *u, bool drop_not_started);
void user_add_to_gc_queue(User *u);
-int user_start(User *u, bool need_user_instance);
+int user_start(User *u);
int user_stop(User *u, bool force);
int user_finalize(User *u);
UserState user_get_state(User *u);
int r;
Seat *seat;
Session *session;
+ User *user;
Button *button;
Inhibitor *inhibitor;
HASHMAP_FOREACH(seat, m->seats)
(void) seat_start(seat);
- /* Users are started by respective sessions */
+ HASHMAP_FOREACH(user, m->users)
+ (void) user_start(user);
+
HASHMAP_FOREACH(session, m->sessions)
(void) session_start(session, NULL, NULL);
* does the PAM session registration early for new connections, and registers a pty only
* much later (this is because it doesn't know yet if it needs one at all, as whether to
* register a pty or not is negotiated much later in the protocol). */
- } else if (streq(tty, "systemd")) {
- if (isempty(class))
- class = "user";
- tty = NULL;
+
} else
/* Chop off leading /dev prefix that some clients specify, but others do not. */
tty = skip_dev_prefix(tty);