forked from extern/egroupware
Changes to support accessing Samba shares with Collabora
This commit is contained in:
parent
75b21741b9
commit
3dd671ad8d
@ -196,7 +196,7 @@ class Credentials
|
|||||||
// Remove special x char added to the end for \0 trimming escape.
|
// Remove special x char added to the end for \0 trimming escape.
|
||||||
if ($type == self::SMIME && substr($password, -1) === 'x') $password = substr($password, 0, -1);
|
if ($type == self::SMIME && substr($password, -1) === 'x') $password = substr($password, 0, -1);
|
||||||
|
|
||||||
foreach(self::$type2prefix as $pattern => $prefix)
|
foreach(static::$type2prefix as $pattern => $prefix)
|
||||||
{
|
{
|
||||||
if ($row['cred_type'] & $pattern)
|
if ($row['cred_type'] & $pattern)
|
||||||
{
|
{
|
||||||
|
@ -105,6 +105,7 @@ class Sharing
|
|||||||
$path_info = substr($path_info, strlen($_SERVER['SCRIPT_NAME']));
|
$path_info = substr($path_info, strlen($_SERVER['SCRIPT_NAME']));
|
||||||
list(, $token/*, $path*/) = preg_split('|[/?]|', $path_info, 3);
|
list(, $token/*, $path*/) = preg_split('|[/?]|', $path_info, 3);
|
||||||
|
|
||||||
|
list($token, $pw_session) = explode(':', $token);
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,6 +524,9 @@ class Sharing
|
|||||||
$table_def = static::$db->get_table_definitions(false,static::TABLE);
|
$table_def = static::$db->get_table_definitions(false,static::TABLE);
|
||||||
$extra = array_intersect_key($extra, $table_def['fd']);
|
$extra = array_intersect_key($extra, $table_def['fd']);
|
||||||
|
|
||||||
|
// Check if path is mounted somewhere that needs a password
|
||||||
|
static::path_needs_password($path);
|
||||||
|
|
||||||
// check if file has been shared before, with identical attributes
|
// check if file has been shared before, with identical attributes
|
||||||
if (($share = static::$db->select(static::TABLE, '*', $extra+array(
|
if (($share = static::$db->select(static::TABLE, '*', $extra+array(
|
||||||
'share_path' => $path,
|
'share_path' => $path,
|
||||||
@ -776,4 +780,32 @@ class Sharing
|
|||||||
|
|
||||||
return Framework::getUrl(Framework::link('/share.php')).'/'.$share;
|
return Framework::getUrl(Framework::link('/share.php')).'/'.$share;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the path has a password required for it's mounting (eg: Samba)
|
||||||
|
* we need to deal with it specially. In general, we just throw an exception
|
||||||
|
* if the mount has $pass in it.
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
*
|
||||||
|
* @throws WrongParameter if you try to share a path that needs a password
|
||||||
|
*/
|
||||||
|
public static function path_needs_password($path)
|
||||||
|
{
|
||||||
|
$mounts = array_reverse(Vfs::mount());
|
||||||
|
$parts = Vfs::parse_url($path);
|
||||||
|
|
||||||
|
foreach($mounts as $mounted => $url)
|
||||||
|
{
|
||||||
|
if(($mounted == $parts['path'] || $mounted.'/' == substr($parts['path'],0,strlen($mounted)+1)) && strpos($url, '$pass') !== FALSE)
|
||||||
|
{
|
||||||
|
throw new Exception\WrongParameter(
|
||||||
|
'Cannot share a file that needs a password. (' .
|
||||||
|
$path . ' mounted from '. $url . ')'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
@ -213,16 +213,12 @@ class StreamWrapper implements StreamWrapperIface
|
|||||||
$path = self::symlinkCache_resolve($path,$do_symlink);
|
$path = self::symlinkCache_resolve($path,$do_symlink);
|
||||||
}
|
}
|
||||||
// setting default user, passwd and domain, if it's not contained int the url
|
// setting default user, passwd and domain, if it's not contained int the url
|
||||||
static $defaults=null;
|
|
||||||
if (is_null($defaults))
|
|
||||||
{
|
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'user' => $GLOBALS['egw_info']['user']['account_lid'],
|
'user' => $GLOBALS['egw_info']['user']['account_lid'],
|
||||||
'pass' => urlencode($GLOBALS['egw_info']['user']['passwd']),
|
'pass' => urlencode($GLOBALS['egw_info']['user']['passwd']),
|
||||||
'host' => $GLOBALS['egw_info']['user']['domain'],
|
'host' => $GLOBALS['egw_info']['user']['domain'],
|
||||||
'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']),
|
'home' => str_replace(array('\\\\','\\'),array('','/'),$GLOBALS['egw_info']['user']['homedirectory']),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
$parts = array_merge(Vfs::parse_url($path),$defaults);
|
$parts = array_merge(Vfs::parse_url($path),$defaults);
|
||||||
if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)!
|
if (!$parts['host']) $parts['host'] = 'default'; // otherwise we get an invalid url (scheme:///path/to/something)!
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user