gettext: pam_panic_pw

This commit is contained in:
Bandie 2018-09-21 22:50:38 +02:00
parent 8ad9fad8e6
commit b7e89ce653
Signed by: Bandie
GPG Key ID: C1E133BC65A822DD
1 changed files with 19 additions and 5 deletions

View File

@ -17,13 +17,15 @@ LICENSE : GNU-GPLv3
#include <sys/stat.h>
#include <crypt.h>
#include "config.h"
#include "../../lib/gettext.h"
#define _(String) gettext(String)
int writePasswords(char pw[][99]){
FILE *f = fopen(PPASSFILE, "w");
if(f == NULL){
fprintf(stderr, "ERROR opening file!\n");
fprintf(stderr, _("ERROR opening file!\n"));
return 2;
}
@ -39,6 +41,12 @@ int writePasswords(char pw[][99]){
int main(void){
// gettext
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
// init
time_t t;
srand((unsigned) time(&t));
unsigned long seed[2];
@ -52,12 +60,17 @@ int main(void){
char pw[2][99];
char pwv[2][99];
char *prompt[4] = {"Key password: ", "Panic password: ", "Retype key password: ","Retype panic password: "};
char *prompt[4] = {
_("Key password: "),
_("Panic password: "),
_("Retype key password: "),
_("Retype panic password: ")
};
int i;
if(getuid() != 0){
printf("Please run this program under root. Write access to %s is mandatory.\n", PPASSFILE); return 1;
printf(_("Please run this program under root. Write access to %s is mandatory.\n"), PPASSFILE); return 1;
}
for(int j=0; j<2; j++){
@ -80,10 +93,10 @@ int main(void){
int ok = strcmp(pw[j], pwv[j]) == 0;
if(!ok){
if(k==2){
printf("Didn't work. Bye.\n");
printf(_("Didn't work. Bye.\n"));
return 1;
}else
printf("Password didn't match. Try again.\n");
printf(_("Password didn't match. Try again.\n"));
}else
break;
}
@ -94,3 +107,4 @@ int main(void){
return writePasswords(pw);
}