Artifact 637580722a168ce9ca7496e35f92392738d18d0f23c067b7f0391fe0f1bad383:
- File pwman.c — part of check-in [c14cf350df] at 2014-05-15 21:36:21 on branch manualheaven — Move src and doc files to top directory (user: base@atomicules.co.uk size: 7012) [more...]
- File
src/pwman.c
— part of check-in
[2ac75c5835]
at
2010-01-03 16:41:40
on branch origin/tweaks
— Avoid warnings about declaration of free in some files by ensuring stdlib.h is always imported
git-svn-id: https://pwman.svn.sourceforge.net/svnroot/pwman/trunk@101 db5f1c25-4851-472e-ac1e-5437d07aece1 (user: gagravarr@users.sourceforge.net size: 7012)
0000: 2f 2a 0a 20 2a 20 20 50 57 4d 61 6e 20 2d 20 70 /*. * PWMan - p
0010: 61 73 73 77 6f 72 64 20 6d 61 6e 61 67 65 6d 65 assword manageme
0020: 6e 74 20 61 70 70 6c 69 63 61 74 69 6f 6e 0a 20 nt application.
0030: 2a 0a 20 2a 20 20 43 6f 70 79 72 69 67 68 74 20 *. * Copyright
0040: 28 43 29 20 32 30 30 32 20 20 49 76 61 6e 20 4b (C) 2002 Ivan K
0050: 65 6c 6c 79 20 3c 69 76 61 6e 40 69 76 61 6e 6b elly <ivan@ivank
0060: 65 6c 6c 79 2e 6e 65 74 3e 0a 20 2a 0a 20 2a 20 elly.net>. *. *
0070: 20 54 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 This program is
0080: 20 66 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 free software;
0090: 79 6f 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 you can redistri
00a0: 62 75 74 65 20 69 74 20 61 6e 64 2f 6f 72 20 6d bute it and/or m
00b0: 6f 64 69 66 79 0a 20 2a 20 20 69 74 20 75 6e 64 odify. * it und
00c0: 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 20 er the terms of
00d0: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 the GNU General
00e0: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 61 Public License a
00f0: 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a 20 s published by.
0100: 2a 20 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 * the Free Soft
0110: 77 61 72 65 20 46 6f 75 6e 64 61 74 69 6f 6e 3b ware Foundation;
0120: 20 65 69 74 68 65 72 20 76 65 72 73 69 6f 6e 20 either version
0130: 32 20 6f 66 20 74 68 65 20 4c 69 63 65 6e 73 65 2 of the License
0140: 2c 20 6f 72 0a 20 2a 20 20 28 61 74 20 79 6f 75 , or. * (at you
0150: 72 20 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 r option) any la
0160: 74 65 72 20 76 65 72 73 69 6f 6e 2e 0a 20 2a 0a ter version.. *.
0170: 20 2a 20 20 54 68 69 73 20 70 72 6f 67 72 61 6d * This program
0180: 20 69 73 20 64 69 73 74 72 69 62 75 74 65 64 20 is distributed
0190: 69 6e 20 74 68 65 20 68 6f 70 65 20 74 68 61 74 in the hope that
01a0: 20 69 74 20 77 69 6c 6c 20 62 65 20 75 73 65 66 it will be usef
01b0: 75 6c 2c 0a 20 2a 20 20 62 75 74 20 57 49 54 48 ul,. * but WITH
01c0: 4f 55 54 20 41 4e 59 20 57 41 52 52 41 4e 54 59 OUT ANY WARRANTY
01d0: 3b 20 77 69 74 68 6f 75 74 20 65 76 65 6e 20 74 ; without even t
01e0: 68 65 20 69 6d 70 6c 69 65 64 20 77 61 72 72 61 he implied warra
01f0: 6e 74 79 20 6f 66 0a 20 2a 20 20 4d 45 52 43 48 nty of. * MERCH
0200: 41 4e 54 41 42 49 4c 49 54 59 20 6f 72 20 46 49 ANTABILITY or FI
0210: 54 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 TNESS FOR A PART
0220: 49 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 ICULAR PURPOSE.
0230: 20 53 65 65 20 74 68 65 0a 20 2a 20 20 47 4e 55 See the. * GNU
0240: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 General Public
0250: 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d 6f 72 65 License for more
0260: 20 64 65 74 61 69 6c 73 2e 0a 20 2a 0a 20 2a 20 details.. *. *
0270: 20 59 6f 75 20 73 68 6f 75 6c 64 20 68 61 76 65 You should have
0280: 20 72 65 63 65 69 76 65 64 20 61 20 63 6f 70 79 received a copy
0290: 20 6f 66 20 74 68 65 20 47 4e 55 20 47 65 6e 65 of the GNU Gene
02a0: 72 61 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e ral Public Licen
02b0: 73 65 0a 20 2a 20 20 61 6c 6f 6e 67 20 77 69 74 se. * along wit
02c0: 68 20 74 68 69 73 20 70 72 6f 67 72 61 6d 3b 20 h this program;
02d0: 69 66 20 6e 6f 74 2c 20 77 72 69 74 65 20 74 6f if not, write to
02e0: 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 77 61 the Free Softwa
02f0: 72 65 0a 20 2a 20 20 46 6f 75 6e 64 61 74 69 6f re. * Foundatio
0300: 6e 2c 20 49 6e 63 2e 2c 20 35 39 20 54 65 6d 70 n, Inc., 59 Temp
0310: 6c 65 20 50 6c 61 63 65 2c 20 53 75 69 74 65 20 le Place, Suite
0320: 33 33 30 2c 20 42 6f 73 74 6f 6e 2c 20 4d 41 20 330, Boston, MA
0330: 20 30 32 31 31 31 2d 31 33 30 37 20 20 55 53 41 02111-1307 USA
0340: 0a 20 2a 2f 0a 0a 23 69 6e 63 6c 75 64 65 20 22 . */..#include "
0350: 70 77 6d 61 6e 2e 68 22 0a 23 69 6e 63 6c 75 64 pwman.h".#includ
0360: 65 20 3c 73 69 67 6e 61 6c 2e 68 3e 0a 23 69 6e e <signal.h>.#in
0370: 63 6c 75 64 65 20 3c 73 74 64 6c 69 62 2e 68 3e clude <stdlib.h>
0380: 0a 23 69 6e 63 6c 75 64 65 20 3c 75 6e 69 73 74 .#include <unist
0390: 64 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 d.h>.#include <s
03a0: 79 73 2f 74 79 70 65 73 2e 68 3e 0a 23 69 6e 63 ys/types.h>.#inc
03b0: 6c 75 64 65 20 3c 73 79 73 2f 73 74 61 74 2e 68 lude <sys/stat.h
03c0: 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 66 63 6e 74 >.#include <fcnt
03d0: 6c 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 l.h>.#include <s
03e0: 74 64 61 72 67 2e 68 3e 0a 0a 73 74 61 74 69 63 tdarg.h>..static
03f0: 20 76 6f 69 64 20 70 77 6d 61 6e 5f 70 61 72 73 void pwman_pars
0400: 65 5f 63 6f 6d 6d 61 6e 64 5f 6c 69 6e 65 28 69 e_command_line(i
0410: 6e 74 20 61 72 67 63 2c 20 63 68 61 72 20 2a 2a nt argc, char **
0420: 61 72 67 76 29 3b 0a 73 74 61 74 69 63 20 76 6f argv);.static vo
0430: 69 64 20 70 77 6d 61 6e 5f 73 68 6f 77 5f 75 73 id pwman_show_us
0440: 61 67 65 28 29 3b 0a 73 74 61 74 69 63 20 76 6f age();.static vo
0450: 69 64 20 70 77 6d 61 6e 5f 73 68 6f 77 5f 76 65 id pwman_show_ve
0460: 72 73 69 6f 6e 28 29 3b 0a 73 74 61 74 69 63 20 rsion();.static
0470: 76 6f 69 64 20 70 77 6d 61 6e 5f 71 75 69 74 28 void pwman_quit(
0480: 29 3b 0a 0a 0a 73 74 61 74 69 63 20 69 6e 74 0a );...static int.
0490: 70 77 6d 61 6e 5f 63 68 65 63 6b 5f 6c 6f 63 6b pwman_check_lock
04a0: 5f 66 69 6c 65 28 29 0a 7b 0a 09 63 68 61 72 20 _file().{..char
04b0: 66 6e 5b 53 54 52 49 4e 47 5f 4c 4f 4e 47 5d 3b fn[STRING_LONG];
04c0: 0a 09 46 49 4c 45 20 2a 66 70 3b 0a 09 0a 09 73 ..FILE *fp;....s
04d0: 6e 70 72 69 6e 74 66 28 66 6e 2c 20 53 54 52 49 nprintf(fn, STRI
04e0: 4e 47 5f 4c 4f 4e 47 2c 20 22 25 73 2e 6c 6f 63 NG_LONG, "%s.loc
04f0: 6b 22 2c 20 6f 70 74 69 6f 6e 73 2d 3e 70 61 73 k", options->pas
0500: 73 77 6f 72 64 5f 66 69 6c 65 29 3b 0a 09 69 66 sword_file);..if
0510: 28 61 63 63 65 73 73 28 66 6e 2c 20 46 5f 4f 4b (access(fn, F_OK
0520: 29 20 3d 3d 20 30 29 7b 0a 09 09 72 65 74 75 72 ) == 0){...retur
0530: 6e 20 31 3b 0a 09 7d 20 65 6c 73 65 20 7b 0a 09 n 1;..} else {..
0540: 09 72 65 74 75 72 6e 20 30 3b 0a 09 7d 0a 7d 0a .return 0;..}.}.
0550: 0a 73 74 61 74 69 63 20 69 6e 74 0a 70 77 6d 61 .static int.pwma
0560: 6e 5f 63 72 65 61 74 65 5f 6c 6f 63 6b 5f 66 69 n_create_lock_fi
0570: 6c 65 28 29 0a 7b 0a 09 63 68 61 72 20 66 6e 5b le().{..char fn[
0580: 53 54 52 49 4e 47 5f 4c 4f 4e 47 5d 3b 0a 09 09 STRING_LONG];...
0590: 0a 09 73 6e 70 72 69 6e 74 66 28 66 6e 2c 20 53 ..snprintf(fn, S
05a0: 54 52 49 4e 47 5f 4c 4f 4e 47 2c 20 22 25 73 2e TRING_LONG, "%s.
05b0: 6c 6f 63 6b 22 2c 20 6f 70 74 69 6f 6e 73 2d 3e lock", options->
05c0: 70 61 73 73 77 6f 72 64 5f 66 69 6c 65 29 3b 0a password_file);.
05d0: 09 63 72 65 61 74 28 66 6e 2c 20 53 5f 49 52 57 .creat(fn, S_IRW
05e0: 58 55 29 3b 0a 7d 0a 0a 73 74 61 74 69 63 20 69 XU);.}..static i
05f0: 6e 74 0a 70 77 6d 61 6e 5f 64 65 6c 65 74 65 5f nt.pwman_delete_
0600: 6c 6f 63 6b 5f 66 69 6c 65 28 29 0a 7b 0a 09 63 lock_file().{..c
0610: 68 61 72 20 66 6e 5b 53 54 52 49 4e 47 5f 4c 4f har fn[STRING_LO
0620: 4e 47 5d 3b 0a 09 0a 09 73 6e 70 72 69 6e 74 66 NG];....snprintf
0630: 28 66 6e 2c 20 53 54 52 49 4e 47 5f 4c 4f 4e 47 (fn, STRING_LONG
0640: 2c 20 22 25 73 2e 6c 6f 63 6b 22 2c 20 6f 70 74 , "%s.lock", opt
0650: 69 6f 6e 73 2d 3e 70 61 73 73 77 6f 72 64 5f 66 ions->password_f
0660: 69 6c 65 29 3b 0a 09 75 6e 6c 69 6e 6b 28 66 6e ile);..unlink(fn
0670: 29 3b 0a 7d 0a 0a 73 74 61 74 69 63 20 76 6f 69 );.}..static voi
0680: 64 0a 70 77 6d 61 6e 5f 69 6e 69 74 28 69 6e 74 d.pwman_init(int
0690: 20 61 72 67 63 2c 20 63 68 61 72 20 2a 61 72 67 argc, char *arg
06a0: 76 5b 5d 29 0a 7b 0a 09 63 68 61 72 20 63 3b 0a v[]).{..char c;.
06b0: 09 69 6e 74 20 6c 6f 61 64 5f 77 6f 72 6b 65 64 .int load_worked
06c0: 2c 20 67 70 67 5f 69 64 5f 76 61 6c 69 64 3b 0a , gpg_id_valid;.
06d0: 0a 09 73 69 67 6e 61 6c 28 53 49 47 4b 49 4c 4c ..signal(SIGKILL
06e0: 2c 20 70 77 6d 61 6e 5f 71 75 69 74 29 3b 0a 09 , pwman_quit);..
06f0: 73 69 67 6e 61 6c 28 53 49 47 54 45 52 4d 2c 20 signal(SIGTERM,
0700: 70 77 6d 61 6e 5f 71 75 69 74 29 3b 0a 0a 09 75 pwman_quit);...u
0710: 6d 61 73 6b 28 44 45 46 41 55 4c 54 5f 55 4d 41 mask(DEFAULT_UMA
0720: 53 4b 29 3b 0a 0a 09 2f 2a 20 67 65 74 20 6f 70 SK);.../* get op
0730: 74 69 6f 6e 73 20 66 72 6f 6d 20 2e 70 77 6d 61 tions from .pwma
0740: 6e 72 63 20 2a 2f 0a 09 6f 70 74 69 6f 6e 73 20 nrc */..options
0750: 3d 20 6f 70 74 69 6f 6e 73 5f 6e 65 77 28 29 3b = options_new();
0760: 0a 09 69 66 28 6f 70 74 69 6f 6e 73 5f 72 65 61 ..if(options_rea
0770: 64 28 29 20 3d 3d 20 2d 31 29 7b 0a 09 09 6f 70 d() == -1){...op
0780: 74 69 6f 6e 73 5f 67 65 74 28 29 3b 0a 09 7d 0a tions_get();..}.
0790: 0a 09 2f 2a 20 70 61 72 73 65 20 63 6f 6d 6d 61 ../* parse comma
07a0: 6e 64 20 6c 69 6e 65 20 6f 70 74 69 6f 6e 73 20 nd line options
07b0: 2a 2f 0a 09 70 77 6d 61 6e 5f 70 61 72 73 65 5f */..pwman_parse_
07c0: 63 6f 6d 6d 61 6e 64 5f 6c 69 6e 65 28 61 72 67 command_line(arg
07d0: 63 2c 20 61 72 67 76 29 3b 0a 0a 09 2f 2a 20 63 c, argv);.../* c
07e0: 68 65 63 6b 20 74 6f 20 73 65 65 20 69 66 20 61 heck to see if a
07f0: 6e 6f 74 68 65 72 20 69 6e 73 74 61 6e 63 65 20 nother instance
0800: 6f 66 20 70 77 6d 61 6e 20 69 73 20 6f 70 65 6e of pwman is open
0810: 20 2a 2f 0a 09 69 66 28 21 6f 70 74 69 6f 6e 73 */..if(!options
0820: 2d 3e 72 65 61 64 6f 6e 6c 79 20 26 26 20 70 77 ->readonly && pw
0830: 6d 61 6e 5f 63 68 65 63 6b 5f 6c 6f 63 6b 5f 66 man_check_lock_f
0840: 69 6c 65 28 29 29 7b 0a 09 09 66 70 72 69 6e 74 ile()){...fprint
0850: 66 28 73 74 64 65 72 72 2c 20 22 49 74 20 73 65 f(stderr, "It se
0860: 65 6d 73 20 25 73 20 69 73 20 61 6c 72 65 61 64 ems %s is alread
0870: 79 20 6f 70 65 6e 65 64 20 62 79 20 61 6e 20 69 y opened by an i
0880: 6e 73 74 61 6e 63 65 20 6f 66 20 70 77 6d 61 6e nstance of pwman
0890: 5c 6e 22 2c 0a 09 09 09 09 6f 70 74 69 6f 6e 73 \n",.....options
08a0: 2d 3e 70 61 73 73 77 6f 72 64 5f 66 69 6c 65 29 ->password_file)
08b0: 3b 0a 09 09 66 70 72 69 6e 74 66 28 73 74 64 65 ;...fprintf(stde
08c0: 72 72 2c 20 22 54 77 6f 20 69 6e 73 74 61 6e 63 rr, "Two instanc
08d0: 65 73 20 6f 66 20 70 77 6d 61 6e 20 73 68 6f 75 es of pwman shou
08e0: 6c 64 20 6e 6f 74 20 62 65 20 6f 70 65 6e 20 74 ld not be open t
08f0: 68 65 20 73 61 6d 65 20 66 69 6c 65 20 61 74 20 he same file at
0900: 74 68 65 20 73 61 6d 65 20 74 69 6d 65 5c 6e 22 the same time\n"
0910: 29 3b 0a 09 09 66 70 72 69 6e 74 66 28 73 74 64 );...fprintf(std
0920: 65 72 72 2c 20 22 49 66 20 79 6f 75 20 61 72 65 err, "If you are
0930: 20 73 75 72 65 20 70 77 6d 61 6e 20 69 73 20 6e sure pwman is n
0940: 6f 74 20 61 6c 72 65 61 64 79 20 6f 70 65 6e 20 ot already open
0950: 79 6f 75 20 63 61 6e 20 64 65 6c 65 74 65 20 74 you can delete t
0960: 68 65 20 66 69 6c 65 2e 5c 6e 22 29 3b 0a 09 09 he file.\n");...
0970: 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 22 fprintf(stderr,"
0980: 41 6c 74 65 72 6e 61 74 69 76 65 6c 79 2c 20 79 Alternatively, y
0990: 6f 75 20 63 61 6e 20 6f 70 65 6e 20 74 68 65 20 ou can open the
09a0: 66 69 6c 65 20 72 65 61 64 6f 6e 6c 79 20 62 79 file readonly by
09b0: 20 61 6e 73 77 65 72 69 6e 67 20 27 72 27 5c 6e answering 'r'\n
09c0: 22 29 3b 0a 09 09 66 70 72 69 6e 74 66 28 73 74 ");...fprintf(st
09d0: 64 65 72 72 2c 22 44 65 6c 65 74 65 20 66 69 6c derr,"Delete fil
09e0: 65 20 25 73 2e 6c 6f 63 6b 3f 20 5b 79 2f 6e 2f e %s.lock? [y/n/
09f0: 72 5d 5c 6e 22 2c 0a 09 09 09 09 6f 70 74 69 6f r]\n",.....optio
0a00: 6e 73 2d 3e 70 61 73 73 77 6f 72 64 5f 66 69 6c ns->password_fil
0a10: 65 29 3b 0a 09 09 63 20 3d 20 67 65 74 63 68 61 e);...c = getcha
0a20: 72 28 29 3b 0a 09 09 66 70 72 69 6e 74 66 28 73 r();...fprintf(s
0a30: 74 64 65 72 72 2c 22 5c 6e 22 29 3b 0a 09 09 73 tderr,"\n");...s
0a40: 77 69 74 63 68 20 28 74 6f 6c 6f 77 65 72 28 63 witch (tolower(c
0a50: 29 29 20 7b 0a 09 09 09 63 61 73 65 20 27 79 27 )) {....case 'y'
0a60: 3a 0a 09 09 09 09 70 77 6d 61 6e 5f 64 65 6c 65 :.....pwman_dele
0a70: 74 65 5f 6c 6f 63 6b 5f 66 69 6c 65 28 29 3b 0a te_lock_file();.
0a80: 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 63 61 ....break;....ca
0a90: 73 65 20 27 72 27 3a 0a 09 09 09 09 6f 70 74 69 se 'r':.....opti
0aa0: 6f 6e 73 2d 3e 72 65 61 64 6f 6e 6c 79 20 3d 20 ons->readonly =
0ab0: 54 52 55 45 3b 0a 09 09 09 09 62 72 65 61 6b 3b TRUE;.....break;
0ac0: 0a 09 09 09 64 65 66 61 75 6c 74 3a 0a 09 09 09 ....default:....
0ad0: 09 65 78 69 74 28 2d 31 29 3b 0a 09 09 7d 0a 09 .exit(-1);...}..
0ae0: 7d 0a 0a 09 2f 2f 20 43 68 65 63 6b 20 74 68 61 }...// Check tha
0af0: 74 20 74 68 65 20 67 70 67 20 69 64 20 69 73 20 t the gpg id is
0b00: 76 61 6c 69 64 2c 20 69 66 20 67 69 76 65 6e 0a valid, if given.
0b10: 09 69 66 28 73 74 72 6c 65 6e 28 6f 70 74 69 6f .if(strlen(optio
0b20: 6e 73 2d 3e 67 70 67 5f 69 64 29 29 20 7b 0a 09 ns->gpg_id)) {..
0b30: 09 67 70 67 5f 69 64 5f 76 61 6c 69 64 20 3d 20 .gpg_id_valid =
0b40: 67 6e 75 70 67 5f 63 68 65 63 6b 5f 69 64 28 6f gnupg_check_id(o
0b50: 70 74 69 6f 6e 73 2d 3e 67 70 67 5f 69 64 29 3b ptions->gpg_id);
0b60: 0a 09 09 69 66 28 67 70 67 5f 69 64 5f 76 61 6c ...if(gpg_id_val
0b70: 69 64 20 3d 3d 20 2d 31 29 20 7b 0a 09 09 09 66 id == -1) {....f
0b80: 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 printf(stderr, "
0b90: 59 6f 75 72 20 47 50 47 20 6b 65 79 20 77 69 74 Your GPG key wit
0ba0: 68 20 69 64 20 6f 66 20 27 25 73 27 20 63 6f 75 h id of '%s' cou
0bb0: 6c 64 20 6e 6f 74 20 62 65 20 66 6f 75 6e 64 5c ld not be found\
0bc0: 6e 22 2c 20 6f 70 74 69 6f 6e 73 2d 3e 67 70 67 n", options->gpg
0bd0: 5f 69 64 29 3b 0a 09 09 09 66 70 72 69 6e 74 66 _id);....fprintf
0be0: 28 73 74 64 65 72 72 2c 20 22 59 6f 75 20 77 69 (stderr, "You wi
0bf0: 6c 6c 20 62 65 20 70 72 6f 6d 70 74 65 64 20 66 ll be prompted f
0c00: 6f 72 20 74 68 65 20 63 6f 72 72 65 63 74 20 6b or the correct k
0c10: 65 79 20 77 68 65 6e 20 73 61 76 69 6e 67 5c 6e ey when saving\n
0c20: 22 29 3b 0a 09 09 09 66 70 72 69 6e 74 66 28 73 ");....fprintf(s
0c30: 74 64 65 72 72 2c 20 22 5c 6e 28 70 72 65 73 73 tderr, "\n(press
0c40: 20 61 6e 79 20 6b 65 79 20 74 6f 20 63 6f 6e 74 any key to cont
0c50: 69 6e 75 65 29 5c 6e 22 29 3b 0a 09 09 09 63 20 inue)\n");....c
0c60: 3d 20 67 65 74 63 68 61 72 28 29 3b 0a 09 09 7d = getchar();...}
0c70: 0a 09 09 69 66 28 67 70 67 5f 69 64 5f 76 61 6c ...if(gpg_id_val
0c80: 69 64 20 3d 3d 20 2d 32 29 20 7b 0a 09 09 09 66 id == -2) {....f
0c90: 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 printf(stderr, "
0ca0: 59 6f 75 72 20 47 50 47 20 6b 65 79 20 77 69 74 Your GPG key wit
0cb0: 68 20 69 64 20 6f 66 20 27 25 73 27 20 68 61 73 h id of '%s' has
0cc0: 20 65 78 70 69 72 65 64 21 5c 6e 22 2c 20 6f 70 expired!\n", op
0cd0: 74 69 6f 6e 73 2d 3e 67 70 67 5f 69 64 29 3b 0a tions->gpg_id);.
0ce0: 09 09 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 ...fprintf(stder
0cf0: 72 2c 20 22 50 6c 65 61 73 65 20 63 68 61 6e 67 r, "Please chang
0d00: 65 20 74 68 65 20 65 78 70 69 72 79 20 64 61 74 e the expiry dat
0d10: 65 20 6f 66 20 79 6f 75 72 20 6b 65 79 2c 20 6f e of your key, o
0d20: 72 20 73 77 69 74 63 68 20 74 6f 20 61 20 6e 65 r switch to a ne
0d30: 77 20 6f 6e 65 5c 6e 22 29 3b 0a 09 09 09 65 78 w one\n");....ex
0d40: 69 74 28 2d 31 29 3b 0a 09 09 7d 0a 09 7d 0a 09 it(-1);...}..}..
0d50: 0a 09 2f 2f 20 53 74 61 72 74 20 75 70 20 6f 75 ..// Start up ou
0d60: 72 20 55 49 0a 09 69 66 28 20 75 69 5f 69 6e 69 r UI..if( ui_ini
0d70: 74 28 29 20 29 7b 0a 09 09 65 78 69 74 28 31 29 t() ){...exit(1)
0d80: 3b 0a 09 7d 0a 0a 09 75 69 5f 72 65 66 72 65 73 ;..}...ui_refres
0d90: 68 5f 77 69 6e 64 6f 77 73 28 29 3b 0a 0a 09 2f h_windows();.../
0da0: 2a 20 67 65 74 20 70 77 20 64 61 74 61 62 61 73 * get pw databas
0db0: 65 20 2a 2f 0a 09 70 77 6c 69 73 74 5f 69 6e 69 e */..pwlist_ini
0dc0: 74 28 29 3b 0a 09 6c 6f 61 64 5f 77 6f 72 6b 65 t();..load_worke
0dd0: 64 20 3d 20 70 77 6c 69 73 74 5f 72 65 61 64 5f d = pwlist_read_
0de0: 66 69 6c 65 28 29 3b 0a 09 69 66 28 6c 6f 61 64 file();..if(load
0df0: 5f 77 6f 72 6b 65 64 20 21 3d 20 30 29 20 7b 0a _worked != 0) {.
0e00: 09 09 64 65 62 75 67 28 22 46 61 69 6c 65 64 20 ..debug("Failed
0e10: 74 6f 20 6c 6f 61 64 20 74 68 65 20 64 61 74 61 to load the data
0e20: 62 61 73 65 2c 20 65 72 72 6f 72 20 77 61 73 20 base, error was
0e30: 25 64 22 2c 20 6c 6f 61 64 5f 77 6f 72 6b 65 64 %d", load_worked
0e40: 29 3b 0a 09 09 2f 2f 20 44 69 64 20 74 68 65 79 );...// Did they
0e50: 20 63 61 6e 63 65 6c 20 6f 75 74 2c 20 6f 72 20 cancel out, or
0e60: 69 73 20 69 74 20 61 20 6e 65 77 20 66 69 6c 65 is it a new file
0e70: 3f 0a 09 09 69 66 28 6c 6f 61 64 5f 77 6f 72 6b ?...if(load_work
0e80: 65 64 20 3c 20 30 29 20 7b 0a 09 09 09 70 77 6c ed < 0) {....pwl
0e90: 69 73 74 20 3d 20 70 77 6c 69 73 74 5f 6e 65 77 ist = pwlist_new
0ea0: 28 22 4d 61 69 6e 22 29 3b 0a 09 09 09 63 75 72 ("Main");....cur
0eb0: 72 65 6e 74 5f 70 77 5f 73 75 62 6c 69 73 74 20 rent_pw_sublist
0ec0: 3d 20 70 77 6c 69 73 74 3b 0a 09 09 7d 20 65 6c = pwlist;...} el
0ed0: 73 65 20 7b 0a 09 09 09 2f 2f 20 51 75 69 74 2c se {....// Quit,
0ee0: 20 68 61 72 64 21 0a 09 09 09 75 69 5f 65 6e 64 hard!....ui_end
0ef0: 28 29 3b 0a 09 09 09 66 70 72 69 6e 74 66 28 73 ();....fprintf(s
0f00: 74 64 65 72 72 2c 20 22 5c 6e 5c 6e 47 50 47 20 tderr, "\n\nGPG
0f10: 72 65 61 64 20 63 61 6e 63 65 6c 6c 65 64 2c 20 read cancelled,
0f20: 65 78 69 74 69 6e 67 5c 6e 22 29 3b 0a 09 09 09 exiting\n");....
0f30: 65 78 69 74 28 31 29 3b 0a 09 09 7d 0a 09 7d 0a exit(1);...}..}.
0f40: 09 69 66 20 28 21 6f 70 74 69 6f 6e 73 2d 3e 72 .if (!options->r
0f50: 65 61 64 6f 6e 6c 79 29 7b 0a 09 09 70 77 6d 61 eadonly){...pwma
0f60: 6e 5f 63 72 65 61 74 65 5f 6c 6f 63 6b 5f 66 69 n_create_lock_fi
0f70: 6c 65 28 29 3b 0a 09 7d 0a 0a 09 75 69 5f 72 65 le();..}...ui_re
0f80: 66 72 65 73 68 5f 77 69 6e 64 6f 77 73 28 29 3b fresh_windows();
0f90: 0a 7d 0a 0a 73 74 61 74 69 63 20 76 6f 69 64 0a .}..static void.
0fa0: 70 77 6d 61 6e 5f 71 75 69 74 28 29 0a 7b 0a 09 pwman_quit().{..
0fb0: 70 77 6c 69 73 74 5f 77 72 69 74 65 5f 66 69 6c pwlist_write_fil
0fc0: 65 28 29 3b 0a 09 70 77 6c 69 73 74 5f 66 72 65 e();..pwlist_fre
0fd0: 65 5f 61 6c 6c 28 29 3b 0a 09 70 77 6d 61 6e 5f e_all();..pwman_
0fe0: 64 65 6c 65 74 65 5f 6c 6f 63 6b 5f 66 69 6c 65 delete_lock_file
0ff0: 28 29 3b 0a 09 0a 09 75 69 5f 65 6e 64 28 29 3b ();....ui_end();
1000: 0a 09 6f 70 74 69 6f 6e 73 5f 77 72 69 74 65 28 ..options_write(
1010: 29 3b 0a 09 0a 09 65 78 69 74 28 30 29 3b 0a 7d );....exit(0);.}
1020: 0a 0a 69 6e 74 0a 6d 61 69 6e 28 69 6e 74 20 61 ..int.main(int a
1030: 72 67 63 2c 20 63 68 61 72 20 2a 61 72 67 76 5b rgc, char *argv[
1040: 5d 29 0a 7b 0a 09 70 77 6d 61 6e 5f 69 6e 69 74 ]).{..pwman_init
1050: 28 61 72 67 63 2c 20 61 72 67 76 29 3b 0a 0a 09 (argc, argv);...
1060: 75 69 5f 72 75 6e 28 29 3b 0a 0a 09 70 77 6d 61 ui_run();...pwma
1070: 6e 5f 71 75 69 74 28 29 3b 0a 09 72 65 74 75 72 n_quit();..retur
1080: 6e 20 30 3b 0a 7d 0a 0a 73 74 61 74 69 63 20 76 n 0;.}..static v
1090: 6f 69 64 0a 70 77 6d 61 6e 5f 70 61 72 73 65 5f oid.pwman_parse_
10a0: 63 6f 6d 6d 61 6e 64 5f 6c 69 6e 65 28 69 6e 74 command_line(int
10b0: 20 61 72 67 63 2c 20 63 68 61 72 20 2a 2a 61 72 argc, char **ar
10c0: 67 76 29 0a 7b 0a 09 69 6e 74 20 69 3b 0a 0a 09 gv).{..int i;...
10d0: 66 6f 72 28 69 20 3d 20 31 3b 20 69 20 3c 20 61 for(i = 1; i < a
10e0: 72 67 63 3b 20 69 2b 2b 29 7b 0a 09 09 69 66 28 rgc; i++){...if(
10f0: 20 21 73 74 72 63 6d 70 28 61 72 67 76 5b 69 5d !strcmp(argv[i]
1100: 2c 20 22 2d 2d 68 65 6c 70 22 29 20 7c 7c 20 21 , "--help") || !
1110: 73 74 72 63 6d 70 28 61 72 67 76 5b 69 5d 2c 20 strcmp(argv[i],
1120: 22 2d 68 22 29 20 29 7b 0a 09 09 09 70 77 6d 61 "-h") ){....pwma
1130: 6e 5f 73 68 6f 77 5f 75 73 61 67 65 28 61 72 67 n_show_usage(arg
1140: 76 5b 30 5d 29 3b 0a 09 09 09 65 78 69 74 28 31 v[0]);....exit(1
1150: 29 3b 0a 09 09 7d 20 65 6c 73 65 20 69 66 28 20 );...} else if(
1160: 21 73 74 72 63 6d 70 28 61 72 67 76 5b 69 5d 2c !strcmp(argv[i],
1170: 20 22 2d 2d 76 65 72 73 69 6f 6e 22 29 20 7c 7c "--version") ||
1180: 20 21 73 74 72 63 6d 70 28 61 72 67 76 5b 69 5d !strcmp(argv[i]
1190: 2c 20 22 2d 76 22 29 20 29 7b 0a 09 09 09 70 77 , "-v") ){....pw
11a0: 6d 61 6e 5f 73 68 6f 77 5f 76 65 72 73 69 6f 6e man_show_version
11b0: 28 29 3b 0a 09 09 09 65 78 69 74 28 31 29 3b 0a ();....exit(1);.
11c0: 09 09 7d 20 65 6c 73 65 20 69 66 28 20 21 73 74 ..} else if( !st
11d0: 72 63 6d 70 28 61 72 67 76 5b 69 5d 2c 20 22 2d rcmp(argv[i], "-
11e0: 2d 67 70 67 2d 70 61 74 68 22 29 20 29 7b 0a 09 -gpg-path") ){..
11f0: 09 09 77 72 69 74 65 5f 6f 70 74 69 6f 6e 73 20 ..write_options
1200: 3d 20 46 41 4c 53 45 3b 0a 09 09 09 73 74 72 6e = FALSE;....strn
1210: 63 70 79 28 6f 70 74 69 6f 6e 73 2d 3e 67 70 67 cpy(options->gpg
1220: 5f 70 61 74 68 2c 20 61 72 67 76 5b 69 20 2b 20 _path, argv[i +
1230: 31 5d 2c 20 53 54 52 49 4e 47 5f 4c 4f 4e 47 29 1], STRING_LONG)
1240: 3b 0a 09 09 09 69 2b 2b 3b 0a 09 09 7d 65 6c 73 ;....i++;...}els
1250: 65 20 69 66 28 20 21 73 74 72 63 6d 70 28 61 72 e if( !strcmp(ar
1260: 67 76 5b 69 5d 2c 20 22 2d 2d 67 70 67 2d 69 64 gv[i], "--gpg-id
1270: 22 29 20 29 7b 0a 09 09 09 77 72 69 74 65 5f 6f ") ){....write_o
1280: 70 74 69 6f 6e 73 20 3d 20 46 41 4c 53 45 3b 0a ptions = FALSE;.
1290: 09 09 09 73 74 72 6e 63 70 79 28 6f 70 74 69 6f ...strncpy(optio
12a0: 6e 73 2d 3e 67 70 67 5f 69 64 2c 20 61 72 67 76 ns->gpg_id, argv
12b0: 5b 69 20 2b 20 31 5d 2c 20 53 54 52 49 4e 47 5f [i + 1], STRING_
12c0: 4c 4f 4e 47 29 3b 0a 09 09 09 69 2b 2b 3b 0a 09 LONG);....i++;..
12d0: 09 7d 20 65 6c 73 65 20 69 66 28 20 21 73 74 72 .} else if( !str
12e0: 63 6d 70 28 61 72 67 76 5b 69 5d 2c 20 22 2d 2d cmp(argv[i], "--
12f0: 66 69 6c 65 22 29 20 7c 7c 20 21 73 74 72 63 6d file") || !strcm
1300: 70 28 61 72 67 76 5b 69 5d 2c 20 22 2d 66 22 29 p(argv[i], "-f")
1310: 20 29 7b 0a 09 09 09 77 72 69 74 65 5f 6f 70 74 ){....write_opt
1320: 69 6f 6e 73 20 3d 20 46 41 4c 53 45 3b 0a 09 09 ions = FALSE;...
1330: 09 73 74 72 6e 63 70 79 28 6f 70 74 69 6f 6e 73 .strncpy(options
1340: 2d 3e 70 61 73 73 77 6f 72 64 5f 66 69 6c 65 2c ->password_file,
1350: 20 61 72 67 76 5b 69 20 2b 20 31 5d 2c 20 53 54 argv[i + 1], ST
1360: 52 49 4e 47 5f 4c 4f 4e 47 29 3b 0a 09 09 09 69 RING_LONG);....i
1370: 2b 2b 3b 0a 09 09 7d 20 65 6c 73 65 20 69 66 28 ++;...} else if(
1380: 20 21 73 74 72 63 6d 70 28 61 72 67 76 5b 69 5d !strcmp(argv[i]
1390: 2c 20 22 2d 2d 70 61 73 73 70 68 72 61 73 65 2d , "--passphrase-
13a0: 74 69 6d 65 6f 75 74 22 29 20 7c 7c 20 21 73 74 timeout") || !st
13b0: 72 63 6d 70 28 61 72 67 76 5b 69 5d 2c 20 22 2d rcmp(argv[i], "-
13c0: 74 22 29 20 29 7b 0a 09 09 09 77 72 69 74 65 5f t") ){....write_
13d0: 6f 70 74 69 6f 6e 73 20 3d 20 46 41 4c 53 45 3b options = FALSE;
13e0: 0a 09 09 09 6f 70 74 69 6f 6e 73 2d 3e 70 61 73 ....options->pas
13f0: 73 70 68 72 61 73 65 5f 74 69 6d 65 6f 75 74 20 sphrase_timeout
1400: 3d 20 61 74 6f 69 28 61 72 67 76 5b 69 20 2b 20 = atoi(argv[i +
1410: 31 5d 29 3b 0a 09 09 09 69 2b 2b 3b 0a 09 09 7d 1]);....i++;...}
1420: 20 65 6c 73 65 20 69 66 20 28 20 21 73 74 72 63 else if ( !strc
1430: 6d 70 28 61 72 67 76 5b 69 5d 2c 20 22 2d 2d 72 mp(argv[i], "--r
1440: 65 61 64 6f 6e 6c 79 22 29 20 7c 7c 20 21 73 74 eadonly") || !st
1450: 72 63 6d 70 28 61 72 67 76 5b 69 5d 2c 20 22 2d rcmp(argv[i], "-
1460: 72 22 29 20 29 7b 0a 09 09 09 77 72 69 74 65 5f r") ){....write_
1470: 6f 70 74 69 6f 6e 73 20 3d 20 46 41 4c 53 45 3b options = FALSE;
1480: 0a 09 09 09 6f 70 74 69 6f 6e 73 2d 3e 72 65 61 ....options->rea
1490: 64 6f 6e 6c 79 20 3d 20 54 52 55 45 3b 0a 09 09 donly = TRUE;...
14a0: 7d 20 65 6c 73 65 20 7b 0a 09 09 09 70 72 69 6e } else {....prin
14b0: 74 66 28 22 6f 70 74 69 6f 6e 20 25 73 20 6e 6f tf("option %s no
14c0: 74 20 72 65 63 6f 67 6e 69 73 65 64 5c 6e 22 2c t recognised\n",
14d0: 20 61 72 67 76 5b 69 5d 29 3b 0a 09 09 09 70 72 argv[i]);....pr
14e0: 69 6e 74 66 28 22 74 72 79 20 25 73 20 2d 2d 68 intf("try %s --h
14f0: 65 6c 70 20 66 6f 72 20 6d 6f 72 65 20 69 6e 66 elp for more inf
1500: 6f 5c 6e 22 2c 20 61 72 67 76 5b 30 5d 29 3b 0a o\n", argv[0]);.
1510: 09 09 09 65 78 69 74 28 31 29 3b 0a 09 09 7d 0a ...exit(1);...}.
1520: 09 7d 0a 7d 0a 0a 73 74 61 74 69 63 20 76 6f 69 .}.}..static voi
1530: 64 0a 70 77 6d 61 6e 5f 73 68 6f 77 5f 76 65 72 d.pwman_show_ver
1540: 73 69 6f 6e 28 29 0a 7b 0a 09 70 75 74 73 28 50 sion().{..puts(P
1550: 41 43 4b 41 47 45 20 22 20 76 20 22 20 56 45 52 ACKAGE " v " VER
1560: 53 49 4f 4e 29 3b 0a 09 70 75 74 73 28 22 57 72 SION);..puts("Wr
1570: 69 74 74 65 6e 20 62 79 20 49 76 61 6e 20 4b 65 itten by Ivan Ke
1580: 6c 6c 79 20 3c 69 76 61 6e 40 69 76 61 6e 6b 65 lly <ivan@ivanke
1590: 6c 6c 79 2e 6e 65 74 3e 5c 6e 22 29 3b 0a 09 70 lly.net>\n");..p
15a0: 75 74 73 28 22 43 6f 70 79 72 69 67 68 74 20 28 uts("Copyright (
15b0: 43 29 20 32 30 30 32 20 49 76 61 6e 20 4b 65 6c C) 2002 Ivan Kel
15c0: 6c 79 22 29 3b 0a 09 70 75 74 73 28 22 54 68 69 ly");..puts("Thi
15d0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66 72 65 s program is fre
15e0: 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f 75 20 e software; you
15f0: 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 74 65 can redistribute
1600: 20 69 74 20 61 6e 64 2f 6f 72 20 6d 6f 64 69 66 it and/or modif
1610: 79 22 29 3b 0a 09 70 75 74 73 28 22 69 74 20 75 y");..puts("it u
1620: 6e 64 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f nder the terms o
1630: 66 20 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 f the GNU Genera
1640: 6c 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 l Public License
1650: 20 61 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 as published by
1660: 22 29 3b 0a 09 70 75 74 73 28 22 74 68 65 20 46 ");..puts("the F
1670: 72 65 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 ree Software Fou
1680: 6e 64 61 74 69 6f 6e 3b 20 65 69 74 68 65 72 20 ndation; either
1690: 76 65 72 73 69 6f 6e 20 32 20 6f 66 20 74 68 65 version 2 of the
16a0: 20 4c 69 63 65 6e 73 65 2c 20 6f 72 22 29 3b 0a License, or");.
16b0: 09 70 75 74 73 28 22 28 61 74 20 79 6f 75 72 20 .puts("(at your
16c0: 6f 70 74 69 6f 6e 29 20 61 6e 79 20 6c 61 74 65 option) any late
16d0: 72 20 76 65 72 73 69 6f 6e 2e 5c 6e 22 29 3b 0a r version.\n");.
16e0: 0a 09 70 75 74 73 28 22 54 68 69 73 20 70 72 6f ..puts("This pro
16f0: 67 72 61 6d 20 69 73 20 64 69 73 74 72 69 62 75 gram is distribu
1700: 74 65 64 20 69 6e 20 74 68 65 20 68 6f 70 65 20 ted in the hope
1710: 74 68 61 74 20 69 74 20 77 69 6c 6c 20 62 65 20 that it will be
1720: 75 73 65 66 75 6c 2c 22 29 3b 0a 09 70 75 74 73 useful,");..puts
1730: 28 22 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e ("but WITHOUT AN
1740: 59 20 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 Y WARRANTY; with
1750: 6f 75 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 out even the imp
1760: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 lied warranty of
1770: 22 29 3b 0a 09 70 75 74 73 28 22 4d 45 52 43 48 ");..puts("MERCH
1780: 41 4e 54 41 42 49 4c 49 54 59 20 6f 72 20 46 49 ANTABILITY or FI
1790: 54 4e 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 TNESS FOR A PART
17a0: 49 43 55 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 ICULAR PURPOSE.
17b0: 20 53 65 65 20 74 68 65 22 29 3b 0a 09 70 75 74 See the");..put
17c0: 73 28 22 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 s("GNU General P
17d0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f ublic License fo
17e0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 5c r more details.\
17f0: 6e 22 29 3b 0a 0a 09 70 75 74 73 28 22 59 6f 75 n");...puts("You
1800: 20 73 68 6f 75 6c 64 20 68 61 76 65 20 72 65 63 should have rec
1810: 65 69 76 65 64 20 61 20 63 6f 70 79 20 6f 66 20 eived a copy of
1820: 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 the GNU General
1830: 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 22 29 Public License")
1840: 3b 0a 09 70 75 74 73 28 22 61 6c 6f 6e 67 20 77 ;..puts("along w
1850: 69 74 68 20 74 68 69 73 20 70 72 6f 67 72 61 6d ith this program
1860: 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69 74 65 20 ; if not, write
1870: 74 6f 20 74 68 65 20 46 72 65 65 20 53 6f 66 74 to the Free Soft
1880: 77 61 72 65 22 29 3b 0a 09 70 75 74 73 28 22 46 ware");..puts("F
1890: 6f 75 6e 64 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c oundation, Inc.,
18a0: 20 35 39 20 54 65 6d 70 6c 65 20 50 6c 61 63 65 59 Temple Place
18b0: 20 2d 20 53 75 69 74 65 20 33 33 30 2c 20 42 6f - Suite 330, Bo
18c0: 73 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2c ston, MA 02111,
18d0: 20 55 53 41 2e 5c 6e 22 29 3b 0a 7d 0a 0a 73 74 USA.\n");.}..st
18e0: 61 74 69 63 20 76 6f 69 64 0a 70 77 6d 61 6e 5f atic void.pwman_
18f0: 73 68 6f 77 5f 75 73 61 67 65 28 63 68 61 72 20 show_usage(char
1900: 2a 61 72 67 76 5f 30 29 0a 7b 0a 09 70 72 69 6e *argv_0).{..prin
1910: 74 66 28 22 55 73 61 67 65 3a 20 25 73 20 5b 4f tf("Usage: %s [O
1920: 50 54 49 4f 4e 53 5d 2e 2e 2e 5c 6e 22 2c 20 61 PTIONS]...\n", a
1930: 72 67 76 5f 30 29 3b 0a 09 70 75 74 73 28 22 53 rgv_0);..puts("S
1940: 74 6f 72 65 20 79 6f 75 20 70 61 73 73 77 6f 72 tore you passwor
1950: 64 73 20 73 65 63 75 72 65 6c 79 20 75 73 69 6e ds securely usin
1960: 67 20 70 75 62 6c 69 63 20 6b 65 79 20 65 6e 63 g public key enc
1970: 72 79 70 74 69 6f 6e 5c 6e 22 29 3b 0a 09 70 75 ryption\n");..pu
1980: 74 73 28 22 20 20 2d 2d 68 65 6c 70 20 20 20 20 ts(" --help
1990: 20 20 20 20 20 20 20 20 20 20 20 20 20 73 68 6f sho
19a0: 77 20 75 73 61 67 65 22 29 3b 0a 09 70 75 74 73 w usage");..puts
19b0: 28 22 20 20 2d 2d 76 65 72 73 69 6f 6e 20 20 20 (" --version
19c0: 20 20 20 20 20 20 20 20 20 20 20 64 69 73 70 6c displ
19d0: 61 79 20 76 65 72 73 69 6f 6e 20 69 6e 66 6f 72 ay version infor
19e0: 6d 61 74 69 6f 6e 22 29 3b 0a 09 70 75 74 73 28 mation");..puts(
19f0: 22 20 20 2d 2d 67 70 67 2d 70 61 74 68 20 3c 70 " --gpg-path <p
1a00: 61 74 68 3e 20 20 20 20 20 20 50 61 74 68 20 74 ath> Path t
1a10: 6f 20 47 6e 75 50 47 20 65 78 65 63 75 74 61 62 o GnuPG executab
1a20: 6c 65 22 29 3b 0a 09 70 75 74 73 28 22 20 20 2d le");..puts(" -
1a30: 2d 67 70 67 2d 69 64 20 3c 69 64 3e 20 20 20 20 -gpg-id <id>
1a40: 20 20 20 20 20 20 47 6e 75 50 47 20 49 44 20 74 GnuPG ID t
1a50: 6f 20 75 73 65 22 29 3b 0a 09 70 75 74 73 28 22 o use");..puts("
1a60: 20 20 2d 2d 66 69 6c 65 20 3c 66 69 6c 65 3e 20 --file <file>
1a70: 20 20 20 20 20 20 20 20 20 66 69 6c 65 20 74 6f file to
1a80: 20 72 65 61 64 20 70 61 73 73 77 6f 72 64 73 20 read passwords
1a90: 66 72 6f 6d 22 29 3b 0a 09 70 75 74 73 28 22 20 from");..puts("
1aa0: 20 2d 2d 70 61 73 73 70 68 72 61 73 65 2d 74 69 --passphrase-ti
1ab0: 6d 65 6f 75 74 20 3c 6d 69 6e 73 3e 20 20 20 20 meout <mins>
1ac0: 74 69 6d 65 20 62 65 66 6f 72 65 20 61 70 70 20 time before app
1ad0: 66 6f 72 67 65 74 73 20 70 61 73 73 70 68 72 61 forgets passphra
1ae0: 73 65 28 69 6e 20 6d 69 6e 75 74 65 73 29 22 29 se(in minutes)")
1af0: 3b 0a 09 70 75 74 73 28 22 20 20 2d 2d 72 65 61 ;..puts(" --rea
1b00: 64 6f 6e 6c 79 20 20 20 20 20 20 20 20 20 20 20 donly
1b10: 20 20 6f 70 65 6e 20 74 68 65 20 64 61 74 61 62 open the datab
1b20: 61 73 65 20 72 65 61 64 6f 6e 6c 79 5c 6e 5c 6e ase readonly\n\n
1b30: 22 29 3b 0a 09 70 75 74 73 28 22 52 65 70 6f 72 ");..puts("Repor
1b40: 74 20 62 75 67 73 20 74 6f 20 3c 69 76 61 6e 40 t bugs to <ivan@
1b50: 69 76 61 6e 6b 65 6c 6c 79 2e 6e 65 74 3e 22 29 ivankelly.net>")
1b60: 3b 0a 7d 0a ;.}.