Assign default group to newly created devices
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user