From: www Date: Sun, 29 Sep 2024 21:23:04 +0000 (+0000) Subject: Mirrored from /srv/git/yakumo.izuru/kanako.git X-Git-Url: https://git.chaotic.ninja/gitweb/yakumo_izuru/?a=commitdiff_plain;ds=sidebyside;p=kanako.git Mirrored from /srv/git/yakumo.izuru/kanako.git git-svn-id: https://svn.chaotic.ninja/svn/kanako-yakumo.izuru@1 19e37f98-b34b-0547-aedb-2b2ec0473a78 --- 252365c0f18b74a2b4407ccfbe668ac7f4c673ba diff --git a/branches/master/COPYING b/branches/master/COPYING new file mode 100644 index 0000000..e31cea1 --- /dev/null +++ b/branches/master/COPYING @@ -0,0 +1,8 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42.1): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a bottle of sake in return Izuru Yakumo + * ---------------------------------------------------------------------------- + */ diff --git a/branches/master/Makefile b/branches/master/Makefile new file mode 100644 index 0000000..a09066b --- /dev/null +++ b/branches/master/Makefile @@ -0,0 +1,14 @@ +PREFIX=/usr/local + +fmt: + shfmt --posix --write kanako + +install: + install -Dm0755 kanako ${DESTDIR}${PREFIX}/bin/kanako + install -Dm0600 kanako.conf.example ${DESTDIR}${PREFIX}/share/examples/kanako/kanako.conf + install -Dm0600 kanako.mdoc ${DESTDIR}${PREFIX}/share/man/man1/kanako.1 + install -Dm0600 kanako.conf.mdoc ${DESTDIR}${PREFIX}/share/man/man5/kanako.conf.5 +uninstall: + rm -f ${PREFIX}/bin/kanako + rm -f ${PREFIX}/share/examples/kanako/kanako.conf + rm -f ${PREFIX}/share/man/man1/kanako.1 ${PREFIX}/share/man/man5/kanako.conf.5 diff --git a/branches/master/README.md b/branches/master/README.md new file mode 100644 index 0000000..333710d --- /dev/null +++ b/branches/master/README.md @@ -0,0 +1,37 @@ +# kanako (神奈子) +the adaptable password manager. named after [Kanako Yasaka](https://en.touhouwiki.net/wiki/Kanako_Yasaka) from [Touhou 10: Mountain of Faith](https://en.touhouwiki.net/wiki/Mountain_of_Faith) + +## Backends supported +* [age](https://age-encryption.org) +* [cream](https://z3bra.org/cream/) +* [gpg](https://gnupg.org) +* [salty](https://git.mills.io/prologic/salty) + +## Dependencies +* Any of the above, depending how you configured it +* `tree(1)` for printing a list +* `mandoc(1)` for documentation +* `rm(1)` with the `-i` and `-I` switches +* `strings(1)`, `dd(1)` and `tr(1)` for generating passwords + +## Add-ons + +### kanako-menu +quick graphical front-end for kanako, works with either of `dmenu(1)` +or `bemenu(1)`, useful for copying passwords to clipboard. + +### kanako-totp +time-based one time password addon for kanako, requires `oathtool(1)` +from oath-toolkit. + +## License +* [Beerware License (Revision 42.1)](COPYING) + +## Related software +* [beastie/aps](https://codeberg.org/beastie/aps) +* [biox/pa](https://github.com/biox/pa) +* [e-zk/page](https://github.com/e-zk/page) +* [kl3/spm](https://notabug.org/kl3/spm) +* [nmeum/tpm](https://github.com/nmeum/tpm) +* [shokara/angou](https://gt.kalli.st/shokara/angou) +* [zx2c4/pass](https://passwordstore.org) diff --git a/branches/master/addons/kanako-menu b/branches/master/addons/kanako-menu new file mode 100644 index 0000000..8725ad1 --- /dev/null +++ b/branches/master/addons/kanako-menu @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -f "${kanako_conf_dir}"/kanako.conf; then + . "${kanako_conf_dir}"/kanako.conf +else + echo "Configuration file has not been found!" + exit 1 +fi + +find . -name '*.enc' | sort | sed 's,^\./,,;s,\.enc$,,' | "${kanako_menu_cmd}" | xargs $(which kanako) -c diff --git a/branches/master/addons/kanako-totp b/branches/master/addons/kanako-totp new file mode 100644 index 0000000..d544872 --- /dev/null +++ b/branches/master/addons/kanako-totp @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +# extracted from https://rgz.ee/bin/pass + +totp_seed="$(kanako -v "$@" | grep 'totp: ' | head -n1 | cut -d' ' -f2)" +if ! [ -z "$totp_seed" ]; then + if command -v oathtool >/dev/null 2>&1; then + oathtool --totp -b "$totp_seed" + else + echo 'oathtool(1) should be installed' + exit 1 + fi +fi diff --git a/branches/master/kanako b/branches/master/kanako new file mode 100644 index 0000000..55e5594 --- /dev/null +++ b/branches/master/kanako @@ -0,0 +1,90 @@ +#!/bin/sh +# $TheSupernovaDuo: kanako,v 2.1 2023/10/25 01:50:28 yakumo_izuru Exp $ + +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_key_dir="${kanako_key_dir:-$HOME/.kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -d "${kanako_store_dir}"; then + cd "${kanako_store_dir}" +else + printf "Password store not found!\n" + printf "Create it with mkdir -p %s\n" "$kanako_store_dir" + exit 1 +fi + +if test -f "${kanako_conf_dir}/kanako.conf"; then + . "${kanako_conf_dir}/kanako.conf" +else + printf "Configuration file has not been found!\n" + printf "Copy kanako.conf from the examples directory,\n" + printf "and edit accordingly.\n" + exit 1 +fi + +copy() { + view "$1" | "${kanako_clip_cmd}" +} +edit() { + if [ -f ${1%%.enc}.enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc >${1%%.enc} + "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} >${1%%.enc}.enc + rm "${1%%.enc}" + else + printf "%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc" + fi +} +gen() { + printf "%s\n" $(strings /dev/null | tr -d ' \t\n\r') +} +list() { + if [ -z "$1" ]; then + $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g' + else + $(which tree) "${1:-.}" | sed 's/\.enc//g' + fi +} +new() { + test -d "$1" && usage + + tmpfile="$(mktemp)" + "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" + + mkdir -p "$(dirname "$1")" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc + rm ${tmpfile} +} +delete_directory() { + rm -r -I "$1" +} +delete_file() { + rm -i "${1}${2}".enc +} +usage() { + printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0" + printf "The arguments for all switches are relative to \${kanako_store_dir}\n" + printf "which is located at %s\n" "${kanako_store_dir}" + exit 1 +} +view() { + if [ -f "${1%%.enc}".enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc + elif [ -d "${1:-.}" ]; then + list "${1:-.}" + else + usage + fi +} + +case $1 in +-c) copy $2 ;; +-e) edit $2 ;; +-g) gen $2 ;; +-l) list $2 ;; +-n) new $2 ;; +-R) delete_directory $2 ;; +-r) delete_file $2 ;; +-v) view $2 ;; +*) usage ;; +esac diff --git a/branches/master/kanako.conf.example b/branches/master/kanako.conf.example new file mode 100644 index 0000000..60d6c3b --- /dev/null +++ b/branches/master/kanako.conf.example @@ -0,0 +1,25 @@ +# Configuration file for kanako(1) + +#kanako_clip_cmd="xclip -i" +#kanako_clip_cmd="wl-copy --primary" +#kanako_menu_cmd="dmenu" + +## age +#kanako_encrypt_cmd="age" +#kanako_encrypt_args="-e -R ${kanako_key_dir}/pub.key --armor" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.key" + +## cream +#kanako_encrypt_cmd="cream" +#kanako_encrypt_args="-e -f" +#kanako_decrypt_args="-d" + +## gpg +#kanako_encrypt_cmd="gpg" +#kanako_encrypt_args="-e --recipient ${kanako_key_dir}/pub.key" +#kanako_decrypt_args="-d" + +## salty +#kanako_encrypt_cmd="salty" +#kanako_encrypt_args="-e -r $(cat ${kanako_key_dir}/pub.slt)" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.slt" diff --git a/branches/master/kanako.conf.mdoc b/branches/master/kanako.conf.mdoc new file mode 100644 index 0000000..66c0bd4 --- /dev/null +++ b/branches/master/kanako.conf.mdoc @@ -0,0 +1,30 @@ +.Dd $Mdocdate$ +.Dt KANAKO.CONF 5 +.Os +.Sh NAME +.Nm kanako.conf +.Nd configuration file for +.Xr kanako 1 +.Sh FIELDS +.Bl -tag -width 11n -compact +.It kanako_clip_cmd +Clipboard executable to be +used with the -c switch +.It kanako_decrypt_args +Arguments for decryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_args +Arguments for encryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_cmd +Encryption executable to +be used with the program +.It kanako_menu_cmd +Menu executable to +be used with kanako_menu +.El +.Sh SEE ALSO +.Xr kanako 1 +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja + diff --git a/branches/master/kanako.mdoc b/branches/master/kanako.mdoc new file mode 100644 index 0000000..72e428b --- /dev/null +++ b/branches/master/kanako.mdoc @@ -0,0 +1,61 @@ +.Dd $Mdocdate$ +.Dt KANAKO 1 +.Os +.Sh NAME +.Nm kanako +.Nd the adaptable password manager +.Sh SYNOPSIS +.Nm +.Op Fl ceglnrRv +.Op Ar args +.Sh DESCRIPTION +It is a clean rewrite of +.Xr ayu 1 +supporting multiple backends +and having more add-ons for +use with it. However, it +may be pretty unstable compared +to said tool, but should work +well for its purpose. +.Sh USAGE +.Bl -tag -width 11n -compact +.It -n +Add a new entry +.It -c +Copy an entry's text to the clipboard +.It -e +Edit an entry +.It -g +Generate a random password +.It -l +List all entries +.It -r +Remove single entries, +will prompt for confirmation +.It -R +Remove recursively a directory w/ entries, +will prompt for confirmation +.It -v +View an entry +.Bl +.El +.Sh SEE ALSO +.Xr age 1 +.Xr cream 1 +.Xr gpg 1 +.Xr kanako.conf 5 +.Xr pwgen 1 +.Xr salty 1 +.Rs +.%A Rob Pike +.%T "UNIX Style, or cat -v Considered Harmful" +.%J "USENIX Summer Conference Proceedings" +.%D 1983 +.Re +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja +.Sh BUGS +Under the Wayland display protocol, +the clipboard subcommand won't work, +due to 'Permission denied'. On X11 +it works just fine. diff --git a/branches/origin-master/COPYING b/branches/origin-master/COPYING new file mode 100644 index 0000000..e31cea1 --- /dev/null +++ b/branches/origin-master/COPYING @@ -0,0 +1,8 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42.1): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a bottle of sake in return Izuru Yakumo + * ---------------------------------------------------------------------------- + */ diff --git a/branches/origin-master/Makefile b/branches/origin-master/Makefile new file mode 100644 index 0000000..a09066b --- /dev/null +++ b/branches/origin-master/Makefile @@ -0,0 +1,14 @@ +PREFIX=/usr/local + +fmt: + shfmt --posix --write kanako + +install: + install -Dm0755 kanako ${DESTDIR}${PREFIX}/bin/kanako + install -Dm0600 kanako.conf.example ${DESTDIR}${PREFIX}/share/examples/kanako/kanako.conf + install -Dm0600 kanako.mdoc ${DESTDIR}${PREFIX}/share/man/man1/kanako.1 + install -Dm0600 kanako.conf.mdoc ${DESTDIR}${PREFIX}/share/man/man5/kanako.conf.5 +uninstall: + rm -f ${PREFIX}/bin/kanako + rm -f ${PREFIX}/share/examples/kanako/kanako.conf + rm -f ${PREFIX}/share/man/man1/kanako.1 ${PREFIX}/share/man/man5/kanako.conf.5 diff --git a/branches/origin-master/README.md b/branches/origin-master/README.md new file mode 100644 index 0000000..333710d --- /dev/null +++ b/branches/origin-master/README.md @@ -0,0 +1,37 @@ +# kanako (神奈子) +the adaptable password manager. named after [Kanako Yasaka](https://en.touhouwiki.net/wiki/Kanako_Yasaka) from [Touhou 10: Mountain of Faith](https://en.touhouwiki.net/wiki/Mountain_of_Faith) + +## Backends supported +* [age](https://age-encryption.org) +* [cream](https://z3bra.org/cream/) +* [gpg](https://gnupg.org) +* [salty](https://git.mills.io/prologic/salty) + +## Dependencies +* Any of the above, depending how you configured it +* `tree(1)` for printing a list +* `mandoc(1)` for documentation +* `rm(1)` with the `-i` and `-I` switches +* `strings(1)`, `dd(1)` and `tr(1)` for generating passwords + +## Add-ons + +### kanako-menu +quick graphical front-end for kanako, works with either of `dmenu(1)` +or `bemenu(1)`, useful for copying passwords to clipboard. + +### kanako-totp +time-based one time password addon for kanako, requires `oathtool(1)` +from oath-toolkit. + +## License +* [Beerware License (Revision 42.1)](COPYING) + +## Related software +* [beastie/aps](https://codeberg.org/beastie/aps) +* [biox/pa](https://github.com/biox/pa) +* [e-zk/page](https://github.com/e-zk/page) +* [kl3/spm](https://notabug.org/kl3/spm) +* [nmeum/tpm](https://github.com/nmeum/tpm) +* [shokara/angou](https://gt.kalli.st/shokara/angou) +* [zx2c4/pass](https://passwordstore.org) diff --git a/branches/origin-master/addons/kanako-menu b/branches/origin-master/addons/kanako-menu new file mode 100644 index 0000000..8725ad1 --- /dev/null +++ b/branches/origin-master/addons/kanako-menu @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -f "${kanako_conf_dir}"/kanako.conf; then + . "${kanako_conf_dir}"/kanako.conf +else + echo "Configuration file has not been found!" + exit 1 +fi + +find . -name '*.enc' | sort | sed 's,^\./,,;s,\.enc$,,' | "${kanako_menu_cmd}" | xargs $(which kanako) -c diff --git a/branches/origin-master/addons/kanako-totp b/branches/origin-master/addons/kanako-totp new file mode 100644 index 0000000..d544872 --- /dev/null +++ b/branches/origin-master/addons/kanako-totp @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +# extracted from https://rgz.ee/bin/pass + +totp_seed="$(kanako -v "$@" | grep 'totp: ' | head -n1 | cut -d' ' -f2)" +if ! [ -z "$totp_seed" ]; then + if command -v oathtool >/dev/null 2>&1; then + oathtool --totp -b "$totp_seed" + else + echo 'oathtool(1) should be installed' + exit 1 + fi +fi diff --git a/branches/origin-master/kanako b/branches/origin-master/kanako new file mode 100644 index 0000000..55e5594 --- /dev/null +++ b/branches/origin-master/kanako @@ -0,0 +1,90 @@ +#!/bin/sh +# $TheSupernovaDuo: kanako,v 2.1 2023/10/25 01:50:28 yakumo_izuru Exp $ + +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_key_dir="${kanako_key_dir:-$HOME/.kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -d "${kanako_store_dir}"; then + cd "${kanako_store_dir}" +else + printf "Password store not found!\n" + printf "Create it with mkdir -p %s\n" "$kanako_store_dir" + exit 1 +fi + +if test -f "${kanako_conf_dir}/kanako.conf"; then + . "${kanako_conf_dir}/kanako.conf" +else + printf "Configuration file has not been found!\n" + printf "Copy kanako.conf from the examples directory,\n" + printf "and edit accordingly.\n" + exit 1 +fi + +copy() { + view "$1" | "${kanako_clip_cmd}" +} +edit() { + if [ -f ${1%%.enc}.enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc >${1%%.enc} + "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} >${1%%.enc}.enc + rm "${1%%.enc}" + else + printf "%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc" + fi +} +gen() { + printf "%s\n" $(strings /dev/null | tr -d ' \t\n\r') +} +list() { + if [ -z "$1" ]; then + $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g' + else + $(which tree) "${1:-.}" | sed 's/\.enc//g' + fi +} +new() { + test -d "$1" && usage + + tmpfile="$(mktemp)" + "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" + + mkdir -p "$(dirname "$1")" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc + rm ${tmpfile} +} +delete_directory() { + rm -r -I "$1" +} +delete_file() { + rm -i "${1}${2}".enc +} +usage() { + printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0" + printf "The arguments for all switches are relative to \${kanako_store_dir}\n" + printf "which is located at %s\n" "${kanako_store_dir}" + exit 1 +} +view() { + if [ -f "${1%%.enc}".enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc + elif [ -d "${1:-.}" ]; then + list "${1:-.}" + else + usage + fi +} + +case $1 in +-c) copy $2 ;; +-e) edit $2 ;; +-g) gen $2 ;; +-l) list $2 ;; +-n) new $2 ;; +-R) delete_directory $2 ;; +-r) delete_file $2 ;; +-v) view $2 ;; +*) usage ;; +esac diff --git a/branches/origin-master/kanako.conf.example b/branches/origin-master/kanako.conf.example new file mode 100644 index 0000000..60d6c3b --- /dev/null +++ b/branches/origin-master/kanako.conf.example @@ -0,0 +1,25 @@ +# Configuration file for kanako(1) + +#kanako_clip_cmd="xclip -i" +#kanako_clip_cmd="wl-copy --primary" +#kanako_menu_cmd="dmenu" + +## age +#kanako_encrypt_cmd="age" +#kanako_encrypt_args="-e -R ${kanako_key_dir}/pub.key --armor" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.key" + +## cream +#kanako_encrypt_cmd="cream" +#kanako_encrypt_args="-e -f" +#kanako_decrypt_args="-d" + +## gpg +#kanako_encrypt_cmd="gpg" +#kanako_encrypt_args="-e --recipient ${kanako_key_dir}/pub.key" +#kanako_decrypt_args="-d" + +## salty +#kanako_encrypt_cmd="salty" +#kanako_encrypt_args="-e -r $(cat ${kanako_key_dir}/pub.slt)" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.slt" diff --git a/branches/origin-master/kanako.conf.mdoc b/branches/origin-master/kanako.conf.mdoc new file mode 100644 index 0000000..66c0bd4 --- /dev/null +++ b/branches/origin-master/kanako.conf.mdoc @@ -0,0 +1,30 @@ +.Dd $Mdocdate$ +.Dt KANAKO.CONF 5 +.Os +.Sh NAME +.Nm kanako.conf +.Nd configuration file for +.Xr kanako 1 +.Sh FIELDS +.Bl -tag -width 11n -compact +.It kanako_clip_cmd +Clipboard executable to be +used with the -c switch +.It kanako_decrypt_args +Arguments for decryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_args +Arguments for encryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_cmd +Encryption executable to +be used with the program +.It kanako_menu_cmd +Menu executable to +be used with kanako_menu +.El +.Sh SEE ALSO +.Xr kanako 1 +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja + diff --git a/branches/origin-master/kanako.mdoc b/branches/origin-master/kanako.mdoc new file mode 100644 index 0000000..72e428b --- /dev/null +++ b/branches/origin-master/kanako.mdoc @@ -0,0 +1,61 @@ +.Dd $Mdocdate$ +.Dt KANAKO 1 +.Os +.Sh NAME +.Nm kanako +.Nd the adaptable password manager +.Sh SYNOPSIS +.Nm +.Op Fl ceglnrRv +.Op Ar args +.Sh DESCRIPTION +It is a clean rewrite of +.Xr ayu 1 +supporting multiple backends +and having more add-ons for +use with it. However, it +may be pretty unstable compared +to said tool, but should work +well for its purpose. +.Sh USAGE +.Bl -tag -width 11n -compact +.It -n +Add a new entry +.It -c +Copy an entry's text to the clipboard +.It -e +Edit an entry +.It -g +Generate a random password +.It -l +List all entries +.It -r +Remove single entries, +will prompt for confirmation +.It -R +Remove recursively a directory w/ entries, +will prompt for confirmation +.It -v +View an entry +.Bl +.El +.Sh SEE ALSO +.Xr age 1 +.Xr cream 1 +.Xr gpg 1 +.Xr kanako.conf 5 +.Xr pwgen 1 +.Xr salty 1 +.Rs +.%A Rob Pike +.%T "UNIX Style, or cat -v Considered Harmful" +.%J "USENIX Summer Conference Proceedings" +.%D 1983 +.Re +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja +.Sh BUGS +Under the Wayland display protocol, +the clipboard subcommand won't work, +due to 'Permission denied'. On X11 +it works just fine. diff --git a/branches/origin/COPYING b/branches/origin/COPYING new file mode 100644 index 0000000..e31cea1 --- /dev/null +++ b/branches/origin/COPYING @@ -0,0 +1,8 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42.1): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a bottle of sake in return Izuru Yakumo + * ---------------------------------------------------------------------------- + */ diff --git a/branches/origin/Makefile b/branches/origin/Makefile new file mode 100644 index 0000000..a09066b --- /dev/null +++ b/branches/origin/Makefile @@ -0,0 +1,14 @@ +PREFIX=/usr/local + +fmt: + shfmt --posix --write kanako + +install: + install -Dm0755 kanako ${DESTDIR}${PREFIX}/bin/kanako + install -Dm0600 kanako.conf.example ${DESTDIR}${PREFIX}/share/examples/kanako/kanako.conf + install -Dm0600 kanako.mdoc ${DESTDIR}${PREFIX}/share/man/man1/kanako.1 + install -Dm0600 kanako.conf.mdoc ${DESTDIR}${PREFIX}/share/man/man5/kanako.conf.5 +uninstall: + rm -f ${PREFIX}/bin/kanako + rm -f ${PREFIX}/share/examples/kanako/kanako.conf + rm -f ${PREFIX}/share/man/man1/kanako.1 ${PREFIX}/share/man/man5/kanako.conf.5 diff --git a/branches/origin/README.md b/branches/origin/README.md new file mode 100644 index 0000000..333710d --- /dev/null +++ b/branches/origin/README.md @@ -0,0 +1,37 @@ +# kanako (神奈子) +the adaptable password manager. named after [Kanako Yasaka](https://en.touhouwiki.net/wiki/Kanako_Yasaka) from [Touhou 10: Mountain of Faith](https://en.touhouwiki.net/wiki/Mountain_of_Faith) + +## Backends supported +* [age](https://age-encryption.org) +* [cream](https://z3bra.org/cream/) +* [gpg](https://gnupg.org) +* [salty](https://git.mills.io/prologic/salty) + +## Dependencies +* Any of the above, depending how you configured it +* `tree(1)` for printing a list +* `mandoc(1)` for documentation +* `rm(1)` with the `-i` and `-I` switches +* `strings(1)`, `dd(1)` and `tr(1)` for generating passwords + +## Add-ons + +### kanako-menu +quick graphical front-end for kanako, works with either of `dmenu(1)` +or `bemenu(1)`, useful for copying passwords to clipboard. + +### kanako-totp +time-based one time password addon for kanako, requires `oathtool(1)` +from oath-toolkit. + +## License +* [Beerware License (Revision 42.1)](COPYING) + +## Related software +* [beastie/aps](https://codeberg.org/beastie/aps) +* [biox/pa](https://github.com/biox/pa) +* [e-zk/page](https://github.com/e-zk/page) +* [kl3/spm](https://notabug.org/kl3/spm) +* [nmeum/tpm](https://github.com/nmeum/tpm) +* [shokara/angou](https://gt.kalli.st/shokara/angou) +* [zx2c4/pass](https://passwordstore.org) diff --git a/branches/origin/addons/kanako-menu b/branches/origin/addons/kanako-menu new file mode 100644 index 0000000..8725ad1 --- /dev/null +++ b/branches/origin/addons/kanako-menu @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -f "${kanako_conf_dir}"/kanako.conf; then + . "${kanako_conf_dir}"/kanako.conf +else + echo "Configuration file has not been found!" + exit 1 +fi + +find . -name '*.enc' | sort | sed 's,^\./,,;s,\.enc$,,' | "${kanako_menu_cmd}" | xargs $(which kanako) -c diff --git a/branches/origin/addons/kanako-totp b/branches/origin/addons/kanako-totp new file mode 100644 index 0000000..d544872 --- /dev/null +++ b/branches/origin/addons/kanako-totp @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +# extracted from https://rgz.ee/bin/pass + +totp_seed="$(kanako -v "$@" | grep 'totp: ' | head -n1 | cut -d' ' -f2)" +if ! [ -z "$totp_seed" ]; then + if command -v oathtool >/dev/null 2>&1; then + oathtool --totp -b "$totp_seed" + else + echo 'oathtool(1) should be installed' + exit 1 + fi +fi diff --git a/branches/origin/kanako b/branches/origin/kanako new file mode 100644 index 0000000..55e5594 --- /dev/null +++ b/branches/origin/kanako @@ -0,0 +1,90 @@ +#!/bin/sh +# $TheSupernovaDuo: kanako,v 2.1 2023/10/25 01:50:28 yakumo_izuru Exp $ + +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_key_dir="${kanako_key_dir:-$HOME/.kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -d "${kanako_store_dir}"; then + cd "${kanako_store_dir}" +else + printf "Password store not found!\n" + printf "Create it with mkdir -p %s\n" "$kanako_store_dir" + exit 1 +fi + +if test -f "${kanako_conf_dir}/kanako.conf"; then + . "${kanako_conf_dir}/kanako.conf" +else + printf "Configuration file has not been found!\n" + printf "Copy kanako.conf from the examples directory,\n" + printf "and edit accordingly.\n" + exit 1 +fi + +copy() { + view "$1" | "${kanako_clip_cmd}" +} +edit() { + if [ -f ${1%%.enc}.enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc >${1%%.enc} + "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} >${1%%.enc}.enc + rm "${1%%.enc}" + else + printf "%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc" + fi +} +gen() { + printf "%s\n" $(strings /dev/null | tr -d ' \t\n\r') +} +list() { + if [ -z "$1" ]; then + $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g' + else + $(which tree) "${1:-.}" | sed 's/\.enc//g' + fi +} +new() { + test -d "$1" && usage + + tmpfile="$(mktemp)" + "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" + + mkdir -p "$(dirname "$1")" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc + rm ${tmpfile} +} +delete_directory() { + rm -r -I "$1" +} +delete_file() { + rm -i "${1}${2}".enc +} +usage() { + printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0" + printf "The arguments for all switches are relative to \${kanako_store_dir}\n" + printf "which is located at %s\n" "${kanako_store_dir}" + exit 1 +} +view() { + if [ -f "${1%%.enc}".enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc + elif [ -d "${1:-.}" ]; then + list "${1:-.}" + else + usage + fi +} + +case $1 in +-c) copy $2 ;; +-e) edit $2 ;; +-g) gen $2 ;; +-l) list $2 ;; +-n) new $2 ;; +-R) delete_directory $2 ;; +-r) delete_file $2 ;; +-v) view $2 ;; +*) usage ;; +esac diff --git a/branches/origin/kanako.conf.example b/branches/origin/kanako.conf.example new file mode 100644 index 0000000..60d6c3b --- /dev/null +++ b/branches/origin/kanako.conf.example @@ -0,0 +1,25 @@ +# Configuration file for kanako(1) + +#kanako_clip_cmd="xclip -i" +#kanako_clip_cmd="wl-copy --primary" +#kanako_menu_cmd="dmenu" + +## age +#kanako_encrypt_cmd="age" +#kanako_encrypt_args="-e -R ${kanako_key_dir}/pub.key --armor" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.key" + +## cream +#kanako_encrypt_cmd="cream" +#kanako_encrypt_args="-e -f" +#kanako_decrypt_args="-d" + +## gpg +#kanako_encrypt_cmd="gpg" +#kanako_encrypt_args="-e --recipient ${kanako_key_dir}/pub.key" +#kanako_decrypt_args="-d" + +## salty +#kanako_encrypt_cmd="salty" +#kanako_encrypt_args="-e -r $(cat ${kanako_key_dir}/pub.slt)" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.slt" diff --git a/branches/origin/kanako.conf.mdoc b/branches/origin/kanako.conf.mdoc new file mode 100644 index 0000000..66c0bd4 --- /dev/null +++ b/branches/origin/kanako.conf.mdoc @@ -0,0 +1,30 @@ +.Dd $Mdocdate$ +.Dt KANAKO.CONF 5 +.Os +.Sh NAME +.Nm kanako.conf +.Nd configuration file for +.Xr kanako 1 +.Sh FIELDS +.Bl -tag -width 11n -compact +.It kanako_clip_cmd +Clipboard executable to be +used with the -c switch +.It kanako_decrypt_args +Arguments for decryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_args +Arguments for encryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_cmd +Encryption executable to +be used with the program +.It kanako_menu_cmd +Menu executable to +be used with kanako_menu +.El +.Sh SEE ALSO +.Xr kanako 1 +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja + diff --git a/branches/origin/kanako.mdoc b/branches/origin/kanako.mdoc new file mode 100644 index 0000000..72e428b --- /dev/null +++ b/branches/origin/kanako.mdoc @@ -0,0 +1,61 @@ +.Dd $Mdocdate$ +.Dt KANAKO 1 +.Os +.Sh NAME +.Nm kanako +.Nd the adaptable password manager +.Sh SYNOPSIS +.Nm +.Op Fl ceglnrRv +.Op Ar args +.Sh DESCRIPTION +It is a clean rewrite of +.Xr ayu 1 +supporting multiple backends +and having more add-ons for +use with it. However, it +may be pretty unstable compared +to said tool, but should work +well for its purpose. +.Sh USAGE +.Bl -tag -width 11n -compact +.It -n +Add a new entry +.It -c +Copy an entry's text to the clipboard +.It -e +Edit an entry +.It -g +Generate a random password +.It -l +List all entries +.It -r +Remove single entries, +will prompt for confirmation +.It -R +Remove recursively a directory w/ entries, +will prompt for confirmation +.It -v +View an entry +.Bl +.El +.Sh SEE ALSO +.Xr age 1 +.Xr cream 1 +.Xr gpg 1 +.Xr kanako.conf 5 +.Xr pwgen 1 +.Xr salty 1 +.Rs +.%A Rob Pike +.%T "UNIX Style, or cat -v Considered Harmful" +.%J "USENIX Summer Conference Proceedings" +.%D 1983 +.Re +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja +.Sh BUGS +Under the Wayland display protocol, +the clipboard subcommand won't work, +due to 'Permission denied'. On X11 +it works just fine. diff --git a/trunk/COPYING b/trunk/COPYING new file mode 100644 index 0000000..e31cea1 --- /dev/null +++ b/trunk/COPYING @@ -0,0 +1,8 @@ +/* + * ---------------------------------------------------------------------------- + * "THE BEER-WARE LICENSE" (Revision 42.1): + * wrote this file. As long as you retain this notice you + * can do whatever you want with this stuff. If we meet some day, and you think + * this stuff is worth it, you can buy me a bottle of sake in return Izuru Yakumo + * ---------------------------------------------------------------------------- + */ diff --git a/trunk/Makefile b/trunk/Makefile new file mode 100644 index 0000000..a09066b --- /dev/null +++ b/trunk/Makefile @@ -0,0 +1,14 @@ +PREFIX=/usr/local + +fmt: + shfmt --posix --write kanako + +install: + install -Dm0755 kanako ${DESTDIR}${PREFIX}/bin/kanako + install -Dm0600 kanako.conf.example ${DESTDIR}${PREFIX}/share/examples/kanako/kanako.conf + install -Dm0600 kanako.mdoc ${DESTDIR}${PREFIX}/share/man/man1/kanako.1 + install -Dm0600 kanako.conf.mdoc ${DESTDIR}${PREFIX}/share/man/man5/kanako.conf.5 +uninstall: + rm -f ${PREFIX}/bin/kanako + rm -f ${PREFIX}/share/examples/kanako/kanako.conf + rm -f ${PREFIX}/share/man/man1/kanako.1 ${PREFIX}/share/man/man5/kanako.conf.5 diff --git a/trunk/README.md b/trunk/README.md new file mode 100644 index 0000000..333710d --- /dev/null +++ b/trunk/README.md @@ -0,0 +1,37 @@ +# kanako (神奈子) +the adaptable password manager. named after [Kanako Yasaka](https://en.touhouwiki.net/wiki/Kanako_Yasaka) from [Touhou 10: Mountain of Faith](https://en.touhouwiki.net/wiki/Mountain_of_Faith) + +## Backends supported +* [age](https://age-encryption.org) +* [cream](https://z3bra.org/cream/) +* [gpg](https://gnupg.org) +* [salty](https://git.mills.io/prologic/salty) + +## Dependencies +* Any of the above, depending how you configured it +* `tree(1)` for printing a list +* `mandoc(1)` for documentation +* `rm(1)` with the `-i` and `-I` switches +* `strings(1)`, `dd(1)` and `tr(1)` for generating passwords + +## Add-ons + +### kanako-menu +quick graphical front-end for kanako, works with either of `dmenu(1)` +or `bemenu(1)`, useful for copying passwords to clipboard. + +### kanako-totp +time-based one time password addon for kanako, requires `oathtool(1)` +from oath-toolkit. + +## License +* [Beerware License (Revision 42.1)](COPYING) + +## Related software +* [beastie/aps](https://codeberg.org/beastie/aps) +* [biox/pa](https://github.com/biox/pa) +* [e-zk/page](https://github.com/e-zk/page) +* [kl3/spm](https://notabug.org/kl3/spm) +* [nmeum/tpm](https://github.com/nmeum/tpm) +* [shokara/angou](https://gt.kalli.st/shokara/angou) +* [zx2c4/pass](https://passwordstore.org) diff --git a/trunk/addons/kanako-menu b/trunk/addons/kanako-menu new file mode 100644 index 0000000..8725ad1 --- /dev/null +++ b/trunk/addons/kanako-menu @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -f "${kanako_conf_dir}"/kanako.conf; then + . "${kanako_conf_dir}"/kanako.conf +else + echo "Configuration file has not been found!" + exit 1 +fi + +find . -name '*.enc' | sort | sed 's,^\./,,;s,\.enc$,,' | "${kanako_menu_cmd}" | xargs $(which kanako) -c diff --git a/trunk/addons/kanako-totp b/trunk/addons/kanako-totp new file mode 100644 index 0000000..d544872 --- /dev/null +++ b/trunk/addons/kanako-totp @@ -0,0 +1,13 @@ +#!/bin/sh -e +# $TheSupernovaDuo: kanako,v 1.9 2023/5/18 21:9:33 yakumo_izuru Exp $ +# extracted from https://rgz.ee/bin/pass + +totp_seed="$(kanako -v "$@" | grep 'totp: ' | head -n1 | cut -d' ' -f2)" +if ! [ -z "$totp_seed" ]; then + if command -v oathtool >/dev/null 2>&1; then + oathtool --totp -b "$totp_seed" + else + echo 'oathtool(1) should be installed' + exit 1 + fi +fi diff --git a/trunk/kanako b/trunk/kanako new file mode 100644 index 0000000..55e5594 --- /dev/null +++ b/trunk/kanako @@ -0,0 +1,90 @@ +#!/bin/sh +# $TheSupernovaDuo: kanako,v 2.1 2023/10/25 01:50:28 yakumo_izuru Exp $ + +readonly kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" +readonly kanako_key_dir="${kanako_key_dir:-$HOME/.kanako}" +readonly kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" + +if test -d "${kanako_store_dir}"; then + cd "${kanako_store_dir}" +else + printf "Password store not found!\n" + printf "Create it with mkdir -p %s\n" "$kanako_store_dir" + exit 1 +fi + +if test -f "${kanako_conf_dir}/kanako.conf"; then + . "${kanako_conf_dir}/kanako.conf" +else + printf "Configuration file has not been found!\n" + printf "Copy kanako.conf from the examples directory,\n" + printf "and edit accordingly.\n" + exit 1 +fi + +copy() { + view "$1" | "${kanako_clip_cmd}" +} +edit() { + if [ -f ${1%%.enc}.enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc >${1%%.enc} + "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} >${1%%.enc}.enc + rm "${1%%.enc}" + else + printf "%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc" + fi +} +gen() { + printf "%s\n" $(strings /dev/null | tr -d ' \t\n\r') +} +list() { + if [ -z "$1" ]; then + $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g' + else + $(which tree) "${1:-.}" | sed 's/\.enc//g' + fi +} +new() { + test -d "$1" && usage + + tmpfile="$(mktemp)" + "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" + + mkdir -p "$(dirname "$1")" + ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc + rm ${tmpfile} +} +delete_directory() { + rm -r -I "$1" +} +delete_file() { + rm -i "${1}${2}".enc +} +usage() { + printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0" + printf "The arguments for all switches are relative to \${kanako_store_dir}\n" + printf "which is located at %s\n" "${kanako_store_dir}" + exit 1 +} +view() { + if [ -f "${1%%.enc}".enc ]; then + ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc + elif [ -d "${1:-.}" ]; then + list "${1:-.}" + else + usage + fi +} + +case $1 in +-c) copy $2 ;; +-e) edit $2 ;; +-g) gen $2 ;; +-l) list $2 ;; +-n) new $2 ;; +-R) delete_directory $2 ;; +-r) delete_file $2 ;; +-v) view $2 ;; +*) usage ;; +esac diff --git a/trunk/kanako.conf.example b/trunk/kanako.conf.example new file mode 100644 index 0000000..60d6c3b --- /dev/null +++ b/trunk/kanako.conf.example @@ -0,0 +1,25 @@ +# Configuration file for kanako(1) + +#kanako_clip_cmd="xclip -i" +#kanako_clip_cmd="wl-copy --primary" +#kanako_menu_cmd="dmenu" + +## age +#kanako_encrypt_cmd="age" +#kanako_encrypt_args="-e -R ${kanako_key_dir}/pub.key --armor" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.key" + +## cream +#kanako_encrypt_cmd="cream" +#kanako_encrypt_args="-e -f" +#kanako_decrypt_args="-d" + +## gpg +#kanako_encrypt_cmd="gpg" +#kanako_encrypt_args="-e --recipient ${kanako_key_dir}/pub.key" +#kanako_decrypt_args="-d" + +## salty +#kanako_encrypt_cmd="salty" +#kanako_encrypt_args="-e -r $(cat ${kanako_key_dir}/pub.slt)" +#kanako_decrypt_args="-d -i ${kanako_key_dir}/priv.slt" diff --git a/trunk/kanako.conf.mdoc b/trunk/kanako.conf.mdoc new file mode 100644 index 0000000..66c0bd4 --- /dev/null +++ b/trunk/kanako.conf.mdoc @@ -0,0 +1,30 @@ +.Dd $Mdocdate$ +.Dt KANAKO.CONF 5 +.Os +.Sh NAME +.Nm kanako.conf +.Nd configuration file for +.Xr kanako 1 +.Sh FIELDS +.Bl -tag -width 11n -compact +.It kanako_clip_cmd +Clipboard executable to be +used with the -c switch +.It kanako_decrypt_args +Arguments for decryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_args +Arguments for encryption +passed to kanako_encrypt_cmd +.It kanako_encrypt_cmd +Encryption executable to +be used with the program +.It kanako_menu_cmd +Menu executable to +be used with kanako_menu +.El +.Sh SEE ALSO +.Xr kanako 1 +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja + diff --git a/trunk/kanako.mdoc b/trunk/kanako.mdoc new file mode 100644 index 0000000..72e428b --- /dev/null +++ b/trunk/kanako.mdoc @@ -0,0 +1,61 @@ +.Dd $Mdocdate$ +.Dt KANAKO 1 +.Os +.Sh NAME +.Nm kanako +.Nd the adaptable password manager +.Sh SYNOPSIS +.Nm +.Op Fl ceglnrRv +.Op Ar args +.Sh DESCRIPTION +It is a clean rewrite of +.Xr ayu 1 +supporting multiple backends +and having more add-ons for +use with it. However, it +may be pretty unstable compared +to said tool, but should work +well for its purpose. +.Sh USAGE +.Bl -tag -width 11n -compact +.It -n +Add a new entry +.It -c +Copy an entry's text to the clipboard +.It -e +Edit an entry +.It -g +Generate a random password +.It -l +List all entries +.It -r +Remove single entries, +will prompt for confirmation +.It -R +Remove recursively a directory w/ entries, +will prompt for confirmation +.It -v +View an entry +.Bl +.El +.Sh SEE ALSO +.Xr age 1 +.Xr cream 1 +.Xr gpg 1 +.Xr kanako.conf 5 +.Xr pwgen 1 +.Xr salty 1 +.Rs +.%A Rob Pike +.%T "UNIX Style, or cat -v Considered Harmful" +.%J "USENIX Summer Conference Proceedings" +.%D 1983 +.Re +.Sh AUTHORS +.An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja +.Sh BUGS +Under the Wayland display protocol, +the clipboard subcommand won't work, +due to 'Permission denied'. On X11 +it works just fine.