fix bitrot in util/zotsh
This commit is contained in:
parent
6f8c977e73
commit
beeafc6bc5
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Zotlabs\Module\Admin;
|
namespace Zotlabs\Module\Admin;
|
||||||
|
|
||||||
|
use App;
|
||||||
use \Zotlabs\Storage\GitRepo;
|
use \Zotlabs\Storage\GitRepo;
|
||||||
use \Michelf\MarkdownExtra;
|
use \Michelf\MarkdownExtra;
|
||||||
|
|
||||||
@ -253,14 +254,14 @@ class Addons {
|
|||||||
* Single plugin
|
* Single plugin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (\App::$argc == 3){
|
if (App::$argc == 3){
|
||||||
$plugin = \App::$argv[2];
|
$plugin = App::$argv[2];
|
||||||
if (!is_file("addon/$plugin/$plugin.php")){
|
if (!is_file("addon/$plugin/$plugin.php")){
|
||||||
notice( t("Item not found.") );
|
notice( t("Item not found.") );
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$enabled = in_array($plugin,\App::$plugins);
|
$enabled = in_array($plugin,App::$plugins);
|
||||||
$info = get_plugin_info($plugin);
|
$info = get_plugin_info($plugin);
|
||||||
$x = check_plugin_versions($info);
|
$x = check_plugin_versions($info);
|
||||||
|
|
||||||
@ -268,11 +269,11 @@ class Addons {
|
|||||||
|
|
||||||
if($enabled && ! $x) {
|
if($enabled && ! $x) {
|
||||||
$enabled = false;
|
$enabled = false;
|
||||||
$idz = array_search($plugin, \App::$plugins);
|
$idz = array_search($plugin, App::$plugins);
|
||||||
if ($idz !== false) {
|
if ($idz !== false) {
|
||||||
unset(\App::$plugins[$idz]);
|
unset(App::$plugins[$idz]);
|
||||||
uninstall_plugin($plugin);
|
uninstall_plugin($plugin);
|
||||||
set_config("system","addon", implode(", ",\App::$plugins));
|
set_config("system","addon", implode(", ",App::$plugins));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$info['disabled'] = 1-intval($x);
|
$info['disabled'] = 1-intval($x);
|
||||||
@ -281,19 +282,19 @@ class Addons {
|
|||||||
check_form_security_token_redirectOnErr('/admin/addons', 'admin_addons', 't');
|
check_form_security_token_redirectOnErr('/admin/addons', 'admin_addons', 't');
|
||||||
$pinstalled = false;
|
$pinstalled = false;
|
||||||
// Toggle plugin status
|
// Toggle plugin status
|
||||||
$idx = array_search($plugin, \App::$plugins);
|
$idx = array_search($plugin, App::$plugins);
|
||||||
if ($idx !== false){
|
if ($idx !== false){
|
||||||
unset(\App::$plugins[$idx]);
|
unset(App::$plugins[$idx]);
|
||||||
uninstall_plugin($plugin);
|
uninstall_plugin($plugin);
|
||||||
$pinstalled = false;
|
$pinstalled = false;
|
||||||
info( sprintf( t("Plugin %s disabled."), $plugin ) );
|
info( sprintf( t("Plugin %s disabled."), $plugin ) );
|
||||||
} else {
|
} else {
|
||||||
\App::$plugins[] = $plugin;
|
App::$plugins[] = $plugin;
|
||||||
install_plugin($plugin);
|
install_plugin($plugin);
|
||||||
$pinstalled = true;
|
$pinstalled = true;
|
||||||
info( sprintf( t("Plugin %s enabled."), $plugin ) );
|
info( sprintf( t("Plugin %s enabled."), $plugin ) );
|
||||||
}
|
}
|
||||||
set_config("system","addon", implode(", ",\App::$plugins));
|
set_config("system","addon", implode(", ",App::$plugins));
|
||||||
|
|
||||||
if($pinstalled) {
|
if($pinstalled) {
|
||||||
@require_once("addon/$plugin/$plugin.php");
|
@require_once("addon/$plugin/$plugin.php");
|
||||||
@ -305,7 +306,7 @@ class Addons {
|
|||||||
|
|
||||||
// display plugin details
|
// display plugin details
|
||||||
|
|
||||||
if (in_array($plugin, \App::$plugins)){
|
if (in_array($plugin, App::$plugins)){
|
||||||
$status = 'on';
|
$status = 'on';
|
||||||
$action = t('Disable');
|
$action = t('Disable');
|
||||||
} else {
|
} else {
|
||||||
@ -380,18 +381,18 @@ class Addons {
|
|||||||
|
|
||||||
list($tmp, $id) = array_map('trim', explode('/', $file));
|
list($tmp, $id) = array_map('trim', explode('/', $file));
|
||||||
$info = get_plugin_info($id);
|
$info = get_plugin_info($id);
|
||||||
$enabled = in_array($id,\App::$plugins);
|
$enabled = in_array($id,App::$plugins);
|
||||||
$x = check_plugin_versions($info);
|
$x = check_plugin_versions($info);
|
||||||
|
|
||||||
// disable plugins which are installed but incompatible versions
|
// disable plugins which are installed but incompatible versions
|
||||||
|
|
||||||
if($enabled && ! $x) {
|
if($enabled && ! $x) {
|
||||||
$enabled = false;
|
$enabled = false;
|
||||||
$idz = array_search($id, \App::$plugins);
|
$idz = array_search($id, App::$plugins);
|
||||||
if ($idz !== false) {
|
if ($idz !== false) {
|
||||||
unset(\App::$plugins[$idz]);
|
unset(App::$plugins[$idz]);
|
||||||
uninstall_plugin($id);
|
uninstall_plugin($id);
|
||||||
set_config("system","addon", implode(", ",\App::$plugins));
|
set_config("system","addon", implode(", ",App::$plugins));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$info['disabled'] = 1-intval($x);
|
$info['disabled'] = 1-intval($x);
|
||||||
|
@ -35,13 +35,6 @@ class Cloud extends \Zotlabs\Web\Controller {
|
|||||||
if (argc() > 1)
|
if (argc() > 1)
|
||||||
$which = argv(1);
|
$which = argv(1);
|
||||||
|
|
||||||
|
|
||||||
if (argc() < 2 && intval(get_config('system','cloud_disable_siteroot'))) {
|
|
||||||
notice( t('Permission denied.') . EOL);
|
|
||||||
construct_page();
|
|
||||||
killme();
|
|
||||||
}
|
|
||||||
|
|
||||||
$profile = 0;
|
$profile = 0;
|
||||||
|
|
||||||
if ($which)
|
if ($which)
|
||||||
|
@ -95,6 +95,8 @@ class Dav extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
|
|
||||||
$auth = new \Zotlabs\Storage\BasicAuth();
|
$auth = new \Zotlabs\Storage\BasicAuth();
|
||||||
|
$auth->observer = get_observer_hash();
|
||||||
|
|
||||||
$auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . ' ' . 'WebDAV');
|
$auth->setRealm(ucfirst(\Zotlabs\Lib\System::get_platform_name()) . ' ' . 'WebDAV');
|
||||||
|
|
||||||
$rootDirectory = new \Zotlabs\Storage\Directory('/', $auth);
|
$rootDirectory = new \Zotlabs\Storage\Directory('/', $auth);
|
||||||
|
@ -720,7 +720,11 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
|
|||||||
* @return array Directory[]
|
* @return array Directory[]
|
||||||
*/
|
*/
|
||||||
function ChannelList(&$auth) {
|
function ChannelList(&$auth) {
|
||||||
$ret = array();
|
$ret = [];
|
||||||
|
|
||||||
|
if (intval(get_config('system','cloud_disable_siteroot'))) {
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT channel_id, channel_address, profile.publish FROM channel left join profile on profile.uid = channel.channel_id WHERE channel_removed = 0 AND channel_system = 0 AND (channel_pageflags & %d) = 0",
|
$r = q("SELECT channel_id, channel_address, profile.publish FROM channel left join profile on profile.uid = channel.channel_id WHERE channel_removed = 0 AND channel_system = 0 AND (channel_pageflags & %d) = 0",
|
||||||
intval(PAGE_HIDDEN)
|
intval(PAGE_HIDDEN)
|
||||||
@ -730,8 +734,7 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota, DAV\IMo
|
|||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage') && $rr['publish']) {
|
if (perm_is_allowed($rr['channel_id'], $auth->observer, 'view_storage') && $rr['publish']) {
|
||||||
logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA);
|
logger('found channel: /cloud/' . $rr['channel_address'], LOGGER_DATA);
|
||||||
// @todo can't we drop '/cloud'? It gets stripped off anyway in RedDirectory
|
$ret[] = new Directory($rr['channel_address'], $auth);
|
||||||
$ret[] = new Directory('/cloud/' . $rr['channel_address'], $auth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,13 @@ Extract somewere and launch zotsh.py
|
|||||||
Description
|
Description
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
Update: 2019-08-14
|
||||||
|
|
||||||
|
Have just looked at this after several years of bitrot and made some updates.
|
||||||
|
it functions for cli DAV access on your assigned hub, but magic-auth to dav repos on other hubs
|
||||||
|
(e.g. the host command) needs to be updated to work with openwebauth.
|
||||||
|
|
||||||
|
----
|
||||||
ZotSH is a command line WebDAV client for Hubzilla.
|
ZotSH is a command line WebDAV client for Hubzilla.
|
||||||
It knows how to magic-auth to remote hubs using Zot.
|
It knows how to magic-auth to remote hubs using Zot.
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -31,7 +31,7 @@ File = namedtuple('File', ['name', 'size', 'mtime', 'ctime', 'contenttype'])
|
|||||||
|
|
||||||
def prop(elem, name, default=None):
|
def prop(elem, name, default=None):
|
||||||
child = elem.find('.//{DAV:}' + name)
|
child = elem.find('.//{DAV:}' + name)
|
||||||
return default if child is None else child.text
|
return default if child is None or child.text is None else child.text
|
||||||
|
|
||||||
|
|
||||||
def elem2file(elem):
|
def elem2file(elem):
|
||||||
|
Binary file not shown.
@ -1,10 +1,12 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import requests
|
import requests
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
import easywebdav
|
import easywebdav
|
||||||
import easywebdav.__version__ as easywebdavversion
|
import easywebdav.__version__ as easywebdavversion
|
||||||
|
import base64
|
||||||
|
|
||||||
__version__= "0.0.2"
|
__version__= "0.0.2"
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ class ZotSH(object):
|
|||||||
@session.setter
|
@session.setter
|
||||||
def session(self, session):
|
def session(self, session):
|
||||||
self._session = session
|
self._session = session
|
||||||
self.davclient = easywebdav.connect( self.hostname, protocol='https', session=session, path="cloud", verify_ssl=VERIFY_SSL)
|
self.davclient = easywebdav.connect( self.hostname, protocol='https', session=session, path="dav", verify_ssl=VERIFY_SSL)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def PS1(self):
|
def PS1(self):
|
||||||
@ -82,12 +84,12 @@ class ZotSH(object):
|
|||||||
#session.params.update({'davguest':1})
|
#session.params.update({'davguest':1})
|
||||||
else:
|
else:
|
||||||
session = self.session
|
session = self.session
|
||||||
session.params.update({'davguest': (not host == SERVER) })
|
#session.params.update({'davguest': (not host == SERVER) })
|
||||||
return session
|
return session
|
||||||
|
|
||||||
def do(self, command, *args):
|
def do(self, command, *args):
|
||||||
if not command in self.commands:
|
if not command in self.commands:
|
||||||
raise CommandNotFound("Unknow command '%s'" % command)
|
raise CommandNotFound("Unknown command '%s'" % command)
|
||||||
|
|
||||||
cmd = getattr(self, "cmd_%s"%command, None)
|
cmd = getattr(self, "cmd_%s"%command, None)
|
||||||
if cmd is None:
|
if cmd is None:
|
||||||
@ -152,30 +154,17 @@ class ZotSH(object):
|
|||||||
session_remote = self.get_host_session(newhost)
|
session_remote = self.get_host_session(newhost)
|
||||||
session_home = self.get_host_session(SERVER)
|
session_home = self.get_host_session(SERVER)
|
||||||
|
|
||||||
# call /magic on SERVER
|
bnewhost = newhost + 'dav'
|
||||||
|
bnewhost = bnewhost.encode('hex')
|
||||||
|
|
||||||
r = session_home.get(
|
r = session_home.get(
|
||||||
SERVER + "magic",
|
SERVER + "magic",
|
||||||
params={'dest': newhost},
|
params={'bdest': bnewhost, 'owa': 1},
|
||||||
allow_redirects=False,
|
allow_redirects=True,
|
||||||
verify=VERIFY_SSL )
|
verify=VERIFY_SSL )
|
||||||
|
|
||||||
if not 'location' in r.headers:
|
|
||||||
raise Exception("Cannot start magic auth to '%s'" % newhostname)
|
|
||||||
auth_url = r.headers['location']
|
|
||||||
|
|
||||||
|
|
||||||
# call auth_url with "test" param
|
|
||||||
|
|
||||||
r = session_remote.get(
|
|
||||||
auth_url,
|
|
||||||
params={'test': 1 },
|
|
||||||
verify=VERIFY_SSL )
|
|
||||||
|
|
||||||
if r.json()['success']:
|
|
||||||
self.hostname = newhostname
|
self.hostname = newhostname
|
||||||
self.session = session_remote
|
self.session = session_remote
|
||||||
else:
|
|
||||||
raise Exception("Cannot magic auth to '%s'" % newhostname)
|
|
||||||
|
|
||||||
|
|
||||||
def cmd_pwd(self, *args):
|
def cmd_pwd(self, *args):
|
||||||
@ -205,7 +194,7 @@ class ZotSH(object):
|
|||||||
print _fmt('d', 0, "../")
|
print _fmt('d', 0, "../")
|
||||||
|
|
||||||
for f in r:
|
for f in r:
|
||||||
name = f.name.replace("/cloud"+self.davclient.cwd,"")
|
name = f.name.replace("/dav"+self.davclient.cwd,"")
|
||||||
type = "-"
|
type = "-"
|
||||||
if name.endswith("/"):
|
if name.endswith("/"):
|
||||||
type = "d"
|
type = "d"
|
||||||
|
Reference in New Issue
Block a user