# HG changeset patch # User Wolfgang Rosenauer # Date 1323377740 -3600 # Node ID 98d01e6fd2bdcdee8928fe609c60dbdd8fbdabec # Parent 262e1fb001a87eda37f8bd74631c02eadb278680 $HOME/.pki/nssdb is now considered automatically if /etc/pki/nssdb does not exist diff -r 262e1fb001a8 -r 98d01e6fd2bd configure.ac --- a/configure.ac Fri Jul 09 09:55:01 2010 +0200 +++ b/configure.ac Thu Dec 08 21:55:40 2011 +0100 @@ -8,7 +8,7 @@ dnl --- Package configuration --- -AM_INIT_AUTOMAKE(nss-shared-helper, 1.0.9) +AM_INIT_AUTOMAKE(nss-shared-helper, 1.0.10) AM_CONFIG_HEADER(config.h) AC_SUBST(VERSION) diff -r 262e1fb001a8 -r 98d01e6fd2bd nss-shared-helper/db.c --- a/nss-shared-helper/db.c Fri Jul 09 09:55:01 2010 +0200 +++ b/nss-shared-helper/db.c Thu Dec 08 21:55:40 2011 +0100 @@ -3,7 +3,7 @@ /* db.c - Helper funcs for shared NSS database * * Copyright (C) 2008 Hans Petter Jansson - * 2008-2010 Wolfgang Rosenauer + * 2008-2011 Wolfgang Rosenauer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,7 +20,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Authors: Hans Petter Jansson + * Authors: Hans Petter Jansson * Wolfgang Rosenauer */ #include @@ -56,34 +56,32 @@ { const char *env; char *path; + char system_path[] = DEFAULT_PATH; struct stat sbuf; int result; env = getenv ("NSS_SHARED_DB_PATH"); - + + /* + * 1. use env NSS_SHARED_DB_PATH + * 2. try /etc/pki/nssdb + * 3. use $HOME/.pki/nssdb + */ if (env && *env) { path = strdup (env); } else { - /* env = getenv ("HOME"); - if (!env || !*env) + if (env && *env) { - fprintf (stderr, "*** nss-shared-helper: Could not determine shared NSS DB path!\n"); - return NULL; + path = malloc (strlen (env) + 1 + strlen (DEFAULT_RELATIVE_PATH) + 1); + strcpy (path, env); + strcat (path, "/"); + strcat (path, DEFAULT_RELATIVE_PATH); } - - path = malloc (strlen (env) + 1 + strlen (DEFAULT_RELATIVE_PATH) + 1); - strcpy (path, env); - strcat (path, "/"); - strcat (path, DEFAULT_RELATIVE_PATH); - */ - path = strdup(DEFAULT_PATH); } /* Create path if it doesn't exist */ - result = stat (path, &sbuf); - if (result != 0) { const char *p0 = path; @@ -112,11 +110,14 @@ p0 = p1 + 1; } while (*p1 != '\0'); - - result = stat (path, &sbuf); } - if (result == 0 && S_ISDIR (sbuf.st_mode)) + /* /etc/pki/nssdb */ + if (stat(system_path, &sbuf) == 0 && S_ISDIR (sbuf.st_mode)) + return system_path; + + /* $HOME/.pki/nssdb */ + if (stat(path, &sbuf) == 0 && S_ISDIR (sbuf.st_mode)) return path; free (path); @@ -136,7 +137,7 @@ if (!getenv ("NSS_USE_SHARED_DB")) { - fprintf (stderr, "*** nss-shared-helper: Shared database disabled (set NSS_USE_SHARED_DB to enable).\n"); + //fprintf (stderr, "*** nss-shared-helper: Shared database disabled (set NSS_USE_SHARED_DB to enable).\n"); rv = NSS_Initialize (old_path, "", "", "secmod.db",