[Owncloud] Mount fs on connect

Josu Lazkano josu.lazkano at barcelonamedia.org
Wed Sep 21 14:09:59 UTC 2011



On Tue, 2011-09-20 at 17:29 +0200, Josu Lazkano wrote:
> Hello, I am new here, I just trying the ownCloud to access our files.
> 
> I am trying to mount a CIFs fs on connect and umount on logout.
> 
> Our fs is designed this way: mount.cifs //fs_server/home$/$user
> $path_user -o username=$user,password=$password
> 
> I add this exec() lines on this files:
> 
> /var/www/cloud/lib/user.php
> 
> public static function logout(){
> 	OC_Hook::emit( "OC_User", "logout", array());
> 	$_SESSION['user_id'] = false;
> 	OC_User::unsetMagicInCookie();
> 	exec ("sudo umount /var/www/cloud/data/".$uid."/files/");
> 	return true;
> 
> /var/www/cloud/apps/user_ldap/user_ldap.php
> 
> public function checkPassword( $uid, $password ) {
> 	if(!$this->configured){
> 		return false;
> 	}
> 	$dn = $this->getDn( $uid );
> 	if( !$dn )
> 		return false;
> 
> 	if (!@ldap_bind( $this->getDs(), $dn, $password ))
> 		return false;
> 	exec ("sudo mount.cifs //fs_server/home
> $/".$uid." /var/www/cloud/data/".$uid."/files/ -o
> username=".$uid.",password=".$password);
> 	return $uid;
> }
> 
> 
> We configure the LDAP access, and when some user login, the fs is
> mounted and can access to the files. This part work well.
> 
> The problem is on logout, it does not umount because we need the $user
> variable to umount, and on the logout() there is no any user
> information.
> 
> How could I fix it?
> 
> Is there other method to add our fs to ownCloud?
> 
> Thanks for this great proyect and work.
> 
> Best regards.
> 
> _______________________________________________
> Owncloud mailing list
> Owncloud at kde.org
> https://mail.kde.org/mailman/listinfo/owncloud


Hello all, thanks to Robin Appelman I got it. I change this file:

/var/www/cloud/lib/user.php

        public static function logout(){
                $uid=OC_User::getUser();
                OC_Hook::emit( "OC_User", "logout", array());
                $_SESSION['user_id'] = false;
                OC_User::unsetMagicInCookie();
                exec ("sudo
umount /var/www/cloud/data/".$uid."/files/");
                return true;
        }

It umount great, but I notice that I can not share if I umount the fs,
so I will keep the mount for each user.

Kind regards.




More information about the Owncloud mailing list