Merge pull request #69 from Bandie/master

pam_panic_pw creates dir if it doesn't exist
This commit is contained in:
Bandie 2018-10-03 21:03:49 +02:00 committed by GitHub
commit e79226683d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 46 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: pam_panic 0.2.0\n" "Project-Id-Version: pam_panic 0.2.0\n"
"Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n" "Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n"
"POT-Creation-Date: 2018-09-30 13:04+0200\n" "POT-Creation-Date: 2018-10-03 20:26+0200\n"
"PO-Revision-Date: 2018-09-20 21:03+0200\n" "PO-Revision-Date: 2018-09-20 21:03+0200\n"
"Last-Translator: <bandie@chaospott.de>\n" "Last-Translator: <bandie@chaospott.de>\n"
"Language-Team: German\n" "Language-Team: German\n"
@ -58,40 +58,40 @@ msgstr "CRITICAL: Passwort-Datei ist beschädigt!"
msgid "Password: " msgid "Password: "
msgstr "Passwort: " msgstr "Passwort: "
#: src/pam_panic_pw/pam_panic_pw.c:28 #: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format #, c-format
msgid "ERROR opening file!\n" msgid "ERROR opening file!\n"
msgstr "ERROR: Datei konnte nicht geöffnet werden!\n" msgstr "ERROR: Datei konnte nicht geöffnet werden!\n"
#: src/pam_panic_pw/pam_panic_pw.c:65 #: src/pam_panic_pw/pam_panic_pw.c:80
msgid "Key password: " msgid "Key password: "
msgstr "Schlüsselpasswort: " msgstr "Schlüsselpasswort: "
#: src/pam_panic_pw/pam_panic_pw.c:66 #: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: " msgid "Panic password: "
msgstr "Panikpasswort: " msgstr "Panikpasswort: "
#: src/pam_panic_pw/pam_panic_pw.c:67 #: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: " msgid "Confirm key password: "
msgstr "Schlüsselpasswort bestätigen: " msgstr "Schlüsselpasswort bestätigen: "
#: src/pam_panic_pw/pam_panic_pw.c:68 #: src/pam_panic_pw/pam_panic_pw.c:83
msgid "Confirm panic password: " msgid "Confirm panic password: "
msgstr "Panikpasswort bestätigen: " msgstr "Panikpasswort bestätigen: "
#: src/pam_panic_pw/pam_panic_pw.c:74 #: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format #, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n" msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr "" msgstr ""
"Dieses Programm muss als root ausgeführt werden. Schreibrechte auf %s sind " "Dieses Programm muss als root ausgeführt werden. Schreibrechte auf %s sind "
"dabei notwendig.\n" "dabei notwendig.\n"
#: src/pam_panic_pw/pam_panic_pw.c:97 #: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format #, c-format
msgid "Didn't work. Bye.\n" msgid "Didn't work. Bye.\n"
msgstr "Hat nicht funktioniert. Tschüss.\n" msgstr "Hat nicht funktioniert. Tschüss.\n"
#: src/pam_panic_pw/pam_panic_pw.c:100 #: src/pam_panic_pw/pam_panic_pw.c:115
#, c-format #, c-format
msgid "Password didn't match. Try again.\n" msgid "Password didn't match. Try again.\n"
msgstr "Passwort stimmt nicht überein. Bitte noch einmal versuchen.\n" msgstr "Passwort stimmt nicht überein. Bitte noch einmal versuchen.\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: pam_panic 0.2.0\n" "Project-Id-Version: pam_panic 0.2.0\n"
"Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n" "Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n"
"POT-Creation-Date: 2018-09-30 13:04+0200\n" "POT-Creation-Date: 2018-10-03 20:26+0200\n"
"PO-Revision-Date: 2018-09-29 18:19+0200\n" "PO-Revision-Date: 2018-09-29 18:19+0200\n"
"Last-Translator: Dangered wolf <d@ngeredwolf.me>\n" "Last-Translator: Dangered wolf <d@ngeredwolf.me>\n"
"Language-Team: Spanish\n" "Language-Team: Spanish\n"
@ -61,40 +61,40 @@ msgstr "CRITICAL: Archivo de contraseña está dañado!"
msgid "Password: " msgid "Password: "
msgstr "Contraseña: " msgstr "Contraseña: "
#: src/pam_panic_pw/pam_panic_pw.c:28 #: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format #, c-format
msgid "ERROR opening file!\n" msgid "ERROR opening file!\n"
msgstr "ERROR al abrir el archivo!\n" msgstr "ERROR al abrir el archivo!\n"
#: src/pam_panic_pw/pam_panic_pw.c:65 #: src/pam_panic_pw/pam_panic_pw.c:80
msgid "Key password: " msgid "Key password: "
msgstr "Contraseña clave: " msgstr "Contraseña clave: "
#: src/pam_panic_pw/pam_panic_pw.c:66 #: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: " msgid "Panic password: "
msgstr "Contraseña de pánico: " msgstr "Contraseña de pánico: "
#: src/pam_panic_pw/pam_panic_pw.c:67 #: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: " msgid "Confirm key password: "
msgstr "Confirmar contraseña clave: " msgstr "Confirmar contraseña clave: "
#: src/pam_panic_pw/pam_panic_pw.c:68 #: src/pam_panic_pw/pam_panic_pw.c:83
msgid "Confirm panic password: " msgid "Confirm panic password: "
msgstr "Confirmar contraseña de pánico: " msgstr "Confirmar contraseña de pánico: "
#: src/pam_panic_pw/pam_panic_pw.c:74 #: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format #, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n" msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr "" msgstr ""
"Ejecute este programa con acceso root. El acceso de escritura a %s es " "Ejecute este programa con acceso root. El acceso de escritura a %s es "
"obligatorio.\n" "obligatorio.\n"
#: src/pam_panic_pw/pam_panic_pw.c:97 #: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format #, c-format
msgid "Didn't work. Bye.\n" msgid "Didn't work. Bye.\n"
msgstr "No funcionó. Adiós.\n" msgstr "No funcionó. Adiós.\n"
#: src/pam_panic_pw/pam_panic_pw.c:100 #: src/pam_panic_pw/pam_panic_pw.c:115
#, c-format #, c-format
msgid "Password didn't match. Try again.\n" msgid "Password didn't match. Try again.\n"
msgstr "La contraseña no coincide. Inténtalo de nuevo.\n" msgstr "La contraseña no coincide. Inténtalo de nuevo.\n"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: pam_panic 0.2.0\n" "Project-Id-Version: pam_panic 0.2.0\n"
"Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n" "Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n"
"POT-Creation-Date: 2018-09-30 13:04+0200\n" "POT-Creation-Date: 2018-10-03 20:26+0200\n"
"PO-Revision-Date: 2018-09-29 18:33+0200\n" "PO-Revision-Date: 2018-09-29 18:33+0200\n"
"Last-Translator: Dashie <dashie@otter.sh>\n" "Last-Translator: Dashie <dashie@otter.sh>\n"
"Language-Team: French\n" "Language-Team: French\n"
@ -59,40 +59,40 @@ msgstr "CRITICAL: Le fichier de mot de passe est corrompu!"
msgid "Password: " msgid "Password: "
msgstr "Mot de passe : " msgstr "Mot de passe : "
#: src/pam_panic_pw/pam_panic_pw.c:28 #: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format #, c-format
msgid "ERROR opening file!\n" msgid "ERROR opening file!\n"
msgstr "ERROR en ouvrant le fichier.\n" msgstr "ERROR en ouvrant le fichier.\n"
#: src/pam_panic_pw/pam_panic_pw.c:65 #: src/pam_panic_pw/pam_panic_pw.c:80
msgid "Key password: " msgid "Key password: "
msgstr "Mot de passe clé : " msgstr "Mot de passe clé : "
#: src/pam_panic_pw/pam_panic_pw.c:66 #: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: " msgid "Panic password: "
msgstr "Mot de passe panique : " msgstr "Mot de passe panique : "
#: src/pam_panic_pw/pam_panic_pw.c:67 #: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: " msgid "Confirm key password: "
msgstr "Confirmer le mot de passe de clé :" msgstr "Confirmer le mot de passe de clé :"
#: src/pam_panic_pw/pam_panic_pw.c:68 #: src/pam_panic_pw/pam_panic_pw.c:83
msgid "Confirm panic password: " msgid "Confirm panic password: "
msgstr "Confirmer le mot de passe de panique : " msgstr "Confirmer le mot de passe de panique : "
#: src/pam_panic_pw/pam_panic_pw.c:74 #: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format #, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n" msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr "" msgstr ""
"Veuillez exécuter ce programme avec les privilèges root. L'accès en écriture " "Veuillez exécuter ce programme avec les privilèges root. L'accès en écriture "
"à %s est obligatoire.\n" "à %s est obligatoire.\n"
#: src/pam_panic_pw/pam_panic_pw.c:97 #: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format #, c-format
msgid "Didn't work. Bye.\n" msgid "Didn't work. Bye.\n"
msgstr "N'a pas fonctionné. Au revoir.\n" msgstr "N'a pas fonctionné. Au revoir.\n"
#: src/pam_panic_pw/pam_panic_pw.c:100 #: src/pam_panic_pw/pam_panic_pw.c:115
#, c-format #, c-format
msgid "Password didn't match. Try again.\n" msgid "Password didn't match. Try again.\n"
msgstr "Le mot de passe ne correspond pas. Réessayer.\n" msgstr "Le mot de passe ne correspond pas. Réessayer.\n"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: pam_panic 0.2.0\n" "Project-Id-Version: pam_panic 0.2.0\n"
"Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n" "Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n"
"POT-Creation-Date: 2018-09-30 13:04+0200\n" "POT-Creation-Date: 2018-10-03 20:26+0200\n"
"PO-Revision-Date: 2018-09-29 18:51+0200\n" "PO-Revision-Date: 2018-09-29 18:51+0200\n"
"Last-Translator: Chromium Neptune <chromium@neplanet.com>\n" "Last-Translator: Chromium Neptune <chromium@neplanet.com>\n"
"Language-Team: Japanese\n" "Language-Team: Japanese\n"
@ -58,40 +58,40 @@ msgstr "危険:パスワードファイルが壊れています!"
msgid "Password: " msgid "Password: "
msgstr "パスフレーズ: " msgstr "パスフレーズ: "
#: src/pam_panic_pw/pam_panic_pw.c:28 #: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format #, c-format
msgid "ERROR opening file!\n" msgid "ERROR opening file!\n"
msgstr "ファイルを開く際にエラーが発生\n" msgstr "ファイルを開く際にエラーが発生\n"
#: src/pam_panic_pw/pam_panic_pw.c:65 #: src/pam_panic_pw/pam_panic_pw.c:80
msgid "Key password: " msgid "Key password: "
msgstr "キーのパスワード: " msgstr "キーのパスワード: "
#: src/pam_panic_pw/pam_panic_pw.c:66 #: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: " msgid "Panic password: "
msgstr "パニックパスワード: " msgstr "パニックパスワード: "
#: src/pam_panic_pw/pam_panic_pw.c:67 #: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: " msgid "Confirm key password: "
msgstr "キーのパスワードを確認: " msgstr "キーのパスワードを確認: "
#: src/pam_panic_pw/pam_panic_pw.c:68 #: src/pam_panic_pw/pam_panic_pw.c:83
msgid "Confirm panic password: " msgid "Confirm panic password: "
msgstr "パニックパスワードを確認する: " msgstr "パニックパスワードを確認する: "
#: src/pam_panic_pw/pam_panic_pw.c:74 #: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format #, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n" msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr "" msgstr ""
"root権限でこのプログラムを実行してください。 %sへの書き込みアクセスは必須で" "root権限でこのプログラムを実行してください。 %sへの書き込みアクセスは必須で"
"す。\n" "す。\n"
#: src/pam_panic_pw/pam_panic_pw.c:97 #: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format #, c-format
msgid "Didn't work. Bye.\n" msgid "Didn't work. Bye.\n"
msgstr "うまくいきませんでした。 さようなら。\n" msgstr "うまくいきませんでした。 さようなら。\n"
#: src/pam_panic_pw/pam_panic_pw.c:100 #: src/pam_panic_pw/pam_panic_pw.c:115
#, c-format #, c-format
msgid "Password didn't match. Try again.\n" msgid "Password didn't match. Try again.\n"
msgstr "パスワードが一致しませんでした。 再試行する。\n" msgstr "パスワードが一致しませんでした。 再試行する。\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: pam_panic 0.2.0\n" "Project-Id-Version: pam_panic 0.2.0\n"
"Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n" "Report-Msgid-Bugs-To: https://github.com/pampanic/pam_panic\n"
"POT-Creation-Date: 2018-09-30 13:04+0200\n" "POT-Creation-Date: 2018-10-03 20:26+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -55,38 +55,38 @@ msgstr ""
msgid "Password: " msgid "Password: "
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:28 #: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format #, c-format
msgid "ERROR opening file!\n" msgid "ERROR opening file!\n"
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:65 #: src/pam_panic_pw/pam_panic_pw.c:80
msgid "Key password: " msgid "Key password: "
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:66 #: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: " msgid "Panic password: "
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:67 #: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: " msgid "Confirm key password: "
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:68 #: src/pam_panic_pw/pam_panic_pw.c:83
msgid "Confirm panic password: " msgid "Confirm panic password: "
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:74 #: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format #, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n" msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:97 #: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format #, c-format
msgid "Didn't work. Bye.\n" msgid "Didn't work. Bye.\n"
msgstr "" msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:100 #: src/pam_panic_pw/pam_panic_pw.c:115
#, c-format #, c-format
msgid "Password didn't match. Try again.\n" msgid "Password didn't match. Try again.\n"
msgstr "" msgstr ""

View File

@ -12,6 +12,7 @@ LICENSE : GNU-GPLv3
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <libgen.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -20,9 +21,23 @@ LICENSE : GNU-GPLv3
#include "../../lib/gettext.h" #include "../../lib/gettext.h"
#define _(String) gettext(String) #define _(String) gettext(String)
#define FMODE 0644
#define DMODE 0755
int writePasswords(char pw[][256], char* pwfile){ int writePasswords(char pw[][256], char* pwfile){
// Check, if path of pwfile exist
// Get parent dir of pwfile
char* parentdir;
parentdir = strdup(pwfile);
dirname(parentdir);
// Get POSIX info about the parent dir and create dir, if it does not exist
struct stat pd;
if(stat(parentdir, &pd) != 0 && !(S_ISDIR(pd.st_mode))){
mkdir(parentdir, DMODE);
}
FILE *f = fopen(pwfile, "w"); FILE *f = fopen(pwfile, "w");
if(f == NULL){ if(f == NULL){
fprintf(stderr, _("ERROR opening file!\n")); fprintf(stderr, _("ERROR opening file!\n"));
@ -33,7 +48,7 @@ int writePasswords(char pw[][256], char* pwfile){
fclose(f); fclose(f);
chmod(pwfile, 0644); chmod(pwfile, FMODE);
return 0; return 0;
} }