kwalletcli/BSDmakefile010064400000000000000000000051261155015165600141330ustar00rootwheel# $MirOS: contrib/hosted/tg/code/kwalletcli/BSDmakefile,v 1.14 2011/04/09 21:45:58 tg Exp $ #- # Copyright © 2009, 2010, 2011 # Thorsten Glaser # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un‐ # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person’s immediate fault when using the work as intended. PROG= kwalletcli SRCS= charconv.c main.c SCRIPTS= kwalletaskpass kwalletcli_getpin pinentry-kwallet MAN= ${PROG}.1 ${SCRIPTS:=.1} BINDIR?= ${BSD_PREFIX}/bin KDE_VER?= 3 .if ${KDE_VER} == 3 KDE_INCS?= -I/usr/include/qt3 -I/usr/include/kde SRCS+= kwif3.cc LDADD+= -lkwalletclient -lkdecore -lqt-mt .elif ${KDE_VER} == 4 KDE_INCS?= -I/usr/include/qt4 -I/usr/include/qt4/QtCore SRCS+= kwif4.cc LDADD+= -lkdeui -lkdecore -lQtCore .else . error unknown KDE_VER; valid: 3 4 .endif CPPFLAGS+= ${KDE_INCS} -D_GNU_SOURCE afterinstall: .for _i in ${SCRIPTS} ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ ${.CURDIR}/${_i} ${DESTDIR}${BINDIR}/ .endfor .include # HTML manpage generation code (currently assumes the basenames # of all manpages to be generated are unique, unlike man(1, 7). HTMANMODE?= local # one of local or sectioned .for _p in ${MANALL} HTMANS+= ${_p:R}.htm ${_p:R}.htm: ${_p} @(. ${BSDSRCDIR}/scripts/roff2htm; \ do_conversion_verbose ${_p:R} ${_p:E:S/cat//} ${_p} $@) .endfor .for _s _t in ${MLINKS} HTMANS+= ${_t:R}.htm ${_t:R}.htm: ${_s:R}.htm @print -ru2 ${_t:R:Q}.htm ← ${_s:R:Q}.htm .if ${HTMANMODE:L:Mlocal} @(print '//s##, ${_t:R}(${_t:E})&#'; \ print '/

/s#

#, ${_t:R}(${_t:E})&#'; \ print wq) | ed -s ${_s:R}.htm .else @(print '//s##, ${_t:R}(${_t:E})&#'; \ print '/

/s#

#, ${_t:R}(${_t:E})&#'; \ print wq) | ed -s ${_s:R}.htm .endif @ln -f ${.ALLSRC} $@ .endfor CLEANFILES+= ${HTMANS} htman: .PHONY ${HTMANS} kwalletcli/GNUmakefile010064400000000000000000000043551155015156000141510ustar00rootwheel# $MirOS: contrib/hosted/tg/code/kwalletcli/GNUmakefile,v 1.11 2011/04/09 21:44:56 tg Exp $ #- # Copyright © 2009, 2011 # Thorsten Glaser # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un‐ # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person’s immediate fault when using the work as intended. SCRIPTS= kwalletaskpass kwalletcli_getpin pinentry-kwallet BINDIR?= /usr/bin MANDIR?= /usr/share/man/man BINMODE?= 755 MANMODE?= 444 INSTALL_STRIP?= -s PROG= kwalletcli SRCS= charconv.c main.c OBJS= charconv.o main.o KDE_VER:= 3 ifeq (${KDE_VER},3) KDE_INCS?= -I/usr/include/qt3 -I/usr/include/kde SRCS+= kwif3.cc OBJS+= kwif3.o LDADD+= -lkwalletclient -lkdecore -lqt-mt else ifeq (${KDE_VER},4) KDE_INCS?= -I/usr/include/qt4 -I/usr/include/qt4/QtCore SRCS+= kwif4.cc OBJS+= kwif4.o LDADD+= -lkdeui -lkdecore -lQtCore else $(error unknown KDE_VER) endif endif CPPFLAGS+= ${KDE_INCS} -D_GNU_SOURCE CC?= gcc CXX?= g++ CFLAGS?= -O2 CXXFLAGS?= ${CFLAGS} all: ${PROG} install: install -c ${INSTALL_STRIP} -m ${BINMODE} \ ${PROG} ${DESTDIR}${BINDIR}/ install -c -m ${BINMODE} \ ${SCRIPTS} ${DESTDIR}${BINDIR}/ for f in ${PROG} ${SCRIPTS}; do \ install -c -m ${MANMODE} $$f.1 ${DESTDIR}${MANDIR}1/; \ done uninstall: for f in ${PROG} ${SCRIPTS}; do \ rm -f ${DESTDIR}${BINDIR}/$$f ${DESTDIR}${MANDIR}1/$$f.1; \ done clean: -rm -f ${OBJS} ${PROG} ${PROG}: ${OBJS} ${DPADD} ${CXX} ${LDFLAGS} -o $@ ${OBJS} ${LDADD} .c.o: ${CC} ${CPPFLAGS} ${CFLAGS} -c -o $@ $< .cc.o: ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $< kwalletcli/LICENCE010064400000000000000000000072201153354472300130660ustar00rootwheelkwalletcli – Command-Line Interface for the KDE Wallet ────────────────────────────────────────────────────── kwalletcli is “OSI Certified Open Source Software” and distributed under the following Terms and Conditions: kwalletcli is covered by The MirOS Licence: Copyright © 2009, 2010, 2011 Thorsten Glaser KDE 4 bindings Copyright © 2009 Thomas Fischer Provided that these terms and disclaimer and all copyright notices are retained or reproduced in an accompanying document, permission is granted to deal in this work without restriction, including un‐ limited rights to use, publicly perform, distribute, sell, modify, merge, give away, or sublicence. This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to the utmost extent permitted by applicable law, neither express nor implied; without malicious intent or gross negligence. In no event may a licensor, author or contributor be held liable for indirect, direct, other damage, loss, or other issues arising in any way out of dealing in the work, even if advised of the possibility of such damage or existence of a defect, except proven that it results out of said person’s immediate fault when using the work as intended. The icon/logo for kwalletcli is a derivate of “The ‘m’” which is a part of the logo for The MirBSD Korn Shell and covered by the same licence as mksh itself (The MirOS Licence, see above): Copyright © 2008, 2009 Lukas U. Copyright © 2008 Thorsten „mirabilos“ Glaser It is also a derivate of The Oxygen Icon Theme by : Copyright © 2007 David Vignoni Copyright © 2007 Johann Ollivier Lapeyre Copyright © 2007 Kenneth Wimer Copyright © 2007 Nuno Fernades Pinheiro Copyright © 2007 Riccardo Iaconelli Copyright © 2007 David J. Miller and others (Jakob Petsovits , etc.) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. KDE Oxygen theme icons is a special kind of software library, it is an artwork library, it's elements can be used in a Graphical User Interface, or GUI. Source code, for this library means: where they exist, SVG; otherwise, if applicable, the multi-layered formats XCF or PSD, or otherwise PNG. The LGPL in some sections obliges you to make the files carry notices. With images this is in some cases impossible or hardly useful. With this library a notice is placed at a prominent place in the directory containing the elements. You may follow this practice. The exception in section 5 of the GNU Lesser General Public License covers the use of elements of this art library in a GUI. ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ ̲ $MirOS: contrib/hosted/tg/code/kwalletcli/LICENCE,v 1.4 2011/03/02 22:50:35 tg Exp $ kwalletcli/charconv.c010064400000000000000000000056151155015734500140550ustar00rootwheel/*- * Copyright © 2011 * Thorsten Glaser * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work without restriction, including un‐ * limited rights to use, publicly perform, distribute, sell, modify, * merge, give away, or sublicence. * * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to * the utmost extent permitted by applicable law, neither express nor * implied; without malicious intent or gross negligence. In no event * may a licensor, author or contributor be held liable for indirect, * direct, other damage, loss, or other issues arising in any way out * of dealing in the work, even if advised of the possibility of such * damage or existence of a defect, except proven that it results out * of said person’s immediate fault when using the work as intended. */ #include #include "kwalletcli.h" const char __rcsid_charconv_c[] = "$MirOS: contrib/hosted/tg/code/kwalletcli/charconv.c,v 1.3 2011/04/09 22:33:49 tg Exp $"; /* From MirOS: contrib/hosted/tg/code/any2utf8/wide.c,v 1.1 2009/08/02 17:12:07 tg Exp */ size_t utf_32to8(char *dst, unsigned int wc) { unsigned char *cp = (unsigned char *)dst; unsigned int count; if (wc > 0x7FFFFFFF) /* beyond UTF-8 */ abort(); if (wc < 0x80) { count = 0; *cp++ = wc; } else if (wc < 0x0800) { count = 1; *cp++ = (wc >> 6) | 0xC0; } else if (wc < 0x00010000) { count = 2; *cp++ = (wc >> 12) | 0xE0; } else if (wc < 0x00200000) { count = 3; *cp++ = (wc >> 18) | 0xF0; } else if (wc < 0x04000000) { count = 4; *cp++ = (wc >> 24) | 0xFC; } else { count = 5; *cp++ = (wc >> 30) | 0xFE; } while (count) *cp++ = ((wc >> (6 * --count)) & 0x3F) | 0x80; return ((size_t)((char *)cp - dst)); } size_t utf_8to32(const char *src, unsigned int *dst) { const unsigned char *s = (const unsigned char *)src; unsigned int wc, count = 0; unsigned char c; wc = *s++; if (wc < 0xC2 || wc >= 0xFE) { if (wc >= 0x80) return (UTFCONV_ERROR); } else if (wc < 0xE0) { count = 1; /* one byte follows */ wc = (wc & 0x1F) << 6; } else if (wc < 0xF0) { count = 2; /* two bytes follow */ wc = (wc & 0x0F) << 12; } else if (wc < 0xF8) { count = 3; /* three bytes follow */ wc = (wc & 0x07) << 18; } else if (wc < 0xFC) { count = 4; /* four bytes follow */ wc = (wc & 0x03) << 24; } else /* (wc < 0xFE) */ { count = 5; /* five bytes follow */ wc = (wc & 0x01) << 30; } while (count) { if (((c = *s++) & 0xC0) != 0x80) return (UTFCONV_ERROR); wc |= (c & 0x3F) << (6 * --count); if (!count) break; if (wc < (1U << (5 * count + 6))) return (UTFCONV_ERROR); } if (wc == 0xFFFE || wc == 0xFFFF || wc > 0x7FFFFFFF || (wc >= 0xD800 && wc <= 0xDFFF)) return (UTFCONV_ERROR); *dst = wc; return ((size_t)((const char *)s - src)); } kwalletcli/kwalletaskpass010064400000000000000000000044321155013772300150540ustar00rootwheel#!/usr/bin/env mksh # $MirOS: contrib/hosted/tg/code/kwalletcli/kwalletaskpass,v 1.6 2011/04/09 20:21:15 tg Exp $ #- # Copyright © 2009, 2010, 2011 # Thorsten Glaser # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un‐ # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person’s immediate fault when using the work as intended. unset LC_ALL LANGUAGE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES \ LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION export LANG=C LC_CTYPE=en_US.UTF-8 set -U if (( $# != 1 )); then print -u2 wrong number of arguments exit 127 fi rv=1 trywallet=0 [[ -n $DISPLAY && $1 = 'Enter passphrase for '* ]] && trywallet=1 if (( trywallet )); then blist=$(kwalletcli -q -f kwalletaskpass-blacklist -e "${1#Enter }") [[ $blist = yes* ]] && trywallet=0 fi if (( trywallet )); then pw=$(kwalletcli -q -f kwalletaskpass -e "${1#Enter }") rv=$? fi # whitelist of known binary queries barg= [[ $1 = 'Allow shared connection to '* || \ $1 = 'Terminate shared connection to '* || \ $1 = 'Open '*' on '*'?' || \ $1 = 'Allow forward to '* || \ $1 = 'Allow use of key '* ]] && barg=-b if (( rv )); then pw=$(kwalletcli_getpin -q $barg -t "$1") rv=$? if (( rv == 0 && trywallet )); then q=${1#Enter } q=${q%%:*([ ])} if kwalletcli_getpin -qb -t "Store $q in the KDE Wallet?"; then kwalletcli -q -f kwalletaskpass \ -e "${1#Enter }" -p "$pw" else kwalletcli -q -f kwalletaskpass-blacklist \ -e "${1#Enter }" -p yes fi fi fi case $rv { (0) print -r -- "$pw" exit 0 ;; (1) exit 1 ;; (*) exit 3 ;; } kwalletcli/kwalletaskpass.1010064400000000000000000000076521155013772300152220ustar00rootwheel.\" $MirOS: contrib/hosted/tg/code/kwalletcli/kwalletaskpass.1,v 1.7 2011/04/09 20:21:15 tg Exp $ .\"- .\" Copyright © 2009, 2010, 2011 .\" Thorsten Glaser .\" .\" Provided that these terms and disclaimer and all copyright notices .\" are retained or reproduced in an accompanying document, permission .\" is granted to deal in this work without restriction, including un‐ .\" limited rights to use, publicly perform, distribute, sell, modify, .\" merge, give away, or sublicence. .\" .\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to .\" the utmost extent permitted by applicable law, neither express nor .\" implied; without malicious intent or gross negligence. In no event .\" may a licensor, author or contributor be held liable for indirect, .\" direct, other damage, loss, or other issues arising in any way out .\" of dealing in the work, even if advised of the possibility of such .\" damage or existence of a defect, except proven that it results out .\" of said person’s immediate fault when using the work as intended. .\"- .\" Try to make GNU groff and AT&T nroff more compatible .\" * ` generates ‘ in gnroff, so use \` .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq .\" * - generates ‐ in gnroff, \- generates −, so .tr it to - .\" thus use - for hyphens and \- for minus signs and option dashes .\" * ~ is size-reduced and placed atop in groff, so use \*(TI .\" * ^ is size-reduced and placed atop in groff, so use \*(ha .\" * \(en does not work in nroff, so use \*(en .ie \n(.g \{\ . ds aq \(aq . ds TI \(ti . ds ha \(ha . ds en \(en .\} .el \{\ . ds aq ' . ds TI ~ . ds ha ^ . ds en \(em .\} .\" Implement .Dd with the Mdocdate RCS keyword .rn Dd xD .de Dd .ie \\$1$Mdocdate: \{\ . xD \\$2 \\$3, \\$4 .\} .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .. .\"- .Dd $Mdocdate: April 9 2011 $ .Dt KWALLETASKPASS 1 .Os .Sh NAME .Nm kwalletaskpass .Nd kwallet-based pass-phrase dialog for use with OpenSSH .Sh SYNOPSIS .Nm .Op Ar options .Ar label .Sh DESCRIPTION .Nm is a kwallet- and pinentry-based pass-phrase dialog for use with OpenSSH. It is intended to be called from the .Xr ssh\-add 1 programme and not invoked directly. .Pp If a passphrase is requested, .Nm works by first looking up the passphrase in the KWallet by means of .Xr kwalletcli 1 ; using it if found, then calling .Xr kwalletcli_getpin 1 to interactively retrieve an answer from the user via .Nm pinentry otherwise. If the user specifies a passphrase, .Xr kwalletcli_getpin 1 is run again to ask if the passphrase should be stored in the KWallet. Negative answers will be stored in the KWallet to avoid being asked each time. .Nm uses the KWallet folders .Ic kwalletaskpass and .Ic kwalletaskpass\-blacklist with matching entry names. .Pp If anything other than a key passphrase is requested, it is merely relayed to .Xr kwalletcli_getpin 1 . Some requests are known to require a boolean answer and are relayed using the boolean query flag; all others are relayed using a PIN query. .Xr ssh 1 accepts either the literal word .Dq yes .Pq case-insensitively matched or an empty answer (both only when using the OK button) as confirmation. .Pp There are currently no options. .Sh RETURN VALUES .Nm exits 0 on success, 1 if the user cancelled the dialogue, or \*(Gt1 if an error occured. .Sh ENVIRONMENT .Bl -tag -width PINENTRY .It Ev DISPLAY The X11 display to use for child processes. If this is unset or empty, .Nm kwalletcli will not be called. .It Ev PINENTRY The .Nm pinentry programme to use. The default is inherited from .Xr kwalletcli_getpin 1 . .El .Sh SEE ALSO .Xr kwalletcli 1 , .Xr kwalletcli_getpin 1 , .Xr ssh\-add 1 , .Xr ssh\-askpass 1 .Sh AUTHORS .Nm was written by .An Thorsten Glaser Aq tg@mirbsd.org mostly for tarent GmbH. The idea came from an .Pa askpass.C file found somewhere on the 'net, with no author information. Since it was licenced less freely, this is a rewrite from scratch; modular and with more functionality, too. kwalletcli/kwalletcli.1010064400000000000000000000121551155015156000143110ustar00rootwheel.\" $MirOS: contrib/hosted/tg/code/kwalletcli/kwalletcli.1,v 1.14 2011/04/09 21:44:56 tg Exp $ .\"- .\" Copyright © 2009, 2010, 2011 .\" Thorsten Glaser .\" .\" Provided that these terms and disclaimer and all copyright notices .\" are retained or reproduced in an accompanying document, permission .\" is granted to deal in this work without restriction, including un‐ .\" limited rights to use, publicly perform, distribute, sell, modify, .\" merge, give away, or sublicence. .\" .\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to .\" the utmost extent permitted by applicable law, neither express nor .\" implied; without malicious intent or gross negligence. In no event .\" may a licensor, author or contributor be held liable for indirect, .\" direct, other damage, loss, or other issues arising in any way out .\" of dealing in the work, even if advised of the possibility of such .\" damage or existence of a defect, except proven that it results out .\" of said person’s immediate fault when using the work as intended. .\"- .\" Try to make GNU groff and AT&T nroff more compatible .\" * ` generates ‘ in gnroff, so use \` .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq .\" * - generates ‐ in gnroff, \- generates −, so .tr it to - .\" thus use - for hyphens and \- for minus signs and option dashes .\" * ~ is size-reduced and placed atop in groff, so use \*(TI .\" * ^ is size-reduced and placed atop in groff, so use \*(ha .\" * \(en does not work in nroff, so use \*(en .ie \n(.g \{\ . ds aq \(aq . ds TI \(ti . ds ha \(ha . ds en \(en .\} .el \{\ . ds aq ' . ds TI ~ . ds ha ^ . ds en \(em .\} .\" Implement .Dd with the Mdocdate RCS keyword .rn Dd xD .de Dd .ie \\$1$Mdocdate: \{\ . xD \\$2 \\$3, \\$4 .\} .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .. .\"- .Dd $Mdocdate: April 9 2011 $ .Dt KWALLETCLI 1 .Os .Sh NAME .Nm kwalletcli .Nd command line interface to the KDE Wallet .Sh SYNOPSIS .Nm .Op Fl q .Fl hV .Nm .Op Fl q .Fl f Ar folder .Fl e Ar entry .Op Fl P | p Ar password .Sh DESCRIPTION The .Nm utility is a command line interface to KWallet. It will only work if KDE is running (DCOP) and reachable (via X11). .Nm can be used to get password entries from the Wallet, or to write them there. .Pp The options are as follows: .Bl -tag -width xPxpassword .It Fl e Ar entry Define the key .Pq Ar entry to use when accessing the Wallet. Mandatory. .It Fl f Ar folder Set the .Ar folder to use when accessing the Wallet. Mandatory. .It Fl h Display the usage. .It Fl P Read the password to write from standard input. Currently limited to 65535 octets. .It Fl p Ar password Write .Ar password into the designated location in the Wallet. .It Fl q Be more quiet. In combination with .Fl V , do not display anything. .It Fl V Display the .Nm version information. .El .Pp Default mode of operation, that is, unless .Fl P or .Fl p are used, is to read the password from the Wallet and print it to standard output as-is, without any trailing newline. .Pp All input and output is assumed to be in UTF-8. The password string (whether read from standard input or command line) is now converted from .Dq possibly UTF-8 but binary transparent to standards-conformant UTF-8 for the Qt side, and back upon reading out. .Sh RETURN VALUES The .Nm utility exits 0 on success or \*(Gt0 if an error occurred: .Bl -tag -width xxx .It 1 The entry specified cannot be found (read access). .It 2 The usage was shown. .It 3 The Wallet could not be opened. May be a missing DCOP connection. Perhaps .Ev DISPLAY is not set. .It 4 The folder specified cannot be found (read access). .It 5 The folder specified cannot be opened. .It 6 The value to the key specified could not be retrieved. .It 8 An error occured trying to write the value. .El .Pp The exit codes 1 and 4, on reading, are not fatal; they merely indicate that the folder or entry specified does not exist. The other errors are fatal and may be used to indicate the user that the KWallet should not be used any more during the current session. .Sh ENVIRONMENT .Bl -tag -width DISPLAY .It Ev DISPLAY The X11 display to use for communicating with the KDE Wallet. .El .Sh SEE ALSO .Xr kwalletcli_getpin 1 .Sh AUTHORS .Nm was written by .An Thorsten Glaser Aq tg@mirbsd.org mostly for tarent GmbH. .Sh CAVEATS Do not use .Fl p Ar password to store it, unless you absolutely must. It is a security risk, because the command line invocation is public information in a normal Unix environment. Use .Fl P instead and provide the .Ar password on standard input. .Pp Beware of trailing newlines, especially outside of .Xr mksh 1 scripts! .Sh BUGS If .Ev DISPLAY is not set, not valid, or .Nm kdeinit or .Nm kdeinit4 cannot start for other reasons, .Nm may not recover gracefully. In KDE 4 versions, this may even result in a Segmentation fault. The author does not know of a way to catch this early; patches are welcome. .Pp There is no way (yet) to set a wallet other than the default wallet. While this is a possible enhancement to the .Nm CLI, there is no feasible way to expose this functionality to the various front-ends, such as .Xr pinentry\-kwallet 1 , anyway, so the priority of fixing this is low. kwalletcli/kwalletcli.h010064400000000000000000000040671155015156000144030ustar00rootwheel/*- * Copyright (c) 2009, 2011 * Thorsten Glaser * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work without restriction, including un- * limited rights to use, publicly perform, distribute, sell, modify, * merge, give away, or sublicence. * * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to * the utmost extent permitted by applicable law, neither express nor * implied; without malicious intent or gross negligence. In no event * may a licensor, author or contributor be held liable for indirect, * direct, other damage, loss, or other issues arising in any way out * of dealing in the work, even if advised of the possibility of such * damage or existence of a defect, except proven that it results out * of said person's immediate fault when using the work as intended. */ #ifndef KWALLETCLI_H #define KWALLETCLI_H "$MirOS: contrib/hosted/tg/code/kwalletcli/kwalletcli.h,v 1.6 2011/04/09 21:44:56 tg Exp $" #if defined(HAVE_ATTRIBUTE_BOUNDED) && HAVE_ATTRIBUTE_BOUNDED #define MKSH_A_BOUNDED(x,y,z) __attribute__((__bounded__ (x, y, z))) #else #define MKSH_A_BOUNDED(x,y,z) /* nothing */ #endif #ifdef __cplusplus extern "C" { #endif /* exported by kwif*.cc */ extern const char __rcsid_kwif[]; /* this function MUST NOT fail if stderr is closed */ int kw_io(const char *, const char *, const char **, const char *); /* these are (except abort/usage and OK) the same as exit codes */ #define KWE_OK_GET 0 #define KWE_NOENTRY 1 #define KWE_ABORT 2 /* errorlevel 2 == usage */ #define KWE_NOWALLET 3 #define KWE_NOFOLDER 4 #define KWE_ERRFOLDER 5 #define KWE_ERRENTRY 6 #define KWE_OK_SET 7 /* uses errorlevel 0 */ #define KWE_ERR_SET 8 /* exported by charconv.c */ /* recode strings between UTF-8 and UCS-32 */ size_t utf_8to32(const char *, unsigned int *); size_t utf_32to8(char *, unsigned int) MKSH_A_BOUNDED(__minbytes__, 1, 6); #define UTFCONV_ERROR ((size_t)31) #ifdef __cplusplus } #endif #endif kwalletcli/kwalletcli.svg010064400000000000000000002073731124325573000147630ustar00rootwheel Logo for kwalletcli – Command-Line Interface for the KDE Wallet Based on an experimental draft of a new MirOS logo (CC-BY-IDC), Utilising Gentium Book Basic (Bold Italic), and The Oxygen Icon Theme by <kde-artists@kde.org> $MirOS: contrib/hosted/tg/code/kwalletcli/kwalletcli.svg,v 1.3 2009/08/20 14:20:48 tg Exp $ Copyright © 2008, 2009 Lukas U. <smultron@midnightbsd.org> Copyright © 2008 Thorsten „mirabilos“ Glaser <tg@mirbsd.org> This artwork is copyrighted material – refer to the 「LICENCE」 file in the kwalletcli source or binary distribution for terms. image/svg+xml kwalletcli/kwalletcli128.png010064400000000000000000000443111124325727500152000ustar00rootwheelPNG  IHDR~^zTXtCopyrightxHT020Q020THT)N,VSHKQ/*.ISpI,N-VЀ7WHTNIM,*,.)vNI/Jvx$cH&IDATxiu7׎ }# .IQG5=Ӟv;CpòE%o[+%ѤHqHKP}yk˼w>|^=щHd|2{9:O<4hAkCk !ojB @h+Rvu'ߋz_}L"ow{YZhUJZGk?_ЭF~{owm(-(86Sq,lq\&:\Bul\Ʋ$"):''F=?bKxo !VݶXxCD2Q2P( (E*Қ0F)E* Q|RRIh"FQٰ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US;_ C^9y.0 j}-@ y{\,$ ?yeP.u4qg(8`8>$B@p0ĚsΫIENDB`kwalletcli/kwalletcli32.png010064400000000000000000000046131124325727500151130ustar00rootwheelPNG  IHDR Vό^zTXtCopyrightxHT020Q020THT)N,VSHKQ/*.ISpI,N-VЀ7WHTNIM,*,.)vNI/Jvx$cIDATHǽYl\{l/qIb;! I@)PEP /UJh>UR!EЅ$,Ğ~sLLxtG37WR"E[JDJAˣ]\v*\G(n1wnz<}dzγn-lzt )U[,cbI$ cbi"PmU;l)H\Gb+c` }`#i/x9, icxj)tcEGH:K-v}TBup"*W|kOw?e{?47˦[(u@ If@#04 L@K-փ\˻fxKkPJjR! F6!݉C m7mG-yd1ѸkaHx2]>%JIhA\=Z+q@ҤZYZՒn lX?td\MdS=Z[&.U 3S,ֶrhXk1&Ėd"A*t%I%R M#tlxƥ:(,n\F$?ˎVϺl>:2rD8ෳP Z h6x>(=8U4Wr'+!-n^Vݙ$b|>>?|j|>Pf85:DA+fLcřkWdFEaw1,[N]>9V>u/.Uͨ6=>1iœqX_vpMuM#&b>3~X_x;0 ԡ~hbV)_ݓHg!n=Dw#Gˇ'ԅ?- ^~ ] z|FGq2ՑKG/,R$Ա<2|;דWj~yk@.Y]`nW.tx@p?<]I:uJIENDB`kwalletcli/kwalletcli64.png010064400000000000000000000152471124325727500151250ustar00rootwheelPNG  IHDR@?P^zTXtCopyrightxHT020Q020THT)N,VSHKQ/*.ISpI,N-VЀ7WHTNIM,*,.)vNI/Jvx$cIDAThݛieuUu^g_8Cr(REH 6aX-僒 1"I|H$bA#cr5VZ$ʢ4Z!gzfzz^_/o֒{C$NQ}nC>G|j5C {[ÁK]֡!=:56=잱$ՆJ#wpp" ZOx[A_]coW';vw<Ï2gϞ|I.F jRsP|yOWDzk~^:a#:ctӱQSTeU@)0BJ*G3HmP Aj2-8(Ia80w'iD#c%J"b@H_ pg"e|B {r9Rf==W5&S]♳e[y'#iO2V3>ZdTO 聼!@dC碿Xd&Yc!Yx`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/@R:ę ZY6:2K6s u7pN+|N{p?r.e/%3a Y.UCaz#k4m50VJ8gKBp4hcɇ>H!Ɂen?<$mN.򣗮+K큽<}!R vkR!vTe&Ƥ^RSUmG EB ݫ2ϸ'R^ TI%ɅAmLdi+%qUfygVx<ػ܏/5OX^ē=^ppHf$Ep΢ n/1C_hG7tcK[%JQbKX"=azbZ'V]11>.79bOGƪ9xN(1SK^^о*żhu{B'KZ[^:y8|`J12%c8+uIUtlj"6:VeWյ$zKೲ1c ?92R]SaiF JJfZWxidK@/ ET%|<yy*C)J[?;Go>(B01άM/~%V&rRfeP'P~RI.Y+m\rlꙩ6gm''^0Ɋw$,n8z_*\}_%}A(BOߙef2;9w$DzcPE6ur?܋>ԯ^L>\__dkи]vׇ~&Zmxf.91/d\(J} ae0R/VxB4]wMpuWxE@Z\f++g7 ,g,d}WEp8NV(Xb7 \vgVPąJhƥ^:M:Y)8[U,v:0{5uI'GKA8qf&}P Y>urS@ DC;[z 5`#{"th={X__/[S'?);ܙ6AоR-b% A^uĻAZ16;:UggjSz_4}[n$ҺUZÅZ#/4ϕBќ,RI$(M0]oZP̹A|!& :uSkH.+Ϝ^?&*tJ$qk_ءLLD&'9;s65[ ؿ;槎m=3Iea XjuOfꧾbO:7' # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un‐ # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person’s immediate fault when using the work as intended. unset LC_ALL LANGUAGE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY \ LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION [[ -z $LC_CTYPE ]] && LC_CTYPE=en_US.UTF-8 export LANG=C LC_CTYPE LC_MESSAGES GPG_TERM GPG_TTY set -U quiet=0 nl=' ' function die { local rv=$1 shift (( quiet )) || print -u2 -r -- "$@" exit $rv } function checkline { local res print -pr -- "$@" read -p res || die 3 pinentry died [[ $res = OK@(| *) ]] || die 4 "got '$res' for '$*'" } function toutf8 { local intext="$*" outtext='' typeset -i i=0 n=${#intext} typeset -i1 c typeset -Uui16 -Z5 x while (( i < n )); do c=1#${intext:(i++):1} if (( (c & 0xFF80) == 0xEF80 )); then (( c &= 0xFF )) fi if (( c < 32 || c == 1#% || c == 1#_ )); then let x=c outtext=${outtext}%${x#16#} elif (( c > 0x7E && c < 0xA0 )); then outtext=${outtext}� else outtext=${outtext}${c#1#} fi done print -nr -- "$outtext" } function tolat1 { local intext="$*" outtext='' typeset -i i=0 n=${#intext} typeset -i1 c typeset -Uui16 -Z5 x while (( i < n )); do c=1#${intext:(i++):1} (( c = c < 0x80 ? c : (c & 0xFF80) == 0xEF80 ? c : c < 0x0100 ? c | 0xEF00 : 0xEFFF )) outtext=${outtext}${c#1#} done print -nr -- "$outtext" } function usage { print -u2 "Usage:\tkwalletcli_getpin [-q] [-b | -m | -p prompt]" print -u2 "\t[-E | -e errortext] [-N NoBtn] [-t desctext] [-Y YesBtn]" print -u2 "Returns: 0=ok (pw on stdout), 1=cancel, 2+=error" exit 2 } function get_tty { GPG_TTY=$(tty) || GPG_TTY= [[ -n $GPG_TTY ]] || die 5 Please set GPG_TTY yourself } asktext='Hast Du das Paßwort?' askprompt='Code:' askerror='' askbool=0 btnyes= btnno= while getopts 'bEe:hmN:p:qt:Y:' ch; do case $ch { (b) askbool=1 ;; (E) askerror='' ;; (e) askerror=$OPTARG ;; (m) askbool=2 ;; (N) btnno=$OPTARG ;; (p) askprompt=$OPTARG ;; (q) quiet=1 ;; (t) asktext=$OPTARG ;; (Y) btnyes=$OPTARG ;; (*) usage ;; } done shift $((OPTIND - 1)) (( $# )) && usage set -A pe_args if [[ -n $DISPLAY ]]; then pe_args[${#pe_args[*]}]=--display pe_args[${#pe_args[*]}]=$DISPLAY fi [[ -n $PINENTRY ]] || PINENTRY=pinentry if "${PINENTRY%-kwallet}" --version >/dev/null 2>&1; then "${PINENTRY%-kwallet}" "${pe_args[@]}" |& subpid=$? read -p res || die 3 pinentry died [[ $res = OK@(| *) ]] || die 4 "got '$res' for '$*'" got_pe=1 trap "kill $subpid; die 6 caught SIGHUP" 1 trap "kill $subpid; die 6 caught SIGINT" 2 trap "kill $subpid; die 6 caught SIGQUIT" 3 trap "kill $subpid; die 6 caught SIGTRAP" 5 trap "kill $subpid; die 6 caught SIGPIPE" 13 trap "kill $subpid; die 6 caught SIGTERM" 15 else got_pe=0 fi [[ -z $DISPLAY && -z $GPG_TTY ]] && get_tty [[ -z $GPG_TERM ]] && GPG_TERM=${TERM:-vt100} if (( !got_pe )); then thetext= sep= (( askbool )) || if [[ -n $askerror ]]; then thetext="*ERROR*: $(toutf8 "$askerror")" sep=$nl$nl fi if [[ -n $asktext ]]; then thetext=$thetext$sep$(toutf8 "$asktext") sep=$nl$nl fi (( askbool )) || if [[ -n $askprompt ]]; then thetext=$thetext$sep$(toutf8 "$askprompt") fi whence -p xmessage >&- || unset DISPLAY if (( askbool )) && [[ -n $DISPLAY ]]; then buttons=${btnyes:-OK},${btnno:-Cancel} (( askbool == 2 )) && buttons=${btnyes:-OK} LC_ALL=C xmessage -nearmouse -buttons "$buttons" \ -default "${btnyes:-OK}" "$(tolat1 "$thetext")" rc=$? (( rc == 101 )) && exit 0 (( rc == 102 )) && exit 1 die 3 xmessage errored out fi if (( askbool == 2 )); then thetext="$thetext$nl${nl}[OK${btnyes:+=$btnyes}] " elif (( askbool )); then thetext="$thetext$nl${nl}[Y${btnyes:+=$btnyes}|N${btnno:+=$btnno}] " elif [[ -n $askprompt ]]; then thetext="$thetext " else thetext=$thetext$nl fi trap 'stty echo; exit 1' 1 2 3 13 15 [[ -n $GPG_TTY ]] || get_tty while :; do print -nru2 -- "$thetext" stty -echo IFS= read -r resp rc=$? print -u2 stty echo if (( rc )); then exit 3 elif (( askbool == 2 )); then exit 0 elif (( !askbool )); then print -nr -- "$resp" exit 0 fi [[ $resp = ?(1|-1|[Tt]?([Rr][Uu][Ee])|[Yy]?([Ee][Ss])) ]] && \ exit 0 [[ $resp = @(0|[Ff]?([Aa][Ll][Ss][Ee])|[Nn]?([Oo])) ]] && \ exit 1 print -u2 "Try again: 1/T[rue]/Y[es] vs 0/F[alse]/N[o]" done 0<>$GPG_TTY 2>&0 fi [[ -z $GPG_TTY ]] || checkline "OPTION ttyname=$GPG_TTY" [[ -z $GPG_TERM ]] || checkline "OPTION ttytype=$GPG_TERM" [[ -z $LC_CTYPE ]] || checkline "OPTION lc-ctype=$LC_CTYPE" [[ -z $LC_MESSAGES ]] || checkline "OPTION lc-messages=$LC_MESSAGES" [[ -n $asktext ]] && checkline "SETDESC $(toutf8 "$asktext")" [[ -n $askprompt ]] && checkline "SETPROMPT $(toutf8 "$askprompt")" [[ -n $askerror ]] && checkline "SETERROR $(toutf8 "$askerror")" [[ -n $btnyes ]] && checkline "SETOK $(toutf8 "$btnyes")" [[ -n $btnno ]] && checkline "SETCANCEL $(toutf8 "$btnno")" if (( askbool == 2 )); then print -p MESSAGE elif (( askbool )); then print -p CONFIRM else print -p GETPIN fi read -p res || die 3 pinentry died if [[ $res = @(D )* ]]; then pass=${res#D } read -p res || die 3 pinentry died else pass= fi if [[ $res = OK@(| *) ]]; then rv=0 print -nr -- "$pass" else rv=1 fi exec 3>&p; exec 3>&- exit $rv kwalletcli/kwalletcli_getpin.1010064400000000000000000000125451156221250500156620ustar00rootwheel.\" $MirOS: contrib/hosted/tg/code/kwalletcli/kwalletcli_getpin.1,v 1.16 2011/05/10 10:36:29 tg Exp $ .\"- .\" Copyright © 2009, 2011 .\" Thorsten Glaser .\" .\" Provided that these terms and disclaimer and all copyright notices .\" are retained or reproduced in an accompanying document, permission .\" is granted to deal in this work without restriction, including un‐ .\" limited rights to use, publicly perform, distribute, sell, modify, .\" merge, give away, or sublicence. .\" .\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to .\" the utmost extent permitted by applicable law, neither express nor .\" implied; without malicious intent or gross negligence. In no event .\" may a licensor, author or contributor be held liable for indirect, .\" direct, other damage, loss, or other issues arising in any way out .\" of dealing in the work, even if advised of the possibility of such .\" damage or existence of a defect, except proven that it results out .\" of said person’s immediate fault when using the work as intended. .\"- .\" Try to make GNU groff and AT&T nroff more compatible .\" * ` generates ‘ in gnroff, so use \` .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq .\" * - generates ‐ in gnroff, \- generates −, so .tr it to - .\" thus use - for hyphens and \- for minus signs and option dashes .\" * ~ is size-reduced and placed atop in groff, so use \*(TI .\" * ^ is size-reduced and placed atop in groff, so use \*(ha .\" * \(en does not work in nroff, so use \*(en .ie \n(.g \{\ . ds aq \(aq . ds TI \(ti . ds ha \(ha . ds en \(en .\} .el \{\ . ds aq ' . ds TI ~ . ds ha ^ . ds en \(em .\} .\" Implement .Dd with the Mdocdate RCS keyword .rn Dd xD .de Dd .ie \\$1$Mdocdate: \{\ . xD \\$2 \\$3, \\$4 .\} .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .. .\"- .Dd $Mdocdate: May 10 2011 $ .Dt KWALLETCLI_GETPIN 1 .Os .Sh NAME .Nm kwalletcli_getpin .Nd command line interface to pinentry .Sh SYNOPSIS .Nm .Op Fl q .Op Fl b | m | p Ar prompt .Op Fl E | e Ar errortext .br .Op Fl N Ar NoText .Op Fl t Ar desctext .Op Fl Y Ar YesText .Sh DESCRIPTION The .Nm utility is a shell wrapper speaking to .Nm pinentry using the Assuan protocol. It will ask the user for a passphrase and print it, without any trailing newline, to standard output. There are options for asking a boolean question or displaying a message. .Pp If .Ev PINENTRY is not empty but points to a non-existing or failing programme, .Nm pinentry is not called. Instead, .Xr xmessage 1 is used for boolean queries and messages if .Ev DISPLAY is set; otherwise, .Nm uses simple terminal I/O on .Ev GPG_TTY using .Xr stty 1 to disable echo of terminal input for passphrase queries. .Pp The options are as follows: .Bl -tag -width xPxdesctxt .It Fl b Ask for a confirmation (boolean) instead of a passphrase. .It Fl E Unset a previously set error text. .It Fl E Ar errtxt Set the error text to .Ar errtxt , displaying a dialogue box with a red X icon indicating that this is a retry question. .It Fl m Display a message (one-button query) instead of asking. .It Fl N Ar NoText Use .Ar NoText instead of .Ic Cancel for the text of the abort button, if any. .It Fl p Ar prompt Set the small descriptive text shown in front of the input field .Pq Dq the Prompt to .Ar prompt . .It Fl q Be more quiet. .It Fl t Ar desctxt Set the descriptive text .Pq the input challenge to .Ar desctxt . .It Fl Y Ar YesText Use .Ar YesText instead of .Ic OK for the text of the confirm button. .El .Pp All input and output is assumed to be in UTF-8. .Sh RETURN VALUES The .Nm utility exits 0 on success, 1 if the passphrase input was cancelled by the user, or \*(Gt1 if an error occurred. Confirmation (boolean) error codes are 0 for Yes, 1 for No, or \*(Gt1 if an error occurred. Messages return \*(Gt0 if an error occurred, 0 otherwise. .Pp A summary of the error codes follows: .Bl -tag -width X -compact .It 0 Read password successfully. Boolean question returned Yes/OK. .It 1 Boolean question returned No/Cancel. .It 2 Wrong command line syntax. .It 3 The process reading user input unexpectedly terminated or errored out. .It 4 Unexpected result reading from pinentry. .It 5 Unable to determine controlling tty, caller must set .Ev GPG_TTY . .It 6 Caught SIGHUP, SIGINT, SIGQUIT, SIGTRAP, SIGPIPE, or SIGTERM. .El .Sh ENVIRONMENT .Bl -tag -width LC_MESSAGES .It Ev DISPLAY If not set, pass current terminal information to .Nm pinentry . .It Ev GPG_TERM Terminal type of the current tty. Defaults to the value of the environment variable .Ev TERM , or .Dq vt100 if unset. .It Ev GPG_TTY The current terminal, determined by .Xr tty 1 if unset. .It Ev LC_CTYPE Passed to .Nm pinentry . Default: .Dq en_US.UTF\-8 .It Ev LC_MESSAGES Passed to .Nm pinentry . Unset by default. .It Ev PINENTRY The .Nm pinentry programme to use. Default: .Dq pinentry .El .Sh SEE ALSO .Xr gpg\-agent 1 , .Xr kwalletcli 1 , .Xr pinentry 1 , .Xr stty 1 , .Xr tset 1 , .Xr tty 1 .Sh AUTHORS .Nm was written by .An Thorsten Glaser Aq tg@mirbsd.org mostly for tarent GmbH. .Sh CAVEATS Some newer pinentry features, such as three-button operation or setting the window title, are not supported yet. .Sh BUGS Some .Nm pinentry programmes may not support messages correctly and display them as boolean queries instead. .Pp Some implementations display labels with the wrong charset. .Pp Neither of these two problems is an issue in .Nm but a bug of the backend implementation. kwalletcli/kwif3.cc010064400000000000000000000053131132264243600134300ustar00rootwheel/*- * Copyright © 2009, 2010 * Thorsten Glaser * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work without restriction, including un‐ * limited rights to use, publicly perform, distribute, sell, modify, * merge, give away, or sublicence. * * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to * the utmost extent permitted by applicable law, neither express nor * implied; without malicious intent or gross negligence. In no event * may a licensor, author or contributor be held liable for indirect, * direct, other damage, loss, or other issues arising in any way out * of dealing in the work, even if advised of the possibility of such * damage or existence of a defect, except proven that it results out * of said person’s immediate fault when using the work as intended. *- * KWallet interface file for Qt 3 and KDE 3 */ #include #include #include #include #include #include "kwalletcli.h" extern "C" char *getenv(const char *); extern "C" char *strdup(const char *); extern "C" const char __rcsid_kwif[] = "$MirOS: contrib/hosted/tg/code/kwalletcli/kwif3.cc,v 1.4 2010/01/11 15:34:30 tg Exp $"; extern "C" int kw_io(const char *fld, const char *ent, const char **pwp, const char *vers) { int rv; QString localwallet, qfld, qent, qpw; KWallet::Wallet *wallet; char *env_DISPLAY; if (pwp == NULL) return (KWE_ABORT); /* very basic protection against kdeinit errors */ if (!(env_DISPLAY = getenv("DISPLAY")) || !*env_DISPLAY) return (KWE_NOWALLET); qfld = QString::fromUtf8(fld); qent = QString::fromUtf8(ent); if (*pwp != NULL) qpw = QString::fromUtf8(*pwp); /* this is ridiculous */ KAboutData aboutData("kwalletcli", I18N_NOOP("KWallet CLI"), vers); KCmdLineArgs::init(&aboutData); KApplication app(false, false); localwallet = KWallet::Wallet::LocalWallet(); wallet = KWallet::Wallet::openWallet(localwallet); if (!wallet) { rv = KWE_NOWALLET; goto out; } if (!wallet->hasFolder(qfld)) { if (*pwp == NULL) { rv = KWE_NOFOLDER; goto out; } wallet->createFolder(qfld); } if (!wallet->setFolder(qfld)) { rv = KWE_ERRFOLDER; goto out; } if (*pwp == NULL) { if (!wallet->hasEntry(qent)) { rv = KWE_NOENTRY; goto out; } qpw = ""; if (wallet->readPassword(qent, qpw)) { rv = KWE_ERRENTRY; goto out; } rv = KWE_OK_GET; *pwp = strdup((const char *)qpw.utf8()); } else { if (wallet->writePassword(qent, qpw)) { rv = KWE_ERR_SET; goto out; } rv = KWE_OK_SET; } out: delete wallet; return (rv); } kwalletcli/kwif4.cc010064400000000000000000000054231132264243700134340ustar00rootwheel/*- * Copyright © 2009, 2010 * Thorsten Glaser * Copyright © 2009 * Thomas Fischer * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work without restriction, including un‐ * limited rights to use, publicly perform, distribute, sell, modify, * merge, give away, or sublicence. * * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to * the utmost extent permitted by applicable law, neither express nor * implied; without malicious intent or gross negligence. In no event * may a licensor, author or contributor be held liable for indirect, * direct, other damage, loss, or other issues arising in any way out * of dealing in the work, even if advised of the possibility of such * damage or existence of a defect, except proven that it results out * of said person’s immediate fault when using the work as intended. *- * KWallet interface file for Qt 4 and KDE 4 */ #include #include #include #include #include #include "kwalletcli.h" extern "C" char *getenv(const char *); extern "C" char *strdup(const char *); extern "C" const char __rcsid_kwif[] = "$MirOS: contrib/hosted/tg/code/kwalletcli/kwif4.cc,v 1.2 2010/01/11 15:34:31 tg Exp $"; extern "C" int kw_io(const char *fld, const char *ent, const char **pwp, const char *vers) { int rv; QString localwallet, qfld, qent, qpw; KWallet::Wallet *wallet; char *env_DISPLAY; if (pwp == NULL) return (KWE_ABORT); /* very basic protection against kdeinit4 errors */ if (!(env_DISPLAY = getenv("DISPLAY")) || !*env_DISPLAY) return (KWE_NOWALLET); qfld = QString::fromUtf8(fld); qent = QString::fromUtf8(ent); if (*pwp != NULL) qpw = QString::fromUtf8(*pwp); /* this is ridiculous */ KAboutData aboutData("kwalletcli", 0, ki18n("KWallet CLI"), vers); KCmdLineArgs::init(&aboutData); KApplication app(false); localwallet = KWallet::Wallet::LocalWallet(); wallet = KWallet::Wallet::openWallet(localwallet, 0); if (!wallet) { rv = KWE_NOWALLET; goto out; } if (!wallet->hasFolder(qfld)) { if (*pwp == NULL) { rv = KWE_NOFOLDER; goto out; } wallet->createFolder(qfld); } if (!wallet->setFolder(qfld)) { rv = KWE_ERRFOLDER; goto out; } if (*pwp == NULL) { if (!wallet->hasEntry(qent)) { rv = KWE_NOENTRY; goto out; } qpw = ""; if (wallet->readPassword(qent, qpw)) { rv = KWE_ERRENTRY; goto out; } rv = KWE_OK_GET; *pwp = strdup((const char *)qpw.toUtf8().data()); } else { if (wallet->writePassword(qent, qpw)) { rv = KWE_ERR_SET; goto out; } rv = KWE_OK_SET; } out: delete wallet; return (rv); } kwalletcli/main.c010064400000000000000000000106741155015627000131730ustar00rootwheel/*- * Copyright © 2009, 2011 * Thorsten Glaser * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work without restriction, including un‐ * limited rights to use, publicly perform, distribute, sell, modify, * merge, give away, or sublicence. * * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to * the utmost extent permitted by applicable law, neither express nor * implied; without malicious intent or gross negligence. In no event * may a licensor, author or contributor be held liable for indirect, * direct, other damage, loss, or other issues arising in any way out * of dealing in the work, even if advised of the possibility of such * damage or existence of a defect, except proven that it results out * of said person’s immediate fault when using the work as intended. */ #include #include #include #include #include #include "kwalletcli.h" const char __rcsid_main_c[] = "$MirOS: contrib/hosted/tg/code/kwalletcli/main.c,v 1.10 2011/04/09 22:24:32 tg Exp $"; #define WOCTET_MASK (0x7FFFFF80) #define WOCTET_VALUE (0x0000EF80) #define iswoctet(wc) (((wc) & WOCTET_MASK) == WOCTET_VALUE) int main(int argc, char *argv[]) { int ch, rv, quiet = 0; const char *kw_folder = NULL, *kw_entry = NULL, *kw_pass = NULL, *fmts; char *vers; while ((ch = getopt(argc, argv, "e:f:hPp:qV")) != -1) { switch (ch) { case 'e': kw_entry = optarg; break; case 'f': kw_folder = optarg; break; case 'P': { char *cp; size_t n = 65536; ssize_t cnt; if ((kw_pass = cp = malloc(n--)) == NULL) abort(); do { cnt = read(STDIN_FILENO, cp, n); if (cnt == -1) { if (errno == EINTR) continue; break; } else if (cnt == 0) break; n -= cnt; cp += cnt; } while (n); *cp = '\0'; break; } case 'p': kw_pass = optarg; break; case 'q': quiet = 1; break; case 'V': if (!quiet) fprintf(stderr, "%s\n%s\n%s\n", __rcsid_main_c, __rcsid_kwif, KWALLETCLI_H); return (0); case 'h': default: usage: fprintf(stderr, "Usage: kwalletcli -f folder" " -e entry [-P | -p writepassword]\n"); return (2); } } if ((argc - optind) || !kw_folder || !kw_entry) goto usage; if (asprintf(&vers, "%s %s %s", __rcsid_main_c, __rcsid_kwif, KWALLETCLI_H) == -1) vers = NULL; if (kw_pass) { unsigned int wc; size_t n; char *dst, *cp; const char *src = kw_pass; /* recode kw_pass from binary/utf-8 to safe utf-8 */ if ((dst = cp = malloc(strlen(kw_pass) * 3 + 1)) == NULL) abort(); do { n = utf_8to32(src, &wc); if (n == UTFCONV_ERROR || iswoctet(wc)) { /* assert: 0x80 <= *src <= 0xFF */ wc = *((const unsigned char *)src); wc |= WOCTET_VALUE; n = 1; } src += n; n = utf_32to8(dst, wc); dst += n; } while (wc); kw_pass = cp; } if (quiet) fclose(stderr); rv = kw_io(kw_folder, kw_entry, &kw_pass, vers ? vers : ""); switch (rv) { case KWE_OK_GET: { unsigned int wc; size_t n; char *dst, *cp; const char *src = kw_pass; /* recode kw_pass from safe utf-8 to binary/utf-8 */ if ((dst = cp = malloc(strlen(kw_pass) + 1)) == NULL) abort(); do { n = utf_8to32(src, &wc); if (n == UTFCONV_ERROR) /* should never happen */ goto print_kw_pass; src += n; if (iswoctet(wc)) { wc &= 0xFF; *((unsigned char *)dst++) = wc; } else { n = utf_32to8(dst, wc); dst += n; } } while (wc); kw_pass = cp; print_kw_pass: printf("%s", kw_pass); break; } case KWE_NOWALLET: if (!quiet) fprintf(stderr, "cannot open wallet\n"); break; case KWE_NOFOLDER: fmts = "folder '%s' does not exist\n"; if (0) /* FALLTHROUGH */ case KWE_ERRFOLDER: fmts = "cannot open folder '%s'\n"; if (!quiet) fprintf(stderr, fmts, kw_folder); break; case KWE_NOENTRY: fmts = "entry '%s' does not exist in folder '%s'\n"; if (0) /* FALLTHROUGH */ case KWE_ERRENTRY: fmts = "error reading entry '%s' from folder '%s'\n"; if (0) /* FALLTHROUGH */ case KWE_ERR_SET: fmts = "error writing entry '%s' to folder '%s'\n"; if (!quiet) fprintf(stderr, fmts, kw_entry, kw_folder); break; case KWE_OK_SET: rv = 0; break; case KWE_ABORT: if (!quiet) fprintf(stderr, "internal error\n"); default: fflush(NULL); abort(); } return (rv); } kwalletcli/pinentry-kwallet010064400000000000000000000177271156221136600153460ustar00rootwheel#!/usr/bin/env mksh rcsid='$MirOS: contrib/hosted/tg/code/kwalletcli/pinentry-kwallet,v 1.15 2011/05/10 10:26:38 tg Exp $' #- # Copyright © 2009, 2010, 2011 # Thorsten Glaser # # Provided that these terms and disclaimer and all copyright notices # are retained or reproduced in an accompanying document, permission # is granted to deal in this work without restriction, including un‐ # limited rights to use, publicly perform, distribute, sell, modify, # merge, give away, or sublicence. # # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to # the utmost extent permitted by applicable law, neither express nor # implied; without malicious intent or gross negligence. In no event # may a licensor, author or contributor be held liable for indirect, # direct, other damage, loss, or other issues arising in any way out # of dealing in the work, even if advised of the possibility of such # damage or existence of a defect, except proven that it results out # of said person’s immediate fault when using the work as intended. unset LC_ALL LANGUAGE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES \ LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION export LANG=C LC_CTYPE=en_US.UTF-8 set -U iodebug=0 iodp=~/pinentry-kwallet.debug if (( iodebug )); then print "\n$$ === new $(date)" >>"$iodp" chmod 0600 "$iodp" fi function io_p_in { local io_line IFS= read -r io_line || return $? (( iodebug )) && print -r -- "$$

>"$iodp" eval $1='${io_line% }' return 0 } function io_s_in { local io_line IFS= read -pr io_line || return $? (( iodebug )) && print -r -- "$$ >"$iodp" eval $1=\$io_line return 0 } function io_p_out { (( iodebug )) && print -r -- "$$ >p $(print "$@")" >>"$iodp" print "$@" } function io_s_out { (( iodebug )) && print -r -- "$$ >s $(print "$@")" >>"$iodp" print -p "$@" } function log { (( iodebug )) && print -r -- "$$ LOG $*" >>"$iodp" } if [[ -n $PINENTRY_KWALLET ]]; then io_p_out ERR 7 trying to call me recursively while io_p_in line; do io_p_out ERR 7 trying to call me recursively done exit 1 fi quiet=0 set -A args last= i=0 for arg in "$@"; do log "argv[$((++i))]='${arg//\'/\'\\\'\'}'" if [[ $last = --display ]]; then v=DISPLAY last=specvar elif [[ $last = --ttyname ]]; then v=GPG_TTY last=specvar elif [[ $last = --ttytype ]]; then v=GPG_TERM last=specvar elif [[ $last = --lc-type ]]; then v=LC_CTYPE last=specvar elif [[ $last = --lc-messages ]]; then v=LC_MESSAGES last=specvar fi if [[ $last = specvar ]]; then eval $v=\$arg eval export $v last=addone fi if [[ $last = addone ]]; then args[${#args[*]}]=$arg last= continue fi last= if [[ $arg = -V ]]; then (( quiet )) || print -ru2 -- "$rcsid" exit 0 elif [[ $arg = --version ]]; then print -r -- "$rcsid" exit 0 elif [[ $arg = @(-h|--help) ]]; then print "Usage: pinentry-kwallet [options]" exit 0 elif [[ $arg = -q ]]; then quiet=1 elif [[ $arg = \ @(-@(d|e|g)|--@(debug|enhanced|no-global-grab)) ]]; then args[${#args[*]}]=$arg elif [[ $arg = \ --@(display|ttyname|ttytype|lc-type|lc-messages) ]]; then args[${#args[*]}]=$arg last=$arg elif [[ $arg = --parent-wid ]]; then args[${#args[*]}]=$arg last=addone else (( quiet )) || print -u2 "warning: unknown argument '$arg'" args[${#args[*]}]=$arg fi done if [[ -z $DISPLAY ]]; then log "since DISPLAY is not set, replacing with: ${PINENTRY:-pinentry}" PINENTRY_KWALLET=set exec "${PINENTRY:-pinentry}" "${args[@]}" fi PINENTRY_KWALLET=set "${PINENTRY:-pinentry}" "${args[@]}" |& copid=$? log "starting coproc $copid: PINENTRY_KWALLET=set '${PINENTRY:-pinentry}' args" io_s_in resp || resp='ERR 14 no coprocess' if [[ $resp = OK@(| *) ]]; then have_sub=1 trap "kill $copid; exit 255" 1 2 3 5 13 15 else have_sub=0 exec 3>&p; exec 3>&- fi log have_sub=$have_sub io_p_out OK ready to listen to your demands x_dsctxt= x_prompt= x_errtxt= function getit { local type=$1 key=〈${x_prompt}〉$x_dsctxt pw rv tw=0 d errcnt blst=0 copyline=0 # the errcnt handling is a little tricky, because GnuPG v2 does # not reuse the pinentry session (suckers, unable to... *rant*) if pw=$(kwalletcli -q -f pinentry-kwallet -e "$type-B-$key") && \ [[ $pw = yes* ]]; then log "blacklisted" blst=1 elif pw=$(kwalletcli -q -f pinentry-kwallet -e "$type-e-$key"); then log "read errcnt: '$pw'" set -A errcnt -- $pw d=$(date -u +'%s') (( errcnt[0] < (d - 15) )) && errcnt[1]=0 else log "read errcnt failed" fi (( blst )) || [[ -z $x_errtxt ]] || (( errcnt[1]++ )) (( blst )) || if (( errcnt[1] )); then errcnt[0]=${d:-$(date -u +'%s')} kwalletcli -q -f pinentry-kwallet -e "$type-e-$key" \ -p "${errcnt[*]}" log "write errcnt: '${errcnt[*]}' -> $?" fi (( blst )) || if (( errcnt[1] < 2 )); then pw=$(kwalletcli -q -f pinentry-kwallet -e "$type-v-$key") rv=$? log "read pass $rv: '$pw'" case $type:$rv { (bool:0) if [[ $pw = \ @(1|-1|[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss]) ]]; then io_p_out OK return elif [[ $pw = \ @(0|[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo]) ]]; then io_p_out ERR 128 not confirmed return fi ;; (pass:0) [[ -n $pw ]] && io_p_out -r "D $pw" io_p_out OK return ;; } fi if (( !have_sub )); then io_p_out ERR 14 no coprocess return fi if [[ $type = bool ]]; then io_s_out CONFIRM io_s_in resp case $resp { (OK@(| *)) pw=1 tw=1 ;; (ERR\ @(128|83886194|83886179)@(| *)) # 128 = not confirmed (hardy) # 83886194 = not confirmed (wheezy) # 83886179 = canceled (wheezy) pw=0 tw=1 ;; } else io_s_out GETPIN io_s_in resp pw= #XXX normally, read until OK|ERR if [[ $resp = @(D )* ]]; then pw=${resp#D } io_s_in resp fi [[ $resp = OK@(| *) ]] && tw=1 fi (( tw && !blst )) && if kwalletcli_getpin -q -b \ -t "Do you want to store your response for description '$x_dsctxt', prompt '$x_prompt' in the KDE Wallet?"; then kwalletcli -q -f pinentry-kwallet -e "$type-v-$key" -p "$pw" log "want store: yes, pw '$pw' -> $?" else # create blacklist entry for this answer kwalletcli -q -f pinentry-kwallet -e "$type-B-$key" -p yes log "want store: no" fi [[ $type = pass ]] && [[ -n $pw ]] && io_p_out -r "D $pw" io_p_out -r -- "$resp" } while io_p_in line; do [[ -z $line || $line = '#'* ]] && continue copyline=1 case $line { (SETDESC) x_dsctxt= ;; (SETDESC\ *) x_dsctxt=${line#SETDESC } ;; (SETPROMPT) x_prompt= ;; (SETPROMPT\ *) x_prompt=${line#SETPROMPT } ;; (SETTITLE@(| *)) ;; (SET@(OK|CANCEL|NOTOK)@(| *)) ;; (SETERROR) x_errtxt= ;; (SETERROR\ *) x_errtxt=${line#SETERROR } ;; (SETQUALITYBAR*) ;; (GETPIN) getit pass ;; (CONFIRM) getit bool ;; (MESSAGE|CONFIRM\ --one-button) ;; (OPTION\ ttyname=*) GPG_TTY=${line#*=} export GPG_TTY ;; (OPTION\ ttytype=*) GPG_TERM=${line#*=} export GPG_TERM ;; (OPTION\ lc-ctype=*) LC_CTYPE=${line#*=} export LC_CTYPE ;; (OPTION\ lc-messages=*) LC_MESSAGES=${line#*=} export LC_MESSAGES ;; (OPTION\ *) ;; (CONFIRM\ *) (( quiet )) || print -ru2 "warning: unknown CONFIRM" \ "option ${line#CONFIRM }" ;; (BYE@(| *)) io_p_out OK break ;; (NOP@(| *)) # copy quietly, in case of keepalive ;; (GETINFO\ pid) # undocumented, but used by GnuPG v2 io_p_out D $$ io_p_out OK copyline=0 ;; (GETINFO\ version) # undocumented, but used by GnuPG v2 # just copy it quietly #XXX maybe return "ERR 103 unknown command"? ;; (GETINFO\ *) # undocumented, but used by GnuPG v2 (( quiet )) || print -ru2 "warning: unknown GETINFO" \ "capability ${line#GETINFO }" ;; (*) (( quiet )) || print -ru2 "warning: unknown line '$line'" ;; } (( copyline )) && if (( have_sub )); then io_s_out -r -- "$line" resp= while [[ $resp != @(OK|ERR)@(| *) ]]; do io_s_in resp io_p_out -r -- "$resp" done else io_p_out OK fi done if (( have_sub )); then io_s_out BYE io_s_in resp fi exec 2>/dev/null # avoid "no coprocess" warnings exec 3>&p; exec 3>&- exit 0 kwalletcli/pinentry-kwallet.1010064400000000000000000000111661156221250600154710ustar00rootwheel.\" $MirOS: contrib/hosted/tg/code/kwalletcli/pinentry-kwallet.1,v 1.8 2011/05/10 10:36:30 tg Exp $ .\"- .\" Copyright © 2009, 2010, 2011 .\" Thorsten Glaser .\" .\" Provided that these terms and disclaimer and all copyright notices .\" are retained or reproduced in an accompanying document, permission .\" is granted to deal in this work without restriction, including un‐ .\" limited rights to use, publicly perform, distribute, sell, modify, .\" merge, give away, or sublicence. .\" .\" This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to .\" the utmost extent permitted by applicable law, neither express nor .\" implied; without malicious intent or gross negligence. In no event .\" may a licensor, author or contributor be held liable for indirect, .\" direct, other damage, loss, or other issues arising in any way out .\" of dealing in the work, even if advised of the possibility of such .\" damage or existence of a defect, except proven that it results out .\" of said person’s immediate fault when using the work as intended. .\"- .\" Try to make GNU groff and AT&T nroff more compatible .\" * ` generates ‘ in gnroff, so use \` .\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq .\" * - generates ‐ in gnroff, \- generates −, so .tr it to - .\" thus use - for hyphens and \- for minus signs and option dashes .\" * ~ is size-reduced and placed atop in groff, so use \*(TI .\" * ^ is size-reduced and placed atop in groff, so use \*(ha .\" * \(en does not work in nroff, so use \*(en .ie \n(.g \{\ . ds aq \(aq . ds TI \(ti . ds ha \(ha . ds en \(en .\} .el \{\ . ds aq ' . ds TI ~ . ds ha ^ . ds en \(em .\} .\" Implement .Dd with the Mdocdate RCS keyword .rn Dd xD .de Dd .ie \\$1$Mdocdate: \{\ . xD \\$2 \\$3, \\$4 .\} .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .. .\"- .Dd $Mdocdate: May 10 2011 $ .Dt PINENTRY\-KWALLET 1 .Os .Sh NAME .Nm pinentry\-kwallet .Nd kwallet-based pass-phrase dialog for use with GnuPG .Sh SYNOPSIS .Nm .Op Fl q .Op Ar options .Sh DESCRIPTION .Nm is a kwallet- and pinentry-based pass-phrase dialog for use with GnuPG. It is intended to be called from the .Xr gpg\-agent 1 daemon and not invoked directly. .Pp .Nm replaces the regular .Ic pinentry\-program stanza set in .Pa \*(TI/.gnupg/gpg\-agent.conf and looks up the passphrases requested in the KWallet first, falling back to .Nm pinentry only if not found. The user is given the option to store it in the KWallet afterwards. Negative answers to this are also stored in the KWallet to avoid asking each time. .Pp .Nm .Pq like other pinentry variants talks a simplified subset of the regular Assuan protocol on stdio; all commands, even unknown ones, are passed through to a .Nm pinentry co-process during run-time, even if the latter is never used. It accepts the same options as .Nm pinentry , even unknown ones, because it is designed to plug in. As an exception, .Fl q makes .Nm more quiet (suppress warnings on stderr), and .Fl V displays the version on stderr (unless .Fl q ) . .Pp .Nm attempts sophisticated error handling: if an error dialogue is displayed, an internal counter is increased. If the counter reaches 2, the value stored in the KWallet is ignored, and the user is asked anew. The counter is stored in the KWallet, which is suboptimal but necessary, because .Xr gpg2 1 does not re-use the Assuan sessions, instead spawning a new .Nm each time a passphrase is required (rather stupid). Error counters are valid for 15 seconds since their last increasement. .Sh RETURN VALUES .Nm exits 1 if it is called recursively, 0 if help or version information are requested, and return codes do not matter in any other cases because errors are signalled in-band. It will exit 0 after the Assuan session is terminated. .Sh ENVIRONMENT .Bl -tag -width PINENTRY .It Ev DISPLAY The X11 display to use for child processes. If not set, .Nm will immediately replace itself with the slave .Ev PINENTRY programme to use. .It Ev GPG_TERM Terminal type of the current tty. .It Ev GPG_TTY The current terminal. .It Ev PINENTRY The .Nm pinentry programme to use. Default: .Dq pinentry .El .Sh SEE ALSO .Xr date 1 , .Xr gpg\-agent 1 , .Xr gpg2 1 , .Xr kwalletcli 1 , .Xr kwalletcli_getpin 1 , .Xr mksh 1 , .Xr pinentry\-curses 1 , .Xr pinentry\-gtk\-2 1 , .Xr pinentry\-qt 1 , .Xr pinentry\-x11 1 .Sh AUTHORS .Nm was written by .An Thorsten Glaser Aq tg@mirbsd.org mostly for tarent GmbH. .Sh CAVEATS Some newer pinentry features, such as three-button operation, are not supported yet. .Pp Some commands, such as version inquiry, as passed through to the pinentry coprocess indiscriminately, which may lead to strange results, should the protocol change or extend.