Module Name:    src
Committed By:   agc
Date:           Wed May 27 05:42:25 UTC 2009

Modified Files:
        src/crypto/external/bsd/netpgp/dist/src/bin: netpgp.c
        src/crypto/external/bsd/netpgp/dist/src/lib: netpgp.c version.h

Log Message:
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".


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
    src/crypto/external/bsd/netpgp/dist/src/bin/netpgp.c
cvs rdiff -u -r1.17 -r1.18 \
    src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
cvs rdiff -u -r1.12 -r1.13 \
    src/crypto/external/bsd/netpgp/dist/src/lib/version.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/crypto/external/bsd/netpgp/dist/src/bin/netpgp.c
diff -u src/crypto/external/bsd/netpgp/dist/src/bin/netpgp.c:1.11 src/crypto/external/bsd/netpgp/dist/src/bin/netpgp.c:1.12
--- src/crypto/external/bsd/netpgp/dist/src/bin/netpgp.c:1.11	Wed May 27 00:38:26 2009
+++ src/crypto/external/bsd/netpgp/dist/src/bin/netpgp.c	Wed May 27 05:42:24 2009
@@ -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 @@
 	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 @@
 	}
 	/* 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 @@
 				"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) {

Index: src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.17 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.18
--- src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.17	Wed May 27 00:38:27 2009
+++ src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c	Wed May 27 05:42:25 2009
@@ -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 @@
 	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 @@
 
 	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 @@
 		(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 @@
 	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));

Index: src/crypto/external/bsd/netpgp/dist/src/lib/version.h
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/version.h:1.12 src/crypto/external/bsd/netpgp/dist/src/lib/version.h:1.13
--- src/crypto/external/bsd/netpgp/dist/src/lib/version.h:1.12	Wed May 27 00:38:27 2009
+++ src/crypto/external/bsd/netpgp/dist/src/lib/version.h	Wed May 27 05:42:25 2009
@@ -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 \

Reply via email to