Skip to content

Commit

Permalink
savannah sync, revert e7c8335
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-naumov committed Aug 3, 2024
1 parent 87e4c2a commit 56f3048
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 39 deletions.
18 changes: 9 additions & 9 deletions src/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
36 changes: 6 additions & 30 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@
#include <signal.h>

#if ENABLE_PAM
#include <security/pam_appl.h>
#include <security/pam_appl.h>
#else
#ifdef _PWD_H_
#include <pwd.h>
#else
#include <shadow.h>
#endif /* PWD_H */
#include <shadow.h>
#endif

#include "screen.h"
Expand Down Expand Up @@ -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");

Expand All @@ -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 */
Expand Down

0 comments on commit 56f3048

Please sign in to comment.