Introduced workitems to Attestation IMV
This commit is contained in:
@@ -262,6 +262,12 @@ INSERT INTO files ( /* 5 */
|
||||
'openssl', 8
|
||||
);
|
||||
|
||||
INSERT INTO files ( /* 6 */
|
||||
name, dir
|
||||
) VALUES (
|
||||
'tnc_config', 2
|
||||
);
|
||||
|
||||
/* Algorithms */
|
||||
|
||||
INSERT INTO algorithms (
|
||||
@@ -639,15 +645,40 @@ INSERT INTO policies ( /* 7 */
|
||||
INSERT INTO policies ( /* 8 */
|
||||
type, name, rec_fail, rec_noresult
|
||||
) VALUES (
|
||||
9, 'No Open TCP Ports', 1, 1
|
||||
11, 'No Open TCP Ports', 1, 1
|
||||
);
|
||||
|
||||
INSERT INTO policies ( /* 9 */
|
||||
type, name, rec_fail, rec_noresult
|
||||
) VALUES (
|
||||
10, 'No Open UDP Ports', 1, 1
|
||||
12, 'No Open UDP Ports', 1, 1
|
||||
);
|
||||
|
||||
INSERT INTO policies ( /* 10 */
|
||||
type, name, file, rec_fail, rec_noresult
|
||||
) VALUES (
|
||||
7, 'Metadata of /etc/tnc_config', 6, 0, 0
|
||||
);
|
||||
|
||||
INSERT INTO policies ( /* 11 */
|
||||
type, name, dir, rec_fail, rec_noresult
|
||||
) VALUES (
|
||||
8, 'Measure as reference /bin', 1, 0, 0
|
||||
);
|
||||
|
||||
INSERT INTO policies ( /* 12 */
|
||||
type, name, file, rec_fail, rec_noresult
|
||||
) VALUES (
|
||||
6, 'Measure /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0', 2, 2, 2
|
||||
);
|
||||
|
||||
INSERT INTO policies ( /* 13 */
|
||||
type, name, file, rec_fail, rec_noresult
|
||||
) VALUES (
|
||||
6, 'Measure /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0', 4, 2, 2
|
||||
);
|
||||
|
||||
|
||||
/* Enforcements */
|
||||
|
||||
INSERT INTO enforcements (
|
||||
@@ -713,13 +744,13 @@ INSERT INTO enforcements (
|
||||
INSERT INTO enforcements (
|
||||
policy, group_id, max_age
|
||||
) VALUES (
|
||||
5, 2, 86400
|
||||
5, 4, 86400
|
||||
);
|
||||
|
||||
INSERT INTO enforcements (
|
||||
policy, group_id, max_age
|
||||
) VALUES (
|
||||
6, 2, 86400
|
||||
6, 4, 86400
|
||||
);
|
||||
|
||||
INSERT INTO enforcements (
|
||||
@@ -788,3 +819,27 @@ INSERT INTO enforcements (
|
||||
9, 5, 60
|
||||
);
|
||||
|
||||
INSERT INTO enforcements (
|
||||
policy, group_id, max_age
|
||||
) VALUES (
|
||||
10, 2, 60
|
||||
);
|
||||
|
||||
INSERT INTO enforcements (
|
||||
policy, group_id, max_age
|
||||
) VALUES (
|
||||
11, 2, 86400
|
||||
);
|
||||
|
||||
INSERT INTO enforcements (
|
||||
policy, group_id, max_age
|
||||
) VALUES (
|
||||
12, 2, 86400
|
||||
);
|
||||
|
||||
INSERT INTO enforcements (
|
||||
policy, group_id, max_age
|
||||
) VALUES (
|
||||
13, 2, 86400
|
||||
);
|
||||
|
||||
|
||||
@@ -285,6 +285,7 @@ static bool delete_connection(private_imv_agent_t *this, TNC_ConnectionID id)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
imv_state_t *state;
|
||||
imv_session_t *session;
|
||||
bool found = FALSE;
|
||||
|
||||
this->connection_lock->write_lock(this->connection_lock);
|
||||
@@ -294,6 +295,11 @@ static bool delete_connection(private_imv_agent_t *this, TNC_ConnectionID id)
|
||||
if (id == state->get_connection_id(state))
|
||||
{
|
||||
found = TRUE;
|
||||
session = state->get_session(state);
|
||||
if (session)
|
||||
{
|
||||
imcv_db->remove_session(imcv_db, session);
|
||||
}
|
||||
state->destroy(state);
|
||||
this->connections->remove_at(this->connections, enumerator);
|
||||
break;
|
||||
@@ -480,7 +486,7 @@ METHOD(imv_agent_t, create_state, TNC_Result,
|
||||
|
||||
if (imcv_db)
|
||||
{
|
||||
session = imcv_db->get_session(imcv_db, conn_id, ar_id_type, ar_id_value);
|
||||
session = imcv_db->add_session(imcv_db, conn_id, ar_id_type, ar_id_value);
|
||||
if (session)
|
||||
{
|
||||
DBG2(DBG_IMV, " assigned session ID %d",
|
||||
|
||||
@@ -59,7 +59,7 @@ struct private_imv_database_t {
|
||||
|
||||
};
|
||||
|
||||
METHOD(imv_database_t, get_session, imv_session_t*,
|
||||
METHOD(imv_database_t, add_session, imv_session_t*,
|
||||
private_imv_database_t *this, TNC_ConnectionID conn_id,
|
||||
u_int32_t ar_id_type, chunk_t ar_id_value)
|
||||
{
|
||||
@@ -123,6 +123,26 @@ METHOD(imv_database_t, get_session, imv_session_t*,
|
||||
return session;
|
||||
}
|
||||
|
||||
METHOD(imv_database_t, remove_session, void,
|
||||
private_imv_database_t *this, imv_session_t *session)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
imv_session_t *current;
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->sessions->create_enumerator(this->sessions);
|
||||
while (enumerator->enumerate(enumerator, ¤t))
|
||||
{
|
||||
if (current == session)
|
||||
{
|
||||
this->sessions->remove_at(this->sessions, enumerator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
}
|
||||
|
||||
METHOD(imv_database_t, add_product, int,
|
||||
private_imv_database_t *this, imv_session_t *session, char *product)
|
||||
{
|
||||
@@ -204,10 +224,9 @@ METHOD(imv_database_t, policy_script, bool,
|
||||
{
|
||||
imv_workitem_t *workitem;
|
||||
imv_workitem_type_t type;
|
||||
imv_session_t *current;
|
||||
int id, session_id, rec_fail, rec_noresult;
|
||||
enumerator_t *enumerator, *e;
|
||||
char command[512], resp[128], *last, *argument;
|
||||
int id, session_id, arg_int, rec_fail, rec_noresult;
|
||||
enumerator_t *e;
|
||||
char command[512], resp[128], *last, *arg_str;
|
||||
FILE *shell;
|
||||
|
||||
session_id = session->get_session_id(session);
|
||||
@@ -250,17 +269,18 @@ METHOD(imv_database_t, policy_script, bool,
|
||||
{
|
||||
/* get workitem list generated by policy manager */
|
||||
e = this->db->query(this->db,
|
||||
"SELECT id, type, argument, rec_fail, rec_noresult "
|
||||
"FROM workitems WHERE session = ?",
|
||||
DB_INT, session_id, DB_INT, DB_INT, DB_TEXT, DB_INT, DB_INT);
|
||||
"SELECT id, type, arg_str, arg_int, rec_fail, rec_noresult "
|
||||
"FROM workitems WHERE session = ?", DB_INT, session_id,
|
||||
DB_INT, DB_INT, DB_TEXT, DB_INT,DB_INT, DB_INT);
|
||||
if (!e)
|
||||
{
|
||||
DBG1(DBG_IMV, "no workitem enumerator returned");
|
||||
return FALSE;
|
||||
}
|
||||
while (e->enumerate(e, &id, &type, &argument, &rec_fail, &rec_noresult))
|
||||
while (e->enumerate(e, &id, &type, &arg_str, &arg_int, &rec_fail,
|
||||
&rec_noresult))
|
||||
{
|
||||
workitem = imv_workitem_create(id, type, argument, rec_fail,
|
||||
workitem = imv_workitem_create(id, type, arg_str, arg_int, rec_fail,
|
||||
rec_noresult);
|
||||
session->insert_workitem(session, workitem);
|
||||
}
|
||||
@@ -270,20 +290,6 @@ METHOD(imv_database_t, policy_script, bool,
|
||||
}
|
||||
else if (!start && session->get_policy_started(session))
|
||||
{
|
||||
/* remove session */
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator = this->sessions->create_enumerator(this->sessions);
|
||||
while (enumerator->enumerate(enumerator, ¤t))
|
||||
{
|
||||
if (current == session)
|
||||
{
|
||||
this->sessions->remove_at(this->sessions, enumerator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
this->mutex->unlock(this->mutex);
|
||||
|
||||
session->set_policy_started(session, FALSE);
|
||||
}
|
||||
|
||||
@@ -329,7 +335,8 @@ imv_database_t *imv_database_create(char *uri, char *script)
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.get_session = _get_session,
|
||||
.add_session = _add_session,
|
||||
.remove_session = _remove_session,
|
||||
.add_product = _add_product,
|
||||
.add_device = _add_device,
|
||||
.add_recommendation = _add_recommendation,
|
||||
|
||||
@@ -44,10 +44,17 @@ struct imv_database_t {
|
||||
* @param ar_id_value Access Requestor identity value
|
||||
* @return Session associated with TNCCS Connection
|
||||
*/
|
||||
imv_session_t* (*get_session)(imv_database_t *this,
|
||||
imv_session_t* (*add_session)(imv_database_t *this,
|
||||
TNC_ConnectionID conn_id,
|
||||
u_int32_t ar_id_type, chunk_t ar_id_value);
|
||||
|
||||
/**
|
||||
* Remove and delete a session
|
||||
*
|
||||
* @param session Session
|
||||
*/
|
||||
void (*remove_session)(imv_database_t *this, imv_session_t *session);
|
||||
|
||||
/**
|
||||
* Add product information string to a session database entry
|
||||
*
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
/**
|
||||
* global debug output variables
|
||||
*/
|
||||
static int debug_level = 2;
|
||||
static int debug_level = 1;
|
||||
static bool stderr_quiet = FALSE;
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ bool policy_start(database_t *db, int session_id)
|
||||
{
|
||||
enumerator_t *e;
|
||||
int id, gid, device_id, product_id, group_id = 0;
|
||||
int type, rec_fail, rec_noresult;
|
||||
int type, file, dir, arg_int, rec_fail, rec_noresult;
|
||||
char *argument;
|
||||
|
||||
/* get session data */
|
||||
@@ -107,22 +107,41 @@ bool policy_start(database_t *db, int session_id)
|
||||
|
||||
/* get enforcements for given group */
|
||||
e = db->query(db,
|
||||
"SELECT e.id, p.type, p.argument, p.rec_fail, p.rec_noresult "
|
||||
"SELECT e.id, "
|
||||
"p.type, p.argument, p.file, p.dir, p.rec_fail, p.rec_noresult "
|
||||
"FROM enforcements AS e JOIN policies as p ON e.policy = p.id "
|
||||
"WHERE e.group_id = ?",
|
||||
DB_INT, group_id, DB_INT, DB_INT, DB_TEXT, DB_INT, DB_INT);
|
||||
"WHERE e.group_id = ?", DB_INT, group_id,
|
||||
DB_INT, DB_INT, DB_TEXT, DB_INT, DB_INT, DB_INT, DB_INT);
|
||||
if (!e)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
while (e->enumerate(e, &id, &type, &argument, &rec_fail, &rec_noresult))
|
||||
while (e->enumerate(e, &id, &type, &argument, &file, &dir, &rec_fail,
|
||||
&rec_noresult))
|
||||
{
|
||||
/* determine arg_int */
|
||||
switch ((imv_workitem_type_t)type)
|
||||
{
|
||||
case IMV_WORKITEM_FILE_REF_MEAS:
|
||||
case IMV_WORKITEM_FILE_MEAS:
|
||||
case IMV_WORKITEM_FILE_META:
|
||||
arg_int = file;
|
||||
break;
|
||||
case IMV_WORKITEM_DIR_REF_MEAS:
|
||||
case IMV_WORKITEM_DIR_MEAS:
|
||||
case IMV_WORKITEM_DIR_META:
|
||||
arg_int = dir;
|
||||
break;
|
||||
default:
|
||||
arg_int = 0;
|
||||
}
|
||||
|
||||
/* insert a workitem */
|
||||
if (db->execute(db, NULL,
|
||||
"INSERT INTO workitems (session, enforcement, type, argument, "
|
||||
"rec_fail, rec_noresult) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
"INSERT INTO workitems (session, enforcement, type, arg_str, "
|
||||
"arg_int, rec_fail, rec_noresult) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
DB_INT, session_id, DB_INT, id, DB_INT, type, DB_TEXT, argument,
|
||||
DB_INT, rec_fail, DB_INT, rec_noresult) != 1)
|
||||
DB_INT, arg_int, DB_INT, rec_fail, DB_INT, rec_noresult) != 1)
|
||||
{
|
||||
e->destroy(e);
|
||||
fprintf(stderr, "could not insert workitem\n");
|
||||
@@ -139,7 +158,6 @@ bool policy_stop(database_t *db, int session_id)
|
||||
enumerator_t *e;
|
||||
int rec, policy;
|
||||
char *result;
|
||||
bool no_worklists = TRUE;
|
||||
|
||||
e = db->query(db,
|
||||
"SELECT w.rec_final, w.result, e.policy FROM workitems AS w "
|
||||
@@ -150,24 +168,16 @@ bool policy_stop(database_t *db, int session_id)
|
||||
{
|
||||
while (e->enumerate(e, &rec, &result, &policy))
|
||||
{
|
||||
no_worklists = FALSE;
|
||||
|
||||
/* insert result */
|
||||
db->execute(db, NULL,
|
||||
"INSERT INTO results (session, policy, rec, result) "
|
||||
"VALUES (?, ?, ?, ?)", DB_INT, session_id, DB_INT, policy,
|
||||
DB_INT, rec, DB_TEXT, result);
|
||||
}
|
||||
e->destroy(e);
|
||||
|
||||
if (no_worklists)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return db->execute(db, NULL,
|
||||
"DELETE FROM workitems WHERE session = ?",
|
||||
DB_UINT, session_id) > 0;
|
||||
DB_UINT, session_id) >= 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -224,6 +234,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* attach IMV database */
|
||||
uri = lib->settings->get_str(lib->settings, "libimcv.database", NULL);
|
||||
if (!uri)
|
||||
{
|
||||
fprintf(stderr, "database uri not defined.\n");
|
||||
exit(SS_RC_INITIALIZATION_FAILED);
|
||||
}
|
||||
|
||||
db = lib->db->create(lib->db, uri);
|
||||
if (!db)
|
||||
{
|
||||
|
||||
@@ -79,6 +79,20 @@ struct imv_state_t {
|
||||
*/
|
||||
u_int32_t (*get_max_msg_len)(imv_state_t *this);
|
||||
|
||||
/**
|
||||
* Set flags for completed actions
|
||||
*
|
||||
* @param flags Flags to be set
|
||||
*/
|
||||
void (*set_action_flags)(imv_state_t *this, u_int32_t flags);
|
||||
|
||||
/**
|
||||
* Get flags set for completed actions
|
||||
*
|
||||
* @return Flags set for completed actions
|
||||
*/
|
||||
u_int32_t (*get_action_flags)(imv_state_t *this);
|
||||
|
||||
/**
|
||||
* Set Access Requestor ID
|
||||
*
|
||||
|
||||
@@ -27,8 +27,10 @@ ENUM(imv_workitem_type_names, IMV_WORKITEM_PACKAGES, IMV_WORKITEM_UDP_SCAN,
|
||||
"PWDEN",
|
||||
"FREFM",
|
||||
"FMEAS",
|
||||
"FMETA",
|
||||
"DREFM",
|
||||
"DMEAS",
|
||||
"DMETA",
|
||||
"TCPSC",
|
||||
"UDPSC"
|
||||
);
|
||||
@@ -62,7 +64,12 @@ struct private_imv_workitem_t {
|
||||
/**
|
||||
* Argument string
|
||||
*/
|
||||
char *argument;
|
||||
char *arg_str;
|
||||
|
||||
/**
|
||||
* Argument integer
|
||||
*/
|
||||
int arg_int;
|
||||
|
||||
/**
|
||||
* Result string
|
||||
@@ -110,10 +117,16 @@ METHOD(imv_workitem_t, get_type, imv_workitem_type_t,
|
||||
return this->type;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, get_argument, char*,
|
||||
METHOD(imv_workitem_t, get_arg_str, char*,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
return this->argument;
|
||||
return this->arg_str;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, get_arg_int, int,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
return this->arg_int;
|
||||
}
|
||||
|
||||
METHOD(imv_workitem_t, set_result, TNC_IMV_Action_Recommendation,
|
||||
@@ -135,9 +148,10 @@ METHOD(imv_workitem_t, set_result, TNC_IMV_Action_Recommendation,
|
||||
this->rec_final = this->rec_noresult;
|
||||
break;
|
||||
}
|
||||
DBG2(DBG_IMV, "workitem %N: %N%s%s", imv_workitem_type_names, this->type,
|
||||
TNC_IMV_Action_Recommendation_names, this->rec_final,
|
||||
strlen(result) ? " - " : "", result);
|
||||
DBG2(DBG_IMV, "IMV %d handled %N workitem %d: %N%s%s", this->imv_id,
|
||||
imv_workitem_type_names, this->type, this->id,
|
||||
TNC_IMV_Action_Recommendation_names, this->rec_final,
|
||||
strlen(result) ? " - " : "", result);
|
||||
|
||||
return this->rec_final;
|
||||
}
|
||||
@@ -155,7 +169,7 @@ METHOD(imv_workitem_t, get_result, TNC_IMV_Action_Recommendation,
|
||||
METHOD(imv_workitem_t, destroy, void,
|
||||
private_imv_workitem_t *this)
|
||||
{
|
||||
free(this->argument);
|
||||
free(this->arg_str);
|
||||
free(this->result);
|
||||
free(this);
|
||||
}
|
||||
@@ -164,7 +178,7 @@ METHOD(imv_workitem_t, destroy, void,
|
||||
* See header
|
||||
*/
|
||||
imv_workitem_t *imv_workitem_create(int id, imv_workitem_type_t type,
|
||||
char *argument,
|
||||
char *arg_str, int arg_int,
|
||||
TNC_IMV_Action_Recommendation rec_fail,
|
||||
TNC_IMV_Action_Recommendation rec_noresult)
|
||||
{
|
||||
@@ -176,7 +190,8 @@ imv_workitem_t *imv_workitem_create(int id, imv_workitem_type_t type,
|
||||
.set_imv_id = _set_imv_id,
|
||||
.get_imv_id = _get_imv_id,
|
||||
.get_type = _get_type,
|
||||
.get_argument = _get_argument,
|
||||
.get_arg_str = _get_arg_str,
|
||||
.get_arg_int = _get_arg_int,
|
||||
.set_result = _set_result,
|
||||
.get_result = _get_result,
|
||||
.destroy = _destroy,
|
||||
@@ -184,7 +199,8 @@ imv_workitem_t *imv_workitem_create(int id, imv_workitem_type_t type,
|
||||
.id = id,
|
||||
.imv_id = TNC_IMVID_ANY,
|
||||
.type = type,
|
||||
.argument = strdup(argument),
|
||||
.arg_str = arg_str ? strdup(arg_str) : NULL,
|
||||
.arg_int = arg_int,
|
||||
.rec_fail = rec_fail,
|
||||
.rec_noresult = rec_noresult,
|
||||
.rec_final = TNC_IMV_ACTION_RECOMMENDATION_NO_RECOMMENDATION,
|
||||
|
||||
@@ -36,10 +36,12 @@ enum imv_workitem_type_t {
|
||||
IMV_WORKITEM_DEFAULT_PWD = 4,
|
||||
IMV_WORKITEM_FILE_REF_MEAS = 5,
|
||||
IMV_WORKITEM_FILE_MEAS = 6,
|
||||
IMV_WORKITEM_DIR_REF_MEAS = 7,
|
||||
IMV_WORKITEM_DIR_MEAS = 8,
|
||||
IMV_WORKITEM_TCP_SCAN = 9,
|
||||
IMV_WORKITEM_UDP_SCAN = 10
|
||||
IMV_WORKITEM_FILE_META = 7,
|
||||
IMV_WORKITEM_DIR_REF_MEAS = 8,
|
||||
IMV_WORKITEM_DIR_MEAS = 9,
|
||||
IMV_WORKITEM_DIR_META = 10,
|
||||
IMV_WORKITEM_TCP_SCAN = 11,
|
||||
IMV_WORKITEM_UDP_SCAN = 12
|
||||
};
|
||||
|
||||
extern enum_name_t *imv_workitem_type_names;
|
||||
@@ -78,11 +80,18 @@ struct imv_workitem_t {
|
||||
TNC_IMVID (*get_imv_id)(imv_workitem_t *this);
|
||||
|
||||
/**
|
||||
* Get argument string
|
||||
* Get string argument
|
||||
*
|
||||
* @return Argument string
|
||||
*/
|
||||
char* (*get_argument)(imv_workitem_t *this);
|
||||
char* (*get_arg_str)(imv_workitem_t *this);
|
||||
|
||||
/**
|
||||
* Get integer argument
|
||||
*
|
||||
* @return Argument integer
|
||||
*/
|
||||
int (*get_arg_int)(imv_workitem_t *this);
|
||||
|
||||
/**
|
||||
* Set result string
|
||||
@@ -114,12 +123,13 @@ struct imv_workitem_t {
|
||||
*
|
||||
* @param id Primary workitem key
|
||||
* @param type Workitem type
|
||||
* @param argument Argument string
|
||||
* @param arg_str String argument
|
||||
* @param arg_int Integer argument
|
||||
* @param rec_fail Recommendation with minor/major non-compliance case
|
||||
* @param rec_noresult Recommendation in don't know/error case
|
||||
*/
|
||||
imv_workitem_t *imv_workitem_create(int id, imv_workitem_type_t type,
|
||||
char *argument,
|
||||
char *arg_str, int arg_int,
|
||||
TNC_IMV_Action_Recommendation rec_fail,
|
||||
TNC_IMV_Action_Recommendation rec_noresult);
|
||||
|
||||
|
||||
@@ -107,7 +107,8 @@ CREATE TABLE workitems (
|
||||
session integer NOT NULL REFERENCES sessions(id),
|
||||
enforcement integer NOT NULL REFERENCES enforcements(id),
|
||||
type integer NOT NULL,
|
||||
argument text NOT NULL,
|
||||
arg_str text,
|
||||
arg_int INTEGER DEFAULT 0,
|
||||
rec_fail integer NOT NULL,
|
||||
rec_noresult integer NOT NULL,
|
||||
rec_final integer,
|
||||
|
||||
@@ -184,8 +184,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
ietf_attr_product_info_t *attr_cast;
|
||||
pen_t vendor_id;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
IMV_OS_ATTR_PRODUCT_INFORMATION);
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_PRODUCT_INFORMATION);
|
||||
attr_cast = (ietf_attr_product_info_t*)attr;
|
||||
os_name = attr_cast->get_info(attr_cast, &vendor_id, NULL);
|
||||
if (vendor_id != PEN_IETF)
|
||||
@@ -205,8 +205,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
{
|
||||
ietf_attr_string_version_t *attr_cast;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
IMV_OS_ATTR_STRING_VERSION);
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_STRING_VERSION);
|
||||
attr_cast = (ietf_attr_string_version_t*)attr;
|
||||
os_version = attr_cast->get_version(attr_cast, NULL, NULL);
|
||||
if (os_version.len)
|
||||
@@ -221,8 +221,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
ietf_attr_numeric_version_t *attr_cast;
|
||||
u_int32_t major, minor;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
IMV_OS_ATTR_NUMERIC_VERSION);
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_NUMERIC_VERSION);
|
||||
attr_cast = (ietf_attr_numeric_version_t*)attr;
|
||||
attr_cast->get_version(attr_cast, &major, &minor);
|
||||
DBG1(DBG_IMV, "operating system numeric version is %d.%d",
|
||||
@@ -236,8 +236,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
op_result_t op_result;
|
||||
time_t last_boot;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
IMV_OS_ATTR_OPERATIONAL_STATUS);
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_OPERATIONAL_STATUS);
|
||||
attr_cast = (ietf_attr_op_status_t*)attr;
|
||||
op_status = attr_cast->get_status(attr_cast);
|
||||
op_result = attr_cast->get_result(attr_cast);
|
||||
@@ -252,8 +252,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
ietf_attr_fwd_enabled_t *attr_cast;
|
||||
os_fwd_status_t fwd_status;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
IMV_OS_ATTR_FORWARDING_ENABLED);
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_FORWARDING_ENABLED);
|
||||
attr_cast = (ietf_attr_fwd_enabled_t*)attr;
|
||||
fwd_status = attr_cast->get_status(attr_cast);
|
||||
DBG1(DBG_IMV, "IPv4 forwarding is %N",
|
||||
@@ -270,7 +270,7 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
ietf_attr_default_pwd_enabled_t *attr_cast;
|
||||
bool default_pwd_status;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_FACTORY_DEFAULT_PWD_ENABLED);
|
||||
attr_cast = (ietf_attr_default_pwd_enabled_t*)attr;
|
||||
default_pwd_status = attr_cast->get_status(attr_cast);
|
||||
@@ -289,8 +289,8 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
enumerator_t *e;
|
||||
status_t status;
|
||||
|
||||
os_state->set_received(os_state,
|
||||
IMV_OS_ATTR_INSTALLED_PACKAGES);
|
||||
state->set_action_flags(state,
|
||||
IMV_OS_ATTR_INSTALLED_PACKAGES);
|
||||
if (!this->db)
|
||||
{
|
||||
break;
|
||||
@@ -325,7 +325,7 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
char *name;
|
||||
chunk_t value;
|
||||
|
||||
os_state->set_received(os_state, IMV_OS_ATTR_SETTINGS);
|
||||
state->set_action_flags(state, IMV_OS_ATTR_SETTINGS);
|
||||
|
||||
attr_cast = (ita_attr_settings_t*)attr;
|
||||
e = attr_cast->create_enumerator(attr_cast);
|
||||
@@ -349,7 +349,7 @@ static TNC_Result receive_msg(private_imv_os_agent_t *this, imv_state_t *state,
|
||||
int device_id;
|
||||
chunk_t value;
|
||||
|
||||
os_state->set_received(os_state, IMV_OS_ATTR_DEVICE_ID);
|
||||
state->set_action_flags(state, IMV_OS_ATTR_DEVICE_ID);
|
||||
|
||||
value = attr->get_value(attr);
|
||||
DBG1(DBG_IMV, "device ID is %.*s", value.len, value.ptr);
|
||||
@@ -464,7 +464,7 @@ METHOD(imv_agent_if_t, receive_message_long, TNC_Result,
|
||||
/**
|
||||
* Build an IETF Attribute Request attribute for missing attributes
|
||||
*/
|
||||
static pa_tnc_attr_t* build_attr_request(u_int received)
|
||||
static pa_tnc_attr_t* build_attr_request(u_int32_t received)
|
||||
{
|
||||
pa_tnc_attr_t *attr;
|
||||
ietf_attr_attr_request_t *attr_cast;
|
||||
@@ -517,7 +517,7 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
TNC_Result result = TNC_RESULT_SUCCESS;
|
||||
bool no_workitems = TRUE;
|
||||
enumerator_t *enumerator;
|
||||
u_int received;
|
||||
u_int32_t received;
|
||||
|
||||
if (!this->agent->get_state(this->agent, id, &state))
|
||||
{
|
||||
@@ -525,14 +525,18 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
}
|
||||
os_state = (imv_os_state_t*)state;
|
||||
handshake_state = os_state->get_handshake_state(os_state);
|
||||
received = os_state->get_received(os_state);
|
||||
received = state->get_action_flags(state);
|
||||
session = state->get_session(state);
|
||||
imv_id = this->agent->get_id(this->agent);
|
||||
|
||||
if (handshake_state == IMV_OS_STATE_END)
|
||||
{
|
||||
return TNC_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
/* create an empty out message - we might need it */
|
||||
out_msg = imv_msg_create(this->agent, state, id,
|
||||
this->agent->get_id(this->agent),
|
||||
TNC_IMCID_ANY, msg_types[0]);
|
||||
out_msg = imv_msg_create(this->agent, state, id, imv_id, TNC_IMCID_ANY,
|
||||
msg_types[0]);
|
||||
|
||||
if (handshake_state == IMV_OS_STATE_INIT)
|
||||
{
|
||||
@@ -627,7 +631,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
|
||||
if (no_workitems)
|
||||
{
|
||||
DBG2(DBG_IMV, "no workitems generated - no evaluation requested");
|
||||
DBG2(DBG_IMV, "IMV %d has no workitems - "
|
||||
"no evaluation requested", imv_id);
|
||||
state->set_recommendation(state,
|
||||
TNC_IMV_ACTION_RECOMMENDATION_ALLOW,
|
||||
TNC_IMV_EVALUATION_RESULT_DONT_KNOW);
|
||||
@@ -727,6 +732,8 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
|
||||
/* finalized all workitems ? */
|
||||
if (session->get_workitem_count(session, imv_id) == 0)
|
||||
{
|
||||
os_state->set_handshake_state(os_state, IMV_OS_STATE_END);
|
||||
|
||||
result = out_msg->send_assessment(out_msg);
|
||||
out_msg->destroy(out_msg);
|
||||
if (result != TNC_RESULT_SUCCESS)
|
||||
|
||||
@@ -64,6 +64,11 @@ struct private_imv_os_state_t {
|
||||
*/
|
||||
u_int32_t max_msg_len;
|
||||
|
||||
/**
|
||||
* Flags set for completed actions
|
||||
*/
|
||||
u_int32_t action_flags;
|
||||
|
||||
/**
|
||||
* Access Requestor ID Type
|
||||
*/
|
||||
@@ -159,11 +164,6 @@ struct private_imv_os_state_t {
|
||||
*/
|
||||
int count_ok;
|
||||
|
||||
/**
|
||||
* Flags set for received attributes
|
||||
*/
|
||||
u_int received_flags;
|
||||
|
||||
/**
|
||||
* OS Settings
|
||||
*/
|
||||
@@ -337,6 +337,18 @@ METHOD(imv_state_t, get_max_msg_len, u_int32_t,
|
||||
return this->max_msg_len;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_action_flags, void,
|
||||
private_imv_os_state_t *this, u_int32_t flags)
|
||||
{
|
||||
this->action_flags |= flags;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, get_action_flags, u_int32_t,
|
||||
private_imv_os_state_t *this)
|
||||
{
|
||||
return this->action_flags;
|
||||
}
|
||||
|
||||
METHOD(imv_state_t, set_ar_id, void,
|
||||
private_imv_os_state_t *this, u_int32_t id_type, chunk_t id_value)
|
||||
{
|
||||
@@ -580,18 +592,6 @@ METHOD(imv_os_state_t, get_count, void,
|
||||
}
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, set_received, void,
|
||||
private_imv_os_state_t *this, u_int flags)
|
||||
{
|
||||
this->received_flags |= flags;
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, get_received, u_int,
|
||||
private_imv_os_state_t *this)
|
||||
{
|
||||
return this->received_flags;
|
||||
}
|
||||
|
||||
METHOD(imv_os_state_t, set_device_id, void,
|
||||
private_imv_os_state_t *this, int id)
|
||||
{
|
||||
@@ -660,6 +660,8 @@ imv_state_t *imv_os_state_create(TNC_ConnectionID connection_id)
|
||||
.set_flags = _set_flags,
|
||||
.set_max_msg_len = _set_max_msg_len,
|
||||
.get_max_msg_len = _get_max_msg_len,
|
||||
.set_action_flags = _set_action_flags,
|
||||
.get_action_flags = _get_action_flags,
|
||||
.set_ar_id = _set_ar_id,
|
||||
.get_ar_id = _get_ar_id,
|
||||
.set_session = _set_session,
|
||||
@@ -678,8 +680,6 @@ imv_state_t *imv_os_state_create(TNC_ConnectionID connection_id)
|
||||
.get_info = _get_info,
|
||||
.set_count = _set_count,
|
||||
.get_count = _get_count,
|
||||
.set_received = _set_received,
|
||||
.get_received = _get_received,
|
||||
.set_device_id = _set_device_id,
|
||||
.get_device_id = _get_device_id,
|
||||
.set_os_settings = _set_os_settings,
|
||||
|
||||
@@ -39,7 +39,8 @@ enum imv_os_handshake_state_t {
|
||||
IMV_OS_STATE_INIT,
|
||||
IMV_OS_STATE_ATTR_REQ,
|
||||
IMV_OS_STATE_POLICY_START,
|
||||
IMV_OS_STATE_WORKITEMS
|
||||
IMV_OS_STATE_WORKITEMS,
|
||||
IMV_OS_STATE_END
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -119,20 +120,6 @@ struct imv_os_state_t {
|
||||
void (*get_count)(imv_os_state_t *this, int *count, int *count_update,
|
||||
int *count_blacklist, int *count_ok);
|
||||
|
||||
/**
|
||||
* Set flags for received attributes
|
||||
*
|
||||
* @param flags Flags to be set
|
||||
*/
|
||||
void (*set_received)(imv_os_state_t *this, u_int flags);
|
||||
|
||||
/**
|
||||
* Get flags set for received attributes
|
||||
*
|
||||
* @return Flags set for received attributes
|
||||
*/
|
||||
u_int (*get_received)(imv_os_state_t *this);
|
||||
|
||||
/**
|
||||
* Set device ID
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user