Bug fix and authoring
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 16 Dec 2015 23:06:48 +0000 (00:06 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 16 Dec 2015 23:06:48 +0000 (00:06 +0100)
Change-Id: I431915ac83727ab2cd27de37ace5015effcc7746
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
35 files changed:
src/af-db.c
src/af-db.h
src/af-launch.c
src/af-launch.h
src/af-run.c
src/af-run.h
src/af-usrd.c
src/secmgr-wrap.c
src/secmgr-wrap.h
src/utils-dir.c
src/utils-dir.h
src/utils-jbus.c
src/utils-jbus.h
src/verbose.c
src/verbose.h
src/wgt-config.c
src/wgt-config.h
src/wgt-info.c
src/wgt-info.h
src/wgt.c
src/wgt.h
src/wgtpkg-base64.c
src/wgtpkg-certs.c
src/wgtpkg-digsig.c
src/wgtpkg-files.c
src/wgtpkg-info.c
src/wgtpkg-install.c
src/wgtpkg-installer.c
src/wgtpkg-pack.c
src/wgtpkg-permissions.c
src/wgtpkg-sign.c
src/wgtpkg-workdir.c
src/wgtpkg-xmlsec.c
src/wgtpkg-zip.c
src/wgtpkg.h

index 1663b35..1977402 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index f54d807..b0002be 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index e085138..438dca6 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
@@ -154,6 +156,7 @@ int af_launch(struct af_launch_desc *desc, pid_t children[2])
                        close(spipe[1]);
                        return -1;
                }
+               assert(rc == 5);
                close(spipe[1]);
                return 0;
        }
@@ -218,11 +221,11 @@ static int launch_master(struct af_launch_desc *desc, struct launchparam *params
 {
        int rc;
        char *argv[6];
-       argv[0] = "/bin/echo";
+       argv[0] = "/usr/bin/echo";
        (void)asprintf(&argv[1], "--alias=/icons:%s", FWK_ICON_DIR);
        (void)asprintf(&argv[2], "--port=%d", params->port);
        (void)asprintf(&argv[3], "--rootdir=%s", desc->path);
-       (void)asprintf(&argv[4], "--token=%", desc->path);
+       (void)asprintf(&argv[4], "--token=%s", params->secret);
        argv[5] = NULL;
 
        rc = write(fd, &child, sizeof child);
@@ -230,7 +233,7 @@ static int launch_master(struct af_launch_desc *desc, struct launchparam *params
                ERROR("can't write master pipe: %m");
                return -1;
        }
-
+       close(fd);
        rc = execve(argv[0], argv, environ);
        ERROR("failed to exec master %s: %m", argv[0]);
        return rc;
index 253642a..301c98c 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 82a3ed2..304eead 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
@@ -315,10 +317,11 @@ int af_run_start(struct json_object *appli)
        /* insert the pid */
        runner->state = as_running;
        pgid_insert(runner);
+       rc = runner->runid;
 
        /* unblock children signal now */
        sigprocmask(SIG_SETMASK, &saved, NULL);
-       return 0;
+       return rc;
 }
 
 int af_run_terminate(int runid)
@@ -336,10 +339,10 @@ int af_run_continue(int runid)
        return killrunner(runid, SIGCONT, as_running);
 }
 
-static json_object *mkstate(struct apprun *runner, const char **runidstr)
+static json_object *mkstate(struct apprun *runner)
 {
        const char *state;
-       struct json_object *result, *obj, *runid;
+       struct json_object *result, *obj;
        int rc;
 
        /* the structure */
@@ -348,8 +351,8 @@ static json_object *mkstate(struct apprun *runner, const char **runidstr)
                goto error;
 
        /* the runid */
-       runid = json_object_new_int(runner->runid);
-       if (runid == NULL)
+       obj = json_object_new_int(runner->runid);
+       if (obj == NULL)
                goto error2;
        json_object_object_add(result, "runid", obj); /* TODO TEST STATUS */
 
@@ -380,8 +383,6 @@ static json_object *mkstate(struct apprun *runner, const char **runidstr)
        json_object_get(obj);
 
        /* done */
-       if (runidstr)
-               *runidstr = json_object_get_string(runid);
        return result;
 
 error2:
@@ -395,7 +396,7 @@ struct json_object *af_run_list()
 {
        struct json_object *result, *obj;
        struct apprun *runner;
-       const char *runidstr;
+       char runidstr[20];
        int i;
 
        /* creates the object */
@@ -408,11 +409,12 @@ struct json_object *af_run_list()
        for (i = 0 ; i < ROOT_RUNNERS_COUNT ; i++) {
                for (runner = runners_by_runid[i] ; runner ; runner = runner->next_by_runid) {
                        if (runner->state != as_terminating && runner->state != as_terminated) {
-                               obj = mkstate(runner, &runidstr);
+                               obj = mkstate(runner);
                                if (obj == NULL) {
                                        json_object_put(result);
                                        return NULL;
                                }
+                               sprintf(runidstr, "%d", runner->runid);
                                /* TODO status ? */
                                json_object_object_add(result, runidstr, obj);
                        }
@@ -428,7 +430,7 @@ struct json_object *af_run_state(int runid)
                errno = ENOENT;
                return NULL;
        }
-       return mkstate(runner, NULL);
+       return mkstate(runner);
 }
 
 /**************** INITIALISATION **********************/
index e3cd14f..1dab682 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 7697b96..6314e2a 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 996f924..57f5d20 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index b6b6890..106b1b5 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index af0bcf0..31bfd8a 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index c296d02..08736c3 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 8c144ad..a542d0b 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 1e4a033..3d71282 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index ad5d265..36d2348 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 082a9b1..cf87ba0 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index cdf501c..1fb61bc 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 480b46c..5457e57 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 816ec12..1560feb 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 50b8ed4..ace9a2d 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 980719b..db16129 100644 (file)
--- a/src/wgt.c
+++ b/src/wgt.c
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 87648ec..bd8c428 100644 (file)
--- a/src/wgt.h
+++ b/src/wgt.h
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index a1099f0..d86f75a 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index da5029c..116e637 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index a146741..e5a8d74 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index cbba052..a89c52b 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 1ed4de6..18b1118 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 4825d1c..b3e4603 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index def311c..7c27fd5 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 483ec89..e7fa752 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index a6efd2a..9dabdd0 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 0ee6a8a..7851c4a 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index d110898..e6632f4 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 6b5f646..b31a5d0 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 4984998..75cb164 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
index 52a78dc..e786f76 100644 (file)
@@ -1,6 +1,8 @@
 /*
  Copyright 2015 IoT.bzh
 
+ author: José Bollo <jose.bollo@iot.bzh>
+
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at