74fc46
diff -up nss/lib/pk11wrap/pk11pars.c.check_policy_file nss/lib/pk11wrap/pk11pars.c
74fc46
--- nss/lib/pk11wrap/pk11pars.c.check_policy_file	2017-02-28 10:49:53.811343156 +0100
74fc46
+++ nss/lib/pk11wrap/pk11pars.c	2017-02-28 10:59:41.178647490 +0100
74fc46
@@ -109,6 +109,7 @@ secmod_NewModule(void)
74fc46
                                                  *other flags are set */
74fc46
 #define SECMOD_FLAG_MODULE_DB_SKIP_FIRST 0x02
74fc46
 #define SECMOD_FLAG_MODULE_DB_DEFAULT_MODDB 0x04
74fc46
+#define SECMOD_FLAG_MODULE_DB_POLICY_ONLY 0x08
74fc46
 
74fc46
 /* private flags for internal (field in SECMODModule). */
74fc46
 /* The meaing of these flags is as follows:
74fc46
@@ -704,6 +705,9 @@ SECMOD_CreateModuleEx(const char *librar
74fc46
         if (NSSUTIL_ArgHasFlag("flags", "defaultModDB", nssc)) {
74fc46
             flags |= SECMOD_FLAG_MODULE_DB_DEFAULT_MODDB;
74fc46
         }
74fc46
+	if (NSSUTIL_ArgHasFlag("flags", "policyOnly", nssc)) {
74fc46
+	    flags |= SECMOD_FLAG_MODULE_DB_POLICY_ONLY;
74fc46
+	}
74fc46
         /* additional moduleDB flags could be added here in the future */
74fc46
         mod->isModuleDB = (PRBool)flags;
74fc46
     }
74fc46
@@ -744,6 +748,14 @@ SECMOD_GetDefaultModDBFlag(SECMODModule
74fc46
 }
74fc46
 
74fc46
 PRBool
74fc46
+secmod_PolicyOnly(SECMODModule *mod)
74fc46
+{
74fc46
+   char flags = (char) mod->isModuleDB;
74fc46
+
74fc46
+   return (flags & SECMOD_FLAG_MODULE_DB_POLICY_ONLY) ? PR_TRUE : PR_FALSE;
74fc46
+}
74fc46
+
74fc46
+PRBool
74fc46
 secmod_IsInternalKeySlot(SECMODModule *mod)
74fc46
 {
74fc46
     char flags = (char)mod->internal;
74fc46
@@ -1661,6 +1673,12 @@ SECMOD_LoadModule(char *modulespec, SECM
74fc46
     if (!module) {
74fc46
         goto loser;
74fc46
     }
74fc46
+
74fc46
+    /* a policy only stanza doesn't actually get 'loaded'. policy has already
74fc46
+     * been parsed as a side effect of the CreateModuleEx call */
74fc46
+    if (secmod_PolicyOnly(module)) {
74fc46
+	return module;
74fc46
+    }
74fc46
     if (parent) {
74fc46
         module->parent = SECMOD_ReferenceModule(parent);
74fc46
         if (module->internal && secmod_IsInternalKeySlot(parent)) {