fscrypt ENOKEY: ignore error and continue

Some files do not have a fscrypt key assigned to them when the fscrypt call is made to get the policy. Ignore the file when backing up in libtar.

Change-Id: I1054752ff332b27d0b3b1eeb288fdcc8112ab993
(cherry picked from commit b2a1f930edb37dc3c18a1df8085a3cc6c1d1ec01)
diff --git a/libtar/append.c b/libtar/append.c
index 3bb5833..e922233 100755
--- a/libtar/append.c
+++ b/libtar/append.c
@@ -82,6 +82,7 @@
 	tar_dev_t *td = NULL;
 	tar_ino_t *ti = NULL;
 	char path[MAXPATHLEN];
+	int filefd;
 
 #ifdef DEBUG
 	LOG("==> tar_append_file(TAR=0x%p (\"%s\"), realname=\"%s\", "
@@ -303,6 +304,20 @@
 	if (t->options & TAR_VERBOSE)
 		LOG("%s\n", th_get_pathname(t));
 
+#if defined(O_BINARY)
+        filefd = open(realname, O_RDONLY|O_BINARY);
+#else
+        filefd = open(realname, O_RDONLY);
+#endif
+        if (filefd == -1)
+        {
+                if (errno == ENOKEY) {
+                        LOG("Required key not available, skipping file\n");
+			close(filefd);
+			return 0;
+                }
+        }
+	close(filefd);
 #ifdef DEBUG
 	LOG("tar_append_file(): writing header");
 #endif
diff --git a/libtar/block.c b/libtar/block.c
index e94c24c..aaedc8e 100755
--- a/libtar/block.c
+++ b/libtar/block.c
@@ -719,7 +719,7 @@
 	}
 
 #ifdef DEBUG
-	LOG("th_write(): returning 0");
+	LOG("th_write(): returning 0\n");
 #endif
 	return 0;
 }