summaryrefslogtreecommitdiffstats
path: root/src/afm-udb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/afm-udb.c')
-rw-r--r--src/afm-udb.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/afm-udb.c b/src/afm-udb.c
index 80cc715..24c188f 100644
--- a/src/afm-udb.c
+++ b/src/afm-udb.c
@@ -224,7 +224,6 @@ static int addunit(
{
struct json_object *priv, *pub, *id;
const char *strid;
- char *un = NULL;
size_t len;
/* create the application structure */
@@ -240,26 +239,13 @@ static int addunit(
len = strlen(unitname);
assert(len >= (sizeof service_extension - 1));
assert(!memcmp(&unitname[len - (sizeof service_extension - 1)], service_extension, sizeof service_extension));
- if (unitname[len - sizeof service_extension] == '@') {
- char buffer[40];
- size_t l = (size_t)snprintf(buffer, sizeof buffer, "%d", (int)getuid());
- un = malloc(len + l + 1);
- if (!un)
- goto error;
- memcpy(&un[0], unitname, len - (sizeof service_extension - 1));
- if (l)
- memcpy(&un[len - (sizeof service_extension - 1)], buffer, l);
- memcpy(&un[len - (sizeof service_extension - 1) + l], service_extension, sizeof service_extension);
- }
/* adds the values */
if (add_fields_of_content(priv, pub, content, length)
|| add_field(priv, pub, key_unit_path, unitpath)
- || add_field(priv, pub, key_unit_name, un ? : unitname)
+ || add_field(priv, pub, key_unit_name, unitname)
|| add_field(priv, pub, key_unit_scope, isuser ? scope_user : scope_system))
goto error;
- free(un);
- un = NULL;
/* get the id */
if (!json_object_object_get_ex(pub, key_id, &id)) {
@@ -278,7 +264,6 @@ static int addunit(
return 0;
error:
- free(un);
json_object_put(pub);
json_object_put(priv);
return -1;
@@ -486,7 +471,7 @@ error:
* 'json_object_put'.
* Returns NULL in case of error.
*/
-struct json_object *afm_udb_applications_private(struct afm_udb *afudb)
+struct json_object *afm_udb_applications_private(struct afm_udb *afudb, int uid)
{
return json_object_get(afudb->applications.prvarr);
}
@@ -497,7 +482,7 @@ struct json_object *afm_udb_applications_private(struct afm_udb *afudb)
* 'json_object_put'.
* Returns NULL in case of error.
*/
-struct json_object *afm_udb_applications_public(struct afm_udb *afudb)
+struct json_object *afm_udb_applications_public(struct afm_udb *afudb, int uid)
{
return json_object_get(afudb->applications.pubarr);
}
@@ -507,7 +492,7 @@ struct json_object *afm_udb_applications_public(struct afm_udb *afudb)
* It returns a JSON-object that must be released using 'json_object_put'.
* Returns NULL in case of error.
*/
-static struct json_object *get_no_case(struct json_object *object, const char *id)
+static struct json_object *get_no_case(struct json_object *object, const char *id, int uid)
{
struct json_object *result;
struct json_object_iter i;
@@ -529,9 +514,9 @@ static struct json_object *get_no_case(struct json_object *object, const char *i
* It returns a JSON-object that must be released using 'json_object_put'.
* Returns NULL in case of error.
*/
-struct json_object *afm_udb_get_application_private(struct afm_udb *afudb, const char *id)
+struct json_object *afm_udb_get_application_private(struct afm_udb *afudb, const char *id, int uid)
{
- return get_no_case(afudb->applications.prvobj, id);
+ return get_no_case(afudb->applications.prvobj, id, uid);
}
/*
@@ -540,9 +525,9 @@ struct json_object *afm_udb_get_application_private(struct afm_udb *afudb, const
* Returns NULL in case of error.
*/
struct json_object *afm_udb_get_application_public(struct afm_udb *afudb,
- const char *id)
+ const char *id, int uid)
{
- return get_no_case(afudb->applications.pubobj, id);
+ return get_no_case(afudb->applications.pubobj, id, uid);
}