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 ""
"Project-Id-Version: pam_panic 0.2.0\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"
"Last-Translator: <bandie@chaospott.de>\n"
"Language-Team: German\n"
@ -58,40 +58,40 @@ msgstr "CRITICAL: Passwort-Datei ist beschädigt!"
msgid "Password: "
msgstr "Passwort: "
#: src/pam_panic_pw/pam_panic_pw.c:28
#: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format
msgid "ERROR opening file!\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: "
msgstr "Schlüsselpasswort: "
#: src/pam_panic_pw/pam_panic_pw.c:66
#: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: "
msgstr "Panikpasswort: "
#: src/pam_panic_pw/pam_panic_pw.c:67
#: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: "
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: "
msgstr "Panikpasswort bestätigen: "
#: src/pam_panic_pw/pam_panic_pw.c:74
#: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr ""
"Dieses Programm muss als root ausgeführt werden. Schreibrechte auf %s sind "
"dabei notwendig.\n"
#: src/pam_panic_pw/pam_panic_pw.c:97
#: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format
msgid "Didn't work. Bye.\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
msgid "Password didn't match. Try again.\n"
msgstr "Passwort stimmt nicht überein. Bitte noch einmal versuchen.\n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pam_panic 0.2.0\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"
"Last-Translator: Dangered wolf <d@ngeredwolf.me>\n"
"Language-Team: Spanish\n"
@ -61,40 +61,40 @@ msgstr "CRITICAL: Archivo de contraseña está dañado!"
msgid "Password: "
msgstr "Contraseña: "
#: src/pam_panic_pw/pam_panic_pw.c:28
#: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format
msgid "ERROR opening file!\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: "
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: "
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: "
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: "
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
msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr ""
"Ejecute este programa con acceso root. El acceso de escritura a %s es "
"obligatorio.\n"
#: src/pam_panic_pw/pam_panic_pw.c:97
#: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format
msgid "Didn't work. Bye.\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
msgid "Password didn't match. Try again.\n"
msgstr "La contraseña no coincide. Inténtalo de nuevo.\n"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pam_panic 0.2.0\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"
"Last-Translator: Dashie <dashie@otter.sh>\n"
"Language-Team: French\n"
@ -59,40 +59,40 @@ msgstr "CRITICAL: Le fichier de mot de passe est corrompu!"
msgid "Password: "
msgstr "Mot de passe : "
#: src/pam_panic_pw/pam_panic_pw.c:28
#: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format
msgid "ERROR opening file!\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: "
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: "
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: "
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: "
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
msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr ""
"Veuillez exécuter ce programme avec les privilèges root. L'accès en écriture "
"à %s est obligatoire.\n"
#: src/pam_panic_pw/pam_panic_pw.c:97
#: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format
msgid "Didn't work. Bye.\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
msgid "Password didn't match. Try again.\n"
msgstr "Le mot de passe ne correspond pas. Réessayer.\n"

View File

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

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pam_panic 0.2.0\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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -55,38 +55,38 @@ msgstr ""
msgid "Password: "
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:28
#: src/pam_panic_pw/pam_panic_pw.c:43
#, c-format
msgid "ERROR opening file!\n"
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:65
#: src/pam_panic_pw/pam_panic_pw.c:80
msgid "Key password: "
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:66
#: src/pam_panic_pw/pam_panic_pw.c:81
msgid "Panic password: "
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:67
#: src/pam_panic_pw/pam_panic_pw.c:82
msgid "Confirm key password: "
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:68
#: src/pam_panic_pw/pam_panic_pw.c:83
msgid "Confirm panic password: "
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:74
#: src/pam_panic_pw/pam_panic_pw.c:89
#, c-format
msgid "Please run this program under root. Write access to %s is mandatory.\n"
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:97
#: src/pam_panic_pw/pam_panic_pw.c:112
#, c-format
msgid "Didn't work. Bye.\n"
msgstr ""
#: src/pam_panic_pw/pam_panic_pw.c:100
#: src/pam_panic_pw/pam_panic_pw.c:115
#, c-format
msgid "Password didn't match. Try again.\n"
msgstr ""

View File

@ -12,6 +12,7 @@ LICENSE : GNU-GPLv3
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
@ -20,9 +21,23 @@ LICENSE : GNU-GPLv3
#include "../../lib/gettext.h"
#define _(String) gettext(String)
#define FMODE 0644
#define DMODE 0755
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");
if(f == NULL){
fprintf(stderr, _("ERROR opening file!\n"));
@ -33,7 +48,7 @@ int writePasswords(char pw[][256], char* pwfile){
fclose(f);
chmod(pwfile, 0644);
chmod(pwfile, FMODE);
return 0;
}