[libvirt] [PATCH v5 09/20] tpm: Check whether previously found executables were updated
Stefan Berger
stefanb at linux.ibm.com
Thu Jul 25 01:06:26 UTC 2019
On 7/24/19 1:02 PM, Daniel P. Berrangé wrote:
> On Fri, Jul 12, 2019 at 12:23:43PM -0400, Stefan Berger wrote:
>
> for (i = 0; i < ARRAY_CARDINALITY(prgs); i++) {
> char *path;
> bool findit = *prgs[i].path == NULL;
> + struct stat statbuf;
> + char *tmp;
> +
> + if (!findit) {
> + /* has executables changed? */
> + if (stat(*prgs[i].path, &statbuf) < 0) {
> + virReportSystemError(errno,
> + _("Could not stat %s"), path);
> + findit = true;
> If we can't stat the binary, then I we should reset ourselves
> back to fully uninitialized state. Certainly if we intend to
> call virReportSystemError, then we must ensure the caller
> treats it as a fatal error. Currently I believe its still
> treated as success by the caller since progs[i].path is
> already non-NULL at this point.
Removed the virReportError() here since we will try to find it again
below and report errors there then.
>
>> + }
>> + if (!findit &&
>> + memcmp(&statbuf.st_mtim,
>> + &prgs[i].stat->st_mtime,
>> + sizeof(statbuf.st_mtim))) {
>> + findit = true;
>> + }
>> + }
>>
>> if (findit) {
>> path = virFindFileInPath(prgs[i].name);
>> @@ -151,7 +177,15 @@ virTPMEmulatorInit(void)
>> VIR_FREE(path);
>> return -1;
>> }
>> + if (stat(path, prgs[i].stat) < 0) {
>> + virReportSystemError(errno,
>> + _("Could not stat %s"), path);
>> + VIR_FREE(path);
>> + return -1;
>> + }
>> + tmp = *prgs[i].path;
>> *prgs[i].path = path;
>> + VIR_FREE(tmp);
>> }
>> }
>>
>> --
>> 2.20.1
>>
> Regards,
> Daniel
More information about the libvir-list
mailing list