mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 05:04:30 +02:00
Merge pull request #10147 from Icinga/Al2Klimov-patch-7
Utility::ReleaseHelper(): remove detection of EOL distros
This commit is contained in:
commit
5cc034b38f
@ -1649,37 +1649,8 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* You are using a distribution which supports LSB. */
|
|
||||||
FILE *fp = popen("type lsb_release >/dev/null 2>&1 && lsb_release -s -i 2>&1", "r");
|
|
||||||
|
|
||||||
if (fp) {
|
|
||||||
std::ostringstream msgbuf;
|
|
||||||
char line[1024];
|
|
||||||
while (fgets(line, sizeof(line), fp))
|
|
||||||
msgbuf << line;
|
|
||||||
int status = pclose(fp);
|
|
||||||
if (WEXITSTATUS(status) == 0) {
|
|
||||||
if (platformName)
|
|
||||||
*platformName = msgbuf.str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fp = popen("type lsb_release >/dev/null 2>&1 && lsb_release -s -r 2>&1", "r");
|
|
||||||
|
|
||||||
if (fp) {
|
|
||||||
std::ostringstream msgbuf;
|
|
||||||
char line[1024];
|
|
||||||
while (fgets(line, sizeof(line), fp))
|
|
||||||
msgbuf << line;
|
|
||||||
int status = pclose(fp);
|
|
||||||
if (WEXITSTATUS(status) == 0) {
|
|
||||||
if (platformVersion)
|
|
||||||
*platformVersion = msgbuf.str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* OS X */
|
/* OS X */
|
||||||
fp = popen("type sw_vers >/dev/null 2>&1 && sw_vers -productName 2>&1", "r");
|
FILE* fp = popen("type sw_vers >/dev/null 2>&1 && sw_vers -productName 2>&1", "r");
|
||||||
|
|
||||||
if (fp) {
|
if (fp) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
@ -1715,43 +1686,6 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Centos/RHEL < 7 */
|
|
||||||
release.close();
|
|
||||||
release.open("/etc/redhat-release");
|
|
||||||
if (release.is_open()) {
|
|
||||||
std::string release_line;
|
|
||||||
getline(release, release_line);
|
|
||||||
|
|
||||||
String info = release_line;
|
|
||||||
|
|
||||||
/* example: Red Hat Enterprise Linux Server release 6.7 (Santiago) */
|
|
||||||
if (platformName)
|
|
||||||
*platformName = info.SubStr(0, info.Find("release") - 1);
|
|
||||||
|
|
||||||
if (platformVersion)
|
|
||||||
*platformVersion = info.SubStr(info.Find("release") + 8);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sles 11 sp3, opensuse w/e */
|
|
||||||
release.close();
|
|
||||||
release.open("/etc/SuSE-release");
|
|
||||||
if (release.is_open()) {
|
|
||||||
std::string release_line;
|
|
||||||
getline(release, release_line);
|
|
||||||
|
|
||||||
String info = release_line;
|
|
||||||
|
|
||||||
if (platformName)
|
|
||||||
*platformName = info.SubStr(0, info.FindFirstOf(" "));
|
|
||||||
|
|
||||||
if (platformVersion)
|
|
||||||
*platformVersion = info.SubStr(info.FindFirstOf(" ") + 1);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Just give up */
|
/* Just give up */
|
||||||
return false;
|
return false;
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user