Merge pull request #10147 from Icinga/Al2Klimov-patch-7

Utility::ReleaseHelper(): remove detection of EOL distros
This commit is contained in:
Yonas Habteab 2024-09-05 09:27:51 +02:00 committed by GitHub
commit 5cc034b38f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 67 deletions

View File

@ -1649,37 +1649,8 @@ static bool ReleaseHelper(String *platformName, String *platformVersion)
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 */
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) {
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 */
return false;
#endif /* _WIN32 */