aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-09-12 14:52:30 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-09-12 14:52:30 +0200
commit8afd46f28a677c40a482ccd18ca5568cf6c0f6aa (patch)
treecc8ad16d2cec14c1a49b31b51bc1b4510b4bda93
parent5b74cd6f2b5cdd82273759aa7d72150dfff58a2c (diff)
Avoid to exit in setting permission list
Change-Id: I623546a8c134b54f7b62b42a980f603202e42868 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/wgtpkg-installer.c8
-rw-r--r--src/wgtpkg-permissions.c7
-rw-r--r--src/wgtpkg-permissions.h2
3 files changed, 11 insertions, 6 deletions
diff --git a/src/wgtpkg-installer.c b/src/wgtpkg-installer.c
index ea08fce..792e8c2 100644
--- a/src/wgtpkg-installer.c
+++ b/src/wgtpkg-installer.c
@@ -66,7 +66,7 @@ static struct option options[] = {
/* install the widgets of the list */
int main(int ac, char **av)
{
- int i;
+ int i, rc;
struct wgt_info *ifo;
LOGAUTH(appname);
@@ -93,7 +93,11 @@ int main(int ac, char **av)
verbosity++;
break;
case 'p':
- grant_permission_list(optarg);
+ rc = grant_permission_list(optarg);
+ if (rc < 0) {
+ ERROR("Can't set granted permission list");
+ exit(1);
+ }
break;
case ':':
ERROR("missing argument value");
diff --git a/src/wgtpkg-permissions.c b/src/wgtpkg-permissions.c
index 9e061c8..6aed31f 100644
--- a/src/wgtpkg-permissions.c
+++ b/src/wgtpkg-permissions.c
@@ -94,7 +94,7 @@ void crop_permissions(unsigned level)
}
/* add permissions granted for installation */
-void grant_permission_list(const char *list)
+int grant_permission_list(const char *list)
{
struct permission *p;
char *iter, c;
@@ -109,14 +109,15 @@ void grant_permission_list(const char *list)
iter[n] = 0;
p = add_permission(iter);
if (!p) {
- ERROR("Can't allocate permission");
- exit(1);
+ errno = ENOMEM;
+ return -1;
}
p->granted = 1;
iter += n;
*iter =c;
iter += strspn(iter, separators);
}
+ return 0;
}
/* checks if the permission 'name' is recorded */
diff --git a/src/wgtpkg-permissions.h b/src/wgtpkg-permissions.h
index b052063..9a99c4c 100644
--- a/src/wgtpkg-permissions.h
+++ b/src/wgtpkg-permissions.h
@@ -19,7 +19,7 @@
extern int is_standard_permission(const char *name);
extern void reset_permissions();
extern void crop_permissions(unsigned level);
-extern void grant_permission_list(const char *list);
+extern int grant_permission_list(const char *list);
extern int permission_exists(const char *name);
extern int request_permission(const char *name);
extern const char *first_usable_permission();