diff options
36 files changed, 7677 insertions, 0 deletions
diff --git a/clientgerrit/COPYING b/clientgerrit/COPYING new file mode 100755 index 0000000..e06d208 --- /dev/null +++ b/clientgerrit/COPYING @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/clientgerrit/README b/clientgerrit/README new file mode 100755 index 0000000..73d1d10 --- /dev/null +++ b/clientgerrit/README @@ -0,0 +1,14 @@ +license : https://gerrit.googlecode.com/svn/documentation/2.1/licenses.html + Apache License 2.0 + Common Development and Distribution License (CDDL) + Apache SSHD - Notice + PostgreSQL JDBC Driver - New Style BSD + H2 Database - EPL or modified MPL + ObjectWeb ASM - New Style BSD + ANTLR - New Style BSD + JGit - New Style BSD + args4j - MIT License + SLF4J - MIT License + Clippy - MIT License + ICU4J License +Ref : https://wiki.tizen.org/wiki/Setup_of_Tizen_Infrastructure_with_Docker diff --git a/clientgerrit/config.conf b/clientgerrit/config.conf new file mode 100755 index 0000000..e9e0fce --- /dev/null +++ b/clientgerrit/config.conf @@ -0,0 +1,58 @@ +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +### Image name +export IMAGES="tizendocker:443/gerritdrupalldap" + +### Repository name (and optionally a tag) to be applied to the resulting image in case of success +export TAG="2.9.4.0.2" + +### Assign a name to the container +export CONTAINER="gerritdrupalldap" + +### Publish a container's port to the host +### format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort +export PORTS="80 389 29418" + +### Read in a line delimited file of environment variables +export ENVLIST="$(pwd)/env/env.list" + +### Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container) +export VOLUMES="/home/gerritdrupalldap/var/lib/ldap/:/var/lib/ldap/ + /home/gerritdrupalldap/etc/ldap/slapd.d/:/etc/ldap/slapd.d/ + /home/gerritdrupalldap/var/lib/mysql:/var/lib/mysql/ + /home/gerritdrupalldap/var/www/html/drupal/sites/default/:/var/www/html/drupal/sites/default/ + /home/gerritdrupalldap/home/gerrit/gerrit/:/home/gerrit/gerrit/ + $(pwd)/root/config/:/config/ + " + +### Container host name +export HOSTNAME="GerritDrupalLdap" + +### Give extended privileges to this container +export PRIVILEGED=no + +### Restart policy to apply when a container exits (no, on-failure[:max-retry], always) +export AUTOSTART=always + +### Add link to another container in the form of name:alias +export LINK_IMAGES="" + +### Mount volumes from the specified container(s) +export VOLUMES_IMAGES="" + +### Add a custom host-to-IP mapping (host:ip) +export ADD_HOSTS="" + +### Add Linux capabilities +export CAP_ADD="" diff --git a/clientgerrit/dgerrit.sh b/clientgerrit/dgerrit.sh new file mode 100755 index 0000000..e18347a --- /dev/null +++ b/clientgerrit/dgerrit.sh @@ -0,0 +1,408 @@ +#! /bin/sh +#=============================================================================== +# Tizen gerrit+drupal+openldap +# 01/17 2015 +# +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== + +home="$( cd "$( dirname "$0" )" && pwd )" +. $home/config.conf + +set -e +#------------------------------------------------------------------------------- +images=$IMAGES:$TAG +container=$CONTAINER + +echo "IMAGES:"$images +echo "CONTAINER:"$container + +if [ ! -z "$PORTS" ] +then + for I in $PORTS; do + service_port=$I + if [ ! -z $(echo "$service_port" | grep ':') ] + then + if [ -z "$ports_cmd" ] + then + ports_cmd=$(echo "-p ${service_port} ") + else + ports_cmd=$(echo $ports_cmd"-p ${service_port} ") + fi + elif [ ! -z $(echo "$service_port" | grep '-') ] + then + d1=$(echo $service_port | cut -d '-' -f1) + d2=$(echo $service_port | cut -d '-' -f2) + instance=$((d2 - d1 + 1)) + #echo "instance:"$instance + count=0 + while [ $count -lt $instance ]; do + expose_port=$((d1 + count)) + if [ -z "$ports_cmd" ] + then + ports_cmd=$(echo "-p ${expose_port}:${expose_port} ") + else + ports_cmd=$(echo $ports_cmd"-p ${expose_port}:${expose_port} ") + fi + count=`expr $count + 1` + done + else + if [ -z "$ports_cmd" ] + then + ports_cmd=$(echo "-p ${service_port}:${service_port} ") + else + ports_cmd=$(echo $ports_cmd"-p ${service_port}:${service_port} ") + fi + fi + done +fi +echo "PORT:"$ports_cmd + +if [ ! -z "$ENVLIST" ] +then + envlist_cmd=$(echo "--env-file $ENVLIST") +fi +echo "ENV LIST:"$envlist_cmd + +if [ ! -z "$VOLUMES" ] +then + for vol in $VOLUMES; do + if [ -z "$volumes_cmd" ] + then + volumes_cmd=$(echo "-v /etc/localtime:/etc/localtime:ro -v $vol ") + else + volumes_cmd=$(echo $volumes_cmd "-v $vol ") + fi + done +fi +echo "VOLUMES:"$volumes_cmd +if [ ! -z "$HOSTNAME" ] +then + hostname_cmd=$(echo "-h $HOSTNAME") +fi +echo "HOST NAME:"$hostname_cmd + +if [ "$PRIVILEGED" = 'yes' ] +then + privileged_cmd=$(echo "--privileged") +fi +echo "PRIVILEGED:"$privileged_cmd + +if [ "$AUTOSTART" = 'always' ] +then + autostart_cmd=$(echo "--restart=always") +elif [ "$AUTOSTART" = 'on-failure^' ] +then + autostart_cmd=$(echo "--restart=on-failure:10") +fi +echo "AUTOSTART:"$autostart_cmd + +if [ ! -z "$LINK_IMAGES" ] +then + for link in $LINK_IMAGES; do + if [ -z "$links_cmd" ] + then + links_cmd=$(echo "--link $link ") + else + links_cmd=$(echo $links_cmd "--link $link ") + fi + done +fi +echo "LINKS:"$links_cmd + +if [ ! -z "$VOLUMES_IMAGES" ] +then + for volumes_images in $VOLUMES_IMAGES; do + if [ -z "$volumes_images_cmd" ] + then + volumes_images_cmd=$(echo "--volumes-from $volumes_images ") + else + volumes_images_cmd=$(echo $volumes_images_cmd "--volumes-from $volumes_images ") + fi + done +fi +echo "VOLUMES-FROM:"$volumes_images_cmd + +if [ ! -z "$ADD_HOSTS" ] +then + for hostserver in $ADD_HOSTS; do + if [ -z "$add_hosts_cmd" ] + then + add_hosts_cmd=$(echo "--add-host=$hostserver ") + else + add_hosts_cmd=$(echo $add_hosts_cmd "--add-host=$hostserver ") + fi + done +fi +echo "ADD_HOST:"$add_hosts_cmd + +if [ ! -z "$CAP_ADD" ] +then + for capadd in $CAP_ADD; do + if [ -z "$capadds_cmd" ] + then + capadds_cmd=$(echo "--cap-add=$capadd ") + else + capadds_cmd=$(echo $capadds_cmd "--cap-add=$capadd ") + fi + done +fi +echo "CAP_ADD:"$capadds_cmd + +#------------------------------------------------------------------------------- +install_docker(){ + echo "Install lxc-docker-1.4.1" + + if [ $(lsb_release -a | sed -n '/Description/p' | grep -c "Ubuntu 14.04") -eq 1 ]; + then + echo "Ubuntu 14.04" + if [ $(dpkg-query -W -f='${Status}' lxc-docker-1.4.1 2>/dev/null | grep -c "ok installed") -eq 0 ]; + then + echo "sudo get -qO- https://get.docker.io/gpg" | sh || true + echo "sudo apt-key add -" | sh || true + echo "sudo sh -c "'"echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"' | sh || true + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y lxc-docker-1.4.1" | sh || true + else + echo $(docker --version) + fi + elif [ $(lsb_release -a | sed -n '/Description/p' | grep -c "Ubuntu 12.04") -eq 1 ]; + then + echo "Ubuntu 12.04" + if [ $(dpkg-query -W -f='${Status}' lxc-docker-1.4.1 2>/dev/null | grep -c "ok installed") -eq 0 ]; + then + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y linux-image-generic-lts-raring linux-headers-generic-lts-raring" | sh || true + echo "sudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring" | sh || true + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y apt-transport-https" | sh || true + + echo "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" | sh || true + echo "sudo sh -c "'"echo deb https://get.docker.com/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"' | sh || true + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y lxc-docker-1.4.1" | sh || true + else + echo $(docker --version) + fi + else + echo "It does not install lxc-docker-1.4.1" + fi + +} +#------------------------------------------------------------------------------- +attach(){ + echo "Attaching docker containers:" + docker exec -it $container script /dev/null -c /bin/bash || true +} +#------------------------------------------------------------------------------- +status(){ + echo "Status docker containers:" + docker ps | grep "$container" || true +} +#------------------------------------------------------------------------------- +stop(){ + echo "Stopping docker containers:" + docker stop $container || true + docker ps | grep "$container" || true +} +#------------------------------------------------------------------------------- +start(){ + echo "Starting ${container}:" + echo " docker run -d --name $container \ + $hostname_cmd \ + $privileged_cmd \ + $links_cmd \ + $ports_cmd \ + $envlist_cmd \ + $volumes_cmd \ + $volumes_images_cmd \ + $add_hosts_cmd \ + $capadds_cmd \ + $images + " + if [ ! -z "$links_cmd" ] + then + for link in $LINK_IMAGES; do + link_sh=$(echo "$link" | cut -d ':' -f1) + if [ -z "$(docker ps | grep "$link_sh" | awk '{print $NF}')" ] + then + echo "Please you must be run the" "$link_sh"" before the" "$container" + exit + fi + done + fi + for run_container in $(docker ps -a | grep "$container" | awk '{print $NF}'); do + if [ "$run_container" = "$container" ]; + then + docker start $container + docker ps | grep "$container" || true + exit + fi + done + docker run -d --name $container \ + $hostname_cmd \ + $privileged_cmd \ + $links_cmd \ + $ports_cmd \ + $envlist_cmd \ + $volumes_cmd \ + $volumes_images_cmd \ + $add_hosts_cmd \ + $capadds_cmd \ + $images + + docker ps | grep "$container" || true +} + +#------------------------------------------------------------------------------- +kill(){ + echo "Killing docker containers:" + docker kill $container || true +} +#------------------------------------------------------------------------------- +rm(){ + echo "Removing stopped containers:" + docker rm $container || true +} +#------------------------------------------------------------------------------- +logs(){ + echo "Show logs of a container" + docker logs $container || true +} +#------------------------------------------------------------------------------- +cp(){ + echo "Copy files/folders from a container's filesystem" + echo "docker cp $container:$1 $2 || true" + docker cp $container:$1 $2 || true +} +#------------------------------------------------------------------------------- +pull(){ + echo "Pull an image or a repository from a Docker registry server" + docker pull $images || true +} +#------------------------------------------------------------------------------- +inspect(){ + echo "Return low-level information on a containe" + docker inspect $container || true +} +#------------------------------------------------------------------------------- +top(){ + echo "Lookup the running processes of a container" + docker top $container || true +} +#------------------------------------------------------------------------------- +save(){ + echo "Save an image to a tar archive" + docker save -o $container"-"$TAG"-docker-image.tar.gz" $images || true + echo $(pwd | awk -F '/' '{print $NF}') + tar cvfzp ../$container"-"$TAG"-docker-script.tar.gz" ../$(pwd | awk -F '/' '{print $NF}') + echo "Save $container-$TAG" +} +#------------------------------------------------------------------------------- +load(){ + echo "Load an image from a tar archive" + docker load -i $container"-"$TAG"-docker-image.tar.gz" || true + echo "Load $container-$TAG" +} +#------------------------------------------------------------------------------- +help(){ + echo "help" + usage +} +#------------------------------------------------------------------------------- +usage (){ + echo "USAGE: $0" COMMAND + + echo -e "\nCommands:" + echo " install Install lxc-docker-1.4.1" + echo " start Start a stopped container" + echo " attach Attach to a running container" + echo " stop Stop a running container" + echo " status Status a running container" + echo " rm Remove this containers" + echo " restart stop, start a container" + echo " kill Kill a running container" + echo " logs Fetch the logs of a container" + echo " cp Copy files/folders from a container's filesystem to the host path" + echo " pull Pull an image or a repository from a Docker registry server" + echo " inspect Return low-level information on a containe" + echo " top Lookup the running processes of a container" + echo " save Save an image to a tar archive" + echo " load Load an image from a tar archive" + echo " help help" + exit 1 +} +#------------------------------------------------------------------------------- +if [ $# -eq 0 ] +then + usage +fi + +#------------------------------------------------------------------------------- +case "$1" in + install) + install_docker + ;; + start) + start + ;; + attach) + attach + ;; + status) + status + ;; + stop) + stop + ;; + restart) + stop + start + ;; + kill) + kill + rm + ;; + rm) + rm + ;; + logs) + logs + ;; + cp) + cp $2 $3 + ;; + pull) + pull + ;; + inspect) + inspect + ;; + top) + top + ;; + save) + save + ;; + load) + load + ;; + help) + help + ;; + *) + usage + ;; +esac +#=============================================================================== + diff --git a/clientgerrit/env/env.list b/clientgerrit/env/env.list new file mode 100755 index 0000000..7ba30ba --- /dev/null +++ b/clientgerrit/env/env.list @@ -0,0 +1,29 @@ +#### LDAP CONFIG #### +LDAP_ROOTPASS=opensuse +#LDAP_ORGANISATION=swplatform +#LDAP_DOMAIN=spt.tizen.sec.samsung.net +LDAP_ORGANISATION=swplatform +LDAP_DOMAIN=example.com + +#### MYSQL DB #### +MYSQL_ROOT_PASSWORD=opensuse +MYSQL_DATA_DIR_DEFAULT=/var/lib/mysql + +#### DRUPAL DB #### +MYSQL_DRUPAL_DATABASE=drupal +MYSQL_DRUPAL_USER=drupaluser +MYSQL_DRUPAL_PASSWORD=drupalpassword + +#### GERRIT DB #### +MYSQL_GERRIT_DATABASE=reviewdb +MYSQL_GERRIT_USER=gerrit +MYSQL_GERRIT_PASSWORD=gerritpassword + + +#### env list #### +TERM=xterm + +ftp_proxy= +http_proxy= +https_proxy= +socks_proxy=
\ No newline at end of file diff --git a/clientgerrit/root/config/apache2_gerrit.conf b/clientgerrit/root/config/apache2_gerrit.conf new file mode 100755 index 0000000..e151131 --- /dev/null +++ b/clientgerrit/root/config/apache2_gerrit.conf @@ -0,0 +1,17 @@ +<VirtualHost *:80> +DocumentRoot /var/www/html + +ErrorLog ${APACHE_LOG_DIR}/error.log +CustomLog ${APACHE_LOG_DIR}/access.log combined + +ServerName http://127.0.0.1/gerrit/ +ProxyRequests Off +ProxyVia Off +ProxyPreserveHost On +AllowEncodedSlashes On +<Proxy *> +Order deny,allow +Allow from all +</Proxy> + ProxyPass /gerrit http://127.0.0.1:8081/gerrit nocanon +</VirtualHost> diff --git a/clientgerrit/root/config/default.settings.php b/clientgerrit/root/config/default.settings.php new file mode 100755 index 0000000..580cc38 --- /dev/null +++ b/clientgerrit/root/config/default.settings.php @@ -0,0 +1,553 @@ +<?php + +/** + * @file + * Drupal site-specific configuration file. + * + * IMPORTANT NOTE: + * This file may have been set to read-only by the Drupal installation program. + * If you make changes to this file, be sure to protect it again after making + * your modifications. Failure to remove write permissions to this file is a + * security risk. + * + * The configuration file to be loaded is based upon the rules below. However + * if the multisite aliasing file named sites/sites.php is present, it will be + * loaded, and the aliases in the array $sites will override the default + * directory rules below. See sites/example.sites.php for more information about + * aliases. + * + * The configuration directory will be discovered by stripping the website's + * hostname from left to right and pathname from right to left. The first + * configuration file found will be used and any others will be ignored. If no + * other configuration file is found then the default configuration file at + * 'sites/default' will be used. + * + * For example, for a fictitious site installed at + * http://www.drupal.org:8080/mysite/test/, the 'settings.php' file is searched + * for in the following directories: + * + * - sites/8080.www.drupal.org.mysite.test + * - sites/www.drupal.org.mysite.test + * - sites/drupal.org.mysite.test + * - sites/org.mysite.test + * + * - sites/8080.www.drupal.org.mysite + * - sites/www.drupal.org.mysite + * - sites/drupal.org.mysite + * - sites/org.mysite + * + * - sites/8080.www.drupal.org + * - sites/www.drupal.org + * - sites/drupal.org + * - sites/org + * + * - sites/default + * + * Note that if you are installing on a non-standard port number, prefix the + * hostname with that number. For example, + * http://www.drupal.org:8080/mysite/test/ could be loaded from + * sites/8080.www.drupal.org.mysite.test/. + * + * @see example.sites.php + * @see conf_path() + */ + +/** + * Database settings: + * + * The $databases array specifies the database connection or + * connections that Drupal may use. Drupal is able to connect + * to multiple databases, including multiple types of databases, + * during the same request. + * + * Each database connection is specified as an array of settings, + * similar to the following: + * @code + * array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Some database engines support transactions. In order to enable + * transaction support for a given database, set the 'transactions' key + * to TRUE. To disable it, set it to FALSE. Note that the default value + * varies by driver. For MySQL, the default is FALSE since MyISAM tables + * do not support transactions. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array(); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/ini.list.php + * See drupal_environment_initialize() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['site_name'] = 'My Drupal site'; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'; + +/** + * By default the page request process will return a fast 404 page for missing + * files if they match the regular expression set in '404_fast_paths' and not + * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in + * the Drupal system log. + * + * You can choose to return a fast 404 page earlier for missing pages (as soon + * as settings.php is loaded) by uncommenting the line below. This speeds up + * server response time when loading 404 error pages and prevents the 404 error + * from being logged in the Drupal system log. In order to prevent valid pages + * such as image styles and other generated content that may match the + * '404_fast_html' regular expression from returning 404 errors, it is necessary + * to add them to the '404_fast_paths_exclude' regular expression above. Make + * sure that you understand the effects of this feature before uncommenting the + * line below. + */ +# drupal_fast_404(); + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $conf['proxy_server'] = ''; +# $conf['proxy_port'] = 8080; +# $conf['proxy_username'] = ''; +# $conf['proxy_password'] = ''; +# $conf['proxy_user_agent'] = ''; +# $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; diff --git a/clientgerrit/root/config/gerrit.config b/clientgerrit/root/config/gerrit.config new file mode 100755 index 0000000..cc601eb --- /dev/null +++ b/clientgerrit/root/config/gerrit.config @@ -0,0 +1,48 @@ +[gerrit] + basePath = git + canonicalWebUrl = http://127.0.0.1/gerrit +[plugins] + allowRemoteAdmin = true +[index] + type = LUCENE +[auth] + type = LDAP +[sendemail] + smtpServer = + smtpUser = + from = + threadPoolSize = 2 +[container] + user = gerrit + javaHome = /usr/lib/jvm/java-1.7.0_60-oracle-x64/jre +[sshd] + listenAddress = *:29418 +[httpd] + listenUrl = proxy-http://127.0.0.1:8081/gerrit +[cache] + directory = cache +[gitweb] + cgi = /usr/share/gitweb/gitweb.cgi +[database] + type = mysql + hostname = localhost + port = 3306 + database = reviewdb + username = gerrit + password = gerritpassword +[ldap] + server = ldap://127.0.0.1 + username = cn=admin,dc=example,dc=com + password = opensuse + sslVerify = false + referral = follow + accountScope = subtree + accountBase = ou=people,dc=example,dc=com + accountPattern = (&(objectClass=inetOrgPerson)(uid=${username})) + accountFullName = displayName + accountEmailAddress = mail + + groupName = ${cn} + groupBase = ou=group,dc=example,dc=com + groupPattern = (&(objectClass=groupOfNames)(cn=${groupname})) + groupMemberPattern = (&(objectClass=groupOfNames)(member=${member})) diff --git a/clientgerrit/root/config/settings.php b/clientgerrit/root/config/settings.php new file mode 100755 index 0000000..580cc38 --- /dev/null +++ b/clientgerrit/root/config/settings.php @@ -0,0 +1,553 @@ +<?php + +/** + * @file + * Drupal site-specific configuration file. + * + * IMPORTANT NOTE: + * This file may have been set to read-only by the Drupal installation program. + * If you make changes to this file, be sure to protect it again after making + * your modifications. Failure to remove write permissions to this file is a + * security risk. + * + * The configuration file to be loaded is based upon the rules below. However + * if the multisite aliasing file named sites/sites.php is present, it will be + * loaded, and the aliases in the array $sites will override the default + * directory rules below. See sites/example.sites.php for more information about + * aliases. + * + * The configuration directory will be discovered by stripping the website's + * hostname from left to right and pathname from right to left. The first + * configuration file found will be used and any others will be ignored. If no + * other configuration file is found then the default configuration file at + * 'sites/default' will be used. + * + * For example, for a fictitious site installed at + * http://www.drupal.org:8080/mysite/test/, the 'settings.php' file is searched + * for in the following directories: + * + * - sites/8080.www.drupal.org.mysite.test + * - sites/www.drupal.org.mysite.test + * - sites/drupal.org.mysite.test + * - sites/org.mysite.test + * + * - sites/8080.www.drupal.org.mysite + * - sites/www.drupal.org.mysite + * - sites/drupal.org.mysite + * - sites/org.mysite + * + * - sites/8080.www.drupal.org + * - sites/www.drupal.org + * - sites/drupal.org + * - sites/org + * + * - sites/default + * + * Note that if you are installing on a non-standard port number, prefix the + * hostname with that number. For example, + * http://www.drupal.org:8080/mysite/test/ could be loaded from + * sites/8080.www.drupal.org.mysite.test/. + * + * @see example.sites.php + * @see conf_path() + */ + +/** + * Database settings: + * + * The $databases array specifies the database connection or + * connections that Drupal may use. Drupal is able to connect + * to multiple databases, including multiple types of databases, + * during the same request. + * + * Each database connection is specified as an array of settings, + * similar to the following: + * @code + * array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Some database engines support transactions. In order to enable + * transaction support for a given database, set the 'transactions' key + * to TRUE. To disable it, set it to FALSE. Note that the default value + * varies by driver. For MySQL, the default is FALSE since MyISAM tables + * do not support transactions. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array(); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/ini.list.php + * See drupal_environment_initialize() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['site_name'] = 'My Drupal site'; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'; + +/** + * By default the page request process will return a fast 404 page for missing + * files if they match the regular expression set in '404_fast_paths' and not + * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in + * the Drupal system log. + * + * You can choose to return a fast 404 page earlier for missing pages (as soon + * as settings.php is loaded) by uncommenting the line below. This speeds up + * server response time when loading 404 error pages and prevents the 404 error + * from being logged in the Drupal system log. In order to prevent valid pages + * such as image styles and other generated content that may match the + * '404_fast_html' regular expression from returning 404 errors, it is necessary + * to add them to the '404_fast_paths_exclude' regular expression above. Make + * sure that you understand the effects of this feature before uncommenting the + * line below. + */ +# drupal_fast_404(); + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $conf['proxy_server'] = ''; +# $conf['proxy_port'] = 8080; +# $conf['proxy_username'] = ''; +# $conf['proxy_password'] = ''; +# $conf['proxy_user_agent'] = ''; +# $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; diff --git a/devgerrit/COPYING b/devgerrit/COPYING new file mode 100755 index 0000000..e06d208 --- /dev/null +++ b/devgerrit/COPYING @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/devgerrit/Dockerfile b/devgerrit/Dockerfile new file mode 100755 index 0000000..5fca45a --- /dev/null +++ b/devgerrit/Dockerfile @@ -0,0 +1,163 @@ +#=============================================================================== +# This file is designed for Tizen infrastructure. +# Author onstudy@samsung.com +#=============================================================================== +FROM ubuntu:14.04 +MAINTAINER onstudy@samsung.com + +RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" >> /etc/apt/sources.list + +#### If you are use the proxy in your enviroment, add below line on building.#### +#ENV ftp_proxy ftp://<ip> +#ENV http_proxy http://<ip> +#ENV https_proxy https://<ip> +#ENV socks_proxy socks://<ip> + + +#### UPDATE #### +RUN apt-get -y update +RUN apt-get install -y vim tar wget telnet supervisor sudo + +#### INSTALL SLAPD #### +RUN apt-get install -y slapd ldap-utils phpldapadmin + +#### INSTALL APACHE2 #### +RUN apt-get install -y php5-mysql php5-gd libapache2-mod-php5 mysql-server +RUN apt-get install -y apache2 apache2-utils php5 php5-ldap phpldapadmin php5-mcrypt libapache2-mod-proxy-html +RUN sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/g' /etc/php5/apache2/php.ini +ENV APACHE_RUN_USER www-data +ENV APACHE_RUN_GROUP www-data +ENV APACHE_LOG_DIR /var/log/apache2 +ENV APACHE_PID_FILE /var/run/apache2.pid +ENV APACHE_RUN_DIR /var/run/apache2 +ENV APACHE_LOCK_DIR /var/lock/apache2 + +RUN a2enmod rewrite \ + && a2enmod proxy \ + && a2enmod proxy_connect \ + && a2enmod proxy_ftp \ + && a2enmod proxy_http + +#### INSTALL GIT #### +RUN apt-get install -y git-core git-review openssh-server + +#### DOWNLOAD DRUPAL #### +# Create needed directories +ENV HTDOCS_DIR /var/www/html + +RUN wget http://ftp.drupal.org/files/projects/drupal-7.28.tar.gz \ + && tar -xzf drupal-7.28.tar.gz \ + && rm drupal-7.28.tar.gz \ + && mv drupal-7.28 ${HTDOCS_DIR}/drupal \ + && mkdir -p ${HTDOCS_DIR}/drupal/sites/default/files/ \ + && chmod o+w ${HTDOCS_DIR}/drupal/sites/default/files/ \ + && chown -R ${APACHE_RUN_USER}:${APACHE_RUN_USER} ${HTDOCS_DIR}/drupal/sites/default/files/ + +#### LDAP MODULES #### +ENV MODULES_DIR ${HTDOCS_DIR}/drupal/sites/all/modules + +#### DOWNLOAD SIMPLE LDAP MODULES #### +RUN wget http://ftp.drupal.org/files/projects/simple_ldap-7.x-1.4.tar.gz \ + && tar -xzf simple_ldap-7.x-1.4.tar.gz \ + && rm simple_ldap-7.x-1.4.tar.gz \ + && mv simple_ldap ${MODULES_DIR}/simple_ldap \ + && chown -R ${APACHE_RUN_USER}:${APACHE_RUN_USER} ${MODULES_DIR}/simple_ldap/ + +#### DOWNLOAD CTOOLS MODULES #### +RUN wget http://ftp.drupal.org/files/projects/ctools-7.x-1.5.tar.gz \ + && tar -xzf ctools-7.x-1.5.tar.gz \ + && rm ctools-7.x-1.5.tar.gz \ + && mv ctools ${MODULES_DIR}/ctools \ + && chown -R ${APACHE_RUN_USER}:${APACHE_RUN_USER} ${MODULES_DIR}/ctools/ + +#### DOWNLOAD VIEWS MODULES #### +RUN wget http://ftp.drupal.org/files/projects/views-7.x-3.8.tar.gz \ + && tar -xzf views-7.x-3.8.tar.gz \ + && rm views-7.x-3.8.tar.gz \ + && mv views ${MODULES_DIR}/views \ + && chown -R ${APACHE_RUN_USER}:${APACHE_RUN_USER} ${MODULES_DIR}/views/ + +#### FIX DRUPAL ERROR #### +ADD drupal/${HTDOCS_DIR}/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.api.php ${HTDOCS_DIR}/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.api.php +ADD drupal/${HTDOCS_DIR}/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.module ${HTDOCS_DIR}/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.module + + +#### INSTALL ORACLE JAVA 7 SDK #### +ENV JVM_DIR /usr/lib/jvm +RUN mkdir -p "${JVM_DIR}" + +ENV DOWNLOAD_DIR /tmp/downloads +RUN mkdir -p "${DOWNLOAD_DIR}" + +RUN wget -q --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" -O "${DOWNLOAD_DIR}/jdk-7u60-linux-x64.tar.gz" "http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-linux-x64.tar.gz" + +RUN tar -xzf "${DOWNLOAD_DIR}/jdk-7u60-linux-x64.tar.gz" +RUN rm -f "${DOWNLOAD_DIR}/jdk-7u60-linux-x64.tar.gz" +RUN mv "jdk1.7.0_60" "${JVM_DIR}/java-1.7.0_60-oracle-x64" +RUN ln -s "${JVM_DIR}/java-1.7.0_60-oracle-x64" "${JVM_DIR}/java-1.7.0-oracle-x64" + +ADD ./jdk/java-1.7.0-oracle-x64.jinfo ${JVM_DIR}/.java-1.7.0-oracle-x64.jinfo +RUN cat "${JVM_DIR}/.java-1.7.0-oracle-x64.jinfo" | grep -E '^(jre|jdk|hl)' | awk '{print "/usr/bin/" $2 " " $2 " " $3 " 30 \n"}' | xargs -t -n4 update-alternatives --install +ENV JAVA_HOME ${JVM_DIR}/java-1.7.0-oracle-x64 + +#### DOWNLOAD GERRIT #### +ENV GERRIT_HOME /home/gerrit +ENV GERRIT_CONFIG_PATH /home/gerrit/gerrit/etc/gerrit.config +ENV GERRIT_USER gerrit +ENV GERRIT_WAR /home/gerrit/gerrit.war + +RUN useradd -ms /bin/bash ${GERRIT_USER} \ + && usermod -aG root ${GERRIT_USER} \ + && wget http://gerrit-releases.storage.googleapis.com/gerrit-2.9.4.war -O /tmp/gerrit.war \ + && mkdir -p $GERRIT_HOME/gerrit \ + && mv /tmp/gerrit.war $GERRIT_WAR \ + && chmod 755 $GERRIT_WAR \ + && chown -R ${GERRIT_USER}:${GERRIT_USER} $GERRIT_HOME + +USER gerrit +RUN java -jar $GERRIT_WAR init --batch -d $GERRIT_HOME/gerrit +USER root + +RUN wget http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar -O $GERRIT_HOME/gerrit/lib/mysql-connector-java-5.1.21.jar \ + && wget http://www.bouncycastle.org/download/bcpkix-jdk15on-149.jar -O $GERRIT_HOME/gerrit/lib/bcpkix-jdk15on-149.jar \ + && wget http://www.bouncycastle.org/download/bcprov-jdk15on-149.jar -O $GERRIT_HOME/gerrit/lib/bcprov-jdk15on-149.jar + +ADD ./gerrit/plugins/ $GERRIT_HOME/gerrit/plugins/ + +#### FIX APACHE2 #### +#gerrit virtualhost 80 port +RUN rm /etc/apache2/sites-enabled/000-default.conf + +#### FIX PHPLDAPADMIN #### +#PhpLdapAdmin password error with PHP 5 +ADD ./phpldapadmin/usr/share/phpldapadmin/lib/TemplateRender.php /usr/share/phpldapadmin/lib/TemplateRender.php + +#### BACKUP GERRIT #### +RUN mv /home/gerrit/gerrit /home/gerrit/backup \ + && rm -rf /home/gerrit/gerrit + +#### BACKUP PHPLDAPADMIN #### +RUN cp -rf /etc/phpldapadmin /etc/phpldapadmin_backup + +#### BACKUP DRUPAL SETTING #### +RUN cp -rf ${HTDOCS_DIR}/drupal/sites/default ${HTDOCS_DIR}/drupal/sites/default_backup + +#### START SCRIPT #### +ADD ./script/phpldapadmin.sh /srv/script/phpldapadmin.sh +ADD ./script/gerrit.sh /srv/script/gerrit.sh +ADD ./script/drupal.sh /srv/script/drupal.sh +ADD ./script/initdb.sh /srv/script/initdb.sh +ADD ./script/slapd.sh /srv/script/slapd.sh +ADD ./script/startup.sh /srv/script/startup.sh +RUN chmod +x /srv/script/* + +ADD ./supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Set environment variables. +ENV HOME /root +ENV TERM xterm + +WORKDIR /srv/script +EXPOSE 80 389 29418 +VOLUME ["/etc/ldap", "/var/lib/ldap", "/run/slapd"] +CMD ["/bin/bash","/srv/script/startup.sh"] diff --git a/devgerrit/README b/devgerrit/README new file mode 100755 index 0000000..73d1d10 --- /dev/null +++ b/devgerrit/README @@ -0,0 +1,14 @@ +license : https://gerrit.googlecode.com/svn/documentation/2.1/licenses.html + Apache License 2.0 + Common Development and Distribution License (CDDL) + Apache SSHD - Notice + PostgreSQL JDBC Driver - New Style BSD + H2 Database - EPL or modified MPL + ObjectWeb ASM - New Style BSD + ANTLR - New Style BSD + JGit - New Style BSD + args4j - MIT License + SLF4J - MIT License + Clippy - MIT License + ICU4J License +Ref : https://wiki.tizen.org/wiki/Setup_of_Tizen_Infrastructure_with_Docker diff --git a/devgerrit/config.conf b/devgerrit/config.conf new file mode 100755 index 0000000..e9e0fce --- /dev/null +++ b/devgerrit/config.conf @@ -0,0 +1,58 @@ +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +### Image name +export IMAGES="tizendocker:443/gerritdrupalldap" + +### Repository name (and optionally a tag) to be applied to the resulting image in case of success +export TAG="2.9.4.0.2" + +### Assign a name to the container +export CONTAINER="gerritdrupalldap" + +### Publish a container's port to the host +### format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort +export PORTS="80 389 29418" + +### Read in a line delimited file of environment variables +export ENVLIST="$(pwd)/env/env.list" + +### Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container) +export VOLUMES="/home/gerritdrupalldap/var/lib/ldap/:/var/lib/ldap/ + /home/gerritdrupalldap/etc/ldap/slapd.d/:/etc/ldap/slapd.d/ + /home/gerritdrupalldap/var/lib/mysql:/var/lib/mysql/ + /home/gerritdrupalldap/var/www/html/drupal/sites/default/:/var/www/html/drupal/sites/default/ + /home/gerritdrupalldap/home/gerrit/gerrit/:/home/gerrit/gerrit/ + $(pwd)/root/config/:/config/ + " + +### Container host name +export HOSTNAME="GerritDrupalLdap" + +### Give extended privileges to this container +export PRIVILEGED=no + +### Restart policy to apply when a container exits (no, on-failure[:max-retry], always) +export AUTOSTART=always + +### Add link to another container in the form of name:alias +export LINK_IMAGES="" + +### Mount volumes from the specified container(s) +export VOLUMES_IMAGES="" + +### Add a custom host-to-IP mapping (host:ip) +export ADD_HOSTS="" + +### Add Linux capabilities +export CAP_ADD="" diff --git a/devgerrit/dgerrit.sh b/devgerrit/dgerrit.sh new file mode 100755 index 0000000..9d480ec --- /dev/null +++ b/devgerrit/dgerrit.sh @@ -0,0 +1,456 @@ +#! /bin/sh +#=============================================================================== +# Tizen gerrit+drupal+openldap +# 01/17 2015 +# +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== + +home="$( cd "$( dirname "$0" )" && pwd )" +. $home/config.conf + +set -e +#------------------------------------------------------------------------------- +images=$IMAGES:$TAG +container=$CONTAINER + +echo "IMAGES:"$images +echo "CONTAINER:"$container + +if [ ! -z "$PORTS" ] +then + for I in $PORTS; do + service_port=$I + if [ ! -z $(echo "$service_port" | grep ':') ] + then + if [ -z "$ports_cmd" ] + then + ports_cmd=$(echo "-p ${service_port} ") + else + ports_cmd=$(echo $ports_cmd"-p ${service_port} ") + fi + elif [ ! -z $(echo "$service_port" | grep '-') ] + then + d1=$(echo $service_port | cut -d '-' -f1) + d2=$(echo $service_port | cut -d '-' -f2) + instance=$((d2 - d1 + 1)) + #echo "instance:"$instance + count=0 + while [ $count -lt $instance ]; do + expose_port=$((d1 + count)) + if [ -z "$ports_cmd" ] + then + ports_cmd=$(echo "-p ${expose_port}:${expose_port} ") + else + ports_cmd=$(echo $ports_cmd"-p ${expose_port}:${expose_port} ") + fi + count=`expr $count + 1` + done + else + if [ -z "$ports_cmd" ] + then + ports_cmd=$(echo "-p ${service_port}:${service_port} ") + else + ports_cmd=$(echo $ports_cmd"-p ${service_port}:${service_port} ") + fi + fi + done +fi +echo "PORT:"$ports_cmd + +if [ ! -z "$ENVLIST" ] +then + envlist_cmd=$(echo "--env-file $ENVLIST") +fi +echo "ENV LIST:"$envlist_cmd + +if [ ! -z "$VOLUMES" ] +then + for vol in $VOLUMES; do + if [ -z "$volumes_cmd" ] + then + volumes_cmd=$(echo "-v /etc/localtime:/etc/localtime:ro -v $vol ") + else + volumes_cmd=$(echo $volumes_cmd "-v $vol ") + fi + done +fi +echo "VOLUMES:"$volumes_cmd +if [ ! -z "$HOSTNAME" ] +then + hostname_cmd=$(echo "-h $HOSTNAME") +fi +echo "HOST NAME:"$hostname_cmd + +if [ "$PRIVILEGED" = 'yes' ] +then + privileged_cmd=$(echo "--privileged") +fi +echo "PRIVILEGED:"$privileged_cmd + +if [ "$AUTOSTART" = 'always' ] +then + autostart_cmd=$(echo "--restart=always") +elif [ "$AUTOSTART" = 'on-failure^' ] +then + autostart_cmd=$(echo "--restart=on-failure:10") +fi +echo "AUTOSTART:"$autostart_cmd + +if [ ! -z "$LINK_IMAGES" ] +then + for link in $LINK_IMAGES; do + if [ -z "$links_cmd" ] + then + links_cmd=$(echo "--link $link ") + else + links_cmd=$(echo $links_cmd "--link $link ") + fi + done +fi +echo "LINKS:"$links_cmd + +if [ ! -z "$VOLUMES_IMAGES" ] +then + for volumes_images in $VOLUMES_IMAGES; do + if [ -z "$volumes_images_cmd" ] + then + volumes_images_cmd=$(echo "--volumes-from $volumes_images ") + else + volumes_images_cmd=$(echo $volumes_images_cmd "--volumes-from $volumes_images ") + fi + done +fi +echo "VOLUMES-FROM:"$volumes_images_cmd + +if [ ! -z "$ADD_HOSTS" ] +then + for hostserver in $ADD_HOSTS; do + if [ -z "$add_hosts_cmd" ] + then + add_hosts_cmd=$(echo "--add-host=$hostserver ") + else + add_hosts_cmd=$(echo $add_hosts_cmd "--add-host=$hostserver ") + fi + done +fi +echo "ADD_HOST:"$add_hosts_cmd + +if [ ! -z "$CAP_ADD" ] +then + for capadd in $CAP_ADD; do + if [ -z "$capadds_cmd" ] + then + capadds_cmd=$(echo "--cap-add=$capadd ") + else + capadds_cmd=$(echo $capadds_cmd "--cap-add=$capadd ") + fi + done +fi +echo "CAP_ADD:"$capadds_cmd + +#------------------------------------------------------------------------------- +install_docker(){ + echo "Install lxc-docker-1.4.1" + + if [ $(lsb_release -a | sed -n '/Description/p' | grep -c "Ubuntu 14.04") -eq 1 ]; + then + echo "Ubuntu 14.04" + if [ $(dpkg-query -W -f='${Status}' lxc-docker-1.4.1 2>/dev/null | grep -c "ok installed") -eq 0 ]; + then + echo "sudo get -qO- https://get.docker.io/gpg" | sh || true + echo "sudo apt-key add -" | sh || true + echo "sudo sh -c "'"echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"' | sh || true + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y lxc-docker-1.4.1" | sh || true + else + echo $(docker --version) + fi + elif [ $(lsb_release -a | sed -n '/Description/p' | grep -c "Ubuntu 12.04") -eq 1 ]; + then + echo "Ubuntu 12.04" + if [ $(dpkg-query -W -f='${Status}' lxc-docker-1.4.1 2>/dev/null | grep -c "ok installed") -eq 0 ]; + then + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y linux-image-generic-lts-raring linux-headers-generic-lts-raring" | sh || true + echo "sudo apt-get install --install-recommends linux-generic-lts-raring xserver-xorg-lts-raring libgl1-mesa-glx-lts-raring" | sh || true + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y apt-transport-https" | sh || true + + echo "sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9" | sh || true + echo "sudo sh -c "'"echo deb https://get.docker.com/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"' | sh || true + echo "sudo apt-get update" | sh || true + echo "sudo apt-get install -y lxc-docker-1.4.1" | sh || true + else + echo $(docker --version) + fi + else + echo "It does not install lxc-docker-1.4.1" + fi + +} +#------------------------------------------------------------------------------- +attach(){ + echo "Attaching docker containers:" + docker exec -it $container script /dev/null -c /bin/bash || true +} +#------------------------------------------------------------------------------- +status(){ + echo "Status docker containers:" + docker ps | grep "$container" || true +} +#------------------------------------------------------------------------------- +build(){ + echo "Build docker images:"$imags + #### Add proxy on Dockerfile #### + if [ ! $(env | grep -c "proxy") -eq 0 ]; + then + PROXYS=$(env | grep "proxy" ) + echo "Enabled Proxy\n"$PROXYS + for proxy in $PROXYS; do + name=$(echo $proxy | sed 's/\=/ /g' | awk '{print $1}') + ip=$(echo $proxy | sed 's/\=/ /g' | awk '{print $2}' | sed 's/,/\\,/g') + sed -i 's,^#ENV '"$name"'.*,ENV '"$name $ip"',' Dockerfile + done + fi + + docker build --rm -t $images . +} +#------------------------------------------------------------------------------- +rebuild(){ + echo "Rebuild docker images:" + docker build --no-cache --rm -t $images . +} +#------------------------------------------------------------------------------- +stop(){ + echo "Stopping docker containers:" + docker stop $container || true + docker ps | grep "$container" || true +} +#------------------------------------------------------------------------------- +start(){ + echo "Starting ${container}:" + echo " docker run -d --name $container \ + $hostname_cmd \ + $privileged_cmd \ + $links_cmd \ + $ports_cmd \ + $envlist_cmd \ + $volumes_cmd \ + $volumes_images_cmd \ + $add_hosts_cmd \ + $capadds_cmd \ + $images + " + if [ ! -z "$links_cmd" ] + then + for link in $LINK_IMAGES; do + link_sh=$(echo "$link" | cut -d ':' -f1) + if [ -z "$(docker ps | grep "$link_sh" | awk '{print $NF}')" ] + then + echo "Please you must be run the" "$link_sh"" before the" "$container" + exit + fi + done + fi + for run_container in $(docker ps -a | grep "$container" | awk '{print $NF}'); do + if [ "$run_container" = "$container" ]; + then + docker start $container + docker ps | grep "$container" || true + exit + fi + done + docker run -d --name $container \ + $hostname_cmd \ + $privileged_cmd \ + $links_cmd \ + $ports_cmd \ + $envlist_cmd \ + $volumes_cmd \ + $volumes_images_cmd \ + $add_hosts_cmd \ + $capadds_cmd \ + $images + + docker ps | grep "$container" || true +} + +#------------------------------------------------------------------------------- +kill(){ + echo "Killing docker containers:" + docker kill $container || true +} +#------------------------------------------------------------------------------- +rm(){ + echo "Removing stopped containers:" + docker rm $container || true +} +#------------------------------------------------------------------------------- +rmi(){ + echo "Removing all untagged images:" + docker images | grep "^<none>" | awk '{print "docker rmi "$3}' | sh +} +#------------------------------------------------------------------------------- +logs(){ + echo "Show logs of a container" + docker logs $container || true +} +#------------------------------------------------------------------------------- +cp(){ + echo "Copy files/folders from a container's filesystem" + echo "docker cp $container:$1 $2 || true" + docker cp $container:$1 $2 || true +} +#------------------------------------------------------------------------------- +pull(){ + echo "Pull an image or a repository from a Docker registry server" + docker pull $images || true +} +#------------------------------------------------------------------------------- +push(){ + echo "Push an image or a repository to a Docker registry server" + docker push $images || true +} +#------------------------------------------------------------------------------- +inspect(){ + echo "Return low-level information on a containe" + docker inspect $container || true +} +#------------------------------------------------------------------------------- +top(){ + echo "Lookup the running processes of a container" + docker top $container || true +} +#------------------------------------------------------------------------------- +save(){ + echo "Save an image to a tar archive" + docker save -o $container"-"$TAG"-docker-image.tar.gz" $images || true + echo $(pwd | awk -F '/' '{print $NF}') + tar cvfzp ../$container"-"$TAG"-docker-script.tar.gz" ../$(pwd | awk -F '/' '{print $NF}') + echo "Save $container-$TAG" +} +#------------------------------------------------------------------------------- +load(){ + echo "Load an image from a tar archive" + docker load -i $container"-"$TAG"-docker-image.tar.gz" || true + echo "Load $container-$TAG" +} +#------------------------------------------------------------------------------- +help(){ + echo "help" + usage +} +#------------------------------------------------------------------------------- +usage (){ + echo "USAGE: $0" COMMAND + + echo -e "\nCommands:" + echo " install Install lxc-docker-1.4.1" + echo " start Start a stopped container" + echo " attach Attach to a running container" + echo " build Build an image from a Dockerfile" + echo " stop Stop a running container" + echo " status Status a running container" + echo " rm Remove this containers" + echo " rmi Remove all <none> images" + echo " restart stop, start a container" + echo " rebuild Rebuild with no-cache options" + echo " kill Kill a running container" + echo " logs Fetch the logs of a container" + echo " cp Copy files/folders from a container's filesystem to the host path" + echo " pull Pull an image or a repository from a Docker registry server" + echo " push Push an image or a repository to a Docker registry server" + echo " inspect Return low-level information on a containe" + echo " top Lookup the running processes of a container" + echo " save Save an image to a tar archive" + echo " load Load an image from a tar archive" + echo " help help" + exit 1 +} +#------------------------------------------------------------------------------- +if [ $# -eq 0 ] +then + usage +fi + +#------------------------------------------------------------------------------- +case "$1" in + install) + install_docker + ;; + start) + start + ;; + attach) + attach + ;; + status) + status + ;; + stop) + stop + ;; + restart) + stop + start + ;; + build) + build + ;; + rebuild) + rebuild + ;; + kill) + kill + rm + ;; + rm) + rm + ;; + rmi) + rmi + ;; + logs) + logs + ;; + cp) + cp $2 $3 + ;; + pull) + pull + ;; + push) + push + ;; + inspect) + inspect + ;; + top) + top + ;; + save) + save + ;; + load) + load + ;; + help) + help + ;; + *) + usage + ;; +esac +#=============================================================================== + diff --git a/devgerrit/drupal/var/www/html/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.api.php b/devgerrit/drupal/var/www/html/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.api.php new file mode 100755 index 0000000..6699db9 --- /dev/null +++ b/devgerrit/drupal/var/www/html/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.api.php @@ -0,0 +1,94 @@ +<?php +/** + * @file + * Describe hooks provided by the Simple LDAP User module. + */ + +/** + * SimpleLdapUser fingerprint. + * + * Variables exposed by __get() and __set() + * ---------------------------------------- + * $attributes + * $dn + * $exists + * $server + * + * Magic methods + * ------------- + * __construct($name) + * __get($name) + * __set($name, $value) + * + * Public functions + * ---------------- + * authenticate($password) + * save() + * delete() + * + * Public static methods + * --------------------- + * singleton($name) + * filter() + * reset() + * hash($key, $value) + */ + +/** + * simple_ldap_user helper functions. + * + * simple_ldap_user_load_or_create_by_name($name) + * simple_ldap_user_login_name_validate($form, &$form_state) + * simple_ldap_user_sync_user_to_ldap($drupal_user) + * simple_ldap_user_sync_user_to_drupal($drupal_user) + * simple_ldap_user_variable_get($varuable) + */ + +/** + * Synchronizes a Drupal user to LDAP. + * + * This hook is called when simple_ldap_user needs to synchronize Drupal user + * data to LDAP. + * + * This example sets the LDAP employeeType attribute to "full-time" + * + * @param StdClass $user + * The full Drupal user object that is being synchronized. + */ +function hook_sync_user_to_ldap($user) { + $ldap_user = SimpleLdapUser::singleton($user->name); + $ldap_user->employeeType = 'full-time'; + $ldap_user->save(); +} + +/** + * Alter user data before saving to Drupal. + * + * This hook is called when simple_ldap_user is doing an account synchronization + * from LDAP to Drupal, immediately before user_save() is called. + * + * @param array $edit + * Array of changes to apply to the Drupal user by user_save(). + * @param StdClass $drupal_user + * The Drupal user object to be saved. + * @param SimpleLdapUser $ldap_user + * The SimpleLdapUser object that matches the Drupal user object. + */ +function hook_simple_ldap_user_to_drupal_alter($edit, $drupal_user, $ldap_user) { + $ldap_user->cn = $ldap_user->uid; + $ldap_user->sn = $ldap_user->uid; +} + +/** + * Alter user data before saving to LDAP. + * + * This hook is called when simple_ldap_user is doing an account synchronization + * from Drupal to LDAP, immediately before SimpleLdapUser::save() is called. + * + * @param SimpleLdapUser $ldap_user + * The SimpleLdapUser object to be saved. + * @param StdClass $drupal_user + * The Drupal user object that matches the SimpleLdapUser object. + */ +function hook_simple_ldap_user_to_ldap_alter($ldap_user, $drupal_user) { +} diff --git a/devgerrit/drupal/var/www/html/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.module b/devgerrit/drupal/var/www/html/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.module new file mode 100755 index 0000000..fbb3fc7 --- /dev/null +++ b/devgerrit/drupal/var/www/html/drupal/sites/all/modules/simple_ldap/simple_ldap_user/simple_ldap_user.module @@ -0,0 +1,740 @@ +<?php +/** + * @file + * Main simple_ldap_user module file. + */ + +/** + * Implements hook_menu(). + */ +function simple_ldap_user_menu() { + $items = array(); + + $items['admin/config/people/simple_ldap/user'] = array( + 'title' => 'Users', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('simple_ldap_user_admin'), + 'access arguments' => array('administer site configuration'), + 'file' => 'simple_ldap_user.admin.inc', + 'type' => MENU_LOCAL_TASK, + 'weight' => 1, + ); + + $items['admin/people/simple_ldap_user_import'] = array( + 'title' => 'Import from LDAP', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('simple_ldap_user_import'), + 'access arguments' => array('administer users'), + 'file' => 'simple_ldap_user.admin.inc', + 'type' => MENU_LOCAL_ACTION, + ); + + return $items; +} + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Overrides the built-in user module's list of users, setting accounts to + * "blocked" if there is no matching LDAP account. + */ +function simple_ldap_user_form_user_admin_account_alter(&$form, &$form_state, $form_id) { + // Update the user array. + foreach ($form['accounts']['#options'] as $uid => $user) { + + // Don't mess with user/1. + if ($uid == 1) { + continue; + } + + // Verify active users. Blocked users may be provisioned to LDAP when they + // are set to active, so they are left alone here. + if ($user['status'] == 'active') { + // Load the user objects. + $drupal_user = user_load($uid); + $ldap_user = SimpleLdapUser::singleton($drupal_user->name); + + // Check whether the user exists in LDAP. + if (!$ldap_user->exists) { + $form['accounts']['#options'][$uid]['status'] = 'blocked'; + } + + // Check whether the user is disabled (Active Directory only). + // http://support.microsoft.com/kb/305144 + if ($ldap_user->server->type == 'Active Directory') { + if (isset($ldap_user->useraccountcontrol[0]) && (int) $ldap_user->useraccountcontrol[0] & 2) { + $form['accounts']['#options'][$uid]['status'] = 'blocked'; + } + } + + } + } +} + +/** + * Implements hook_entity_info_alter(). + * + * Specifies that SimpleLdapuserController should be used to load users instead + * of the default controller. + */ +function simple_ldap_user_entity_info_alter(&$entity_info) { + if (isset($entity_info['user'])) { + // Use the SimpleLdapUserController class to manage users. + $entity_info['user']['controller class'] = 'SimpleLdapUserController'; + } +} + +/** + * Implements hook_form_alter(). + */ +function simple_ldap_user_form_alter(&$form, &$form_state, $form_id) { + switch ($form_id) { + case 'user_login_block': + // Remove the register and password reminder links. + $server = SimpleLdapServer::singleton(); + if ($server->readonly) { + unset($form['links']); + } + case 'user_login': + case 'user_pass': + // Insert simple_ldap_user's username validation. + array_unshift($form['#validate'], 'simple_ldap_user_login_name_validate'); + break; + + case 'user_profile_form': + // Disable mapped fields if LDAP Server is read-only. + $server = SimpleLdapServer::singleton(); + $attribute_map = simple_ldap_user_variable_get('simple_ldap_user_attribute_map'); + + // Name, Mail, and Password are special attributes. + $form['account']['name']['#disabled'] = $server->readonly; + $form['account']['mail']['#disabled'] = $server->readonly; + $form['account']['pass']['#disabled'] = $server->readonly; + + // Active Directory has some additional restrictions. + if ($server->type == 'Active Directory') { + $form['account']['name']['#disabled'] = TRUE; + $form['account']['pass']['#disabled'] = stripos($server->host, 'ldaps://') === FALSE; + } + + // Other mapped fields. + foreach ($attribute_map as $attribute) { + foreach ($attribute['drupal'] as $drupal_attribute) { + $type = substr($drupal_attribute, 0, 1); + switch ($type) { + case '#': + // Use Field API. + $form[substr($drupal_attribute, 1)]['#disabled'] = $server->readonly; + break; + + default: + // Use the user object directly. + $form['account'][$drupal_attribute]['#disabled'] = $server->readonly; + } + } + } + break; + + default: + } +} + +/** + * Implements hook_menu_alter(). + * + * Disables the user register and password reminder pages if the LDAP server is + * read-only. + */ +function simple_ldap_user_menu_alter(&$items) { + $server = SimpleLdapServer::singleton(); + if ($server->readonly) { + $items['user/register']['access callback'] = FALSE; + $items['user/password']['access callback'] = FALSE; + } +} + +/** + * Implements hook_user_login(). + * + * Fires when a user logs in. + * + * @param array $edit + * The form values submitted by the user to log in, + * including raw username and password. + */ +function simple_ldap_user_user_login(&$edit, $account) { + if ($account->uid == 1) { + return; + } + $sync = simple_ldap_user_variable_get('simple_ldap_user_sync'); + if ($sync == 'hook_user_login') { + switch (simple_ldap_user_variable_get('simple_ldap_user_source')) { + case 'ldap': + simple_ldap_user_sync_user_to_drupal($account); + break; + + case 'drupal': + simple_ldap_user_sync_user_to_ldap($account); + break; + } + } +} + +/** + * Implements hook_user_presave(). + * + * Fires before an account is created or changed. + * + * @param array $edit + * The form values submitted by the user. + */ +function simple_ldap_user_user_presave(&$edit, $account, $category) { + // Do not overwrite the user status in the database. + if (isset($account->simple_ldap_user_drupal_status)) { + // If status is in the edit array, we need to be sure we're not + // unintentionally saving the LDAP value to the database. To check this, we + // see if $edit['status'] matches $account->status. If it does, set + // $edit['status'] to the simple_ldap_user_drupal_status value. + if (isset($edit['status']) && $edit['status'] == $account->status) { + $edit['status'] = $account->simple_ldap_user_drupal_status; + } + // Now set the $account->status back to the value in the database, just to + // be safe. This ensures that if $edit['status'] is empty, we don't mess up + // what's in the database with what is on the user object. + $account->status = $account->simple_ldap_user_drupal_status; + } + // To make sure we've covered all our bases, we also set $account->original's + // status back to what is in the database as well. + if (isset($account->original) && isset($account->original->simple_ldap_user_drupal_status)) { + $account->original->status = $account->simple_ldap_user_drupal_status; + } + + if ($account->is_new && isset($edit['name'])) { + $ldap_user = SimpleLdapUser::singleton($edit['name']); + + if ($ldap_user->exists) { + // Force an initial sync from LDAP to drupal. + $attribute_mail = simple_ldap_user_variable_get('simple_ldap_user_attribute_mail'); + $attribute_map = simple_ldap_user_variable_get('simple_ldap_user_attribute_map'); + + // Get the user's email address. + $edit['mail'] = $ldap_user->{$attribute_mail}[0]; + + // Get the remaining mapped attributes. + foreach ($attribute_map as $attribute) { + + // Skip drupal-to-ldap many-to-one mappings. + if (count($attribute['drupal']) > 1) { + break; + } + + // Get the field type. + $drupal_attribute = reset($attribute['drupal']); + $type = substr($drupal_attribute, 0, 1); + + switch ($type) { + // Use Field API. + case '#': + // Strip the type character from the attribute name. + $drupal_attribute = substr($drupal_attribute, 1); + + for ($i = 0; $i < $ldap_user->{$attribute['ldap']}['count']; $i++) { + $edit[$drupal_attribute][LANGUAGE_NONE][$i]['value'] = $ldap_user->{$attribute['ldap']}[$i]; + } + break; + + // Use the user object directly. + default: + $edit[$drupal_attribute] = $ldap_user->{$attribute['ldap']}[0]; + } + } + } + } +} + +/** + * Implements hook_user_insert(). + * + * Fires after a new account is created. + * + * @param array $edit + * The form values submitted by the user. + */ +function simple_ldap_user_user_insert(&$edit, $account, $category) { + $ldap_user = SimpleLdapUser::singleton($account->name); + if (!$ldap_user->exists) { + module_invoke_all('sync_user_to_ldap', $account); + } +} + +/** + * Implements hook_user_update(). + * + * Fires when a user account is edited. + * + * @param array $edit + * The form values submitted by the user. + */ +function simple_ldap_user_user_update(&$edit, $account, $category) { + // Don't do anything for uid 1. + if ($account->uid == 1) { + return; + } + + // Don't do anything if the hook was called via hook_sync_user_to_drupal(). + if (empty($account->hook_sync_user_to_drupal)) { + $ldap_user = SimpleLdapUser::singleton($account->name); + $enabled = isset($edit['status']) ? $edit['status'] : NULL; + // In hook_user_presave, we may have messed with the $edit['status'] and + // $account->status values, setting them to the database values, not what + // LDAP had set status to. Set those back to the LDAP values now. + if (isset($account->simple_ldap_user_ldap_status)) { + $enabled = $account->status = $account->simple_ldap_user_ldap_status; + } + if ($enabled || $ldap_user->exists) { + module_invoke_all('sync_user_to_ldap', $account); + } + } + else { + unset($account->hook_sync_user_to_drupal); + } +} + +/** + * Implements hook_user_delete(). + * + * Fires when a user account is deleted, before account is + * deleted. + * + * @throw SimpleLdapException + */ +function simple_ldap_user_user_delete($account) { + $ldap_user = SimpleLdapUser::singleton($account->name); + try { + $ldap_user->delete(); + } catch (SimpleLdapException $e) { + drupal_set_message(t('Failed to delete @name from LDAP.', array('@name' => $account->name)) . ' ' . t('Error @code: @message.', array('@code' => $e->getCode(), '@message' => $e->getMessage())), 'error', FALSE); + } +} + +/** + * Implements hook_user_load(). + * + * Fires when user information is being loaded from the database. + * User information is cached, so this does not fire every time + * a user object is handled. + */ +function simple_ldap_user_user_load($users) { + $sync = simple_ldap_user_variable_get('simple_ldap_user_sync'); + if ($sync == 'hook_user_load') { + foreach ($users as $user) { + if ($user->uid == 1) { + continue; + } + switch (simple_ldap_user_variable_get('simple_ldap_user_source')) { + case 'ldap': + simple_ldap_user_sync_user_to_drupal($user); + break; + + case 'drupal': + simple_ldap_user_sync_user_to_ldap($user); + break; + } + } + } +} + +/** + * Validate the username on a login or password reset form. + */ +function simple_ldap_user_login_name_validate($form, &$form_state) { + // Get the username from the form data. + $name = trim($form_state['values']['name']); + + simple_ldap_user_load_or_create_by_name($name); +} + +/** + * Create a valid LDAP user on this site if they don't already exist. + * + * @param string $name + * The username or email address to load. + * + * @return mixed + * The Drupal user object, or FALSE if the process failed. + */ +function simple_ldap_user_load_or_create_by_name($name) { + // Load the LDAP user with the given username. + $ldap_user = SimpleLdapUser::singleton($name); + + // If the user doesn't exist in LDAP, there is nothing for us to do. + if (!$ldap_user->exists) { + return FALSE; + } + + // Attempt to load the drupal user. + $drupal_user = user_load_by_name($name); + if (!$drupal_user) { + $drupal_user = user_load_by_mail($name); + } + + // If the user doesn't already exist in Drupal, create them. + if (!$drupal_user) { + $attribute_name = simple_ldap_user_variable_get('simple_ldap_user_attribute_name'); + $attribute_mail = simple_ldap_user_variable_get('simple_ldap_user_attribute_mail'); + $edit = array( + 'name' => $ldap_user->{strtolower($attribute_name)}[0], + 'mail' => $ldap_user->{strtolower($attribute_mail)}[0], + 'status' => 1, + ); + $drupal_user = user_save(NULL, $edit); + } + + return $drupal_user; +} + +/** + * Synchronizes Drupal user properties to LDAP. + */ +function simple_ldap_user_sync_user_to_ldap($drupal_user) { + // Don't try to sync if the server is read-only. + $server = SimpleLdapServer::singleton(); + if ($server->readonly) { + return; + } + + // Don't try to sync anonymous or user 1. + if ($drupal_user->uid == 0 || $drupal_user->uid == 1) { + return; + } + + // simple_ldap_user configuration. + $attribute_name = simple_ldap_user_variable_get('simple_ldap_user_attribute_name'); + $attribute_mail = simple_ldap_user_variable_get('simple_ldap_user_attribute_mail'); + $attribute_pass = simple_ldap_user_variable_get('simple_ldap_user_attribute_pass'); + $attribute_map = simple_ldap_user_variable_get('simple_ldap_user_attribute_map'); + + // Load the LDAP user. + $ldap_user = SimpleLdapUser::singleton($drupal_user->name); + + // Mail is a special attribute. + $ldap_user->$attribute_mail = $drupal_user->mail; + + // Password is a special attribute. + $ldap_user->$attribute_pass = $drupal_user->pass; + + // Synchronize the fields in the attribute map. + foreach ($attribute_map as $attribute) { + + // Initialize the Drupal value array. + $drupal_values = array(); + + // Parse the drupal attribute name. + foreach ($attribute['drupal'] as $drupal_attribute) { + + // Get the field type. + $type = substr($drupal_attribute, 0, 1); + + // Get the Drupal value(s) based on the field type. + switch ($type) { + case '#': + // Get the value using Field API. + $drupal_attribute = substr($drupal_attribute, 1); + $items = field_get_items('user', $drupal_user, $drupal_attribute); + $value = array(); + if (is_array($items)) { + foreach ($items as $item) { + if (isset($item['value'])) { + $value[] = $item['value']; + } + } + } + $drupal_values[] = $value; + break; + + default: + // Get the value directly from the user object. + $drupal_values[] = array($drupal_user->$drupal_attribute); + } + } + + // Merge the $drupal_values array into uniform values for the LDAP server. + // This is needed to account for drupal attributes of mixed types. + // First, find the largest value array. + $size = 0; + foreach ($drupal_values as $drupal_value) { + $count = count($drupal_value); + if ($count > $size) { + $size = $count; + } + } + + // Then, generate the ldap array. + $ldap_values = array(); + for ($i = 0; $i < $size; $i++) { + $ldap_values[$i] = ''; + foreach ($drupal_values as $values) { + if (isset($values[$i])) { + $ldap_values[$i] .= ' ' . $values[$i]; + } + } + $ldap_values[$i] = trim($ldap_values[$i]); + } + + // Finally, add the values to the LDAP user. + $ldap_user->{$attribute['ldap']} = $ldap_values; + } + + // Set the DN. + $attribute_rdn = simple_ldap_user_variable_get('simple_ldap_user_attribute_rdn'); + if (empty($attribute_rdn)) { + $attribute_rdn = $attribute_name; + } + if ($ldap_user->{$attribute_rdn}['count'] > 0) { + if ($ldap_user->dn) { + // Reconstruct an existing DN. + $parts = SimpleLdap::ldap_explode_dn($ldap_user->dn); + $basedn = ''; + for ($i = 1; $i < $parts['count']; $i++) { + $basedn .= ',' . $parts[$i]; + } + } + else { + // Default to using the configured basedn. + $basedn = ',' . simple_ldap_user_variable_get('simple_ldap_user_basedn'); + } + $ldap_user->dn = $attribute_rdn . '=' . $ldap_user->{$attribute_rdn}[0] . $basedn; + } + + // Allow altering the LDAP user object before saving. + drupal_alter('simple_ldap_user_to_ldap', $ldap_user, $drupal_user); + + // Save any changes. + try { + $ldap_user->cn = $ldap_user->uid; + $ldap_user->sn = $ldap_user->uid; + $ldap_user->save(); + } catch (SimpleLdapException $e) { + drupal_set_message(t('Failed to save the user to LDAP.') . ' ' . format_string('%error', array('%error' => $e->getMessage())), 'error'); + } +} + +/** + * Synchronizes LDAP attributes to Drupal user properties. + */ +function simple_ldap_user_sync_user_to_drupal($drupal_user) { + // simple_ldap_user configuration. + $attribute_name = simple_ldap_user_variable_get('simple_ldap_user_attribute_name'); + $attribute_mail = simple_ldap_user_variable_get('simple_ldap_user_attribute_mail'); + $attribute_map = simple_ldap_user_variable_get('simple_ldap_user_attribute_map'); + + // Load the LDAP user, force a cache reset. + $ldap_user = SimpleLdapUser::singleton($drupal_user->name, TRUE); + + // Nothing to sync. + if (!$ldap_user->exists || (isset($drupal_user->uid) && $drupal_user->uid == 1)) { + return; + } + + // Initialize array of attribute changes. + $edit = array(); + + // Mail is a special attribute. + if (isset($ldap_user->{$attribute_mail}[0]) && $drupal_user->mail != $ldap_user->{$attribute_mail}[0]) { + $edit['mail'] = $ldap_user->{$attribute_mail}[0]; + } + + // Synchronize the fields in the attribute map. + foreach ($attribute_map as $attribute) { + + // Skip drupal-to-ldap many-to-one mappings. + if (count($attribute['drupal']) > 1) { + continue; + } + + // Get the drupal field name and type. + $drupal_attribute = reset($attribute['drupal']); + $drupal_attribute_trimmed = substr($drupal_attribute, 1); + $type = substr($drupal_attribute, 0, 1); + + if (isset($drupal_user->$drupal_attribute) || isset($drupal_user->$drupal_attribute_trimmed)) { + switch ($type) { + + // Update the value in drupal using Field API. + case '#': + // Get the Drupal field values and metadata. + $drupal_attribute = substr($drupal_attribute, 1); + $items = field_get_items('user', $drupal_user, $drupal_attribute); + $info = field_info_field($drupal_attribute); + $language = field_language('user', $drupal_user, $drupal_attribute); + + // Synchronize. + $dirty = FALSE; + for ($i = 0; $i < $ldap_user->{$attribute['ldap']}['count']; $i++) { + if ($i < $info['cardinality'] || $info['cardinality'] == FIELD_CARDINALITY_UNLIMITED) { + $edit[$drupal_attribute][$language][$i]['value'] = $ldap_user->{$attribute['ldap']}[$i]; + if ($items[$i]['value'] != $ldap_user->{$attribute['ldap']}[$i]) { + $dirty = TRUE; + } + } + } + + // Check if any changes were actually made. + if (!$dirty) { + unset($edit[$drupal_attribute]); + } + break; + + // Update the value directly on the user object. + case 'default': + default: + if (isset($ldap_user->{$attribute['ldap']}[0]) && $drupal_user->$drupal_attribute != $ldap_user->{$attribute['ldap']}[0]) { + $edit[$drupal_attribute] = $ldap_user->{$attribute['ldap']}[0]; + } + } + } + } + + // Allow altering the Drupal user object before saving. + drupal_alter('simple_ldap_user_to_drupal', $edit, $drupal_user, $ldap_user); + + // Save any changes. + if (!empty($edit)) { + if (!isset($drupal_user->original)) { + // This avoids an infinite load/save loop. + $drupal_user->original = clone $drupal_user; + } + $drupal_user->hook_sync_user_to_drupal = TRUE; + $drupal_user = user_save($drupal_user, $edit); + } + + // Synchronized user. + return $drupal_user; +} + +/** + * Implements hook_user_operations(). + */ +function simple_ldap_user_user_operations() { + $operations = array(); + $server = SimpleLdapServer::singleton(); + if (!$server->readonly) { + $operations['simple_ldap_user_export'] = array( + 'label' => t('Export selected users to LDAP'), + 'callback' => 'simple_ldap_user_export', + ); + } + return $operations; +} + +/** + * Handles bulk user export from admin/people. + */ +function simple_ldap_user_export($users) { + // Generate the batch operation array. + $operations = array(); + foreach ($users as $uid) { + // Don't sync user1. + if ($uid == 1) { + continue; + } + + $operations[] = array('simple_ldap_user_export_user', array($uid)); + } + + $batch = array( + 'operations' => $operations, + ); + + batch_set($batch); +} + +/** + * Batch process function for mass user export. + */ +function simple_ldap_user_export_user($uid, $context) { + // Sync user to LDAP. + $user = user_load($uid); + simple_ldap_user_sync_user_to_ldap($user); + $context['message'] = 'Exporting ' . $user->name; +} + +/** + * Returns the value for the specified variable. + * + * This function takes into account the configured LDAP server type, and + * attempts to determine a reasonable default value to try to use in the event + * that the module has not yet been configured. + */ +function simple_ldap_user_variable_get($name, $default = NULL, $force_default = FALSE) { + // Allow variable name shorthand by prepending 'simple_ldap_user_' to $name if + // it is not already there. + if (strpos($name, 'simple_ldap_user_') !== 0) { + $name = 'simple_ldap_user_' . $name; + } + + // Get an LDAP server object. + $server = SimpleLdapServer::singleton(); + + // Handle special variables. + switch ($name) { + case 'simple_ldap_user_source': + // If the LDAP server is set to read-only, force LDAP->Drupal sync. + if ($server->readonly) { + return 'ldap'; + } + break; + + case 'simple_ldap_user_attribute_map': + // Load the attribute map from settings.php. + $attribute_map = variable_get($name, array()); + foreach ($attribute_map as $key => $value) { + // LDAP likes lowercase. + $attribute_map[$key]['ldap'] = strtolower($attribute_map[$key]['ldap']); + + // Make sure the Drupal attribute is an array. + if (!is_array($attribute_map[$key]['drupal'])) { + $attribute_map[$key]['drupal'] = array($attribute_map[$key]['drupal']); + } + } + return $attribute_map; + } + + // Define defaults that differ based on LDAP server type. + switch ($server->type) { + case 'Active Directory': + $defaults = array( + 'simple_ldap_user_objectclass' => array('user'), + 'simple_ldap_user_attribute_name' => 'samaccountname', + 'simple_ldap_user_attribute_mail' => 'mail', + 'simple_ldap_user_attribute_pass' => 'unicodepwd', + 'simple_ldap_user_password_hash' => 'unicode', + 'simple_ldap_user_attribute_rdn' => 'cn', + ); + break; + + default: + $defaults = array( + 'simple_ldap_user_objectclass' => array('inetorgperson'), + 'simple_ldap_user_attribute_name' => 'cn', + 'simple_ldap_user_attribute_mail' => 'mail', + 'simple_ldap_user_attribute_pass' => 'userpassword', + 'simple_ldap_user_password_hash' => 'salted sha', + ); + } + + // Define defaults that do not depend on LDAP server type. + $defaults['simple_ldap_user_basedn'] = $server->basedn; + $defaults['simple_ldap_user_scope'] = 'sub'; + $defaults['simple_ldap_user_source'] = 'ldap'; + $defaults['simple_ldap_user_sync'] = 'hook_user_load'; + + // Determine the default value for the given variable. + $default = isset($defaults[$name]) ? $defaults[$name] : $default; + + if ($force_default) { + return $default; + } + + return variable_get($name, $default); +} diff --git a/devgerrit/env/env.list b/devgerrit/env/env.list new file mode 100755 index 0000000..271fe20 --- /dev/null +++ b/devgerrit/env/env.list @@ -0,0 +1,28 @@ +#### LDAP CONFIG #### +LDAP_ROOTPASS=opensuse +#LDAP_ORGANISATION=swplatform +#LDAP_DOMAIN=spt.tizen.sec.samsung.net +LDAP_ORGANISATION=swplatform +LDAP_DOMAIN=example.com + +#### MYSQL DB #### +MYSQL_ROOT_PASSWORD=opensuse +MYSQL_DATA_DIR_DEFAULT=/var/lib/mysql + +#### DRUPAL DB #### +MYSQL_DRUPAL_DATABASE=drupal +MYSQL_DRUPAL_USER=drupaluser +MYSQL_DRUPAL_PASSWORD=drupalpassword + +#### GERRIT DB #### +MYSQL_GERRIT_DATABASE=reviewdb +MYSQL_GERRIT_USER=gerrit +MYSQL_GERRIT_PASSWORD=gerritpassword + +#### env list #### +TERM=xterm + +ftp_proxy= +http_proxy= +https_proxy= +socks_proxy=
\ No newline at end of file diff --git a/devgerrit/gerrit/plugins/commit-message-length-validator.jar b/devgerrit/gerrit/plugins/commit-message-length-validator.jar Binary files differnew file mode 100755 index 0000000..4f6f9b0 --- /dev/null +++ b/devgerrit/gerrit/plugins/commit-message-length-validator.jar diff --git a/devgerrit/gerrit/plugins/delete-project-2.9.jar b/devgerrit/gerrit/plugins/delete-project-2.9.jar Binary files differnew file mode 100755 index 0000000..fade44f --- /dev/null +++ b/devgerrit/gerrit/plugins/delete-project-2.9.jar diff --git a/devgerrit/gerrit/plugins/download-commands.jar b/devgerrit/gerrit/plugins/download-commands.jar Binary files differnew file mode 100755 index 0000000..6b555b7 --- /dev/null +++ b/devgerrit/gerrit/plugins/download-commands.jar diff --git a/devgerrit/gerrit/plugins/replication.jar b/devgerrit/gerrit/plugins/replication.jar Binary files differnew file mode 100755 index 0000000..96813b9 --- /dev/null +++ b/devgerrit/gerrit/plugins/replication.jar diff --git a/devgerrit/gerrit/plugins/reviewnotes.jar b/devgerrit/gerrit/plugins/reviewnotes.jar Binary files differnew file mode 100755 index 0000000..96da5bb --- /dev/null +++ b/devgerrit/gerrit/plugins/reviewnotes.jar diff --git a/devgerrit/gerrit/plugins/singleusergroup.jar b/devgerrit/gerrit/plugins/singleusergroup.jar Binary files differnew file mode 100755 index 0000000..ede9b65 --- /dev/null +++ b/devgerrit/gerrit/plugins/singleusergroup.jar diff --git a/devgerrit/jdk/java-1.7.0-oracle-x64.jinfo b/devgerrit/jdk/java-1.7.0-oracle-x64.jinfo new file mode 100755 index 0000000..453b930 --- /dev/null +++ b/devgerrit/jdk/java-1.7.0-oracle-x64.jinfo @@ -0,0 +1,45 @@ +name=java-1.7.0-oracle-x64 +alias=java-1.7.0_60-oracle-x64 +priority=30 +section=main + +hl java /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/java +hl keytool /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/keytool +hl pack200 /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/pack200 +hl rmid /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/rmid +hl rmiregistry /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/rmiregistry +hl unpack200 /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/unpack200 +hl orbd /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/orbd +hl servertool /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/servertool +hl tnameserv /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/tnameserv +hl jexec /usr/lib/jvm/java-1.7.0-oracle-x64/jre/lib/jexec +jre policytool /usr/lib/jvm/java-1.7.0-oracle-x64/jre/bin/policytool +jdk appletviewer /usr/lib/jvm/java-1.7.0-oracle-x64/bin/appletviewer +jdk extcheck /usr/lib/jvm/java-1.7.0-oracle-x64/bin/extcheck +jdk idlj /usr/lib/jvm/java-1.7.0-oracle-x64/bin/idlj +jdk jar /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jar +jdk jarsigner /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jarsigner +jdk javac /usr/lib/jvm/java-1.7.0-oracle-x64/bin/javac +jdk javadoc /usr/lib/jvm/java-1.7.0-oracle-x64/bin/javadoc +jdk javah /usr/lib/jvm/java-1.7.0-oracle-x64/bin/javah +jdk javap /usr/lib/jvm/java-1.7.0-oracle-x64/bin/javap +jdk jcmd /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jcmd +jdk jconsole /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jconsole +jdk jdb /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jdb +jdk jhat /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jhat +jdk jinfo /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jinfo +jdk jmap /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jmap +jdk jps /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jps +jdk jrunscript /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jrunscript +jdk jsadebugd /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jsadebugd +jdk jstack /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jstack +jdk jstat /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jstat +jdk jstatd /usr/lib/jvm/java-1.7.0-oracle-x64/bin/jstatd +jdk native2ascii /usr/lib/jvm/java-1.7.0-oracle-x64/bin/native2ascii +jdk rmic /usr/lib/jvm/java-1.7.0-oracle-x64/bin/rmic +jdk schemagen /usr/lib/jvm/java-1.7.0-oracle-x64/bin/schemagen +jdk serialver /usr/lib/jvm/java-1.7.0-oracle-x64/bin/serialver +jdk wsgen /usr/lib/jvm/java-1.7.0-oracle-x64/bin/wsgen +jdk wsimport /usr/lib/jvm/java-1.7.0-oracle-x64/bin/wsimport +jdk xjc /usr/lib/jvm/java-1.7.0-oracle-x64/bin/xjc +plugin mozilla-javaplugin.so /usr/lib/jvm/java-1.7.0-oracle-x64/jre/lib/amd64/IcedTeaPlugin.so
\ No newline at end of file diff --git a/devgerrit/phpldapadmin/usr/share/phpldapadmin/lib/TemplateRender.php b/devgerrit/phpldapadmin/usr/share/phpldapadmin/lib/TemplateRender.php new file mode 100755 index 0000000..663c271 --- /dev/null +++ b/devgerrit/phpldapadmin/usr/share/phpldapadmin/lib/TemplateRender.php @@ -0,0 +1,2533 @@ +<?php +/** + * This class will render the creation or editing of an LDAP entry. + * + * @author The phpLDAPadmin development team + * @package phpLDAPadmin + */ + +/** + * TemplateRender class + * + * @package phpLDAPadmin + * @subpackage Templates + */ +class TemplateRender extends PageRender { + # Page number + private $pagelast; + + /** CORE FUNCTIONS **/ + + /** + * Initialise and Render the TemplateRender + */ + public function accept($norender=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s:%s</font><br />',time(),__METHOD__); + if (DEBUGTMP||DEBUGTMPSUB) printf('<font size=-2>* %s [Visit-Start:%s]</font><br />',__METHOD__,get_class($this)); + + $tree = get_cached_item($this->server_id,'tree'); + if (! $tree) + $tree = Tree::getInstance($this->server_id); + + $treeitem = $tree->getEntry($this->dn); + + # If we have a DN, and no template_id, see if the tree has one from last time + if ($this->dn && is_null($this->template_id) && $treeitem && $treeitem->getTemplate()) + $this->template_id = $treeitem->getTemplate(); + + # Check that we have a valid template, or present a selection + # @todo change this so that the modification templates rendered are the ones for the objectclass of the dn. + if (! $this->template_id) + $this->template_id = $this->getTemplateChoice(); + + if ($treeitem) + $treeitem->setTemplate($this->template_id); + + $this->page = get_request('page','REQUEST',false,1); + + if ($this->template_id AND $this->template_id != 'invalid') { + if (! $this->template) + parent::accept(); + + $this->url_base = sprintf('server_id=%s&dn=%s', + $this->getServerID(),$this->template->getDNEncode()); + $this->layout['hint'] = sprintf('<td class="icon"><img src="%s/light.png" alt="%s" /></td><td colspan="3"><span class="hint">%%s</span></td>', + IMGDIR,_('Hint')); + $this->layout['action'] = '<td class="icon"><img src="%s/%s" alt="%s" /></td><td><a href="cmd.php?%s" title="%s">%s</a></td>'; + $this->layout['actionajax'] = '<td class="icon"><img src="%s/%s" alt="%s" /></td><td><a href="cmd.php?%s" title="%s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a></td>'; + + # If we dont want to render this template automatically, we'll return here. + if ($norender) + return; + + $this->visitStart(); + + foreach ($this->template->getAttributes(true) as $attribute) { + # Evaluate our defaults + if ($attribute->getAutoValue()) + $this->get('Default',$attribute, + $this->template->getContainer() ? $this->template->getContainer() : $this->getServer()->getContainerPath($this->template->getDN()), + 'autovalue'); + + # If this is the default template, we should mark all our attributes to show(). + if (($this->template->getID() == 'none') && (! $attribute->isInternal()) + && (($this->template->getContext() == 'edit' && $this->template->getID() == 'none') + || ($this->template->getContext() == 'create' && $attribute->getName() != 'objectclass'))) + $attribute->show(); + } + + if (DEBUGTMP||DEBUGTMPSUB) printf('<font size=-2>* %s [Visit-End:%s]</font><br />',__METHOD__,get_class($this)); + + $this->visitEnd(); + } + } + + protected function getDefaultAttribute($attribute,$container,$type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + switch ($type) { + case 'autovalue': + $autovalue = $attribute->getAutoValue(); + + break; + + case 'helpervalue': + $autovalue = $attribute->getHelperValue(); + + break; + + default: + system_message(array( + 'title'=>_('Unknown Default Attribute context'), + 'body'=>sprintf('%s (<b>%s</b>)',_('A call was made to getDefaultAttribute() with an unkown context'),$type), + 'type'=>'warn')); + + return; + } + + $args = explode(';',$autovalue['args']); + $server = $this->getServer(); + $vals = ''; + + switch ($autovalue['function']) { + /** + * Function enables normal PHP functions to be called to evaluate a value. + * eg: =php.Function(date;dmY) + * + * All arguments will be passed to the function, and its value returned. + * If this used used in a POST context, the attribute values can be used as arguments. + * + * Mandatory Arguments: + * * arg 0 + * - php Function to call + * + * Additional arguments will be passed to the function. + */ + case 'Function': + $function = array_shift($args); + + if (count($args) && count($args) > 1) { + system_message(array( + 'title'=>_('Too many arguments'), + 'body'=>sprintf('%s (<b>%s</b>)',_('Function() only takes two arguments and more than two were specified'),count($args)), + 'type'=>'warn')); + + return; + } + + $function_args = explode(',',$args[0]); + + if (function_exists($function)) + $vals = call_user_func_array($function,$function_args); + + else + system_message(array( + 'title'=>_('Function doesnt exist'), + 'body'=>sprintf('%s (<b>%s</b>)',_('An attempt was made to call a function that doesnt exist'),$function), + 'type'=>'warn')); + + break; + + /** + * GetNextNumber will query the LDAP server and calculate the next number based on the query + * eg: <![CDATA[=php.GetNextNumber(/;gidNumber;false;(&(objectClass=posixGroup));*2,+1000)]]> + * + * Mandatory Arguments: + * * arg 0 + * - "$" => 'auto_number','search_base' in config file + * - "/",".",".." => get container parent as usual + * + * * arg 1 + * - attribute to query for + * + * Optional Arguments: + * * arg 2 (pool mechanism only) + * - "true" increments attribute by 1 + * - "false" do nothing + * + * * arg 3 (pool mechanism only) + * - ldap filter (must match one entry only in container) + * + * * arg 4 + * - calculus on number, eg: + * - *2,+1000 => number = (2*number) + 1000 + * + * * arg 5 + * - Min number + */ + case 'GetNextNumber': + # If the attribute already has values, we'll return + if ($type == 'autovalue' && $attribute->getValues()) + return; + + if ($args[0] == '$') + $args[0] = $server->getValue($this->server_id,'auto_number','search_base'); + + $container = $server->getContainerPath($container,$args[0]); + + $vals = get_next_number($container,$args[1], + (! empty($args[2]) && ($args[2] == 'false')) ? false : true, + (! empty($args[3])) ? $args[3] : false, + (! empty($args[5])) ? $args[5] : null); + + # Operate calculus on next number. + if (! empty($args[4])) { + $mod = explode(',',$args[4]); + $next_number = $vals; + + foreach ($mod as $calc) { + $operand = $calc{0}; + $operator = substr ($calc,1); + + switch ($operand) { + case '*': + $next_number = $next_number * $operator; + break; + + case '+': + $next_number = $next_number + $operator; + break; + + case '-': + $next_number = $next_number - $operator; + break; + + case '/': + $next_number = $next_number / $operator; + break; + } + } + + $vals = $next_number; + } + + break; + + /** + * PickList will query the LDAP server and provide a select list of values + * MultiList will query the LDAP server and provide a multi select list of values + * eg: <![CDATA[=php.MultiList(/;(objectClass=posixAccount);uid)]]> + * + * eg: <![CDATA[=php.MultiList(/;(&(objectClass=posixAccount)(uid=groupA*));uid;%cn/U% (%gidNumber%);memberUid;dmdName=users;root => cn=root,nobody => cn=nobody;gidNumber;10)]]> + * + * Mandatory Arguments: + * * arg 0 + * - container, to query from current position + * - "/",".",".." => get container parent as usual + * + * * arg 1 + * - LDAP filter. May include '%attr%', it will be expanded. + * + * * arg2 + * - list attribute key + * + * Optional Arguments: + * * arg3 + * - select display (plus modifier /C: Capitalize) + * - replaced by %arg 2% if not given + * + * * arg 4 + * - the value furnished in output - must be attribute id. replaced by arg 2 if not given + * + * * arg 5 + * - container override + * + * * arg 6 + * - csv list (, separator) of added values. syntax: key => display_attribute=value, key... + * + * * arg 7 + * - csv list (, separator) of sort attributes (less to more important) + * + * * arg 8 (for MultiList) + * - size of displayed list (default: 10 lines) + */ + case 'MultiList': + case 'PickList': + # arg5 overrides our container + if (empty($args[5])) + $container = $server->getContainerPath($container,$args[0]); + else + $container = $args[5]; + + # Process filter (arg 1), eventually replace %attr% by it's value set in a previous page. + preg_match_all('/%(\w+)(\|.+)?(\/[lUC])?%/U',$args[1],$filtermatchall); + //print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod + + if (isset($_REQUEST['form'])) { + $formvalues = array_change_key_case($_REQUEST['form']); + + foreach ($filtermatchall[1] as $arg) { + $value = $formvalues[strtolower($arg)]; + $args[1] = preg_replace("/%($arg)(\|.+)?(\/[lU])?%/U",$value,$args[1]); + } + } + + if (empty($args[3])) + $args[3] = "%{$args[2]}%"; + + preg_match_all('/%(\w+)(\|.+)?(\/[lUC])?%/U',$args[3],$matchall); + //print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod + + $attrs = array_unique(array_merge($matchall[1],array($args[2]))); + + # arg7 is sort attributes + if (isset($args[7])) { + $sort_attrs = explode(',',$args[7]); + $attrs = array_unique(array_merge($attrs,$sort_attrs)); + } + + $picklistvalues = return_ldap_hash($container,$args[1],$args[2],$attrs,(isset($args[7]) && ($args[7])) ? $sort_attrs : false); + + # arg6 is a set of fixed values to add to search result + if (isset($args[6])) { + $fixedvalues = explode(',',$args[6]); + + foreach ($fixedvalues as $fixedvalue) { + if (empty($fixedvalue)) + continue; + + $fixedvalue = preg_split('/=\>/',$fixedvalue); + $displayvalue = explode('=',$fixedvalue[1]); + + $newvalue[trim($fixedvalue[0])] = array($args[2]=>trim($fixedvalue[0]),trim($displayvalue[0])=>trim($displayvalue[1])); + + $picklistvalues = array_merge($picklistvalues,$newvalue); + } + } + + $vals = array(); + + foreach ($picklistvalues as $key => $values) { + $display = $args[3]; + + foreach ($matchall[1] as $key => $arg) { + if (isset($values[$arg])) + $disp_val = $values[$arg]; + else + $disp_val = ''; + + if (is_array($disp_val)) + $disp_val = $disp_val[0]; + + if ($matchall[3][$key]) + switch ($matchall[3][$key]) { + case '/l': + # lowercase + if (function_exists('mb_convert_case')) + $disp_val = mb_convert_case($disp_val,MB_CASE_LOWER,'utf-8'); + else + $disp_val = strtolower($disp_val); + + break; + + case '/U': + # uppercase + if (function_exists('mb_convert_case')) + $disp_val = mb_convert_case($disp_val,MB_CASE_UPPER,'utf-8'); + else + $disp_val = strtoupper($disp_val); + + break; + + case '/C': + # capitalize + if (function_exists('mb_convert_case')) + $disp_val = mb_convert_case($disp_val,MB_CASE_TITLE,'utf-8'); + else + $disp_val = ucfirst($disp_val); + + break; + + default: + break; + } + + # make value a substring of + preg_match_all('/^\|([0-9]*)-([0-9]*)$/',trim($matchall[2][$key]),$substrarray); + + if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) { + $begin = $substrarray[1][0] ? $substrarray[1][0] : '0'; + $end = $substrarray[2][0] ? $substrarray[2][0] : strlen($disp_val); + + if (function_exists('mb_substr')) + $disp_val = mb_substr($disp_val,$begin,$end,'utf-8'); + else + $disp_val = substr($disp_val,$begin,$end); + } + + $display = preg_replace("/%($arg)(\|.+)?(\/[lUC])?%/U",$disp_val,$display); + } + + if (! isset($picklist[$values[$args[2]]])) { + $vals[$values[$args[2]]] = $display; + $picklist[$values[$args[2]]] = true; + } + } + + break; + + /** + * PasswordEncryptionTypes will return a list of our support password encryption types + * eg: =php.PasswordEncryptionTypes() + * + * This function doesnt use any arguments + */ + case 'PasswordEncryptionTypes': + $vals = password_types(); + + break; + + /** + * RandomPassword will create a random password for the value. + * eg: =php.RandomPassword() + * + * When calling the attribute Javascript it will generate a random password. + * + * This function doesnt use any arguments + */ + case 'RandomPassword': + break; + } + + switch ($type) { + case 'autovalue': + if (! is_array($vals)) + $attribute->autoValue(array($vals)); + else + $attribute->autoValue($vals); + + break; + + case 'helpervalue': + return $vals; + } + } + + /** + * Set the mode of the TemplateRender + * Applicable modes are "create" or "edit" + */ + protected function getMode() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if ($this->dn) + return 'modification'; + elseif ($this->container) + return 'creation'; + elseif (get_request('create_base')) + return 'creation'; + else + debug_dump_backtrace(sprintf('Unknown mode for %s',__METHOD__),1); + } + + /** + * Return the container for this mode + */ + protected function getModeContainer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + switch ($this->getMode()) { + case 'creation': + return $this->container; + break; + + case 'modification': + return $this->dn; + break; + + default: + return null; + } + } + + /** + * Is the default template enabled? + */ + protected function haveDefaultTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if ($_SESSION[APPCONFIG]->getValue('appearance','disable_default_template')) + return false; + else + return true; + } + + /** + * Present a list of available templates for creating and editing LDAP entries + */ + protected function drawTemplateChoice() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $this->drawTitle(); + $this->drawSubTitle(); + echo "\n"; + + switch ($this->getMode()) { + case 'creation': + $msg = _('Select a template for the creation process'); + break; + + case 'modification': + $msg = _('Select a template to edit the entry'); + break; + } + + $avail_templates = $this->getTemplates(); + $templates = $avail_templates->getTemplates($this->getMode(),$this->getModeContainer()); + printf('<h3 style="text-align: center;">%s</h3>',$msg); + + $href_parms = array_to_query_string($_GET,array('meth')); + printf('<form id="template_choice_form" action="cmd.php?%s" method="post">',htmlspecialchars($href_parms)); + echo "\n\n"; + + if (count($_POST)) { + echo '<div>'; + foreach ($_POST as $p => $v) + printf('<input type="hidden" name="%s" value="%s" />',$p,$v); + echo '</div>'; + echo "\n\n"; + } + + echo '<table class="forminput" width="100%" border="0">'; + echo '<tr>'; + printf('<td class="heading" style="vertical-align: top">%s:</td>',_('Templates')); + echo '<td>'; + echo '<table>'; + + $i = -1; + $nb_templates = count($templates); + + if ($this->haveDefaultTemplate()) + $nb_templates++; + + foreach ($templates as $name => $details) { + $i++; + + $isInValid = $details->isInValid(); + + # Balance the columns properly + if (($nb_templates % 2 == 0 && $i == intval($nb_templates / 2)) || + ($nb_templates % 2 == 1 && $i == intval($nb_templates / 2) + 1)) { + echo '</table></td><td><table>'; + } + + echo "\n"; + echo '<tr>'; + + if ($isInValid) + printf('<td class="icon"><img src="%s/disabled.png" alt="Disabled" /></td>',IMGDIR); + + else { + if (isAjaxEnabled()) + printf('<td><input type="radio" name="template" value="%s" id="%s" onclick="return ajDISPLAY(\'BODY\',\'%s&template=%s\',\'%s\');" /></td>', + htmlspecialchars($details->getID()),htmlspecialchars($details->getID()),htmlspecialchars($href_parms),$details->getID(),str_replace('\'','\\\'',_('Retrieving DN'))); + else + printf('<td><input type="radio" name="template" value="%s" id="%s" onclick="document.getElementById(\'template_choice_form\').submit()" /></td>', + htmlspecialchars($details->getID()),htmlspecialchars($details->getID())); + } + + printf('<td class="icon"><label for="%s"><img src="%s" alt="" /></label></td>', + htmlspecialchars($details->getID()),$details->getIcon()); + printf('<td class="label"><label for="%s">', + htmlspecialchars($details->getID())); + + if ($isInValid) + printf('<span id="%s" style="color: gray"><acronym title="%s">',htmlspecialchars($details->getID()),_($isInValid)); + + echo _($details->getTitle()); + + if ($isInValid) + echo '</acronym></span>'; + + echo '</label></td>'; + echo '</tr>'; + } + echo "\n"; + + # Default template + if ($this->haveDefaultTemplate()) { + $i++; + + # Balance the columns properly + if (($nb_templates % 2 == 0 && $i == intval($nb_templates / 2)) || + ($nb_templates % 2 == 1 && $i == intval($nb_templates / 2) + 1)) { + echo '</table></td><td><table>'; + } + + echo '<tr>'; + if (isAjaxEnabled()) + printf('<td><input type="radio" name="template" value="none" id="none" onclick="return ajDISPLAY(\'BODY\',\'%s&template=%s\',\'%s\');" /></td>', + htmlspecialchars($href_parms),'none',str_replace('\'','\\\'',_('Retrieving DN'))); + else + echo '<td><input type="radio" name="template" value="none" id="none" onclick="document.getElementById(\'template_choice_form\').submit()" /></td>'; + + printf('<td class="icon"><label for="none"><img src="%s/ldap-default.png" alt="" /></label></td>',IMGDIR); + printf('<td class="label"><label for="none">%s</label></td>',_('Default')); + echo '</tr>'; + } + + echo '</table>'; + echo '</td></tr>'; + + echo '</table>'; + echo '</form>'; + } + + /** VISIT METHODS **/ + + /** + * This function will setup our template object (read LDAP for current values, read $_REQUEST for new values, etc) + * so that it can be rendered. + */ + private function visitStart() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + # If we have a DN, then we are an editing template + if ($this->dn) + $this->template->setDN($this->dn); + + # Else if we have a container, we are a creating template + elseif ($this->container || get_request('create_base')) + $this->template->setContainer($this->container); + + else + debug_dump_backtrace('Dont know what type of template we are - no DN or CONTAINER?',1); + + # Header + $this->drawHeader(); + } + + private function visitEnd() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + foreach ($this->template->getAttributesShown() as $attribute) + if ($attribute->getPage() > $this->pagelast) + $this->pagelast = $attribute->getPage(); + echo "\n\n"; + + if ($this->template->getContext() == 'create') { + $this->drawStepTitle($this->page); + $this->drawStepFormStart($this->page); + $this->drawStepForm($this->page); + $this->drawStepFormEnd(); + + } elseif ($this->template->getContext() == 'copyasnew') { + $this->drawStepFormStart($this->page); + printf('<input type="hidden" name="container" value="%s" />',$this->template->getContainer(false)); + echo '<div><table>'; + $this->drawRDNChooser(); + echo '</table></div>'; + $this->drawForm(true); + $this->drawStepFormSubmitButton($this->page); + + } else { + # Draw internal attributes + if (get_request('show_internal_attrs','REQUEST')) { + echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">'; + $this->drawInternalAttributes(); + echo '</table><br/>'; + echo "\n"; + } + + $this->drawFormStart(); + + # To support our AJAX add Attribute + printf('<div id="ajADD" style="display: %s"></div>','none'); + + $this->drawForm(); + $this->drawStepFormEnd(); + } + } + + /** PAGE DRAWING METHODS **/ + + private function drawHeader() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + # Title + $this->drawTitle(); + if (get_request('create_base')) + $this->drawSubTitle(sprintf('<b>%s</b>: %s',_('Creating Base DN'),$this->template->getDN())); + else + $this->drawSubTitle(); + echo "\n"; + + # Menu + $this->drawMenu(); + } + + public function drawTitle($title=null) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (is_null($title)) + switch ($this->getMode()) { + case 'creation': + $title = _('Create Object'); + break; + + case 'modification': + $title = htmlspecialchars(get_rdn($this->dn)); + break; + + default: + $title = 'Title'; + } + + parent::drawTitle($title); + } + + public function drawSubTitle($subtitle=null) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if ($subtitle) + return parent::drawSubTitle($subtitle); + + switch ($this->getMode()) { + case 'creation': + $subtitle = sprintf('%s: <b>%s</b> %s: <b>%s</b>', + _('Server'),$this->getServer()->getName(), + _('Container'),htmlspecialchars($this->container)); + + if ($this->template_id) { + $subtitle .= '<br />'; + $subtitle .= sprintf('%s: <b>%s</b>',_('Template'),$this->template->getID() != 'none' ? $this->template->getTitle() : _('Default')); + if ($this->template->getName()) + $subtitle .= sprintf(' (<b>%s</b>)',$this->template->getName(false)); + } + + break; + + case 'modification': + $subtitle = sprintf('%s: <b>%s</b> %s: <b>%s</b>', + _('Server'),$this->getServer()->getName(), + _('Distinguished Name'),htmlspecialchars($this->dn)); + + if ($this->template_id) { + $subtitle .= '<br />'; + $subtitle .= sprintf('%s: <b>%s</b>',_('Template'),$this->template->getID() != 'none' ? $this->template->getTitle() : _('Default')); + if ($this->template->getName()) + $subtitle .= sprintf(' (<b>%s</b>)',$this->template->getName(false)); + } + + break; + } + + parent::drawSubTitle($subtitle); + } + + /** PAGE ENTRY MENU **/ + + private function drawMenu() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + # We only have a menu for editing entries. + if ($this->template->getContext() == 'edit') { + + echo '<table class="menu" width="100%" border="0">'; + echo '<tr>'; + $menuitem_number = 0; + + foreach (array('entryrefresh','showinternal','switchtemplate','entryexport','entrycopy','entrydelete','entryrename','entrycompare','childcreate','addattr','msgdel','childview','childexport','msgschema','msgro','msgmodattr') as $item) { + $item = $this->getMenuItem($item); + + if ($item) { + $endofrow = false; + $start = true; + $it = ''; // menu item + $ms = ''; // item message + + if (is_array($item) && count($item) > 0) { + $it = $item[0]; + + if (count($item) > 1) + $ms = $item[1]; + + } else { + $it = $item; + } + + if ($it) { + $menuitem_number++; + echo $it; + + if ($ms) { + if (($menuitem_number % 2) == 1) { + $menuitem_number++; + echo '<td colspan="2"> </td>'; + $endofrow = false; + $start = false; + } + + if ($endofrow) + print $ms; + else + echo "</tr><tr>$ms"; + + echo '</tr><tr>'; + $endofrow = true; + $start = false; + + } else { + if ($menuitem_number > 1 && ($menuitem_number % 2) == 0) { + echo '</tr><tr>'; + $endofrow = true; + $start = false; + } + } + + } elseif ($ms) { + if (($menuitem_number % 2) == 1) { + $menuitem_number++; + echo '<td colspan="2"> </td>'; + $endofrow = false; + $start = false; + } + + if ($endofrow || $start) + print $ms; + else + echo "</tr><tr>$ms"; + + echo '</tr><tr>'; + $endofrow = true; + $start = false; + } + + echo "\n"; + } + } + + if (($menuitem_number % 2) == 1) + echo '<td> </td><td> </td>'; + else + echo '<td> </td><td> </td><td> </td><td> </td>'; + + echo '</tr>'; + echo '</table>'; + } + } + + /** PAGE ENTRY MENU ITEMS **/ + + private function getMenuItem($i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s (%s)</font><br />',__METHOD__,$i); + + switch ($i) { + case 'entryrefresh': + if ($_SESSION[APPCONFIG]->isCommandAvailable('cmd','entry_refresh')) + return $this->getMenuItemRefresh(); + else + return ''; + + case 'switchtemplate': + if ($_SESSION[APPCONFIG]->isCommandAvailable('cmd','switch_template')) + return $this->getMenuItemSwitchTemplate(); + else + return ''; + + case 'entryexport': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','export_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','export')) + return $this->getMenuItemExportBase(); + else + return ''; + + case 'entrycopy': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','copy_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','copy') && ! $this->template->isReadOnly()) + return $this->getMenuItemMove(); + else + return ''; + + case 'showinternal': + if ($_SESSION[APPCONFIG]->isCommandAvailable('cmd','entry_internal_attributes_show')) + return $this->getMenuItemInternalAttributes(); + else + return ''; + + case 'entrydelete': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','delete_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','delete') && ! $this->template->isReadOnly()) + return $this->getMenuItemDelete(); + else + return ''; + + case 'entryrename': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','rename_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','rename') && ! $this->template->isReadOnly()) { + + # Check if any of the RDN's are read only. + $rdnro = false; + foreach ($this->template->getRDNAttributeName() as $attr) { + $attribute = $this->template->getAttribute($attr); + + if ($attribute && $attribute->isVisible() && ! $attribute->isReadOnly()) { + $rdnro = true; + break; + } + } + + if (! $rdnro) + return $this->getMenuItemRename(); + } + + return ''; + + case 'msgdel': + if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints') + && $_SESSION[APPCONFIG]->isCommandAvailable('script','delete_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','delete') && ! $this->template->isReadOnly()) + return array('',$this->getDeleteAttributeMessage()); + else + return ''; + + case 'entrycompare': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','compare_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','compare') && ! $this->template->isReadOnly()) + return $this->getMenuItemCompare(); + else + return ''; + + case 'childcreate': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','create') && ! $this->template->isReadOnly() && ! $this->template->isNoLeaf()) + return $this->getMenuItemCreate(); + else + return ''; + + case 'addattr': + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','add_attr_form') && ! $this->template->isReadOnly()) + return $this->getMenuItemAddAttribute(); + else + return ''; + + case 'childview': + case 'childexport': + static $children_count = false; + static $more_children = false; + + $tree = get_cached_item($this->getServerID(),'tree'); + $tree_item = $tree->getEntry($this->template->getDN()); + + if (! $tree_item) { + $tree->addEntry($this->template->getDN()); + $tree_item = $tree->getEntry($this->template->getDN()); + } + + if ($children_count === false) { + # Visible children in the tree + $children_count = count($tree_item->getChildren()); + # Is there filtered children ? + $more_children = $tree_item->isSizeLimited(); + + if (! $children_count || ! $more_children) { + # All children in ldap + $all_children = $this->getServer()->getContainerContents( + $this->template->getDN(),null,$children_count+1,'(objectClass=*)',$_SESSION[APPCONFIG]->getValue('deref','view'),null); + + $more_children = (count($all_children) > $children_count); + } + } + + if ($children_count > 0 || $more_children) { + if ($children_count <= 0) + $children_count = ''; + if ($more_children) + $children_count .= '+'; + + if ($i == 'childview') + return $this->getMenuItemShowChildren($children_count); + elseif ($i == 'childexport' && $_SESSION[APPCONFIG]->isCommandAvailable('script','export_form') && $_SESSION[APPCONFIG]->isCommandAvailable('script','export')) + return $this->getMenuItemExportSub(); + else + return ''; + + } else + return ''; + + case 'msgschema': + if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints') && $_SESSION[APPCONFIG]->isCommandAvailable('script','schema')) + return array('',$this->getViewSchemaMessage()); + else + return array(); + + case 'msgro': + if ($this->template->isReadOnly()) + return array('',$this->getReadOnlyMessage()); + else + return array(); + + case 'msgmodattr': + $modified_attrs = array(); + $modified = get_request('modified_attrs','REQUEST',false,array()); + + foreach ($this->template->getAttributes(true) as $attribute) + if (in_array($attribute->getName(),$modified)) + array_push($modified_attrs,$attribute->getFriendlyName()); + + if (count($modified_attrs)) + return array('',$this->getModifiedAttributesMessage($modified_attrs)); + else + return array(); + + default: + return false; + } + } + + protected function getDeleteAttributeMessage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if ($_SESSION[APPCONFIG]->isCommandAvailable('script','delete_attr') && ! $this->template->isReadOnly()) + return sprintf($this->layout['hint'],_('Hint: To delete an attribute, empty the text field and click save.')); + else + return ''; + } + + protected function getModifiedAttributesMessage(&$modified_attributes) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + return sprintf($this->layout['hint'], + (count($modified_attributes) == 1) ? + sprintf(_('An attribute (%s) was modified and is highlighted below.'),implode('',$modified_attributes)) : + sprintf(_('Some attributes (%s) were modified and are highlighted below.'),implode(', ',$modified_attributes))); + } + + protected function getReadOnlyMessage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + return sprintf($this->layout['hint'],_('Viewing entry in read-only mode.')); + } + + protected function getViewSchemaMessage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + return sprintf($this->layout['hint'],_('Hint: To view the schema for an attribute, click the attribute name.')); + } + + /** PAGE ENTRY MENU ITEMS DETAILS **/ + + private function getMenuItemRefresh() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=template_engine&%s&junk=%s',$this->url_base,random_junk()); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'refresh.png',_('Refresh'), + htmlspecialchars($href),_('Refresh this entry'),htmlspecialchars($href),str_replace('\'','\\\'',_('Reloading')),_('Refresh')); + else + return sprintf($this->layout['action'],IMGDIR,'refresh.png',_('Refresh'), + htmlspecialchars($href),_('Refresh this entry'),_('Refresh')); + } + + protected function getMenuItemSwitchTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + $href = sprintf('cmd=template_engine&%s&template=',$this->url_base); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'switch.png',_('Switch Template'), + htmlspecialchars($href),_('Change to another template'),htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Switch Template')); + else + return sprintf($this->layout['action'],IMGDIR,'switch.png',_('Switch Template'), + htmlspecialchars($href),_('Change to another template'),_('Switch Template')); + } + + protected function getMenuItemExportBase() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=export_form&%s&scope=base',$this->url_base); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'export.png',_('Export'), + htmlspecialchars($href),_('Save a dump of this object'),htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Export')); + else + return sprintf($this->layout['action'],IMGDIR,'export.png',_('Export'), + htmlspecialchars($href),_('Save a dump of this object'),_('Export')); + } + + private function getMenuItemMove() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=copy_form&%s',$this->url_base); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'cut.png',_('Cut'), + htmlspecialchars($href),_('Copy this object to another location, a new DN, or another server'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Copy or move this entry')); + else + return sprintf($this->layout['action'],IMGDIR,'cut.png',_('Cut'), + htmlspecialchars($href),_('Copy this object to another location, a new DN, or another server'), + _('Copy or move this entry')); + } + + protected function getMenuItemInternalAttributes() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (get_request('show_internal_attrs','REQUEST')) { + $href = sprintf('cmd=template_engine&%s&junk=',$this->url_base,random_junk()); + + return sprintf($this->layout['action'],IMGDIR,'tools-no.png',_('Hide'), + htmlspecialchars($href),'',_('Hide internal attributes')); + + } else { + $href = sprintf('cmd=template_engine&show_internal_attrs=true&%s',$this->url_base); + + return sprintf($this->layout['action'],IMGDIR,'tools.png',_('Show'), + htmlspecialchars($href),'',_('Show internal attributes')); + } + } + + private function getMenuItemDelete() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=delete_form&%s',$this->url_base); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'trash.png',_('Trash'), + htmlspecialchars($href),_('You will be prompted to confirm this decision'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Delete this entry')); + else + return sprintf($this->layout['action'],IMGDIR,'trash.png',_('Trash'), + htmlspecialchars($href),_('You will be prompted to confirm this decision'),_('Delete this entry')); + } + + protected function getMenuItemRename() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=rename_form&%s&template=%s',$this->url_base,$this->template->getID()); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'rename.png',_('Rename'), + htmlspecialchars($href),_('Rename this entry'),htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Rename')); + else + return sprintf($this->layout['action'],IMGDIR,'rename.png',_('Rename'), + htmlspecialchars($href),_('Rename this entry'),_('Rename')); + } + + protected function getMenuItemCompare() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=compare_form&%s',$this->url_base); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'compare.png',_('Compare'), + htmlspecialchars($href),_('Compare this entry with another'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Compare with another entry')); + else + return sprintf($this->layout['action'],IMGDIR,'compare.png',_('Compare'), + htmlspecialchars($href),_('Compare this entry with another'),_('Compare with another entry')); + } + + protected function getMenuItemCreate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),$this->template->getDNEncode()); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'create.png',_('Create'), + htmlspecialchars($href),_('Create a child entry'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Create a child entry')); + else + return sprintf($this->layout['action'],IMGDIR,'create.png',_('Create'), + htmlspecialchars($href),_('Create a child entry'),_('Create a child entry')); + } + + protected function getMenuItemAddAttribute() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (! $this->template->getAvailAttrs()) + return ''; + + $href = sprintf('cmd=add_attr_form&%s',$this->url_base); + $layout = '<td class="icon"><img src="%s/%s" alt="%s" /></td><td><a href="cmd.php?%s" title="%s" onclick="getDiv(\'ADD\').style.display = \'block\';return ajDISPLAY(\'ADD\',\'%s\',\'%s\');">%s</a></td>'; + + if (isAjaxEnabled()) + return sprintf($layout,IMGDIR,'add.png',_('Add'), + htmlspecialchars($href),_('Add new attribute to this object'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Add new attribute')),_('Add new attribute')); + else + return sprintf($this->layout['action'],IMGDIR,'add.png',_('Add'), + htmlspecialchars($href),_('Add new attribute to this object'),_('Add new attribute')); + } + + protected function getMenuItemShowChildren($children_count) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=query_engine&server_id=%s&filter=%s&base=%s&scope=one&query=none&size_limit=0&search=true', + $this->getServerID(),rawurlencode('objectClass=*'),$this->template->getDNEncode()); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'children.png',_('Children'), + htmlspecialchars($href),_('View the children of this object'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')), + ($children_count == 1) ? _('View 1 child') : sprintf(_('View %s children'),$children_count)); + else + return sprintf($this->layout['action'],IMGDIR,'children.png',_('Children'), + htmlspecialchars($href),_('View the children of this object'), + ($children_count == 1) ? _('View 1 child') : sprintf(_('View %s children'),$children_count)); + } + + protected function getMenuItemExportSub() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=export_form&%s&scope=%s',$this->url_base,'sub'); + + if (isAjaxEnabled()) + return sprintf($this->layout['actionajax'],IMGDIR,'export.png',_('Save'), + htmlspecialchars($href),_('Save a dump of this object and all of its children'), + htmlspecialchars($href),str_replace('\'','\\\'',_('Loading')),_('Export subtree')); + else + return sprintf($this->layout['action'],IMGDIR,'export.png',_('Save'), + htmlspecialchars($href),_('Save a dump of this object and all of its children'),_('Export subtree')); + } + + /** CHOOSERS **/ + + /** + * RDN Chooser + */ + protected function drawRDNChooser() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (! count($this->template->getRDNAttrs())) { + printf('<tr><th colspan="2">%s</th></tr>','RDN'); + + echo '<tr><td class="value" colspan="2" style="text-align: center;"><select name="rdn_attribute[]" id="rdn_attribute" />'; + printf('<option value="">%s</option>',_('select the rdn attribute')); + + if ($_SESSION[APPCONFIG]->getValue('appearance','rdn_all_attrs')) + $allattrs = true; + else + $allattrs = false; + + foreach ($this->template->getAttributes($allattrs) as $attr) { + $n = $attr->getName(false); + + if ($attr->getName() != 'objectclass') { + $m = $attr->getFriendlyName(); + $b = ' '; + printf('<option value="%s">%s%s(%s)</option>',$n,$m,$b,$n); + } + } + + echo '</select></td></tr>'; + + } else { + echo '<tr><td colspan="2">'; + foreach ($this->template->getRDNAttrs() as $rdn) + printf('<input type="hidden" name="rdn_attribute[]" value="%s" id="rdn_attribute"/>',htmlspecialchars($rdn)); + + if (get_request('create_base')) + echo '<input type="hidden" name="create_base" value="true" />'; + + echo '</td></tr>'; + } + } + + /** + * Container Chooser + */ + protected function drawContainerChooser($default_container) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + echo '<tr>'; + printf('<td class="heading">%s</td>',_('Container')); + echo '<td>'; + if (get_request('create_base')) + printf('%s<input type="hidden" name="container" size="40" value="%s" />',$default_container,htmlspecialchars($default_container)); + else { + printf('<input type="text" name="container" size="40" value="%s" />',htmlspecialchars($default_container)); + draw_chooser_link('entry_form','container'); + } + echo '</td>'; + echo '</tr>'; + } + + /** + * Object Class Chooser + */ + protected function drawObjectClassChooser() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $socs = $this->getServer()->SchemaObjectClasses(); + if (! $socs) + $socs = array(); + + echo '<tr>'; + printf('<td class="heading">%s</td>',_('ObjectClasses')); + echo '<td><select name="new_values[objectclass][]" multiple="multiple" size="15">'; + + foreach ($socs as $name => $oclass) { + if (! strcasecmp('top',$name)) + continue; + + printf('<option %s value="%s">%s</option>', + ($oclass->getType() == 'structural') ? 'style="font-weight: bold" ' : '', + htmlspecialchars($oclass->getName(false)),$oclass->getName(false)); + } + + echo '</select>'; + echo '</td>'; + echo '</tr>'; + + if ($_SESSION[APPCONFIG]->getValue('appearance','show_hints')) { + printf('<tr><td> </td><td><small><img src="%s/light.png" alt="Hint" /><span class="hint">',IMGDIR); + echo _('Hint: You must choose exactly one structural objectClass (shown in bold above)'); + echo '</span></small><br /></td></tr>'; + } + } + + /** INTERNAL ATTRIBUTES **/ + + protected function drawInternalAttributes() { + if ($this->template->getAttributesInternal()) + foreach ($this->template->getAttributesInternal() as $attribute) + $this->draw('Internal',$attribute); + else + printf('<tr><td>(%s)<br/></td></tr>',_('No internal attributes')); + + echo "\n"; + } + + protected function drawInternalAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $this->draw('Template',$attribute); + } + + /** FORM METHODS **/ + + public function drawFormStart() { + echo '<form action="cmd.php" method="post" enctype="multipart/form-data" id="entry_form" onsubmit="return submitForm(this)">'; + + echo '<div>'; + if ($_SESSION[APPCONFIG]->getValue('confirm','update')) + echo '<input type="hidden" name="cmd" value="update_confirm" />'; + else + echo '<input type="hidden" name="cmd" value="update" />'; + echo '</div>'; + } + + protected function drawForm($nosubmit=false) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + echo '<div>'; + printf('<input type="hidden" name="server_id" value="%s" />',$this->getServerID()); + printf('<input type="hidden" name="dn" value="%s" />',$this->template->getDNEncode(false)); + printf('<input type="hidden" name="template" value="%s" />',$this->template->getID()); + echo '</div>'; + + echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">'; + + $this->drawShownAttributes(); + if (! $nosubmit) + $this->drawFormSubmitButton(); + + echo '</table>'; + + echo '<div> '; + $this->drawHiddenAttributes(); + echo '</div>'; + } + + public function drawFormEnd() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + # Include the RDN details to support creating the base + if (get_request('create_base')) { + if (get_request('rdn')) { + $rdn = explode('=',get_request('rdn')); + echo '<div>'; + printf('<input type="hidden" name="new_values[%s][]" value="%s" />',$rdn[0],$rdn[1]); + printf('<input type="hidden" name="rdn_attribute[]" value="%s" />',$rdn[0]); + echo '</div>'; + } + } + + echo '</form>'; + + # Javascript + $this->drawJavascript(); + + # For debugging, show the template object. + if (! $_SESSION[APPCONFIG]->getValue('appearance','hide_debug_info') && get_request('debug','GET')) { + echo "\n\n"; + printf('<img src="%s/plus.png" alt="Plus" onclick="if (document.getElementById(\'DEBUGtemplate\').style.display == \'none\') { document.getElementById(\'DEBUGtemplate\').style.display = \'block\' } else { document.getElementById(\'DEBUGtemplate\').style.display = \'none\' };"/>',IMGDIR); + echo '<div id="DEBUGtemplate" style="display: none">'; + echo '<fieldset>'; + printf('<legend>DEBUG: %s</legend>',$this->template->getDescription()); + echo '<textarea cols="120" rows="20">'; + debug_dump($this); + echo '</textarea>'; + echo '</fieldset>'; + echo '</div>'; + } + } + + public function drawFormSubmitButton() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (! $this->template->isReadOnly()) + // @todo cant use AJAX here, it affects file uploads. + printf('<tr><td colspan="2" style="text-align: center;"><input type="submit" id="create_button" name="submit" value="%s" /></td></tr>', + _('Update Object')); + } + + /** STEP FORM METHODS **/ + + private function drawStepTitle($page) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + if (DEBUGTMP||DEBUGTMPSUB) printf('<font size=-2>* %s [templateNAME:%s]</font><br />',__METHOD__,$this->template->getName()); + + # The default template needs to ask the user for objectClasses. + if ($this->template->isType('default')) { + # The default template only uses 2 pages + $this->pagelast = 2; + + echo '<h4 style="text-align: center;">'; + printf('%s: ',sprintf(_('Step %s of %s'),$page,$this->pagelast)); + + if ($page == 1) + echo _('Container and ObjectClass(es)'); + else + echo _('Specify attributes and values'); + + echo '</h4>'; + + } elseif ($this->template->getDescription()) + printf('<h4 style="text-align: center;">%s (%s)</h4>', + _($this->template->getDescription()), + sprintf(_('Step %s of %s'),$page,$this->pagelast)); + } + + private function drawStepFormStart($page) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (($this->template->isType('default') && $this->template->getContext() == 'create' && $page == 1) || $page < $this->pagelast) { + echo '<form action="cmd.php?cmd=template_engine" method="post" enctype="multipart/form-data" id="entry_form" onsubmit="return submitForm(this)">'; + echo '<div>'; + + } else { + echo '<form action="cmd.php" method="post" enctype="multipart/form-data" id="entry_form" onsubmit="return submitForm(this)">'; + echo '<div>'; + + if ($_SESSION[APPCONFIG]->getValue('confirm','create') && ! get_request('create_base')) + echo '<input type="hidden" name="cmd" value="create_confirm" />'; + else + echo '<input type="hidden" name="cmd" value="create" />'; + } + } + + protected function drawStepForm($page) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + printf('<input type="hidden" name="server_id" value="%s" />',$this->getServerID()); + printf('<input type="hidden" name="template" value="%s" />',$this->template->getID()); + printf('<input type="hidden" name="page" value="%s" />',$page+1); + if (get_request('create_base')) + echo '<input type="hidden" name="create_base" value="true" />'; + + $this->drawHiddenAttributes(); + + if ($this->template->isType('default') && $page == 1) { + echo '</div>'; + + echo '<table class="forminput" border="0" style="margin-left: auto; margin-right: auto;">'; + + $this->drawContainerChooser($this->template->getContainer()); + $this->drawObjectClassChooser(); + + } else { + printf('<input type="hidden" name="container" value="%s" />',$this->template->getContainerEncode(false)); + echo '</div>'; + + echo '<table class="entry" cellspacing="0" border="0" style="margin-left: auto; margin-right: auto;">'; + + $this->drawRDNChooser(); + + if ($this->template->isType('default') && $this->template->getContext() == 'create') + $this->drawStepFormDefaultAttributes(); + else + $this->drawShownAttributes(); + } + + $this->drawStepFormSubmitButton($page); + + echo '</table>'; + } + + private function drawStepFormEnd() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $this->drawFormEnd(); + } + + private function drawStepFormSubmitButton($page) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + echo '<tr>'; + if ($page < $this->pagelast) + printf('<td> </td><td><input type="submit" id="create_button" value="%s" /></td>',_('Proceed >>')); + else + // @todo cant use AJAX here, it affects file uploads. + printf('<td style="text-align: center;"><input type="submit" id="create_button" name="submit" value="%s" /></td>', + _('Create Object')); + echo '</tr>'; + } + + /** + * Given our known objectClass in the template, this will render the required MAY and optional MUST attributes + */ + private function drawStepFormDefaultAttributes() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + # Put required attributes first + $attrs = array(); + $attrs['required'] = array(); + $attrs['optional'] = array(); + foreach ($this->template->getAttributes(true) as $attribute) { + # Skip the objectclass attribute, we already know it in a default creation form. + if ($attribute->getName() == 'objectclass') + continue; + + if ($attribute->isRequired()) + array_push($attrs['required'],$attribute); + + elseif (! $attribute->getValues()) + array_push($attrs['optional'],$attribute); + } + + printf('<tr><th colspan="2">%s</th></tr>',_('Required Attributes')); + if (count($attrs['required'])) + foreach ($attrs['required'] as $attribute) + $this->draw('Template',$attribute); + + else + printf('<tr class="noinput"><td colspan="2" style="text-align: center;">(%s)</td></tr>',_('none')); + + printf('<tr><th colspan="2">%s</th></tr>',_('Optional Attributes')); + if (count($attrs['optional'])) + foreach ($attrs['optional'] as $attribute) + $this->draw('Template',$attribute); + + else + printf('<tr class="noinput"><td colspan="2" style="text-align: center;">(%s)</td></tr>',_('none')); + + echo "\n"; + } + + /** DRAW ATTRIBUTES **/ + + private function drawShownAttributes() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + foreach ($this->template->getAttributesShown() as $attribute) + if (($attribute->getPage() == $this->page) && ($attribute->isRequired() || $attribute->isMay())) { + $this->draw('Template',$attribute); + echo "\n"; + } + } + + /** DRAW PAGE JAVACRIPT */ + + protected function drawJavascript() { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + echo "\n"; + printf('<!-- START: %s -->',__METHOD__); + echo "\n"; + + printf('<script type="text/javascript" src="%sTemplateRender.js"></script>',JSDIR); + printf('<script type="text/javascript" src="%stoAscii.js"></script>',JSDIR); + printf('<script type="text/javascript" src="%sdnChooserPopup.js"></script>',JSDIR); + echo "\n"; + + printf('<!-- START: MAIN FORM VALIDATION: %s -->',__METHOD__); + echo ' +<script type="text/javascript"> +function validateForm(silence) { + var i = 0; + var valid = true; + var components = null;'."\n"; + + foreach ($this->template->getAttributes(true) as $attribute) { + if ($attribute->isVisible() && ($attribute->getOnchange()) || $attribute->isRequired()) { + echo ' + components = getAttributeComponents("new","'.$attribute->getName().'"); + for (i = 0; i < components.length; i++) { + if (window.validate_'.$attribute->getName().') { + valid = (!validate_'.$attribute->getName().'(components[i],silence) || !valid) ? false : true; + } + }'; + echo "\n"; + } + } + + # If we displayed the RDN chooser... + if (! count($this->template->getRDNAttrs())) + echo ' valid = (!document.getElementById(\'rdn_attribute\').value || !valid) ? false : true;'; + + echo ' + return valid; +} +</script>'; + echo "\n"; + printf('<!-- END: MAIN FORM VALIDATION: %s -->',__METHOD__); + echo "\n"; + + $this->drawTemplateJavascript(); + + # For DateAttributes, we need to set some defaults for the js_calendar. + echo '<!-- START: GLOBAL SETTINGS FOR THE js_calendar -->'."\n"; + echo '<script type="text/javascript">'."\n"; + echo 'var defaults = new Array();'."\n"; + printf('var default_date_format = "%s";',$_SESSION[APPCONFIG]->getValue('appearance','date')); + echo "\n"; + echo '</script>'."\n"; + echo '<!-- END: GLOBAL SETTINGS FOR THE js_calendar -->'."\n"; + echo "\n"; + + foreach ($this->template->getAttributesShown() as $attribute) + $this->draw('Javascript',$attribute); + + // @todo We need to sleep here a little bit, because our JS may not have loaded yet. + echo '<script type="text/javascript"> + if (typeof getAttributeComponents == "undefined") + setTimeout("isJSComplete()",1000); + else + validateForm(true); + + function isJSComplete() { + if (typeof getAttributeComponents == "undefined") { + alert("Our Javascript didnt load in time, you may need to reload this page"); + + // Sometimes the alert gives us enough time! + if (typeof getAttributeComponents != "undefined") + alert("Dont bother, our JS is loaded now!"); + } + + validateForm(true); + } + </script>'."\n"; + printf('<!-- END: %s -->',__METHOD__); + echo "\n"; + } + + /** + * Javascript Functions + */ + private function drawTemplateJavascript() { + printf('<!-- START: ONCHANGE PROCESSING %s -->',__METHOD__); + echo "\n"; + foreach ($this->template->getAttributes(true) as $attribute) + if ($onchange = $attribute->getOnChange()) + if (is_array($onchange)) + foreach ($onchange as $value) + $this->template->OnChangeAdd($attribute->getName(),$value); + else + $this->template->OnChangeAdd($attribute->getName(),$onchange); + printf('<!-- END: ONCHANGE PROCESSING %s -->',__METHOD__); + echo "\n"; + + printf('<!-- START: %s -->',__METHOD__); + + echo ' +<script type="text/javascript"> +var attrTrace; +function fill(id,value) { + attrTrace = new Array(); + fillRec(id,value); +} +function fillRec(id,value) { + if (attrTrace[id] == 1) { + return; + } else { + var pre = ""; + var suf = ""; + var i; + attrTrace[id] = 1; + + pla_setComponentValue(pla_getComponentById(id),value); + + // here comes template-specific implementation,generated by php + if (false) {}'; + + foreach ($this->template->getAttributes(true) as $attribute) { + if ($attribute->isVisible() && ($attribute->getOnchange()) || $attribute->isRequired()) { + $attr = $attribute->getName(); + + printf(" + else if ((i = id.indexOf('_%s_')) >= 0) {",$attr); + echo " + pre = id.substring(0,i+1);"; + printf(" + suf = id.substring(i + 1 + '%s'.length,id.length);\n",$attr); + + $this->draw('FillJavascript',$attribute,'id','value'); + + if (isset($attribute->js['autoFill'])) + echo $attribute->js['autoFill']; + + echo " + }\n"; + } + } + + echo '} +} +</script>'; + echo "\n"; + printf('<!-- END: %s -->',__METHOD__); + echo "\n"; + } + + /** ATTRIBUTE TITLE **/ + + protected function drawTitleAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (($this->template->getContext() == 'edit') + && ($attribute->hasBeenModified() || in_array($attribute->getName(),get_request('modified_attrs','REQUEST',false,array())))) + echo '<tr class="updated">'; + else + echo '<tr>'; + + echo '<td class="title">'; + $this->draw('Name',$attribute); + echo '</td>'; + + echo '<td class="note">'; + + # Setup the $attr_note, which will be displayed to the right of the attr name (if any) + if ($_SESSION[APPCONFIG]->getValue('appearance','show_attribute_notes')) + $this->draw('Notes',$attribute); + + echo '</td>'; + echo '</tr>'; + } + + /** ATTRIBUTE LINE **/ + + protected function drawStartValueLineAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (($this->template->getContext() == 'edit') + && ($attribute->hasBeenModified() || in_array($attribute->getName(),get_request('modified_attrs','REQUEST',false,array())))) + echo '<tr class="updated">'; + else + echo '<tr>'; + + echo '<td class="value" colspan="2">'; + } + + protected function drawEndValueLineAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + echo '</td>'; + echo '</tr>'; + + if ($attribute->getSpacer()) + echo '<tr class="spacer"><td colspan="3"> </td></tr>'; + + if (($this->template->getContext() == 'edit') + && ($attribute->hasBeenModified() || in_array($attribute->getName(),get_request('modified_attrs','REQUEST',false,array())))) + echo '<tr class="updated"><td class="bottom" colspan="2"></td></tr>'; + } + + protected function drawTemplateAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $this->draw('Title',$attribute); + $this->draw('TemplateValues',$attribute); + } + + protected function drawTemplateValuesAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s:%s</font><br />',time(),__METHOD__); + + $this->draw('StartValueLine',$attribute); + + # Draws values + $value_count = $attribute->getValueCount(); + for ($i=0;$i<$value_count;$i++) + $this->draw('Value',$attribute,$i); + + if (! $attribute->isInternal()) { + $blankvalue_count = $attribute->getMaxValueCount(); + if ($blankvalue_count < 0) + $blankvalue_count = 1; + + $blankvalue_count -= $value_count; + + for ($j=0;$j<$blankvalue_count;$j++) + $this->draw('Value',$attribute,$i+$j); + + if (($value_count == $blankvalue_count) || ($value_count && $blankvalue_count < 1)) + $this->draw('Menu',$attribute); + } + + $this->draw('EndValueLine',$attribute); + echo "\n"; + } + + /** DRAW ICONS FOR ATTRIBUTES VALUES **/ + + protected function drawIconAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (is_dn_string($val) || $this->getServer()->isDNAttr($attribute->getName())) + $this->draw('DnValueIcon',$attribute,$val); + elseif (is_mail_string($val)) + $this->draw('MailValueIcon',$attribute,$val); + elseif (is_url_string($val)) + $this->draw('UrlValueIcon',$attribute,$val); + + else { + if ($icon = $attribute->getIcon()) + printf('<img src="%s" alt="Icon" style="float: right;" /> ',$icon); + } + } + + protected function drawDnValueIconAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (strlen($val) <= 0) + printf('<img src="%s/ldap-alias.png" alt="Go" style="float: right;" /> ',IMGDIR); + elseif ($this->getServer()->dnExists($val)) + printf('<a href="cmd.php?cmd=template_engine&server_id=%s&dn=%s" title="%s %s"><img src="%s/ldap-alias.png" alt="Go" /></a> ', + $this->getServerID(),rawurlencode($val),_('Go to'),$val,IMGDIR); + else + printf('<a title="%s %s"><img src="%s/nogo.png" alt="Go" /></a> ',_('DN not available'),$val,IMGDIR); + } + + protected function drawMailValueIconAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $img = sprintf('<img src="%s/mail.png" alt="%s" style="float: right;" />',IMGDIR,_('Mail')); + if (strlen($val) <= 0) + echo $img; + else + printf('<a href="mailto:%s">%s</a>',htmlspecialchars($val),$img); + echo ' '; + } + + protected function drawUrlValueIconAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $img = sprintf('<img src="%s/ldap-dc.png" alt="%s" style="float: right;" />',IMGDIR,_('URL')); + $url = explode(' +',$val,2); + + if (strlen($val) <= 0) + echo $img; + else + printf('<a href="%s" onclick="target=\'new\';">%s</a>',htmlspecialchars($url[0]),$img); + echo ' '; + } + + /** DEFAULT ATTRIBUTE RENDERING **/ + + /** javacript */ + + protected function drawJavascriptAttribute($attribute) { + if (! $attribute->needJS()) { + printf('<!-- NO JS REQUIRED FOR %s -->',$attribute->getName()); + echo "\n"; + return; + } + + printf('<!-- START: ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + + echo '<script type="text/javascript">'."\n"; + + echo '// focus'."\n"; + if ($attribute->needJS('focus')) { + printf('function focus_%s(component) {',$attribute->getName()); + echo "\n"; + $this->draw('FocusJavascript',$attribute,'component'); + echo "};\n"; + } + + echo '// blur'."\n"; + if ($attribute->needJS('blur')) { + printf('function blur_%s(component) {',$attribute->getName()); + echo "\n"; + $this->draw('BlurJavascript',$attribute,'component'); + echo "};\n"; + } + + echo '// validate'."\n"; + printf('function validate_%s(component,silence) {',$attribute->getName()); + echo "\n"; + + if ($attribute->needJS('validate')) { + echo ' var valid = true;'; + echo "\n"; + $this->draw('ValidateJavascript',$attribute,'component','silence','valid'); + echo "\n"; + echo ' if (valid) { component.style.backgroundColor = "white"; component.style.color = "black"; }'; + echo ' else { component.style.backgroundColor = \'#FFFFA0\'; component.style.color = "black"; }'; + echo ' return valid;'; + + } else { + echo ' return true;'."\n"; + } + + echo '}'."\n"; + + echo '</script>'."\n"; + + printf('<!-- END: ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + } + + protected function getFocusJavascriptAttribute($attribute,$component) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + return ''; + } + + protected function getBlurJavascriptAttribute($attribute,$component) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $j = "\t".'fill('.$component.'.id,pla_getComponentValue('.$component.'));'."\n"; + $j .= "\t".'validate_'.$attribute->getName().'('.$component.',false);'."\n"; + + return $j; + } + + protected function drawFocusJavascriptAttribute($attribute,$component) { + echo $this->get('FocusJavascript',$attribute,$component); + } + + protected function drawBlurJavascriptAttribute($attribute,$component) { + echo $this->get('BlurJavascript',$attribute,$component); + } + + protected function drawFillJavascriptAttribute($attribute,$component_id,$component_value) { + if ($attribute->needJS('validate')) + printf("\tvalidate_%s(pla_getComponentById(%s),true);\n",$attribute->getName(),$component_id); + } + + protected function drawValidateJavascriptAttribute($attribute,$component,$silence,$var_valid) { + printf('var vals = getAttributeValues("new","%s");',$attribute->getName()); + echo 'if (vals.length <= 0) {'; + printf('%s = false;',$var_valid); + printf('alertError("%s: %s",%s);',_('This attribute is required'),$attribute->getFriendlyName(),$silence); + echo '}'; + echo "\n"; + + printf('var comp = getAttributeComponents("new","%s");',$attribute->getName()); + echo 'for (var i = 0; i < comp.length; i++) {'; + printf('comp[i].style.backgroundColor = "%s";',$var_valid ? 'white' : '#FFFFA0'); + echo '}'; + } + + /** ATTRIBUTE MENU **/ + + protected function drawMenuAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $result = ''; + $item = ''; + + foreach (array('add','modify','rename') as $action) + if ($item = $this->get('MenuItem',$attribute,$action)) + $result .= sprintf('<div class="add_value">%s</div>',$item); + + if (! $result) + return; + + echo '<table class="entry" border="0"><tr><td style="width: 25px;"> </td>'; + printf('<td>%s</td>',$result); + echo '</td>'; + echo '</tr></table>'; + } + + protected function getMenuItemAttribute($attribute,$action) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + # If there is no DN, then this is a creating entry. + if (($this->template->getContext() == 'create') || $this->template->isReadOnly()) + return false; + + switch ($action) { + case 'add': + if ($attribute->isVisible() && ! $attribute->isReadOnly() + && $_SESSION[APPCONFIG]->isCommandAvailable('script','add_value_form')) { + + if ($attribute->haveMoreValues()) + return $this->get('AddValueMenuItem',$attribute); + } + + return ''; + + case 'modify': + if (in_array($attribute->getName(),arrayLower($_SESSION[APPCONFIG]->getValue('modify_member','groupattr')))) { + if ($attribute->isVisible() && ! $attribute->isReadOnly() && ! $attribute->isRDN() + && $_SESSION[APPCONFIG]->isCommandAvailable('script','modify_member_form')) + return $this->get('ModifyMemberMenuItem',$attribute); + } + + return ''; + + case 'rename': + if ($attribute->isVisible() && $attribute->isRDN() && ! $attribute->isReadOnly() + && $_SESSION[APPCONFIG]->isCommandAvailable('script','rename_form') + && $_SESSION[APPCONFIG]->isCommandAvailable('script','rename')) + return $this->get('RenameMenuItem',$attribute); + + return ''; + + default: + return false; + } + } + + protected function getAddValueMenuItemAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href_parm = htmlspecialchars(sprintf('cmd=add_value_form&server_id=%s&dn=%s&attr=%s', + $this->getServerID(),$this->template->getDNEncode(),rawurlencode($attribute->getName(false)))); + + if (isAjaxEnabled()) + return sprintf('(<a href="cmd.php?%s" title="%s %s" onclick="return ajDISPLAY(\'ADDVALUE%s\',\'%s&raw=1\',\'%s\',1);">%s</a>)', + $href_parm,_('Add an additional value to attribute'),$attribute->getName(false),$attribute->getName(), + $href_parm,str_replace('\'','\\\'',_('Add Value to Attribute')),_('add value')); + else + return sprintf('(<a href="cmd.php?%s" title="%s %s">%s</a>)', + $href_parm,_('Add an additional value to attribute'),$attribute->getName(false),_('add value')); + } + + protected function getAddValueMenuItemObjectClassAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href_parm = htmlspecialchars(sprintf('cmd=add_value_form&server_id=%s&dn=%s&attr=%s', + $this->getServerID(),$this->template->getDNEncode(),rawurlencode($attribute->getName(false)))); + + if (isAjaxEnabled()) + return sprintf('(<a href="cmd.php?%s" title="%s %s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>)', + $href_parm,_('Add an additional value to attribute'),$attribute->getName(false), + $href_parm,str_replace('\'','\\\'',_('Add Value to Attribute')),_('add value')); + else + return sprintf('(<a href="cmd.php?%s" title="%s %s">%s</a>)', + $href_parm,_('Add an additional value to attribute'),$attribute->getName(false),_('add value')); + } + + protected function getModifyMemberMenuItemAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd=modify_member_form&server_id=%s&dn=%s&attr=%s', + $this->getServerID(),$this->template->getDNEncode(),rawurlencode($attribute->getName())); + + if (isAjaxEnabled()) + return sprintf('(<a href="cmd.php?%s" title="%s: %s" onclick="return ajDISPLAY(\'BODY\',\'%s\',\'%s\');">%s</a>)', + htmlspecialchars($href),_('Modify members for'),$this->template->getDN(), + htmlspecialchars($href),str_replace('\'','\\\'',_('Modify group membership')), + _('modify group members')); + else + return sprintf('(<a href="cmd.php?%s" title="%s: %s">%s</a>)', + htmlspecialchars($href),_('Modify members for'),$this->template->getDN(),_('modify group members')); + } + + protected function getRenameMenuItemAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $href = sprintf('cmd.php?cmd=rename_form&server_id=%s&dn=%s&template=%s', + $this->getServerID(),$this->template->getDNEncode(),$this->template->getID()); + + return sprintf('<small>(<a href="%s">%s</a>)</small>',htmlspecialchars($href),_('rename')); + } + + /** values **/ + + protected function drawValueAttribute($attribute,$i) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if ($attribute->isMultiple() && $i > 0) + return; + + $val = $attribute->getValue($i); + + if ($attribute->isVisible()) { + echo '<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td class="icon" style="width: 25px;">'; + $this->draw('Icon',$attribute,$val); + echo '</td>'; + + echo '<td valign="top">'; + } + + if ($attribute->isInternal()) + $this->draw('FormReadOnlyValue',$attribute,$i); + else + $this->draw('FormValue',$attribute,$i); + + if ($attribute->isVisible()) { + echo '</td>'; + + echo '<td valign="top" style="text-align: right;">'; + $this->draw('RequiredSymbol',$attribute); + echo '</td></tr></table>'; + } + echo "\n"; + } + + # @todo for userPasswords, we need to capture the default value of select lists, without specifying <default> + protected function drawHelperAttribute($attribute,$i) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $params = $attribute->getHelper(); + + # We take the first <id> only + $id = isset($params['id']) ? $params['id'] : ''; + if (is_array($id)) { + system_message(array( + 'title'=>_('Too many arguments'), + 'body'=>sprintf('%s (<b>%s</b>)',_('Helper attribute has too many ID values, only the first one is used'),count($id)), + 'type'=>'warn')); + + $id = $id[0]; + } + + # We take the first <display> only + $display = isset($params['display']) ? $params['display'] : ''; + if (is_array($display)) { + system_message(array( + 'title'=>_('Too many arguments'), + 'body'=>sprintf('%s (<b>%s</b>)',_('Helper attribute has too many DISPLAY values, only the first one is used'),count($display)), + 'type'=>'warn')); + + $display = $display[0]; + } + + # We take the first <default> only + $default = isset($params['default']) ? $params['default'] : ''; + if (is_array($default)) { + system_message(array( + 'title'=>_('Too many arguments'), + 'body'=>sprintf('%s (<b>%s</b>)',_('Helper attribute has too many DISPLAY values, only the first one is used'),count($default)), + 'type'=>'warn')); + + $default = $default[0]; + } + + if ($attribute->getHelperValue()) + $vals = $this->get('Default',$attribute, + $this->template->getContainer() ? $this->template->getContainer() : $this->getServer()->getContainerPath($this->template->getDN()), + 'helpervalue'); + else + $vals = isset($params['value']) ? $params['value'] : ''; + + if ($this->template->getContext() == 'create') + $dn = $this->template->getContainer(); + else + $dn = $this->template->getDN(); + + if (is_array($vals) && count($vals) > 0) { + $found = false; + + printf('<select name="%s[%s][%s]" id="%s_%s_%s">', + $id,htmlspecialchars($attribute->getName()),$i, + $id,htmlspecialchars($attribute->getName()),$i); + + foreach ($vals as $v) { + printf('<option value="%s" %s>%s</option>',$v,($v == $default) ? 'selected="selected"' : '',$v); + + if ($v == $default) + $found = true; + } + + if (! $found) + printf('<option value="%s" selected="selected">%s</option>',$default,$default ? $default : ' '); + + echo '</select>'; + + } else { + # Vals must be an empty array. + if (is_array($vals)) + $vals = ''; + + printf('<input type="text" name="%s[%s][%s]" id="%s_%s_%s" value="%s" size="4" />', + $id,htmlspecialchars($attribute->getName()),$i, + $id,htmlspecialchars($attribute->getName()),$i, + htmlspecialchars($vals)); + } + + if ($display) { + echo '<div class="helper">'; + printf('<span class="hint">%s</span>',$display); + echo '</div>'; + } + } + + protected function drawRequiredSymbolAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if ($attribute->isRequired() && ! $attribute->isReadOnly()) + echo '*'; + } + + /** BINARY ATTRIBUTE RENDERING **/ + + #@todo do we need a $this->drawJavascriptAttribute($attribute) here too ? + protected function drawJavascriptBinaryAttribute($attribute) { + # If there are no values, then this javascript doesnt need to be drawn. + if (! $attribute->getValues()) + return; + + static $drawn = false; + + # This JS may have been rendered by multiple Binary attributes + if ($drawn) + return; + else + $drawn = true; + + printf('<!-- START: BINARY ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + + echo '<!-- This form is submitted by JavaScript when the user clicks "Delete attribute" on a binary attribute -->'; + echo '<form id="delete_attribute_form" action="cmd.php?cmd=delete_attr" method="post">'; + printf('<input type="hidden" name="server_id" value="%s" />',$this->getServerID()); + printf('<input type="hidden" name="dn" value="%s" />',$this->template->getDNEncode(false)); + printf('<input type="hidden" name="template" value="%s" />',$this->template->getID()); + echo '<input type="hidden" name="attr" value="FILLED IN BY JAVASCRIPT" />'; + echo '<input type="hidden" name="index" value="FILLED IN BY JAVASCRIPT" />'; + echo '</form>'; + + echo ' +<script type="text/javascript"> +function deleteAttribute(attrName,friendlyName,i) +{ + if (confirm("'._('Really delete value from attribute').' \'" + friendlyName + "\'?")) { + document.getElementById(\'delete_attribute_form\').attr.value = attrName; + document.getElementById(\'delete_attribute_form\').index.value = i; + document.getElementById(\'delete_attribute_form\').submit(); + } +} +</script>'; + echo "\n"; + + printf('<!-- END: BINARY ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + } + + /** DATE ATTRIBUTE RENDERING **/ + + protected function drawJavaScriptDateAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + printf('<!-- START: DATE ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + + $this->drawJavaScriptAttribute($attribute); + + static $drawn = false; + + # This JS may have been rendered by multiple Date attributes + if (! $drawn) { + printf('<script type="text/javascript" src="%sjscalendar/lang/calendar-en.js"></script>',JSDIR); + printf('<script type="text/javascript" src="%sjscalendar/calendar-setup.js"></script>',JSDIR); + printf('<script type="text/javascript" src="%sdate_selector.js"></script>',JSDIR); + + $drawn = true; + } + + $config = array(); + $config['date'] = array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs')); + $config['time'] = array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs_showtime')); + $config['format'] = $_SESSION[APPCONFIG]->getValue('appearance','date'); + + if (isset($config['date'][$attribute->getName()])) + $config['format'] = $config['date'][$attribute->getName()]; + + for ($i=0;$i<=$attribute->getValueCount();$i++) { + printf('<script type="text/javascript">defaults[\'new_values_%s_%s\'] = \'%s\';</script>',$attribute->getName(),$i,$config['format']); + + if (in_array_ignore_case($attribute->getName(),array_keys($config['time'])) && ($config['time'][$attribute->getName()])) + printf('<script type="text/javascript">defaults[\'f_time_%s_%s\'] = \'%s\';</script>',$attribute->getName(),$i,'true'); + + echo "\n"; + } + + printf('<!-- END: DATE ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + } + + /** + * Draws an HTML date selector button which, when clicked, pops up a date selector dialog. + */ + protected function drawSelectorPopupDateAttribute($attribute,$i) { + printf('<a href="javascript:dateSelector(\'%s_%s\');" title="%s"><img src="%s/calendar.png" alt="Calendar" class="chooser" id="f_trigger_%s_%s" style="cursor: pointer;" /></a>', + $attribute->getName(),$i,_('Click to popup a dialog to select a date graphically'),IMGDIR,$attribute->getName(),$i); + } + + /** DN ATTRIBUTES **/ + + protected function drawIconDnAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + $this->draw('DnValueIcon',$attribute,$val); + } + + /** OBJECT CLASS ATTRIBUTE **/ + + protected function drawIconObjectClassAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (! $_SESSION[APPCONFIG]->getValue('appearance','show_schema_link') || !$_SESSION[APPCONFIG]->isCommandAvailable('script','schema')) + return; + + if (strlen($val) > 0) { + $href = sprintf('cmd.php?cmd=schema&server_id=%s&view=objectclasses&viewvalue=%s', + $this->getServerID(),$val); + printf('<a href="%s" title="%s"><img src="%s/info.png" alt="Info" /></a> ', + htmlspecialchars($href),_('View the schema description for this objectClass'),IMGDIR); + } + } + + /** PASSWORD ATTRIBUTES **/ + + protected function drawJavascriptPasswordAttribute($attribute) { + static $drawn = array(); + + # This JS may have been rendered by multiple Binary attributes + if (isset($drawn[$attribute->getName()]) && $drawn[$attribute->getName()]) + return; + else + $drawn[$attribute->getName()] = true; + + printf('<!-- START: PASSWORD ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + + $this->drawJavascriptAttribute($attribute); + + # Add the javascript so we can call check password later. + echo ' +<script type="text/javascript"> + function passwordComparePopup(component_id,attr) { + mywindow = open(\'password_checker.php\',\'myname\',\'resizable=no,width=500,height=200,scrollbars=1\'); + mywindow.location.href = \'password_checker.php?componentid=\'+component_id+\'&attr=\'+attr; + if (mywindow.opener == null) mywindow.opener = self; + } +</script>'; + echo "\n"; + + printf('<!-- END: PASSWORD ATTRIBUTE %s (%s)-->',__METHOD__,$attribute->getName()); + echo "\n"; + } + + protected function drawCheckLinkPasswordAttribute($attribute,$component_id) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + printf('<small><a href="javascript:passwordComparePopup(\'%s\',\'%s\')">%s...</a></small><br />', + $component_id,$attribute->getName(),_('Check password')); + } + + /** RANDOM PASSWORD **/ + + /** + * This will draw the javascript that displays to the user the random password generated + * + * @todo This function doesnt work well if there are more than 1 RandomPasswordAttributes on the form for the same attribute (unlikely situation) + */ + protected function drawJavascriptRandomPasswordAttribute($attribute) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + printf("\n<!-- START: %s -->\n",__METHOD__); + $this->drawJavascriptPasswordAttribute($attribute); + + $pwd = password_generate(); + $pwd = str_replace("\\","\\\\",$pwd); + $pwd = str_replace("'","\\'",$pwd); + + printf("\n<!-- %s -->\n",__METHOD__); + echo '<script type="text/javascript">'."\n"; + echo 'var i = 0;'."\n"; + printf('var component = document.getElementById(\'new_values_%s_\'+i);',$attribute->getName()); + echo "\n"; + echo 'while (component) {'."\n"; + echo ' if (!component.value) {'."\n"; + printf(' component.value = \'%s\';',$pwd); + echo "\n"; + printf(' alert(\'%s:\n%s\');',_('A random password was generated for you'),$pwd); + echo "\n"; + echo ' };'."\n"; + echo ' i++;'."\n"; + printf(' component = document.getElementById(\'new_values_%s_\'+i);',$attribute->getName()); + echo "\n"; + # It seems that JS gets stuck in a loop if there isnt a command here? - normally this alert isnt shown. + printf('alert("It seems another element was found, PLA hasnt been configured for this situation Component: "+component.value+" I:"+i);',$attribute->getName()); + echo "\n"; + echo '}'."\n"; + echo '</script>'; + printf("\n<!-- END: %s -->\n",__METHOD__); + } + + protected function drawDefaultHelperPasswordAttribute($attribute,$i) { + $id = 'enc'; + + if ($val = $attribute->getValue($i)) + $default = get_enc_type($val); + else + $default = $this->getServer()->getValue('appearance','password_hash_custom'); + + if (! $attribute->getPostValue()) + printf('<input type="hidden" name="post_value[%s][]" value="%s" />',$attribute->getName(),$i); + + printf('<select name="%s[%s][%s]" id="%s_%s_%s">', + $id,htmlspecialchars($attribute->getName()),$i, + $id,htmlspecialchars($attribute->getName()),$i); + + foreach (password_types() as $v => $display) + printf('<option value="%s" %s>%s</option>',$v,($v == $default) ? 'selected="selected"' : '',$display); + + echo '</select>'; + } + + protected function drawDefaultHelperSambaPasswordAttribute($attribute,$i) { + $id = 'enc'; + + if (! $attribute->getPostValue()) + printf('<input type="hidden" name="post_value[%s][]" value="%s" />',$attribute->getName(),$i); + + switch ($attribute->getName()) { + case 'sambalmpassword' : $enc = 'lm'; break; + case 'sambantpassword' : $enc = 'nt'; break; + + default: + return ''; + } + + printf('<input type="hidden" name="%s[%s][%s]" id="%s_%s_%s" value="%s" />', + $id,htmlspecialchars($attribute->getName()),$i, + $id,htmlspecialchars($attribute->getName()),$i,$enc); + } + + /** SELECTION ATTRIBUTE RENDERING **/ + + protected function drawIconSelectionAttribute($attribute,$val) { + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + if (! $attribute->isMultiple() || $attribute->isReadOnly()) + $this->drawIconAttribute($attribute,$val); + } + + protected function getMenuItemSelectionAttribute($attribute,$i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + + if (DEBUGTMP) printf('<font size=-2>%s</font><br />',__METHOD__); + + switch ($i) { + case 'add': + if (! $attribute->isMultiple()) + return $this->getMenuItemAttribute($attribute,$i); + else + return ''; + + case 'modify': + return ''; + + default: + return $this->getMenuItemAttribute($attribute,$i); + } + } +} +?> diff --git a/devgerrit/root/config/apache2_gerrit.conf b/devgerrit/root/config/apache2_gerrit.conf new file mode 100755 index 0000000..e151131 --- /dev/null +++ b/devgerrit/root/config/apache2_gerrit.conf @@ -0,0 +1,17 @@ +<VirtualHost *:80> +DocumentRoot /var/www/html + +ErrorLog ${APACHE_LOG_DIR}/error.log +CustomLog ${APACHE_LOG_DIR}/access.log combined + +ServerName http://127.0.0.1/gerrit/ +ProxyRequests Off +ProxyVia Off +ProxyPreserveHost On +AllowEncodedSlashes On +<Proxy *> +Order deny,allow +Allow from all +</Proxy> + ProxyPass /gerrit http://127.0.0.1:8081/gerrit nocanon +</VirtualHost> diff --git a/devgerrit/root/config/default.settings.php b/devgerrit/root/config/default.settings.php new file mode 100755 index 0000000..580cc38 --- /dev/null +++ b/devgerrit/root/config/default.settings.php @@ -0,0 +1,553 @@ +<?php + +/** + * @file + * Drupal site-specific configuration file. + * + * IMPORTANT NOTE: + * This file may have been set to read-only by the Drupal installation program. + * If you make changes to this file, be sure to protect it again after making + * your modifications. Failure to remove write permissions to this file is a + * security risk. + * + * The configuration file to be loaded is based upon the rules below. However + * if the multisite aliasing file named sites/sites.php is present, it will be + * loaded, and the aliases in the array $sites will override the default + * directory rules below. See sites/example.sites.php for more information about + * aliases. + * + * The configuration directory will be discovered by stripping the website's + * hostname from left to right and pathname from right to left. The first + * configuration file found will be used and any others will be ignored. If no + * other configuration file is found then the default configuration file at + * 'sites/default' will be used. + * + * For example, for a fictitious site installed at + * http://www.drupal.org:8080/mysite/test/, the 'settings.php' file is searched + * for in the following directories: + * + * - sites/8080.www.drupal.org.mysite.test + * - sites/www.drupal.org.mysite.test + * - sites/drupal.org.mysite.test + * - sites/org.mysite.test + * + * - sites/8080.www.drupal.org.mysite + * - sites/www.drupal.org.mysite + * - sites/drupal.org.mysite + * - sites/org.mysite + * + * - sites/8080.www.drupal.org + * - sites/www.drupal.org + * - sites/drupal.org + * - sites/org + * + * - sites/default + * + * Note that if you are installing on a non-standard port number, prefix the + * hostname with that number. For example, + * http://www.drupal.org:8080/mysite/test/ could be loaded from + * sites/8080.www.drupal.org.mysite.test/. + * + * @see example.sites.php + * @see conf_path() + */ + +/** + * Database settings: + * + * The $databases array specifies the database connection or + * connections that Drupal may use. Drupal is able to connect + * to multiple databases, including multiple types of databases, + * during the same request. + * + * Each database connection is specified as an array of settings, + * similar to the following: + * @code + * array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Some database engines support transactions. In order to enable + * transaction support for a given database, set the 'transactions' key + * to TRUE. To disable it, set it to FALSE. Note that the default value + * varies by driver. For MySQL, the default is FALSE since MyISAM tables + * do not support transactions. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array(); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/ini.list.php + * See drupal_environment_initialize() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['site_name'] = 'My Drupal site'; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'; + +/** + * By default the page request process will return a fast 404 page for missing + * files if they match the regular expression set in '404_fast_paths' and not + * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in + * the Drupal system log. + * + * You can choose to return a fast 404 page earlier for missing pages (as soon + * as settings.php is loaded) by uncommenting the line below. This speeds up + * server response time when loading 404 error pages and prevents the 404 error + * from being logged in the Drupal system log. In order to prevent valid pages + * such as image styles and other generated content that may match the + * '404_fast_html' regular expression from returning 404 errors, it is necessary + * to add them to the '404_fast_paths_exclude' regular expression above. Make + * sure that you understand the effects of this feature before uncommenting the + * line below. + */ +# drupal_fast_404(); + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $conf['proxy_server'] = ''; +# $conf['proxy_port'] = 8080; +# $conf['proxy_username'] = ''; +# $conf['proxy_password'] = ''; +# $conf['proxy_user_agent'] = ''; +# $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; diff --git a/devgerrit/root/config/gerrit.config b/devgerrit/root/config/gerrit.config new file mode 100755 index 0000000..cc601eb --- /dev/null +++ b/devgerrit/root/config/gerrit.config @@ -0,0 +1,48 @@ +[gerrit] + basePath = git + canonicalWebUrl = http://127.0.0.1/gerrit +[plugins] + allowRemoteAdmin = true +[index] + type = LUCENE +[auth] + type = LDAP +[sendemail] + smtpServer = + smtpUser = + from = + threadPoolSize = 2 +[container] + user = gerrit + javaHome = /usr/lib/jvm/java-1.7.0_60-oracle-x64/jre +[sshd] + listenAddress = *:29418 +[httpd] + listenUrl = proxy-http://127.0.0.1:8081/gerrit +[cache] + directory = cache +[gitweb] + cgi = /usr/share/gitweb/gitweb.cgi +[database] + type = mysql + hostname = localhost + port = 3306 + database = reviewdb + username = gerrit + password = gerritpassword +[ldap] + server = ldap://127.0.0.1 + username = cn=admin,dc=example,dc=com + password = opensuse + sslVerify = false + referral = follow + accountScope = subtree + accountBase = ou=people,dc=example,dc=com + accountPattern = (&(objectClass=inetOrgPerson)(uid=${username})) + accountFullName = displayName + accountEmailAddress = mail + + groupName = ${cn} + groupBase = ou=group,dc=example,dc=com + groupPattern = (&(objectClass=groupOfNames)(cn=${groupname})) + groupMemberPattern = (&(objectClass=groupOfNames)(member=${member})) diff --git a/devgerrit/root/config/settings.php b/devgerrit/root/config/settings.php new file mode 100755 index 0000000..580cc38 --- /dev/null +++ b/devgerrit/root/config/settings.php @@ -0,0 +1,553 @@ +<?php + +/** + * @file + * Drupal site-specific configuration file. + * + * IMPORTANT NOTE: + * This file may have been set to read-only by the Drupal installation program. + * If you make changes to this file, be sure to protect it again after making + * your modifications. Failure to remove write permissions to this file is a + * security risk. + * + * The configuration file to be loaded is based upon the rules below. However + * if the multisite aliasing file named sites/sites.php is present, it will be + * loaded, and the aliases in the array $sites will override the default + * directory rules below. See sites/example.sites.php for more information about + * aliases. + * + * The configuration directory will be discovered by stripping the website's + * hostname from left to right and pathname from right to left. The first + * configuration file found will be used and any others will be ignored. If no + * other configuration file is found then the default configuration file at + * 'sites/default' will be used. + * + * For example, for a fictitious site installed at + * http://www.drupal.org:8080/mysite/test/, the 'settings.php' file is searched + * for in the following directories: + * + * - sites/8080.www.drupal.org.mysite.test + * - sites/www.drupal.org.mysite.test + * - sites/drupal.org.mysite.test + * - sites/org.mysite.test + * + * - sites/8080.www.drupal.org.mysite + * - sites/www.drupal.org.mysite + * - sites/drupal.org.mysite + * - sites/org.mysite + * + * - sites/8080.www.drupal.org + * - sites/www.drupal.org + * - sites/drupal.org + * - sites/org + * + * - sites/default + * + * Note that if you are installing on a non-standard port number, prefix the + * hostname with that number. For example, + * http://www.drupal.org:8080/mysite/test/ could be loaded from + * sites/8080.www.drupal.org.mysite.test/. + * + * @see example.sites.php + * @see conf_path() + */ + +/** + * Database settings: + * + * The $databases array specifies the database connection or + * connections that Drupal may use. Drupal is able to connect + * to multiple databases, including multiple types of databases, + * during the same request. + * + * Each database connection is specified as an array of settings, + * similar to the following: + * @code + * array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'port' => 3306, + * 'prefix' => 'myprefix_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * The "driver" property indicates what Drupal database driver the + * connection should use. This is usually the same as the name of the + * database type, such as mysql or sqlite, but not always. The other + * properties will vary depending on the driver. For SQLite, you must + * specify a database file name in a directory that is writable by the + * webserver. For most other drivers, you must specify a + * username, password, host, and database name. + * + * Some database engines support transactions. In order to enable + * transaction support for a given database, set the 'transactions' key + * to TRUE. To disable it, set it to FALSE. Note that the default value + * varies by driver. For MySQL, the default is FALSE since MyISAM tables + * do not support transactions. + * + * For each database, you may optionally specify multiple "target" databases. + * A target database allows Drupal to try to send certain queries to a + * different database if it can but fall back to the default connection if not. + * That is useful for master/slave replication, as Drupal may try to connect + * to a slave server when appropriate and if one is not available will simply + * fall back to the single master server. + * + * The general format for the $databases array is as follows: + * @code + * $databases['default']['default'] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['default']['slave'][] = $info_array; + * $databases['extra']['default'] = $info_array; + * @endcode + * + * In the above example, $info_array is an array of settings described above. + * The first line sets a "default" database that has one master database + * (the second level default). The second and third lines create an array + * of potential slave databases. Drupal will select one at random for a given + * request as needed. The fourth line creates a new database with a name of + * "extra". + * + * For a single database configuration, the following is sufficient: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => 'main_', + * 'collation' => 'utf8_general_ci', + * ); + * @endcode + * + * You can optionally set prefixes for some or all database table names + * by using the 'prefix' setting. If a prefix is specified, the table + * name will be prepended with its value. Be sure to use valid database + * characters only, usually alphanumeric and underscore. If no prefixes + * are desired, leave it as an empty string ''. + * + * To have all database names prefixed, set 'prefix' as a string: + * @code + * 'prefix' => 'main_', + * @endcode + * To provide prefixes for specific tables, set 'prefix' as an array. + * The array's keys are the table names and the values are the prefixes. + * The 'default' element is mandatory and holds the prefix for any tables + * not specified elsewhere in the array. Example: + * @code + * 'prefix' => array( + * 'default' => 'main_', + * 'users' => 'shared_', + * 'sessions' => 'shared_', + * 'role' => 'shared_', + * 'authmap' => 'shared_', + * ), + * @endcode + * You can also use a reference to a schema/database as a prefix. This may be + * useful if your Drupal installation exists in a schema that is not the default + * or you want to access several databases from the same code base at the same + * time. + * Example: + * @code + * 'prefix' => array( + * 'default' => 'main.', + * 'users' => 'shared.', + * 'sessions' => 'shared.', + * 'role' => 'shared.', + * 'authmap' => 'shared.', + * ); + * @endcode + * NOTE: MySQL and SQLite's definition of a schema is a database. + * + * Advanced users can add or override initial commands to execute when + * connecting to the database server, as well as PDO connection settings. For + * example, to enable MySQL SELECT queries to exceed the max_join_size system + * variable, and to reduce the database connection timeout to 5 seconds: + * + * @code + * $databases['default']['default'] = array( + * 'init_commands' => array( + * 'big_selects' => 'SET SQL_BIG_SELECTS=1', + * ), + * 'pdo' => array( + * PDO::ATTR_TIMEOUT => 5, + * ), + * ); + * @endcode + * + * WARNING: These defaults are designed for database portability. Changing them + * may cause unexpected behavior, including potential data loss. + * + * @see DatabaseConnection_mysql::__construct + * @see DatabaseConnection_pgsql::__construct + * @see DatabaseConnection_sqlite::__construct + * + * Database configuration format: + * @code + * $databases['default']['default'] = array( + * 'driver' => 'mysql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'pgsql', + * 'database' => 'databasename', + * 'username' => 'username', + * 'password' => 'password', + * 'host' => 'localhost', + * 'prefix' => '', + * ); + * $databases['default']['default'] = array( + * 'driver' => 'sqlite', + * 'database' => '/path/to/databasefilename', + * ); + * @endcode + */ +$databases = array(); + +/** + * Access control for update.php script. + * + * If you are updating your Drupal installation using the update.php script but + * are not logged in using either an account with the "Administer software + * updates" permission or the site maintenance account (the account that was + * created during installation), you will need to modify the access check + * statement below. Change the FALSE to a TRUE to disable the access check. + * After finishing the upgrade, be sure to open this file again and change the + * TRUE back to a FALSE! + */ +$update_free_access = FALSE; + +/** + * Salt for one-time login links and cancel links, form tokens, etc. + * + * This variable will be set to a random value by the installer. All one-time + * login links will be invalidated if the value is changed. Note that if your + * site is deployed on a cluster of web servers, you must ensure that this + * variable has the same value on each server. If this variable is empty, a hash + * of the serialized database credentials will be used as a fallback salt. + * + * For enhanced security, you may set this variable to a value using the + * contents of a file outside your docroot that is never saved together + * with any backups of your Drupal files and database. + * + * Example: + * $drupal_hash_salt = file_get_contents('/home/example/salt.txt'); + * + */ +$drupal_hash_salt = ''; + +/** + * Base URL (optional). + * + * If Drupal is generating incorrect URLs on your site, which could + * be in HTML headers (links to CSS and JS files) or visible links on pages + * (such as in menus), uncomment the Base URL statement below (remove the + * leading hash sign) and fill in the absolute URL to your Drupal installation. + * + * You might also want to force users to use a given domain. + * See the .htaccess file for more information. + * + * Examples: + * $base_url = 'http://www.example.com'; + * $base_url = 'http://www.example.com:8888'; + * $base_url = 'http://www.example.com/drupal'; + * $base_url = 'https://www.example.com:8888/drupal'; + * + * It is not allowed to have a trailing slash; Drupal will add it + * for you. + */ +# $base_url = 'http://www.example.com'; // NO trailing slash! + +/** + * PHP settings: + * + * To see what PHP settings are possible, including whether they can be set at + * runtime (by using ini_set()), read the PHP documentation: + * http://www.php.net/manual/ini.list.php + * See drupal_environment_initialize() in includes/bootstrap.inc for required + * runtime settings and the .htaccess file for non-runtime settings. Settings + * defined there should not be duplicated here so as to avoid conflict issues. + */ + +/** + * Some distributions of Linux (most notably Debian) ship their PHP + * installations with garbage collection (gc) disabled. Since Drupal depends on + * PHP's garbage collection for clearing sessions, ensure that garbage + * collection occurs by using the most common settings. + */ +ini_set('session.gc_probability', 1); +ini_set('session.gc_divisor', 100); + +/** + * Set session lifetime (in seconds), i.e. the time from the user's last visit + * to the active session may be deleted by the session garbage collector. When + * a session is deleted, authenticated users are logged out, and the contents + * of the user's $_SESSION variable is discarded. + */ +ini_set('session.gc_maxlifetime', 200000); + +/** + * Set session cookie lifetime (in seconds), i.e. the time from the session is + * created to the cookie expires, i.e. when the browser is expected to discard + * the cookie. The value 0 means "until the browser is closed". + */ +ini_set('session.cookie_lifetime', 2000000); + +/** + * If you encounter a situation where users post a large amount of text, and + * the result is stripped out upon viewing but can still be edited, Drupal's + * output filter may not have sufficient memory to process it. If you + * experience this issue, you may wish to uncomment the following two lines + * and increase the limits of these variables. For more information, see + * http://php.net/manual/pcre.configuration.php. + */ +# ini_set('pcre.backtrack_limit', 200000); +# ini_set('pcre.recursion_limit', 200000); + +/** + * Drupal automatically generates a unique session cookie name for each site + * based on its full domain name. If you have multiple domains pointing at the + * same Drupal site, you can either redirect them all to a single domain (see + * comment in .htaccess), or uncomment the line below and specify their shared + * base domain. Doing so assures that users remain logged in as they cross + * between your various domains. Make sure to always start the $cookie_domain + * with a leading dot, as per RFC 2109. + */ +# $cookie_domain = '.example.com'; + +/** + * Variable overrides: + * + * To override specific entries in the 'variable' table for this site, + * set them here. You usually don't need to use this feature. This is + * useful in a configuration file for a vhost or directory, rather than + * the default settings.php. Any configuration setting from the 'variable' + * table can be given a new value. Note that any values you provide in + * these variable overrides will not be modifiable from the Drupal + * administration interface. + * + * The following overrides are examples: + * - site_name: Defines the site's name. + * - theme_default: Defines the default theme for this site. + * - anonymous: Defines the human-readable name of anonymous users. + * Remove the leading hash signs to enable. + */ +# $conf['site_name'] = 'My Drupal site'; +# $conf['theme_default'] = 'garland'; +# $conf['anonymous'] = 'Visitor'; + +/** + * A custom theme can be set for the offline page. This applies when the site + * is explicitly set to maintenance mode through the administration page or when + * the database is inactive due to an error. It can be set through the + * 'maintenance_theme' key. The template file should also be copied into the + * theme. It is located inside 'modules/system/maintenance-page.tpl.php'. + * Note: This setting does not apply to installation and update pages. + */ +# $conf['maintenance_theme'] = 'bartik'; + +/** + * Reverse Proxy Configuration: + * + * Reverse proxy servers are often used to enhance the performance + * of heavily visited sites and may also provide other site caching, + * security, or encryption benefits. In an environment where Drupal + * is behind a reverse proxy, the real IP address of the client should + * be determined such that the correct client IP address is available + * to Drupal's logging, statistics, and access management systems. In + * the most simple scenario, the proxy server will add an + * X-Forwarded-For header to the request that contains the client IP + * address. However, HTTP headers are vulnerable to spoofing, where a + * malicious client could bypass restrictions by setting the + * X-Forwarded-For header directly. Therefore, Drupal's proxy + * configuration requires the IP addresses of all remote proxies to be + * specified in $conf['reverse_proxy_addresses'] to work correctly. + * + * Enable this setting to get Drupal to determine the client IP from + * the X-Forwarded-For header (or $conf['reverse_proxy_header'] if set). + * If you are unsure about this setting, do not have a reverse proxy, + * or Drupal operates in a shared hosting environment, this setting + * should remain commented out. + * + * In order for this setting to be used you must specify every possible + * reverse proxy IP address in $conf['reverse_proxy_addresses']. + * If a complete list of reverse proxies is not available in your + * environment (for example, if you use a CDN) you may set the + * $_SERVER['REMOTE_ADDR'] variable directly in settings.php. + * Be aware, however, that it is likely that this would allow IP + * address spoofing unless more advanced precautions are taken. + */ +# $conf['reverse_proxy'] = TRUE; + +/** + * Specify every reverse proxy IP address in your environment. + * This setting is required if $conf['reverse_proxy'] is TRUE. + */ +# $conf['reverse_proxy_addresses'] = array('a.b.c.d', ...); + +/** + * Set this value if your proxy server sends the client IP in a header + * other than X-Forwarded-For. + */ +# $conf['reverse_proxy_header'] = 'HTTP_X_CLUSTER_CLIENT_IP'; + +/** + * Page caching: + * + * By default, Drupal sends a "Vary: Cookie" HTTP header for anonymous page + * views. This tells a HTTP proxy that it may return a page from its local + * cache without contacting the web server, if the user sends the same Cookie + * header as the user who originally requested the cached page. Without "Vary: + * Cookie", authenticated users would also be served the anonymous page from + * the cache. If the site has mostly anonymous users except a few known + * editors/administrators, the Vary header can be omitted. This allows for + * better caching in HTTP proxies (including reverse proxies), i.e. even if + * clients send different cookies, they still get content served from the cache. + * However, authenticated users should access the site directly (i.e. not use an + * HTTP proxy, and bypass the reverse proxy if one is used) in order to avoid + * getting cached pages from the proxy. + */ +# $conf['omit_vary_cookie'] = TRUE; + +/** + * CSS/JS aggregated file gzip compression: + * + * By default, when CSS or JS aggregation and clean URLs are enabled Drupal will + * store a gzip compressed (.gz) copy of the aggregated files. If this file is + * available then rewrite rules in the default .htaccess file will serve these + * files to browsers that accept gzip encoded content. This allows pages to load + * faster for these users and has minimal impact on server load. If you are + * using a webserver other than Apache httpd, or a caching reverse proxy that is + * configured to cache and compress these files itself you may want to uncomment + * one or both of the below lines, which will prevent gzip files being stored. + */ +# $conf['css_gzip_compression'] = FALSE; +# $conf['js_gzip_compression'] = FALSE; + +/** + * String overrides: + * + * To override specific strings on your site with or without enabling the Locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'][''] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); + +/** + * + * IP blocking: + * + * To bypass database queries for denied IP addresses, use this setting. + * Drupal queries the {blocked_ips} table by default on every page request + * for both authenticated and anonymous users. This allows the system to + * block IP addresses from within the administrative interface and before any + * modules are loaded. However on high traffic websites you may want to avoid + * this query, allowing you to bypass database access altogether for anonymous + * users under certain caching configurations. + * + * If using this setting, you will need to add back any IP addresses which + * you may have blocked via the administrative interface. Each element of this + * array represents a blocked IP address. Uncommenting the array and leaving it + * empty will have the effect of disabling IP blocking on your site. + * + * Remove the leading hash signs to enable. + */ +# $conf['blocked_ips'] = array( +# 'a.b.c.d', +# ); + +/** + * Fast 404 pages: + * + * Drupal can generate fully themed 404 pages. However, some of these responses + * are for images or other resource files that are not displayed to the user. + * This can waste bandwidth, and also generate server load. + * + * The options below return a simple, fast 404 page for URLs matching a + * specific pattern: + * - 404_fast_paths_exclude: A regular expression to match paths to exclude, + * such as images generated by image styles, or dynamically-resized images. + * If you need to add more paths, you can add '|path' to the expression. + * - 404_fast_paths: A regular expression to match paths that should return a + * simple 404 page, rather than the fully themed 404 page. If you don't have + * any aliases ending in htm or html you can add '|s?html?' to the expression. + * - 404_fast_html: The html to return for simple 404 pages. + * + * Add leading hash signs if you would like to disable this functionality. + */ +$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//'; +$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i'; +$conf['404_fast_html'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>'; + +/** + * By default the page request process will return a fast 404 page for missing + * files if they match the regular expression set in '404_fast_paths' and not + * '404_fast_paths_exclude' above. 404 errors will simultaneously be logged in + * the Drupal system log. + * + * You can choose to return a fast 404 page earlier for missing pages (as soon + * as settings.php is loaded) by uncommenting the line below. This speeds up + * server response time when loading 404 error pages and prevents the 404 error + * from being logged in the Drupal system log. In order to prevent valid pages + * such as image styles and other generated content that may match the + * '404_fast_html' regular expression from returning 404 errors, it is necessary + * to add them to the '404_fast_paths_exclude' regular expression above. Make + * sure that you understand the effects of this feature before uncommenting the + * line below. + */ +# drupal_fast_404(); + +/** + * External access proxy settings: + * + * If your site must access the Internet via a web proxy then you can enter + * the proxy settings here. Currently only basic authentication is supported + * by using the username and password variables. The proxy_user_agent variable + * can be set to NULL for proxies that require no User-Agent header or to a + * non-empty string for proxies that limit requests to a specific agent. The + * proxy_exceptions variable is an array of host names to be accessed directly, + * not via proxy. + */ +# $conf['proxy_server'] = ''; +# $conf['proxy_port'] = 8080; +# $conf['proxy_username'] = ''; +# $conf['proxy_password'] = ''; +# $conf['proxy_user_agent'] = ''; +# $conf['proxy_exceptions'] = array('127.0.0.1', 'localhost'); + +/** + * Authorized file system operations: + * + * The Update manager module included with Drupal provides a mechanism for + * site administrators to securely install missing updates for the site + * directly through the web user interface. On securely-configured servers, + * the Update manager will require the administrator to provide SSH or FTP + * credentials before allowing the installation to proceed; this allows the + * site to update the new files as the user who owns all the Drupal files, + * instead of as the user the webserver is running as. On servers where the + * webserver user is itself the owner of the Drupal files, the administrator + * will not be prompted for SSH or FTP credentials (note that these server + * setups are common on shared hosting, but are inherently insecure). + * + * Some sites might wish to disable the above functionality, and only update + * the code directly via SSH or FTP themselves. This setting completely + * disables all functionality related to these authorized file operations. + * + * @see http://drupal.org/node/244924 + * + * Remove the leading hash signs to disable. + */ +# $conf['allow_authorize_operations'] = FALSE; diff --git a/devgerrit/script/drupal.sh b/devgerrit/script/drupal.sh new file mode 100755 index 0000000..fcbb77c --- /dev/null +++ b/devgerrit/script/drupal.sh @@ -0,0 +1,35 @@ +#!/bin/bash +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +HTDOCS_DIR=/var/www/html +MODULES_DIR=${HTDOCS_DIR}/drupal/sites/all/modules +set -e + +if [ ! -e "${HTDOCS_DIR}/drupal/sites/default/settings.php" ] +then + cp /config/settings.php ${HTDOCS_DIR}/drupal/sites/default/settings.php + chmod a+w ${HTDOCS_DIR}/drupal/sites/default/settings.php +fi +if [ ! -e "${HTDOCS_DIR}/drupal/sites/default/default.settings.php" ] +then + cp /config/default.settings.php ${HTDOCS_DIR}/drupal/sites/default/default.settings.php + chmod a+w ${HTDOCS_DIR}/drupal/sites/default/default.settings.php +fi +if [ ! -d "${HTDOCS_DIR}/drupal/sites/default/files/" ] +then + mkdir -p ${HTDOCS_DIR}/drupal/sites/default/files/ + chmod o+w ${HTDOCS_DIR}/drupal/sites/default/files/ +fi + +chown -R ${APACHE_RUN_USER}:${APACHE_RUN_USER} ${HTDOCS_DIR}/drupal diff --git a/devgerrit/script/gerrit.sh b/devgerrit/script/gerrit.sh new file mode 100755 index 0000000..fd8a921 --- /dev/null +++ b/devgerrit/script/gerrit.sh @@ -0,0 +1,59 @@ +#!/bin/bash +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== + +GERRIT_HOME=/home/gerrit +GERRIT_CONFIG_PATH=/home/gerrit/gerrit/etc/gerrit.config + +set -e + +if [ ! -d "${GERRIT_HOME}/gerrit/bin" ] +then + echo "restore gerrit" + mkdir -p ${GERRIT_HOME}/gerrit + cp -r /home/gerrit/backup/* ${GERRIT_HOME}/gerrit + rm -rf /home/gerrit/backup + chown -R gerrit:gerrit ${GERRIT_HOME}/gerrit +fi + + +if [ -e "/config/gerrit.config" ] +then +echo "cp gerrit.config" +cp /config/gerrit.config $GERRIT_CONFIG_PATH +fi + +if [ ! -e "/var/lib/mysql/$MYSQL_GERRIT_DATABASE/accounts.frm" ] +then + echo "Create gerrit db tables;" + cd $GERRIT_HOME + java -jar gerrit.war init --batch -d gerrit + +fi + +if [ -e "/config/apache2_gerrit.conf" ] +then +echo "cp apache2_gerrit.conf" +cp /config/apache2_gerrit.conf /etc/apache2/sites-available/gerrit.conf +ln -s /etc/apache2/sites-available/gerrit.conf /etc/apache2/sites-enabled/001-gerrit.conf +fi + +if [ ! -e $GERRIT_HOME/docker_bootstrapped ]; then + chown -R gerrit:gerrit $GERRIT_HOME +else + echo "found docker_bootstrapped" +fi + + + diff --git a/devgerrit/script/initdb.sh b/devgerrit/script/initdb.sh new file mode 100755 index 0000000..ba4107b --- /dev/null +++ b/devgerrit/script/initdb.sh @@ -0,0 +1,63 @@ +#!/bin/bash +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +set -e + +status () { + echo "---> ${@}" >&2 +} + + +if [ ! -d $MYSQL_DATA_DIR_DEFAULT/$MYSQL_DRUPAL_DATABASE ]; then + if [ -z "$MYSQL_ROOT_PASSWORD" ]; then + echo >&2 'error: database is uninitialized and MYSQL_ROOT_PASSWORD not set' + echo >&2 ' Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?' + exit 1 + fi + + status "mysql_install_db" + /usr/bin/mysql_install_db + chown -R mysql:mysql $MYSQL_DATA_DIR_DEFAULT + chmod 700 $MYSQL_DATA_DIR_DEFAULT + + # setup user + /usr/bin/mysqld_safe --skip-grant-tables & + sleep 10s + + status "initdb.sh start" + status "1" + mysql -u root -e "use mysql; UPDATE user SET Password=PASSWORD('$MYSQL_ROOT_PASSWORD') WHERE User='root'; FLUSH PRIVILEGES;" + + status "2" + mysql -u root --password=$MYSQL_ROOT_PASSWORD <<-EOFMYSQL + CREATE DATABASE IF NOT EXISTS $MYSQL_DRUPAL_DATABASE ; + CREATE USER '$MYSQL_DRUPAL_USER'@'%' IDENTIFIED BY '$MYSQL_DRUPAL_PASSWORD' ; + CREATE USER '$MYSQL_DRUPAL_USER'@'localhost' IDENTIFIED BY '$MYSQL_DRUPAL_PASSWORD' ; + GRANT ALL ON $MYSQL_DRUPAL_DATABASE.* TO '$MYSQL_DRUPAL_USER'@'%','$MYSQL_DRUPAL_USER'@'localhost' ; + FLUSH PRIVILEGES ; + EOFMYSQL + status "3" + mysql -u root --password=$MYSQL_ROOT_PASSWORD <<-EOFMYSQL + CREATE DATABASE IF NOT EXISTS $MYSQL_GERRIT_DATABASE ; + CREATE USER '$MYSQL_GERRIT_USER'@'%' IDENTIFIED BY '$MYSQL_GERRIT_PASSWORD' ; + CREATE USER '$MYSQL_GERRIT_USER'@'localhost' IDENTIFIED BY '$MYSQL_GERRIT_PASSWORD' ; + GRANT ALL ON $MYSQL_GERRIT_DATABASE.* TO '$MYSQL_GERRIT_USER'@'%','$MYSQL_GERRIT_USER'@'localhost' ; + FLUSH PRIVILEGES ; + EOFMYSQL + status "initdb.sh end" + +fi +chown -R mysql:mysql $MYSQL_DATA_DIR_DEFAULT + + diff --git a/devgerrit/script/phpldapadmin.sh b/devgerrit/script/phpldapadmin.sh new file mode 100755 index 0000000..7479bcd --- /dev/null +++ b/devgerrit/script/phpldapadmin.sh @@ -0,0 +1,25 @@ +#!/bin/bash +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +set -e + +if [ ! -e "/etc/phpldapadmin/config.php" ] +then + mkdir -p /etc/phpldapadmin + cp -r /etc/phpldapadmin_backup/* /etc/phpldapadmin + rm -rf /etc/phpldapadmin_backup +fi + +chown -R root:${APACHE_RUN_USER} /etc/phpldapadmin/ + diff --git a/devgerrit/script/slapd.sh b/devgerrit/script/slapd.sh new file mode 100755 index 0000000..2ed660a --- /dev/null +++ b/devgerrit/script/slapd.sh @@ -0,0 +1,62 @@ +#!/bin/sh +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +set -eu + +status () { + echo "---> ${@}" >&2 +} + +set -x +: LDAP_ROOTPASS=${LDAP_ROOTPASS} +: LDAP_DOMAIN=${LDAP_DOMAIN} +: LDAP_ORGANISATION=${LDAP_ORGANISATION} + +if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then + status "configuring slapd for first run" + + cat <<EOF | debconf-set-selections +slapd slapd/internal/generated_adminpw password ${LDAP_ROOTPASS} +slapd slapd/internal/adminpw password ${LDAP_ROOTPASS} +slapd slapd/password2 password ${LDAP_ROOTPASS} +slapd slapd/password1 password ${LDAP_ROOTPASS} +slapd slapd/dump_database_destdir string /var/backups/slapd-VERSION +slapd slapd/domain string ${LDAP_DOMAIN} +slapd shared/organization string ${LDAP_ORGANISATION} +slapd slapd/backend string HDB +slapd slapd/purge_database boolean true +slapd slapd/move_old_database boolean true +slapd slapd/allow_ldap_v2 boolean false +slapd slapd/no_configuration boolean false +slapd slapd/dump_database select when needed +EOF + + dpkg-reconfigure -f noninteractive slapd + /usr/sbin/slapd -h "ldapi:///" -u openldap -g openldap -d 0 & + PID=$! + sleep 10 + #ldapadd -Q -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/default.ldif + #sleep 3 + status "killing slapd" + kill $PID + status "killed" + touch /var/lib/ldap/docker_bootstrapped +else + status "found already-configured slapd" +fi + +chown -R openldap:openldap /var/lib/ldap/ +chown -R openldap:openldap /etc/ldap/slapd.d/ + + diff --git a/devgerrit/script/startup.sh b/devgerrit/script/startup.sh new file mode 100755 index 0000000..b25d27b --- /dev/null +++ b/devgerrit/script/startup.sh @@ -0,0 +1,30 @@ +#!/bin/bash +#=============================================================================== +# Copyright (c) 2014-2015 Samsung Electronics Co., Ltd. +# Author onstudy@samsung.com +# +# 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; version 2 of the License +# +# 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. +#=============================================================================== +# slapd +/srv/script/slapd.sh + +#Create drupal gerrit database +/srv/script/initdb.sh + +#drupal init config +/srv/script/drupal.sh + +#gerrit init config +/srv/script/gerrit.sh + +# start daemon +/usr/bin/supervisord -c /etc/supervisor/supervisord.conf + + diff --git a/devgerrit/supervisor/supervisord.conf b/devgerrit/supervisor/supervisord.conf new file mode 100755 index 0000000..225f418 --- /dev/null +++ b/devgerrit/supervisor/supervisord.conf @@ -0,0 +1,17 @@ +[supervisord] +nodaemon=true + +[program:slapd] +command=/usr/sbin/slapd -h "ldap:///" -u openldap -g openldap -d 0 + +[program:apache2] +command=service apache2 start +;command=/usr/sbin/apache2 -D FOREGROUND + + +[program:gerrit] +command=/bin/bash -c "/home/gerrit/gerrit/bin/gerrit.sh start" + +[program:mysql] +command=/usr/bin/pidproxy /var/run/mysqld.pid /usr/bin/mysqld_safe + |