Assign default group to newly created devices

This commit is contained in:
Andreas Steffen
2013-06-25 11:49:32 +02:00
parent 632e5b0b99
commit 59c9ec107f
+12 -1
View File
@@ -23,6 +23,9 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
/* The default policy group #1 is assumed to always exist */
#define DEFAULT_GROUP_ID 1
/** /**
* global debug output variables * global debug output variables
*/ */
@@ -113,6 +116,15 @@ bool policy_start(database_t *db, int session_id)
} }
} }
/* assign a newly created device to a default group */
if (device_id && !created)
{
db->execute(db, NULL,
"INSERT INTO groups_members (device_id, group_id) "
"VALUES (?, ?)", DB_INT, device_id,
DB_INT, group_id ? group_id : DEFAULT_GROUP_ID);
}
/* get iteratively enforcements for given group */ /* get iteratively enforcements for given group */
while (group_id) while (group_id)
{ {
@@ -291,4 +303,3 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }