Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Revert "afm-unit: add autoapi in required-api feature""
[src/app-framework-main.git]
/
src
/
wgtpkg-permissions.c
diff --git
a/src/wgtpkg-permissions.c
b/src/wgtpkg-permissions.c
index
c341054
..
62381bb
100644
(file)
--- a/
src/wgtpkg-permissions.c
+++ b/
src/wgtpkg-permissions.c
@@
-1,5
+1,5
@@
/*
/*
- Copyright
2015
IoT.bzh
+ Copyright
(C) 2015-2018
IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
author: José Bollo <jose.bollo@iot.bzh>
@@
-32,18
+32,10
@@
struct permission {
unsigned level: 3;
};
unsigned level: 3;
};
-static const char prefix_of_permissions[] = FWK_PREFIX_PERMISSION;
-
static unsigned int nrpermissions = 0;
static struct permission *permissions = NULL;
static unsigned int indexiter = 0;
static unsigned int nrpermissions = 0;
static struct permission *permissions = NULL;
static unsigned int indexiter = 0;
-/* check is the name has the correct prefix for permissions */
-int is_standard_permission(const char *name)
-{
- return 0 == memcmp(name, prefix_of_permissions, sizeof(prefix_of_permissions) - 1);
-}
-
/* retrieves the permission of name */
static struct permission *get_permission(const char *name)
{
/* retrieves the permission of name */
static struct permission *get_permission(const char *name)
{
@@
-137,13
+129,25
@@
int permission_exists(const char *name)
/* request the permission, returns 1 if granted or 0 otherwise */
int request_permission(const char *name)
{
/* request the permission, returns 1 if granted or 0 otherwise */
int request_permission(const char *name)
{
+#define HACK_ALLOWING_REQUESTED_PERMISSIONS 1
+
struct permission *p = get_permission(name);
struct permission *p = get_permission(name);
+
+#if defined(HACK_ALLOWING_REQUESTED_PERMISSIONS) && HACK_ALLOWING_REQUESTED_PERMISSIONS
+ if (!p)
+ p = add_permission(name);
+#endif
if (p) {
if (p) {
+#if defined(HACK_ALLOWING_REQUESTED_PERMISSIONS) && HACK_ALLOWING_REQUESTED_PERMISSIONS
+ p->granted = 1;
+#endif
p->requested = 1;
if (p->granted)
return 1;
}
return 0;
p->requested = 1;
if (p->granted)
return 1;
}
return 0;
+
+#undef HACK_ALLOWING_REQUESTED_PERMISSIONS
}
/* iteration over granted and requested permissions */
}
/* iteration over granted and requested permissions */