Code

Next roll of changes. Splitting plugins from core.
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 7 Apr 2008 15:08:08 +0000 (15:08 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 7 Apr 2008 15:08:08 +0000 (15:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10250 594d385d-05f5-0310-b6e9-bd551577e9d8

27 files changed:
gosa-core/contrib/desktoprc [new file with mode: 0644]
gosa-core/contrib/gosa [new file with mode: 0755]
gosa-core/contrib/gosa.1 [new file with mode: 0644]
gosa-core/contrib/openxchange/README.openxchange [deleted file]
gosa-core/contrib/patches/imap-2001a-quota.patch [deleted file]
gosa-core/contrib/patches/php4-imap-getacl.patch [deleted file]
gosa-core/contrib/scripts/README [deleted file]
gosa-core/contrib/scripts/desktoprc [deleted file]
gosa-core/contrib/scripts/goAgent.pl [deleted file]
gosa-core/contrib/scripts/goQuota.pl [deleted file]
gosa-core/contrib/scripts/goQuotaView.pl [deleted file]
gosa-core/contrib/scripts/goSquid.pl [deleted file]
gosa-core/contrib/scripts/gosa [deleted file]
gosa-core/contrib/scripts/gosa.1 [deleted file]
gosa-core/contrib/scripts/mkHash.pl [deleted file]
gosa-core/contrib/scripts/sieve_vacation/IMAP/Sieve.pm [deleted file]
gosa-core/contrib/scripts/sieve_vacation/update-vacation.pl [deleted file]
gosa-core/debian/gosa-desktop.install
gosa-core/debian/rules
gosa-plugins/mail/contrib/goAgent.pl [new file with mode: 0644]
gosa-plugins/mail/contrib/sieve_vacation/IMAP/Sieve.pm [new file with mode: 0644]
gosa-plugins/mail/contrib/sieve_vacation/update-vacation.pl [new file with mode: 0644]
gosa-plugins/squid/README.squid [new file with mode: 0644]
gosa-plugins/squid/contrib/goQuota.pl [new file with mode: 0644]
gosa-plugins/squid/contrib/goQuotaView.pl [new file with mode: 0644]
gosa-plugins/squid/contrib/goSquid.pl [new file with mode: 0644]
gosa-plugins/squid/contrib/mkHash.pl [new file with mode: 0644]

diff --git a/gosa-core/contrib/desktoprc b/gosa-core/contrib/desktoprc
new file mode 100644 (file)
index 0000000..839c056
--- /dev/null
@@ -0,0 +1 @@
+URL="https://www.gosa-project.org/demo/2.5/"
diff --git a/gosa-core/contrib/gosa b/gosa-core/contrib/gosa
new file mode 100755 (executable)
index 0000000..4fb0789
--- /dev/null
@@ -0,0 +1,177 @@
+#!/bin/sh
+# Start script for GOsa to be started via gecko based browsers
+
+[ -r /etc/gosa/desktoprc ] && . /etc/gosa/desktoprc
+[ -r $HOME/.gosa-desktop ] && . $HOME/.gosa-desktop
+
+url=""
+if [ $# -ne 1 -a -z "$URL" ]; then
+       echo "Usage: $(basename $0) <URL>"
+       exit 1
+fi
+
+if [ $# -ne 1 ]; then
+       url="$URL"
+else
+       url="$1"
+fi
+
+# What browser are we using?
+result=""
+echo -n "Looking for browser: "
+for browser in iceweasel firefox mozilla; do
+       if which $browser 2> /dev/null; then
+               result=$browser
+               break
+       fi
+done
+if [ -z "$result" ]; then
+       echo "none found. You'll need iceweasel, firefox or mozilla in your PATH!"
+       exit 1
+fi
+browser=$result
+dbrowser=$browser
+
+# Workaround for debian
+if [ "$browser" = "iceweasel" ]; then
+       dbrowser=firefox
+fi
+
+# Check for presence of gosa profile
+if [ ! -d $HOME/.mozilla/$dbrowser/*.gosa ]; then
+       echo "No browser profile found for GOsa - creating one..."
+       $browser -CreateProfile gosa
+       if [ "$browser" = "iceweasel" ]; then
+               config=`echo $HOME/.mozilla/firefox/*.gosa/`
+       else
+               config=`echo $HOME/.mozilla/$dbrowser/*.gosa/`
+       fi
+
+       # Catch resolution
+       width=1024
+       height=768
+       if which xrandr > /dev/null; then
+               if xrandr 1> /dev/null 2> /dev/null; then
+                       resolution=$(xrandr | sed -n '/current/s/^.*current \([0-9]*\)[^0-9]*\([0-9]*\).*$/\1 \2/p')
+                       width=${resolution%% *}
+                       height=${resolution##* }
+
+                       [ $width -gt 1050 ] && width=1050
+                       [ $height -gt 850 ] && height=850
+               fi
+       fi
+
+       cat << EOF > $config/prefs.js
+# Mozilla User Preferences
+
+/* Do not edit this file.
+ *
+ * If you make changes to this file while the browser is running,
+ * the changes will be overwritten when the browser exits.
+ *
+ * To make a manual change to preferences, you can visit the URL about:config
+ * For more information, see http://www.mozilla.org/unix/customizing.html#prefs
+ */
+
+user_pref("app.update.autoUpdateEnabled", false);
+user_pref("app.update.enabled", false);
+user_pref("browser.download.folderList", 2);
+user_pref("browser.download.manager.showWhenStarting", false);
+user_pref("browser.formfill.enable", false);
+user_pref("browser.preferences.lastpanel", 1);
+user_pref("browser.search.selectedEngine", "Damnfresh");
+user_pref("browser.startup.homepage", "$url");
+user_pref("browser.startup.homepage_override.mstone", "rv:1.8.1.1");
+user_pref("extensions.disabledObsolete", true);
+user_pref("extensions.lastAppVersion", "2.0.0.1");
+user_pref("extensions.update.autoUpdateEnabled", false);
+user_pref("intl.charsetmenu.browser.cache", "ISO-8859-1");
+user_pref("network.cookie.prefsMigrated", true);
+user_pref("security.OCSP.URL", "");
+user_pref("security.OCSP.signingCA", "Builtin Object Token:IPS CLASE1 root");
+user_pref("security.warn_entering_secure", false);
+user_pref("security.warn_leaving_secure", false);
+user_pref("security.warn_submit_insecure", false);
+user_pref("security.warn_viewing_mixed", false);
+user_pref("signon.rememberSignons", false);
+user_pref("security.warn_submit_insecure", false);
+EOF
+
+       cat << EOF > $config/84795799.s
+#2c
+http://vserver-02
+.
+EOF
+
+       [ ! -d $config/chrome ] && mkdir -p $config/chrome
+       cat << EOF > $config/chrome/userChrome.css
+#main-menubar {
+        display: none;
+}
+#navigator-throbber {
+        display: none;
+}
+EOF
+
+cat << EOF > $config/localstore.rdf
+<?xml version="1.0"?>
+<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
+         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+  <RDF:Description RDF:about="chrome://mozapps/content/downloads/unknownContentType.xul#unknownContentType"
+                   screenX="267"
+                   screenY="304" />
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul#PersonalToolbar"
+                   currentset="__empty"
+                   collapsed="true" />
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul#toolbar-menubar"
+                   currentset="__empty"
+                   collapsed="true" />
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul#sidebar-box"
+                   collapsed="true"
+                   sidebarcommand=""
+                   width=""
+                   src="" />
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul#status-bar"
+                   hidden="true" />
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul">
+    <NC:persist RDF:resource="chrome://browser/content/browser.xul#main-window"/>
+    <NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-box"/>
+    <NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-title"/>
+    <NC:persist RDF:resource="chrome://browser/content/browser.xul#nav-bar"/>
+    <NC:persist RDF:resource="chrome://browser/content/browser.xul#PersonalToolbar"/>
+    <NC:persist RDF:resource="chrome://browser/content/browser.xul#toolbar-menubar"/>
+  </RDF:Description>
+  <RDF:Description RDF:about="chrome://mozapps/content/downloads/unknownContentType.xul">
+    <NC:persist RDF:resource="chrome://mozapps/content/downloads/unknownContentType.xul#unknownContentType"/>
+  </RDF:Description>
+  <RDF:Description RDF:about="chrome://global/content/customizeToolbar.xul">
+    <NC:persist RDF:resource="chrome://global/content/customizeToolbar.xul#CustomizeToolbarWindow"/>
+  </RDF:Description>
+  <RDF:Description RDF:about="chrome://help/content/help.xul#help"
+                   screenX="350"
+                   screenY="225"
+                   width="700"
+                   height="550" />
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul#main-window"
+                   screenX="50"
+                   screenY="25"
+                   sizemode="normal"
+                   width="$width"
+                   height="$height" />
+  <RDF:Description RDF:about="chrome://help/content/help.xul">
+    <NC:persist RDF:resource="chrome://help/content/help.xul#help"/>
+  </RDF:Description>
+  <RDF:Description RDF:about="chrome://browser/content/browser.xul#nav-bar"
+                   currentset="__empty"
+                   collapsed="true" />
+</RDF:RDF>
+
+
+
+EOF
+fi
+
+
+# Start mozilla with GOsa profile
+$browser -P gosa $url
+
diff --git a/gosa-core/contrib/gosa.1 b/gosa-core/contrib/gosa.1
new file mode 100644 (file)
index 0000000..73f383e
--- /dev/null
@@ -0,0 +1,41 @@
+.TH gosa 1
+.SH NAME
+gosa \- start script for the GOsa web interface
+.SH SYNOPSIS
+.PP
+.B gosa
+[
+URL
+]
+.SH DESCRIPTION
+Start the 
+.B GOsa
+web interface using a gecko based browser and generate
+a special browser profile for
+.B GOsa
+usage. This profile will disable
+normal style browser navigation and URL fields.
+.SH OPTIONS
+.TP
+.BR URL
+Open this URL when launching the browser with the GOsa profile. This
+option is optional and may be preset by the
+.B configuration
+files.
+.SH "RETURN VALUE"
+The script return zero values on success.
+.SH EXAMPLES
+.B gosa
+https://admin.example.net
+.SH FILES
+Presetting the URL works by placing something like
+.B URL="http://admin.example.net"
+inside one of these files:
+.br
+.nf
+.\" set tabstop to longest possible filename, plus a wee bit
+.ta \w'/usr/lib/perl/getopts.pl   'u
+\fI/etc/gosa/desktoprc\fR      system wide setting
+\fI$HOME/.gosa-desktop\fR      user specific setting
+.SH AUTHOR
+Cajus Pollmeier <cajus@debian.org>
diff --git a/gosa-core/contrib/openxchange/README.openxchange b/gosa-core/contrib/openxchange/README.openxchange
deleted file mode 100644 (file)
index 52effd8..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-### Small tutorial for use GOsa with open-xchange ###
-
-Once installed open-xchange (http://www.open-xchange.org) and php4-pgsql 
-module we must do some changes to get open-xchange running with GOsa.
-
-- php.ini must have extension=pg_sql.so
-
-- The webserver must have access to the Postgresql server.
-
-- In the connectivity section of gosa.conf must have something like this:
-                <tab class="oxchangeAccount"
-                        pghost="server"
-                        pguser="openexchange"
-                        pgpasswd="test"
-                        pgdbname="openexchange"
-               />
-
-
-
-We suppose that openxchage is installed in /usr/local/openxchange, 
-and the base for GOsa ldap tree is dc=example,dc=org
-
-
-- Make changes to admintools.conf (/usr/local/openxchange/etc/admintools.conf):
-
-OXBASE="dc=example,dc=org"
-OX_LEAF="$OXBASE"
-# Where are the OX Users
-USER_BASEDN="ou=people,$OX_LEAF"
-# Where are the OX Groups
-GROUP_BASEDN="ou=groups,$OX_LEAF"
-# Where are the OX Resources
-RESOURCES_BASEDN="ou=Resources,ou=ResourceObjects,ou=OxObjects,$OX_LEAF"
-# Where are the OX Resource Groups
-RESOURCE_GROUPS_BASEDN="ou=ResourceGroups,ou=ResourceObjects,ou=OxObjects,$OX_LEAF"
-# Where is the Global Adressbook
-GLOBAL_ADDRESSBOOKDN="o=AddressBook,ou=OxObjects,$OX_LEAF"
-# where are the adressbook admins
-GLOBAL_ADDRESSBOOK_ADMINSDN="cn=AddressAdmins,ou=OxObjects,$GLOBAL_ADDRESSBOOKDN"
-
-- Make changes in login.pm (usually in /usr/lib/cgi-bin/login.pm):
-my $ldap_userBase = 'ou=Users,ou=OxObjects,';
-to
-my $ldap_userBase = 'ou=people,';
-
-- Put the Base in ldap.conf (/usr/local/openxchange/etc/groupware/ldap.conf)
-BASE    dc=example,dc=org
-
-- If you are using as GOsa dnmode "uid", You must change in ldap.properties 
-(/usr/local/openxchange/etc/groupware/ldap.properties):
-
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeuserCountryName=userCountry
- to
-com.openexchange.groupware.ldap.OXUserObjectAttributeuserCountryName=st
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeimapServerName=imapServer
- to
-com.openexchange.groupware.ldap.OXUserObjectAttributeimapServerName=gosaMailServer
-
-com.openexchange.groupware.ldap.OXUserObjectAttributesmtpServerName=smtpServer
- to 
-com.openexchange.groupware.ldap.OXUserObjectAttributesmtpServerName=gosaMailServer
-
-com.openexchange.groupware.ldap.userBaseDN=ou\u003DUsers,ou\u003DOxObjects
-to
-com.openexchange.groupware.ldap.userBaseDN=ou\u003Dpeople
-
-
-
-- If you are using as GOsa dnmode "cn", the ldap.properties  
-(/usr/local/openxchange/etc/groupware/ldap.properties) 
-configuration of open-xchange must be like this:
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributebusinessCategoryName=businessCategory
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributecnName=cn
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeCountryName=c
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributedescriptionName=description
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributedisplayNameName=displayName
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeemployeeNumberName=employeeNumber
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeemployeeTypeName=employeeType
-
-com.openexchange.groupware.ldap.OXUserObjectAttributecoName=co
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributehomePhoneName=homePhone
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributehomePostalAddressName=homePostalAddress
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeInfoName=info
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeinitialsName=initials
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeinternationaliSDNNumberName=internationaliSDNNumber
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeIPPhoneName=IPPhone
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeotherfacsimiletelephonenumberName=otherfacsimiletelephonenumber
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeroomNumberName=roomNumber
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributetelexNumberName=telexNumber
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeuidName=uid
-
-com.openexchange.groupware.ldap.inetOrgPersonClassName=inetOrgPerson
-
-com.openexchange.groupware.ldap.OXUserObjectAttributebirthDayName=birthDay
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeDistributionListName=OXUserDistributionList
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeAnniversaryName=OXUserAnniversary
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeBranchesName=OXUserBranches
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeCategoriesName=OXUserCategories
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeChildrenName=OXUserChildren
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeCityName=OXUserCity
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeCommentName=OXUserComment
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeComRegName=OXUserComReg
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeEmail2Name=OXUserEmail2
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeEmail3Name=OXUserEmail3
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeInstantMessenger2Name=OXUserInstantMessenger2
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeInstantMessengerName=OXUserInstantMessenger
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeMaritalStatusName=OXUserMaritalStatus
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeNickNameName=OXUserNickName
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeOtherCityName=OXUserOtherCity
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeOtherCountryName=OXUserOtherCountry
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeOtherPostalCodeName=OXUserOtherPostalCode
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeOtherStateName=OXUserOtherState
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeOtherStreetName=OXUserOtherStreet
-
-com.openexchange.groupware.ldap.OXUserObjectAttributePositionName=OXUserPosition
-
-com.openexchange.groupware.ldap.OXUserObjectAttributePostalCodeName=OXUserPostalCode
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeProfessionName=OXUserProfession
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeSalesVolumeName=OXUserSalesVolume
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeSpouseNameName=OXUserSpouseName
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeStateName=OXUserState
-
-com.openexchange.groupware.ldap.OXUserObjectAttributesuffixName=OXUserSuffix
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTaxIDName=OXUserTaxID
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleAssistantName=OXUserTeleAssistant
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleBusiness2Name=OXUserTeleBusiness2
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleCallbackName=OXUserTeleCallback
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleCarName=OXUserTeleCar
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleCompanyName=OXUserTeleCompany
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleFax2Name=OXUserTeleFax2
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleHome2Name=OXUserTeleHome2
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleMobile2Name=OXUserTeleMobile2
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleOtherName=OXUserTeleOther
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTelePrimaryName=OXUserTelePrimary
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleRadioName=OXUserTeleRadio
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeTeleTTYName=OXUserTeleTTY
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeurlName=url
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef01Name=OXUserUserUndef01
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef02Name=OXUserUserUndef02
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef03Name=OXUserUserUndef03
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef04Name=OXUserUserUndef04
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef05Name=OXUserUserUndef05
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef06Name=OXUserUserUndef06
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef07Name=OXUserUserUndef07
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef08Name=OXUserUserUndef08
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef09Name=OXUserUserUndef09
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef10Name=OXUserUserUndef10
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef11Name=OXUserUserUndef11
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef12Name=OXUserUserUndef12
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef13Name=OXUserUserUndef13
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef14Name=OXUserUserUndef14
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef15Name=OXUserUserUndef15
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef16Name=OXUserUserUndef16
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef17Name=OXUserUserUndef17
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef18Name=OXUserUserUndef18
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef19Name=OXUserUserUndef19
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeUserUndef20Name=OXUserUserUndef20
-
-com.openexchange.groupware.ldap.OXUserObjectClassName=OXUserObject
-
-com.openexchange.groupware.ldap.AllContactUIDSearch=(&(objectClass\u003DinetOrgPerson)(objectClass\u003DOXUserObject))
-
-!com.openexchange.groupware.ldap.AllContactUIDSearchScope=1
-
-com.openexchange.groupware.ldap.credentialsBaseDN=[credentialsBaseDN]
-
-com.openexchange.groupware.ldap.credentialsDN=cn\u003D[uid],[userBaseDN],[credentialsBaseDN]
-
-com.openexchange.groupware.ldap.groupOfNamesAttributememberName=member
-
-com.openexchange.groupware.ldap.AddressAdminsDN=cn\u003DAddressAdmins,[globalAddressBookBaseDN]
-
-com.openexchange.groupware.ldap.globalAddressBookBaseDN=o\u003DAddressBook
-
-com.openexchange.groupware.ldap.GlobalAddressBookEntryDN=cn\u003D[contactid],[globalAddressBookBaseDN]
-
-com.openexchange.groupware.ldap.InternalUsersForeSureNameUIDPatternSearchFilter=(&(objectClass\u003DinetOrgPerson)(objectClass\u003DOXUserObject)(|(sn\u003D[pattern])(givenname\u003D[pattern])(cn\u003D[pattern]))(mailEnabled\u003Dok))
-
-com.openexchange.groupware.ldap.InternalUsersStartingLetterSearchFilter=(&(objectClass\u003DinetOrgPerson)(objectClass\u003DOXUserObject)(sn\u003D[letter]*)(mailEnabled\u003Dok))
-
-com.openexchange.groupware.ldap.UserAddressBookEntryDN=cn\u003D[contactid],[UserAddressBookDN]
-
-com.openexchange.groupware.ldap.localDomainsBaseDN=ou\u003DDNSObjects,ou\u003DAdminObjects
-
-com.openexchange.groupware.ldap.OXVDomainAttributedomainNameName=domainName
-
-com.openexchange.groupware.ldap.LocalDomainsSearchFilter=(&(objectClass\u003DOXVDomainObject)(MTALocaldomain\u003Dtrue))
-
-com.openexchange.groupware.ldap.OXIMAPFolderAttributefnName=fn
-
-com.openexchange.groupware.ldap.sharedFolderBaseDN=ou\u003DSharedFolder
-
-com.openexchange.groupware.ldap.SharedFolderSearchFilter=(&(objectclass\u003DOXIMAPFolderObject)(mailenabled\u003Dok))
-
-!com.openexchange.groupware.ldap.sharedFolderSearchScope=1
-
-com.openexchange.groupware.ldap.OXResourceGroupAttributeresourceGroupAvailableName=resourceGroupAvailable
-
-com.openexchange.groupware.ldap.OXResourceGroupAttributeresourceGroupMemberName=resourceGroupMember
-
-com.openexchange.groupware.ldap.OXResourceGroupAttributeresourceGroupNameName=resourceGroupName
-
-com.openexchange.groupware.ldap.ResourceGroupDN=resourceGroupName\u003D[group],[resourceGroupBaseDN]
-
-com.openexchange.groupware.ldap.ResourceGroupPatternSearchFilter=(&(objectclass\u003DOXResourceGroupObject)(resourceGroupName\u003D[pattern]))
-
-com.openexchange.groupware.ldap.ResourceGroupSearchFilter=(objectclass\u003DOXResourceGroupObject)
-
-!com.openexchange.groupware.ldap.ResourceGroupSearchScope=1
-
-com.openexchange.groupware.ldap.OXResourceAttributeresourceNameName=resourceName
-
-#Where are the resources?
-com.openexchange.groupware.ldap.resourceBaseDN=ou\u003DResources,ou\u003DResourceObjects
-
-com.openexchange.groupware.ldap.ResourceDN=resourceName\u003D[resource],[resourceBaseDN]
-
-#Where are the resource groups?
-com.openexchange.groupware.ldap.resourceGroupBaseDN=ou\u003DResourceGroups,ou\u003DResourceObjects
-
-#Searches resources with the a pattern.
-com.openexchange.groupware.ldap.ResourcePatternSearchFilter=(&(objectclass\u003DOXResourceObject)(resourceName\u003D[pattern]))
-
-!com.openexchange.groupware.ldap.ResourceSearchScope=1
-
-com.openexchange.groupware.ldap.DNForDefaultMail=cn\u003Dmailadmin,[userBaseDN]
-
-com.openexchange.groupware.ldap.Factory.AuthenticationSupport=com.openexchange.groupware.ldap.DefaultAuthenticationSupport
-
-com.openexchange.groupware.ldap.Factory.ContactSupport=com.openexchange.groupware.ldap.DefaultContactSupport
-
-com.openexchange.groupware.ldap.Factory.MailSupport=com.openexchange.groupware.ldap.DefaultMailSupport
-
-com.openexchange.groupware.ldap.Factory.ResourcesHandle=com.openexchange.groupware.ldap.DefaultResourcesHandle
-
-#Class, that implementes UserGroupHandle, ResourcesHandle
-com.openexchange.groupware.ldap.Factory.UserGroupHandle=com.openexchange.groupware.ldap.DefaultUserGroupHandle
-
-#Where to search for groups?
-com.openexchange.groupware.ldap.groupBaseDN=ou\u003DGroups
-
-#Complete dn of a group.
-com.openexchange.groupware.ldap.GroupDN=cn\u003D[gid],[groupBaseDN]
-
-com.openexchange.groupware.ldap.GroupSearchFilter=(objectclass\u003DposixGroup)
-
-#Searches all groups for the user
-com.openexchange.groupware.ldap.GroupsForUserSearchFilter=(&(objectclass\u003DposixGroup)(memberUid\u003D[uid]))
-
-com.openexchange.groupware.ldap.GroupsPatternSearchFilter=(&(objectclass\u003DposixGroup)(cn\u003D[pattern]))
-
-!com.openexchange.groupware.ldap.GroupSearchScope=1
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributefacsimileName=facsimileTelephoneNumber
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributegivenNameName=givenName
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributelabeledURIName=labeledURI
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributelName=l
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributemailName=mail
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributemobileName=mobile
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeoName=o
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributeouName=ou
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributepagerName=pager
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributepostalCodeName=postalCode
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributepreferredLanguageName=preferredLanguage
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributesnName=sn
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributestName=st
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributestreetName=street
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributetelephoneNumberName=telephoneNumber
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributetitleName=title
-
-com.openexchange.groupware.ldap.OXUserObjectAttributealiasName=alias
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeappointmentDaysName=OXAppointmentDays
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeimapServerName=gosaMailServer
-
-com.openexchange.groupware.ldap.OXUserObjectAttributemailDomainName=mailDomain
-
-com.openexchange.groupware.ldap.OXUserObjectAttributesmtpServerName=gosaMailServer
-
-com.openexchange.groupware.ldap.OXUserObjectAttributetaskDaysName=OXTaskDays
-
-com.openexchange.groupware.ldap.OXUserObjectAttributetimeZoneName=OXTimeZone
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeuserCountryName=st
-
-com.openexchange.groupware.ldap.OXUserObjectAttributevaddressName=vaddress
-
-com.openexchange.groupware.ldap.posixAccountAttributecnName=cn
-
-com.openexchange.groupware.ldap.posixAccountAttributeuidName=uid
-
-com.openexchange.groupware.ldap.posixGroupAttributecnName=cn
-
-com.openexchange.groupware.ldap.posixGroupAttributememberUidName=memberUid
-
-com.openexchange.groupware.ldap.UserAddressBookDN=ou\u003Daddr,cn\u003D[uid],[userBaseDN]
-
-com.openexchange.groupware.ldap.UserAttributeOpenLDAPaciName=OpenLDAPaci
-
-com.openexchange.groupware.ldap.userBaseDN=ou\u003Dpeople
-
-#DN to the user object
-com.openexchange.groupware.ldap.UserDN=cn\u003D[uid],[userBaseDN]
-
-com.openexchange.groupware.ldap.UsersCNPatternSearchFilter=(&(objectclass\u003DposixAccount)(objectClass\u003DinetOrgPerson)(|(cn\u003D[pattern])(givenName\u003D[pattern])(cn\u003D[pattern])))
-
-com.openexchange.groupware.ldap.UserSearchFilter=(&(cn\u003D[uid])(objectClass\u003DOXUserObject))
-
-!com.openexchange.groupware.ldap.UserSearchScope=1
-
-com.openexchange.groupware.ldap.UsersForeSureNamePatternSearchFilter=(&(objectclass\u003DposixAccount)(|(givenName\u003D[pattern])(sn\u003D[pattern])))
-
-com.openexchange.groupware.ldap.UsersForeSureNameUIDPatternSearchFilter=(&(objectclass\u003DposixAccount)(objectClass\u003DinetOrgPerson)(|(givenName\u003D[pattern])(sn\u003D[pattern])(cn\u003D[pattern])))
-
-com.openexchange.groupware.ldap.UsersPatternSearchFilter=(&(objectclass\u003DposixAccount)(cn\u003D[pattern]))
-
-#Define the objectClasses an user object should belong to if you are performing pattern searches.
-com.openexchange.groupware.ldap.UsersPatternSearchObjectClasses=posixAccount,inetOrgPerson,OXUserObject
-
-com.openexchange.groupware.ldap.GlobalAddressBookSearchScope=1
-
-com.openexchange.groupware.ldap.inetOrgPersonAttributejpegPhotoName=jpegPhoto
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeDayViewEndTimeName=OXDayViewEndTime
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeDayViewStartTimeName=OXDayViewStartTime
-
-com.openexchange.groupware.ldap.OXUserObjectAttributeDayViewIntervalName=OXDayViewInterval
-
-!com.openexchange.groupware.ldap.LocalDomainsSearchScope=1
-
-
-
-
-
-
-This configuration is based in documentation gets from 
-http://www.open-xchange.org/oxwiki/
-
-TODO:
-- more testing
-- check cn configuration
-- check addressbook
-- subtree support
-
diff --git a/gosa-core/contrib/patches/imap-2001a-quota.patch b/gosa-core/contrib/patches/imap-2001a-quota.patch
deleted file mode 100644 (file)
index 304488d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-diff -Naur imap-2001a/src/c-client/imap4r1.c imap-2001a.patched/src/c-client/imap4r1.c
---- imap-2001a/src/c-client/imap4r1.c  Wed Nov 14 23:50:55 2001
-+++ imap-2001a.patched/src/c-client/imap4r1.c  Wed May 21 09:54:35 2003
-@@ -2358,10 +2358,12 @@
-       do {                    /* for each list item */
-       *s++ = c;               /* write prefix character */
-       if (list) {             /* sigh, QUOTA has bizarre syntax! */
--        for (t = (char *) list->text.data; *t; *s++ = *t++);
--        sprintf (s," %lu",list->text.size);
--        s += strlen (s);
--        c = ' ';              /* prefix character for subsequent strings */
-+        if (list->text.size != 0){
-+          for (t = (char *) list->text.data; *t; *s++ = *t++);
-+          sprintf (s," %lu",list->text.size);
-+          s += strlen (s);
-+          c = ' ';            /* prefix character for subsequent strings */
-+        }
-       }
-       }
-       while (list = list->next);
diff --git a/gosa-core/contrib/patches/php4-imap-getacl.patch b/gosa-core/contrib/patches/php4-imap-getacl.patch
deleted file mode 100644 (file)
index ae3a235..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
---- php-imap-4.3.9/php_imap.c.fix      2004-08-06 15:04:17 +0400
-+++ php-imap-4.3.9/php_imap.c  2004-08-06 15:11:43 +0400
-@@ -138,6 +138,7 @@ function_entry imap_functions[] = {
-       PHP_FE(imap_get_quotaroot,                                              NULL)
-       PHP_FE(imap_set_quota,                                                  NULL)
-       PHP_FE(imap_setacl,                                                             NULL)
-+        PHP_FE(imap_getacl,                                                             NULL)
- #endif
-       PHP_FE(imap_mail,                                                               NULL)
-@@ -377,6 +378,22 @@ void mail_getquota(MAILSTREAM *stream, c
- /* }}} */
- #endif
-+/* {{{ mail_getquota 
-+ *
-+ * Mail GET_ACL callback
-+ * Called via the mail_parameter function in c-client:src/c-client/mail.c
-+ */
-+void mail_getacl(MAILSTREAM *stream, char *mailbox, ACLLIST *alist)
-+{
-+      TSRMLS_FETCH();
-+
-+      /* walk through the ACLLIST */
-+      for (; alist; alist = alist->next)
-+      {
-+              add_assoc_stringl(IMAPG(imap_acl_list), alist->identifier, alist->rights, strlen(alist->rights), 1);
-+      }
-+}
-+/* }}} */
- /* {{{ php_imap_init_globals
-  */
-@@ -402,6 +419,7 @@ static void php_imap_init_globals(zend_i
-       imap_globals->folderlist_style = FLIST_ARRAY;
- #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
-       imap_globals->quota_return = NULL;
-+        imap_globals->imap_acl_list = NIL;
- #endif
- }
- /* }}} */
-@@ -985,6 +1003,37 @@ PHP_FUNCTION(imap_setacl)
- }
- /* }}} */
-+/* {{{ proto array imap_get_quota(int stream_id, string mailbox)
-+      Gets the ACL for a given mailbox */
-+PHP_FUNCTION(imap_getacl)
-+{
-+      zval **streamind, **mailbox;
-+      pils *imap_le_struct;
-+
-+      if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind, &mailbox) == FAILURE) {
-+              ZEND_WRONG_PARAM_COUNT();
-+      }
-+
-+      ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
-+
-+      convert_to_string_ex(mailbox);
-+
-+    /* initializing the special array for the return values */
-+    array_init(return_value);
-+
-+    IMAPG(imap_acl_list) = return_value;
-+
-+      /* set the callback for the GET_ACL function */
-+      mail_parameters(NIL, SET_ACL, (void *) mail_getacl);
-+      if(!imap_getacl(imap_le_struct->imap_stream, Z_STRVAL_PP(mailbox))) {
-+              php_error(E_WARNING, "c-client imap_getacl failed");
-+              RETURN_FALSE;
-+      }
-+
-+    IMAPG(imap_acl_list) = NIL;
-+}
-+/* }}} */
-+
- #endif /* HAVE_IMAP2000 || HAVE_IMAP2001 */
---- php-imap-4.3.9/php_imap.h.fix      2004-08-06 15:09:33 +0400
-+++ php-imap-4.3.9/php_imap.h  2004-08-06 15:10:42 +0400
-@@ -172,6 +172,7 @@ PHP_FUNCTION(imap_get_quota);
- PHP_FUNCTION(imap_get_quotaroot);
- PHP_FUNCTION(imap_set_quota);
- PHP_FUNCTION(imap_setacl);
-+PHP_FUNCTION(imap_getacl);
- #endif
-@@ -202,6 +203,7 @@ ZEND_BEGIN_MODULE_GLOBALS(imap)
-       unsigned long status_uidvalidity;
- #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
-       zval **quota_return;
-+        pval *imap_acl_list;
- #endif
- ZEND_END_MODULE_GLOBALS(imap)
diff --git a/gosa-core/contrib/scripts/README b/gosa-core/contrib/scripts/README
deleted file mode 100644 (file)
index 023f428..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-goQuota.pl - run this script via cron (each 5-10 min for examle). It makes
-             cache file (quota.db) with traffic usage and user info from LDAP
-
-goQuotaView.pl - read collected data from quota.db and print it to
-                 stdout in human readable format
-
-goSquid.pl - connect this script to squid
-             redirect_program /usr/local/sbin/goSquid
-
-goAgent.pl - one script to create home directories and mailboxes on
-             filesystem. run it via cron
-  
-mkHash.pl  - create hash file for black list
-
-At this time all scripts have no config file. Please, edit source to configure.
-
-Igor Muratov <migor@altlinux.org>
diff --git a/gosa-core/contrib/scripts/desktoprc b/gosa-core/contrib/scripts/desktoprc
deleted file mode 100644 (file)
index 839c056..0000000
+++ /dev/null
@@ -1 +0,0 @@
-URL="https://www.gosa-project.org/demo/2.5/"
diff --git a/gosa-core/contrib/scripts/goAgent.pl b/gosa-core/contrib/scripts/goAgent.pl
deleted file mode 100644 (file)
index 41b991e..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/usr/bin/perl
-#
-# Igor Muratov <migor@altlinux.org>
-#
-# Find changes at LDAP and put this to filesystem
-#
-#
-# Igor Muratov <migor@altlinux.org>
-# 20041004
-# - Added rebuildVirtual function
-# 
-# Igor Muratov <migor@altlinux.org>
-# 20040617:
-# - Changed search fiter to exclude gosaUserTemplate entries
-#
-# Simon Liebold <s.liebold@gmx.de>:
-# 20040617:
-# - Changed $TS_FILE-location
-#
-# $Id: goAgent.pl,v 1.4 2004/11/19 21:46:56 migor-guest Exp $ 
-#
-
-use strict;
-use Net::LDAP;
-
-my $LDAP_HOST='localhost';
-my $LDAP_PORT='389';
-my $LDAP_BASE='dc=example,dc=com';
-#my $LDAP_USER='cn=admin,dc=example,dc=com';
-#my $LDAP_PASS='secret';
-
-my $HOME_DIR='/home';
-my $TS_FILE='/tmp/gosa_timestamp';
-my $KEYS_DIR='/etc/openssh/authorized_keys2';
-my $MAIL_DIR='/var/spool/mail';
-my $VLOCAL='/etc/postfix/virtual_local';
-my $VFORWARD='/etc/postfix/virtual_forward';
-my ($ldap, $mesg, $entry);
-my $virtuals = 0;
-
-# Anonymous bind to LDAP
-sub anonBind
-{
-       my $ldap = Net::LDAP->new( $LDAP_HOST, port => $LDAP_PORT );
-       my $mesg = $ldap->bind();
-       $mesg->code && die $mesg->error;
-       return $ldap;
-}
-
-# Bind as LDAP user
-#sub userBind
-#{
-#      my $ldap = Net::LDAP->new( $LDAP_HOST, port => $LDAP_PORT );
-#      my $mesg = $ldap->bind($LDAP_USER, password=>$LDAP_PASS);
-#      $mesg->code && die $mesg->error;
-#      return $ldap;
-#}
-
-# Read timestamp
-sub getTS
-{
-       open(F, "< $TS_FILE");
-       my $ts = <F>;
-       chop $ts;
-       $ts ||= "19700101000000Z";
-       return $ts;
-}
-
-# save timestamp
-sub putTS
-{
-       my $ts = `date -u '+%Y%m%d%H%M%SZ'`;
-       open(F, "> $TS_FILE");
-       print F $ts;
-}
-
-sub rebuildVirtuals
-{
-       print "Rebuild virtuals table for postfix\n";
-       $mesg = $ldap->search(
-               base => $LDAP_BASE,
-               filter => "(&(objectClass=gosaMailAccount)(gosaMailDeliveryMode=[*L*])(|(mail=*)(gosaMailAlternateAddress=*)))",
-               attrs =>  [
-                       'mail',
-                       'uid',
-                       'gosaMailForwardingAddress',
-                       'memberUid'
-               ],
-       );
-
-       # Work if changes is present
-       open(VIRT, "> $VLOCAL");
-       foreach my $entry ($mesg->all_entries)
-       {
-               foreach my $addr ($entry->get_value('mail'))
-               {
-                       print VIRT "$addr\t";
-                       print VIRT join(",", (
-                               $entry->get_value("uid"),
-                               $entry->get_value("gosaMailForwardingAddress"),
-                               $entry->get_value("memberUid"),
-                       ));
-                       print VIRT "\n";
-               }
-       }
-       close(VIRT);
-       `postmap $VLOCAL`;
-
-       $mesg = $ldap->search(
-               base => $LDAP_BASE,
-               filter => "(&(objectClass=gosaMailAccount)(!(gosaMailDeliveryMode=[*L*]))(|(mail=*)(gosaMailAlternateAddress=*)))",
-               attrs =>  [
-                       'gosaMailForwardingAddress',
-               ],
-       );
-
-       # Work if changes is present
-       open(VIRT, "> $VFORWARD");
-       foreach my $entry ($mesg->all_entries)
-       {
-               foreach my $addr ($entry->get_value('mail'))
-               {
-                       print VIRT "$addr\t";
-                       print VIRT join(",", (
-                               $entry->get_value("gosaMailForwardingAddress"),
-                       ));
-                       print VIRT "\n";
-               }
-       }
-       close(VIRT);
-       `postmap $VFORWARD`;
-}
-
-sub posixAccount
-{
-       my $entry = shift;
-       my $uid = ($entry->get_value('uid'))[0];
-       my $home = ($entry->get_value('homeDirectory'))[0];
-       my $uidNumber = ($entry->get_value('uidNumber'))[0];
-       my $gidNumber = ($entry->get_value('gidNumber'))[0];
-
-       print "Update posixAccount: $uid\n";
-       `install -dD -m0701 -o$uidNumber:$gidNumber $home`;
-       #`install -d -m0700 -o$uidNumber:$gidNumber $home/.ssh`;
-       #`install -d -m0751 -o$uidNumber:$gidNumber $home/.public_html`;
-       print "\tEntry ".$entry->dn()." updated\n";
-}
-
-# Get ssh keys and place to system directory
-sub strongAuthenticationUser
-{
-       my $entry = shift;
-       my $uid = ($entry->get_value('uid'))[0];
-       open(KEYS, "> $KEYS_DIR/$uid");
-       print KEYS $_ foreach ($entry->get_value('userCertificate;binary'));
-}
-
-# Create mailbox if need
-sub inetLocalMailRecipient
-{
-       my $entry = shift;
-       my $uid = ($entry->get_value('uid'))[0];
-       my $mail = ($entry->get_value('mailLocalAddress'))[0];
-       my $addr = ($entry->get_value('mailRoutingAddress'))[0];
-       my $uidNumber = ($entry->get_value('uidNumber'))[0];
-       my $mailbox = "$MAIL_DIR/$uid";
-
-       print "Update inetLocalMailRecipient: $mail\n";
-       if( $uid eq $addr )
-       {
-               if( -f "$mailbox" )
-               {
-                       print "Warning: mailbox $mailbox alredy exists. No changes.\n";
-               } else {
-                       `install -m660 -o$uidNumber -gmail /dev/null $mailbox`;
-               }
-       }
-       print "\tEntry ".$entry->dn()." updated\n";
-}
-
-sub disassemble
-{
-       my $entry = shift;
-
-       foreach my $attr ($entry->get_value('objectClass'))
-       {
-               if( $attr eq "posixAccount" ) {
-                       posixAccount($entry);
-               } elsif( $attr eq "inetLocalMailRecipient" ) {
-                       inetLocalMailRecipient($entry);
-               } elsif( $attr eq "strongAuthenticationUser" ) {
-                       strongAuthenticationUser($entry);
-               } elsif( $attr eq "gosaMailAccount" ) {
-                       $virtuals++;
-               }
-       }
-}
-
-#
-# Start main process
-#
-
-# Read timestamp from file
-my $ts = getTS;
-
-$ldap = anonBind;
-$mesg = $ldap->search(
-       base => $LDAP_BASE,
-       filter => "(&(modifyTimestamp>=$ts)(!(objectClass=gosaUserTemplate)))"
-);
-
-# Put timestamp to file
-putTS;
-
-# Work if changes is present
-if($mesg->count > 0)
-{
-       print "Processing records modified after $ts\n\n";
-
-       foreach my $entry ($mesg->all_entries)
-       {
-               disassemble($entry);
-       }
-       rebuildVirtuals if $virtuals;
-}
diff --git a/gosa-core/contrib/scripts/goQuota.pl b/gosa-core/contrib/scripts/goQuota.pl
deleted file mode 100644 (file)
index cceeffa..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-#!/usr/bin/perl
-#
-# Parse squid log and write current traffic usage by users into cache
-#
-# Igor Muratov <migor@altlinux.org>
-#
-# $Id: goQuota.pl,v 1.4 2005/04/03 00:46:14 migor-guest Exp $
-#
-
-use strict;
-use Time::Local;
-use Net::LDAP;
-use DB_File;
-use POSIX qw(strftime);
-
-my $debug = 0;
-$|=1;
-
-my $LDAP;
-my $LDAP_HOST = "localhost";
-my $LDAP_PORT = "389";
-my $LDAP_BASE = "ou=People,dc=example,dc=com";
-
-my $ACCESS_LOG = '/var/log/squid/access.log';
-my $CACHE_FILE = '/var/spool/squid/quota.db';
-my $DEFAULT_PERIOD = 'm';
-my $FORMAT = "A16 A5 S S L A5 L L L";
-
-my %cache;
-my @lines;
-
-sub timestamp
-{
-       return strftime("%a %b %X goQuota[$$]: ", localtime);
-}
-
-sub anonBind
-{
-       my $ldap = Net::LDAP->new( $LDAP_HOST, port => $LDAP_PORT );
-       if($ldap)
-       {
-               my $mesg = $ldap->bind();
-               $mesg->code && warn timestamp, "Can't bind to ldap://$LDAP_HOST:$LDAP_PORT:", $mesg->error, "\n";
-               return $ldap;
-       }
-       else
-       {
-               warn timestamp, "Can't connect to ldap://$LDAP_HOST:$LDAP_PORT\n";
-               return undef;
-       }
-}
-
-# Retrive users's data from LDAP
-sub update_userinfo
-{
-       my $user = shift;
-       my $uid = $user->{uid};
-
-       return undef unless $LDAP;
-
-       # User unknown or cache field is expired
-       my $result = $LDAP->search( base=>$LDAP_BASE,
-               filter=>"(&(objectClass=gosaProxyAccount)(uid=$uid))",
-               attrs=>[
-                       'uid',
-                       'gosaProxyAcctFlags',
-                       'gosaProxyQuota',
-                       'gosaProxyQuotaPeriod',
-                       'gosaProxyWorkingStop',
-                       'gosaProxyWorkingStart',
-                       'modifyTimestamp'
-               ]
-       );
-       $result->code && warn timestamp, "Failed to search: ", $result->error;
-
-       # Get user's data
-       if($result->count)
-       {
-               my $entry = ($result->entries)[0];
-
-               $user->{uid} = ($entry->get_value('uid'))[0];
-               $user->{modifyTimestamp} = ($entry->get_value('modifyTimestamp'))[0];
-               $user->{gosaProxyWorkingStart} = ($entry->get_value('gosaProxyWorkingStart'))[0];
-               $user->{gosaProxyWorkingStop} = ($entry->get_value('gosaProxyWorkingStop'))[0];
-               $user->{gosaProxyAcctFlags} = ($entry->get_value('gosaProxyAcctFlags'))[0];
-
-               my ($quota, $unit) = ($entry->get_value('gosaProxyQuota'))[0] =~ /(\d+)(\S)/g;
-               $user->{gosaProxyQuota} = $quota;
-               $user->{gosaProxyQuota} *= 1024 if $unit =~ /[Kk]/;
-               $user->{gosaProxyQuota} *= 1048576 if $unit =~ /[Mm]/;
-               $user->{gosaProxyQuota} *= 1073741824 if $unit =~ /[Gg]/;
-
-               $user->{gosaProxyQuotaPeriod} = ($entry->get_value('gosaProxyQuotaPeriod'))[0] || $DEFAULT_PERIOD;
-               # Return
-               warn timestamp, "User $uid found in LDAP.\n";
-               return 1;
-       } else {
-               # Unknown user
-               warn timestamp, "User $uid does not exists in LDAP.\n";
-               $user->{uid} = $uid;
-               $user->{gosaProxyAcctFlags} = '[FTB]';
-               $user->{gosaProxyQuota} = 0;
-               $user->{gosaProxyQuotaPeriod} = 'y';
-               return 0;
-       }
-}
-
-sub get_update
-{
-       my $ts = shift;
-       my %update;
-       my $result = $LDAP->search( base=>$LDAP_BASE,
-               filter=>"(&(objectClass=gosaProxyAccount)(modifyTimestamp>=$ts))",
-               attrs=>'uid'
-       );
-
-       # Get user's data
-       if($result->count)
-       {
-               my $entry = ($result->entries)[0];
-               $update{($entry->get_value('uid'))[0]}++;
-       }
-       return %update;
-}
-
-# Check quota
-sub update_quota
-{
-       my $user = shift;
-       my $uid = $user->{uid};
-
-       my $period = 0;
-       $period = 3600 if $user->{gosaProxyQuotaPeriod} eq 'h';
-       $period = 86400 if $user->{gosaProxyQuotaPeriod} eq 'd';
-       $period = 604800 if $user->{gosaProxyQuotaPeriod} eq 'w';
-       $period = 2592000 if $user->{gosaProxyQuotaPeriod} eq 'm';
-       $period = 220752000 if $user->{gosaProxyQuotaPeriod} eq 'y';
-
-       if($user->{lastRequest} - $user->{firstRequest} > $period)
-       {
-               if($user->{trafficUsage} > $user->{gosaProxyQuota})
-               {
-                       warn timestamp, "Reduce quota for $uid while $period seconds.\n";
-                       $user->{trafficUsage} -= $user->{gosaProxyQuota};
-                       $user->{firstRequest} += $period;
-               }
-               else
-               {
-                       warn timestamp, "Restart quota for $uid.\n";
-                       $user->{trafficUsage} = 0;
-                       $user->{firstRequest} = $user->{lastRequest};
-               }
-       }
-}
-
-sub dump_data
-{
-       my $user = shift;
-       print "User: ",$user->{uid},"\n";
-       print "\t",$user->{modifyTimestamp},"\n";
-       print "\t",$user->{gosaProxyAcctFlags},"\n";
-       print "\t",$user->{gosaProxyWorkingStart},"\n";
-       print "\t",$user->{gosaProxyWorkingStop},"\n";
-       print "\t",$user->{gosaProxyQuota},"\n";
-       print "\t",$user->{gosaProxyQuotaPeriod},"\n";
-       print "\t",$user->{trafficUsage},"\n";
-       print "\t",$user->{firstRequest},"\n";
-       print "\t",$user->{lastRequest},"\n";
-}
-
-sub unpack_user
-{
-       my $uid = shift;
-       my $user;
-
-       $user->{uid} = $uid;
-       (
-               $user->{modifyTimestamp},
-               $user->{gosaProxyAcctFlags},
-               $user->{gosaProxyWorkingStart},
-               $user->{gosaProxyWorkingStop},
-               $user->{gosaProxyQuota},
-               $user->{gosaProxyQuotaPeriod},
-               $user->{trafficUsage},
-               $user->{firstRequest},
-               $user->{lastRequest}
-       ) = unpack($FORMAT, $cache{$uid});
-
-       return $user;
-}
-
-sub pack_user
-{
-       my $user = shift;
-
-       $cache{$user->{uid}} = pack(
-               $FORMAT,
-               $user->{modifyTimestamp},
-               $user->{gosaProxyAcctFlags},
-               $user->{gosaProxyWorkingStart},
-               $user->{gosaProxyWorkingStop},
-               $user->{gosaProxyQuota},
-               $user->{gosaProxyQuotaPeriod},
-               $user->{trafficUsage},
-               $user->{firstRequest},
-               $user->{lastRequest}
-       );
-}
-
-#--------------------------------------
-$LDAP = anonBind or die timestamp, "No lines processed.\n";
-
-# This is a first time parsing?
-my $firstStart = 1;
-$firstStart = 0 if -e $CACHE_FILE;
-
-# Open log file and cache
-my $cache = tie(%cache, 'DB_File', $CACHE_FILE, O_CREAT|O_RDWR);
-my $log = tie(@lines, 'DB_File', $ACCESS_LOG, O_RDWR, 0640, $DB_RECNO)
-       or die "Cannot open file $ACCESS_LOG: $!\n";
-
-# Mark users which updated in LDAP
-my %updated;
-if(! $firstStart)
-{
-       my $ts = strftime("%Y%m%d%H%M%SZ", gmtime);
-       %updated = get_update($cache{MODIFY_TIMESTAMP} || "19700101000000Z");
-
-       my @count = %updated;
-       $cache{MODIFY_TIMESTAMP} = $ts if $#count;
-
-       foreach my $u (keys %updated)
-       {
-               warn timestamp, "User $u has been updated in LDAP. Refresh data.\n";
-               my $user = unpack_user($u);
-               update_userinfo($user);
-               pack_user($user);
-       }
-}
-
-# Processing log file
-my $index = $cache{TIMESTAMP} < (split / +/, $lines[0])[0]
-       ? 0 : $cache{STRING_NUMBER};
-warn timestamp, "Cache update start at line $index.\n";
-while($lines[$index])
-{
-       # There are array named lines with elements
-       # 0 - line timestamp
-       # 1 - ?? (unused)
-       # 2 - client's IP (unused)
-       # 3 - squid's cache status TEXT_CODE/num_code (unused)
-       # 4 - object size in bytes
-       # 5 - metod (unused)
-       # 6 - URL (unused)
-       # 7 - username
-       # 8 - load status TYPE/source
-       # 9 - mime type (unused)
-       my @line = split / +/, $lines[$index++];
-
-       # Skip line if have no incoming traffic
-       (my $errcode = $line[8]) =~ s/\/\S+//;
-       next if $errcode eq "NONE";
-
-       # Get data from cache
-       (my $uid = $line[7]) =~ s/^-$/anonymous/;
-       my $user = unpack_user($uid);
-
-       # Update user info from LDAP if need
-       if ( !exists($cache{$uid}) )
-       {
-               warn timestamp, "User $uid is not in cache. Go to search LDAP.\n";
-               update_userinfo($user);
-       }
-
-       # Update traffic info
-       $user->{trafficUsage} += $line[4];
-       $user->{firstRequest} |= $line[0];
-       $user->{lastRequest} = $line[0];
-
-       update_quota($user);
-       pack_user($user);
-
-       dump_data($user) if $debug;
-
-       $cache{TIMESTAMP} = $user->{lastRequest};
-}
-
-warn timestamp, $index - $cache{STRING_NUMBER}, " new lines processed.\n";
-$cache{STRING_NUMBER} = $index;
-
-$LDAP->unbind;
-untie @lines;
-untie %cache;
-
diff --git a/gosa-core/contrib/scripts/goQuotaView.pl b/gosa-core/contrib/scripts/goQuotaView.pl
deleted file mode 100644 (file)
index 7dd1497..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/perl
-#
-# Show user info from cache
-#
-# Igor Muratov <migor@altlinux.org>
-#
-# $Id: goQuotaView.pl,v 1.2 2005/04/03 00:46:14 migor-guest Exp $
-#
-
-use strict;
-use DB_File;
-
-my $CACHE_FILE = '/var/spool/squid/quota.db';
-my $FORMAT = "A16 A5 S S L A5 L L L";
-
-my %cache;
-
-sub min2time
-{
-       my $min = shift;
-       return sprintf("%2d:%02d",$min/60,$min%60);
-}
-
-sub show_user
-{
-       my $uid = shift;
-
-       my (
-               $modifyTimestamp, $gosaProxyAcctFlags, $gosaProxyWorkingStart,
-               $gosaProxyWorkingStop, $gosaProxyQuota, $gosaProxyQuotaPeriod,
-               $trafficUsage, $firstRequest, $lastRequest
-       ) = unpack($FORMAT, $cache{$uid});
-
-       my ($ts_Y, $ts_M, $ts_D, $ts_h, $ts_m, $ts_s)
-               = $modifyTimestamp =~ /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/g;
-       my $ts = "$ts_D\.$ts_M\.$ts_Y $ts_h:$ts_m:$ts_s GMT";
-
-       $gosaProxyAcctFlags =~ s/[\[\]]//g;
-       $gosaProxyAcctFlags =~ s/F/unwanted content, /g;
-       $gosaProxyAcctFlags =~ s/T/work time, /g;
-       $gosaProxyAcctFlags =~ s/B/traffic/g;
-
-       $gosaProxyQuotaPeriod =~ s/h/hour/;
-       $gosaProxyQuotaPeriod =~ s/d/day/;
-       $gosaProxyQuotaPeriod =~ s/w/week/;
-       $gosaProxyQuotaPeriod =~ s/m/month/;
-       $gosaProxyQuotaPeriod =~ s/y/year/;
-
-       $firstRequest = localtime($firstRequest);
-       $lastRequest = localtime($lastRequest);
-
-       printf "User: %s
-  LDAP modify timestamp\t%s
-  Limited by\t\t%s
-  Work time from\t%s
-  Work time to\t\t%s
-  Quota period\t\tOne %s
-  Traffic quota size\t%s bytes
-  Current traffic usage\t%s bytes
-  First request time\t%s
-  Last request time\t%s\n",
-       $uid, $ts, $gosaProxyAcctFlags, min2time($gosaProxyWorkingStart),
-       min2time($gosaProxyWorkingStop), $gosaProxyQuotaPeriod, $gosaProxyQuota,
-       $trafficUsage, $firstRequest, $lastRequest;
-}
-
-#------------------------
-tie(%cache, 'DB_File', $CACHE_FILE, O_CREAT|O_RDWR);
-
-if($ARGV[0])
-{
-       show_user($ARGV[0]);
-}
-else
-{
-       print "eee\n";
-       printf "LAST STRING: %d\nLAST CACHE UPDATE: %s\nLDAP LAST CHANGE:  %s\n",
-               $cache{STRING_NUMBER},
-               time2str("%d.%m.%Y %H:%M:%S",$cache{TIMESTAMP}),
-               $cache{MODIFY_TIMESTAMP};
-
-       foreach my $user (keys %cache)
-       {
-               next if $user eq "TIMESTAMP";
-               next if $user eq "STRING_NUMBER";
-               next if $user eq "MODIFY_TIMESTAMP";
-               show_user($user);
-       }
-}
-
-untie %cache;
diff --git a/gosa-core/contrib/scripts/goSquid.pl b/gosa-core/contrib/scripts/goSquid.pl
deleted file mode 100644 (file)
index b91db16..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/perl
-#
-# Squid redirect programm for GOsa project
-#
-# Igor Muratov <migor@altlinux.org>
-#
-# $Id: goSquid.pl,v 1.3 2005/04/03 00:46:14 migor-guest Exp $
-#
-
-use strict;
-use POSIX qw(strftime);
-use Time::Local;
-use DB_File;
-
-my $debug = 0;
-$|=1;
-
-my $DEFAULT_URL = "http://www.squid-cache.org/Squidlogo2.gif";
-my $black_list = '/var/spool/squid/domains.db';
-my $cache_file = '/var/spool/squid/quota.db';
-my $format = "A16 A5 S S L A5 L L L";
-
-my %cache;
-my %blacklist;
-
-sub timestamp
-{
-       return strftime("%a %b %X goSquid[$$]: ", localtime);
-}
-
-# Check url in our blacklist
-sub unwanted_content
-{
-       my $url = shift;
-       my $host = (split(/\//, $url))[2];
-
-       return 1 if exists($blacklist{$host}) and $blacklist{$host} > 0;
-       return undef;
-}
-
-# Check work time limit
-sub work_time
-{
-       my $user = shift;
-       my ($min,$hour) = (localtime)[1,2];
-       my $time = $hour * 60 + $min;
-
-       return 1 if $user->{gosaProxyWorkingStart} < $time and $user->{gosaProxyWorkingStop} > $time;
-       return undef;
-}
-
-sub quota_exceed
-{
-       my $user = shift;
-
-       return 1 if $user->{trafficUsage} > $user->{gosaProxyQuota};
-       return undef;
-}
-
-sub check_access
-{
-       my ($user, $url) = @_;
-
-       $user->{timed} = 0;
-       $user->{quoted} = 0;
-       $user->{filtered} = 0;
-
-       if($user->{gosaProxyAcctFlags} =~ m/[F]/)
-       {
-               # Filter unwanted content
-               $user->{filtered} = 1 if unwanted_content($url);
-       }
-       if($user->{gosaProxyAcctFlags} =~ m/[T]/)
-       {
-               # Filter unwanted content during working hours only
-               $user->{timed} = 1 if work_time($user);
-       }
-       if($user->{gosaProxyAcctFlags} =~ m/B/)
-       {
-               $user->{quoted} = 1 if quota_exceed($user);
-       }
-}
-
-#--------------------------------------
-while (<>) {
-       my ($url, $addr, $uid, $method) = split;
-       my $time = timelocal(localtime);
-       tie(%blacklist, 'DB_File', $black_list, O_RDONLY);
-       tie(%cache, 'DB_File', $cache_file, O_RDONLY);
-
-       if( exists($cache{$uid}) )
-       {
-               my $user;
-               $user->{uid} = $uid;
-               (
-                       $user->{modifyTimestamp},
-                       $user->{gosaProxyAcctFlags},
-                       $user->{gosaProxyWorkingStart},
-                       $user->{gosaProxyWorkingStop},
-                       $user->{gosaProxyQuota},
-                       $user->{gosaProxyQuotaPeriod},
-                       $user->{trafficUsage},
-                       $user->{firstRequest},
-                       $user->{lastRequest}
-               ) = unpack($format, $cache{$uid});
-
-               check_access($user, $url);
-
-               if($user->{'disabled'})
-               {
-                       warn timestamp, "Access denied for unknown user $uid\n";
-               }
-               elsif($user->{'timed'})
-               {
-                       warn timestamp, "Access denied by worktime for $uid\n";
-               }
-               elsif($user->{'quoted'})
-               {
-                       warn timestamp, "Access denied by quota for $uid\n";
-               }
-               elsif($user->{'filtered'})
-               {
-                       warn timestamp, "Content $url filtered for $uid\n";
-               }
-               else
-               {
-                       print "$url\n";
-                       next;
-               }
-       }
-
-       untie %blacklist;
-       untie %cache;
-
-       print "$DEFAULT_URL\n";
-}
diff --git a/gosa-core/contrib/scripts/gosa b/gosa-core/contrib/scripts/gosa
deleted file mode 100755 (executable)
index 4fb0789..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/sh
-# Start script for GOsa to be started via gecko based browsers
-
-[ -r /etc/gosa/desktoprc ] && . /etc/gosa/desktoprc
-[ -r $HOME/.gosa-desktop ] && . $HOME/.gosa-desktop
-
-url=""
-if [ $# -ne 1 -a -z "$URL" ]; then
-       echo "Usage: $(basename $0) <URL>"
-       exit 1
-fi
-
-if [ $# -ne 1 ]; then
-       url="$URL"
-else
-       url="$1"
-fi
-
-# What browser are we using?
-result=""
-echo -n "Looking for browser: "
-for browser in iceweasel firefox mozilla; do
-       if which $browser 2> /dev/null; then
-               result=$browser
-               break
-       fi
-done
-if [ -z "$result" ]; then
-       echo "none found. You'll need iceweasel, firefox or mozilla in your PATH!"
-       exit 1
-fi
-browser=$result
-dbrowser=$browser
-
-# Workaround for debian
-if [ "$browser" = "iceweasel" ]; then
-       dbrowser=firefox
-fi
-
-# Check for presence of gosa profile
-if [ ! -d $HOME/.mozilla/$dbrowser/*.gosa ]; then
-       echo "No browser profile found for GOsa - creating one..."
-       $browser -CreateProfile gosa
-       if [ "$browser" = "iceweasel" ]; then
-               config=`echo $HOME/.mozilla/firefox/*.gosa/`
-       else
-               config=`echo $HOME/.mozilla/$dbrowser/*.gosa/`
-       fi
-
-       # Catch resolution
-       width=1024
-       height=768
-       if which xrandr > /dev/null; then
-               if xrandr 1> /dev/null 2> /dev/null; then
-                       resolution=$(xrandr | sed -n '/current/s/^.*current \([0-9]*\)[^0-9]*\([0-9]*\).*$/\1 \2/p')
-                       width=${resolution%% *}
-                       height=${resolution##* }
-
-                       [ $width -gt 1050 ] && width=1050
-                       [ $height -gt 850 ] && height=850
-               fi
-       fi
-
-       cat << EOF > $config/prefs.js
-# Mozilla User Preferences
-
-/* Do not edit this file.
- *
- * If you make changes to this file while the browser is running,
- * the changes will be overwritten when the browser exits.
- *
- * To make a manual change to preferences, you can visit the URL about:config
- * For more information, see http://www.mozilla.org/unix/customizing.html#prefs
- */
-
-user_pref("app.update.autoUpdateEnabled", false);
-user_pref("app.update.enabled", false);
-user_pref("browser.download.folderList", 2);
-user_pref("browser.download.manager.showWhenStarting", false);
-user_pref("browser.formfill.enable", false);
-user_pref("browser.preferences.lastpanel", 1);
-user_pref("browser.search.selectedEngine", "Damnfresh");
-user_pref("browser.startup.homepage", "$url");
-user_pref("browser.startup.homepage_override.mstone", "rv:1.8.1.1");
-user_pref("extensions.disabledObsolete", true);
-user_pref("extensions.lastAppVersion", "2.0.0.1");
-user_pref("extensions.update.autoUpdateEnabled", false);
-user_pref("intl.charsetmenu.browser.cache", "ISO-8859-1");
-user_pref("network.cookie.prefsMigrated", true);
-user_pref("security.OCSP.URL", "");
-user_pref("security.OCSP.signingCA", "Builtin Object Token:IPS CLASE1 root");
-user_pref("security.warn_entering_secure", false);
-user_pref("security.warn_leaving_secure", false);
-user_pref("security.warn_submit_insecure", false);
-user_pref("security.warn_viewing_mixed", false);
-user_pref("signon.rememberSignons", false);
-user_pref("security.warn_submit_insecure", false);
-EOF
-
-       cat << EOF > $config/84795799.s
-#2c
-http://vserver-02
-.
-EOF
-
-       [ ! -d $config/chrome ] && mkdir -p $config/chrome
-       cat << EOF > $config/chrome/userChrome.css
-#main-menubar {
-        display: none;
-}
-#navigator-throbber {
-        display: none;
-}
-EOF
-
-cat << EOF > $config/localstore.rdf
-<?xml version="1.0"?>
-<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"
-         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-  <RDF:Description RDF:about="chrome://mozapps/content/downloads/unknownContentType.xul#unknownContentType"
-                   screenX="267"
-                   screenY="304" />
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul#PersonalToolbar"
-                   currentset="__empty"
-                   collapsed="true" />
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul#toolbar-menubar"
-                   currentset="__empty"
-                   collapsed="true" />
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul#sidebar-box"
-                   collapsed="true"
-                   sidebarcommand=""
-                   width=""
-                   src="" />
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul#status-bar"
-                   hidden="true" />
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul">
-    <NC:persist RDF:resource="chrome://browser/content/browser.xul#main-window"/>
-    <NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-box"/>
-    <NC:persist RDF:resource="chrome://browser/content/browser.xul#sidebar-title"/>
-    <NC:persist RDF:resource="chrome://browser/content/browser.xul#nav-bar"/>
-    <NC:persist RDF:resource="chrome://browser/content/browser.xul#PersonalToolbar"/>
-    <NC:persist RDF:resource="chrome://browser/content/browser.xul#toolbar-menubar"/>
-  </RDF:Description>
-  <RDF:Description RDF:about="chrome://mozapps/content/downloads/unknownContentType.xul">
-    <NC:persist RDF:resource="chrome://mozapps/content/downloads/unknownContentType.xul#unknownContentType"/>
-  </RDF:Description>
-  <RDF:Description RDF:about="chrome://global/content/customizeToolbar.xul">
-    <NC:persist RDF:resource="chrome://global/content/customizeToolbar.xul#CustomizeToolbarWindow"/>
-  </RDF:Description>
-  <RDF:Description RDF:about="chrome://help/content/help.xul#help"
-                   screenX="350"
-                   screenY="225"
-                   width="700"
-                   height="550" />
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul#main-window"
-                   screenX="50"
-                   screenY="25"
-                   sizemode="normal"
-                   width="$width"
-                   height="$height" />
-  <RDF:Description RDF:about="chrome://help/content/help.xul">
-    <NC:persist RDF:resource="chrome://help/content/help.xul#help"/>
-  </RDF:Description>
-  <RDF:Description RDF:about="chrome://browser/content/browser.xul#nav-bar"
-                   currentset="__empty"
-                   collapsed="true" />
-</RDF:RDF>
-
-
-
-EOF
-fi
-
-
-# Start mozilla with GOsa profile
-$browser -P gosa $url
-
diff --git a/gosa-core/contrib/scripts/gosa.1 b/gosa-core/contrib/scripts/gosa.1
deleted file mode 100644 (file)
index 73f383e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-.TH gosa 1
-.SH NAME
-gosa \- start script for the GOsa web interface
-.SH SYNOPSIS
-.PP
-.B gosa
-[
-URL
-]
-.SH DESCRIPTION
-Start the 
-.B GOsa
-web interface using a gecko based browser and generate
-a special browser profile for
-.B GOsa
-usage. This profile will disable
-normal style browser navigation and URL fields.
-.SH OPTIONS
-.TP
-.BR URL
-Open this URL when launching the browser with the GOsa profile. This
-option is optional and may be preset by the
-.B configuration
-files.
-.SH "RETURN VALUE"
-The script return zero values on success.
-.SH EXAMPLES
-.B gosa
-https://admin.example.net
-.SH FILES
-Presetting the URL works by placing something like
-.B URL="http://admin.example.net"
-inside one of these files:
-.br
-.nf
-.\" set tabstop to longest possible filename, plus a wee bit
-.ta \w'/usr/lib/perl/getopts.pl   'u
-\fI/etc/gosa/desktoprc\fR      system wide setting
-\fI$HOME/.gosa-desktop\fR      user specific setting
-.SH AUTHOR
-Cajus Pollmeier <cajus@debian.org>
diff --git a/gosa-core/contrib/scripts/mkHash.pl b/gosa-core/contrib/scripts/mkHash.pl
deleted file mode 100644 (file)
index 84f4bd1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use DB_File;
-
-my $db = "/var/spool/squid/domains.db";
-my %db;
-
-tie(%db, 'DB_File', $db);
-
-while(<>)
-{
-       chomp;
-       unless(exists($db{$_}))
-       {
-               $db{$_} = 1;
-       }
-}
-
-untie %db;
diff --git a/gosa-core/contrib/scripts/sieve_vacation/IMAP/Sieve.pm b/gosa-core/contrib/scripts/sieve_vacation/IMAP/Sieve.pm
deleted file mode 100644 (file)
index ec10808..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-# $Id: Sieve.pm,v 0.4.9b 2001/06/15 19:25:00 alain Exp $
-
-package IMAP::Sieve;
-
-use strict;
-use Carp;
-use IO::Select;
-use IO::Socket;
-use IO::Socket::INET;
-#use Text::ParseWords qw(parse_line);
-use Cwd;
-
-use vars qw($VERSION);
-
-$VERSION = '0.4.9b';
-
-sub new {
-    my $class = shift;
-    my $self = {};
-    bless $self, $class;
-    if ((scalar(@_) % 2) != 0) {
-       croak "$class called with incorrect number of arguments";
-    }
-    while (@_) {
-       my $key = shift(@_);
-       my $value = shift(@_);
-       $self->{$key} = $value;
-    }
-    $self->{'CLASS'} = $class;
-    $self->_initialize;
-    return $self;
-}
-
-sub _initialize {
-    my $self = shift;
-    my ($len,$userpass,$encode);
-    if (!defined($self->{'Server'})) {
-       croak "$self->{'CLASS'} not initialized properly : Server parameter missing";
-    }
-    if (!defined($self->{'Port'})) {
-       $self->{'Port'} = 2000; # default sieve port;
-    }
-    if (!defined($self->{'Login'})) {
-       croak "$self->{'CLASS'} not initialized properly : Login parameter missing";
-    }
-    if (!defined($self->{'Password'})) {
-       croak "$self->{'CLASS'} not initialized properly : Password parameter missing";
-    }
-    if (!defined($self->{'Proxy'})) {
-       $self->{'Proxy'} = ''; # Proxy;
-    }
-    if (defined($self->{'SSL'})) {
-       my $cwd= cwd;
-       my %ssl_defaults = (
-                         'SSL_use_cert' => 0,
-                         'SSL_verify_mode' => 0x00,
-                         'SSL_key_file' => $cwd."/certs/client-key.pem",
-                         'SSL_cert_file' => $cwd."/certs/client-cert.pem",
-                         'SSL_ca_path' => $cwd."/certs",
-                         'SSL_ca_file' => $cwd."/certs/ca-cert.pem",
-                         );
-       my @ssl_options;
-       my $ssl_key;
-       my $key;
-       foreach $ssl_key (keys(%ssl_defaults)) {
-               if (!defined($self->{$ssl_key})) {
-                       $self->{$ssl_key} = $ssl_defaults{$ssl_key};
-               }
-       }
-       foreach $ssl_key (keys(%{$self})) {
-               if ($ssl_key =~ /^SSL_/) {
-                       push @ssl_options, $ssl_key,$self->{$ssl_key};
-               }
-       }
-        my $SSL_try="use IO::Socket::SSL";
-       eval $SSL_try;
-       if (!eval {$self->{'Socket'} =
-               IO::Socket::SSL->new(PeerAddr => $self->{'Server'},
-                                    PeerPort => $self->{'Port'},
-                                    Proto => 'tcp',
-                                    Reuse => 1,
-                                    Timeout => 5,
-                                    @ssl_options);}) {
-               $self->_error("initialize", "couldn't establish a sieve SSL connection to",$self->{'Server'}, "[$!]","path=$cwd");
-               delete $self->{'Socket'};
-               return;
-       }
-     }
-     else {
-
-       if (!eval {$self->{'Socket'} = IO::Socket::INET->new(PeerAddr => $self->{'Server'},
-                                                        PeerPort => $self->{'Port'},
-                                                        Proto => 'tcp',
-                                                        Reuse => 1); })
-       {
-               $self->_error("initialize", "could'nt establish a Sieve connection to",$self->{'Server'});                              
-               return;
-       }
-    } # if SSL
-
-    my $fh = $self->{'Socket'};
-     $_ = $self->_read; #get banner
-    my $try=$_;
-    if (!/timsieved/i) {
-       $self->close;
-       $self->_error("initialize","bad response from",$self->{'Server'},$try);
-       return;
-    }
-    chomp;
-    if (/\r$/) {
-       chop;
-    }
-    if (/IMPLEMENTATION/) {
-       $self->{'Implementation'}=$1 if /^"IMPLEMENTATION" +"(.*)"/;
-       #version 2 of cyrus imap/timsieved
-       # get capability
-       # get OK as well
-       $_=$self->_read;
-        while (!/^OK/) {
-          $self->{'Capability'}=$1 if /^"SASL" +"(.*)"/;
-          $self->{'Sieve'}=$1 if /^"SIEVE" +"(.*)"/;
-          $_ = $self->_read;
-##        $_=$self->_read;
-       }
-    }
-    else {
-       $self->{'Capability'}=$_;
-    }
-    $userpass = "$self->{'Proxy'}\x00".$self->{'Login'}."\x00".$self->{'Password'};
-    $encode=encode_base64($userpass);
-    $len=length($encode);
-    print $fh "AUTHENTICATE \"PLAIN\" {$len+}\r\n";
-    print $fh "$encode\r\n";
-    
-    $_ = $self->_read;
-    $try=$_;
-    if ($try=~/NO/) {
-       $self->close;
-       $self->_error("Login incorrect while connecting to $self->{'Server'}", $try);
-       return;
-    } elsif (/OK/) {
-       $self->{'Error'}= "No Errors";
-       return;
-    } else {
-       #croak "$self->{'CLASS'}: Unknown error -- $_";
-       $self->_error("Unknown error",$try);
-       return;
-    }
-    $self->{'Error'}="No Errors";
-    return;
-}
-sub encode_base64 ($;$)
-{
-    my $res = "";
-    my $eol = $_[1];
-    $eol = "\n" unless defined $eol;
-    pos($_[0]) = 0;                          # ensure start at the beginning
-    while ($_[0] =~ /(.{1,45})/gs) {
-       $res .= substr(pack('u', $1), 1);
-       chop($res);
-    }
-    $res =~ tr|` -_|AA-Za-z0-9+/|;               # `# help emacs
-    # fix padding at the end
-    my $padding = (3 - length($_[0]) % 3) % 3;
-    $res =~ s/.{$padding}$/'=' x $padding/e if $padding;
-    # break encoded string into lines of no more than 76 characters each
-    if (length $eol) {
-       $res =~ s/(.{1,76})/$1$eol/g;
-    }
-    $res;
-}
-
-
-sub _error {
-    my $self = shift;
-    my $func = shift;
-    my @error = @_;
-
-    $self->{'Error'} = join(" ",$self->{'CLASS'}, "[", $func, "]:", @error);
-}
-
-sub _read {
-       my $self = shift;
-       my $buffer ="";
-       my $char = "";
-       my $bytes= 1;
-       while ($bytes == 1) {
-               $bytes = sysread $self->{'Socket'},$char,1;
-               if ($bytes == 0) {
-                       if (length ($buffer) != 0) {
-                               return $buffer;
-                       }
-                       else {
-                               return;
-                       }
-               }
-               else {
-                       if (($char eq "\n") or ($char eq "\r")) {
-                               if (length($buffer) ==0) {
-                                       # remove any cr or nl leftover
-                               }
-                               else {
-                                       return $buffer;
-                               }
-                       }
-                       else {
-                               $buffer.=$char;
-                       }
-               }
-       }
-}
-                               
-                               
-sub close {
-    my $self = shift;
-     if (!defined($self->{'Socket'})) {
-       return 0;
-     }
-     my $fh =$self->{'Socket'};
-    print $fh "LOGOUT\r\n";
-    close($self->{'Socket'});
-    delete $self->{'Socket'};
-}
-
-sub putscript {
-    my $self = shift;
-    my $len;
-
-    if (scalar(@_) != 2)  {
-       $self->_error("putscript", "incorrect number of arguments");
-       return 1;
-    }
-
-    my $scriptname = shift;
-    my $script = shift;
-
-    if (!defined($self->{'Socket'})) {
-       $self->_error("putscript", "no connection open to", $self->{'Server'});
-       return 1;
-    }
-    $len=length($script);
-    my $fh = $self->{'Socket'};
-    print $fh "PUTSCRIPT \"$scriptname\" {$len+}\r\n";
-    print $fh "$script\r\n";
-    $_ = $self->_read;
-    if (/^OK/) {
-       $self->{'Error'} = 'No Errors';
-       return 0;
-    } else {
-       $self->_error("putscript", "couldn't save script", $scriptname, ":", $_);
-       return 1;
-    }
-}
-
-sub deletescript {
-    my $self = shift;
-
-    if (scalar(@_) != 1) {
-       $self->_error("deletescript", "incorrect number of arguments");
-       return 1;
-    }
-    my $script = shift;
-    if (!defined($self->{'Socket'})) {
-       $self->_error("deletescript", "no connection open to", $self->{'Server'});
-       return 1;
-    }
-    my $fh = $self->{'Socket'};
-    print $fh "DELETESCRIPT \"$script\"\r\n";
-    $_ = $self->_read;
-    if (/^OK/) {
-       $self->{'Error'} = 'No Errors';
-       return 0;
-    } else {
-       $self->_error("deletescript", "couldn't delete", $script, ":", $_);
-       return 1;
-    }
-}
-sub getscript { # returns a string
-    my $self = shift;
-    my $allscript;
-
-    if (scalar(@_) != 1) {
-       $self->_error("getscript", "incorrect number of arguments");
-       return 1;
-    }
-    my $script = shift;
-    if (!defined($self->{'Socket'})) {
-       $self->_error("getscript", "no connection open to", $self->{'Server'});
-       return 1;
-    }
-    my $fh = $self->{'Socket'};
-    print $fh "GETSCRIPT \"$script\"\r\n";
-    $_ = $self->_read;
-    if (/^{.*}/) { $_ = $self->_read;  } # remove file size line
-
-    # should probably use the file size to calculate how much to read in
-    while ((!/^OK/) && (!/^NO/)) {
-       $_.="\n" if $_ !~/\n.*$/; # replace newline that _read removes
-       $allscript.=$_; 
-       $_ = $self->_read;
-    }
-    if (/^OK/) {
-       return $allscript;
-    } else {
-       $self->_error("getscript", "couldn't get script", $script, ":", $_);
-       return;
-    }
-}
-
-sub setactive {
-    my $self = shift;
-
-    if (scalar(@_) != 1) {
-       $self->_error("setactive", "incorrect number of arguments");
-       return 1;
-    }
-    my $script = shift;
-    if (!defined($self->{'Socket'})) {
-       $self->_error("setactive", "no connection open to", $self->{'Server'});
-       return 1;
-    }
-    my $fh = $self->{'Socket'};
-    print $fh "SETACTIVE \"$script\"\r\n";
-    $_ = $self->_read;
-    if (/^OK/) {
-       $self->{'Error'} = "No Errors";
-       return 0;
-    } else {
-       $self->_error("setactive", "couldn't set as active", $script, ":", $_);
-       return 1;
-    }
-}
-
-
-sub noop {
-    my $self = shift;
-    my ($id, $acl);
-
-    if (!defined($self->{'Socket'})) {
-       $self->_error("noop", "no connection open to", $self->{'Server'});
-       return 1;
-    }
-    my $fh = $self->{'Socket'};
-    print $fh "NOOP\r\n";
-       $_ = $self->_read;
-       if (!/^OK/) {
-           $self->_error("noop", "couldn't do noop"
-                        );
-           return 1;
-       }
-    $self->{'Error'} = 'No Errors';
-    return 0;
-}
-
-
-sub listscripts {
-    my $self = shift;
-    my (@scripts);
-
-    if (!defined($self->{'Socket'})) {
-       $self->_error("listscripts", "no connection open to", $self->{'Server'});
-       return;
-    }
-
-    #send the command
-    $self->{'Socket'}->print ("LISTSCRIPTS\r\n");
-
-    # While we have more to read
-    while (defined ($_ = $self->_read)) {
-
-                       # Exit the loop if we're at the end of the text
-               last if (m/^OK.*/);
-
-                       # Select the stuff between the quotes (without the asterisk)
-               # m/^"([^"]+?)\*?"\r?$/;
-               # Select including the asterisk (to determine the default script)
-#              m/^"([^"]+?\*?)"\r?$/;
-               $_=~s/"//g;
-                       # Get the name of the script
-                       push @scripts, $_;
-     } 
-
-     if (/^OK/) {
-        return @scripts;
-     } else {
-
-
-
-    }
-    if (/^OK/) {
-       return @scripts;
-    } else {
-       $self->_error("list", "couldn't get list for",  ":", $_);
-       return;
-    }
-}
-
-1;
-__END__
-
diff --git a/gosa-core/contrib/scripts/sieve_vacation/update-vacation.pl b/gosa-core/contrib/scripts/sieve_vacation/update-vacation.pl
deleted file mode 100644 (file)
index aeef964..0000000
+++ /dev/null
@@ -1,600 +0,0 @@
-#!/usr/bin/perl -w -I/usr/local/lib/perl
-#
-# This code is part of GOsa (https://gosa.gonicus.de)
-# Copyright (C) 2007 Frank Moeller
-#
-# 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 IMAP::Sieve;
-use XML::Simple;
-use Data::Dumper;
-use Net::LDAP;
-use URI;
-use utf8;
-use Getopt::Std;
-use Date::Format;
-use vars qw/ %opt /;
-
-#
-# Definitions
-#
-my $gosa_config = "/etc/gosa/gosa.conf";
-my $opt_string = 'l:hs';
-my $location = "";
-my $today_gmt = time ();
-my $today = $today_gmt + 3600;
-my $server_attribute = "";
-my $alternate_address_attribute = "";
-my $gosa_sieve_script_name = "gosa";
-my $simple_bind_dn = "";
-my $simple_bind_dn_pwd = "";
-my $gosa_sieve_script_status = "FALSE";
-my $gosa_sieve_spam_header = "Sort mails with higher spam level";
-my ($ss,$mm,$hh,$day,$month,$year,$zone);
-
-#
-# Templates
-#
-my $gosa_sieve_header = "\#\#\#GOSA\nrequire\ \[\"fileinto\",\ \"reject\",\ \"vacation\"\]\;\n\n";
-my $vacation_header_template = "\# Begin vacation message";
-my $vacation_footer_template = "\# End vacation message";
-
-#
-# Placeholder
-#
-my $start_date_ph = "##STARTDATE##";
-my $stop_date_ph = "##STOPDATE##";
-
-#
-# Usage
-#
-sub usage {
-       die "Usage:\nperl $0 [option]\n
-            \twithout any option $0 uses the default location\n
-            \tOptions:
-            \t\t-l <\"location name\">\tuse special location
-            \t\t-s\t\t\tshow all locations
-            \t\t-h\t\t\tthis help \n";
-}
-
-#
-# Config import
-#
-sub read_config {
-       my $input = shift || die "need config file: $!";
-       my $stream = "";
-       open ( FILE, "< $input" ) or die "Error opening file $input: $! \n";
-       {
-               local $/ = undef;
-               $stream = <FILE>;
-       }
-       close ( FILE );
-       return $stream;
-}
-
-#
-# XML parser
-#
-sub parseconfig {
-       my $c_location = shift;
-       my $xmldata = shift;
-       chomp $c_location;
-       chomp $xmldata;
-       my $data = $xmldata;
-       my $xml = new XML::Simple ();
-       my $c_data = $xml -> XMLin( $xmldata);
-       my $config = {};
-       my $config_base;
-       my $ldap_admin;
-       my $ldap_admin_pwd;
-       my $url;
-       my $mailMethod;
-       #print Dumper ($c_data->{main}->{location}->{config});
-       if ( $c_data->{main}->{location}->{config} ) {
-               #print "IF\n";
-               $config_base = $c_data->{main}->{location}->{config};
-               $url = $c_data->{main}->{location}->{referral}->{url};
-               $ldap_admin = $c_data->{main}->{location}->{referral}->{admin};
-               $ldap_admin_pwd = $c_data->{main}->{location}->{referral}->{password};
-               $mailMethod = $c_data->{main}->{location}->{mailMethod};
-       } else {
-               #print "ELSE\n";
-               $config_base = $c_data->{main}->{location}->{$c_location}->{config};
-               $url = $c_data->{main}->{location}->{$c_location}->{referral}->{url};
-               $ldap_admin = $c_data->{main}->{location}->{$c_location}->{referral}->{admin};
-               $ldap_admin_pwd = $c_data->{main}->{location}->{$c_location}->{referral}->{password};
-               $mailMethod = $c_data->{main}->{location}->{$c_location}->{mailMethod};
-       }
-       print "$config_base -- $url -- $ldap_admin -- $ldap_admin_pwd -- $mailMethod\n";
-       $config->{config_base} = $config_base;
-       $config->{url} = $url;
-       $config->{mailMethod} = $mailMethod;
-       $config->{ldap_admin} = $ldap_admin;
-       $config->{ldap_admin_pwd} = $ldap_admin_pwd;
-
-       return $config;
-}
-
-#
-# Get default location
-#
-sub get_default_location {
-       my $xmldata = shift;
-       my $xml = new XML::Simple ( RootName=>'conf' );
-       my $c_data = $xml -> XMLin( $xmldata );
-       my $default = $c_data->{main}->{default};
-
-       return $default;
-}
-
-#
-# List all location
-#
-sub list_locations {
-       my $xmldata = shift;
-       my $xml = new XML::Simple ( RootName=>'conf' );
-       my $c_data = $xml -> XMLin( $xmldata );
-       my $default = get_default_location ( $xmldata );
-       $default = $default . " (default)";
-       my @locations = ( $default );
-       my $data_ref = $c_data->{main}->{location};
-       my @keys = keys ( %{$data_ref} );
-       @locations = (@locations, @keys);
-
-       return @locations;
-}
-
-#
-# LDAP error handling
-#
-sub ldap_error {
-       my ($from, $mesg) = @_;
-       print "Return code: ", $mesg->code;
-       print "\tMessage: ", $mesg->error_name;
-       print " :",          $mesg->error_text;
-       print "MessageID: ", $mesg->mesg_id;
-       print "\tDN: ", $mesg->dn;
-}
-
-
-#
-# LDAP search
-#
-sub ldap_search {
-       my $url = shift;
-       my $searchString = shift;
-       my $scope = shift;
-       my $base = shift;
-       my $attrs = shift;
-       my $bind_dn = shift;
-       my $bind_dn_pwd = shift;
-       
-       if ( $base eq "NULL" ) {
-               $base = "";
-       }
-       my $ldap = Net::LDAP->new( $url ) or die "$@";
-       if ( ( ! ( $bind_dn ) ) || ( ! ( $bind_dn_pwd ) ) ) {
-               $ldap->bind;
-       } else {
-               $ldap->bind ( $bind_dn, password => $bind_dn_pwd );
-       }
-
-       my $result = $ldap->search (    base    => "$base",
-                                       scope   => "$scope",
-                                       filter  => "$searchString",
-                                       attrs   =>  $attrs
-                                       );
-       if ( $result->code ) {
-               ldap_error ( "Searching", $result );
-       }
-
-       $ldap->unbind;
-       
-       return $result;
-}
-
-#
-# Retrieve LDAP server
-#
-sub get_ldap_server {
-       my $url = shift;
-       
-       my $uri = URI->new($url);
-
-       my $scheme = $uri->scheme;
-       my $host = $uri->host;
-       my $port = $uri->port;
-       #print "$scheme - $host - $port\n";
-       my $server = $scheme . "://" . $host . ":" . $port;
-
-       return $server;
-}
-
-#
-# Retrieve LDAP base
-#
-sub get_ldap_base {
-       my $url = shift;
-       my $config_base = shift;
-       my $bind_dn = shift;
-       my $bind_dn_pwd = shift;
-       my $filter = "(objectClass=*)";
-       my $init_base = "NULL";
-       my $scope = "base";
-       my $attributes = [ 'namingcontexts' ];
-       my $entry = {};
-       my $base = "";
-
-       $config_base =~ s/\,\ +/\,/g;
-       #print $url."\n";
-       #print $config_base."\n";
-       my $result = ldap_search ( $url, $filter, $scope, $init_base, $attributes, $bind_dn, $bind_dn_pwd );
-       my @entries = $result->entries;
-       my $noe = @entries;
-       #print $noe."\n";
-       foreach $entry ( @entries ) {
-               my $tmp = $entry->get_value ( 'namingcontexts' );
-               #print $tmp."\n";
-               $tmp =~ s/\,\ +/\,/g;
-               if ( $config_base =~ m/$tmp/ ) {
-                       $base = $entry->get_value ( 'namingcontexts' );
-               }
-       }
-
-       return $base;
-}
-
-#
-# SIEVE functions
-#
-sub opensieve {
-       my $admin = shift;
-       my $pass = shift;
-       my $user = shift;
-       my $server = shift;
-       my $port = shift;
-
-       #print ( "##### Proxy => $user, Server => $server, Login => $admin, Password => $pass, Port => $port ####\n" );
-
-       my $sieve = IMAP::Sieve->new ( 'Proxy' => $user, 'Server' => $server, 'Login' => $admin, 'Password' => $pass, 'Port' => $port );
-       return $sieve;
-}
-
-sub closesieve {
-       my $sieve = shift;
-
-       if ($sieve) {$sieve->close};
-}
-
-sub listscripts {
-       my $sieve = shift;
-
-       my @scripts = $sieve->listscripts;
-       my $script_list = join("\n",@scripts)."\n";
-       #print $script_list;
-       return $script_list;
-}
-
-sub getscript {
-       my $sieve = shift;
-       my $script = shift;
-       my $scriptfile;
-       chomp $script;
-       #print "$sieve\n";
-       #print "$script\n";
-
-       $scriptfile = $sieve->getscript($script);
-       return $scriptfile;
-}
-
-sub putscript {
-       my $sieve = shift;
-       my $scriptname = shift;
-       my $script = shift;
-       #print "$sieve\n";
-       #print "$scriptname\n";
-       #print "$script\n";
-
-       my $res=$sieve->putscript($scriptname,$script);
-       if ($res) {print $sieve->{'Error'}}
-       return;
-}
-
-sub setactive {
-       my $sieve = shift;
-       my $script = shift;
-
-       my $res=$sieve->setactive($script);
-       if ($res) { print $sieve->{'Error'};}
-       return;
-}
-
-#
-# main ()
-#
-# read options
-getopts( "$opt_string", \%opt );
-
-# read GOsa config
-my $input_stream = read_config ( $gosa_config );
-
-# get location
-if ( $opt{l} ) {
-       $location = $opt{l};
-} elsif ( $opt{h} ) {
-       usage ();
-       exit (0);
-} elsif ( $opt{s} ) {
-       my $loc;
-       my $counter = 1;
-       my @locations = list_locations ( $input_stream );
-       print "\nConfigured Locations: \n";
-       print "---------------------\n";
-       foreach $loc ( @locations ) {
-               print $counter . ". " . $loc . "\n";
-               $counter++;
-       }
-       print "\n\n";
-       exit (0);
-} else {
-       $location = get_default_location ( $input_stream );
-}
-
-# parse config
-my $config = parseconfig ( $location, $input_stream );
-my $ldap_url = get_ldap_server ( $config->{url} );
-my $gosa_config_base = $config->{config_base};
-my $bind_dn = $config->{ldap_admin};
-my $bind_dn_pwd = $config->{ldap_admin_pwd};
-my $mailMethod = $config->{mailMethod};
-utf8::encode($ldap_url);
-utf8::encode($gosa_config_base);
-utf8::encode($mailMethod);
-
-# default mailMethod = kolab
-if ( $mailMethod =~ m/kolab/i ) {
-       $server_attribute = "kolabHomeServer";
-       $alternate_address_attribute = "alias";
-} elsif ( $mailMethod =~ m/cyrus/i ) {
-       $server_attribute = "gosaMailServer";
-       $alternate_address_attribute = "gosaMailAlternateAddress";
-} else {
-       exit (0);
-}
-
-# determine LDAP base
-my $ldap_base = get_ldap_base ( $ldap_url, $gosa_config_base, $simple_bind_dn, $simple_bind_dn_pwd );
-
-# retrieve user informations with activated vacation feature
-my $filter = "(&(objectClass=gosaMailAccount)(gosaMailDeliveryMode=*V*)(!(gosaMailDeliveryMode=*C*)))";
-my $list_of_attributes = [ 'uid', 'mail', $alternate_address_attribute, 'gosaVacationMessage', 'gosaVacationStart', 'gosaVacationStop', $server_attribute ];
-my $search_scope = "sub";
-my $result = ldap_search ( $ldap_url, $filter, $search_scope, $ldap_base, $list_of_attributes, $simple_bind_dn, $simple_bind_dn_pwd );
-
-my @entries = $result->entries;
-my $noe = @entries;
-#print "NOE = $noe\n";
-my $entry = {};
-foreach $entry ( @entries ) {
-       # INITIALISATIONS
-       $gosa_sieve_script_status = "FALSE";
-       my @sieve_scripts = "";
-       my $script_name = "";
-       my $sieve_script = "";
-       my $sieve_vacation = "";
-       # END INITIALISATIONS
-       my $uid_v = $entry->get_value ( 'uid' );
-       #print "$uid_v\n";
-       my $mail_v = $entry->get_value ( 'mail' );
-       my @mailalternate = $entry->get_value ( $alternate_address_attribute );
-       my $vacation = $entry->get_value ( 'gosaVacationMessage' );
-       my $start_v = $entry->get_value ( 'gosaVacationStart' );
-       my $stop_v = $entry->get_value ( 'gosaVacationStop' );
-       my $server_v = $entry->get_value ( $server_attribute );
-
-       # temp. hack to compensate old gosa server name style
-       #if ( $server_v =~ m/^imap\:\/\//i ) {
-       #       $server_v =~ s/^imap\:\/\///;
-       #}
-       if ( ! ( $uid_v ) ) {
-               $uid_v = "";
-       }
-       if ( ! ( $mail_v ) ) {
-               $mail_v = "";
-       }
-       my @mailAddress = ($mail_v);
-       my $alias = "";
-       foreach $alias ( @mailalternate ) {
-               push @mailAddress, $alias;
-       }
-       my $addresses = "";
-       foreach $alias ( @mailAddress ) {
-               $addresses .= "\"" . $alias . "\", ";
-       }
-       $addresses =~ s/\ *$//;
-       $addresses =~ s/\,$//;
-       if ( ! ( $vacation ) ) {
-               $vacation = "";
-       }
-
-       if ( ! ( $start_v ) ) {
-               $start_v = 0;
-               next;
-       }
-       #print time2str("%d.%m.%Y", $start_v)."\n";
-       my $start_date_string = time2str("%d.%m.%Y", $start_v)."\n";
-
-       if ( ! ( $stop_v ) ) {
-               $stop_v = 0;
-               next;
-       }
-       #print time2str("%d.%m.%Y", $stop_v)."\n";
-       my $stop_date_string = time2str("%d.%m.%Y", $stop_v)."\n";
-
-       chomp $start_date_string;
-       chomp $stop_date_string;
-       $vacation =~ s/$start_date_ph/$start_date_string/g;
-       $vacation =~ s/$stop_date_ph/$stop_date_string/g;
-
-       if ( ! ( $server_v ) ) {
-               $server_v = "";
-               next;
-       }
-       #print $uid_v . " | " .
-       #       $addresses . " | " .
-       #       "\n";
-
-       my ($sieve_user, $tmp) = split ( /\@/, $mail_v );
-
-       print "today = $today\nstart = $start_v\nstop = $stop_v\n";
-       my $real_stop = $stop_v + 86400;
-       if ( ( $today >= $start_v ) && ( $today < $real_stop ) ) {
-               print "activating vacation for user $uid_v\n";
-
-               my $srv_filter = "(&(goImapName=$server_v)(objectClass=goImapServer))";
-               my $srv_list_of_attributes = [ 'goImapSieveServer', 'goImapSievePort', 'goImapAdmin', 'goImapPassword' ];
-               my $srv_result = ldap_search ( $ldap_url, $srv_filter, $search_scope, $ldap_base, $srv_list_of_attributes, $bind_dn, $bind_dn_pwd );
-               my @srv_entries = $srv_result->entries;
-               my $srv_entry = {};
-               my $noe = @srv_entries;
-               if ( $noe == 0 ) {
-                       printf STDERR "Error: no $server_attribute defined! Aboarting...";
-               } elsif ( $noe > 1 ) {
-                       printf STDERR "Error: multiple $server_attribute defined! Aboarting...";
-               } else {
-                       my $goImapSieveServer = $srv_entries[0]->get_value ( 'goImapSieveServer' );
-                       my $goImapSievePort = $srv_entries[0]->get_value ( 'goImapSievePort' );
-                       my $goImapAdmin = $srv_entries[0]->get_value ( 'goImapAdmin' );
-                       my $goImapPassword = $srv_entries[0]->get_value ( 'goImapPassword' );
-                       if ( ( $goImapSieveServer ) && ( $goImapSievePort ) && ( $goImapAdmin ) && ( $goImapPassword ) ) {
-#                              if ( ! ( $sieve_user = $uid_v ) ) {
-#                                      $sieve_user = $uid_v;
-#                              }
-                               #my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $sieve_user, $goImapSieveServer, $goImapSievePort);
-                               my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $uid_v, $goImapSieveServer, $goImapSievePort);
-                               @sieve_scripts = listscripts ( $sieve );
-                               #print Dumper (@sieve_scripts);
-                               $script_name = "";
-                               if ( @sieve_scripts ) {
-                                       foreach $script_name ( @sieve_scripts ) {
-                                               if ( $script_name =~ m/$gosa_sieve_script_name/ ) {
-                                                       $gosa_sieve_script_status = "TRUE";
-                                               }
-                                       }
-                                       if ( $gosa_sieve_script_status eq "TRUE" ) {
-                                               print "retrieving and modifying gosa sieve script for user $uid_v\n";
-                                               # requirements
-                                               $sieve_script = getscript( $sieve, $gosa_sieve_script_name );
-                                               #print "$sieve_script\n";
-                                               if ( ! ( $sieve_script ) ) {
-                                                       print "No Sieve Script! Creating New One!\n";
-                                                       $sieve_script = $gosa_sieve_header;
-                                               }
-                                               if ( $sieve_script =~ m/require.*\[.*["|'] *vacation *["|'].*\]/ ) {
-                                                       print "require vacation ok\n";
-                                               } else {
-                                                       print "require vacation not ok\n";
-                                                       print "modifying require statement\n";
-                                                       $sieve_script =~ s/require(.*\[.*)\]/require$1\, "vacation"\]/;
-                                               }
-                                               if ( ! ( $sieve_script =~ m/$vacation_header_template/ ) ) {
-                                                       print "no match header template\n";
-                                                       $sieve_vacation = $vacation_header_template .
-                                                                               "\n" .
-                                                                               "vacation :addresses [$addresses]\n" .
-                                                                               "\"" .
-                                                                               $vacation . 
-                                                                               "\n\"\;" .
-                                                                               "\n" .
-                                                                               $vacation_footer_template .
-                                                                               "\n\n";
-                                               }
-                                               #print ( "$sieve_vacation\n" );
-                                               #print ( "$sieve_script\n" );
-                                               # including vacation message
-                                               if ( $sieve_script =~ m/$gosa_sieve_spam_header/ ) {
-                                                       #print "MATCH\n";
-                                                       $sieve_script =~ s/($gosa_sieve_spam_header[^{}]*{[^{}]*})/$1\n\n$sieve_vacation/;
-                                               } else {
-                                                       $sieve_script =~ s/require(.*\[.*\]\;)/require$1\n\n$sieve_vacation/;
-                                               }
-                                               #print ( "START SIEVE $sieve_script\nSTOP SIEVE" );
-                                               # uploading new sieve script
-                                               putscript( $sieve, $gosa_sieve_script_name, $sieve_script );
-                                               # activating new sieve script
-                                               setactive( $sieve, $gosa_sieve_script_name );
-                                       } else {
-                                               print "no gosa script available for user $uid_v, creating new one";
-                                               $sieve_script = $gosa_sieve_header . "\n\n" . $sieve_vacation;
-                                               # uploading new sieve script
-                                               putscript( $sieve, $gosa_sieve_script_name, $sieve_script );
-                                               # activating new sieve script
-                                               setactive( $sieve, $gosa_sieve_script_name );
-                                       }
-                               }
-                               closesieve ( $sieve );
-                       }
-               }
-       } elsif ( $today >= $real_stop ) {
-               print "deactivating vacation for user $uid_v\n";
-
-               my $srv_filter = "(&(goImapName=$server_v)(objectClass=goImapServer))";
-               my $srv_list_of_attributes = [ 'goImapSieveServer', 'goImapSievePort', 'goImapAdmin', 'goImapPassword' ];
-               my $srv_result = ldap_search ( $ldap_url, $srv_filter, $search_scope, $ldap_base, $srv_list_of_attributes, $bind_dn, $bind_dn_pwd );
-               my @srv_entries = $srv_result->entries;
-               my $srv_entry = {};
-               my $noe = @srv_entries;
-               if ( $noe == 0 ) {
-                       printf STDERR "Error: no $server_attribute defined! Aboarting...";
-               } elsif ( $noe > 1 ) {
-                       printf STDERR "Error: multiple $server_attribute defined! Aboarting...";
-               } else {
-                       my $goImapSieveServer = $srv_entries[0]->get_value ( 'goImapSieveServer' );
-                       my $goImapSievePort = $srv_entries[0]->get_value ( 'goImapSievePort' );
-                       my $goImapAdmin = $srv_entries[0]->get_value ( 'goImapAdmin' );
-                       my $goImapPassword = $srv_entries[0]->get_value ( 'goImapPassword' );
-                       if ( ( $goImapSieveServer ) && ( $goImapSievePort ) && ( $goImapAdmin ) && ( $goImapPassword ) ) {
-                               #my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $sieve_user, $goImapSieveServer, $goImapSievePort);
-                               my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $uid_v, $goImapSieveServer, $goImapSievePort);
-                               @sieve_scripts = listscripts ( $sieve );
-                               $script_name = "";
-                               if ( @sieve_scripts ) {
-                                       foreach $script_name ( @sieve_scripts ) {
-                                               if ( $script_name =~ m/$gosa_sieve_script_name/ ) {
-                                                       $gosa_sieve_script_status = "TRUE";
-                                               }
-                                       }
-                                       if ( $gosa_sieve_script_status eq "TRUE" ) {
-                                               # removing vacation part
-                                               $sieve_script = getscript( $sieve, $gosa_sieve_script_name );
-                                               if ( $sieve_script ) {
-                                                       #print "OLD SIEVE SCRIPT:\n$sieve_script\n\n";
-                                                       $sieve_script =~ s/$vacation_header_template[^#]*$vacation_footer_template//;
-                                                       #print "NEW SIEVE SCRIPT:\n$sieve_script\n\n";
-                                                       # uploading new sieve script
-                                                       putscript( $sieve, $gosa_sieve_script_name, $sieve_script );
-                                                       # activating new sieve script
-                                                       setactive( $sieve, $gosa_sieve_script_name );
-                                               }
-                                       }
-                               }
-                               closesieve ( $sieve );
-                       }
-               }
-       } else {
-               print "no vacation process necessary for user $uid_v\n";
-       }
-}
index 831d7b1d5c3ae22b161f749ba3bcdb1c9a10bb07..0be551155c3bd088b86470e3aebec35bf22085e6 100644 (file)
@@ -1,5 +1,5 @@
-contrib/scripts/desktoprc   /etc/gosa
-contrib/scripts/gosa        /usr/bin
+contrib/desktoprc           /etc/gosa
+contrib/gosa                /usr/bin
 debian/gosa.xpm             /usr/share/pixmaps
 debian/gosa-16.xpm          /usr/share/pixmaps
 debian/gosa-desktop.desktop /usr/share/applications
index f4d88bf3ff05dbce85649fa1bc92b92be33b04ae..994412dbb0d4c784ec6b20d48f9f0c08eb80e5c8 100755 (executable)
@@ -61,7 +61,7 @@ binary-common:
        dh_installexamples
        dh_installmenu
        dh_installdebconf       
-       dh_installman -pgosa-desktop contrib/scripts/gosa.1
+       dh_installman -pgosa-desktop contrib/gosa.1
        dh_link
        dh_strip
        dh_compress 
diff --git a/gosa-plugins/mail/contrib/goAgent.pl b/gosa-plugins/mail/contrib/goAgent.pl
new file mode 100644 (file)
index 0000000..41b991e
--- /dev/null
@@ -0,0 +1,225 @@
+#!/usr/bin/perl
+#
+# Igor Muratov <migor@altlinux.org>
+#
+# Find changes at LDAP and put this to filesystem
+#
+#
+# Igor Muratov <migor@altlinux.org>
+# 20041004
+# - Added rebuildVirtual function
+# 
+# Igor Muratov <migor@altlinux.org>
+# 20040617:
+# - Changed search fiter to exclude gosaUserTemplate entries
+#
+# Simon Liebold <s.liebold@gmx.de>:
+# 20040617:
+# - Changed $TS_FILE-location
+#
+# $Id: goAgent.pl,v 1.4 2004/11/19 21:46:56 migor-guest Exp $ 
+#
+
+use strict;
+use Net::LDAP;
+
+my $LDAP_HOST='localhost';
+my $LDAP_PORT='389';
+my $LDAP_BASE='dc=example,dc=com';
+#my $LDAP_USER='cn=admin,dc=example,dc=com';
+#my $LDAP_PASS='secret';
+
+my $HOME_DIR='/home';
+my $TS_FILE='/tmp/gosa_timestamp';
+my $KEYS_DIR='/etc/openssh/authorized_keys2';
+my $MAIL_DIR='/var/spool/mail';
+my $VLOCAL='/etc/postfix/virtual_local';
+my $VFORWARD='/etc/postfix/virtual_forward';
+my ($ldap, $mesg, $entry);
+my $virtuals = 0;
+
+# Anonymous bind to LDAP
+sub anonBind
+{
+       my $ldap = Net::LDAP->new( $LDAP_HOST, port => $LDAP_PORT );
+       my $mesg = $ldap->bind();
+       $mesg->code && die $mesg->error;
+       return $ldap;
+}
+
+# Bind as LDAP user
+#sub userBind
+#{
+#      my $ldap = Net::LDAP->new( $LDAP_HOST, port => $LDAP_PORT );
+#      my $mesg = $ldap->bind($LDAP_USER, password=>$LDAP_PASS);
+#      $mesg->code && die $mesg->error;
+#      return $ldap;
+#}
+
+# Read timestamp
+sub getTS
+{
+       open(F, "< $TS_FILE");
+       my $ts = <F>;
+       chop $ts;
+       $ts ||= "19700101000000Z";
+       return $ts;
+}
+
+# save timestamp
+sub putTS
+{
+       my $ts = `date -u '+%Y%m%d%H%M%SZ'`;
+       open(F, "> $TS_FILE");
+       print F $ts;
+}
+
+sub rebuildVirtuals
+{
+       print "Rebuild virtuals table for postfix\n";
+       $mesg = $ldap->search(
+               base => $LDAP_BASE,
+               filter => "(&(objectClass=gosaMailAccount)(gosaMailDeliveryMode=[*L*])(|(mail=*)(gosaMailAlternateAddress=*)))",
+               attrs =>  [
+                       'mail',
+                       'uid',
+                       'gosaMailForwardingAddress',
+                       'memberUid'
+               ],
+       );
+
+       # Work if changes is present
+       open(VIRT, "> $VLOCAL");
+       foreach my $entry ($mesg->all_entries)
+       {
+               foreach my $addr ($entry->get_value('mail'))
+               {
+                       print VIRT "$addr\t";
+                       print VIRT join(",", (
+                               $entry->get_value("uid"),
+                               $entry->get_value("gosaMailForwardingAddress"),
+                               $entry->get_value("memberUid"),
+                       ));
+                       print VIRT "\n";
+               }
+       }
+       close(VIRT);
+       `postmap $VLOCAL`;
+
+       $mesg = $ldap->search(
+               base => $LDAP_BASE,
+               filter => "(&(objectClass=gosaMailAccount)(!(gosaMailDeliveryMode=[*L*]))(|(mail=*)(gosaMailAlternateAddress=*)))",
+               attrs =>  [
+                       'gosaMailForwardingAddress',
+               ],
+       );
+
+       # Work if changes is present
+       open(VIRT, "> $VFORWARD");
+       foreach my $entry ($mesg->all_entries)
+       {
+               foreach my $addr ($entry->get_value('mail'))
+               {
+                       print VIRT "$addr\t";
+                       print VIRT join(",", (
+                               $entry->get_value("gosaMailForwardingAddress"),
+                       ));
+                       print VIRT "\n";
+               }
+       }
+       close(VIRT);
+       `postmap $VFORWARD`;
+}
+
+sub posixAccount
+{
+       my $entry = shift;
+       my $uid = ($entry->get_value('uid'))[0];
+       my $home = ($entry->get_value('homeDirectory'))[0];
+       my $uidNumber = ($entry->get_value('uidNumber'))[0];
+       my $gidNumber = ($entry->get_value('gidNumber'))[0];
+
+       print "Update posixAccount: $uid\n";
+       `install -dD -m0701 -o$uidNumber:$gidNumber $home`;
+       #`install -d -m0700 -o$uidNumber:$gidNumber $home/.ssh`;
+       #`install -d -m0751 -o$uidNumber:$gidNumber $home/.public_html`;
+       print "\tEntry ".$entry->dn()." updated\n";
+}
+
+# Get ssh keys and place to system directory
+sub strongAuthenticationUser
+{
+       my $entry = shift;
+       my $uid = ($entry->get_value('uid'))[0];
+       open(KEYS, "> $KEYS_DIR/$uid");
+       print KEYS $_ foreach ($entry->get_value('userCertificate;binary'));
+}
+
+# Create mailbox if need
+sub inetLocalMailRecipient
+{
+       my $entry = shift;
+       my $uid = ($entry->get_value('uid'))[0];
+       my $mail = ($entry->get_value('mailLocalAddress'))[0];
+       my $addr = ($entry->get_value('mailRoutingAddress'))[0];
+       my $uidNumber = ($entry->get_value('uidNumber'))[0];
+       my $mailbox = "$MAIL_DIR/$uid";
+
+       print "Update inetLocalMailRecipient: $mail\n";
+       if( $uid eq $addr )
+       {
+               if( -f "$mailbox" )
+               {
+                       print "Warning: mailbox $mailbox alredy exists. No changes.\n";
+               } else {
+                       `install -m660 -o$uidNumber -gmail /dev/null $mailbox`;
+               }
+       }
+       print "\tEntry ".$entry->dn()." updated\n";
+}
+
+sub disassemble
+{
+       my $entry = shift;
+
+       foreach my $attr ($entry->get_value('objectClass'))
+       {
+               if( $attr eq "posixAccount" ) {
+                       posixAccount($entry);
+               } elsif( $attr eq "inetLocalMailRecipient" ) {
+                       inetLocalMailRecipient($entry);
+               } elsif( $attr eq "strongAuthenticationUser" ) {
+                       strongAuthenticationUser($entry);
+               } elsif( $attr eq "gosaMailAccount" ) {
+                       $virtuals++;
+               }
+       }
+}
+
+#
+# Start main process
+#
+
+# Read timestamp from file
+my $ts = getTS;
+
+$ldap = anonBind;
+$mesg = $ldap->search(
+       base => $LDAP_BASE,
+       filter => "(&(modifyTimestamp>=$ts)(!(objectClass=gosaUserTemplate)))"
+);
+
+# Put timestamp to file
+putTS;
+
+# Work if changes is present
+if($mesg->count > 0)
+{
+       print "Processing records modified after $ts\n\n";
+
+       foreach my $entry ($mesg->all_entries)
+       {
+               disassemble($entry);
+       }
+       rebuildVirtuals if $virtuals;
+}
diff --git a/gosa-plugins/mail/contrib/sieve_vacation/IMAP/Sieve.pm b/gosa-plugins/mail/contrib/sieve_vacation/IMAP/Sieve.pm
new file mode 100644 (file)
index 0000000..ec10808
--- /dev/null
@@ -0,0 +1,401 @@
+# $Id: Sieve.pm,v 0.4.9b 2001/06/15 19:25:00 alain Exp $
+
+package IMAP::Sieve;
+
+use strict;
+use Carp;
+use IO::Select;
+use IO::Socket;
+use IO::Socket::INET;
+#use Text::ParseWords qw(parse_line);
+use Cwd;
+
+use vars qw($VERSION);
+
+$VERSION = '0.4.9b';
+
+sub new {
+    my $class = shift;
+    my $self = {};
+    bless $self, $class;
+    if ((scalar(@_) % 2) != 0) {
+       croak "$class called with incorrect number of arguments";
+    }
+    while (@_) {
+       my $key = shift(@_);
+       my $value = shift(@_);
+       $self->{$key} = $value;
+    }
+    $self->{'CLASS'} = $class;
+    $self->_initialize;
+    return $self;
+}
+
+sub _initialize {
+    my $self = shift;
+    my ($len,$userpass,$encode);
+    if (!defined($self->{'Server'})) {
+       croak "$self->{'CLASS'} not initialized properly : Server parameter missing";
+    }
+    if (!defined($self->{'Port'})) {
+       $self->{'Port'} = 2000; # default sieve port;
+    }
+    if (!defined($self->{'Login'})) {
+       croak "$self->{'CLASS'} not initialized properly : Login parameter missing";
+    }
+    if (!defined($self->{'Password'})) {
+       croak "$self->{'CLASS'} not initialized properly : Password parameter missing";
+    }
+    if (!defined($self->{'Proxy'})) {
+       $self->{'Proxy'} = ''; # Proxy;
+    }
+    if (defined($self->{'SSL'})) {
+       my $cwd= cwd;
+       my %ssl_defaults = (
+                         'SSL_use_cert' => 0,
+                         'SSL_verify_mode' => 0x00,
+                         'SSL_key_file' => $cwd."/certs/client-key.pem",
+                         'SSL_cert_file' => $cwd."/certs/client-cert.pem",
+                         'SSL_ca_path' => $cwd."/certs",
+                         'SSL_ca_file' => $cwd."/certs/ca-cert.pem",
+                         );
+       my @ssl_options;
+       my $ssl_key;
+       my $key;
+       foreach $ssl_key (keys(%ssl_defaults)) {
+               if (!defined($self->{$ssl_key})) {
+                       $self->{$ssl_key} = $ssl_defaults{$ssl_key};
+               }
+       }
+       foreach $ssl_key (keys(%{$self})) {
+               if ($ssl_key =~ /^SSL_/) {
+                       push @ssl_options, $ssl_key,$self->{$ssl_key};
+               }
+       }
+        my $SSL_try="use IO::Socket::SSL";
+       eval $SSL_try;
+       if (!eval {$self->{'Socket'} =
+               IO::Socket::SSL->new(PeerAddr => $self->{'Server'},
+                                    PeerPort => $self->{'Port'},
+                                    Proto => 'tcp',
+                                    Reuse => 1,
+                                    Timeout => 5,
+                                    @ssl_options);}) {
+               $self->_error("initialize", "couldn't establish a sieve SSL connection to",$self->{'Server'}, "[$!]","path=$cwd");
+               delete $self->{'Socket'};
+               return;
+       }
+     }
+     else {
+
+       if (!eval {$self->{'Socket'} = IO::Socket::INET->new(PeerAddr => $self->{'Server'},
+                                                        PeerPort => $self->{'Port'},
+                                                        Proto => 'tcp',
+                                                        Reuse => 1); })
+       {
+               $self->_error("initialize", "could'nt establish a Sieve connection to",$self->{'Server'});                              
+               return;
+       }
+    } # if SSL
+
+    my $fh = $self->{'Socket'};
+     $_ = $self->_read; #get banner
+    my $try=$_;
+    if (!/timsieved/i) {
+       $self->close;
+       $self->_error("initialize","bad response from",$self->{'Server'},$try);
+       return;
+    }
+    chomp;
+    if (/\r$/) {
+       chop;
+    }
+    if (/IMPLEMENTATION/) {
+       $self->{'Implementation'}=$1 if /^"IMPLEMENTATION" +"(.*)"/;
+       #version 2 of cyrus imap/timsieved
+       # get capability
+       # get OK as well
+       $_=$self->_read;
+        while (!/^OK/) {
+          $self->{'Capability'}=$1 if /^"SASL" +"(.*)"/;
+          $self->{'Sieve'}=$1 if /^"SIEVE" +"(.*)"/;
+          $_ = $self->_read;
+##        $_=$self->_read;
+       }
+    }
+    else {
+       $self->{'Capability'}=$_;
+    }
+    $userpass = "$self->{'Proxy'}\x00".$self->{'Login'}."\x00".$self->{'Password'};
+    $encode=encode_base64($userpass);
+    $len=length($encode);
+    print $fh "AUTHENTICATE \"PLAIN\" {$len+}\r\n";
+    print $fh "$encode\r\n";
+    
+    $_ = $self->_read;
+    $try=$_;
+    if ($try=~/NO/) {
+       $self->close;
+       $self->_error("Login incorrect while connecting to $self->{'Server'}", $try);
+       return;
+    } elsif (/OK/) {
+       $self->{'Error'}= "No Errors";
+       return;
+    } else {
+       #croak "$self->{'CLASS'}: Unknown error -- $_";
+       $self->_error("Unknown error",$try);
+       return;
+    }
+    $self->{'Error'}="No Errors";
+    return;
+}
+sub encode_base64 ($;$)
+{
+    my $res = "";
+    my $eol = $_[1];
+    $eol = "\n" unless defined $eol;
+    pos($_[0]) = 0;                          # ensure start at the beginning
+    while ($_[0] =~ /(.{1,45})/gs) {
+       $res .= substr(pack('u', $1), 1);
+       chop($res);
+    }
+    $res =~ tr|` -_|AA-Za-z0-9+/|;               # `# help emacs
+    # fix padding at the end
+    my $padding = (3 - length($_[0]) % 3) % 3;
+    $res =~ s/.{$padding}$/'=' x $padding/e if $padding;
+    # break encoded string into lines of no more than 76 characters each
+    if (length $eol) {
+       $res =~ s/(.{1,76})/$1$eol/g;
+    }
+    $res;
+}
+
+
+sub _error {
+    my $self = shift;
+    my $func = shift;
+    my @error = @_;
+
+    $self->{'Error'} = join(" ",$self->{'CLASS'}, "[", $func, "]:", @error);
+}
+
+sub _read {
+       my $self = shift;
+       my $buffer ="";
+       my $char = "";
+       my $bytes= 1;
+       while ($bytes == 1) {
+               $bytes = sysread $self->{'Socket'},$char,1;
+               if ($bytes == 0) {
+                       if (length ($buffer) != 0) {
+                               return $buffer;
+                       }
+                       else {
+                               return;
+                       }
+               }
+               else {
+                       if (($char eq "\n") or ($char eq "\r")) {
+                               if (length($buffer) ==0) {
+                                       # remove any cr or nl leftover
+                               }
+                               else {
+                                       return $buffer;
+                               }
+                       }
+                       else {
+                               $buffer.=$char;
+                       }
+               }
+       }
+}
+                               
+                               
+sub close {
+    my $self = shift;
+     if (!defined($self->{'Socket'})) {
+       return 0;
+     }
+     my $fh =$self->{'Socket'};
+    print $fh "LOGOUT\r\n";
+    close($self->{'Socket'});
+    delete $self->{'Socket'};
+}
+
+sub putscript {
+    my $self = shift;
+    my $len;
+
+    if (scalar(@_) != 2)  {
+       $self->_error("putscript", "incorrect number of arguments");
+       return 1;
+    }
+
+    my $scriptname = shift;
+    my $script = shift;
+
+    if (!defined($self->{'Socket'})) {
+       $self->_error("putscript", "no connection open to", $self->{'Server'});
+       return 1;
+    }
+    $len=length($script);
+    my $fh = $self->{'Socket'};
+    print $fh "PUTSCRIPT \"$scriptname\" {$len+}\r\n";
+    print $fh "$script\r\n";
+    $_ = $self->_read;
+    if (/^OK/) {
+       $self->{'Error'} = 'No Errors';
+       return 0;
+    } else {
+       $self->_error("putscript", "couldn't save script", $scriptname, ":", $_);
+       return 1;
+    }
+}
+
+sub deletescript {
+    my $self = shift;
+
+    if (scalar(@_) != 1) {
+       $self->_error("deletescript", "incorrect number of arguments");
+       return 1;
+    }
+    my $script = shift;
+    if (!defined($self->{'Socket'})) {
+       $self->_error("deletescript", "no connection open to", $self->{'Server'});
+       return 1;
+    }
+    my $fh = $self->{'Socket'};
+    print $fh "DELETESCRIPT \"$script\"\r\n";
+    $_ = $self->_read;
+    if (/^OK/) {
+       $self->{'Error'} = 'No Errors';
+       return 0;
+    } else {
+       $self->_error("deletescript", "couldn't delete", $script, ":", $_);
+       return 1;
+    }
+}
+sub getscript { # returns a string
+    my $self = shift;
+    my $allscript;
+
+    if (scalar(@_) != 1) {
+       $self->_error("getscript", "incorrect number of arguments");
+       return 1;
+    }
+    my $script = shift;
+    if (!defined($self->{'Socket'})) {
+       $self->_error("getscript", "no connection open to", $self->{'Server'});
+       return 1;
+    }
+    my $fh = $self->{'Socket'};
+    print $fh "GETSCRIPT \"$script\"\r\n";
+    $_ = $self->_read;
+    if (/^{.*}/) { $_ = $self->_read;  } # remove file size line
+
+    # should probably use the file size to calculate how much to read in
+    while ((!/^OK/) && (!/^NO/)) {
+       $_.="\n" if $_ !~/\n.*$/; # replace newline that _read removes
+       $allscript.=$_; 
+       $_ = $self->_read;
+    }
+    if (/^OK/) {
+       return $allscript;
+    } else {
+       $self->_error("getscript", "couldn't get script", $script, ":", $_);
+       return;
+    }
+}
+
+sub setactive {
+    my $self = shift;
+
+    if (scalar(@_) != 1) {
+       $self->_error("setactive", "incorrect number of arguments");
+       return 1;
+    }
+    my $script = shift;
+    if (!defined($self->{'Socket'})) {
+       $self->_error("setactive", "no connection open to", $self->{'Server'});
+       return 1;
+    }
+    my $fh = $self->{'Socket'};
+    print $fh "SETACTIVE \"$script\"\r\n";
+    $_ = $self->_read;
+    if (/^OK/) {
+       $self->{'Error'} = "No Errors";
+       return 0;
+    } else {
+       $self->_error("setactive", "couldn't set as active", $script, ":", $_);
+       return 1;
+    }
+}
+
+
+sub noop {
+    my $self = shift;
+    my ($id, $acl);
+
+    if (!defined($self->{'Socket'})) {
+       $self->_error("noop", "no connection open to", $self->{'Server'});
+       return 1;
+    }
+    my $fh = $self->{'Socket'};
+    print $fh "NOOP\r\n";
+       $_ = $self->_read;
+       if (!/^OK/) {
+           $self->_error("noop", "couldn't do noop"
+                        );
+           return 1;
+       }
+    $self->{'Error'} = 'No Errors';
+    return 0;
+}
+
+
+sub listscripts {
+    my $self = shift;
+    my (@scripts);
+
+    if (!defined($self->{'Socket'})) {
+       $self->_error("listscripts", "no connection open to", $self->{'Server'});
+       return;
+    }
+
+    #send the command
+    $self->{'Socket'}->print ("LISTSCRIPTS\r\n");
+
+    # While we have more to read
+    while (defined ($_ = $self->_read)) {
+
+                       # Exit the loop if we're at the end of the text
+               last if (m/^OK.*/);
+
+                       # Select the stuff between the quotes (without the asterisk)
+               # m/^"([^"]+?)\*?"\r?$/;
+               # Select including the asterisk (to determine the default script)
+#              m/^"([^"]+?\*?)"\r?$/;
+               $_=~s/"//g;
+                       # Get the name of the script
+                       push @scripts, $_;
+     } 
+
+     if (/^OK/) {
+        return @scripts;
+     } else {
+
+
+
+    }
+    if (/^OK/) {
+       return @scripts;
+    } else {
+       $self->_error("list", "couldn't get list for",  ":", $_);
+       return;
+    }
+}
+
+1;
+__END__
+
diff --git a/gosa-plugins/mail/contrib/sieve_vacation/update-vacation.pl b/gosa-plugins/mail/contrib/sieve_vacation/update-vacation.pl
new file mode 100644 (file)
index 0000000..aeef964
--- /dev/null
@@ -0,0 +1,600 @@
+#!/usr/bin/perl -w -I/usr/local/lib/perl
+#
+# This code is part of GOsa (https://gosa.gonicus.de)
+# Copyright (C) 2007 Frank Moeller
+#
+# 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 IMAP::Sieve;
+use XML::Simple;
+use Data::Dumper;
+use Net::LDAP;
+use URI;
+use utf8;
+use Getopt::Std;
+use Date::Format;
+use vars qw/ %opt /;
+
+#
+# Definitions
+#
+my $gosa_config = "/etc/gosa/gosa.conf";
+my $opt_string = 'l:hs';
+my $location = "";
+my $today_gmt = time ();
+my $today = $today_gmt + 3600;
+my $server_attribute = "";
+my $alternate_address_attribute = "";
+my $gosa_sieve_script_name = "gosa";
+my $simple_bind_dn = "";
+my $simple_bind_dn_pwd = "";
+my $gosa_sieve_script_status = "FALSE";
+my $gosa_sieve_spam_header = "Sort mails with higher spam level";
+my ($ss,$mm,$hh,$day,$month,$year,$zone);
+
+#
+# Templates
+#
+my $gosa_sieve_header = "\#\#\#GOSA\nrequire\ \[\"fileinto\",\ \"reject\",\ \"vacation\"\]\;\n\n";
+my $vacation_header_template = "\# Begin vacation message";
+my $vacation_footer_template = "\# End vacation message";
+
+#
+# Placeholder
+#
+my $start_date_ph = "##STARTDATE##";
+my $stop_date_ph = "##STOPDATE##";
+
+#
+# Usage
+#
+sub usage {
+       die "Usage:\nperl $0 [option]\n
+            \twithout any option $0 uses the default location\n
+            \tOptions:
+            \t\t-l <\"location name\">\tuse special location
+            \t\t-s\t\t\tshow all locations
+            \t\t-h\t\t\tthis help \n";
+}
+
+#
+# Config import
+#
+sub read_config {
+       my $input = shift || die "need config file: $!";
+       my $stream = "";
+       open ( FILE, "< $input" ) or die "Error opening file $input: $! \n";
+       {
+               local $/ = undef;
+               $stream = <FILE>;
+       }
+       close ( FILE );
+       return $stream;
+}
+
+#
+# XML parser
+#
+sub parseconfig {
+       my $c_location = shift;
+       my $xmldata = shift;
+       chomp $c_location;
+       chomp $xmldata;
+       my $data = $xmldata;
+       my $xml = new XML::Simple ();
+       my $c_data = $xml -> XMLin( $xmldata);
+       my $config = {};
+       my $config_base;
+       my $ldap_admin;
+       my $ldap_admin_pwd;
+       my $url;
+       my $mailMethod;
+       #print Dumper ($c_data->{main}->{location}->{config});
+       if ( $c_data->{main}->{location}->{config} ) {
+               #print "IF\n";
+               $config_base = $c_data->{main}->{location}->{config};
+               $url = $c_data->{main}->{location}->{referral}->{url};
+               $ldap_admin = $c_data->{main}->{location}->{referral}->{admin};
+               $ldap_admin_pwd = $c_data->{main}->{location}->{referral}->{password};
+               $mailMethod = $c_data->{main}->{location}->{mailMethod};
+       } else {
+               #print "ELSE\n";
+               $config_base = $c_data->{main}->{location}->{$c_location}->{config};
+               $url = $c_data->{main}->{location}->{$c_location}->{referral}->{url};
+               $ldap_admin = $c_data->{main}->{location}->{$c_location}->{referral}->{admin};
+               $ldap_admin_pwd = $c_data->{main}->{location}->{$c_location}->{referral}->{password};
+               $mailMethod = $c_data->{main}->{location}->{$c_location}->{mailMethod};
+       }
+       print "$config_base -- $url -- $ldap_admin -- $ldap_admin_pwd -- $mailMethod\n";
+       $config->{config_base} = $config_base;
+       $config->{url} = $url;
+       $config->{mailMethod} = $mailMethod;
+       $config->{ldap_admin} = $ldap_admin;
+       $config->{ldap_admin_pwd} = $ldap_admin_pwd;
+
+       return $config;
+}
+
+#
+# Get default location
+#
+sub get_default_location {
+       my $xmldata = shift;
+       my $xml = new XML::Simple ( RootName=>'conf' );
+       my $c_data = $xml -> XMLin( $xmldata );
+       my $default = $c_data->{main}->{default};
+
+       return $default;
+}
+
+#
+# List all location
+#
+sub list_locations {
+       my $xmldata = shift;
+       my $xml = new XML::Simple ( RootName=>'conf' );
+       my $c_data = $xml -> XMLin( $xmldata );
+       my $default = get_default_location ( $xmldata );
+       $default = $default . " (default)";
+       my @locations = ( $default );
+       my $data_ref = $c_data->{main}->{location};
+       my @keys = keys ( %{$data_ref} );
+       @locations = (@locations, @keys);
+
+       return @locations;
+}
+
+#
+# LDAP error handling
+#
+sub ldap_error {
+       my ($from, $mesg) = @_;
+       print "Return code: ", $mesg->code;
+       print "\tMessage: ", $mesg->error_name;
+       print " :",          $mesg->error_text;
+       print "MessageID: ", $mesg->mesg_id;
+       print "\tDN: ", $mesg->dn;
+}
+
+
+#
+# LDAP search
+#
+sub ldap_search {
+       my $url = shift;
+       my $searchString = shift;
+       my $scope = shift;
+       my $base = shift;
+       my $attrs = shift;
+       my $bind_dn = shift;
+       my $bind_dn_pwd = shift;
+       
+       if ( $base eq "NULL" ) {
+               $base = "";
+       }
+       my $ldap = Net::LDAP->new( $url ) or die "$@";
+       if ( ( ! ( $bind_dn ) ) || ( ! ( $bind_dn_pwd ) ) ) {
+               $ldap->bind;
+       } else {
+               $ldap->bind ( $bind_dn, password => $bind_dn_pwd );
+       }
+
+       my $result = $ldap->search (    base    => "$base",
+                                       scope   => "$scope",
+                                       filter  => "$searchString",
+                                       attrs   =>  $attrs
+                                       );
+       if ( $result->code ) {
+               ldap_error ( "Searching", $result );
+       }
+
+       $ldap->unbind;
+       
+       return $result;
+}
+
+#
+# Retrieve LDAP server
+#
+sub get_ldap_server {
+       my $url = shift;
+       
+       my $uri = URI->new($url);
+
+       my $scheme = $uri->scheme;
+       my $host = $uri->host;
+       my $port = $uri->port;
+       #print "$scheme - $host - $port\n";
+       my $server = $scheme . "://" . $host . ":" . $port;
+
+       return $server;
+}
+
+#
+# Retrieve LDAP base
+#
+sub get_ldap_base {
+       my $url = shift;
+       my $config_base = shift;
+       my $bind_dn = shift;
+       my $bind_dn_pwd = shift;
+       my $filter = "(objectClass=*)";
+       my $init_base = "NULL";
+       my $scope = "base";
+       my $attributes = [ 'namingcontexts' ];
+       my $entry = {};
+       my $base = "";
+
+       $config_base =~ s/\,\ +/\,/g;
+       #print $url."\n";
+       #print $config_base."\n";
+       my $result = ldap_search ( $url, $filter, $scope, $init_base, $attributes, $bind_dn, $bind_dn_pwd );
+       my @entries = $result->entries;
+       my $noe = @entries;
+       #print $noe."\n";
+       foreach $entry ( @entries ) {
+               my $tmp = $entry->get_value ( 'namingcontexts' );
+               #print $tmp."\n";
+               $tmp =~ s/\,\ +/\,/g;
+               if ( $config_base =~ m/$tmp/ ) {
+                       $base = $entry->get_value ( 'namingcontexts' );
+               }
+       }
+
+       return $base;
+}
+
+#
+# SIEVE functions
+#
+sub opensieve {
+       my $admin = shift;
+       my $pass = shift;
+       my $user = shift;
+       my $server = shift;
+       my $port = shift;
+
+       #print ( "##### Proxy => $user, Server => $server, Login => $admin, Password => $pass, Port => $port ####\n" );
+
+       my $sieve = IMAP::Sieve->new ( 'Proxy' => $user, 'Server' => $server, 'Login' => $admin, 'Password' => $pass, 'Port' => $port );
+       return $sieve;
+}
+
+sub closesieve {
+       my $sieve = shift;
+
+       if ($sieve) {$sieve->close};
+}
+
+sub listscripts {
+       my $sieve = shift;
+
+       my @scripts = $sieve->listscripts;
+       my $script_list = join("\n",@scripts)."\n";
+       #print $script_list;
+       return $script_list;
+}
+
+sub getscript {
+       my $sieve = shift;
+       my $script = shift;
+       my $scriptfile;
+       chomp $script;
+       #print "$sieve\n";
+       #print "$script\n";
+
+       $scriptfile = $sieve->getscript($script);
+       return $scriptfile;
+}
+
+sub putscript {
+       my $sieve = shift;
+       my $scriptname = shift;
+       my $script = shift;
+       #print "$sieve\n";
+       #print "$scriptname\n";
+       #print "$script\n";
+
+       my $res=$sieve->putscript($scriptname,$script);
+       if ($res) {print $sieve->{'Error'}}
+       return;
+}
+
+sub setactive {
+       my $sieve = shift;
+       my $script = shift;
+
+       my $res=$sieve->setactive($script);
+       if ($res) { print $sieve->{'Error'};}
+       return;
+}
+
+#
+# main ()
+#
+# read options
+getopts( "$opt_string", \%opt );
+
+# read GOsa config
+my $input_stream = read_config ( $gosa_config );
+
+# get location
+if ( $opt{l} ) {
+       $location = $opt{l};
+} elsif ( $opt{h} ) {
+       usage ();
+       exit (0);
+} elsif ( $opt{s} ) {
+       my $loc;
+       my $counter = 1;
+       my @locations = list_locations ( $input_stream );
+       print "\nConfigured Locations: \n";
+       print "---------------------\n";
+       foreach $loc ( @locations ) {
+               print $counter . ". " . $loc . "\n";
+               $counter++;
+       }
+       print "\n\n";
+       exit (0);
+} else {
+       $location = get_default_location ( $input_stream );
+}
+
+# parse config
+my $config = parseconfig ( $location, $input_stream );
+my $ldap_url = get_ldap_server ( $config->{url} );
+my $gosa_config_base = $config->{config_base};
+my $bind_dn = $config->{ldap_admin};
+my $bind_dn_pwd = $config->{ldap_admin_pwd};
+my $mailMethod = $config->{mailMethod};
+utf8::encode($ldap_url);
+utf8::encode($gosa_config_base);
+utf8::encode($mailMethod);
+
+# default mailMethod = kolab
+if ( $mailMethod =~ m/kolab/i ) {
+       $server_attribute = "kolabHomeServer";
+       $alternate_address_attribute = "alias";
+} elsif ( $mailMethod =~ m/cyrus/i ) {
+       $server_attribute = "gosaMailServer";
+       $alternate_address_attribute = "gosaMailAlternateAddress";
+} else {
+       exit (0);
+}
+
+# determine LDAP base
+my $ldap_base = get_ldap_base ( $ldap_url, $gosa_config_base, $simple_bind_dn, $simple_bind_dn_pwd );
+
+# retrieve user informations with activated vacation feature
+my $filter = "(&(objectClass=gosaMailAccount)(gosaMailDeliveryMode=*V*)(!(gosaMailDeliveryMode=*C*)))";
+my $list_of_attributes = [ 'uid', 'mail', $alternate_address_attribute, 'gosaVacationMessage', 'gosaVacationStart', 'gosaVacationStop', $server_attribute ];
+my $search_scope = "sub";
+my $result = ldap_search ( $ldap_url, $filter, $search_scope, $ldap_base, $list_of_attributes, $simple_bind_dn, $simple_bind_dn_pwd );
+
+my @entries = $result->entries;
+my $noe = @entries;
+#print "NOE = $noe\n";
+my $entry = {};
+foreach $entry ( @entries ) {
+       # INITIALISATIONS
+       $gosa_sieve_script_status = "FALSE";
+       my @sieve_scripts = "";
+       my $script_name = "";
+       my $sieve_script = "";
+       my $sieve_vacation = "";
+       # END INITIALISATIONS
+       my $uid_v = $entry->get_value ( 'uid' );
+       #print "$uid_v\n";
+       my $mail_v = $entry->get_value ( 'mail' );
+       my @mailalternate = $entry->get_value ( $alternate_address_attribute );
+       my $vacation = $entry->get_value ( 'gosaVacationMessage' );
+       my $start_v = $entry->get_value ( 'gosaVacationStart' );
+       my $stop_v = $entry->get_value ( 'gosaVacationStop' );
+       my $server_v = $entry->get_value ( $server_attribute );
+
+       # temp. hack to compensate old gosa server name style
+       #if ( $server_v =~ m/^imap\:\/\//i ) {
+       #       $server_v =~ s/^imap\:\/\///;
+       #}
+       if ( ! ( $uid_v ) ) {
+               $uid_v = "";
+       }
+       if ( ! ( $mail_v ) ) {
+               $mail_v = "";
+       }
+       my @mailAddress = ($mail_v);
+       my $alias = "";
+       foreach $alias ( @mailalternate ) {
+               push @mailAddress, $alias;
+       }
+       my $addresses = "";
+       foreach $alias ( @mailAddress ) {
+               $addresses .= "\"" . $alias . "\", ";
+       }
+       $addresses =~ s/\ *$//;
+       $addresses =~ s/\,$//;
+       if ( ! ( $vacation ) ) {
+               $vacation = "";
+       }
+
+       if ( ! ( $start_v ) ) {
+               $start_v = 0;
+               next;
+       }
+       #print time2str("%d.%m.%Y", $start_v)."\n";
+       my $start_date_string = time2str("%d.%m.%Y", $start_v)."\n";
+
+       if ( ! ( $stop_v ) ) {
+               $stop_v = 0;
+               next;
+       }
+       #print time2str("%d.%m.%Y", $stop_v)."\n";
+       my $stop_date_string = time2str("%d.%m.%Y", $stop_v)."\n";
+
+       chomp $start_date_string;
+       chomp $stop_date_string;
+       $vacation =~ s/$start_date_ph/$start_date_string/g;
+       $vacation =~ s/$stop_date_ph/$stop_date_string/g;
+
+       if ( ! ( $server_v ) ) {
+               $server_v = "";
+               next;
+       }
+       #print $uid_v . " | " .
+       #       $addresses . " | " .
+       #       "\n";
+
+       my ($sieve_user, $tmp) = split ( /\@/, $mail_v );
+
+       print "today = $today\nstart = $start_v\nstop = $stop_v\n";
+       my $real_stop = $stop_v + 86400;
+       if ( ( $today >= $start_v ) && ( $today < $real_stop ) ) {
+               print "activating vacation for user $uid_v\n";
+
+               my $srv_filter = "(&(goImapName=$server_v)(objectClass=goImapServer))";
+               my $srv_list_of_attributes = [ 'goImapSieveServer', 'goImapSievePort', 'goImapAdmin', 'goImapPassword' ];
+               my $srv_result = ldap_search ( $ldap_url, $srv_filter, $search_scope, $ldap_base, $srv_list_of_attributes, $bind_dn, $bind_dn_pwd );
+               my @srv_entries = $srv_result->entries;
+               my $srv_entry = {};
+               my $noe = @srv_entries;
+               if ( $noe == 0 ) {
+                       printf STDERR "Error: no $server_attribute defined! Aboarting...";
+               } elsif ( $noe > 1 ) {
+                       printf STDERR "Error: multiple $server_attribute defined! Aboarting...";
+               } else {
+                       my $goImapSieveServer = $srv_entries[0]->get_value ( 'goImapSieveServer' );
+                       my $goImapSievePort = $srv_entries[0]->get_value ( 'goImapSievePort' );
+                       my $goImapAdmin = $srv_entries[0]->get_value ( 'goImapAdmin' );
+                       my $goImapPassword = $srv_entries[0]->get_value ( 'goImapPassword' );
+                       if ( ( $goImapSieveServer ) && ( $goImapSievePort ) && ( $goImapAdmin ) && ( $goImapPassword ) ) {
+#                              if ( ! ( $sieve_user = $uid_v ) ) {
+#                                      $sieve_user = $uid_v;
+#                              }
+                               #my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $sieve_user, $goImapSieveServer, $goImapSievePort);
+                               my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $uid_v, $goImapSieveServer, $goImapSievePort);
+                               @sieve_scripts = listscripts ( $sieve );
+                               #print Dumper (@sieve_scripts);
+                               $script_name = "";
+                               if ( @sieve_scripts ) {
+                                       foreach $script_name ( @sieve_scripts ) {
+                                               if ( $script_name =~ m/$gosa_sieve_script_name/ ) {
+                                                       $gosa_sieve_script_status = "TRUE";
+                                               }
+                                       }
+                                       if ( $gosa_sieve_script_status eq "TRUE" ) {
+                                               print "retrieving and modifying gosa sieve script for user $uid_v\n";
+                                               # requirements
+                                               $sieve_script = getscript( $sieve, $gosa_sieve_script_name );
+                                               #print "$sieve_script\n";
+                                               if ( ! ( $sieve_script ) ) {
+                                                       print "No Sieve Script! Creating New One!\n";
+                                                       $sieve_script = $gosa_sieve_header;
+                                               }
+                                               if ( $sieve_script =~ m/require.*\[.*["|'] *vacation *["|'].*\]/ ) {
+                                                       print "require vacation ok\n";
+                                               } else {
+                                                       print "require vacation not ok\n";
+                                                       print "modifying require statement\n";
+                                                       $sieve_script =~ s/require(.*\[.*)\]/require$1\, "vacation"\]/;
+                                               }
+                                               if ( ! ( $sieve_script =~ m/$vacation_header_template/ ) ) {
+                                                       print "no match header template\n";
+                                                       $sieve_vacation = $vacation_header_template .
+                                                                               "\n" .
+                                                                               "vacation :addresses [$addresses]\n" .
+                                                                               "\"" .
+                                                                               $vacation . 
+                                                                               "\n\"\;" .
+                                                                               "\n" .
+                                                                               $vacation_footer_template .
+                                                                               "\n\n";
+                                               }
+                                               #print ( "$sieve_vacation\n" );
+                                               #print ( "$sieve_script\n" );
+                                               # including vacation message
+                                               if ( $sieve_script =~ m/$gosa_sieve_spam_header/ ) {
+                                                       #print "MATCH\n";
+                                                       $sieve_script =~ s/($gosa_sieve_spam_header[^{}]*{[^{}]*})/$1\n\n$sieve_vacation/;
+                                               } else {
+                                                       $sieve_script =~ s/require(.*\[.*\]\;)/require$1\n\n$sieve_vacation/;
+                                               }
+                                               #print ( "START SIEVE $sieve_script\nSTOP SIEVE" );
+                                               # uploading new sieve script
+                                               putscript( $sieve, $gosa_sieve_script_name, $sieve_script );
+                                               # activating new sieve script
+                                               setactive( $sieve, $gosa_sieve_script_name );
+                                       } else {
+                                               print "no gosa script available for user $uid_v, creating new one";
+                                               $sieve_script = $gosa_sieve_header . "\n\n" . $sieve_vacation;
+                                               # uploading new sieve script
+                                               putscript( $sieve, $gosa_sieve_script_name, $sieve_script );
+                                               # activating new sieve script
+                                               setactive( $sieve, $gosa_sieve_script_name );
+                                       }
+                               }
+                               closesieve ( $sieve );
+                       }
+               }
+       } elsif ( $today >= $real_stop ) {
+               print "deactivating vacation for user $uid_v\n";
+
+               my $srv_filter = "(&(goImapName=$server_v)(objectClass=goImapServer))";
+               my $srv_list_of_attributes = [ 'goImapSieveServer', 'goImapSievePort', 'goImapAdmin', 'goImapPassword' ];
+               my $srv_result = ldap_search ( $ldap_url, $srv_filter, $search_scope, $ldap_base, $srv_list_of_attributes, $bind_dn, $bind_dn_pwd );
+               my @srv_entries = $srv_result->entries;
+               my $srv_entry = {};
+               my $noe = @srv_entries;
+               if ( $noe == 0 ) {
+                       printf STDERR "Error: no $server_attribute defined! Aboarting...";
+               } elsif ( $noe > 1 ) {
+                       printf STDERR "Error: multiple $server_attribute defined! Aboarting...";
+               } else {
+                       my $goImapSieveServer = $srv_entries[0]->get_value ( 'goImapSieveServer' );
+                       my $goImapSievePort = $srv_entries[0]->get_value ( 'goImapSievePort' );
+                       my $goImapAdmin = $srv_entries[0]->get_value ( 'goImapAdmin' );
+                       my $goImapPassword = $srv_entries[0]->get_value ( 'goImapPassword' );
+                       if ( ( $goImapSieveServer ) && ( $goImapSievePort ) && ( $goImapAdmin ) && ( $goImapPassword ) ) {
+                               #my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $sieve_user, $goImapSieveServer, $goImapSievePort);
+                               my $sieve = opensieve ( $goImapAdmin, $goImapPassword, $uid_v, $goImapSieveServer, $goImapSievePort);
+                               @sieve_scripts = listscripts ( $sieve );
+                               $script_name = "";
+                               if ( @sieve_scripts ) {
+                                       foreach $script_name ( @sieve_scripts ) {
+                                               if ( $script_name =~ m/$gosa_sieve_script_name/ ) {
+                                                       $gosa_sieve_script_status = "TRUE";
+                                               }
+                                       }
+                                       if ( $gosa_sieve_script_status eq "TRUE" ) {
+                                               # removing vacation part
+                                               $sieve_script = getscript( $sieve, $gosa_sieve_script_name );
+                                               if ( $sieve_script ) {
+                                                       #print "OLD SIEVE SCRIPT:\n$sieve_script\n\n";
+                                                       $sieve_script =~ s/$vacation_header_template[^#]*$vacation_footer_template//;
+                                                       #print "NEW SIEVE SCRIPT:\n$sieve_script\n\n";
+                                                       # uploading new sieve script
+                                                       putscript( $sieve, $gosa_sieve_script_name, $sieve_script );
+                                                       # activating new sieve script
+                                                       setactive( $sieve, $gosa_sieve_script_name );
+                                               }
+                                       }
+                               }
+                               closesieve ( $sieve );
+                       }
+               }
+       } else {
+               print "no vacation process necessary for user $uid_v\n";
+       }
+}
diff --git a/gosa-plugins/squid/README.squid b/gosa-plugins/squid/README.squid
new file mode 100644 (file)
index 0000000..023f428
--- /dev/null
@@ -0,0 +1,17 @@
+goQuota.pl - run this script via cron (each 5-10 min for examle). It makes
+             cache file (quota.db) with traffic usage and user info from LDAP
+
+goQuotaView.pl - read collected data from quota.db and print it to
+                 stdout in human readable format
+
+goSquid.pl - connect this script to squid
+             redirect_program /usr/local/sbin/goSquid
+
+goAgent.pl - one script to create home directories and mailboxes on
+             filesystem. run it via cron
+  
+mkHash.pl  - create hash file for black list
+
+At this time all scripts have no config file. Please, edit source to configure.
+
+Igor Muratov <migor@altlinux.org>
diff --git a/gosa-plugins/squid/contrib/goQuota.pl b/gosa-plugins/squid/contrib/goQuota.pl
new file mode 100644 (file)
index 0000000..cceeffa
--- /dev/null
@@ -0,0 +1,294 @@
+#!/usr/bin/perl
+#
+# Parse squid log and write current traffic usage by users into cache
+#
+# Igor Muratov <migor@altlinux.org>
+#
+# $Id: goQuota.pl,v 1.4 2005/04/03 00:46:14 migor-guest Exp $
+#
+
+use strict;
+use Time::Local;
+use Net::LDAP;
+use DB_File;
+use POSIX qw(strftime);
+
+my $debug = 0;
+$|=1;
+
+my $LDAP;
+my $LDAP_HOST = "localhost";
+my $LDAP_PORT = "389";
+my $LDAP_BASE = "ou=People,dc=example,dc=com";
+
+my $ACCESS_LOG = '/var/log/squid/access.log';
+my $CACHE_FILE = '/var/spool/squid/quota.db';
+my $DEFAULT_PERIOD = 'm';
+my $FORMAT = "A16 A5 S S L A5 L L L";
+
+my %cache;
+my @lines;
+
+sub timestamp
+{
+       return strftime("%a %b %X goQuota[$$]: ", localtime);
+}
+
+sub anonBind
+{
+       my $ldap = Net::LDAP->new( $LDAP_HOST, port => $LDAP_PORT );
+       if($ldap)
+       {
+               my $mesg = $ldap->bind();
+               $mesg->code && warn timestamp, "Can't bind to ldap://$LDAP_HOST:$LDAP_PORT:", $mesg->error, "\n";
+               return $ldap;
+       }
+       else
+       {
+               warn timestamp, "Can't connect to ldap://$LDAP_HOST:$LDAP_PORT\n";
+               return undef;
+       }
+}
+
+# Retrive users's data from LDAP
+sub update_userinfo
+{
+       my $user = shift;
+       my $uid = $user->{uid};
+
+       return undef unless $LDAP;
+
+       # User unknown or cache field is expired
+       my $result = $LDAP->search( base=>$LDAP_BASE,
+               filter=>"(&(objectClass=gosaProxyAccount)(uid=$uid))",
+               attrs=>[
+                       'uid',
+                       'gosaProxyAcctFlags',
+                       'gosaProxyQuota',
+                       'gosaProxyQuotaPeriod',
+                       'gosaProxyWorkingStop',
+                       'gosaProxyWorkingStart',
+                       'modifyTimestamp'
+               ]
+       );
+       $result->code && warn timestamp, "Failed to search: ", $result->error;
+
+       # Get user's data
+       if($result->count)
+       {
+               my $entry = ($result->entries)[0];
+
+               $user->{uid} = ($entry->get_value('uid'))[0];
+               $user->{modifyTimestamp} = ($entry->get_value('modifyTimestamp'))[0];
+               $user->{gosaProxyWorkingStart} = ($entry->get_value('gosaProxyWorkingStart'))[0];
+               $user->{gosaProxyWorkingStop} = ($entry->get_value('gosaProxyWorkingStop'))[0];
+               $user->{gosaProxyAcctFlags} = ($entry->get_value('gosaProxyAcctFlags'))[0];
+
+               my ($quota, $unit) = ($entry->get_value('gosaProxyQuota'))[0] =~ /(\d+)(\S)/g;
+               $user->{gosaProxyQuota} = $quota;
+               $user->{gosaProxyQuota} *= 1024 if $unit =~ /[Kk]/;
+               $user->{gosaProxyQuota} *= 1048576 if $unit =~ /[Mm]/;
+               $user->{gosaProxyQuota} *= 1073741824 if $unit =~ /[Gg]/;
+
+               $user->{gosaProxyQuotaPeriod} = ($entry->get_value('gosaProxyQuotaPeriod'))[0] || $DEFAULT_PERIOD;
+               # Return
+               warn timestamp, "User $uid found in LDAP.\n";
+               return 1;
+       } else {
+               # Unknown user
+               warn timestamp, "User $uid does not exists in LDAP.\n";
+               $user->{uid} = $uid;
+               $user->{gosaProxyAcctFlags} = '[FTB]';
+               $user->{gosaProxyQuota} = 0;
+               $user->{gosaProxyQuotaPeriod} = 'y';
+               return 0;
+       }
+}
+
+sub get_update
+{
+       my $ts = shift;
+       my %update;
+       my $result = $LDAP->search( base=>$LDAP_BASE,
+               filter=>"(&(objectClass=gosaProxyAccount)(modifyTimestamp>=$ts))",
+               attrs=>'uid'
+       );
+
+       # Get user's data
+       if($result->count)
+       {
+               my $entry = ($result->entries)[0];
+               $update{($entry->get_value('uid'))[0]}++;
+       }
+       return %update;
+}
+
+# Check quota
+sub update_quota
+{
+       my $user = shift;
+       my $uid = $user->{uid};
+
+       my $period = 0;
+       $period = 3600 if $user->{gosaProxyQuotaPeriod} eq 'h';
+       $period = 86400 if $user->{gosaProxyQuotaPeriod} eq 'd';
+       $period = 604800 if $user->{gosaProxyQuotaPeriod} eq 'w';
+       $period = 2592000 if $user->{gosaProxyQuotaPeriod} eq 'm';
+       $period = 220752000 if $user->{gosaProxyQuotaPeriod} eq 'y';
+
+       if($user->{lastRequest} - $user->{firstRequest} > $period)
+       {
+               if($user->{trafficUsage} > $user->{gosaProxyQuota})
+               {
+                       warn timestamp, "Reduce quota for $uid while $period seconds.\n";
+                       $user->{trafficUsage} -= $user->{gosaProxyQuota};
+                       $user->{firstRequest} += $period;
+               }
+               else
+               {
+                       warn timestamp, "Restart quota for $uid.\n";
+                       $user->{trafficUsage} = 0;
+                       $user->{firstRequest} = $user->{lastRequest};
+               }
+       }
+}
+
+sub dump_data
+{
+       my $user = shift;
+       print "User: ",$user->{uid},"\n";
+       print "\t",$user->{modifyTimestamp},"\n";
+       print "\t",$user->{gosaProxyAcctFlags},"\n";
+       print "\t",$user->{gosaProxyWorkingStart},"\n";
+       print "\t",$user->{gosaProxyWorkingStop},"\n";
+       print "\t",$user->{gosaProxyQuota},"\n";
+       print "\t",$user->{gosaProxyQuotaPeriod},"\n";
+       print "\t",$user->{trafficUsage},"\n";
+       print "\t",$user->{firstRequest},"\n";
+       print "\t",$user->{lastRequest},"\n";
+}
+
+sub unpack_user
+{
+       my $uid = shift;
+       my $user;
+
+       $user->{uid} = $uid;
+       (
+               $user->{modifyTimestamp},
+               $user->{gosaProxyAcctFlags},
+               $user->{gosaProxyWorkingStart},
+               $user->{gosaProxyWorkingStop},
+               $user->{gosaProxyQuota},
+               $user->{gosaProxyQuotaPeriod},
+               $user->{trafficUsage},
+               $user->{firstRequest},
+               $user->{lastRequest}
+       ) = unpack($FORMAT, $cache{$uid});
+
+       return $user;
+}
+
+sub pack_user
+{
+       my $user = shift;
+
+       $cache{$user->{uid}} = pack(
+               $FORMAT,
+               $user->{modifyTimestamp},
+               $user->{gosaProxyAcctFlags},
+               $user->{gosaProxyWorkingStart},
+               $user->{gosaProxyWorkingStop},
+               $user->{gosaProxyQuota},
+               $user->{gosaProxyQuotaPeriod},
+               $user->{trafficUsage},
+               $user->{firstRequest},
+               $user->{lastRequest}
+       );
+}
+
+#--------------------------------------
+$LDAP = anonBind or die timestamp, "No lines processed.\n";
+
+# This is a first time parsing?
+my $firstStart = 1;
+$firstStart = 0 if -e $CACHE_FILE;
+
+# Open log file and cache
+my $cache = tie(%cache, 'DB_File', $CACHE_FILE, O_CREAT|O_RDWR);
+my $log = tie(@lines, 'DB_File', $ACCESS_LOG, O_RDWR, 0640, $DB_RECNO)
+       or die "Cannot open file $ACCESS_LOG: $!\n";
+
+# Mark users which updated in LDAP
+my %updated;
+if(! $firstStart)
+{
+       my $ts = strftime("%Y%m%d%H%M%SZ", gmtime);
+       %updated = get_update($cache{MODIFY_TIMESTAMP} || "19700101000000Z");
+
+       my @count = %updated;
+       $cache{MODIFY_TIMESTAMP} = $ts if $#count;
+
+       foreach my $u (keys %updated)
+       {
+               warn timestamp, "User $u has been updated in LDAP. Refresh data.\n";
+               my $user = unpack_user($u);
+               update_userinfo($user);
+               pack_user($user);
+       }
+}
+
+# Processing log file
+my $index = $cache{TIMESTAMP} < (split / +/, $lines[0])[0]
+       ? 0 : $cache{STRING_NUMBER};
+warn timestamp, "Cache update start at line $index.\n";
+while($lines[$index])
+{
+       # There are array named lines with elements
+       # 0 - line timestamp
+       # 1 - ?? (unused)
+       # 2 - client's IP (unused)
+       # 3 - squid's cache status TEXT_CODE/num_code (unused)
+       # 4 - object size in bytes
+       # 5 - metod (unused)
+       # 6 - URL (unused)
+       # 7 - username
+       # 8 - load status TYPE/source
+       # 9 - mime type (unused)
+       my @line = split / +/, $lines[$index++];
+
+       # Skip line if have no incoming traffic
+       (my $errcode = $line[8]) =~ s/\/\S+//;
+       next if $errcode eq "NONE";
+
+       # Get data from cache
+       (my $uid = $line[7]) =~ s/^-$/anonymous/;
+       my $user = unpack_user($uid);
+
+       # Update user info from LDAP if need
+       if ( !exists($cache{$uid}) )
+       {
+               warn timestamp, "User $uid is not in cache. Go to search LDAP.\n";
+               update_userinfo($user);
+       }
+
+       # Update traffic info
+       $user->{trafficUsage} += $line[4];
+       $user->{firstRequest} |= $line[0];
+       $user->{lastRequest} = $line[0];
+
+       update_quota($user);
+       pack_user($user);
+
+       dump_data($user) if $debug;
+
+       $cache{TIMESTAMP} = $user->{lastRequest};
+}
+
+warn timestamp, $index - $cache{STRING_NUMBER}, " new lines processed.\n";
+$cache{STRING_NUMBER} = $index;
+
+$LDAP->unbind;
+untie @lines;
+untie %cache;
+
diff --git a/gosa-plugins/squid/contrib/goQuotaView.pl b/gosa-plugins/squid/contrib/goQuotaView.pl
new file mode 100644 (file)
index 0000000..7dd1497
--- /dev/null
@@ -0,0 +1,91 @@
+#!/usr/bin/perl
+#
+# Show user info from cache
+#
+# Igor Muratov <migor@altlinux.org>
+#
+# $Id: goQuotaView.pl,v 1.2 2005/04/03 00:46:14 migor-guest Exp $
+#
+
+use strict;
+use DB_File;
+
+my $CACHE_FILE = '/var/spool/squid/quota.db';
+my $FORMAT = "A16 A5 S S L A5 L L L";
+
+my %cache;
+
+sub min2time
+{
+       my $min = shift;
+       return sprintf("%2d:%02d",$min/60,$min%60);
+}
+
+sub show_user
+{
+       my $uid = shift;
+
+       my (
+               $modifyTimestamp, $gosaProxyAcctFlags, $gosaProxyWorkingStart,
+               $gosaProxyWorkingStop, $gosaProxyQuota, $gosaProxyQuotaPeriod,
+               $trafficUsage, $firstRequest, $lastRequest
+       ) = unpack($FORMAT, $cache{$uid});
+
+       my ($ts_Y, $ts_M, $ts_D, $ts_h, $ts_m, $ts_s)
+               = $modifyTimestamp =~ /(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/g;
+       my $ts = "$ts_D\.$ts_M\.$ts_Y $ts_h:$ts_m:$ts_s GMT";
+
+       $gosaProxyAcctFlags =~ s/[\[\]]//g;
+       $gosaProxyAcctFlags =~ s/F/unwanted content, /g;
+       $gosaProxyAcctFlags =~ s/T/work time, /g;
+       $gosaProxyAcctFlags =~ s/B/traffic/g;
+
+       $gosaProxyQuotaPeriod =~ s/h/hour/;
+       $gosaProxyQuotaPeriod =~ s/d/day/;
+       $gosaProxyQuotaPeriod =~ s/w/week/;
+       $gosaProxyQuotaPeriod =~ s/m/month/;
+       $gosaProxyQuotaPeriod =~ s/y/year/;
+
+       $firstRequest = localtime($firstRequest);
+       $lastRequest = localtime($lastRequest);
+
+       printf "User: %s
+  LDAP modify timestamp\t%s
+  Limited by\t\t%s
+  Work time from\t%s
+  Work time to\t\t%s
+  Quota period\t\tOne %s
+  Traffic quota size\t%s bytes
+  Current traffic usage\t%s bytes
+  First request time\t%s
+  Last request time\t%s\n",
+       $uid, $ts, $gosaProxyAcctFlags, min2time($gosaProxyWorkingStart),
+       min2time($gosaProxyWorkingStop), $gosaProxyQuotaPeriod, $gosaProxyQuota,
+       $trafficUsage, $firstRequest, $lastRequest;
+}
+
+#------------------------
+tie(%cache, 'DB_File', $CACHE_FILE, O_CREAT|O_RDWR);
+
+if($ARGV[0])
+{
+       show_user($ARGV[0]);
+}
+else
+{
+       print "eee\n";
+       printf "LAST STRING: %d\nLAST CACHE UPDATE: %s\nLDAP LAST CHANGE:  %s\n",
+               $cache{STRING_NUMBER},
+               time2str("%d.%m.%Y %H:%M:%S",$cache{TIMESTAMP}),
+               $cache{MODIFY_TIMESTAMP};
+
+       foreach my $user (keys %cache)
+       {
+               next if $user eq "TIMESTAMP";
+               next if $user eq "STRING_NUMBER";
+               next if $user eq "MODIFY_TIMESTAMP";
+               show_user($user);
+       }
+}
+
+untie %cache;
diff --git a/gosa-plugins/squid/contrib/goSquid.pl b/gosa-plugins/squid/contrib/goSquid.pl
new file mode 100644 (file)
index 0000000..b91db16
--- /dev/null
@@ -0,0 +1,136 @@
+#!/usr/bin/perl
+#
+# Squid redirect programm for GOsa project
+#
+# Igor Muratov <migor@altlinux.org>
+#
+# $Id: goSquid.pl,v 1.3 2005/04/03 00:46:14 migor-guest Exp $
+#
+
+use strict;
+use POSIX qw(strftime);
+use Time::Local;
+use DB_File;
+
+my $debug = 0;
+$|=1;
+
+my $DEFAULT_URL = "http://www.squid-cache.org/Squidlogo2.gif";
+my $black_list = '/var/spool/squid/domains.db';
+my $cache_file = '/var/spool/squid/quota.db';
+my $format = "A16 A5 S S L A5 L L L";
+
+my %cache;
+my %blacklist;
+
+sub timestamp
+{
+       return strftime("%a %b %X goSquid[$$]: ", localtime);
+}
+
+# Check url in our blacklist
+sub unwanted_content
+{
+       my $url = shift;
+       my $host = (split(/\//, $url))[2];
+
+       return 1 if exists($blacklist{$host}) and $blacklist{$host} > 0;
+       return undef;
+}
+
+# Check work time limit
+sub work_time
+{
+       my $user = shift;
+       my ($min,$hour) = (localtime)[1,2];
+       my $time = $hour * 60 + $min;
+
+       return 1 if $user->{gosaProxyWorkingStart} < $time and $user->{gosaProxyWorkingStop} > $time;
+       return undef;
+}
+
+sub quota_exceed
+{
+       my $user = shift;
+
+       return 1 if $user->{trafficUsage} > $user->{gosaProxyQuota};
+       return undef;
+}
+
+sub check_access
+{
+       my ($user, $url) = @_;
+
+       $user->{timed} = 0;
+       $user->{quoted} = 0;
+       $user->{filtered} = 0;
+
+       if($user->{gosaProxyAcctFlags} =~ m/[F]/)
+       {
+               # Filter unwanted content
+               $user->{filtered} = 1 if unwanted_content($url);
+       }
+       if($user->{gosaProxyAcctFlags} =~ m/[T]/)
+       {
+               # Filter unwanted content during working hours only
+               $user->{timed} = 1 if work_time($user);
+       }
+       if($user->{gosaProxyAcctFlags} =~ m/B/)
+       {
+               $user->{quoted} = 1 if quota_exceed($user);
+       }
+}
+
+#--------------------------------------
+while (<>) {
+       my ($url, $addr, $uid, $method) = split;
+       my $time = timelocal(localtime);
+       tie(%blacklist, 'DB_File', $black_list, O_RDONLY);
+       tie(%cache, 'DB_File', $cache_file, O_RDONLY);
+
+       if( exists($cache{$uid}) )
+       {
+               my $user;
+               $user->{uid} = $uid;
+               (
+                       $user->{modifyTimestamp},
+                       $user->{gosaProxyAcctFlags},
+                       $user->{gosaProxyWorkingStart},
+                       $user->{gosaProxyWorkingStop},
+                       $user->{gosaProxyQuota},
+                       $user->{gosaProxyQuotaPeriod},
+                       $user->{trafficUsage},
+                       $user->{firstRequest},
+                       $user->{lastRequest}
+               ) = unpack($format, $cache{$uid});
+
+               check_access($user, $url);
+
+               if($user->{'disabled'})
+               {
+                       warn timestamp, "Access denied for unknown user $uid\n";
+               }
+               elsif($user->{'timed'})
+               {
+                       warn timestamp, "Access denied by worktime for $uid\n";
+               }
+               elsif($user->{'quoted'})
+               {
+                       warn timestamp, "Access denied by quota for $uid\n";
+               }
+               elsif($user->{'filtered'})
+               {
+                       warn timestamp, "Content $url filtered for $uid\n";
+               }
+               else
+               {
+                       print "$url\n";
+                       next;
+               }
+       }
+
+       untie %blacklist;
+       untie %cache;
+
+       print "$DEFAULT_URL\n";
+}
diff --git a/gosa-plugins/squid/contrib/mkHash.pl b/gosa-plugins/squid/contrib/mkHash.pl
new file mode 100644 (file)
index 0000000..84f4bd1
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use DB_File;
+
+my $db = "/var/spool/squid/domains.db";
+my %db;
+
+tie(%db, 'DB_File', $db);
+
+while(<>)
+{
+       chomp;
+       unless(exists($db{$_}))
+       {
+               $db{$_} = 1;
+       }
+}
+
+untie %db;