summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael Gapczynski <GapczynskiM@gmail.com>2011-08-11 17:42:37 -0400
committerMichael Gapczynski <GapczynskiM@gmail.com>2011-08-11 17:42:37 -0400
commit4830555cce8fbc5505b4d6bbc2bdd5ddc582f3b5 (patch)
tree1d6c150ca0c725abb854afc2ab76422ebdcd4d85 /lib
parent9e35d5a886b192b1ab3e19ca0e1b9608a39d60ac (diff)
parent52df7accfd1a1a8f4ac35d29e00d60961469c063 (diff)
downloadnextcloud-server-4830555cce8fbc5505b4d6bbc2bdd5ddc582f3b5.tar.gz
nextcloud-server-4830555cce8fbc5505b4d6bbc2bdd5ddc582f3b5.zip
Merge branch 'master' into sharing
Conflicts: .gitignore
Diffstat (limited to 'lib')
-rw-r--r--lib/app.php10
-rwxr-xr-xlib/crypt.php54
-rwxr-xr-xlib/helper.php18
-rw-r--r--lib/ocsclient.php16
-rw-r--r--lib/setup.php1
-rw-r--r--lib/user.php1
-rw-r--r--lib/util.php2
7 files changed, 70 insertions, 32 deletions
diff --git a/lib/app.php b/lib/app.php
index 6a2e3078596..e7cf74af85c 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -200,13 +200,13 @@ class OC_App{
public static function getSettingsNavigation(){
$l=new OC_L10N('core');
$admin=array(
- array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "admin", "users.php" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "admin", "users.png" )),
- array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "admin", "apps.php?installed" ), "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "admin", "apps.png" )),
- array( "id" => "files_administration", "order" => 3, "href" => OC_Helper::linkTo( "files", "admin.php" ), "name" => $l->t("Files"), "icon" => OC_Helper::imagePath( "files", "folder.png" )),
+ array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkTo( "admin", "users.php" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "admin", "users.svg" )),
+ array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkTo( "admin", "apps.php?installed" ), "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "admin", "apps.svg" )),
+// array( "id" => "files_administration", "order" => 3, "href" => OC_Helper::linkTo( "files", "admin.php" ), "name" => $l->t("Files"), "icon" => OC_Helper::imagePath( "settings", "options.svg" )),
);
$settings=array(
- array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkTo( "help", "index.php" ), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath( "help", "help.png" )),
- array( "id" => "settings", "order" => 1, "href" => OC_Helper::linkTo( "settings", "index.php" ), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath( "settings", "personal.png" ))
+ array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkTo( "help", "index.php" ), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath( "help", "help.svg" )),
+ array( "id" => "settings", "order" => 1, "href" => OC_Helper::linkTo( "settings", "index.php" ), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath( "settings", "personal.svg" ))
);
if( OC_Group::inGroup( $_SESSION["user_id"], "admin" )){
$settings=array_merge($admin,$settings);
diff --git a/lib/crypt.php b/lib/crypt.php
index d75515cf2de..83e6ac4cde0 100755
--- a/lib/crypt.php
+++ b/lib/crypt.php
@@ -24,9 +24,10 @@
// Todo:
// Crypt/decrypt button in the userinterface
+// setting if crypto should be on by default
// transparent decrypt/encrpt in filesystem.php
// don't use a password directly as encryption key. but a key which is stored on the server and encrypted with the user password. -> password change faster
-
+// check if the block lenght of the encrypted data stays the same
require_once('Crypt_Blowfish/Blowfish.php');
@@ -38,15 +39,50 @@ class OC_Crypt {
static $encription_extension='.encrypted';
- public static function createkey( $passcode) {
- // generate a random key
- $key=mt_rand(10000,99999).mt_rand(10000,99999).mt_rand(10000,99999).mt_rand(10000,99999);
+ public static function init($login,$password) {
+ $_SESSION['user_password'] = $password; // save the password as passcode for the encryption
+ if(OC_User::isLoggedIn()){
+ // does key exist?
+ if(!file_exists(OC_Config::getValue( "datadirectory").'/'.$login.'/encryption.key')){
+ OC_Crypt::createkey($_SESSION['user_password']);
+ }
+ }
+ }
+
- // encrypt the key with the passcode of the user
- $enckey=OC_Crypt::encrypt($key,$passcode);
- // Write the file
- file_put_contents( "$SERVERROOT/config/encryption.key", $enckey );
+ public static function createkey($passcode) {
+ if(OC_User::isLoggedIn()){
+ // generate a random key
+ $key=mt_rand(10000,99999).mt_rand(10000,99999).mt_rand(10000,99999).mt_rand(10000,99999);
+
+ // encrypt the key with the passcode of the user
+ $enckey=OC_Crypt::encrypt($key,$passcode);
+
+ // Write the file
+ $username=OC_USER::getUser();
+ file_put_contents(OC_Config::getValue( "datadirectory").'/'.$username.'/encryption.key', $enckey );
+ }
+ }
+
+ public static function changekeypasscode( $newpasscode) {
+ if(OC_User::isLoggedIn()){
+ $username=OC_USER::getUser();
+
+ // read old key
+ $key=file_get_contents(OC_Config::getValue( "datadirectory").'/'.$username.'/encryption.key');
+
+ // decrypt key with old passcode
+ $key=OC_Crypt::decrypt($key, $_SESSION['user_password']);
+
+ // encrypt again with new passcode
+ $key=OC_Crypt::encrypt($key,$newpassword);
+
+ // store the new key
+ file_put_contents(OC_Config::getValue( "datadirectory").'/'.$username.'/encryption.key', $key );
+
+ $_SESSION['user_password']=$newpasscode;
+ }
}
/**
@@ -59,7 +95,7 @@ class OC_Crypt {
*/
public static function encrypt( $content, $key) {
$bf = new Crypt_Blowfish($key);
- return($bf->encrypt($contents));
+ return($bf->encrypt($content));
}
diff --git a/lib/helper.php b/lib/helper.php
index fa5163ac266..272f4607011 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -89,11 +89,11 @@ class OC_Helper {
}
/**
- * @brief get path to icon of mime type
+ * @brief get path to icon of file type
* @param $mimetype mimetype
* @returns the url
*
- * Returns the path to the image of this mime type.
+ * Returns the path to the image of this file type.
*/
public static function mimetypeIcon( $mimetype ){
global $SERVERROOT;
@@ -103,20 +103,20 @@ class OC_Helper {
// Is it a dir?
if( $mimetype == "dir" ){
- return "$WEBROOT/core/img/places/folder.png";
+ return "$WEBROOT/core/img/places/folder.svg";
}
// Icon exists?
- if( file_exists( "$SERVERROOT/core/img/mimetypes/$mimetype.png" )){
- return "$WEBROOT/core/img/mimetypes/$mimetype.png";
+ if( file_exists( "$SERVERROOT/core/img/filetypes/$mimetype.svg" )){
+ return "$WEBROOT/core/img/filetypes/$mimetype.svg";
}
- //try only the first part of the mimetype
+ //try only the first part of the filetype
$mimetype=substr($mimetype,0,strpos($mimetype,'-'));
- if( file_exists( "$SERVERROOT/core/img/mimetypes/$mimetype.png" )){
- return "$WEBROOT/core/img/mimetypes/$mimetype.png";
+ if( file_exists( "$SERVERROOT/core/img/filetypes/$mimetype.svg" )){
+ return "$WEBROOT/core/img/filetypes/$mimetype.svg";
}
else{
- return "$WEBROOT/core/img/mimetypes/file.png";
+ return "$WEBROOT/core/img/filetypes/file.svg";
}
}
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 2d85e715090..1df9e21e606 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -80,15 +80,15 @@ class OC_OCSClient{
$tmp=$data->data->content;
for($i = 0; $i < count($tmp); $i++) {
$app=array();
- $app['id']=$tmp[$i]->id;
- $app['name']=$tmp[$i]->name;
- $app['type']=$tmp[$i]->typeid;
- $app['typename']=$tmp[$i]->typename;
- $app['personid']=$tmp[$i]->personid;
- $app['detailpage']=$tmp[$i]->detailpage;
- $app['preview']=$tmp[$i]->smallpreviewpic1;
+ $app['id']=(string)$tmp[$i]->id;
+ $app['name']=(string)$tmp[$i]->name;
+ $app['type']=(string)$tmp[$i]->typeid;
+ $app['typename']=(string)$tmp[$i]->typename;
+ $app['personid']=(string)$tmp[$i]->personid;
+ $app['detailpage']=(string)$tmp[$i]->detailpage;
+ $app['preview']=(string)$tmp[$i]->smallpreviewpic1;
$app['changed']=strtotime($tmp[$i]->changed);
- $app['description']=$tmp[$i]->description;
+ $app['description']=(string)$tmp[$i]->description;
$apps[]=$app;
}
diff --git a/lib/setup.php b/lib/setup.php
index 192fd134608..c7259d6b8ce 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -206,6 +206,7 @@ class OC_Setup {
OC_User::createUser($username, $password);
OC_Group::createGroup('admin');
OC_Group::addToGroup($username, 'admin');
+ OC_User::login($username, $password);
//guess what this does
OC_Installer::installShippedApps(true);
diff --git a/lib/user.php b/lib/user.php
index a2ede8234be..e53ba145c9e 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -193,6 +193,7 @@ class OC_User {
if( $run && self::checkPassword( $uid, $password )){
$_SESSION['user_id'] = $uid;
+ OC_Crypt::init($uid,$password);
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid ));
return true;
}
diff --git a/lib/util.php b/lib/util.php
index 10cd320977a..224b54335b8 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -194,7 +194,7 @@ class OC_Util {
global $SERVERROOT;
global $CONFIG_DATADIRECTORY;
- $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );;
+ $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue( "datadirectory", "$SERVERROOT/data" );
$CONFIG_BACKUPDIRECTORY = OC_Config::getValue( "backupdirectory", "$SERVERROOT/backup" );
$CONFIG_INSTALLED = OC_Config::getValue( "installed", false );
$errors=array();