treewide: adjust ubus object type names
[project/rpcd.git] / sys.c
diff --git a/sys.c b/sys.c
index 2d835229fe85c1e898dcbc3b6f26638643462faf..097e7057f7daad2208a6a24f07132ebff39c66a8 100644 (file)
--- a/sys.c
+++ b/sys.c
@@ -88,6 +88,7 @@ rpc_cgi_password_set(struct ubus_context *ctx, struct ubus_object *obj,
        ssize_t n;
        int ret;
        const char *const passwd = "/bin/passwd";
+       const struct timespec ts = {0, 100 * 1000 * 1000};
 
        blobmsg_parse(rpc_password_policy, __RPC_P_MAX, tb,
                      blob_data(msg), blob_len(msg));
@@ -145,8 +146,7 @@ rpc_cgi_password_set(struct ubus_context *ctx, struct ubus_object *obj,
                if (n < 0)
                        return rpc_errno_status();
 
-               const struct timespec req = {0, 100 * 1000 * 1000};
-               nanosleep(&req, NULL);
+               nanosleep(&ts, NULL);
 
                n = write(fds[1], blobmsg_data(tb[RPC_P_PASSWORD]),
                              blobmsg_data_len(tb[RPC_P_PASSWORD]) - 1);
@@ -228,6 +228,18 @@ procstr:
                        continue;
                }
 
+               /* If there is ABIVersion, remove that suffix */
+               if (!strcmp(var, "ABIVersion:")) {
+                       if (strlen(pkg) <= strlen(p1))
+                               continue;
+                       tmp = &pkg[strlen(pkg) - strlen(p1)];
+                       if (strncmp(p1, tmp, strlen(p1)))
+                               continue;
+
+                       *tmp = '\0';
+                       continue;
+               }
+
                if (!strcmp(var, "Version:")) {
                        strncpy(ver, p1, sizeof(ver));
                        continue;
@@ -343,7 +355,7 @@ rpc_sys_api_init(const struct rpc_daemon_ops *o, struct ubus_context *ctx)
        };
 
        static struct ubus_object_type sys_type =
-               UBUS_OBJECT_TYPE("luci-rpc-sys", sys_methods);
+               UBUS_OBJECT_TYPE("rpcd-plugin-sys", sys_methods);
 
        static struct ubus_object obj = {
                .name = "rpc-sys",