1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 19:52:20 +00:00

DtPamSvc: Improve user experience.

This commit is contained in:
Liang Chang 2021-02-01 23:43:52 +08:00 committed by Jon Trulson
parent e68846d543
commit c75169ca3f
2 changed files with 3 additions and 18 deletions

View file

@ -48,9 +48,9 @@
#include <errno.h> #include <errno.h>
#include <dirent.h> #include <dirent.h>
#include <sys/param.h> #include <sys/param.h>
#include <pwd.h>
#include <security/pam_appl.h> #include <security/pam_appl.h>
#include <utmpx.h> #include <utmpx.h>
#include <unistd.h>
#include "PamSvc.h" #include "PamSvc.h"
/* /*
@ -69,7 +69,6 @@ static char* create_devname(char* short_devname);
static struct pam_conv pam_conv = {login_conv, NULL}; static struct pam_conv pam_conv = {login_conv, NULL};
static char *saved_user_passwd; static char *saved_user_passwd;
static pam_handle_t *pamh = NULL; static pam_handle_t *pamh = NULL;
static int pam_auth_trys = 0;
/**************************************************************************** /****************************************************************************
* PamInit * PamInit
@ -126,18 +125,8 @@ int _DtAuthentication ( char* prog_name,
status = PamInit(prog_name, user, line_dev, display_name); status = PamInit(prog_name, user, line_dev, display_name);
if (status == PAM_SUCCESS) { if (status == PAM_SUCCESS) {
struct passwd *pwd;
saved_user_passwd = user_passwd; saved_user_passwd = user_passwd;
status = pam_authenticate( pamh, 0 ); status = pam_authenticate( pamh, 0 );
pam_auth_trys++;
if (status != PAM_SUCCESS) {
sleep(PAM_LOGIN_SLEEPTIME);
if (pam_auth_trys > PAM_LOGIN_MAXTRIES) {
sleep(PAM_LOGIN_DISABLETIME);
}
}
}; };
if (status != PAM_SUCCESS) { if (status != PAM_SUCCESS) {
@ -208,8 +197,8 @@ int _DtSetCred(char* prog_name, char* user, uid_t uid, gid_t gid)
if (status == PAM_SUCCESS && setgid(gid) == -1) if (status == PAM_SUCCESS && setgid(gid) == -1)
status = DT_BAD_GID; status = DT_BAD_GID;
if (status == PAM_SUCCESS && if ((status == PAM_SUCCESS &&
( !user) || (initgroups(user, gid) == -1) ) !user) || (initgroups(user, gid) == -1))
status = DT_INITGROUP_FAIL; status = DT_INITGROUP_FAIL;
if (status == PAM_SUCCESS) if (status == PAM_SUCCESS)

View file

@ -43,10 +43,6 @@
#include <sys/types.h> #include <sys/types.h>
#define PAM_LOGIN_MAXTRIES 5
#define PAM_LOGIN_SLEEPTIME 4
#define PAM_LOGIN_DISABLETIME 20
#define DT_BAD_GID 29 /* Invalid Group ID */ #define DT_BAD_GID 29 /* Invalid Group ID */
#define DT_INITGROUP_FAIL 30 /* group IDs init failed */ #define DT_INITGROUP_FAIL 30 /* group IDs init failed */
#define DT_BAD_UID 31 /* Invaid User ID */ #define DT_BAD_UID 31 /* Invaid User ID */