diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index 77636015f340..4469d4acf7e0 100644 --- a/libexec/rshd/rshd.c +++ b/libexec/rshd/rshd.c @@ -469,6 +469,11 @@ doit(fromp) error("Logins currently disabled.\n"); exit(1); } +#if BSD > 43 + /* before fork, while we're session leader */ + if (setlogin(pwd->pw_name) < 0) + syslog(LOG_ERR, "setlogin() failed: %m"); +#endif (void) write(STDERR_FILENO, "\0", 1); sent_null = 1; @@ -643,10 +648,6 @@ doit(fromp) } if (*pwd->pw_shell == '\0') pwd->pw_shell = _PATH_BSHELL; -#if BSD > 43 - if (setlogin(pwd->pw_name) < 0) - syslog(LOG_ERR, "setlogin() failed: %m"); -#endif (void) setgid((gid_t)pwd->pw_gid); initgroups(pwd->pw_name, pwd->pw_gid); (void) setuid((uid_t)pwd->pw_uid);