fixed measurement of directory contents
This commit is contained in:
@@ -454,14 +454,14 @@ TNC_Result TNC_IMV_ReceiveMessage(TNC_IMVID imv_id,
|
|||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
DBG1(DBG_IMV, " database enumerator failed");
|
DBG1(DBG_IMV, " database enumerator failed");
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (!e->enumerate(e, &db_measurement))
|
if (!e->enumerate(e, &db_measurement))
|
||||||
{
|
{
|
||||||
DBG1(DBG_IMV, " measurement for '%s' not found"
|
DBG1(DBG_IMV, " measurement for '%s' not found"
|
||||||
" in database", filename);
|
" in database", filename);
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (chunk_equals(db_measurement, measurement))
|
if (chunk_equals(db_measurement, measurement))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -606,8 +606,7 @@ static char* get_filename(char *pathname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
METHOD(pts_t, do_measurements, pts_file_meas_t*,
|
METHOD(pts_t, do_measurements, pts_file_meas_t*,
|
||||||
private_pts_t *this, u_int16_t request_id, char *pathname,
|
private_pts_t *this, u_int16_t request_id, char *pathname, bool is_directory)
|
||||||
bool directory_flag)
|
|
||||||
{
|
{
|
||||||
hasher_t *hasher;
|
hasher_t *hasher;
|
||||||
hash_algorithm_t hash_alg;
|
hash_algorithm_t hash_alg;
|
||||||
@@ -630,7 +629,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
|
|||||||
/* Link the hash to the measurement and set the measurement length */
|
/* Link the hash to the measurement and set the measurement length */
|
||||||
measurement = chunk_create(hash, hasher->get_hash_size(hasher));
|
measurement = chunk_create(hash, hasher->get_hash_size(hasher));
|
||||||
|
|
||||||
if (directory_flag)
|
if (is_directory)
|
||||||
{
|
{
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
char *rel_name, *abs_name;
|
char *rel_name, *abs_name;
|
||||||
@@ -647,7 +646,8 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
|
|||||||
}
|
}
|
||||||
while (enumerator->enumerate(enumerator, &rel_name, &abs_name, &st))
|
while (enumerator->enumerate(enumerator, &rel_name, &abs_name, &st))
|
||||||
{
|
{
|
||||||
if (S_ISDIR(st.st_mode) && *rel_name != '.')
|
/* measure regular files only */
|
||||||
|
if (S_ISREG(st.st_mode) && *rel_name != '.')
|
||||||
{
|
{
|
||||||
if (!hash_file(hasher, abs_name, hash))
|
if (!hash_file(hasher, abs_name, hash))
|
||||||
{
|
{
|
||||||
@@ -656,8 +656,7 @@ METHOD(pts_t, do_measurements, pts_file_meas_t*,
|
|||||||
measurements->destroy(measurements);
|
measurements->destroy(measurements);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
DBG2(DBG_IMC, " %#B for '%s'",
|
DBG2(DBG_IMC, " %#B for '%s'", &measurement, rel_name);
|
||||||
&measurement, rel_name);
|
|
||||||
measurements->add(measurements, rel_name, measurement);
|
measurements->add(measurements, rel_name, measurement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,12 @@ METHOD(pa_tnc_attr_t, build, void,
|
|||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
|
if (first)
|
||||||
|
{
|
||||||
|
/* no attached measurements */
|
||||||
|
writer->write_uint16(writer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
this->value = chunk_clone(writer->get_buf(writer));
|
this->value = chunk_clone(writer->get_buf(writer));
|
||||||
writer->destroy(writer);
|
writer->destroy(writer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user