diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/createlinks mezzanine_patched_smeserver-shared-folders-0.1/createlinks --- smeserver-shared-folders-0.1/createlinks 2009-05-17 20:09:55.000000000 +0200 +++ mezzanine_patched_smeserver-shared-folders-0.1/createlinks 2009-05-17 19:19:34.000000000 +0200 @@ -33,7 +33,9 @@ foreach my $event (qw(share-create share-modify share-delete share-modify-servers)) { templates2events("/etc/samba/smb.conf", $event); + templates2events("/etc/httpd/conf/httpd.conf", $event); safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/smbd"); + safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); } templates2events("/etc/fstab", "post-upgrade"); diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess50shares mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess50shares --- smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess50shares 1970-01-01 01:00:00.000000000 +0100 +++ mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess50shares 2009-05-17 19:19:34.000000000 +0200 @@ -0,0 +1,144 @@ +#------------------------------------------------------------ +# Shared Folders HTTP Access +#------------------------------------------------------------ + +{ + use esmith::AccountsDB; + my $adb = esmith::AccountsDB->open_ro(); + $OUT = ""; + foreach my $share ($adb->get_all_by_prop(type => 'share')) + { + my %properties = $share->props; + my $key = $share->key; + + my $allow; + my $pass; + my $satisfy; + + # Find which users has at least read access + my @users = ('admin'); + if ($properties{'WriteGroups'}) { + my @groups = split (/[;,]/, $properties{'WriteGroups'}); + + foreach my $group (@groups) { + my $members = $adb->get_prop($group, 'Members') || ""; + if (length($members) > 0) { + push @users, split (/[;,]/, $members); + } + } + + } + if ($properties{'ReadGroups'}) { + my @groups = split (/[;,]/, $properties{'ReadGroups'}); + + foreach my $group (@groups) { + my $members = $adb->get_prop($group, 'Members') || ""; + if (length($members) > 0) { + push @users, split (/[;,]/, $members); + } + } + + } + + my %seen = (); + my @unique = sort (grep { ! $seen{ $_ }++ } @users); + + my $users = join(" ", @unique) || ''; + + if ($properties{'httpAccess'}) + { + if ($properties{'httpAccess'} eq 'none') + { + next; + } + elsif ($properties{'httpAccess'} eq 'local') + { + $allow = $localAccess; + $pass = 0; + $satisfy = 'all'; + } + elsif ($properties{'httpAccess'} eq 'local-pw') + { + $allow = $localAccess; + $pass = 1; + $satisfy = 'all'; + } + elsif ($properties{'httpAccess'} eq 'global') + { + $allow = 'all'; + $pass = 0; + $satisfy = 'all'; + } + elsif ($properties{'httpAccess'} eq 'global-pw') + { + $allow = 'all'; + $pass = 1; + $satisfy = 'all'; + } + elsif ($properties{'httpAccess'} eq 'global-pw-remote') + { + $allow = $localAccess; + $pass = 1; + $satisfy = 'any'; + } + } + + my $allowOverride = $properties{'AllowOverride'} || "None"; + my $followSymLinks = $properties{'FollowSymLinks'} || "disabled"; + my $indexes = $properties{'Indexes'} || "enabled"; + my $requireSSL = $properties{'RequireSSL'} || "enabled"; + my $dynamicContent = $properties{'DynamicContent'} || "disabled"; + + $OUT .= "\n"; + $OUT .= "#------------------------------------------------------------\n"; + $OUT .= "# $key shared folder ($properties{'Name'})\n"; + $OUT .= "#------------------------------------------------------------\n"; + + $OUT .= "\n"; + $OUT .= "\n"; + $OUT .= " Options None\n"; + $OUT .= " Options +Indexes\n" if ($indexes eq 'enabled'); + $OUT .= " Options +FollowSymLinks\n" if ($followSymLinks eq 'enabled'); + $OUT .= " SSLRequireSSL on\n" if ($requireSSL eq 'enabled'); + + if ($dynamicContent eq 'enabled') + { + $OUT .= " Options +Includes\n"; + $OUT .= " AddType application/x-httpd-php .php .php3 .phtml\n"; + $OUT .= " AddType application/x-httpd-php-source .phps\n"; + + my $basedir = $properties{PHPBaseDir} + || ("/home/e-smith/files/shares/$key/"); + $OUT .= " php_admin_value open_basedir $basedir\n"; + $OUT .= " php_admin_flag register_globals on\n" if (($properties{PHPRegisterGlobals} || 'disabled') eq 'enabled'); + $OUT .= " php_admin_value memory_limit $properties{PHPMemoryLimit}\n" if ($properties{PHPMemoryLimit}); + $OUT .= " php_admin_value max_execution_time $properties{PHPMaxExecutionTime}\n" if ($properties{PHPMaxExecutionTime}); + + } + else + { + $OUT .= " DirectoryIndex index.shtml index.htm index.html\n"; + $OUT .= " Options +IncludesNOEXEC\n"; + $OUT .= " \n"; + $OUT .= " order deny,allow\n"; + $OUT .= " Deny from all\n"; + $OUT .= " \n"; + } + + $OUT .= " AllowOverride $allowOverride\n"; + $OUT .= " order deny,allow\n"; + $OUT .= " deny from all\n"; + $OUT .= " allow from $allow\n"; + if ($pass) + { + $OUT .= " AuthName \"$properties{'Name'}\"\n"; + $OUT .= " AuthType Basic\n"; + $OUT .= " AuthExternal pwauth\n"; + $OUT .= " require user $users\n"; + $OUT .= " Satisfy $satisfy\n"; + } + + $OUT .= "\n"; + + } +} diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/25ShareContent mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/25ShareContent --- smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/25ShareContent 1970-01-01 01:00:00.000000000 +0100 +++ mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/25ShareContent 2009-05-17 19:19:34.000000000 +0200 @@ -0,0 +1,42 @@ +{ + use esmith::AccountsDB; + my $accounts = esmith::AccountsDB->open_ro; + + use esmith::DomainsDB; + my $domains = esmith::DomainsDB->open_ro; + + $OUT = ""; + + my $share = $virtualHostContent; + my $basedir = "/home/e-smith/files/shares/$share"; + + if (($domains->get_prop($virtualHost, 'SystemPrimaryDomain') || 'no') + eq 'yes') + { + my @shares = $accounts->get_all_by_prop(type => 'share'); + foreach my $share (@shares) + { + my $key = $share->key; + my $access = $share->prop('httpAccess') || 'none'; + next if (($access eq 'none') || ($key eq $virtualHostContent)); + my $basedir = "/home/e-smith/files/shares/$key"; + my $name = $share->prop("Name") || ""; + + $OUT .= "\n"; + $OUT .= " # $key share ($name)\n"; + $OUT .= "\n"; + + my $SSLPort = $modSSL{'TCPPort'} || '443'; + + if (( $port ne $SSLPort ) && (($share->prop('RequireSSL') || 'enabled') eq 'enabled')){ + $OUT .= " RewriteEngine on\n"; + $OUT .= " RewriteRule ^/$key(/.*|\$) https://%{HTTP_HOST}/$key\$1 \[L,R\]\n"; + } + else{ + $OUT .= " Alias /$key $basedir/files\n"; + } + } + $OUT .= " # No shares in system\n" unless @shares; + } +} + diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/90shares mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/90shares --- smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/90shares 2009-04-08 11:55:18.000000000 +0200 +++ mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/90shares 2009-05-17 19:19:34.000000000 +0200 @@ -6,7 +6,7 @@ foreach my $share ($adb->get_all_by_prop(type => 'share')) { - if ( ($share->prop('status') || 'enabled') eq 'enabled'){ + if ( ($share->prop('smbAccess') || 'browseable') =~ /browseable$/ ){ $OUT .= esmith::templates::processTemplate ( { MORE_DATA => { diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/shares/40browseable mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/shares/40browseable --- smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/shares/40browseable 2009-04-08 11:55:18.000000000 +0200 +++ mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/templates/etc/smb.conf/shares/40browseable 2009-05-17 19:19:34.000000000 +0200 @@ -1,5 +1,5 @@ { - if ( ($share->prop('Browseable') || 'yes') eq 'no') { + if ( ($share->prop('smbAccess') || 'browseable') eq 'non-browseable') { $OUT .= "browseable = no\n"; } } diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/root/etc/e-smith/web/functions/shares mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/web/functions/shares --- smeserver-shared-folders-0.1/root/etc/e-smith/web/functions/shares 2009-04-08 11:55:18.000000000 +0200 +++ mezzanine_patched_smeserver-shared-folders-0.1/root/etc/e-smith/web/functions/shares 2009-05-17 20:09:48.000000000 +0200 @@ -47,6 +47,9 @@ + + + - - - DESC_STATUS + + + + DESC_SMB_SETTINGS - - DESC_BROWSEABLE - + id="smbaccess" + options="smbAccess_list()"> + + DESC_SMB_ACCESS + DESC_RECYCLEBIN - + + + + DESC_HTTP_SETTINGS + + + + + DESC_HTTP_ACCESS + + + + + DESC_REQUIRE_SSL + + + + + DESC_INDEXES + + + + + DESC_DYNAMIC_CONTENT + + + REMOVE_TITLE diff -Nur -x '*.orig' -x '*.rej' smeserver-shared-folders-0.1/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/shares.pm mezzanine_patched_smeserver-shared-folders-0.1/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/shares.pm --- smeserver-shared-folders-0.1/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/shares.pm 2009-04-08 11:55:18.000000000 +0200 +++ mezzanine_patched_smeserver-shared-folders-0.1/root/usr/lib/perl5/site_perl/esmith/FormMagick/Panel/shares.pm 2009-05-17 19:19:34.000000000 +0200 @@ -24,12 +24,15 @@ print_share_table print_share_name_field genGroupAccess + smbAccess_list + httpAccess_list max_share_name_length handle_shares remove_share print_save_or_add_button wherenext print_custom_button + print_section_bar ); our $VERSION = sprintf '%d.%03d', q$Revision: 1.8 $ =~ /: (\d+).(\d+)/; @@ -172,9 +175,12 @@ # Set default value my $q = $self->{cgi}; - $q->param(-name=>'status',-value=>'enabled'); - $q->param(-name=>'browseable',-value=>'yes'); + $q->param(-name=>'smbaccess',-value=>'browseable'); $q->param(-name=>'recyclebin',-value=>'disabled'); + $q->param(-name=>'httpaccess',-value=>'none'); + $q->param(-name=>'requireSSL',-value=>'disabled'); + $q->param(-name=>'indexes',-value=>'disabled'); + $q->param(-name=>'dynamic',-value=>'disabled'); print qq() . $self->localise('NAME_FIELD_DESC', {maxLength => $maxLength }) . qq(); @@ -200,12 +206,18 @@ $rec->prop('ReadGroups')); $q->param(-name=>'WriteGroups',-value=> $rec->prop('WriteGroups')); - $q->param(-name=>'status',-value=> - ($rec->prop('status') || 'enabled')); - $q->param(-name=>'browseable',-value=> - ($rec->prop('Browseable') || 'yes')); + $q->param(-name=>'smbaccess',-value=> + ($rec->prop('smbAccess') || 'enabled')); $q->param(-name=>'recyclebin',-value=> ($rec->prop('RecycleBin') || 'disabled')); + $q->param(-name=>'httpaccess',-value=> + ($rec->prop('httpAccess') || 'none')); + $q->param(-name=>'requireSSL',-value=> + ($rec->prop('RequireSSL') || 'enabled')); + $q->param(-name=>'indexes',-value=> + ($rec->prop('Indexes') || 'enabled')); + $q->param(-name=>'dynamic',-value=> + ($rec->prop('DynamicContent') || 'disabled')); } } else { @@ -278,6 +290,40 @@ return $out; } +# Print a section bar +sub print_section_bar{ + my ($fm) = @_; + print " \n \n"; + print "
\n"; + return undef; +} + + +# Returns the hash of public access settings for showing in the smb +# access drop down list. + +sub smbAccess_list { + return { + 'none' => 'NONE', + 'browseable' => 'ENABLED_BROWSEABLE', + 'non-browseable' => 'ENABLED_NON_BROWSEABLE', + }; +} + + +# Returns the hash of public access settings for showing in the http +# access drop down list. + +sub httpAccess_list { + return { + 'none' => 'NONE', + 'local' => 'LOCAL_NETWORK_NO_PASSWORD', + 'local-pw' => 'LOCAL_NETWORK_PASSWORD', + 'global' => 'ENTIRE_INTERNET_NO_PASSWORD', + 'global-pw' => 'ENTIRE_INTERNET_PASSWORD', + 'global-pw-remote' => 'ENTIRE_INTERNET_PASSWORD_REMOTE' + }; +} # VALIDATION ROUTINES @@ -402,11 +448,14 @@ if (my $acct = $accountdb->new_record($name, { Name => $self->cgi->param('description'), WriteGroups => $WriteGroups, - ReadGroups => $ReadGroups, - Browseable => $self->cgi->param('browseable'), - RecycleBin => $self->cgi->param('recyclebin'), - status => $self->cgi->param('status'), - type => 'share', + ReadGroups => $ReadGroups, + RecycleBin => $self->cgi->param('recyclebin'), + smbAccess => $self->cgi->param('smbaccess'), + httpAccess => $self->cgi->param('httpaccess'), + RequireSSL => $self->cgi->param('requireSSL'), + Indexes => $self->cgi->param('indexes'), + DynamicContent => $self->cgi->param('dynamic'), + type => 'share', }) ) { # Untaint $name before use in system() @@ -445,12 +494,14 @@ $acct->merge_props( Name => $self->cgi->param('description'), - WriteGroups => $WriteGroups, - ReadGroups => $ReadGroups, - Browseable => $self->cgi->param('browseable'), - RecycleBin => $self->cgi->param('recyclebin'), - status => $self->cgi->param('status'), - + WriteGroups => $WriteGroups, + ReadGroups => $ReadGroups, + RecycleBin => $self->cgi->param('recyclebin'), + smbAccess => $self->cgi->param('smbaccess'), + httpAccess => $self->cgi->param('httpaccess'), + RequireSSL => $self->cgi->param('requireSSL'), + Indexes => $self->cgi->param('indexes'), + DynamicContent => $self->cgi->param('dynamic'), ); # Untaint $name before use in system()