tgINITPID, tgINITPID_PID,
tgXID, tgUTS, tgSYSINFO,
tgFEATURE, tgCANONIFY,
- tgVERIFYCAP, tgXIDTYPE,
+ tgVERIFYCAP, tgXIDTYPE, tgVERIFYPROC,
} VserverTag;
static struct {
{ "PXID", tgPXID, "returns the xid of the parent context" },
{ "CANONIFY", tgCANONIFY, "canonifies the vserver-name and removes dangerous characters" },
{ "VERIFYCAP", tgVERIFYCAP, "test if the kernel supports linux capabilities" },
+ { "VERIFYPROC", tgVERIFYPROC, "test if /proc can be read by contexts!=0" },
{ "XIDTYPE", tgXIDTYPE, "returns the type of the given XID" },
};
}
static bool
+verifyProc()
+{
+ char const *errptr;
+
+ if (!switchToWatchXid(&errptr)) {
+ perror(errptr);
+ return false;
+ }
+
+ if (access("/proc/uptime", R_OK)==-1) {
+ if (errno!=ENOENT)
+ perror("access(\"/proc/uptime\")");
+
+ return false;
+ }
+
+ return true;
+}
+
+static bool
verifyCap()
{
struct __user_cap_header_struct header;
static bool
str2bool(char const *str)
{
- return atoi(str)!=0 || strchr("yYtY", str[0])!=0 || strcasecmp("true", str)==0;
+ return atoi(str)!=0 || strchr("yYtT", str[0])!=0 || strcasecmp("true", str)==0;
}
static int
res = vc_getVserverAppDir(vserver, vcCFG_AUTO, argc==0 ? "" : argv[0]);
break;
- case tgRUNNING :
- res = (vc_getVserverCtx(vserver, vcCFG_AUTO, false, 0)==VC_NOCTX) ? 0 : "1";
+ case tgRUNNING : {
+ signed long xid; // type is a small hack, but should be ok...
+ struct vc_vx_info info;
+
+ if (isNumber(vserver, &xid) && xid>=0)
+ res = (vc_get_vx_info(xid, &info)==-1) ? 0 : "1";
+ else
+ res = (vc_getVserverCtx(vserver, vcCFG_AUTO, false, 0)==VC_NOCTX) ? 0 : "1";
+
break;
+ }
case tgCANONIFY :
strcpy(buf, vserver);
case tgSYSINFO : return printSysInfo(buf); break;
case tgFEATURE : return testFeature(argc,argv); break;
case tgVERIFYCAP : return verifyCap() ? 0 : 1; break;
+ case tgVERIFYPROC : return verifyProc() ? 0 : 1; break;
default : {