gettext: pam_panic_password
This commit is contained in:
parent
54ffdc16f1
commit
8ad9fad8e6
@ -11,6 +11,10 @@ LICENSE : GNU-GPLv3
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "../config.h"
|
||||
#include "../../lib/gettext.h"
|
||||
|
||||
#include <security/pam_modules.h>
|
||||
#include <security/pam_ext.h>
|
||||
#include <syslog.h>
|
||||
@ -18,21 +22,18 @@ LICENSE : GNU-GPLv3
|
||||
#include "pam_panic_password.h"
|
||||
#include "pam_panic_reject.h"
|
||||
|
||||
#define MSG_NOFILE "ALERT for password option: No password file detected."
|
||||
#define MSG_ERROPEN "ERROR: Couldn't open password file."
|
||||
#define MSG_CORRUPT "CRITICAL: Password file is corrupt!"
|
||||
|
||||
#define _(String) gettext(String)
|
||||
|
||||
int readPassword(pam_handle_t *pamh, char pw[2][99]){
|
||||
|
||||
// Open file
|
||||
if(access(PPASSFILE, F_OK) == -1){
|
||||
pam_syslog(pamh, LOG_ALERT, MSG_NOFILE);
|
||||
pam_syslog(pamh, LOG_ALERT, _("ALERT for passwort option: No password file detected."));
|
||||
return 2;
|
||||
}
|
||||
FILE *f = fopen(PPASSFILE, "r");
|
||||
if(f == NULL){
|
||||
pam_syslog(pamh, LOG_ALERT, MSG_ERROPEN);
|
||||
pam_syslog(pamh, LOG_ALERT, _("ERROR: Couldn't open password file."));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -44,7 +45,7 @@ int readPassword(pam_handle_t *pamh, char pw[2][99]){
|
||||
fclose(f);
|
||||
|
||||
if(nread != 198){
|
||||
pam_syslog(pamh, LOG_CRIT, MSG_CORRUPT);
|
||||
pam_syslog(pamh, LOG_CRIT, _("CRITICAL: Password file is corrupt!"));
|
||||
return 3;
|
||||
}
|
||||
|
||||
@ -65,6 +66,11 @@ int readPassword(pam_handle_t *pamh, char pw[2][99]){
|
||||
|
||||
int authPassword(pam_handle_t *pamh, char *serious_dev, int8_t bSerious, int8_t bReboot, int8_t bPoweroff){
|
||||
|
||||
// gettext
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
// PAM password response
|
||||
char resp[256];
|
||||
char *response = NULL;
|
||||
@ -84,7 +90,7 @@ int authPassword(pam_handle_t *pamh, char *serious_dev, int8_t bSerious, int8_t
|
||||
|
||||
|
||||
|
||||
pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &response, PWPROMPT);
|
||||
pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &response, _("Password: "));
|
||||
|
||||
// Is response null?
|
||||
if(!response)
|
||||
|
@ -10,7 +10,6 @@ LICENSE : GNU-GPLv3
|
||||
#ifndef PPASSFILE
|
||||
#error PPASSFILE must be declared!
|
||||
#endif
|
||||
#define PWPROMPT "Password::"
|
||||
|
||||
int authPassword(pam_handle_t *pamh, char *serious_dev, int8_t bSerious, int8_t bReboot, int8_t bPoweroff);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user