summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();