Improved folder creation code
Created stub method for checking user pwd recovery preference from db Added pwd recovery column to db Added comments
This commit is contained in:
parent
c1f1fbda08
commit
c89fd49870
|
@ -18,6 +18,14 @@
|
|||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>64</length>
|
||||
<comments>What client-side / server-side configuration is used</comments>
|
||||
</field>
|
||||
<field>
|
||||
<name>recovery</name>
|
||||
<type>boolean</type>
|
||||
<notnull>true</notnull>
|
||||
<default>0</default>
|
||||
<comments>Whether encryption key recovery is enabled</comments>
|
||||
</field>
|
||||
</declaration>
|
||||
</table>
|
||||
|
|
|
@ -29,9 +29,6 @@ namespace OCA\Encryption;
|
|||
|
||||
class Hooks {
|
||||
|
||||
// TODO: use passphrase for encrypting private key that is separate to
|
||||
// the login password
|
||||
|
||||
/**
|
||||
* @brief Startup encryption backend upon user login
|
||||
* @note This method should never be called for users using client side encryption
|
||||
|
@ -196,12 +193,15 @@ class Hooks {
|
|||
|
||||
$usersSharing = \OCP\Share::getUsersSharingFile( $path, true );
|
||||
|
||||
// Recursively expand path to include subfiles
|
||||
$allPaths = $util->getPaths( $path );
|
||||
|
||||
$failed = array();
|
||||
|
||||
// Loop through all subfiles
|
||||
foreach ( $allPaths as $path ) {
|
||||
|
||||
// Attempt to set shareKey
|
||||
if ( ! $util->setSharedFileKeyfiles( $session, $usersSharing, $path ) ) {
|
||||
|
||||
$failed[] = $path;
|
||||
|
|
|
@ -153,46 +153,25 @@ class Util {
|
|||
*/
|
||||
public function setupServerSide( $passphrase = null ) {
|
||||
|
||||
// Create user dir
|
||||
if( !$this->view->file_exists( $this->userDir ) ) {
|
||||
// Set directories to check / create
|
||||
$setUpDirs = array(
|
||||
$this->userDir
|
||||
, $this->userFilesDir
|
||||
, $this->publicKeyDir
|
||||
, $this->encryptionDir
|
||||
, $this->keyfilesPath
|
||||
, $this->shareKeysPath
|
||||
);
|
||||
|
||||
$this->view->mkdir( $this->userDir );
|
||||
// Check / create all necessary dirs
|
||||
foreach ( $setUpDirs as $dirPath ) {
|
||||
|
||||
if( !$this->view->file_exists( $dirPath ) ) {
|
||||
|
||||
$this->view->mkdir( $dirPath );
|
||||
|
||||
}
|
||||
|
||||
// Create user files dir
|
||||
if( !$this->view->file_exists( $this->userFilesDir ) ) {
|
||||
|
||||
$this->view->mkdir( $this->userFilesDir );
|
||||
|
||||
}
|
||||
|
||||
// Create shared public key directory
|
||||
if( !$this->view->file_exists( $this->publicKeyDir ) ) {
|
||||
|
||||
$this->view->mkdir( $this->publicKeyDir );
|
||||
|
||||
}
|
||||
|
||||
// Create encryption app directory
|
||||
if( !$this->view->file_exists( $this->encryptionDir ) ) {
|
||||
|
||||
$this->view->mkdir( $this->encryptionDir );
|
||||
|
||||
}
|
||||
|
||||
// Create mirrored keyfile directory
|
||||
if( !$this->view->file_exists( $this->keyfilesPath ) ) {
|
||||
|
||||
$this->view->mkdir( $this->keyfilesPath );
|
||||
|
||||
}
|
||||
|
||||
// Create mirrored share env keys directory
|
||||
if( !$this->view->file_exists( $this->shareKeysPath ) ) {
|
||||
|
||||
$this->view->mkdir( $this->shareKeysPath );
|
||||
|
||||
}
|
||||
|
||||
// Create user keypair
|
||||
|
@ -223,6 +202,20 @@ class Util {
|
|||
|
||||
}
|
||||
|
||||
public function recoveryEnabled( ) {
|
||||
|
||||
$sql = 'SELECT * FROM `*PREFIX*myusers` WHERE id = ?';
|
||||
$args = array(1);
|
||||
|
||||
$query = \OCP\DB::prepare($sql);
|
||||
$result = $query->execute($args);
|
||||
|
||||
while($row = $result->fetchRow()) {
|
||||
$userName = $row['username'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Find all files and their encryption status within a directory
|
||||
* @param string $directory The path of the parent directory to search
|
||||
|
@ -737,6 +730,7 @@ class Util {
|
|||
|
||||
$fileOwner = \OC\Files\Filesystem::getOwner( $filePath );
|
||||
|
||||
// Decrypt keyfile
|
||||
$plainKeyfile = $this->decryptUnknownKeyfile( $filePath, $fileOwner, $privateKey );
|
||||
|
||||
// Re-enc keyfile to (additional) sharekeys
|
||||
|
|
Loading…
Reference in New Issue