shithub: riscv

Download patch

ref: 84228515b6cf2bfc091e783c10485012e2e7a9b6
parent: c5e90835580ef45b060ffc3ab520757848d432a6
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Dec 26 14:48:38 EST 2016

keyfs: print error message when reading /adm/keys fails

--- a/sys/src/cmd/auth/keyfs.c
+++ b/sys/src/cmd/auth/keyfs.c
@@ -771,15 +771,14 @@
 	/* write file */
 	fd = create(userkeys, OWRITE, 0660);
 	if(fd < 0){
+		fprint(2, "keyfs: can't write %s: %r\n", userkeys);
 		free(buf);
-		fprint(2, "keyfs: can't write keys file\n");
 		return;
 	}
 	if(write(fd, buf, p - buf) != (p - buf))
-		fprint(2, "keyfs: can't write keys file\n");
-
-	free(buf);
+		fprint(2, "keyfs: can't write %s: %r\n", userkeys);
 	close(fd);
+	free(buf);
 
 	newkeys();
 }
@@ -854,8 +853,10 @@
 
 	/* read file into an array */
 	fd = open(userkeys, OREAD);
-	if(fd < 0)
+	if(fd < 0){
+		fprint(2, "keyfs: can't read %s: %r\n", userkeys);
 		return 0;
+	}
 	d = dirfstat(fd);
 	if(d == nil){
 		close(fd);