Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#2779 - Feature request: Display name of file in /etc/config if uci can't parse it #7584

Open
openwrt-bot opened this issue Jan 27, 2020 · 8 comments
Labels

Comments

@openwrt-bot
Copy link

richb-hanover:

In LuCI issues #3567 on Github (openwrt/luci#3567) I asked about the "uci: Entry not found" message. The problem was that there was an unusual (non-standard) file present in /etc/config

I created a feature request there (openwrt/luci#3569), but I understand that this report/request should be filed here.

Request: It would be good if that error message could include more information, perhaps the file name of the offending file. Thank you.

@openwrt-bot
Copy link
Author

adrianschmutzler:

+1

This is completely independent from Luci, and should be addressed directly in uci project most probably.

@openwrt-bot
Copy link
Author

richb-hanover:

Hi Adrian,

Thanks for thinking about this.

I'm confused, though. I filed a feature request at openwrt/luci#3569 but was told (I think) to file the request over here.

Where should this request go? Many thanks.

Rich

@openwrt-bot
Copy link
Author

adrianschmutzler:

It's okay here, as the uci system is part of OpenWrt.

@openwrt-bot
Copy link
Author

richb-hanover:

That's great. Thank you.

@openwrt-bot
Copy link
Author

@openwrt-bot
Copy link
Author

adrianschmutzler:

Will test this when I have time on device:
diff --git a/libuci.c b/libuci.c
index 140edf2..3099f20 100644
--- a/libuci.c
+++ b/libuci.c
@@ -210,12 +210,16 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
int uci_set_backend(struct uci_context *ctx, const char *name)
{
struct uci_element *e;

  •   char error_info[128];
    
      UCI_HANDLE_ERR(ctx);
      UCI_ASSERT(ctx, name != NULL);
      e = uci_lookup_list(&ctx->backends, name);
    
  •   if (!e)
    
  •           UCI_THROW(ctx, UCI_ERR_NOTFOUND);
    
  •   if (!e) {
    
  •           snprintf(error_info, sizeof(error_info) - 1, "%s: %s",
    
  •                   UCI_ERR_NOTFOUND, name);
    
  •           UCI_THROW(ctx, error_info);
    
  •   }
      ctx->backend = uci_to_backend(e);
      return 0;
    

}

@openwrt-bot
Copy link
Author

adrianschmutzler:

Looks like it's not that easy.

@openwrt-bot
Copy link
Author

adrianschmutzler:

Seems like it's more complicated:
One would have to write the name of the missing file to error_info in uci_get_errorstr(), like done fore UCI_ERR_PARSE already:
https://git.openwrt.org/?p=project/uci.git;a=blob;f=libuci.c;h=140edf2adbb0817ad89fdbb2d78984290d3017ca;hb=HEAD#l141

The problem is that the information about the requested data is not in the uci_context struct (ctx), but in an ubi_ptr struct. Definitions here:
https://git.openwrt.org/?p=project/uci.git;a=blob;f=uci.h;h=43f2052a00e6901e67cd6d1956fdb36375b41358;hb=HEAD#l396
https://git.openwrt.org/?p=project/uci.git;a=blob;f=uci.h;h=43f2052a00e6901e67cd6d1956fdb36375b41358;hb=HEAD#l396

So, one would have to create a field for the failed ptr or package string, and then write content to it for each situation where UCI_ERR_NOTFOUND is triggered. That seems to be what's done for the parsing error right now ...

This looks to me like it will require a lot of testing, and I do not have the time to implement it ATM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant