100-os-release.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. Index: lldpd-0.7.15/src/daemon/lldpd.c
  2. ===================================================================
  3. --- lldpd-0.7.15.orig/src/daemon/lldpd.c
  4. +++ lldpd-0.7.15/src/daemon/lldpd.c
  5. @@ -736,6 +736,10 @@ lldpd_get_os_release() {
  6. fp = fopen("/usr/lib/os-release", "r");
  7. }
  8. if (!fp) {
  9. + log_debug("localchassis", "could not open /usr/lib/os-release");
  10. + fp = fopen("/etc/openwrt_release", "r");
  11. + }
  12. + if (!fp) {
  13. log_info("localchassis",
  14. "could not open either /etc/os-release or /usr/lib/os-release");
  15. return NULL;
  16. @@ -745,7 +749,8 @@ lldpd_get_os_release() {
  17. key = strtok(line, "=");
  18. val = strtok(NULL, "=");
  19. - if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0) {
  20. + if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0 ||
  21. + strncmp(key, "DISTRIB_DESCRIPTION", sizeof(line)) == 0) {
  22. strlcpy(release, val, sizeof(line));
  23. break;
  24. }
  25. @@ -755,11 +760,11 @@ lldpd_get_os_release() {
  26. /* Remove trailing newline and all " in the string. */
  27. ptr1 = release + strlen(release) - 1;
  28. while (ptr1 != release &&
  29. - ((*ptr1 == '"') || (*ptr1 == '\n'))) {
  30. + ((*ptr1 == '"') || (*ptr1 == '\n') || (*ptr1 == '\''))) {
  31. *ptr1 = '\0';
  32. ptr1--;
  33. }
  34. - if (release[0] == '"')
  35. + if (release[0] == '"' || release[0] == '\'')
  36. return release+1;
  37. return release;
  38. }