gettext: pam_panic_password

This commit is contained in:
Bandie 2018-09-21 22:49:07 +02:00
parent 54ffdc16f1
commit 8ad9fad8e6
Signed by: Bandie
GPG Key ID: C1E133BC65A822DD
2 changed files with 14 additions and 9 deletions

View File

@ -11,6 +11,10 @@ LICENSE : GNU-GPLv3
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "../config.h"
#include "../../lib/gettext.h"
#include <security/pam_modules.h> #include <security/pam_modules.h>
#include <security/pam_ext.h> #include <security/pam_ext.h>
#include <syslog.h> #include <syslog.h>
@ -18,21 +22,18 @@ LICENSE : GNU-GPLv3
#include "pam_panic_password.h" #include "pam_panic_password.h"
#include "pam_panic_reject.h" #include "pam_panic_reject.h"
#define MSG_NOFILE "ALERT for password option: No password file detected." #define _(String) gettext(String)
#define MSG_ERROPEN "ERROR: Couldn't open password file."
#define MSG_CORRUPT "CRITICAL: Password file is corrupt!"
int readPassword(pam_handle_t *pamh, char pw[2][99]){ int readPassword(pam_handle_t *pamh, char pw[2][99]){
// Open file // Open file
if(access(PPASSFILE, F_OK) == -1){ 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; return 2;
} }
FILE *f = fopen(PPASSFILE, "r"); FILE *f = fopen(PPASSFILE, "r");
if(f == NULL){ if(f == NULL){
pam_syslog(pamh, LOG_ALERT, MSG_ERROPEN); pam_syslog(pamh, LOG_ALERT, _("ERROR: Couldn't open password file."));
return 1; return 1;
} }
@ -44,7 +45,7 @@ int readPassword(pam_handle_t *pamh, char pw[2][99]){
fclose(f); fclose(f);
if(nread != 198){ if(nread != 198){
pam_syslog(pamh, LOG_CRIT, MSG_CORRUPT); pam_syslog(pamh, LOG_CRIT, _("CRITICAL: Password file is corrupt!"));
return 3; 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){ 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 // PAM password response
char resp[256]; char resp[256];
char *response = NULL; 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? // Is response null?
if(!response) if(!response)

View File

@ -10,7 +10,6 @@ LICENSE : GNU-GPLv3
#ifndef PPASSFILE #ifndef PPASSFILE
#error PPASSFILE must be declared! #error PPASSFILE must be declared!
#endif #endif
#define PWPROMPT "Password::"
int authPassword(pam_handle_t *pamh, char *serious_dev, int8_t bSerious, int8_t bReboot, int8_t bPoweroff); int authPassword(pam_handle_t *pamh, char *serious_dev, int8_t bSerious, int8_t bReboot, int8_t bPoweroff);