diff --git a/src/screen.c b/src/screen.c index 97360fe..35c6c9a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -90,13 +90,13 @@ static void SetTtyname(bool fatal, struct stat *st); int nversion; /* numerical version, used for secondary DA */ /* the attacher */ -bool do_auth = false; -struct passwd *ppp; -char *attach_tty; -int attach_fd = -1; -char *attach_term; -char *LoginName; -struct mode attach_Mode; +bool do_auth = false; +struct passwd *ppp; +char *attach_tty; +int attach_fd = -1; +char *attach_term; +char *LoginName; +struct mode attach_Mode; /* Indicator whether the current tty exists in another namespace. */ bool attach_tty_is_in_new_ns = false; @@ -948,7 +948,7 @@ int main(int argc, char **argv) *ap = '-'; if (strlen(socknamebuf) > FILENAME_MAX) socknamebuf[FILENAME_MAX - 1] = 0; - snprintf(SocketPath + strlen(SocketPath), sizeof(SocketPath) - strlen(SocketPath) + 2, "/%s", socknamebuf); + snprintf(SocketPath + strlen(SocketPath), sizeof(SocketPath) - strlen(SocketPath), "/%s", socknamebuf); SET_GUID(); Attacher(); /* NOTREACHED */ @@ -1013,7 +1013,7 @@ int main(int argc, char **argv) if (strlen(socknamebuf) > FILENAME_MAX) { socknamebuf[FILENAME_MAX] = 0; } - snprintf(SocketPath + strlen(SocketPath), sizeof(SocketPath) - strlen(SocketPath) + 2, "/%s", socknamebuf); + snprintf(SocketPath + strlen(SocketPath), sizeof(SocketPath) - strlen(SocketPath), "/%s", socknamebuf); ServerSocket = MakeServerSocket(); #ifdef SYSTEM_SCREENRC diff --git a/src/socket.c b/src/socket.c index 7ea4dcb..9c5b8b9 100644 --- a/src/socket.c +++ b/src/socket.c @@ -47,13 +47,9 @@ #include #if ENABLE_PAM - #include +#include #else - #ifdef _PWD_H_ - #include - #else - #include - #endif /* PWD_H */ +#include #endif #include "screen.h" @@ -1207,30 +1203,13 @@ static bool CheckPassword(const char *password) { static bool CheckPassword(const char *password) { bool ret = false; char *passwd = 0; - -#ifndef _PWD_H - struct passwd *p; -#else struct spwd *p; -#endif - gid_t gid = getegid(); uid_t uid = geteuid(); - if (seteuid(0) || setegid(0)) { + if (seteuid(0) || setegid(0)) Panic(0, "\r\ncan't get root uid/gid\r\n"); - printf("Can not get root uid/gid\n"); - } - -#ifndef _PWD_H - p = getpwnam_shadow(ppp->pw_name); -#else p = getspnam(ppp->pw_name); -#endif - - if (p == NULL) - return false; - if (seteuid(uid) || setegid(gid)) Panic(0, "\r\ncan't restore uid/gid\r\n"); @@ -1239,13 +1218,10 @@ static bool CheckPassword(const char *password) { return false; } -#ifndef _PWD_H - passwd = crypt(password, p->pw_passwd); - ret = (strcmp(passwd, p->pw_passwd) == 0); -#else passwd = crypt(password, p->sp_pwdp); - ret = (strcmp(passwd, p->sp_pwdp) == 0); -#endif + + ret = (strcmp(passwd, p->sp_pwdp) == 0); + return ret; } #endif /* ENABLE_PAM */