From: Enrico Scholz Date: Tue, 25 Oct 2005 16:20:07 +0000 (+0000) Subject: vc_getVserverByCtx_*(): added 'validate_result' parameter to avoid X-Git-Tag: version_0_30_210~99 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79f0d2d8202c93e0d610184697cb466505c9e058;p=util-vserver.git vc_getVserverByCtx_*(): added 'validate_result' parameter to avoid recursion when called by getvserverctx() git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2182 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/lib/getvserverbyctx-compat.hc b/util-vserver/lib/getvserverbyctx-compat.hc index 9418e2f..79ceef6 100644 --- a/util-vserver/lib/getvserverbyctx-compat.hc +++ b/util-vserver/lib/getvserverbyctx-compat.hc @@ -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); diff --git a/util-vserver/lib/getvserverbyctx-v13.hc b/util-vserver/lib/getvserverbyctx-v13.hc index 7cd90a8..d9f601b 100644 --- a/util-vserver/lib/getvserverbyctx-v13.hc +++ b/util-vserver/lib/getvserverbyctx-v13.hc @@ -21,12 +21,14 @@ #endif static char * -vc_getVserverByCtx_v13(xid_t ctx, vcCfgStyle *style, char const UNUSED *revdir) +vc_getVserverByCtx_v13(xid_t ctx, vcCfgStyle *style, char const UNUSED *revdir, + bool validate_result) { char buf[128]; if (vc_get_vhi_name(ctx, vcVHI_CONTEXT, buf, sizeof buf)!=-1 && - vc_getVserverCtx(buf, vcCFG_RECENT_FULL, false, 0)==ctx) { + (!validate_result || + vc_getVserverCtx(buf, vcCFG_RECENT_FULL, false, 0)==ctx)) { if (style) *style = vcCFG_RECENT_FULL; return strdup(buf); } diff --git a/util-vserver/lib/getvserverbyctx.c b/util-vserver/lib/getvserverbyctx.c index 8ceda6f..0519f7b 100644 --- a/util-vserver/lib/getvserverbyctx.c +++ b/util-vserver/lib/getvserverbyctx.c @@ -31,11 +31,21 @@ #include "getvserverbyctx-compat.hc" #include "getvserverbyctx-v13.hc" + char * -vc_getVserverByCtx(xid_t ctx, vcCfgStyle *style, char const *revdir) +vc_getVserverByCtx_Internal(xid_t ctx, /*@null@*/vcCfgStyle *style, + /*@null@*/char const *revdir, + bool validate_result) { if (vc_isSupported(vcFEATURE_MIGRATE)) - return vc_getVserverByCtx_v13(ctx, style, revdir); + return vc_getVserverByCtx_v13(ctx, style, revdir, validate_result); else - return vc_getVserverByCtx_compat(ctx, style, revdir); + return vc_getVserverByCtx_compat(ctx, style, revdir, validate_result); +} + +char * +vc_getVserverByCtx(xid_t ctx, vcCfgStyle *style, char const *revdir) +{ + return vc_getVserverByCtx_Internal(ctx, style, revdir, true); + }