commit f05d6b75212166cf03aa4f5b8fbf13b3d38a1804 Author: Daniel Berteaud Date: Mon Nov 19 09:30:39 2012 +0100 Initial commit diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..fca5b4e --- /dev/null +++ b/createlinks @@ -0,0 +1,12 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +# Templates to expand +templates2events("/etc/e-smith/sql/init/openuploaddb", qw(bootstrap-console-save webapps-update)); +templates2events("/usr/share/openupload/www/config.inc.php", qw(bootstrap-console-save webapps-update)); + +# PHP header and footer +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/template-end"); + diff --git a/root/etc/e-smith/db/accounts/defaults/openupload/type b/root/etc/e-smith/db/accounts/defaults/openupload/type new file mode 100644 index 0000000..96cdd3b --- /dev/null +++ b/root/etc/e-smith/db/accounts/defaults/openupload/type @@ -0,0 +1 @@ +url diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/DbName b/root/etc/e-smith/db/configuration/defaults/openupload/DbName new file mode 100644 index 0000000..7628136 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/DbName @@ -0,0 +1 @@ +openuploaddb diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/DbUser b/root/etc/e-smith/db/configuration/defaults/openupload/DbUser new file mode 100644 index 0000000..3a8d6e1 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/DbUser @@ -0,0 +1 @@ +openuploaduser diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/MaxUpload b/root/etc/e-smith/db/configuration/defaults/openupload/MaxUpload new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/MaxUpload @@ -0,0 +1 @@ +5 diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/MaxUploadSize b/root/etc/e-smith/db/configuration/defaults/openupload/MaxUploadSize new file mode 100644 index 0000000..29d6383 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/MaxUploadSize @@ -0,0 +1 @@ +100 diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/RequireSSL b/root/etc/e-smith/db/configuration/defaults/openupload/RequireSSL new file mode 100644 index 0000000..7cfab5b --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/RequireSSL @@ -0,0 +1 @@ +yes diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/access b/root/etc/e-smith/db/configuration/defaults/openupload/access new file mode 100644 index 0000000..3e18ebf --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/access @@ -0,0 +1 @@ +private diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/status b/root/etc/e-smith/db/configuration/defaults/openupload/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/openupload/type b/root/etc/e-smith/db/configuration/defaults/openupload/type new file mode 100644 index 0000000..1b93c9e --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/openupload/type @@ -0,0 +1 @@ +webapp diff --git a/root/etc/e-smith/db/configuration/migrate/openupload-database b/root/etc/e-smith/db/configuration/migrate/openupload-database new file mode 100644 index 0000000..4730231 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/openupload-database @@ -0,0 +1,33 @@ +{ + my $rec = $DB->get('openupload') + || $DB->new_record('openupload', {type => 'webapp'}); + my $pw = $rec->prop('DbPassword'); + if (not $pw or length($pw) < 57) + { + use MIME::Base64 qw(encode_base64); + + $pw = "not set due to error"; + if ( open( RANDOM, "/dev/urandom" ) ) + { + my $buf; + # 57 bytes is a full line of Base64 coding, and contains + # 456 bits of randomness - given a perfectly random /dev/random + if ( read( RANDOM, $buf, 57 ) != 57 ) + { + warn("Short read from /dev/random: $!"); + } + else + { + $pw = encode_base64($buf); + chomp $pw; + } + close RANDOM; + } + else + { + warn "Could not open /dev/urandom: $!"; + } + $rec->set_prop('DbPassword', $pw); + } +} + diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/openuploaddb b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/openuploaddb new file mode 100644 index 0000000..940dcf3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/openuploaddb @@ -0,0 +1 @@ +PERMS=0750 diff --git a/root/etc/e-smith/templates.metadata/usr/share/openupload/www/config.inc.php b/root/etc/e-smith/templates.metadata/usr/share/openupload/www/config.inc.php new file mode 100644 index 0000000..a169049 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/usr/share/openupload/www/config.inc.php @@ -0,0 +1,4 @@ +UID="root" +GID="www" +PERMS=0640 + diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/openuploaddb b/root/etc/e-smith/templates/etc/e-smith/sql/init/openuploaddb new file mode 100644 index 0000000..b5a3e62 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/openuploaddb @@ -0,0 +1,51 @@ +{ +my $db = ${'openupload'}{'DbName'} || 'openuploaddb'; +my $user = ${'openupload'}{'DbUser'} || 'openuploaduser'; +my $pass = ${'openupload'}{'DbPassword'} || 'secret'; + +my $dbstruct = `rpm -ql openupload | grep mysql | grep structure`; +my $dbbase = `rpm -ql openupload | grep mysql | grep base`; +my $dbacl = `rpm -ql openupload | grep mysql | grep private`; + + +$OUT .= <<"END"; +#! /bin/sh +if [ ! -d /var/lib/mysql/$db ]; then + /usr/bin/mysql -e 'create database $db' + /usr/bin/mysql $db < $dbstruct + /usr/bin/mysql $db < $dbbase + /usr/bin/mysql $db < $dbacl +fi + +/usr/bin/mysql < + AllowOverride None + $requiressl + AddType application/x-httpd-php .php + php_admin_value open_basedir /usr/share/openupload:/var/lib/openupload + php_admin_flag file_uploads on + php_admin_flag magic_quotes Off + php_admin_flag magic_quotes_gpc Off + php_admin_value upload_max_filesize $maxsize + php_admin_value post_max_size $maxsize + php_admin_value memory_limit $maxsize + php_admin_value max_execution_time 0 + php_admin_value upload_tmp_dir /var/lib/openupload/tmp + php_admin_value session.save_path /var/lib/openupload/tmp + order deny,allow + deny from all + allow from $allow + Satisfy all + + Order allow,deny + Deny from all + + + +END +} +else{ + $OUT .= "# OpenUpload is disabled\n"; +} +} diff --git a/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirOpenUpload b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirOpenUpload new file mode 100644 index 0000000..d787616 --- /dev/null +++ b/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/61RedirOpenUpload @@ -0,0 +1,15 @@ +{ +my $sslport = $modSSL{'TCPPort'} || '443'; +my $alias = $openupload{'AliasOnPrimary'} || 'enabled'; +my $requiressl = $openupload{'RequireSSL'} || 'yes'; + +if (($port ne $sslport) && ($requiressl ne 'no') && ($alias ne 'disabled')){ + + ## Redirect Web Address to Secure Address + $OUT .= " RewriteEngine on\n"; + $OUT .= " RewriteCond %{QUERY_STRING} action=login\n" if ($requiressl eq 'login'); + $OUT .= " RewriteRule ^/openupload(/.*|\$) https://%{HTTP_HOST}/openupload\$1 \[L,R\]\n"; + +} +} + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/10paths b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/10paths new file mode 100644 index 0000000..1e46df2 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/10paths @@ -0,0 +1,9 @@ + +$CONFIG['WWW_SERVER'] = 'http://{"$SystemName.$DomainName";}'; + +$CONFIG['WWW_ROOT'] = '/openupload'; + +$CONFIG['INSTALL_ROOT'] = '/usr/share/openupload/'; + +$CONFIG['DATA_PATH'] = '/var/lib/openupload'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/20database b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/20database new file mode 100644 index 0000000..14bf55b --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/20database @@ -0,0 +1,8 @@ + +$CONFIG['database']['type'] = 'mysql'; +$CONFIG['database']['host'] = 'localhost'; +$CONFIG['database']['user'] = '{"$openupload{'DbUser'}";}'; +$CONFIG['database']['password'] = '{"$openupload{'DbPassword'}";}'; +$CONFIG['database']['name'] = '{"$openupload{'DbName'}";}'; +$CONFIG['database']['prefix'] = ''; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/30register b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/30register new file mode 100644 index 0000000..bc457f1 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/30register @@ -0,0 +1,5 @@ + +$CONFIG['registration']['email_confirm'] = 'yes'; +$CONFIG['register']['nologingroup'] = 'unregistered'; +$CONFIG['register']['default_group'] = 'registered'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/40site b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/40site new file mode 100644 index 0000000..29db4ee --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/40site @@ -0,0 +1,7 @@ + +$CONFIG['site']['title'] = 'Open Upload'; +$CONFIG['site']['webmaster'] = 'admin@{"$DomainName";}'; +$CONFIG['site']['email'] = 'admin@{"$DomainName";}'; +$CONFIG['site']['footer'] = 'Open Upload - Created by Alessandro Briosi © 2009'; +$CONFIG['site']['template'] = 'default'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/50upload b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/50upload new file mode 100644 index 0000000..08bf81a --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/50upload @@ -0,0 +1,17 @@ + +$CONFIG['max_upload_size'] = '{"$openupload{'MaxUploadSize'}";}'; + +$CONFIG['use_short_links'] = 'yes'; + +$CONFIG['id_max_length'] = '10'; + +$CONFIG['id_use_alpha'] = 'yes'; + +$CONFIG['max_download_time'] = '0'; + +$CONFIG['multiupload'] = '{"$openupload{'MaxUpload'}";}'; + +$CONFIG['allow_unprotected_removal'] = ''; + +$CONFIG['progress'] = 'none'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/60settings b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/60settings new file mode 100644 index 0000000..d0aa652 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/60settings @@ -0,0 +1,5 @@ + +$CONFIG['translator'] = 'phparray'; + +$CONFIG['defaultlang'] = 'en'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/70log b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/70log new file mode 100644 index 0000000..5ecef0d --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/70log @@ -0,0 +1,5 @@ + +$CONFIG['logging']['enabled'] = 'yes'; +$CONFIG['logging']['db_level'] = '4'; +$CONFIG['logging']['syslog_level'] = '0'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/80plugins b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/80plugins new file mode 100644 index 0000000..d68968c --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/80plugins @@ -0,0 +1,9 @@ + +$CONFIG['plugins']['0'] = 'captcha'; +$CONFIG['plugins']['1'] = 'compress'; +$CONFIG['plugins']['2'] = 'email'; +$CONFIG['plugins']['3'] = 'expire'; +$CONFIG['plugins']['4'] = 'filesize'; +$CONFIG['plugins']['5'] = 'mimetypes'; +$CONFIG['plugins']['6'] = 'password'; + diff --git a/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/90auth b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/90auth new file mode 100644 index 0000000..3aed7d2 --- /dev/null +++ b/root/etc/e-smith/templates/usr/share/openupload/www/config.inc.php/90auth @@ -0,0 +1,49 @@ +{ + +my $auth = $openupload{'Authentication'} || 'ldap'; +my $ldapbase = esmith::util::ldapBase($DomainName); + +if ($auth eq 'imap'){ + $OUT .=<<"EOF"; + +\$CONFIG['auth'] = 'imap'; +\$CONFIG['imap']['server'] = "\{localhost/imap/notls\}"; +\$CONFIG['imap']['domain'] = "$DomainName"; +\$CONFIG['imap']['default_group'] = 'registered'; + +EOF +} +elsif ($auth eq 'database' or $auth eq 'internal'){ + $OUT .=<<"EOF"; + +\$CONFIG['auth'] = 'default'; + +EOF +} +elsif ($auth eq 'ldap' or $auth eq 'LemonLDAP'){ + + if ($auth eq 'ldap'){ + $OUT .= "\$CONFIG['auth'] = 'ldap';\n"; + } + elsif ($auth eq 'LemonLDAP'){ + $OUT .= "\$CONFIG['auth'] = 'httpldap';\n"; + $OUT .= "\$CONFIG['httpldap']['login'] = 'HTTP_AUTH_USER';\n"; + } + $OUT .=<<"EOF"; + +\$CONFIG['ldap']['host'] = '127.0.0.1'; +\$CONFIG['ldap']['basedn'] = "$ldapbase"; +\$CONFIG['ldap']['userdn'] = 'ou=Users,$ldapbase'; +\$CONFIG['ldap']['userclass'] = 'inetOrgPerson'; +\$CONFIG['ldap']['uid'] = 'uid'; +\$CONFIG['ldap']['userfields'] = array ( 'uid' => 'login', 'cn' => 'name', 'gidnumber' => 'group_id', 'mail' => 'email'); +\$CONFIG['ldap']['groupdn'] = 'ou=Groups,$ldapbase'; +\$CONFIG['ldap']['groupclass'] = 'mailboxRelatedObject'; +\$CONFIG['ldap']['gid'] = 'gidNumber'; +\$CONFIG['ldap']['sgid'] = 'memberUid'; +\$CONFIG['ldap']['groupfields'] = array ( 'cn' => 'name', 'description' => 'description' ); +\$CONFIG['ldap']['sgroupfields'] = array ( 'cn' => 'name', 'description' => 'description' ); + +EOF +} +} diff --git a/smeserver-openupload.spec b/smeserver-openupload.spec new file mode 100644 index 0000000..121fcb4 --- /dev/null +++ b/smeserver-openupload.spec @@ -0,0 +1,108 @@ +# Authority: vip-ire +# Name: Daniel Berteaud + +%define name smeserver-openupload +%define version 0.1 +%define release 11 +Summary: sme server integration of openupload +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +License: GNU GPL version 2 +URL: http://openupload.sourceforge.net/ +Group: SMEserver/addon +Source: %{name}-%{version}.tar.gz +Patch1: smeserver-openupload-0.1-session_save_path.patch +Patch2: smeserver-openupload-0.1-prop_alias_on_primary.patch +Patch3: smeserver-openupload-0.1-support_lemonldap_auth.patch +Patch4: smeserver-openupload-0.1-fix_ldap_auth_config.patch +Patch5: smeserver-openupload-0.1-make_ldap_the_default_auth.patch +Patch6: smeserver-openupload-0.1-dont_rewrite_if_alias_is_disabled.patch +Patch7: smeserver-openupload-0.1-add_login_field.patch +Patch8: smeserver-openupload-0.1-fix_defaults_db.patch +Patch9: smeserver-openupload-0.1-remove_default_auth.patch +Patch10: smeserver-openupload-0.1-fix_public_access.patch + +BuildArchitectures: noarch +BuildRequires: e-smith-devtools +BuildRoot: /var/tmp/%{name}-%{version} +Requires: e-smith-base >= 5.2.0-56 +Requires: openupload +Requires: smeserver-webapps-common +AutoReqProv: no + +%description +smserver integration of openupload. +OpenUpload is an open source application to share files over +the internet (like MegaUpload or RapidShare for example) + +%changelog +* Wed Oct 19 2011 Daniel Berteaud 0.1-11.sme +- Fix public access property handling + +* Thu Jul 21 2011 Daniel Berteaud 0.1-10.sme +- Remove DB fragment for authentication + +* Mon Jul 11 2011 Daniel Berteaud 0.1-9 +- Fix accounts defaults fragments location + +* Wed May 04 2011 Daniel B. 0.1-8 +- Requires e-smith-base >= 5.2.0-56 + +* Thu Feb 17 2011 Daniel B. 0.1-7 +- Add default login field for httpldap auth + +* Mon Jan 31 2011 Daniel B. 0.1-6 +- Fix templates for LDAP auth +- LDAP is now the default auth +- Don't add useless rewriterules in apache if alias is disabled +- Stop disabling openupload on rpm removal + +* Wed Jan 05 2011 Daniel B. 0.1-5 +- Add AliasOnPrimary prop +- Support LemonLDAP auth + +* Tue Dec 14 2010 Daniel B. 0.1-4 +- Revert previous change + +* Tue Nov 23 2010 Daniel B. 0.1-3 +- Change owner and group from apache to www + +* Thu Mar 11 2010 Daniel B. 0.1-2 +- put session files in /var/lib/openupload/tmp to prevent conflicts + +* Tue Mar 09 2010 Daniel B. 0.1-1 +- initial release + +%prep +%setup +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 + +%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 +