CHANGES 1.99.5 -> 1.99.6
+ made --homedir=d consistent with POLS. Default is $HOME/.gnupg, and if a directory is specified with --homedir=d, the directory containing conf file and keyrings is taken to be "d".
This commit is contained in:
parent
2df14e286f
commit
d70007f532
30
crypto/external/bsd/netpgp/dist/src/bin/netpgp.c
vendored
30
crypto/external/bsd/netpgp/dist/src/bin/netpgp.c
vendored
@ -30,6 +30,7 @@
|
||||
/* Command line program to perform netpgp operations */
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
@ -246,6 +247,31 @@ give_it_large(netpgp_t *netpgp)
|
||||
netpgp_setvar(netpgp, "verbose", num);
|
||||
}
|
||||
|
||||
/* set the home directory value to "home/subdir" */
|
||||
static int
|
||||
set_homedir(netpgp_t *netpgp, char *home, const char *subdir)
|
||||
{
|
||||
struct stat st;
|
||||
char d[MAXPATHLEN];
|
||||
|
||||
if (home == NULL) {
|
||||
(void) fprintf(stderr, "NULL HOME directory\n");
|
||||
return 0;
|
||||
}
|
||||
(void) snprintf(d, sizeof(d), "%s%s", home, (subdir) ? subdir : "");
|
||||
if (stat(d, &st) == 0) {
|
||||
if ((st.st_mode & S_IFMT) == S_IFDIR) {
|
||||
netpgp_setvar(netpgp, "homedir", d);
|
||||
return 1;
|
||||
}
|
||||
(void) fprintf(stderr, "netpgp: homedir \"%s\" is not a dir\n",
|
||||
d);
|
||||
return 0;
|
||||
}
|
||||
(void) fprintf(stderr, "netpgp: warning homedir \"%s\" not found\n", d);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
@ -268,7 +294,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
/* set some defaults */
|
||||
netpgp_setvar(&netpgp, "hash", DEFAULT_HASH_ALG);
|
||||
netpgp_setvar(&netpgp, "homedir", getenv("HOME"));
|
||||
set_homedir(&netpgp, getenv("HOME"), "/.gnupg");
|
||||
optindex = 0;
|
||||
while ((ch = getopt_long(argc, argv, "", options, &optindex)) != -1) {
|
||||
switch (options[optindex].val) {
|
||||
@ -334,7 +360,7 @@ main(int argc, char **argv)
|
||||
"No home directory argument provided\n");
|
||||
exit(EXIT_ERROR);
|
||||
}
|
||||
netpgp_setvar(&netpgp, "homedir", optarg);
|
||||
set_homedir(&netpgp, optarg, NULL);
|
||||
break;
|
||||
case NUMBITS:
|
||||
if (optarg == NULL) {
|
||||
|
15
crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
vendored
15
crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
vendored
@ -34,7 +34,7 @@
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
|
||||
__RCSID("$NetBSD: netpgp.c,v 1.17 2009/05/27 00:38:27 agc Exp $");
|
||||
__RCSID("$NetBSD: netpgp.c,v 1.18 2009/05/27 05:42:25 agc Exp $");
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -100,7 +100,7 @@ conffile(netpgp_t *netpgp, char *homedir, char *userid, size_t length)
|
||||
FILE *fp;
|
||||
|
||||
__OPS_USED(netpgp);
|
||||
(void) snprintf(buf, sizeof(buf), "%s/.gnupg/gpg.conf", homedir);
|
||||
(void) snprintf(buf, sizeof(buf), "%s/gpg.conf", homedir);
|
||||
if ((fp = fopen(buf, "r")) == NULL) {
|
||||
(void) fprintf(stderr, "conffile: can't open '%s'\n", buf);
|
||||
return 0;
|
||||
@ -210,8 +210,7 @@ readkeyring(netpgp_t *netpgp, const char *name)
|
||||
|
||||
homedir = netpgp_getvar(netpgp, "homedir");
|
||||
if ((filename = netpgp_getvar(netpgp, name)) == NULL) {
|
||||
(void) snprintf(f, sizeof(f), "%s/.gnupg/%s.gpg",
|
||||
homedir, name);
|
||||
(void) snprintf(f, sizeof(f), "%s/%s.gpg", homedir, name);
|
||||
filename = f;
|
||||
}
|
||||
keyring = calloc(1, sizeof(*keyring));
|
||||
@ -255,8 +254,8 @@ netpgp_init(netpgp_t *netpgp)
|
||||
(void) fprintf(stderr, "netpgp: warning: core dumps enabled\n");
|
||||
}
|
||||
if ((homedir = netpgp_getvar(netpgp, "homedir")) == NULL) {
|
||||
netpgp_setvar(netpgp, "homedir", getenv("HOME"));
|
||||
homedir = netpgp_getvar(netpgp, "homedir");
|
||||
(void) fprintf(stderr, "netpgp: bad homedir\n");
|
||||
return 0;
|
||||
}
|
||||
if ((userid = netpgp_getvar(netpgp, "userid")) == NULL) {
|
||||
(void) memset(id, 0x0, sizeof(id));
|
||||
@ -568,10 +567,10 @@ netpgp_list_packets(netpgp_t *netpgp, char *f, int armour, char *pubringname)
|
||||
char ringname[MAXPATHLEN];
|
||||
char *homedir;
|
||||
|
||||
homedir = getenv("HOME");
|
||||
homedir = netpgp_getvar(netpgp, "homedir");
|
||||
if (pubringname == NULL) {
|
||||
(void) snprintf(ringname, sizeof(ringname),
|
||||
"%s/.gnupg/pubring.gpg", homedir);
|
||||
"%s/pubring.gpg", homedir);
|
||||
pubringname = ringname;
|
||||
}
|
||||
keyring = calloc(1, sizeof(*keyring));
|
||||
|
@ -58,7 +58,7 @@
|
||||
#endif
|
||||
|
||||
/* development versions have .99 suffix */
|
||||
#define NETPGP_BASE_VERSION "1.99.5"
|
||||
#define NETPGP_BASE_VERSION "1.99.6"
|
||||
|
||||
#define NETPGP_VERSION_CAT(a, b) "NetPGP portable " a "/[" b "]"
|
||||
#define NETPGP_VERSION_STRING \
|
||||
|
Loading…
Reference in New Issue
Block a user