--- /dev/null
+From: Felix Fietkau <nbd@nbd.name>
+Date: Fri, 28 Feb 2025 17:17:46 +0100
+Subject: [PATCH] uci: add support for altering the override config directory
+
+This was added to libuci recently
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -202,6 +202,11 @@ if(UCI_SUPPORT)
+ include_directories(${uci_include_dir})
+ set(LIBRARIES ${LIBRARIES} uci_lib)
+ add_library(uci_lib MODULE lib/uci.c)
++ list(APPEND CMAKE_REQUIRED_LIBRARIES ${libubox} ${libuci})
++ check_function_exists(uci_set_conf2dir HAVE_UCI_CONF2DIR)
++ if (HAVE_UCI_CONF2DIR)
++ target_compile_definitions(uci_lib PUBLIC HAVE_UCI_CONF2DIR)
++ endif()
+ set_target_properties(uci_lib PROPERTIES OUTPUT_NAME uci PREFIX "")
+ target_link_options(uci_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS})
+ target_link_libraries(uci_lib ${libuci} ${libubox})
+--- a/lib/uci.c
++++ b/lib/uci.c
+@@ -158,11 +158,13 @@ uc_uci_cursor(uc_vm_t *vm, size_t nargs)
+ {
+ uc_value_t *cdir = uc_fn_arg(0);
+ uc_value_t *sdir = uc_fn_arg(1);
++ uc_value_t *c2dir = uc_fn_arg(2);
+ struct uci_context *c;
+ int rv;
+
+ if ((cdir && ucv_type(cdir) != UC_STRING) ||
+- (sdir && ucv_type(sdir) != UC_STRING))
++ (sdir && ucv_type(sdir) != UC_STRING) ||
++ (c2dir && ucv_type(c2dir) != UC_STRING))
+ err_return(UCI_ERR_INVAL);
+
+ c = uci_alloc_context();
+@@ -184,6 +186,15 @@ uc_uci_cursor(uc_vm_t *vm, size_t nargs)
+ err_return(rv);
+ }
+
++#ifdef HAVE_UCI_CONF2DIR
++ if (c2dir) {
++ rv = uci_set_conf2dir(c, ucv_string_get(c2dir));
++
++ if (rv)
++ err_return(rv);
++ }
++#endif
++
+ ok_return(ucv_resource_create(vm, "uci.cursor", c));
+ }
+