From 82e6798781be9375a485c5606a36f5af9ab34ce9 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 6 Apr 2012 17:47:06 +0200 Subject: [PATCH] initial commit --- createlinks | 34 ++++++++ root/etc/e-smith/accounts/defaults/ajaxplorer/type | 1 + .../db/configuration/defaults/ajaxplorer/access | 1 + .../db/configuration/defaults/ajaxplorer/status | 1 + .../db/configuration/defaults/ajaxplorer/type | 1 + .../e-smith/events/actions/ajaxplorer-user-rights | 50 +++++++++++ .../plugins/auth.serial/__user__/rights.ser | 4 + .../lib/ajaxplorer/plugins/auth.serial/roles.ser | 4 + .../lib/ajaxplorer/plugins/auth.serial/users.ser | 4 + .../plugins/conf.serial/plugins_configs.ser | 4 + .../etc/ajaxplorer/bootstrap_plugins.php/001exec | 1 + .../ajaxplorer/bootstrap_plugins.php/040plugins | 53 ++++++++++++ .../ajaxplorer/bootstrap_repositories.php/001exec | 1 + .../ajaxplorer/bootstrap_repositories.php/050repo | 92 +++++++++++++++++++++ .../etc/httpd/conf/httpd.conf/98Ajaxplorer | 73 ++++++++++++++++ .../conf/httpd.conf/VirtualHosts/60AjaxplorerSSL | 14 ++++ .../plugins/auth.serial/__user__/rights.ser/10All | 46 +++++++++++ .../ajaxplorer/plugins/auth.serial/roles.ser/10All | 32 ++++++++ .../ajaxplorer/plugins/auth.serial/users.ser/10All | 16 ++++ .../plugins/conf.serial/plugins_configs.ser/10All | 20 +++++ smeserver-ajaxplorer.spec | 96 ++++++++++++++++++++++ 21 files changed, 548 insertions(+) create mode 100644 createlinks create mode 100644 root/etc/e-smith/accounts/defaults/ajaxplorer/type create mode 100644 root/etc/e-smith/db/configuration/defaults/ajaxplorer/access create mode 100644 root/etc/e-smith/db/configuration/defaults/ajaxplorer/status create mode 100644 root/etc/e-smith/db/configuration/defaults/ajaxplorer/type create mode 100644 root/etc/e-smith/events/actions/ajaxplorer-user-rights create mode 100644 root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser create mode 100644 root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/roles.ser create mode 100644 root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/users.ser create mode 100644 root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser create mode 100644 root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/001exec create mode 100644 root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/040plugins create mode 100644 root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/001exec create mode 100644 root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/050repo create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Ajaxplorer create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60AjaxplorerSSL create mode 100644 root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser/10All create mode 100644 root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/roles.ser/10All create mode 100644 root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/users.ser/10All create mode 100644 root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser/10All create mode 100644 smeserver-ajaxplorer.spec diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..05669f1 --- /dev/null +++ b/createlinks @@ -0,0 +1,34 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +templates2events("/etc/ajaxplorer/bootstrap_plugins.php", qw(webapps-update bootstrap-console-save)); +templates2events("/var/cache/ajaxplorer/diag_result.php", qw(webapps-update bootstrap-console-save)); +templates2events("/etc/ajaxplorer/bootstrap_repositories.php", qw(webapps-update bootstrap-console-save share-create share-delete share-modify share-modify-servers)); +templates2events("/var/lib/ajaxplorer/plugins/auth.serial/roles.ser", qw(webapps-update bootstrap-console-save share-create share-delete share-modify share-modify-servers)); +templates2events("/var/lib/ajaxplorer/plugins/auth.serial/users.ser", qw(webapps-update bootstrap-console-save user-create user-delete)); +templates2events("/etc/ajaxplorer/diag_result.php", qw(webapps-update bootstrap-console-save)); +templates2events("/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser", qw(webapps-update bootstrap-console-save)); + +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/ajaxplorer/boostrap_plugins.php/template-end"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/etc/ajaxplorer/boostrap_repositories.php/template-end"); +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/var/cache/ajaxplorer/diag_result.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/var/cache/ajaxplorer/diag_result.php/template-end"); + +event_link("ajaxplorer-user-rights", "webapps-update", "85"); +event_link("ajaxplorer-user-rights", "share-create", "85"); +event_link("ajaxplorer-user-rights", "share-delete", "85"); +event_link("ajaxplorer-user-rights", "share-modify", "85"); +event_link("ajaxplorer-user-rights", "share-modify-servers", "85"); +event_link("ajaxplorer-user-rights", "user-delete", "85"); +event_link("ajaxplorer-user-rights", "group-create", "85"); +event_link("ajaxplorer-user-rights", "group-modify", "85"); +event_link("ajaxplorer-user-rights", "group-delete", "85"); +event_link("ajaxplorer-user-rights", "user-modify-admin", "85"); + +safe_touch("root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/roles.ser/template-begin"); +safe_touch("root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser/template-begin"); +safe_touch("root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/users.ser/template-begin"); +safe_touch("root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser/template-begin"); diff --git a/root/etc/e-smith/accounts/defaults/ajaxplorer/type b/root/etc/e-smith/accounts/defaults/ajaxplorer/type new file mode 100644 index 0000000..96cdd3b --- /dev/null +++ b/root/etc/e-smith/accounts/defaults/ajaxplorer/type @@ -0,0 +1 @@ +url diff --git a/root/etc/e-smith/db/configuration/defaults/ajaxplorer/access b/root/etc/e-smith/db/configuration/defaults/ajaxplorer/access new file mode 100644 index 0000000..3e18ebf --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/ajaxplorer/access @@ -0,0 +1 @@ +private diff --git a/root/etc/e-smith/db/configuration/defaults/ajaxplorer/status b/root/etc/e-smith/db/configuration/defaults/ajaxplorer/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/ajaxplorer/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/ajaxplorer/type b/root/etc/e-smith/db/configuration/defaults/ajaxplorer/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/ajaxplorer/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/events/actions/ajaxplorer-user-rights b/root/etc/e-smith/events/actions/ajaxplorer-user-rights new file mode 100644 index 0000000..1e1df71 --- /dev/null +++ b/root/etc/e-smith/events/actions/ajaxplorer-user-rights @@ -0,0 +1,50 @@ +#!/usr/bin/perl -w + +#---------------------------------------------------------------------- +# copyright (C) 2011-2012 Firewall Services +# Daniel Berteaud +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#---------------------------------------------------------------------- + +use strict; +use esmith::templates; +use esmith::AccountsDB; +use File::Path qw(mkpath rmtree); + +my $a = esmith::AccountsDB->open_ro; + +# Remove all the permissions +unlink(); + +# Remove active sessions +unlink(); + +# Remove plugin cache +unlink(); + +foreach my $user (($a->users),$a->get('admin')){ + my $name = $user->key; + mkpath('/var/lib/ajaxplorer/plugins/auth.serial/' . $name); + chmod 0770, "/var/lib/ajaxplorer/plugins/auth.serial/$name"; + chown '0', '102', "/var/lib/ajaxplorer/plugins/auth.serial/$name"; + processTemplate( + { + TEMPLATE_PATH => "/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser", + MORE_DATA => {KEY=>$name}, + OUTPUT_FILENAME => "/var/lib/ajaxplorer/plugins/auth.serial/$name/rights.ser", + }); +} + diff --git a/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser new file mode 100644 index 0000000..69e5009 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser @@ -0,0 +1,4 @@ +PERMS=0660 +UID="root" +GID="www" + diff --git a/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/roles.ser b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/roles.ser new file mode 100644 index 0000000..69e5009 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/roles.ser @@ -0,0 +1,4 @@ +PERMS=0660 +UID="root" +GID="www" + diff --git a/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/users.ser b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/users.ser new file mode 100644 index 0000000..69e5009 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/auth.serial/users.ser @@ -0,0 +1,4 @@ +PERMS=0660 +UID="root" +GID="www" + diff --git a/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser new file mode 100644 index 0000000..69e5009 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser @@ -0,0 +1,4 @@ +PERMS=0660 +UID="root" +GID="www" + diff --git a/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/001exec b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/001exec new file mode 100644 index 0000000..cc84ed5 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/001exec @@ -0,0 +1 @@ +defined('AJXP_EXEC') or die( 'Access not allowed'); diff --git a/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/040plugins b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/040plugins new file mode 100644 index 0000000..1709700 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_plugins.php/040plugins @@ -0,0 +1,53 @@ +/*********************************************************/ +/* PLUGINS DEFINITIONS +/* Drivers will define how the application will work. For +/* each type of operation, there are multiple implementation +/* possible. Check the content of the plugins folder. +/* CONF = users and repositories definition, +/* AUTH = users authentification mechanism, +/* LOG = logs of the application. +/* +/* By default, the three are all based on files. +/* +/* ACTIVE_PLUGINS adds other type of plugins to the application. +/* If you are developping your own plugin, do not forget to declare +/* it here. +/*********************************************************/ +$PLUGINS = array( + "CONF_DRIVER" => array( + "NAME" => "serial", + "OPTIONS" => array( + "REPOSITORIES_FILEPATH" => "/var/lib/ajaxplorer/plugins/conf.serial/repo.ser", + "ROLES_FILEPATH" => "/var/lib/ajaxplorer/plugins/auth.serial/roles.ser", + "USERS_DIRPATH" => "/var/lib/ajaxplorer/plugins/auth.serial", + ) + ), + "AUTH_DRIVER" => array( + "NAME" => "basic_http", + "OPTIONS" => array( + "LOGIN_REDIRECT" => false, + "USERS_FILEPATH" => "/var/lib/ajaxplorer/plugins/auth.serial/users.ser", + "AUTOCREATE_AJXPUSER" => false, + "TRANSMIT_CLEAR_PASS" => false, + "LOGOUT_URL" => "{$ajaxplorer{'LogoutUrl'} || 'http://' . $SystemName . '.' . $DomainName;}" ) + ), + "LOG_DRIVER" => array( + "NAME" => "text", + "OPTIONS" => array( + "LOG_PATH" => "/var/log/ajaxplorer/", + "LOG_FILE_NAME" => 'log_' . date('m-d-y') . '.txt', + "LOG_CHMOD" => 0770 + ) + ), + // Do not use wildcard for uploader, to keep them in a given order + // Warning, do not add the "meta." plugins, they are automatically + // detected and activated by the application. + "ACTIVE_PLUGINS" => array("editor.*", "uploader.flex", "uploader.html", "gui.ajax", "hook.*") +); +if(AJXP_Utils::userAgentIsMobile())\{ + $PLUGINS["ACTIVE_PLUGINS"][] = "gui.mobile"; + if(AJXP_Utils::userAgentIsIOS() && !isSet($_GET["skipIOS"]) && !isSet($_COOKIE["SKIP_IOS"]))\{ + $PLUGINS["ACTIVE_PLUGINS"][] = "gui.ios"; + \} +\} + diff --git a/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/001exec b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/001exec new file mode 100644 index 0000000..cc84ed5 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/001exec @@ -0,0 +1 @@ +defined('AJXP_EXEC') or die( 'Access not allowed'); diff --git a/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/050repo b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/050repo new file mode 100644 index 0000000..f955058 --- /dev/null +++ b/root/etc/e-smith/templates/etc/ajaxplorer/bootstrap_repositories.php/050repo @@ -0,0 +1,92 @@ +/*********************************************************/ +/* BASIC REPOSITORY CONFIGURATION. +/* To add a repository, create a new shared-folders and choose +/* the access with web-based management interface +/*********************************************************/ + +{ +use esmith::AccountsDB; + +my $a = esmith::AccountsDB->open_ro(); + +foreach my $share ($a->get_all_by_prop(type=>'share')){ + my $name = $share->key; + my $access = $share->prop('Ajaxplorer') || 'disabled'; + next unless ($access eq 'enabled'); + my $desc = $share->prop('Name') || $name; + my $recycledir = (($share->prop('RecycleBin') || 'disabled') eq 'disabled') ? + '' : $share->prop('RecycleBinDir') || 'Recycle Bin'; + my $meta = (($share->prop('AjaxplorerIndex') || 'disabled') eq 'disabled') ? + '' : '"index.lucene" => array( + "index_content" => "1", + "index_meta_fields" => "anything_area", + "repository_specific_keywords" => "" + ),' . "\n "; + $meta .= (($share->prop('AjaxplorerMetadata') || 'disabled') eq 'disabled') ? + '' : '"metastore.serial" => array( + "METADATA_FILE_LOCATION" => "outside", + ), + "meta.user" => array ( + "meta_fields" => "stars_rate,css_label,anything_area", + "meta_labels" => "Rate,Type,Note", + ),'; + $OUT .=<<"EOF"; + +\$REPOSITORIES["$name"] = array( + "DISPLAY" => "$desc", + "AJXP_SLUG" => "$name", + "DRIVER" => "fs", + "DRIVER_OPTIONS" => array( + "PATH" => "/home/e-smith/files/shares/$name/files/", + "CREATE" => false, + "RECYCLE_BIN" => '$recycledir', + "CHMOD_VALUE" => '0660', + "DEFAULT_RIGHTS" => "", + "PAGINATION_THRESHOLD" => 500, + "PAGINATION_NUMBER" => 200, + "META_SOURCES" => array( + $meta + ) + ), +); + +EOF + +} + +if (($ajaxplorer{'PublicShares'} || 'disabled') eq 'enabled'){ + $OUT .=<<'EOF'; + +$REPOSITORIES["ajxp_shared"] = array( + "DISPLAY" => "Shared Elements", + "DISPLAY_ID" => "363", + "DRIVER" => "ajxp_shared", + "DRIVER_OPTIONS"=> array( + "DEFAULT_RIGHTS" => "" + ) +); + +EOF + +} + +$OUT .=<<'EOF'; + +// ADMIN REPOSITORY +/* + +Settings interface is disabled because the configuration +is managed by the SME Server templates system +New repositories can be added using the smeserver-shared-folders +contrib + +$REPOSITORIES[1] = array( + "DISPLAY" => "Settings", + "DISPLAY_ID" => "165", + "DRIVER" => "ajxp_conf", + "DRIVER_OPTIONS"=> array() +); +*/ + +EOF +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Ajaxplorer b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Ajaxplorer new file mode 100644 index 0000000..96b26d1 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/98Ajaxplorer @@ -0,0 +1,73 @@ +{ + +use esmith::AccountsDB; +my $a = esmith::AccountsDB->open_ro; + +if (($ajaxplorer{'status'} || 'disabled') eq 'enabled'){ + my $alias = (($ajaxplorer{'AliasOnPrimary'} || 'enabled') eq 'enabled' ) ? 'Alias /ajaxplorer /usr/share/ajaxplorer':''; + my $allow = (($ajaxplorer{'access'} || 'private') eq 'public') ? 'all':"$localAccess $externalSSLAccess"; + my $auth = (($ajaxplorer{'Authentication'} || 'http') eq 'http') ? "AuthName \"Ajaxplorer\"\n" . + " AuthType Basic\n" . + " AuthExternal pwauth\n" . + " Require valid-user\n" : ''; + my $maxsize = $ajaxplorer{'MaxUploadSize'} || '200M'; + + my $shares = ''; + foreach my $share ($a->get_all_by_prop(type=>'share')){ + my $name = $share->key; + my $access = $share->prop('Ajaxplorer') || 'disabled'; + $shares .= ":/home/e-smith/files/shares/$name/files" if ($access eq 'enabled'); + } + + my $public = $ajaxplorer{'PublicShares'} || 'disabled'; + $OUT .=<<"EOF" if ($public eq 'enabled'); + +Alias /ajxppub /var/lib/ajaxplorer/public + + Options None + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/ajaxplorer:/var/lib/ajaxplorer:/var/log/ajaxplorer:/etc/ajaxplorer:/var/cache/ajaxplorer:/usr/share/pear/$shares + Order deny,allow + Allow from all + + deny from all + + + +EOF + + $OUT .=<<"EOF"; + +$alias + + + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/ajaxplorer:/var/lib/ajaxplorer:/var/log/ajaxplorer:/etc/ajaxplorer:/var/cache/ajaxplorer:/usr/share/pear/$shares + php_admin_value memory_limit 100M + php_admin_value upload_max_filesize $maxsize + php_admin_value post_max_size $maxsize + php_admin_value max_execution_time 86400 + php_admin_value upload_tmp_dir /var/lib/ajaxplorer/tmp + php_admin_value session.save_path /var/lib/ajaxplorer/tmp + SSLRequireSSL on + Order deny,allow + Deny from all + Allow from $allow + $auth + + +EOF + +} +else { + $OUT .=<<'EOF'; + +# Ajaxplorer is disabled +# You can enable it with +# db configuration setprop ajaxplorer status enabled +# signal-event webapps-update + +EOF +} + +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60AjaxplorerSSL b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60AjaxplorerSSL new file mode 100644 index 0000000..020f9b0 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/60AjaxplorerSSL @@ -0,0 +1,14 @@ +{ +my $sslport = $modSSL{'TCPPort'} || '443'; +my $status = $ajaxplorer{'status'} || 'enabled'; +my $alias = $ajaxplorer{'AliasOnPrimary'} || 'enabled'; + +if (($port ne $sslport) && ($status eq 'enabled') && ($alias eq 'enabled')){ + + ## Redirect Web Address to Secure Address + $OUT .= " RewriteEngine on\n"; + $OUT .= " RewriteRule ^/ajaxplorer(/.*|\$) https://%{HTTP_HOST}/ajaxplorer\$1 \[L,R\]\n"; + +} +} + diff --git a/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser/10All b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser/10All new file mode 100644 index 0000000..abb9cba --- /dev/null +++ b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/__user__/rights.ser/10All @@ -0,0 +1,46 @@ +{ + +use PHP::Serialization qw(serialize); +use esmith::AccountsDB; + +my $a = esmith::AccountsDB->open_ro || die "Error opening accounts db\n"; +my @s = $a->get_all_by_prop( type => 'share' ); +my $data; +my $id = $KEY; + +foreach my $share (@s){ + my $sharename = $share->key; + my $access = $share->prop('Ajaxplorer') || 'disabled'; + next unless ($access eq 'enabled'); + my @readgroups = split(/[;,]/, $share->prop('ReadGroups') || ''); + my @writegroups = split(/[;,]/, $share->prop('WriteGroups') || ''); + my @readusers = split(/[;,]/, $share->prop('ReadUsers') || ''); + my @writeusers = split(/[;,]/, $share->prop('WriteUsers') || ''); + + + foreach (@readgroups){ + $data->{$sharename} = 'r' if ( $a->is_user_in_group($id,$_) ); + } + foreach (@writegroups){ + $data->{$sharename} = 'rw' if ( $a->is_user_in_group($id,$_) ); + } + foreach (@readusers){ + $data->{$sharename} = 'r' if ( $_ eq $id ); + } + foreach (@writegroups){ + $data->{$sharename} = 'rw' if ( $_ eq $id ); + } + $data->{'ajxp.admin'} = ($id eq 'admin') ? 1:0; +} + +$data->{'ajxp_shared'} = 'rw' + if (($ajaxplorer{'PublicShares'} || 'disabled') eq 'enabled'); + +# Hugly hack to convert int -> bool +my $string = serialize($data); +$string =~ s/i:/b:/; + +$OUT = $string; + +} + diff --git a/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/roles.ser/10All b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/roles.ser/10All new file mode 100644 index 0000000..0c5acce --- /dev/null +++ b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/roles.ser/10All @@ -0,0 +1,32 @@ +{ + +use PHP::Serialization qw(serialize); +use esmith::AccountsDB; + +my $a = esmith::AccountsDB->open_ro || die "Error opening accounts db\n"; + +my @s = $a->get_all_by_prop( type => 'share' ); + +my $data; + +foreach my $group ($a->groups){ + my $groupname = $group->key; + foreach my $share (@s){ + my $sharename = $share->key; + my $access = $share->prop('Ajaxplorer') || 'disabled'; + next unless ($access eq 'enabled'); + my @read = split(/[;,]/, $share->prop('ReadGroups') || ''); + my @write = split(/[;,]/, $share->prop('WriteGroups') || ''); + + $data->{$groupname}->{"\00AjxpRole\00rights"}{$sharename} = 'rw' if ( grep { $groupname eq $_ } @write ); + $data->{$groupname}->{"\00AjxpRole\00rights"}{$sharename} = 'r' if ( grep { $groupname eq $_ } @read ); + $data->{$groupname}->{"\00AjxpRole\00id"} = $groupname; + + $data->{$groupname} = bless $data->{$groupname},'PHP::Serialization::Object::AjxpRole'; + } +} + +$OUT = serialize($data); + +} + diff --git a/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/users.ser/10All b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/users.ser/10All new file mode 100644 index 0000000..d26c975 --- /dev/null +++ b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/auth.serial/users.ser/10All @@ -0,0 +1,16 @@ +{ + +use PHP::Serialization qw(serialize); +use esmith::AccountsDB; + +my $a = esmith::AccountsDB->open_ro || die "Error opening accounts db\n"; +my $data; + +foreach my $user ($a->users,$a->get('admin')){ + my $key = $user->key; + $data->{$key} = $key; +} + +$OUT .= serialize($data); + +} diff --git a/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser/10All b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser/10All new file mode 100644 index 0000000..ed9c094 --- /dev/null +++ b/root/etc/e-smith/templates/var/lib/ajaxplorer/plugins/conf.serial/plugins_configs.ser/10All @@ -0,0 +1,20 @@ +{ +use PHP::Serialization qw(serialize); +my $data; + +$data->{'core.uploader'}->{'UPLOAD_MAX_SIZE'} = "0"; +$data->{'core.uploader'}->{'UPLOAD_MAX_NUMBER'} = "50"; +$data->{'gui.ajax'}->{'CUSTOM_WELCOME_MESSAGE'} = $ajaxplorer{'WelcomMessage'} || 'Ajaxplorer'; +$data->{'core.ajaxplorer'}->{'WEBMASTER_EMAIL'} = 'admin@'.$DomainName; +$data->{'core.ajaxplorer'}->{'AJXP_TMP_DIR'} = '/var/lib/ajaxplorer/tmp'; +$data->{'core.ajaxplorer'}->{'DEFAULT_LANGUAGE'} = $ajaxplorer{'DefaultLanguage'} || 'en'; +$data->{'core.ajaxplorer'}->{'APPLICATION_TITLE'} = $ajaxplorer{'Title'} || 'Ajaxplorer'; + +if (($ajaxplorer{'PublicShares'} || 'disabled') eq 'enabled'){ + $data->{'core.ajaxplorer'}->{'PUBLIC_DOWNLOAD_FOLDER'} = '/var/lib/ajaxplorer/public'; + $data->{'core.ajaxplorer'}->{'PUBLIC_DOWNLOAD_URL'} = $ajaxplorer{'PublicDownloadUrl'} || "http://$SystemName.$DomainName/ajxppub"; +} + +$OUT = serialize($data); + +} diff --git a/smeserver-ajaxplorer.spec b/smeserver-ajaxplorer.spec new file mode 100644 index 0000000..5850f41 --- /dev/null +++ b/smeserver-ajaxplorer.spec @@ -0,0 +1,96 @@ +# Authority: vip-ire +# Name: Daniel Berteaud + +%define name smeserver-ajaxplorer +%define version 0.1.1 +%define release 11 +Summary: sme server integration of ajaxplorer +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GNU GPL version 2 +URL: http://www.ajaxplorer.info/wordpress/ +Group: SMEserver/addon +Source: %{name}-%{version}.tar.gz + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: /var/tmp/%{name}-%{version} +Requires: e-smith-base >= 5.2.0-56 +Requires: ajaxplorer >= 4.0.0 +Requires: smeserver-webapps-common +Requires: smeserver-shared-folders >= 0.1-64 +Requires: perl(PHP::Serialization) +Requires: perl(File::Path) + +%description +smserver integration of ajaxplorer. +Ajaxplorer is a rich-client browser for managing files on a web server +This contrib works with the smeserver-shared-folders addon + +%changelog +* Fri Apr 06 2012 Daniel Berteaud 0.1.1-1 +- Migrate to GIT +- make all shares accessible with open_basedir + +* Sat Feb 18 2012 Daniel Berteaud 0.1-11 +- Support user level ACL + +* Tue Jan 03 2012 Daniel Berteaud 0.1-10 +- Ajaxplorer 4.0 compatibility +- Support publiclets + +* Tue Dec 06 2011 Daniel Berteaud 0.1-9 +- turn on JS debug (IE doesn't like compacted JS) + +* Mon Dec 05 2011 Daniel Berteaud 0.1-8 +- Rise upload_max_number to 50 + +* Wed Nov 23 2011 Daniel Berteaud 0.1-7 +- Allow access to /usr/share/pear and to /usr/share/doc/ajaxplorer-*/client +- Warn the user after 10min of inactivity (instead of 3) +- Add support for logout URL +- Remove plugin cache files on updates +- Add support for meta.serial + +* Thu Nov 03 2011 Daniel Berteaud 0.1-6 +- Fix default Recycle Bin dir + +* Thu Oct 27 2011 Daniel Berteaud 0.1-5 +- Flush active sessions on privileges updates + +* Mon Jul 11 2011 Daniel Berteaud 0.1-4 +- Reserve /ajaxplorer location + +* Tue Jul 05 2011 Daniel B. 0.1-3 +- Honor Recycle Bin settings + +* Tue Jun 28 2011 Daniel B. 0.1-2 +- Call ajaxplorer-user-rights later +- Fix display name of repositories + +* Fri Jun 24 2011 Daniel B. 0.1-1 +- initial release + +%prep +%setup + +%build +perl ./createlinks + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + > %{name}-%{version}-filelist + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +%clean +rm -rf $RPM_BUILD_ROOT + + +%postun +