diff mbox series

[ima-evm-utils,v4,01/17] Revert "Reset 'errno' after failure to open or access a file"

Message ID 20221101201803.372652-2-zohar@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series address deprecated warnings | expand

Commit Message

Mimi Zohar Nov. 1, 2022, 8:17 p.m. UTC
This reverts commit acb19d1894a4a95471b8d2346cd6c3ecf3385110.

Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 src/evmctl.c    | 18 ++----------------
 src/libimaevm.c |  4 ----
 2 files changed, 2 insertions(+), 20 deletions(-)

Comments

Stefan Berger Nov. 1, 2022, 9:46 p.m. UTC | #1
On 11/1/22 16:17, Mimi Zohar wrote:
> This reverts commit acb19d1894a4a95471b8d2346cd6c3ecf3385110.

$ git show acb19d1
fatal: ambiguous argument 'acb19d1': unknown revision or path not in the working tree.

Are you reverting this from a public tree? or could you just drop this patch from your series?

Also after removing this patch from the mbox file I cannot apply these patches to my sourceforge checkout -- presumably next-testing branch:

$ git am ./v4_20221101_zohar_address_deprecated_warnings.mbx
Applying: log and reset 'errno' after failure to open non-critical files
Applying: Log and reset 'errno' on lsetxattr failure
Applying: travis: update dist=focal
Applying: Update configure.ac to address a couple of obsolete warnings
Applying: Deprecate IMA signature version 1
error: patch failed: src/libimaevm.c:684
error: src/libimaevm.c: patch does not apply
Patch failed at 0005 Deprecate IMA signature version 1
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

    Stefan
Mimi Zohar Nov. 1, 2022, 11:04 p.m. UTC | #2
Hi Stefan,

On Tue, 2022-11-01 at 17:46 -0400, Stefan Berger wrote:
> 
> On 11/1/22 16:17, Mimi Zohar wrote:
> > This reverts commit acb19d1894a4a95471b8d2346cd6c3ecf3385110.
> 
> $ git show acb19d1
> fatal: ambiguous argument 'acb19d1': unknown revision or path not in the working tree.
> 
> Are you reverting this from a public tree? or could you just drop this patch from your series?
> 
> Also after removing this patch from the mbox file I cannot apply these patches to my sourceforge checkout -- presumably next-testing branch:
> 
> $ git am ./v4_20221101_zohar_address_deprecated_warnings.mbx
> Applying: log and reset 'errno' after failure to open non-critical files
> Applying: Log and reset 'errno' on lsetxattr failure
> Applying: travis: update dist=focal
> Applying: Update configure.ac to address a couple of obsolete warnings
> Applying: Deprecate IMA signature version 1
> error: patch failed: src/libimaevm.c:684
> error: src/libimaevm.c: patch does not apply
> Patch failed at 0005 Deprecate IMA signature version 1
> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> When you have resolved this problem, run "git am --continue".
> If you prefer to skip this patch, run "git am --skip" instead.
> To restore the original branch and stop patching, run "git am --abort".

Sorry, I should have used "--base=auto" when generating the patch set. 
Yes, the patch set is based on the github next-testing branch.

thanks,

Mimi
Stefan Berger Nov. 2, 2022, 12:25 a.m. UTC | #3
On 11/1/22 19:04, Mimi Zohar wrote:
> Hi Stefan,
> 
> On Tue, 2022-11-01 at 17:46 -0400, Stefan Berger wrote:
>>
>> On 11/1/22 16:17, Mimi Zohar wrote:
>>> This reverts commit acb19d1894a4a95471b8d2346cd6c3ecf3385110.
>>
>> $ git show acb19d1
>> fatal: ambiguous argument 'acb19d1': unknown revision or path not in the working tree.
>>
>> Are you reverting this from a public tree? or could you just drop this patch from your series?
>>
>> Also after removing this patch from the mbox file I cannot apply these patches to my sourceforge checkout -- presumably next-testing branch:
>>
>> $ git am ./v4_20221101_zohar_address_deprecated_warnings.mbx
>> Applying: log and reset 'errno' after failure to open non-critical files
>> Applying: Log and reset 'errno' on lsetxattr failure
>> Applying: travis: update dist=focal
>> Applying: Update configure.ac to address a couple of obsolete warnings
>> Applying: Deprecate IMA signature version 1
>> error: patch failed: src/libimaevm.c:684
>> error: src/libimaevm.c: patch does not apply
>> Patch failed at 0005 Deprecate IMA signature version 1
>> hint: Use 'git am --show-current-patch=diff' to see the failed patch
>> When you have resolved this problem, run "git am --continue".
>> If you prefer to skip this patch, run "git am --skip" instead.
>> To restore the original branch and stop patching, run "git am --abort".
> 
> Sorry, I should have used "--base=auto" when generating the patch set.
> Yes, the patch set is based on the github next-testing branch.
> 

Is the github repo now the main repo and sourceforge repo is dead?

> thanks,
> 
> Mimi
>
Mimi Zohar Nov. 3, 2022, 1:54 p.m. UTC | #4
On Tue, 2022-11-01 at 20:25 -0400, Stefan Berger wrote:
> 
> On 11/1/22 19:04, Mimi Zohar wrote:
> > Hi Stefan,
> > 
> > On Tue, 2022-11-01 at 17:46 -0400, Stefan Berger wrote:
> >>
> >> On 11/1/22 16:17, Mimi Zohar wrote:
> >>> This reverts commit acb19d1894a4a95471b8d2346cd6c3ecf3385110.
> >>
> >> $ git show acb19d1
> >> fatal: ambiguous argument 'acb19d1': unknown revision or path not in the working tree.
> >>
> >> Are you reverting this from a public tree? or could you just drop this patch from your series?
> >>
> >> Also after removing this patch from the mbox file I cannot apply these patches to my sourceforge checkout -- presumably next-testing branch:
> >>
> >> $ git am ./v4_20221101_zohar_address_deprecated_warnings.mbx
> >> Applying: log and reset 'errno' after failure to open non-critical files
> >> Applying: Log and reset 'errno' on lsetxattr failure
> >> Applying: travis: update dist=focal
> >> Applying: Update configure.ac to address a couple of obsolete warnings
> >> Applying: Deprecate IMA signature version 1
> >> error: patch failed: src/libimaevm.c:684
> >> error: src/libimaevm.c: patch does not apply
> >> Patch failed at 0005 Deprecate IMA signature version 1
> >> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> >> When you have resolved this problem, run "git am --continue".
> >> If you prefer to skip this patch, run "git am --skip" instead.
> >> To restore the original branch and stop patching, run "git am --abort".
> > 
> > Sorry, I should have used "--base=auto" when generating the patch set.
> > Yes, the patch set is based on the github next-testing branch.
> > 
> 
> Is the github repo now the main repo and sourceforge repo is dead?

The "next" branch in both repo's are the same.  Before posting patches,
I verify that github Actions works.   As a result, the next-testing
branch on github is rebased frequently.  Once a patch set is ready, the
"next" branch in both repo's is updated.

To answer your question the github repo is primary.

Mimi
Petr Vorel Nov. 3, 2022, 2:32 p.m. UTC | #5
> On Tue, 2022-11-01 at 20:25 -0400, Stefan Berger wrote:

> > On 11/1/22 19:04, Mimi Zohar wrote:
> > > Hi Stefan,

> > > On Tue, 2022-11-01 at 17:46 -0400, Stefan Berger wrote:

> > >> On 11/1/22 16:17, Mimi Zohar wrote:
> > >>> This reverts commit acb19d1894a4a95471b8d2346cd6c3ecf3385110.

> > >> $ git show acb19d1
> > >> fatal: ambiguous argument 'acb19d1': unknown revision or path not in the working tree.

> > >> Are you reverting this from a public tree? or could you just drop this patch from your series?

> > >> Also after removing this patch from the mbox file I cannot apply these patches to my sourceforge checkout -- presumably next-testing branch:

> > >> $ git am ./v4_20221101_zohar_address_deprecated_warnings.mbx
> > >> Applying: log and reset 'errno' after failure to open non-critical files
> > >> Applying: Log and reset 'errno' on lsetxattr failure
> > >> Applying: travis: update dist=focal
> > >> Applying: Update configure.ac to address a couple of obsolete warnings
> > >> Applying: Deprecate IMA signature version 1
> > >> error: patch failed: src/libimaevm.c:684
> > >> error: src/libimaevm.c: patch does not apply
> > >> Patch failed at 0005 Deprecate IMA signature version 1
> > >> hint: Use 'git am --show-current-patch=diff' to see the failed patch
> > >> When you have resolved this problem, run "git am --continue".
> > >> If you prefer to skip this patch, run "git am --skip" instead.
> > >> To restore the original branch and stop patching, run "git am --abort".

> > > Sorry, I should have used "--base=auto" when generating the patch set.
> > > Yes, the patch set is based on the github next-testing branch.


> > Is the github repo now the main repo and sourceforge repo is dead?

> The "next" branch in both repo's are the same.  Before posting patches,
> I verify that github Actions works.   As a result, the next-testing
> branch on github is rebased frequently.  Once a patch set is ready, the
> "next" branch in both repo's is updated.

> To answer your question the github repo is primary.
Maybe deleting everything in sourceforge and ad put single file with link to
github.com would save you work (having master, next and next-testing branches
with this file).

Kind regards,
Petr

> Mimi
Mimi Zohar Nov. 3, 2022, 9:35 p.m. UTC | #6
Hi Petr,

> > > Is the github repo now the main repo and sourceforge repo is dead?
> 
> > The "next" branch in both repo's are the same.  Before posting patches,
> > I verify that github Actions works.   As a result, the next-testing
> > branch on github is rebased frequently.  Once a patch set is ready, the
> > "next" branch in both repo's is updated.
> 
> > To answer your question the github repo is primary.
> Maybe deleting everything in sourceforge and ad put single file with link to
> github.com would save you work (having master, next and next-testing branches
> with this file).

Thanks, definitely appreciate time saving tips!  Vitaly suggested
saving the sourceforge wiki info in ima-evm-utils and updating the
file(s) like any other file.  Before removing "everything"h from
sourceforge, that still needs to be done.
Vitaly Chikunov Nov. 3, 2022, 10:50 p.m. UTC | #7
On Thu, Nov 03, 2022 at 05:35:40PM -0400, Mimi Zohar wrote:
> Hi Petr,
> 
> > > > Is the github repo now the main repo and sourceforge repo is dead?
> > 
> > > The "next" branch in both repo's are the same.  Before posting patches,
> > > I verify that github Actions works.   As a result, the next-testing
> > > branch on github is rebased frequently.  Once a patch set is ready, the
> > > "next" branch in both repo's is updated.
> > 
> > > To answer your question the github repo is primary.
> > Maybe deleting everything in sourceforge and ad put single file with link to
> > github.com would save you work (having master, next and next-testing branches
> > with this file).
> 
> Thanks, definitely appreciate time saving tips!  Vitaly suggested
> saving the sourceforge wiki info in ima-evm-utils and updating the
> file(s) like any other file.  Before removing "everything"h from
> sourceforge, that still needs to be done.

I thought markdown should be downloaded from Edit interface, which is not
available on SF for non-admins. But I found recently how to download it
in Json format via Allura API:

  curl -s https://sourceforge.net/rest/p/linux-ima/wiki/Home  | jq -r .text

Then only end-of-lines need to be fixed.

Thanks,

> 
> -- 
> thanks,
> 
> Mimi
Mimi Zohar Nov. 13, 2022, 9:25 p.m. UTC | #8
On Fri, 2022-11-04 at 01:50 +0300, Vitaly Chikunov wrote:
> On Thu, Nov 03, 2022 at 05:35:40PM -0400, Mimi Zohar wrote:
> > Hi Petr,
> > 
> > > > > Is the github repo now the main repo and sourceforge repo is dead?
> > > 
> > > > The "next" branch in both repo's are the same.  Before posting patches,
> > > > I verify that github Actions works.   As a result, the next-testing
> > > > branch on github is rebased frequently.  Once a patch set is ready, the
> > > > "next" branch in both repo's is updated.
> > > 
> > > > To answer your question the github repo is primary.
> > > Maybe deleting everything in sourceforge and ad put single file with link to
> > > github.com would save you work (having master, next and next-testing branches
> > > with this file).
> > 
> > Thanks, definitely appreciate time saving tips!  Vitaly suggested
> > saving the sourceforge wiki info in ima-evm-utils and updating the
> > file(s) like any other file.  Before removing "everything"h from
> > sourceforge, that still needs to be done.
> 
> I thought markdown should be downloaded from Edit interface, which is not
> available on SF for non-admins. But I found recently hbow to download it
> in Json format via Allura API:
> 
>   curl -s https://sourceforge.net/rest/p/linux-ima/wiki/Home  | jq -r .text
> 
> Then only end-of-lines need to be fixed.

There's an admin option to export the wiki, but this is much better.
diff mbox series

Patch

diff --git a/src/evmctl.c b/src/evmctl.c
index 76e2561798fa..0412bc0ac2b0 100644
--- a/src/evmctl.c
+++ b/src/evmctl.c
@@ -182,7 +182,6 @@  static int bin2file(const char *file, const char *ext, const unsigned char *data
 	fp = fopen(name, "w");
 	if (!fp) {
 		log_err("Failed to open: %s\n", name);
-		errno = 0;
 		return -1;
 	}
 	err = fwrite(data, len, 1, fp);
@@ -208,7 +207,6 @@  static unsigned char *file2bin(const char *file, const char *ext, int *size)
 	fp = fopen(name, "r");
 	if (!fp) {
 		log_err("Failed to open: %s\n", name);
-		errno = 0;
 		return NULL;
 	}
 	if (fstat(fileno(fp), &stats) == -1) {
@@ -315,10 +313,8 @@  static int get_uuid(struct stat *st, char *uuid)
 	sprintf(path, "blkid -s UUID -o value /dev/block/%u:%u", major, minor);
 
 	fp = popen(path, "r");
-	if (!fp) {
-		errno = 0;
+	if (!fp)
 		goto err;
-	}
 
 	len = fread(_uuid, 1, sizeof(_uuid), fp);
 	pclose(fp);
@@ -375,7 +371,6 @@  static int calc_evm_hash(const char *file, unsigned char *hash)
 
 			if (fd < 0) {
 				log_err("Failed to open: %s\n", file);
-				errno = 0;
 				return -1;
 			}
 			if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
@@ -1201,7 +1196,6 @@  static int calc_evm_hmac(const char *file, const char *keyfile, unsigned char *h
 
 		if (fd < 0) {
 			log_err("Failed to open %s\n", file);
-			errno = 0;
 			goto out;
 		}
 		if (ioctl(fd, FS_IOC_GETVERSION, &generation)) {
@@ -1392,7 +1386,6 @@  static int ima_fix(const char *path)
 	fd = open(path, O_RDONLY);
 	if (fd < 0) {
 		log_errno("Failed to open file: %s", path);
-		errno = 0;
 		return -1;
 	}
 
@@ -1916,10 +1909,8 @@  static int read_sysfs_pcrs(int num_banks, struct tpm_bank_info *tpm_banks)
 	int i, result;
 
 	fp = fopen(pcrs, "r");
-	if (!fp) {
+	if (!fp)
 		fp = fopen(misc_pcrs, "r");
-		errno = 0;
-	}
 	if (!fp)
 		return -1;
 
@@ -1982,7 +1973,6 @@  static int read_file_pcrs(int num_banks, struct tpm_bank_info *tpm_banks)
 		fp = fopen(path, "r");
 		if (!fp) {
 			log_err("Could not open '%s'\n", path);
-			errno = 0;
 			return -1;
 		}
 
@@ -2075,7 +2065,6 @@  static int ima_measurement(const char *file)
 	fp = fopen(file, "rb");
 	if (!fp) {
 		log_err("Failed to open measurement file: %s\n", file);
-		errno = 0;
 		return -1;
 	}
 
@@ -2321,7 +2310,6 @@  static int read_binary_bios_measurements(char *file, struct tpm_bank_info *bank)
 	fp = fopen(file, "r");
 	if (!fp) {
 		log_errno("Failed to open TPM 1.2 event log.\n");
-		errno = 0;
 		return 1;
 	}
 
@@ -2758,8 +2746,6 @@  int main(int argc, char *argv[])
 	unsigned long keyid;
 	char *eptr;
 
-	errno = 0;	/* initialize errno */
-
 #if !(OPENSSL_VERSION_NUMBER < 0x10100000)
 	OPENSSL_init_crypto(
 #ifndef DISABLE_OPENSSL_CONF
diff --git a/src/libimaevm.c b/src/libimaevm.c
index e4b62b4989b2..611631c57f14 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -144,7 +144,6 @@  static int add_file_hash(const char *file, EVP_MD_CTX *ctx)
 	fp = fopen(file, "r");
 	if (!fp) {
 		log_err("Failed to open: %s\n", file);
-		errno = 0;
 		return -1;
 	}
 
@@ -259,7 +258,6 @@  EVP_PKEY *read_pub_pkey(const char *keyfile, int x509)
 	if (!fp) {
 		if (imaevm_params.verbose > LOG_INFO)
 			log_info("Failed to open keyfile: %s\n", keyfile);
-		errno = 0;
 		return NULL;
 	}
 
@@ -878,7 +876,6 @@  static int read_keyid_from_cert(uint32_t *keyid_be, const char *certfile, int tr
 
 	if (!(fp = fopen(certfile, "r"))) {
 		log_err("Cannot open %s: %s\n", certfile, strerror(errno));
-		errno = 0;
 		return -1;
 	}
 	if (!PEM_read_X509(fp, &x, NULL, NULL)) {
@@ -970,7 +967,6 @@  static EVP_PKEY *read_priv_pkey(const char *keyfile, const char *keypass)
 		fp = fopen(keyfile, "r");
 		if (!fp) {
 			log_err("Failed to open keyfile: %s\n", keyfile);
-			errno = 0;
 			return NULL;
 		}
 		pkey = PEM_read_PrivateKey(fp, NULL, NULL, (void *)keypass);