Assign default group to newly created devices
This commit is contained in:
parent
632e5b0b99
commit
59c9ec107f
|
@ -23,6 +23,9 @@
|
|||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
/* The default policy group #1 is assumed to always exist */
|
||||
#define DEFAULT_GROUP_ID 1
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
while (group_id)
|
||||
{
|
||||
|
@ -291,4 +303,3 @@ int main(int argc, char *argv[])
|
|||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue