commit b4db9c0f618366510ec7022becc5d7fbcafcb079
parent 035fb0bc5019ec15044538ba94874e82a236bdcb
Author: Naveen Narayanan zerous <zerous@nocebo.space>
Date: Fri, 29 Dec 2017 11:58:23 +0300
fix a couple of things:
- return value of exit()
- throw error if fopen() fails
- i/p can be n or N.
Diffstat:
README | | | 56 | -------------------------------------------------------- |
README.md | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
pass.c | | | 7 | ++++--- |
3 files changed, 67 insertions(+), 59 deletions(-)
diff --git a/README b/README
@@ -1,56 +0,0 @@
-# currently only supports OpenBSD
-* make
-* install
-
-Documentation:
-* With pass, each password lives inside of a gpg encrypted file whose filename is
- the title of the website or resource that requires the password.
-* These encrypted files may be organized into meaningful folder hierarchies,
- copied from computer to computer, and in general, manipulated using standard
- command line file management utilities.
-* All passwords live in ~/.password-store and pass provides some nice commands
- for adding, editing, generating, and retrieving passwords.
-* You can edit the password store using ordinary unix shell commands alongside
- the pass command.
-
-To be implemented:
-* initialize password store
-* show password
-* copy password to clipboard; -c
-* add existing password to the store using insert
-* generate password
-* remove password
-
-Potential Libraries:
-* GPGME
-
-Personal Development:
-* Knowledge in cryptography
-* Knowledge in algorithms
-* a utility I can use and share
-
-flags:
-init: initialize new password store and use gpg-id for encryption
-ls: list names of passwords inside the tree at subfolder by using tree(1)
-grep: searches inside decrypted password file for search-string and displays
- line containing matched string along with filename. (uses grep(1))
-find: List names of passwords inside the tree that match pass-name by using
- the tree program.
-show: decrypt and print a password. If -c is specified, xclip is used and then
- restore the clipboard after 45 sec.
-insert: insert a new password into the password store.
-rm: remove the password from the password store.
-mv: renames the password or directory named old-path to new-path
-help: Show usage message
-ver: Show version information
-
-
-Notes:
-* standard password store only supports gpgv2
-
-GnuPG Functions:
-gpg encrypt
-gpg decrypt
-
-OpenBSD perks:
-pledge
diff --git a/README.md b/README.md
@@ -0,0 +1,63 @@
+# pass
+
+A stripped down version of the standard unix password manager "pass" in C.
+
+# Dependencies
+
+gpg2
+libgpgme
+
+# Installation
+
+Edit config.mk to match your setup (pass is installed into
+/usr/local/ namespace by default).
+
+Post-configuration:
+
+$ make
+$ doas make install
+
+# Documentation:
+
+* With pass, each password lives inside of a gpg encrypted file whose filename is
+ the title of the website or resource that requires the password.
+* These encrypted files may be dealt with like any other file & manipulated
+ using standard command line file management utilities.
+* Passwords live inside the respective files in ~/.password-store.
+* pass provides some commands for adding, removing and retrieving passwords.
+* Editing passwords is possible by overwriting them.
+
+# Commands
+
+init:
+ initialize new password storage and use a gpg-uid for encryption.
+
+insert:
+ insert a new password into the password store.
+
+rm:
+ remove password from the password store.
+
+show:
+ "show" is just a place-holder. Invoking pass with the filename will
+ decrypt it and print the password to stdout.
+
+help:
+ Show usage message.
+
+ver:
+ Show version information
+
+# Credits
+
+Jason at zx2c4 dot com <https://www.passwordstore.org/>
+
+# Extras
+
+pkg_install tree pwgen
+
+You may use tree to view the structure of files and directories in
+~/.password-store.
+You can pipeline the output of pwgen to pass; creating complex passwords.
+ pwgen -1 | pass insert Email/userid@domain.com
+Note: pass will read input until newline.
diff --git a/pass.c b/pass.c
@@ -59,7 +59,7 @@ usage(void)
"\tpass pass-name\n"
"\tpass rm pass-name\n"
);
- exit(0);
+ exit(1);
}
void
@@ -137,6 +137,8 @@ getuserid(char *u)
snprintf(file, sizeof(file), "%s/.password-store/.gpg-id", home);
fp = fopen(file, "r");
+ if (!fp)
+ fatal("fopen: %s", file);
while ((i = fgetc(fp)) != EOF)
*u++ = i;
*u = '\0';
@@ -196,7 +198,7 @@ insert(char *item)
if ((fp = fopen(t, "r"))) {
if (isatty(fd)) {
printf("An entry already exists for %s. Overwrite it? [y/N] ", filename);
- if ((c = getchar()) == 'N') {
+ if ((c = getchar()) == 'N' || c == 'n') {
fclose(fp);
logdbgx("Don't overwrite");
exit(1);
@@ -204,7 +206,6 @@ insert(char *item)
} else {
/* Assuming user knows what he/she is doing */
printf("Overwriting %s\n", filename);
- c = 'y';
}
}