X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvserver-info.c;h=824744f38382435ceaee48e873ffbf26e4f6beef;hb=148ab3024621f97b9cf95091657db2448098bc66;hp=d28bf282889ac141d4de78c1bf79ccac5f044145;hpb=3564d8678a2134185e5e6e83083de027b359ca28;p=util-vserver.git diff --git a/src/vserver-info.c b/src/vserver-info.c index d28bf28..824744f 100644 --- a/src/vserver-info.c +++ b/src/vserver-info.c @@ -185,9 +185,11 @@ verifyProc() static bool verifyCap() { + int retried = 0; struct __user_cap_header_struct header; - struct __user_cap_data_struct user; - header.version = _LINUX_CAPABILITY_VERSION; + struct __user_cap_data_struct user[2]; + + header.version = _LINUX_CAPABILITY_VERSION_3; header.pid = 0; if (getuid()!=0) { @@ -199,17 +201,24 @@ verifyCap() // perror( "prctl:" ); // return false; // } - - if (capget(&header, &user)==-1) { + +retry: + if (capget(&header, user)==-1) { + if (!retried && + header.version != _LINUX_CAPABILITY_VERSION_3) { + header.version = _LINUX_CAPABILITY_VERSION_1; + retried = 1; + goto retry; + } perror("capget()"); return false; } - user.effective = 0; - user.permitted = 0; - user.inheritable = 0; + user[0].effective = user[1].effective = 0; + user[0].permitted = user[1].permitted = 0; + user[0].inheritable = user[1].inheritable = 0; - if (capset(&header, &user)==-1) { + if (capset(&header, user)==-1) { perror("capset()"); return false; } @@ -233,6 +242,21 @@ getAPIVer(char *buf) return buf; } +static char * +getAPIConfig(char *buf) +{ + vc_vci_t v = vc_get_vci(); + size_t l; + + if (v==-1) return 0; + + l = utilvserver_fmt_xuint64(0, (unsigned int)v); + memcpy(buf, "0x0000000000000000", 19); + utilvserver_fmt_xuint64(buf+2+16-l, (unsigned int)v); + + return buf; +} + static inline char * getCtxId(char *buf, const char *pid_str, xid_t (*get_id)(pid_t pid), const char *err_str) { @@ -423,12 +447,18 @@ printSysInfo(char *buf) "Versions:\n" " Kernel: "); WRITE_STR(1, uts.release); + WRITE_MSG(1, "\n" " VS-API: "); - memset(buf, 0, 128); if (getAPIVer(buf)) WRITE_STR(1, buf); else WRITE_MSG(1, "???"); + + WRITE_MSG(1, "\n" + " VCI: "); + memset(buf, 0, 128); + if (getAPIConfig(buf)) WRITE_STR(1, buf); + else WRITE_MSG(1, "???"); WRITE_MSG(1, "\n" " util-vserver: " PACKAGE_VERSION "; " __DATE__ ", " __TIME__"\n"