From 4b707677b58b827667e1051da2a8d01aa1462487 Mon Sep 17 00:00:00 2001 From: Valient Gough Date: Mon, 5 May 2008 03:33:31 +0000 Subject: [PATCH] add direct-load method so that encfsctl cat can work with direct cipher paths git-svn-id: http://encfs.googlecode.com/svn/trunk@19 db9cf616-1c43-0410-9cb8-a902689de0d6 --- encfs/DirNode.cpp | 16 ++++++++++++++++ encfs/DirNode.h | 4 ++++ encfs/encfsctl.cpp | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/encfs/DirNode.cpp b/encfs/DirNode.cpp index 0d54ace..6c683d5 100644 --- a/encfs/DirNode.cpp +++ b/encfs/DirNode.cpp @@ -706,6 +706,22 @@ shared_ptr DirNode::renameNode( const char *from, const char *to, return node; } +shared_ptr DirNode::directLookup( const char *path ) +{ + return shared_ptr( + new FileNode( this, + config->fsSubVersion, + "unknown", path, + config->cipher, config->key, + config->blockSize, config->blockMACBytes, + config->blockMACRandBytes, + config->uniqueIV, + config->externalIVChaining, + config->forceDecode, + config->reverseEncryption, + config->allowHoles) ); +} + shared_ptr DirNode::findOrCreate( const char *plainName) { shared_ptr node; diff --git a/encfs/DirNode.h b/encfs/DirNode.h index 254342a..ddd6dec 100644 --- a/encfs/DirNode.h +++ b/encfs/DirNode.h @@ -135,6 +135,10 @@ public: shared_ptr openNode( const char *plaintextName, const char *requestor, int flags, int *openResult ); + /* For internal use - open a cipher file directly + */ + shared_ptr directLookup( const char *realPath ); + std::string cipherPath( const char *plaintextPath ); std::string plainPath( const char *cipherPath ); diff --git a/encfs/encfsctl.cpp b/encfs/encfsctl.cpp index fe83e2b..eb50500 100644 --- a/encfs/encfsctl.cpp +++ b/encfs/encfsctl.cpp @@ -334,6 +334,19 @@ int processContents( const shared_ptr &rootInfo, int errCode = 0; shared_ptr node = rootInfo->root->openNode( path, "encfsctl", O_RDONLY, &errCode ); + + if(!node) + { + // try opening directly, so a cipher-path can be passed in + node = rootInfo->root->directLookup( path ); + if(node) + { + errCode = node->open( O_RDONLY ); + if(errCode < 0) + node.reset(); + } + } + if(!node) { cerr << "unable to open " << path << "\n";