From: Matteo Nastasi (mop) Date: Wed, 8 Oct 2014 17:05:20 +0000 (+0200) Subject: Merge branch 'fflush_mgmt' into curls X-Git-Tag: v4.15.0~4^2 X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=706f411d26dee22befc679885d715dd620b674e5;hp=988413fc84244751058890aec6aa4d0c2e9cdafa;p=brisk.git Merge branch 'fflush_mgmt' into curls --- diff --git a/INSTALL.sh b/INSTALL.sh index 3c25449..7c4b75d 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -90,6 +90,7 @@ function searchetc() { # # MAIN # +declare -a nam if [ "$1" = "chk" ]; then set -e oldifs="$IFS" @@ -100,7 +101,7 @@ if [ "$1" = "chk" ]; then done taggit="$(git describe --tags | sed 's/^v//g')" - tagphp="$(grep "^\$G_brisk_version = " web/Obj/brisk.phh | sed 's/^[^"]\+"//g;s/".*//g')" + tagphp="$(grep "^\$G_brisk_version = " web/Obj/brisk.phh | sed 's/^[^"]\+"//g;s/".*//g')" # ' emacs hell if [ "$taggit" != "$tagphp" ]; then echo echo "WARNING: taggit: [$taggit] tagphp: [$tagphp]" @@ -111,16 +112,28 @@ fi # before all check errors on the sources $0 chk || exit 3 - if [ "$1" = "pkg" ]; then if [ "$2" != "" ]; then tag="$2" else tag="$(git describe)" fi - nam1="brisk_${tag}.tgz" - nam2="brisk-img_${tag}.tgz" - echo "Build packages ${nam1} and ${nam2}." + nam_idx=0 + nam[$nam_idx]="brisk_${tag}.tgz" + nam_idx=$((nam_idx + 1)) + nam[$nam_idx]="brisk-img_${tag}.tgz" + + if [ -d ../curl-de-sac ]; then + nam_idx=$((nam_idx + 1)) + nam[$nam_idx]="curl-de-sac_${tag}.tgz" + fi + pkg_list="" + sep="" + for i in ${nam[@]}; do + pkg_list="${pkg_list}${sep}${i}" + sep=", " + done + echo "Build packages ${pkg_list}." read -p "Proceed [y/n]: " a if [ "$a" != "y" -a "$a" != "Y" ]; then exit 1 @@ -129,11 +142,17 @@ if [ "$1" = "pkg" ]; then cd ../brisk-img git archive --format=tar --prefix=brisk-${tag}/brisk-img/ $tag | gzip > ../$nam2 cd - + if [ -d ../curl-de-sac ]; then + cd ../curl-de-sac + git archive --format=tar --prefix=brisk-${tag}/curl-de-sac/ $tag | gzip > ../$nam3 + cd - + fi exit 0 fi if [ -f "$CONFIG_FILE" ]; then source "$CONFIG_FILE" + conffile_in="$CONFIG_FILE" fi if [ "x$prefix_path" = "x" ]; then @@ -175,6 +194,7 @@ while [ $# -gt 0 ]; do exit 1 fi . "$conffile" + conffile_in="$conffile" fi shift $sh done @@ -341,7 +361,7 @@ if [ "$web_only" = "FALSE" ]; then fi install -d ${web_path}__ -for i in $(find web -type d | sed 's/^....//g'); do +for i in $(find web -type d | grep '/' | sed 's/^....//g'); do install -d ${web_path}__/$i done @@ -401,15 +421,20 @@ sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path document_root="$(grep DocumentRoot "${apache_conf}" | grep -v '^[ ]*#' | awk '{ print $2 }')" sed -i "s@^\(\$DOCUMENT_ROOT *= *[\"']\)[^\"']*\([\"']\)@\1$document_root\2@g" ${web_path}__/spush/*.ph* -if [ -d ${web_path} ]; then - mv ${web_path} ${web_path}.old -fi - if [ -d ../brisk-img ]; then cd ../brisk-img ./INSTALL.sh -w ${web_path}__ cd - >/dev/null 2>&1 fi +if [ -d ../curl-de-sac ]; then + cd ../curl-de-sac + if [ ! -z "$conffile_in" ]; then + ./INSTALL.sh -f "$conffile_in" -w ${web_path}__ + else + ./INSTALL.sh -w ${web_path}__ + fi + cd - >/dev/null 2>&1 +fi # config file installation or diff if [ -f "$etc_path/$brisk_conf" ]; then @@ -424,6 +449,10 @@ else cp "${web_path}__""/Obj/brisk.conf-templ.pho" "$etc_path/$brisk_conf" fi +if [ -d ${web_path} ]; then + mv ${web_path} ${web_path}.old +fi + mv ${web_path}__ ${web_path} if [ -d ${web_path}.old ]; then rm -rf ${web_path}.old diff --git a/bin/restarter.sh b/bin/restarter.sh new file mode 100755 index 0000000..848c02c --- /dev/null +++ b/bin/restarter.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# set -x +cd "$PWD" 2>/dev/null +dirnm="$PWD" +cwd_old="$(ls -i -d "$dirnm" | cut -d ' ' -f 1)" +pid_exe="" +while true; do + if [ "$pid_exe" = "" ]; then + sleep 2 + cd "$dirnm" 2>/dev/null + "$@" & + pid_exe="$!" + fi + sleep 1 + kill -0 $pid_exe >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Process not present" + exit 0 + fi + for tloop in 1 2 3 4 5; do + cwd_cur="$(ls -i -d "$dirnm" 2>/dev/null | cut -d ' ' -f 1)" + if [ "$cwd_cur" ]; then + break + fi + sleep 1 + done + if [ $tloop -eq 5 ]; then + echo "Unavailable current working directory" + exit 1 + fi + if [ "$cwd_cur" != "$cwd_old" ]; then + kill $pid_exe + wait $pid_exe + echo "WAIT EXIT: $?" + pid_exe="" + fi + cwd_old="$cwd_cur" +done + diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 391f0a8..3af8a15 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2,7 +2,7 @@ /* * brisk - brisk.phh * - * Copyright (C) 2006-2013 Matteo Nastasi + * Copyright (C) 2006-2014 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -79,6 +79,7 @@ define('DBG_LMOP', 0x0800); define('DBG_TRAC', 0x1000); define('DBG_SHME', 0x2000); define('DBG_ENGI', 0x4000); +define('DBG_CDS', 0x8000); // NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols define('BRISK_DEBUG', 0x0800); @@ -1000,10 +1001,13 @@ class Brisk var $delay_mgr; + var $cds; + public static $sess_cur; function Brisk() { + $this->cds = NULL; } // constructor @@ -1013,7 +1017,7 @@ class Brisk fprintf(STDERR, "ROOM FROM FILE\n"); rename($crystal_filename, $crystal_filename.".old"); - $brisk->reload($ban_list, $black_list); + $brisk->reload(TRUE, $ban_list, $black_list); return($brisk); } @@ -1030,11 +1034,6 @@ class Brisk $thiz->ban_list = NULL; $thiz->black_list = NULL; - fprintf(STDERR, "PRE IPCLASS_UPDATE (%d, %d)\n", count($ban_list), count($black_list)); - $thiz->ipclass_update('ban_list', $ban_list); - $thiz->ipclass_update('black_list', $black_list); - fprintf(STDERR, "POST IPCLASS_UPDATE %d %d\n", count($thiz->ban_list), count($thiz->black_list)); - for ($i = 0 ; $i < MAX_PLAYERS ; $i++) { $thiz->user[$i] = User::create($thiz, $i, "", ""); } @@ -1049,6 +1048,8 @@ class Brisk static::$sess_cur = FALSE; + $thiz->reload(TRUE, $ban_list, $black_list); + return ($thiz); } @@ -1073,15 +1074,22 @@ class Brisk } } - function reload($ban_list, $black_list) + function reload($is_first, $ban_list, $black_list) { fprintf(STDERR, "RELOAD STUFF (%d)(%d)\n", count($ban_list), count($black_list)); + if (defined('CURL_DE_SAC_VERS')) { + if (brisk_cds_reload($this) == FALSE) { + exit(12); + } + } $this->ipclass_update("ban_list", $ban_list); $this->ipclass_update("black_list", $black_list); - $this->banned_kickoff(); - $this->garbage_manager(TRUE); + if (!$is_first) { + $this->banned_kickoff(); + $this->garbage_manager(TRUE); + } } function banned_kickoff() @@ -2255,6 +2263,9 @@ class Brisk } $idx = $ghost; + if (defined('CURL_DE_SAC_VERS')) { + brisk_cds_execute($this, $real_idx, $sess, $ip, $authenticate); + } return ($this->user[$ghost]); } else if ($idx != -1 && $i == MAX_PLAYERS) { @@ -2354,6 +2365,9 @@ class Brisk log_main(sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s] count [%d] name [%s] code [%s]", $idx, $sess, $name_new, count($this->user),$this->user[$real_idx]->name, $this->user[$real_idx]->code)); $ret = $this->user[$real_idx]; + if (defined('CURL_DE_SAC_VERS')) { + brisk_cds_execute($this, $real_idx, $sess, $ip, $authenticate); + } return ($ret); } @@ -2707,6 +2721,33 @@ function log_mop($step, $log) } +function log_cds($log) +{ + GLOBAL $PHP_SELF; + + if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_CDS) == 0) + return; + + $sess = Brisk::sess_cur_get(); + if (isset($sess) == FALSE) + $ssess = "XXXX"; + else + $ssess = $sess; + + if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_CDS) == 0) + return; + + if ((BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_TRAC) + $btrace = btrace_line(debug_backtrace()); + else + $btrace = ""; + if (($fp = @fopen(LEGAL_PATH."/cds.log", 'a')) != FALSE) { + fwrite($fp, sprintf("CDS: [%f] [%s] [%s]\n", gettimeofday(TRUE), $log, $btrace)); + fclose($fp); + } +} + + function log_only2($log) { GLOBAL $PHP_SELF; diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 91012a8..e4e020d 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -796,7 +796,7 @@ class Sac_a_push { $line = trim($buf); if ($line == "reload") { require("$DOCUMENT_ROOT/Etc/".BRISK_CONF); - $this->app->reload($G_ban_list, $G_black_list); + $this->app->reload(FALSE, $G_ban_list, $G_black_list); global_dump(); } else if ($line == "shutdown" || $line == "sd") { @@ -941,6 +941,9 @@ class Sac_a_push { } // if (isset($this->s2u[$id]... } // foreach ($this->socks... printf("\n"); + if (defined('CURL_DE_SAC_VERS')) { + $this->app->cds->process(); + } } // while (... } // function run(... diff --git a/web/doc_download.php b/web/doc_download.php index d447c19..9e86ef1 100644 --- a/web/doc_download.php +++ b/web/doc_download.php @@ -9,16 +9,23 @@ function main() return(FALSE); } - $fname = sprintf("%s%s.pdf", $G_doc_path, basename($_GET['doc'])); + $ext = "pdf"; + $cont_type = "application/octet-stream"; + if (isset($_GET['ext']) && ($_GET['ext'] == "txt")) { + $cont_type = "plain/text"; + $ext = $_GET['ext']; + } + + $fname = sprintf("%s%s.%s", $G_doc_path, basename($_GET['doc']), $ext); if (! file_exists($fname)) { return(FALSE); } - header("Content-Type: application/octet-stream"); + header(sprintf("Content-Type: %s", $cont_type)); header(sprintf("Content-Disposition: attachment; filename=brisk_%s", basename($fname))); readfile($fname); return(TRUE); } main(); -?> \ No newline at end of file +?> diff --git a/web/index.php b/web/index.php index c53bc95..70e1ddd 100644 --- a/web/index.php +++ b/web/index.php @@ -356,13 +356,13 @@ function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get } } + $banned = FALSE; if ($ACTION == "login" && isset($name)) { log_main("pre garbage_manager DUE"); if (isset($pass_private) == FALSE || $pass_private == "") { $pass_private = FALSE; - $banned = FALSE; if ($brisk->ban_check($remote_addr)) { // TODO: find a way to add a nonblocking sleep(5) here $banned = TRUE; diff --git a/web/spush/brisk-spush.php b/web/spush/brisk-spush.php index cbbce76..6e07d92 100755 --- a/web/spush/brisk-spush.php +++ b/web/spush/brisk-spush.php @@ -28,11 +28,11 @@ $G_base = "../"; require_once($G_base."Obj/sac-a-push.phh"); require_once("./brisk-spush.phh"); require_once($G_base."Obj/user.phh"); +@include_once($G_base."Obj/curl-de-brisk.phh"); require_once($G_base."Obj/brisk.phh"); require_once($G_base."Obj/auth.phh"); require_once($G_base."Obj/zlibstream.phh"); require_once($G_base."Obj/mail.phh"); -// require_once("../Obj/proxyscan.phh"); require_once($G_base."index.php"); require_once($G_base."index_wr.php"); require_once($G_base."briskin5/Obj/briskin5.phh");