701-reload_config_inline.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. From: Felix Fietkau <[email protected]>
  2. Date: Fri, 26 May 2023 10:23:59 +0200
  3. Subject: [PATCH] Add ucode support, use ucode for the main ubus object #2
  4. This implements vastly improved dynamic configuration reload support.
  5. It can handle configuration changes on individual wifi interfaces, as well
  6. as adding/removing interfaces.
  7. --- a/hostapd/config_file.c
  8. +++ b/hostapd/config_file.c
  9. @@ -5207,7 +5207,12 @@ struct hostapd_config * hostapd_config_r
  10. int errors = 0;
  11. size_t i;
  12. - f = fopen(fname, "r");
  13. + if (!strncmp(fname, "data:", 5)) {
  14. + f = fmemopen((void *)(fname + 5), strlen(fname + 5), "r");
  15. + fname = "<inline>";
  16. + } else {
  17. + f = fopen(fname, "r");
  18. + }
  19. if (f == NULL) {
  20. wpa_printf(MSG_ERROR, "Could not open configuration file '%s' "
  21. "for reading.", fname);
  22. --- a/wpa_supplicant/config_file.c
  23. +++ b/wpa_supplicant/config_file.c
  24. @@ -326,8 +326,13 @@ struct wpa_config * wpa_config_read(cons
  25. while (cred_tail && cred_tail->next)
  26. cred_tail = cred_tail->next;
  27. + if (!strncmp(name, "data:", 5)) {
  28. + f = fmemopen((void *)(name + 5), strlen(name + 5), "r");
  29. + name = "<inline>";
  30. + } else {
  31. + f = fopen(name, "r");
  32. + }
  33. wpa_printf(MSG_DEBUG, "Reading configuration file '%s'", name);
  34. - f = fopen(name, "r");
  35. if (f == NULL) {
  36. wpa_printf(MSG_ERROR, "Failed to open config file '%s', "
  37. "error: %s", name, strerror(errno));