Changeset 24 in code
- Timestamp:
- May 14, 2025, 2:23:43 AM (4 weeks ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/COPYING
r17 r24 2 2 * ---------------------------------------------------------------------------- 3 3 * "THE BEER-WARE LICENSE" (Revision 42.1): 4 * < yakumo.izuru@chaotic.ninja> wrote this file. As long as you retain this notice you4 * <eternal-servant@yakumo.dev> wrote this file. As long as you retain this notice you 5 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 6 * this stuff is worth it, you can buy me a bottle of sake in return Izuru Yakumo -
trunk/README.md
r22 r24 9 9 10 10 ## Dependencies 11 * Any of the above, depending how you configured it 12 * `tree(1)` for printing a list 13 * `mandoc(1)` for documentation 14 * `rm(1)` with the `-i` and `-I` switches 15 * `strings(1)`, `dd(1)` and `tr(1)` for generating passwords 11 * [dd(1)](https://man.netbsd.org/dd.1) 12 * [oathtool(1)](https://www.nongnu.org/oath-toolkit/) 13 * [rm(1)](https://man.netbsd.org/rm.1) 14 * [strings(1)](https://man.netbsd.org/strings.1) 15 * [tr(1)](https://man.netbsd.org/tr.1) 16 * [tree(1)](https://github.com/Old-Man-Programmer/tree) 16 17 17 18 ## Add-ons … … 20 21 quick graphical front-end for kanako, works with either of `dmenu(1)` 21 22 or `bemenu(1)`, useful for copying passwords to clipboard. 22 23 ### kanako-totp24 time-based one time password addon for kanako, requires `oathtool(1)`25 from oath-toolkit.26 23 27 24 ## License -
trunk/kanako
r23 r24 1 1 #!/bin/sh 2 # $ TheSupernovaDuo: kanako,v 2.1 2023/10/25 01:50:28yakumo_izuru Exp $2 # $YakumoLabs: kanako,v 2.2 2025/05/14 02:07:06 yakumo_izuru Exp $ 3 3 4 readonlykanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}"5 readonlykanako_key_dir="${kanako_key_dir:-$HOME/.kanako}"6 readonlykanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}"4 kanako_conf_dir="${kanako_conf_dir:-$HOME/.config/kanako}" 5 kanako_key_dir="${kanako_key_dir:-$HOME/.kanako}" 6 kanako_store_dir="${kanako_store_dir:-$HOME/.kanako-store}" 7 7 8 if test -d "${kanako_store_dir}"; then 9 cd "${kanako_store_dir}" 10 else 11 printf "Password store not found!\n" 12 printf "Create it with mkdir -p %s\n" "$kanako_store_dir" 13 exit 1 14 fi 8 _die() { 9 printf "\033[1;31m%s\033[0m\n" "$*" >&2 10 exit 1 11 } 12 _warn() { 13 printf "\033[1;35m%s\033[0m\n" "$*" 14 } 15 15 16 if test -f "${kanako_conf_dir}/kanako.conf"; then 17 . "${kanako_conf_dir}/kanako.conf" 18 else 19 printf "Configuration file has not been found!\n" 20 printf "Copy kanako.conf from the examples directory,\n" 21 printf "and edit accordingly.\n" 22 exit 1 23 fi 16 [ -d "${kanako_store_dir}" ] && cd "${kanako_store_dir}" || _die "Password store not found" 17 [ -f "${kanako_conf_dir}/kanako.conf" ] && . "${kanako_conf_dir}/kanako.conf" || _die "Configuration file not found" 24 18 25 19 copy() { … … 27 21 } 28 22 edit() { 29 30 31 32 33 34 35 printf"%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc"36 23 if [ -f ${1%%.enc}.enc ]; then 24 ${kanako_encrypt_cmd} ${kanako_decrypt_args} ${1%%.enc}.enc >${1%%.enc} 25 "${EDITOR:-${EDITOR:-vi}}" "${1%%.enc}" 26 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${1%%.enc} >${1%%.enc}.enc 27 rm "${1%%.enc}" 28 else 29 _warn "%s does not exist, maybe there was a typo on your end?\n" "${1%%.enc}.enc" 30 fi 37 31 } 38 32 gen() { 39 33 printf "%s\n" $(strings </dev/urandom | dd bs=1 count="${1:-30}" 2>/dev/null | tr -d ' \t\n\r') 40 34 } 41 35 list() { 42 if [ -z "$1" ]; then 43 $(which tree) "${kanako_store_dir}/" | sed 's/\.enc//g' 44 else 45 $(which tree) "${1:-.}" | sed 's/\.enc//g' 46 fi 36 if [ -z "$(command -v tree)" ]; then 37 _die "Required dependency 'tree' not found" 38 39 fi 40 if [ -z "$1" ]; then 41 tree "${kanako_store_dir}/" | sed 's/\.enc//g' 42 else 43 tree "${1:-.}" | sed 's/\.enc//g' 44 fi 47 45 } 48 46 new() { 49 test -d "$1" && usage 47 [ -d "$1" ] && usage 48 tmpfile="$(mktemp)" 49 "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" 50 mkdir -p "$(dirname "$1")" 51 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc 52 rm ${tmpfile} 53 } 54 otp() { 55 if [ -z "$(command -v oathtool)" ]; then 56 _die "Required dependency 'oathtool' not found" 50 57 51 tmpfile="$(mktemp)" 52 "${EDITOR:-${EDITOR:-vi}}" "${tmpfile}" 53 54 mkdir -p "$(dirname "$1")" 55 ${kanako_encrypt_cmd} ${kanako_encrypt_args} ${tmpfile} >${1%%.enc}.enc 56 rm ${tmpfile} 58 fi 59 totp_seed=$(view "$1" | grep 'totp: ' | head -n1 | cut -d' ' -f2) 60 if ! [ -z ${totp_seed} ]; then 61 oathtool --totp -b ${totp_seed} 62 fi 57 63 } 58 64 delete_directory() { 59 rm -r -I"$1"65 rm -r -i "$1" 60 66 } 61 67 delete_file() { 62 68 rm -i "${1}${2}".enc 63 69 } 64 70 usage() { 65 66 67 68 exit 1 71 printf "Usage: %s [-c|-e|-g|-l|-n|-R|-r|-v [file or directory]]\n" "$0" 72 printf "The arguments for all switches are relative to \${kanako_store_dir}\n" 73 printf "which is located at %s\n" "${kanako_store_dir}" 74 exit 69 75 } 70 76 view() { 71 72 73 74 75 76 77 77 if [ -f "${1%%.enc}".enc ]; then 78 ${kanako_encrypt_cmd} ${kanako_decrypt_args} "${1%%.enc}".enc 79 elif [ -d "${1:-.}" ]; then 80 list "${1:-.}" 81 else 82 usage 83 fi 78 84 } 79 85 80 86 case $1 in 81 -c) copy $2 ;; 82 -e) edit $2 ;; 83 -g) gen $2 ;; 84 -l) list $2 ;; 85 -n) new $2 ;; 86 -R) delete_directory $2 ;; 87 -r) delete_file $2 ;; 88 -v) view $2 ;; 89 *) usage ;; 87 -c) copy $2 ;; 88 -e) edit $2 ;; 89 -g) gen $2 ;; 90 -l) list $2 ;; 91 -n) new $2 ;; 92 -o) otp $2 ;; 93 -R) delete_directory $2 ;; 94 -r) delete_file $2 ;; 95 -v) view $2 ;; 96 *) usage ;; 90 97 esac -
trunk/kanako.conf.mdoc
r18 r24 1 .Dd $Mdocdate$1 .Dd May 14, 2025 2 2 .Dt KANAKO.CONF 5 3 3 .Os 4 4 .Sh NAME 5 5 .Nm kanako.conf 6 .Nd configuration file for 7 .Xr kanako 1 8 .Sh FIELDS 6 .Nd configuration file for kanako 7 .Sh CONFIGURATION FIELDS 9 8 .Bl -tag -width 11n -compact 10 9 .It kanako_clip_cmd … … 27 26 .Xr kanako 1 28 27 .Sh AUTHORS 29 .An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja 30 28 .An Izuru Yakumo Aq Mt eternal-servant@yakumo.dev -
trunk/kanako.mdoc
r23 r24 1 .Dd $Mdocdate$1 .Dd May 14, 2025 2 2 .Dt KANAKO 1 3 3 .Os … … 7 7 .Sh SYNOPSIS 8 8 .Nm 9 .Op Fl cegln rRv9 .Op Fl ceglnorRv 10 10 .Op Ar args 11 11 .Sh DESCRIPTION … … 14 14 supporting multiple backends 15 15 and having more add-ons for 16 use with it. However, it 17 may be pretty unstable compared 18 to said tool, but should work 19 well for its purpose. 16 use with it. 17 However, it may be pretty unstable compared 18 to said tool, but should work well for its purpose. 20 19 .Sh USAGE 21 20 .Bl -tag -width 11n -compact … … 30 29 .It -l 31 30 List all entries 31 .It -o 32 Obtain a one time password 32 33 .It -r 33 34 Remove single entries, … … 38 39 .It -v 39 40 View an entry 40 .Bl41 41 .El 42 42 .Sh SEE ALSO 43 .Xr age 1 44 .Xr cream 1 45 .Xr gpg 1 43 .Xr age 1 , 44 .Xr cream 1 , 45 .Xr gpg 1 , 46 .Xr oathtool 1 , 47 .Xr pwgen 1 , 48 .Xr salty 1 , 46 49 .Xr kanako.conf 5 47 .Xr pwgen 148 .Xr salty 149 50 .Rs 50 51 .%A Rob Pike … … 54 55 .Re 55 56 .Sh AUTHORS 56 .An Izuru Yakumo Aq Mt yakumo.izuru@chaotic.ninja 57 .Sh BUGS 58 Under the Wayland display protocol, 59 the clipboard subcommand won't work, 60 due to 'Permission denied'. On X11 61 it works just fine. 57 .An Izuru Yakumo Aq Mt eternal-servant@yakumo.dev
Note:
See TracChangeset
for help on using the changeset viewer.