最新ルールに従い
このコミットが含まれているのは:
コミット
a5c6e3fe54
|
@ -1,5 +1,6 @@
|
|||
sp
|
||||
sp-*
|
||||
dist
|
||||
release
|
||||
.ccls-cache
|
||||
*.o
|
||||
*.tar.gz
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* OpenBSD向けのリリースコマンドの追加
|
||||
* FreeBSD向けのリリースコマンドの追加
|
||||
* Linux向けのリリースコマンドの追加
|
||||
* 最新ルールに従い
|
||||
|
||||
# 1.2.0
|
||||
* やっとTOTP機能性を修正した
|
||||
|
|
33
Makefile
33
Makefile
|
@ -1,7 +1,9 @@
|
|||
UNAME_S!=uname -s
|
||||
|
||||
NAME!=cat main.c | grep "const char\* sofname" | awk '{print $$5}' | sed "s/\"//g" | sed "s/;//"
|
||||
VERSION!=cat main.c | grep "const char\* version" | awk '{print $$5}' | sed "s/\"//g" | sed "s/;//"
|
||||
NAME!=cat main.c | grep "const char\* sofname" | awk '{print $$5}' | \
|
||||
sed "s/\"//g" | sed "s/;//"
|
||||
VERSION!=cat main.c | grep "const char\* version" | awk '{print $$5}' | \
|
||||
sed "s/\"//g" | sed "s/;//"
|
||||
PREFIX=/usr/local
|
||||
|
||||
.if ${UNAME_S} == "FreeBSD"
|
||||
|
@ -15,8 +17,12 @@ MANPREFIX=${PREFIX}/share/man
|
|||
.endif
|
||||
|
||||
CC=cc
|
||||
FILES=main.c showpass.c yankpass.c addpass.c delpass.c listpass.c genpass.c initpass.c otppass.c base32.c
|
||||
FILES=main.c src/*.c
|
||||
CFLAGS=-Wall -Wextra -O3 -I${PREFIX}/include -L${PREFIX}/lib
|
||||
.if ${UNAME_S} == "NetBSD"
|
||||
CFLAGS=-Wall -Wextra -O3 -I/usr/pkg/include -L/usr/pkg/lib \
|
||||
-I/usr/local/include -L/usr/local/include
|
||||
.endif
|
||||
LDFLAGS=-lgpgme -lcrypto
|
||||
|
||||
all:
|
||||
|
@ -28,22 +34,25 @@ clean:
|
|||
|
||||
dist: clean
|
||||
mkdir -p ${NAME}-${VERSION}
|
||||
cp -R LICENSE.txt Makefile README.md CHANGELOG.md\
|
||||
${NAME}-completion.zsh ${NAME}.1\ *.c *.h ${NAME}-${VERSION}
|
||||
tar zcfv ${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
|
||||
cp -R LICENSE.txt Makefile README.md CHANGELOG.md \
|
||||
${NAME}-completion.zsh ${NAME}.1 main.c src ${NAME}-${VERSION}
|
||||
tar zcfv dist/${NAME}-${VERSION}.tar.gz ${NAME}-${VERSION}
|
||||
rm -rf ${NAME}-${VERSION}
|
||||
|
||||
release-openbsd:
|
||||
${CC} ${CFLAGS} -o ${NAME}-${VERSION}-openbsd-amd64 ${FILES} -static -lgpgme -lcrypto -lc -lassuan -lgpg-error -lintl -liconv
|
||||
strip ${NAME}
|
||||
${CC} ${CFLAGS} -o release/${NAME}-${VERSION}-openbsd-amd64 ${FILES} \
|
||||
-static -lgpgme -lcrypto -lc -lassuan -lgpg-error -lintl -liconv
|
||||
strip release/${NAME}-${VERSION}-openbsd-amd64
|
||||
|
||||
release-freebsd:
|
||||
${CC} ${CFLAGS} -o ${NAME}-${VERSION}-freebsd-amd64 ${FILES} -static -lgpgme -lcrypto -lc -lassuan -lgpg-error -lthr -lintl
|
||||
strip ${NAME}
|
||||
${CC} ${CFLAGS} -o release/${NAME}-${version}-freebsd-amd64 ${FILES} \
|
||||
-static -lgpgme -lcrypto -lc -lassuan -lgpg-error -lthr -lintl
|
||||
strip release/${NAME}-${VERSION}-linux-amd64
|
||||
|
||||
release-linux:
|
||||
${CC} ${CFLAGS} -o ${NAME}-${VERSION}-linux-amd64 ${FILES} -static -lgpgme -lcrypto -lc -lassuan -lgpg-error
|
||||
strip ${NAME}
|
||||
${CC} ${CFLAGS} -o release/${NAME}-${VERSION}-linux-amd64 ${FILES} \
|
||||
-static -lgpgme -lcrypto -lc -lassuan -lgpg-error
|
||||
strip release/${NAME}-${VERSION}-linux-amd64
|
||||
|
||||
install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
|
|
|
@ -89,8 +89,10 @@ $ sp -d 076.moe/suwako
|
|||
|
||||
## TOTP(ワンタイムパスワード)
|
||||
### QRコードから
|
||||
QRコードをダウンロードし、zbarimgを使用して「QR-Code:」以降の部分をコピーし、spに追加して下さい。\
|
||||
`sp -a`を実行すると、「パスワード」を聞かれますが、TOTPの場合は「otpauth://」から始まる文字列をコピペして下さい。
|
||||
QRコードをダウンロードし、zbarimgを使用して「QR-Code:」以降の部分をコピーし、
|
||||
spに追加して下さい。\
|
||||
`sp -a`を実行すると、「パスワード」を聞かれますが、
|
||||
TOTPの場合は「otpauth://」から始まる文字列をコピペして下さい。
|
||||
```sh
|
||||
$ zbarimg -q gitler.png
|
||||
QR-Code:otpauth://totp/Gitler%20%28gitler.moe%29:suwako?algorithm=SHA1&digits=6&issuer=Gitler%20%28gitler.moe%29&period=30&secret=〇〇
|
||||
|
|
97
main.c
97
main.c
|
@ -5,14 +5,14 @@
|
|||
|
||||
#include <gpgme.h>
|
||||
|
||||
#include "initpass.h"
|
||||
#include "showpass.h"
|
||||
#include "yankpass.h"
|
||||
#include "listpass.h"
|
||||
#include "addpass.h"
|
||||
#include "delpass.h"
|
||||
#include "genpass.h"
|
||||
#include "otppass.h"
|
||||
#include "src/initpass.h"
|
||||
#include "src/showpass.h"
|
||||
#include "src/yankpass.h"
|
||||
#include "src/listpass.h"
|
||||
#include "src/addpass.h"
|
||||
#include "src/delpass.h"
|
||||
#include "src/genpass.h"
|
||||
#include "src/otppass.h"
|
||||
|
||||
const char* sofname = "sp";
|
||||
const char* version = "1.3.0";
|
||||
|
@ -21,15 +21,34 @@ void helpme() {
|
|||
printf("076 %s %s - シンプルなパスワードマネージャー\n", sofname, version);
|
||||
printf("https://076.moe/ | https://gitler.moe/suwako/%s\n\n", sofname);
|
||||
puts ("使い方:");
|
||||
printf("%s -i <gpg-id> :GPGと使ってパスワードストレージを初期設定\n", sofname);
|
||||
printf(
|
||||
"%s -i <gpg-id> :GPGと使ってパスワードストレージを初期設定\n",
|
||||
sofname
|
||||
);
|
||||
printf("%s -s <パスワード名> :パスワードを表示\n", sofname);
|
||||
printf("%s -y <パスワード名> :パスワードを表示せずクリップボードにコピーする\n", sofname);
|
||||
printf(
|
||||
"%s %s%s\n",
|
||||
sofname,
|
||||
"-y <パスワード名> :",
|
||||
"パスワードを表示せずクリップボードにコピーする"
|
||||
);
|
||||
printf("%s -l :パスワード一覧を表示\n", sofname);
|
||||
printf("%s -a <パスワード名> :パスワードを追加\n", sofname);
|
||||
printf("%s -d <パスワード名> :パスワードを削除\n", sofname);
|
||||
printf("%s -e <パスワード名> :パスワードを変更\n", sofname);
|
||||
printf("%s -g <文字数> [risk|secure] :希望文字数でパスワードをランダムに作成する。risk=英数字のみ(不安)、secure=英数字+特別文字(デフォルト)を使用\n", sofname);
|
||||
printf("%s -o <パスワード名> :ワンタイムパスワード(TOTP)を表示。存在しなければ、創作する\n", sofname);
|
||||
printf(
|
||||
"%s %s%s%s\n",
|
||||
sofname,
|
||||
"-g <文字数> [risk|secure] :",
|
||||
"希望文字数でパスワードをランダムに作成する。",
|
||||
"risk=英数字のみ(不安)、secure=英数字+特別文字(デフォルト)を使用"
|
||||
);
|
||||
printf(
|
||||
"%s %s%s\n",
|
||||
sofname,
|
||||
"-o <パスワード名> :",
|
||||
"ワンタイムパスワード(TOTP)を表示。存在しなければ、創作する"
|
||||
);
|
||||
printf("%s -h :ヘルプを表示\n", sofname);
|
||||
printf("%s -v :バージョンを表示\n", sofname);
|
||||
}
|
||||
|
@ -39,15 +58,42 @@ void helpme_en() {
|
|||
printf("https://076.moe/ | https://gitler.moe/suwako/%s\n", sofname);
|
||||
puts ("When reporting issues, please report in Japanese.\n");
|
||||
puts ("Usage:");
|
||||
printf("%s -i <gpg-id> : First setting for using GPG and password storage\n", sofname);
|
||||
printf("%s -s <Password name> : Show password\n", sofname);
|
||||
printf("%s -y <Password name> : Copy password to clipboard without show\n", sofname);
|
||||
printf("%s -l : Show me list of password\n", sofname);
|
||||
printf(
|
||||
"%s %s%s\n",
|
||||
sofname,
|
||||
"-i <gpg-id> : ",
|
||||
"First setting for using GPG and password storage"
|
||||
);
|
||||
printf(
|
||||
"%s -s <Password name> : Show password\n", sofname
|
||||
);
|
||||
printf(
|
||||
"%s %s%s\n",
|
||||
sofname,
|
||||
"-y <Password name> : ",
|
||||
"Copy password to clipboard without show"
|
||||
);
|
||||
printf(
|
||||
"%s %s\n",
|
||||
sofname,
|
||||
"-l : Show me list of password"
|
||||
);
|
||||
printf("%s -a <Password name> : Add password\n", sofname);
|
||||
printf("%s -d <Password name> : Delete password\n", sofname);
|
||||
printf("%s -e <Password name> : Edit password\n", sofname);
|
||||
printf("%s -g <Characters amount> [risk|secure] : Randomly make password with hoped amount. Using risk = only english letter and number (abnoxious), secure = english letter and digit + special character (default)\n", sofname);
|
||||
printf("%s -o <Password name> : Show one time password. If not exist, construct\n", sofname);
|
||||
printf("%s %s%s%s%s\n",
|
||||
sofname,
|
||||
"-g <Characters amount> [risk|secure] : ",
|
||||
"Randomly make password with hoped amount.",
|
||||
"Using risk = only english letter and number (abnoxious),",
|
||||
"secure = english letter and digit + special character (default)"
|
||||
);
|
||||
printf(
|
||||
"%s %s%s\n",
|
||||
sofname,
|
||||
"-o <Password name> : ",
|
||||
"Show one time password. If not exist, construct"
|
||||
);
|
||||
printf("%s -h : Show help\n", sofname);
|
||||
printf("%s -v : Show version\n", sofname);
|
||||
}
|
||||
|
@ -68,7 +114,8 @@ int main (int argc, char* argv[]) {
|
|||
char basePath[512];
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting home directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting home directory");
|
||||
else perror("ホームディレクトリを受取に失敗");
|
||||
return -1;
|
||||
}
|
||||
|
@ -86,8 +133,10 @@ int main (int argc, char* argv[]) {
|
|||
}
|
||||
else if (strcmp(argv[1], "-g") == 0) {
|
||||
if (argc == 3) genpass(atoi(argv[2]), true);
|
||||
else if (argc == 4 && strcmp(argv[3], "risk") == 0) genpass(atoi(argv[2]), false);
|
||||
else if (argc == 4 && strcmp(argv[3], "secure") == 0) genpass(atoi(argv[2]), true);
|
||||
else if (argc == 4 && strcmp(argv[3], "risk") == 0)
|
||||
genpass(atoi(argv[2]), false);
|
||||
else if (argc == 4 && strcmp(argv[3], "secure") == 0)
|
||||
genpass(atoi(argv[2]), true);
|
||||
else {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) helpme_en();
|
||||
else helpme();
|
||||
|
@ -97,7 +146,8 @@ int main (int argc, char* argv[]) {
|
|||
char fullPath[512];
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting home directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting home directory");
|
||||
else perror("ホームディレクトリを受取に失敗");
|
||||
return -1;
|
||||
}
|
||||
|
@ -107,7 +157,8 @@ int main (int argc, char* argv[]) {
|
|||
|
||||
otppass(fullPath);
|
||||
}
|
||||
else if (argc == 2 && strcmp(argv[1], "-v") == 0) printf("%s-%s\n", sofname, version);
|
||||
else if (argc == 2 && strcmp(argv[1], "-v") == 0)
|
||||
printf("%s-%s\n", sofname, version);
|
||||
else {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) helpme_en();
|
||||
else helpme();
|
||||
|
|
|
@ -31,9 +31,11 @@ int mkdir_r(const char *path, mode_t mode) {
|
|||
|
||||
for (p = tmp + 1; *p; p++) {
|
||||
if (*p == '/') {
|
||||
*p = 0; // 最後の「/」文字を取り消す
|
||||
// 最後の「/」文字を取り消す
|
||||
*p = 0;
|
||||
if (mkdir(tmp, mode) != 0 && errno != EEXIST) return -1;
|
||||
*p = '/'; // また追加
|
||||
// また追加
|
||||
*p = '/';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +81,8 @@ void addpass(char* file) {
|
|||
// パスを準備
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to retrieving home directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to retrieving home directory");
|
||||
else perror("ホームディレクトリを受取に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -93,7 +96,8 @@ void addpass(char* file) {
|
|||
int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
|
||||
char* gpgpathchk = malloc(alllen);
|
||||
if (gpgpathchk == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to allocating memory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to allocating memory");
|
||||
else perror("メモリを割当に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -101,24 +105,38 @@ void addpass(char* file) {
|
|||
// ファイルが既に存在するかどうか確認
|
||||
snprintf(gpgpathchk, alllen, "%s%s%s%s", homedir, basedir, file, ext);
|
||||
if (access(gpgpathchk, F_OK) != -1) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Password already exist.\nFor edit, please run ' sp -e %s '.\n", file);
|
||||
else fprintf(stderr, "パスワードが既に存在しています。\n変更するには、「 sp -e %s 」を実行して下さい。\n", file);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(
|
||||
stderr,
|
||||
"Password already exist.\nFor edit, please run ' sp -e %s '.\n",
|
||||
file
|
||||
);
|
||||
else
|
||||
fprintf(
|
||||
stderr,
|
||||
"%s\n変更するには、「 sp -e %s 」を実行して下さい。\n",
|
||||
"パスワードが既に存在しています。",
|
||||
file
|
||||
);
|
||||
free(gpgpathchk);
|
||||
return;
|
||||
}
|
||||
free(gpgpathchk);
|
||||
|
||||
// パスワードを受け取る
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) getpasswd("Password: ", pass, sizeof(pass));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
getpasswd("Password: ", pass, sizeof(pass));
|
||||
else getpasswd("パスワード: ", pass, sizeof(pass));
|
||||
puts("");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) getpasswd("Password (for verification): ", knin, sizeof(knin));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
getpasswd("Password (for verification): ", knin, sizeof(knin));
|
||||
else getpasswd("パスワード(確認用): ", knin, sizeof(knin));
|
||||
puts("");
|
||||
|
||||
// パスワードが一致するかどうか確認
|
||||
if (strcmp(pass, knin) != 0) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Password does not match. Ending...");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Password does not match. Ending...");
|
||||
else perror("パスワードが一致していません。終了…");
|
||||
return;
|
||||
}
|
||||
|
@ -138,7 +156,8 @@ void addpass(char* file) {
|
|||
// GPGMEを創作
|
||||
err = gpgme_new(&ctx);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to generating GPGME: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to generating GPGME: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "GPGMEを創作に失敗:%s\n", gpgme_strerror(err));
|
||||
return;
|
||||
}
|
||||
|
@ -146,7 +165,8 @@ void addpass(char* file) {
|
|||
// GPGMEは非対話的モードに設定
|
||||
err = gpgme_set_pinentry_mode(ctx, GPGME_PINENTRY_MODE_LOOPBACK);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to setting pinentry mode: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to setting pinentry mode: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "pinentryモードを設定に失敗: %s\n", gpgme_strerror(err));
|
||||
gpgme_release(ctx);
|
||||
return;
|
||||
|
@ -155,8 +175,10 @@ void addpass(char* file) {
|
|||
// パスワードからデータオブジェクトを創作
|
||||
err = gpgme_data_new_from_mem(&in, pass, strlen(pass), 0);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to making data object: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "データオブジェクトを創作に失敗: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to making data object: %s\n", gpgme_strerror(err));
|
||||
else
|
||||
fprintf(stderr, "データオブジェクトを創作に失敗: %s\n", gpgme_strerror(err));
|
||||
gpgme_release(ctx);
|
||||
return;
|
||||
}
|
||||
|
@ -182,7 +204,8 @@ void addpass(char* file) {
|
|||
|
||||
char* keyid = malloc(256);
|
||||
if (!fgets(keyid, 256, keyfile)) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to reading key ID");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to reading key ID");
|
||||
else perror("鍵IDを読込に失敗");
|
||||
fclose(keyfile);
|
||||
free(keyid);
|
||||
|
@ -194,7 +217,8 @@ void addpass(char* file) {
|
|||
|
||||
err = gpgme_get_key(ctx, keyid, &key[0], 0);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to getting key: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to getting key: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "鍵を受取に失敗: %s\n", gpgme_strerror(err));
|
||||
free(keyid);
|
||||
return;
|
||||
|
@ -212,7 +236,8 @@ void addpass(char* file) {
|
|||
// 暗号化
|
||||
err = gpgme_op_encrypt(ctx, &key[0], GPGME_ENCRYPT_ALWAYS_TRUST, in, out);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to encrypt: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to encrypt: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "暗号化に失敗: %s\n", gpgme_strerror(err));
|
||||
cleanup(ctx, key[0], in, out);
|
||||
return;
|
||||
|
@ -222,7 +247,8 @@ void addpass(char* file) {
|
|||
char* gpgpath = malloc(alllen);
|
||||
if (gpgpath == NULL) {
|
||||
cleanup(ctx, key[0], in, out);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to allocating memory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to allocating memory");
|
||||
else perror("メモリを割当に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -238,7 +264,8 @@ void addpass(char* file) {
|
|||
if (mkdir_r(dirpath, 0755) != 0) {
|
||||
free(gpgpath);
|
||||
cleanup(ctx, key[0], in, out);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to constructing directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to constructing directory");
|
||||
else perror("ディレクトリを創作に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -249,7 +276,8 @@ void addpass(char* file) {
|
|||
if (stat(gpgpath, &statbuf) == 0) {
|
||||
free(gpgpath);
|
||||
cleanup(ctx, key[0], in, out);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Password is already exist");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Password is already exist");
|
||||
else perror("パスワードは既に存在しています");
|
||||
return;
|
||||
}
|
||||
|
@ -271,7 +299,8 @@ void addpass(char* file) {
|
|||
// データが保存したかどうか確認
|
||||
ssize_t encrypted_data_size = gpgme_data_seek(out, 0, SEEK_END);
|
||||
if (encrypted_data_size <= 0) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to saving the data");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to saving the data");
|
||||
else perror("データを保存に失敗");
|
||||
fclose(gpgfile);
|
||||
free(gpgpath);
|
||||
|
@ -287,7 +316,8 @@ void addpass(char* file) {
|
|||
|
||||
while ((read_bytes = gpgme_data_read(out, buffer, sizeof(buffer))) > 0) {
|
||||
if (fwrite(buffer, 1, (size_t)read_bytes, gpgfile) != (size_t)read_bytes) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to writing password");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to writing password");
|
||||
else perror("パスワードを書き込みに失敗");
|
||||
free(gpgpath);
|
||||
cleanup(ctx, key[0], in, out);
|
||||
|
@ -300,6 +330,7 @@ void addpass(char* file) {
|
|||
free(gpgpath);
|
||||
cleanup(ctx, key[0], in, out);
|
||||
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) puts("I could save the password");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
puts("I could save the password");
|
||||
else puts("パスワードを保存出来ました");
|
||||
}
|
|
@ -12,7 +12,8 @@ int delpass(char* file, int force) {
|
|||
char pwfile[512];
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting home directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting home directory");
|
||||
else perror("ホームディレクトリを受取に失敗");
|
||||
return -1;
|
||||
}
|
||||
|
@ -23,7 +24,8 @@ int delpass(char* file, int force) {
|
|||
int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
|
||||
char* gpgpathchk = malloc(alllen);
|
||||
if (gpgpathchk == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to allocating memory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to allocating memory");
|
||||
else perror("メモリを割当に失敗");
|
||||
return -1;
|
||||
}
|
||||
|
@ -31,23 +33,34 @@ int delpass(char* file, int force) {
|
|||
// ファイルが既に存在するかどうか確認
|
||||
snprintf(gpgpathchk, alllen, "%s%s%s%s", homedir, basedir, file, ext);
|
||||
if (access(gpgpathchk, F_OK) != 0) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Password does not exist");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Password does not exist");
|
||||
else perror("パスワードが存在しません");
|
||||
free(gpgpathchk);
|
||||
return -1;
|
||||
}
|
||||
free(gpgpathchk);
|
||||
|
||||
int needed = snprintf(pwfile, sizeof(pwfile), "%s%s%s%s", homedir, basedir, file, ext);
|
||||
int needed = snprintf(
|
||||
pwfile,
|
||||
sizeof(pwfile),
|
||||
"%s%s%s%s",
|
||||
homedir,
|
||||
basedir,
|
||||
file,
|
||||
ext
|
||||
);
|
||||
if (needed >= (int)sizeof(pwfile)) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Error: Path is too long");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Error: Path is too long");
|
||||
else perror("エラー:パスが長すぎる");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 削除を確認する
|
||||
if (force == 0) { // パスワードの変更のばあい、確認は不要
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) printf("Is it really good if I delete the password '%s'? (y/N): ", file);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
printf("Is it really good if I delete the password '%s'? (y/N): ", file);
|
||||
printf("パスワード「%s」を本当に削除する事が宜しいでしょうか? (y/N): ", file);
|
||||
int confirm = getchar();
|
||||
if (confirm != 'y' && confirm != 'Y') {
|
||||
|
@ -61,7 +74,8 @@ int delpass(char* file, int force) {
|
|||
}
|
||||
|
||||
if (unlink(pwfile) == -1) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Password cannot be delete");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Password cannot be delete");
|
||||
else perror("パスワードを削除出来ませんですた");
|
||||
return -1;
|
||||
}
|
|
@ -7,13 +7,16 @@
|
|||
void genpass(int count, bool issecure) {
|
||||
char *lang = getenv("SP_LANG");
|
||||
|
||||
const char* charset_risky = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
const char* charset_secure = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()=~-^\\|_@`[{]};:+*<>,./?";
|
||||
const char* charset_risky =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
const char* charset_secure =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()=~-^\\|_@`[{]};:+*<>,./?";
|
||||
const char* charset = issecure ? charset_secure : charset_risky;
|
||||
|
||||
FILE *fp = fopen("/dev/random", "rb");
|
||||
if (fp == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Could not opening /dev/random");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Could not opening /dev/random");
|
||||
else perror("/dev/randomを開けられませんでした");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
|
@ -12,7 +12,8 @@ void initpass(char* gpgid) {
|
|||
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting home directory.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting home directory.");
|
||||
else perror("ホームディレクトリを受取に失敗。");
|
||||
return;
|
||||
}
|
||||
|
@ -22,7 +23,8 @@ void initpass(char* gpgid) {
|
|||
snprintf(dirpath, sizeof(dirpath), "%s%s", homedir, basedir);
|
||||
|
||||
if (mkdir_r(dirpath, 0755) != 0 && errno != EEXIST) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to creating directory.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to creating directory.");
|
||||
else perror("ディレクトリを作成に失敗。");
|
||||
return;
|
||||
}
|
||||
|
@ -32,27 +34,31 @@ void initpass(char* gpgid) {
|
|||
|
||||
struct stat statbuf;
|
||||
if (stat(gpgidpath, &statbuf) == 0) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror(".gpg-id file is already exist.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror(".gpg-id file is already exist.");
|
||||
else perror(".gpg-idファイルは既に存在します。");
|
||||
return;
|
||||
}
|
||||
|
||||
FILE* gpgidfile = fopen(gpgidpath, "w");
|
||||
if (gpgidfile == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to writing .gpg-id file.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to writing .gpg-id file.");
|
||||
else perror(".gpg-idファイルを書き込めません。");
|
||||
fclose(gpgidfile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fputs(gpgid, gpgidfile) == EOF) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to writing .gpg-id file.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to writing .gpg-id file.");
|
||||
else perror(".gpg-idファイルへの書き込みに失敗しました。");
|
||||
fclose(gpgidfile);
|
||||
return;
|
||||
}
|
||||
|
||||
fclose(gpgidfile);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) puts("First time setup was complete.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
puts("First time setup was complete.");
|
||||
else puts("初期設定に完了しました。");
|
||||
}
|
|
@ -12,7 +12,8 @@ void listpass(char* basePath, int level) {
|
|||
struct dirent* entry;
|
||||
DIR* dir = opendir(basePath);
|
||||
if (!dir) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Could not opening directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Could not opening directory");
|
||||
else perror("ディレクトリを開けられません");
|
||||
return;
|
||||
}
|
||||
|
@ -25,14 +26,16 @@ void listpass(char* basePath, int level) {
|
|||
char path[1000];
|
||||
int needed = snprintf(path, sizeof(path), "%s/%s", basePath, entry->d_name);
|
||||
if (needed >= (int)sizeof(path) || needed < 0) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Error: Path is too long, or failed to getting lenth");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Error: Path is too long, or failed to getting lenth");
|
||||
else perror("エラー:パスが長すぎる、又は長さを受取に失敗");
|
||||
continue;
|
||||
}
|
||||
|
||||
struct stat statbuf;
|
||||
if (stat(path, &statbuf) == -1) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to reading file status");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to reading file status");
|
||||
else perror("ファイル状況を読込に失敗");
|
||||
continue;
|
||||
}
|
|
@ -12,7 +12,8 @@ unsigned char* extract_secret(const char* otpauth_url, size_t* decoded_len) {
|
|||
|
||||
const char* secret_start = strstr(otpauth_url, "secret=");
|
||||
if (!secret_start) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("In the middle of the OTPAuth URL, could not found secret");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("In the middle of the OTPAuth URL, could not found secret");
|
||||
else perror("OTPAuth URLの中に、シークレットを見つけられませんでした");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -28,7 +29,8 @@ unsigned char* extract_secret(const char* otpauth_url, size_t* decoded_len) {
|
|||
}
|
||||
|
||||
if (secret_end < secret_start) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Illegal secret range");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Illegal secret range");
|
||||
else perror("不正なシークレットの距離");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -37,7 +39,8 @@ unsigned char* extract_secret(const char* otpauth_url, size_t* decoded_len) {
|
|||
char* secret_encoded = (char*)malloc(secret_len + 1);
|
||||
|
||||
if (secret_encoded == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to allocating memory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to allocating memory");
|
||||
else perror("メモリの役割に失敗");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -49,7 +52,8 @@ unsigned char* extract_secret(const char* otpauth_url, size_t* decoded_len) {
|
|||
free(secret_encoded);
|
||||
|
||||
if (!secret_decoded) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to decrypting of the BASE32");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to decrypting of the BASE32");
|
||||
else perror("BASE32の復号化に失敗");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -61,7 +65,15 @@ uint32_t generate_totp(const char *secret, uint64_t counter) {
|
|||
counter = htobe64(counter);
|
||||
|
||||
unsigned char hash[SHA_DIGEST_LENGTH];
|
||||
HMAC(EVP_sha1(), secret, strlen(secret), (unsigned char *)&counter, sizeof(counter), hash, NULL);
|
||||
HMAC(
|
||||
EVP_sha1(),
|
||||
secret,
|
||||
strlen(secret),
|
||||
(unsigned char *)&counter,
|
||||
sizeof(counter),
|
||||
hash,
|
||||
NULL
|
||||
);
|
||||
|
||||
int offset = hash[SHA_DIGEST_LENGTH - 1] & 0x0F;
|
||||
uint32_t truncated_hash =
|
||||
|
@ -84,35 +96,40 @@ void otppass(char* file) {
|
|||
gpgme_check_version(NULL);
|
||||
err = gpgme_new(&ctx);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to generating the GPG");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to generating the GPG");
|
||||
else perror("GPGMEを創作に失敗");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
err = gpgme_data_new_from_file(&in, file, 1);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to reading the GPG file");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to reading the GPG file");
|
||||
else perror("GPGファイルを読込に失敗");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
err = gpgme_data_new(&out);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to reading the GPG data");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to reading the GPG data");
|
||||
else perror("GPGデータを読込に失敗");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
err = gpgme_op_decrypt(ctx, in, out);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to decrypting the GPG");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to decrypting the GPG");
|
||||
else perror("GPGを復号化に失敗");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
char* secret = gpgme_data_release_and_get_mem(out, &secret_len);
|
||||
if (!secret) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting the GPG");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting the GPG");
|
||||
else perror("GPGを受取に失敗");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -120,7 +137,8 @@ void otppass(char* file) {
|
|||
size_t decoded_len;
|
||||
unsigned char* secret_decoded = extract_secret(secret, &decoded_len);
|
||||
if (!secret_decoded) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to decoding or exporting secret");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to decoding or exporting secret");
|
||||
else perror("シークレットの抽出又はデコードに失敗しました");
|
||||
free(secret);
|
||||
exit(1);
|
|
@ -8,7 +8,13 @@
|
|||
|
||||
#include "showpass.h"
|
||||
|
||||
void clean_up(gpgme_ctx_t ctx, gpgme_data_t in, gpgme_data_t out, FILE* gpgfile, char* gpgpath) {
|
||||
void clean_up(
|
||||
gpgme_ctx_t ctx,
|
||||
gpgme_data_t in,
|
||||
gpgme_data_t out,
|
||||
FILE* gpgfile,
|
||||
char* gpgpath
|
||||
) {
|
||||
if (gpgfile) fclose(gpgfile);
|
||||
if (gpgpath) free(gpgpath);
|
||||
gpgme_data_release(in);
|
||||
|
@ -32,7 +38,8 @@ void showpass(char* file) {
|
|||
// GPGMEを創作
|
||||
err = gpgme_new(&ctx);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to generating GPGME: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to generating GPGME: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "GPGMEを創作に失敗:%s\n", gpgme_strerror(err));
|
||||
return;
|
||||
}
|
||||
|
@ -43,7 +50,8 @@ void showpass(char* file) {
|
|||
// 暗号化したタイルを開く
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting home directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting home directory");
|
||||
else perror("ホームディレクトリを受取に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +61,8 @@ void showpass(char* file) {
|
|||
int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
|
||||
char* gpgpath = malloc(alllen);
|
||||
if (gpgpath == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to allocating memeory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to allocating memeory");
|
||||
else perror("メモリを割当に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -74,7 +83,8 @@ void showpass(char* file) {
|
|||
|
||||
// ファイルからinデータオブジェクトを創作
|
||||
if (gpgme_data_new_from_stream(&in, gpgfile) != GPG_ERR_NO_ERROR) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to generating the GPGME data object");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to generating the GPGME data object");
|
||||
else perror("GPGMEデータオブジェクトを創作に失敗");
|
||||
clean_up(ctx, in, out, gpgfile, gpgpath);
|
||||
return;
|
||||
|
@ -82,7 +92,8 @@ void showpass(char* file) {
|
|||
|
||||
// outデータオブジェクトを創作
|
||||
if (gpgme_data_new(&out) != GPG_ERR_NO_ERROR) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to generating the GPGME data object");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to generating the GPGME data object");
|
||||
else perror("GPGMEデータオブジェクトを創作に失敗");
|
||||
clean_up(ctx, in, out, gpgfile, gpgpath);
|
||||
return;
|
||||
|
@ -94,7 +105,8 @@ void showpass(char* file) {
|
|||
// 復号化して
|
||||
err = gpgme_op_decrypt(ctx, in, out);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to decrypting: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to decrypting: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "復号化に失敗: %s\n", gpgme_strerror(err));
|
||||
|
||||
// 掃除
|
|
@ -14,7 +14,8 @@ void yankpass(char* file) {
|
|||
|
||||
// Xセッションではない場合(例えば、SSH、TTY、Gayland等)、showpass()を実行して
|
||||
if (getenv("DISPLAY") == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) puts("There is no X session, so executing 'sp -s'.");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
puts("There is no X session, so executing 'sp -s'.");
|
||||
else puts("Xセッションではありませんので、「sp -s」を実行します。");
|
||||
showpass(file);
|
||||
return;
|
||||
|
@ -33,7 +34,8 @@ void yankpass(char* file) {
|
|||
// GPGMEを創作
|
||||
err = gpgme_new(&ctx);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to generating GPGME: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to generating GPGME: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "GPGMEを創作に失敗:%s\n", gpgme_strerror(err));
|
||||
return;
|
||||
}
|
||||
|
@ -44,7 +46,8 @@ void yankpass(char* file) {
|
|||
// 暗号化したタイルを開く
|
||||
char* homedir = getenv("HOME");
|
||||
if (homedir == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to getting home directory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to getting home directory");
|
||||
else perror("ホームディレクトリを受取に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -54,7 +57,8 @@ void yankpass(char* file) {
|
|||
int alllen = snprintf(NULL, 0, "%s%s%s%s", homedir, basedir, file, ext) + 1;
|
||||
char* gpgpath = malloc(alllen);
|
||||
if (gpgpath == NULL) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Failed to allocating memory");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Failed to allocating memory");
|
||||
else perror("メモリを割当に失敗");
|
||||
return;
|
||||
}
|
||||
|
@ -80,7 +84,8 @@ void yankpass(char* file) {
|
|||
// 復号化して
|
||||
err = gpgme_op_decrypt(ctx, in, out);
|
||||
if (err) {
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) fprintf(stderr, "Failed to decryption: %s\n", gpgme_strerror(err));
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
fprintf(stderr, "Failed to decryption: %s\n", gpgme_strerror(err));
|
||||
else fprintf(stderr, "復号化に失敗: %s\n", gpgme_strerror(err));
|
||||
|
||||
// 掃除
|
||||
|
@ -102,7 +107,8 @@ void yankpass(char* file) {
|
|||
gpgme_data_release(in);
|
||||
gpgme_data_release(out);
|
||||
gpgme_release(ctx);
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) perror("Could not found a clipboard");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
perror("Could not found a clipboard");
|
||||
else perror("クリップボードを見つけられませんでした");
|
||||
return;
|
||||
}
|
||||
|
@ -123,8 +129,18 @@ void yankpass(char* file) {
|
|||
pclose(pipe);
|
||||
|
||||
// 45秒後、クリップボードから削除する
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0) puts("Added password to the clipboard.\nI will take it away from the clipboard after 45 second");
|
||||
else puts("パスワードをクリップボードに追加しました。\n45秒後はクリップボードから取り消されます");
|
||||
if (lang != NULL && strncmp(lang, "en", 2) == 0)
|
||||
printf(
|
||||
"%s\n%s",
|
||||
"Added password to the clipboard.",
|
||||
"I will take it away from the clipboard after 45 second"
|
||||
);
|
||||
else
|
||||
printf(
|
||||
"%s\n%s",
|
||||
"パスワードをクリップボードに追加しました。",
|
||||
"45秒後はクリップボードから取り消されます"
|
||||
);
|
||||
sleep(45);
|
||||
system("echo -n | xclip -selection clipboard");
|
||||
|
読み込み中…
新しいイシューから参照