Maapi_load_config is failing with access denied with user admin

Hi,

maapi_load_config() is failing with Access denied as it is not able to create new element with user admin
devel.log:

devel-aaa User: admin[admin] rejected data access path /oc-platform:components/component{lcd1} op create due to rule “admin/openconfig-component-access”

console output

appliance-1(config)# system database config-restore name 1.xml proceed yes
Error: access denied
Database config-restore failed.

Here, I can see only access denied but i want to know while process which path it is getting triggered.
or
How do I capture the error details above mentioned in devel.log in application and report to the user.

Point here is at application level if we know that some path is incorrect we can modify and proceed further

It would be tricky, but it can be done.

You would have to register an error formatting callback and register for receiving developer log notifications.
When access is denied, copy paste the text from the developer log notification you received to the output_str when calling confd_error_seterr(uinfo, output_str) from the error formatting callback that was invoked by ConfD.

See the ConfD UG confd_lib_dp man page section ERROR FORMATTING CALLBACK and the
In your case, the type is CONFD_ERRTYPE_MISC, and the code is CONFD_MISC_ACCESS_DENIED.
An example can be found under examples.confd/dp/error_formatting where you can, for example, add the CONFD_MISC_ACCESS_DENIED error code to that example.

For the notification part, see the confd_lib_events(3) man page (attached to the UG too). The examples.confd/misc/notifications/confd_notifications.c program is a nice example. You can test receiving developer log notifications by using the “-D” flag with that program after starting a ConfD instance.

Hi cohult,

Thanks for the update.

I tried to identify the code for example.confd/misc/notifications/confd_notifications.c and examples.confd/dp/error_formatting but I couldn’t.

Can you help me where can i get that ?

Hi Madhu,

The ConfD examples are shipped with the ConfD product installer in a separate tarball, for example, confd-7.8.3.examples.tar.gz. You can get it from where you downloaded the ConfD installer.

As a developer, these are the installation files shipped with the full version of ConfD (7.8.3 is the latest version) that you should make sure you have access to:

  • confd-7.8.3.linux.x86_64.signed.bin- The ConfD installation binary (include the C API binary and Python API binary and source code)
  • confd-7.8.3.doc.tar.gz - The documentation in PDF and HTML format.
  • confd-7.8.3.examples.tar.gz - The ConfD example set with ~150 examples.
  • confd-7.8.3.libconfd.tar.gz - the C API (libconfd) source code.
  • confd-7.8.3.java.tar.gz - the Java API JAR files, including the source code JAR.

If you run the ConfD installer with the examples, documentation, and Java API in the same directory, they will be extracted into the folder where you installed ConfD, for example, under confd-7.8.3/examples.confd, confd-7.8.3/doc, and confd-7.8.3/java.

The libconfd C-API source code tarball will not be extracted by the ConfD installer, but usually, when developing with ConfD, you extract it into a confd-7.8.3/libconfd folder.

The ConfD Kick-Start Guide is a good resource for these kinds of basics, although I may have thrown in a bit more details above.