vc_getVserverByCtx_*(): added 'validate_result' parameter to avoid
[util-vserver.git] / util-vserver / lib / getvserverbyctx-compat.hc
index 9418e2f..79ceef6 100644 (file)
@@ -67,7 +67,8 @@ handleLegacy(xid_t UNUSED xid)
 #endif
 
 static char *
-vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir)
+vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir,
+                         bool validate_result)
 {
   if (revdir==0) revdir = DEFAULT_PKGSTATEREVDIR;
 
@@ -92,8 +93,10 @@ vc_getVserverByCtx_compat(xid_t ctx, vcCfgStyle *style, char const *revdir)
   switch (cur_style) {
     case vcCFG_RECENT_SHORT    :
     case vcCFG_RECENT_FULL     :
-       // check if expected ctx == actual ctx
-      if (vc_getVserverCtx(path, vcCFG_RECENT_FULL, false, 0)!=ctx) return 0;
+       // check if expected ctx == actual ctx (but only when this check is
+       // request)
+      if (validate_result &&
+         vc_getVserverCtx(path, vcCFG_RECENT_FULL, false, 0)!=ctx) return 0;
 
       if (style) *style = vcCFG_RECENT_FULL;
       return strdup(path);