|
@@ -1,4 +1,5 @@
|
|
|
#include "src/fs.h"
|
|
|
+#include "src/gpgme.h"
|
|
|
|
|
|
// http://libfuse.github.io/doxygen/globals.html
|
|
|
#define FUSE_USE_VERSION 31
|
|
@@ -26,36 +27,6 @@ static const char gpgme_recip_fpr[] =
|
|
|
"1234567890ABCDEF1234567890ABCDEF12345678";
|
|
|
static gpgme_key_t gpgme_recip_key;
|
|
|
|
|
|
-static int rgpgfs_gpgme_data_to_file(const char *path, gpgme_data_t data) {
|
|
|
- if (gpgme_data_seek(data, 0, SEEK_SET) != 0) {
|
|
|
- perror("rgpgfs_gpgme_data_to_file: failed to seek");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- FILE *file = fopen(path, "wb");
|
|
|
- if (file == NULL) {
|
|
|
- perror("rgpgfs_gpgme_data_to_file: failed to open file");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- ssize_t count;
|
|
|
- char buf[BUFSIZ];
|
|
|
- while ((count = gpgme_data_read(data, buf, BUFSIZ)) > 0) {
|
|
|
- if (fwrite(buf, 1, count, file) != count) {
|
|
|
- fprintf(stderr,
|
|
|
- "rgpgfs_gpgme_data_to_file: failed to write data to file");
|
|
|
- return 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if (count != 0) {
|
|
|
- perror("rgpgfs_gpgme_data_to_file: failed to load data into buffer");
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- fclose(file);
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
static int rgpgfs_encrypt(const char *source_path, char *cache_path) {
|
|
|
// fprintf(stderr, "rgpgfs_encrypt('%s', %p)\n", source_path, cache_path);
|
|
|
size_t source_path_len = strnlen(source_path, FUSE_PATH_BUF_LEN);
|