From c0fc18e47e49dd4e3cc2f09452a19297dad63f9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Thu, 17 Dec 2015 00:06:48 +0100 Subject: [PATCH] Bug fix and authoring MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I431915ac83727ab2cd27de37ace5015effcc7746 Signed-off-by: José Bollo --- src/af-db.c | 2 ++ src/af-db.h | 2 ++ src/af-launch.c | 9 ++++++--- src/af-launch.h | 2 ++ src/af-run.c | 22 ++++++++++++---------- src/af-run.h | 2 ++ src/af-usrd.c | 2 ++ src/secmgr-wrap.c | 2 ++ src/secmgr-wrap.h | 2 ++ src/utils-dir.c | 2 ++ src/utils-dir.h | 2 ++ src/utils-jbus.c | 2 ++ src/utils-jbus.h | 2 ++ src/verbose.c | 2 ++ src/verbose.h | 2 ++ src/wgt-config.c | 2 ++ src/wgt-config.h | 2 ++ src/wgt-info.c | 2 ++ src/wgt-info.h | 2 ++ src/wgt.c | 2 ++ src/wgt.h | 2 ++ src/wgtpkg-base64.c | 2 ++ src/wgtpkg-certs.c | 2 ++ src/wgtpkg-digsig.c | 2 ++ src/wgtpkg-files.c | 2 ++ src/wgtpkg-info.c | 2 ++ src/wgtpkg-install.c | 2 ++ src/wgtpkg-installer.c | 2 ++ src/wgtpkg-pack.c | 2 ++ src/wgtpkg-permissions.c | 2 ++ src/wgtpkg-sign.c | 2 ++ src/wgtpkg-workdir.c | 2 ++ src/wgtpkg-xmlsec.c | 2 ++ src/wgtpkg-zip.c | 2 ++ src/wgtpkg.h | 2 ++ 35 files changed, 84 insertions(+), 13 deletions(-) diff --git a/src/af-db.c b/src/af-db.c index 1663b35..1977402 100644 --- a/src/af-db.c +++ b/src/af-db.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/af-db.h b/src/af-db.h index f54d807..b0002be 100644 --- a/src/af-db.h +++ b/src/af-db.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/af-launch.c b/src/af-launch.c index e085138..438dca6 100644 --- a/src/af-launch.c +++ b/src/af-launch.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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; diff --git a/src/af-launch.h b/src/af-launch.h index 253642a..301c98c 100644 --- a/src/af-launch.h +++ b/src/af-launch.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/af-run.c b/src/af-run.c index 82a3ed2..304eead 100644 --- a/src/af-run.c +++ b/src/af-run.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 **********************/ diff --git a/src/af-run.h b/src/af-run.h index e3cd14f..1dab682 100644 --- a/src/af-run.h +++ b/src/af-run.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/af-usrd.c b/src/af-usrd.c index 7697b96..6314e2a 100644 --- a/src/af-usrd.c +++ b/src/af-usrd.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/secmgr-wrap.c b/src/secmgr-wrap.c index 996f924..57f5d20 100644 --- a/src/secmgr-wrap.c +++ b/src/secmgr-wrap.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/secmgr-wrap.h b/src/secmgr-wrap.h index b6b6890..106b1b5 100644 --- a/src/secmgr-wrap.h +++ b/src/secmgr-wrap.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/utils-dir.c b/src/utils-dir.c index af0bcf0..31bfd8a 100644 --- a/src/utils-dir.c +++ b/src/utils-dir.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/utils-dir.h b/src/utils-dir.h index c296d02..08736c3 100644 --- a/src/utils-dir.h +++ b/src/utils-dir.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/utils-jbus.c b/src/utils-jbus.c index 8c144ad..a542d0b 100644 --- a/src/utils-jbus.c +++ b/src/utils-jbus.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/utils-jbus.h b/src/utils-jbus.h index 1e4a033..3d71282 100644 --- a/src/utils-jbus.h +++ b/src/utils-jbus.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/verbose.c b/src/verbose.c index ad5d265..36d2348 100644 --- a/src/verbose.c +++ b/src/verbose.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/verbose.h b/src/verbose.h index 082a9b1..cf87ba0 100644 --- a/src/verbose.h +++ b/src/verbose.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgt-config.c b/src/wgt-config.c index cdf501c..1fb61bc 100644 --- a/src/wgt-config.c +++ b/src/wgt-config.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgt-config.h b/src/wgt-config.h index 480b46c..5457e57 100644 --- a/src/wgt-config.h +++ b/src/wgt-config.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgt-info.c b/src/wgt-info.c index 816ec12..1560feb 100644 --- a/src/wgt-info.c +++ b/src/wgt-info.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgt-info.h b/src/wgt-info.h index 50b8ed4..ace9a2d 100644 --- a/src/wgt-info.h +++ b/src/wgt-info.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgt.c b/src/wgt.c index 980719b..db16129 100644 --- a/src/wgt.c +++ b/src/wgt.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgt.h b/src/wgt.h index 87648ec..bd8c428 100644 --- a/src/wgt.h +++ b/src/wgt.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-base64.c b/src/wgtpkg-base64.c index a1099f0..d86f75a 100644 --- a/src/wgtpkg-base64.c +++ b/src/wgtpkg-base64.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-certs.c b/src/wgtpkg-certs.c index da5029c..116e637 100644 --- a/src/wgtpkg-certs.c +++ b/src/wgtpkg-certs.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-digsig.c b/src/wgtpkg-digsig.c index a146741..e5a8d74 100644 --- a/src/wgtpkg-digsig.c +++ b/src/wgtpkg-digsig.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-files.c b/src/wgtpkg-files.c index cbba052..a89c52b 100644 --- a/src/wgtpkg-files.c +++ b/src/wgtpkg-files.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-info.c b/src/wgtpkg-info.c index 1ed4de6..18b1118 100644 --- a/src/wgtpkg-info.c +++ b/src/wgtpkg-info.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-install.c b/src/wgtpkg-install.c index 4825d1c..b3e4603 100644 --- a/src/wgtpkg-install.c +++ b/src/wgtpkg-install.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-installer.c b/src/wgtpkg-installer.c index def311c..7c27fd5 100644 --- a/src/wgtpkg-installer.c +++ b/src/wgtpkg-installer.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-pack.c b/src/wgtpkg-pack.c index 483ec89..e7fa752 100644 --- a/src/wgtpkg-pack.c +++ b/src/wgtpkg-pack.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-permissions.c b/src/wgtpkg-permissions.c index a6efd2a..9dabdd0 100644 --- a/src/wgtpkg-permissions.c +++ b/src/wgtpkg-permissions.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-sign.c b/src/wgtpkg-sign.c index 0ee6a8a..7851c4a 100644 --- a/src/wgtpkg-sign.c +++ b/src/wgtpkg-sign.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-workdir.c b/src/wgtpkg-workdir.c index d110898..e6632f4 100644 --- a/src/wgtpkg-workdir.c +++ b/src/wgtpkg-workdir.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-xmlsec.c b/src/wgtpkg-xmlsec.c index 6b5f646..b31a5d0 100644 --- a/src/wgtpkg-xmlsec.c +++ b/src/wgtpkg-xmlsec.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg-zip.c b/src/wgtpkg-zip.c index 4984998..75cb164 100644 --- a/src/wgtpkg-zip.c +++ b/src/wgtpkg-zip.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 diff --git a/src/wgtpkg.h b/src/wgtpkg.h index 52a78dc..e786f76 100644 --- a/src/wgtpkg.h +++ b/src/wgtpkg.h @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 -- 2.16.6