You can subscribe to this list here.
2005 |
Jan
|
Feb
(32) |
Mar
(56) |
Apr
(92) |
May
(39) |
Jun
(226) |
Jul
(98) |
Aug
(66) |
Sep
|
Oct
(153) |
Nov
(43) |
Dec
(42) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(97) |
Feb
(141) |
Mar
(147) |
Apr
(80) |
May
(51) |
Jun
(93) |
Jul
(88) |
Aug
(50) |
Sep
(179) |
Oct
(48) |
Nov
(82) |
Dec
(71) |
2007 |
Jan
(42) |
Feb
(46) |
Mar
(123) |
Apr
(21) |
May
(139) |
Jun
(59) |
Jul
(34) |
Aug
(57) |
Sep
(47) |
Oct
(137) |
Nov
(49) |
Dec
(12) |
2008 |
Jan
(10) |
Feb
(8) |
Mar
(63) |
Apr
(17) |
May
(34) |
Jun
(38) |
Jul
(16) |
Aug
(62) |
Sep
(9) |
Oct
(121) |
Nov
(38) |
Dec
(4) |
2009 |
Jan
|
Feb
(11) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(4) |
Apr
(10) |
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(12) |
2012 |
Jan
(26) |
Feb
(1) |
Mar
(15) |
Apr
(1) |
May
(1) |
Jun
(7) |
Jul
(2) |
Aug
|
Sep
(1) |
Oct
(52) |
Nov
(8) |
Dec
(25) |
2013 |
Jan
(35) |
Feb
(14) |
Mar
(10) |
Apr
(10) |
May
(29) |
Jun
(16) |
Jul
(5) |
Aug
(8) |
Sep
(8) |
Oct
(6) |
Nov
(1) |
Dec
(3) |
2014 |
Jan
(16) |
Feb
(13) |
Mar
(5) |
Apr
(9) |
May
(21) |
Jun
(6) |
Jul
(5) |
Aug
(2) |
Sep
(59) |
Oct
(115) |
Nov
(122) |
Dec
(45) |
2015 |
Jan
(31) |
Feb
(32) |
Mar
(19) |
Apr
(25) |
May
(3) |
Jun
(4) |
Jul
(18) |
Aug
(3) |
Sep
(23) |
Oct
(11) |
Nov
(17) |
Dec
(12) |
2016 |
Jan
(20) |
Feb
(27) |
Mar
(20) |
Apr
(40) |
May
(35) |
Jun
(48) |
Jul
(44) |
Aug
(51) |
Sep
(18) |
Oct
(42) |
Nov
(39) |
Dec
(29) |
2017 |
Jan
(37) |
Feb
(34) |
Mar
(20) |
Apr
(37) |
May
(10) |
Jun
(2) |
Jul
(14) |
Aug
(15) |
Sep
(25) |
Oct
(29) |
Nov
(15) |
Dec
(29) |
2018 |
Jan
(5) |
Feb
(15) |
Mar
(6) |
Apr
(20) |
May
(39) |
Jun
(39) |
Jul
(17) |
Aug
(20) |
Sep
(10) |
Oct
(17) |
Nov
(20) |
Dec
(8) |
2019 |
Jan
(28) |
Feb
(21) |
Mar
(13) |
Apr
(44) |
May
(44) |
Jun
(28) |
Jul
(51) |
Aug
(30) |
Sep
(7) |
Oct
(20) |
Nov
(8) |
Dec
(21) |
2020 |
Jan
(27) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Zoran V. <vas...@us...> - 2005-03-18 08:34:12
|
Update of /cvsroot/naviserver/naviserver/tcl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16655 Modified Files: fastpath.tcl Log Message: Removed all AOLpress stuff Index: fastpath.tcl =================================================================== RCS file: /cvsroot/naviserver/naviserver/tcl/fastpath.tcl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fastpath.tcl 16 Feb 2005 16:45:44 -0000 1.2 --- fastpath.tcl 18 Mar 2005 08:33:54 -0000 1.3 *************** *** 37,44 **** # AOLserver 2.x fastpath routines moved from C. The C code # now only handles the simple case of returning a file through ! # an optimized caching routines. All legacy AOLpress publishing ! # functions are handled with the Tcl code below. In addition, ! # the C code will dispatch to the _ns_dirlist proc below to ! # handle directory listings and AOLpress MiniWeb top pages. # --- 37,43 ---- # AOLserver 2.x fastpath routines moved from C. The C code # now only handles the simple case of returning a file through ! # an optimized caching routines. ! # In addition, the C code will dispatch to the _ns_dirlist proc ! # below to handle directory listings. # *************** *** 47,104 **** nsv_set _ns_fastpath hidedot [ns_config -bool $path hidedotfiles 1] nsv_set _ns_fastpath toppage [ns_config -bool $path returnmwtoppage 0] - nsv_set _ns_fastpath aolpress [ns_config -bool $path enableaolpress 0] nsv_set _ns_fastpath builddirs [ns_config -bool $path builddirs 0] nsv_set _ns_fastpath serverlog [ns_config -bool $path serverlog 1] # - # Register the publishing procs if enabled. Note that you must - # load a permission module (e.g., nsperm) or the server - # will deny access to all these publishing methods. - # - - if {[nsv_get _ns_fastpath aolpress]} { - ns_register_proc PUT / _ns_publish _ns_put - ns_register_proc DELETE / _ns_publish _ns_delete - ns_register_proc BROWSE / _ns_publish _ns_browse - ns_register_proc MKDIR / _ns_publish _ns_mkdir - ns_register_proc OPTIONS / _ns_publish _ns_options - } - - - # - # _ns_isaolpress -- - # - # Is the client AOLpress? - # - - proc _ns_isaolpress {} { - set agent [ns_set iget [ns_conn headers] user-agent] - return [string match NaviPress/* $agent] - } - - - # - # _ns_getnvd -- - # - # Return the MiniWeb control file for a directory. - # - - proc _ns_getnvd dir { - return $dir/document.nvd - } - - - # - # _ns_ismw -- - # - # Is the directory a MiniWeb? - # - - proc _ns_ismw dir { - return [file exists [_ns_getnvd $dir]] - } - - - # # _ns_dirlist -- # --- 46,53 ---- *************** *** 117,143 **** # - # Handle special case of AOLpress MiniWebs. - # - - if {[nsv_get _ns_fastpath toppage] && [_ns_ismw $dir]} { - set nvd [_ns_getnvd $dir] - if {[_ns_isaolpress]} { - return [ns_returnfile 200 application/x-navidoc $file] - } - set fp [open $nvd] - while {[gets $fp line] >= 0} { - if {[string match Pages:* $line]} { - break - } - } - gets $fp line - close $fp - set file [lindex [split $line \"] 1] - if {[file exists $dir/$file]} { - return [ns_returnredirect $file] - } - } - - # # Handle default case of directory listing. Simple # format is just the files while fancy includes --- 66,69 ---- *************** *** 214,499 **** } - - # - # _ns_publish -- - # - # Wrapper to log publishing actions. - # - - proc _ns_publish proc { - if {[nsv_get _ns_fastpath serverlog]} { - ns_log notice "fastpath:[ns_conn authuser]:$proc [ns_conn url]" - } - $proc - } - proc ns_returnok {} { ns_return 200 text/plain "" } - proc _ns_remove file { - if {[nsv_get _ns_fastpath serverlog]} { - ns_log notice "fastpath:[ns_conn authuser]:unlink: $file" - } - ns_unlink $file - } - - # - # _ns_browse -- - # - # Handle the AOLpress BROWSE request to for its file dialog. - # - - proc _ns_browse {} { - set url [ns_conn url] - set dir [ns_url2file $url] - set files "" - foreach f [glob -nocomplain $dir/*] { - set tail [file tail $f] - if {[file isdir $f]} { - set type "application/x-navidir" - } else { - set type [ns_guesstype $tail] - } - append files "$type $tail\n" - } - ns_return 200 application/x-navibrowse $files - } - - - # - # _ns_mkdir -- - # - # Handle the AOLpress MKDIR request to create a new directory. - # - - proc _ns_mkdir {} { - set url [ns_conn url] - set dir [ns_url2file $url] - if {[file exists $dir]} { - return [ns_returnbadrequest "File Exists"] - } - - if {[catch {ns_mkdir $dir} err]} { - ns_log error "fastpath: mkdir $dir failed: $err" - ns_returnbadrequest "Could not create directory" - } - ns_returnok - } - - - # - # _ns_options -- - # - # Handle the AOLpress OPTIONS request to return available functions. - # Note that LOCK and UNLOCK are not yet supported. - # - - proc _ns_options {} { - set hdrs [ns_conn outputheaders] - ns_set put $hdrs Allow "OPTIONS, GET, HEAD, PUT, BROWSE, MKDIR" - ns_returnok - } - - - # - # _ns_delete -- - # - # Handle the AOLpress DELETE request to delete a file - # or empty directory. Note that deleting MiniWebs is - # not yet supported. - # - - proc _ns_delete {} { - set url [ns_conn url] - set file [ns_url2file $url] - if {![file exists $file]} { - return [ns_returnbadrequest "No Such File"] - } - if {[catch { - if {![file isdir $file]} { - _ns_remove $file - } else { - set dir $file - if {[_ns_ismw $dir]} { - set nvd [_ns_getnvd $dir] - set tail [file tail $nvd] - set files($tail) 1 - set pages 0 - set fp [open $nvd] - while {[gets $fp line] >= 0} { - if {[string match Pages:* $line]} { - set pages 1 - break - } - } - if {$pages} { - while {[gets $fp line] >= 0} { - if {![string match "\"*" $line]} break - set file [lindex [split $line \"] 1] - set files($file) 0 - } - } - close $fp - foreach file [glob -nocomplain $dir/*] { - set tail [file tail $file] - if {![info exists files($tail)]} { - return [ns_returnbadrequest "Directory not empty"] - } - set files($tail) 1 - } - foreach tail [array names files] { - if {$files($tail)} { - _ns_remove $dir/$tail - } - } - } - ns_rmdir $dir - } - } err]} { - ns_log error "fastpath: delete $file failed: $err" - ns_returnbadrequest "Could not delete file" - } - ns_returnok - } - - - # - # _ns_put -- - # - # Handle the AOLpress PUT request to save a file - # or MiniWeb. The MiniWeb code is a bit tricky. - # Also, files are saved to tmp files and renamed - # to ensure half-written files don't become permanent - # - - proc _ns_put {} { - set url [ns_conn url] - set file [ns_url2file $url] - set hdrs [ns_conn headers] - set isdir 0 - set ismw 0 - set exists [file exists $file] - set type [ns_set iget $hdrs content-type] - - if {[ns_set ifind $hdrs x-navicreate] < 0} { - set create 0 - } else { - set create 1 - } - - if {$create && $exists} { - return [ns_returnerror 500 "Already Exists"] - } - if {$exists} { - set isdir [file isdir $file] - if {$isdir} { - set ismw [_ns_ismw $file] - } - } - if {$type == "application/x-naviwad"} { - if {$exists} { - if {!$ismw} { - return [ns_returnerror 500 "not miniweb"] - } - } - set ismw 1 - } elseif {$exists && $isdir} { - return [ns_returnerror 500 "File is a directory"] - } - - if {[catch { - if {$ismw} { - - # - # Create MiniWeb directory if necessary. - # - - set dir $file - if {!$exists} { - ns_mkdir $dir - } - - # - # Spool MiniWeb content in a tmp file. - # - - set tmp [ns_tmpnam] - set fp [open $tmp w+] - fconfigure $fp -translation binary - ns_conncptofp $fp - - # - # Read the headers and save the content - # for each included file. - # - - seek $fp 0 - while {[gets $fp line] >= 0} { - set line [string trim $line] - if {![string length $line]} { - if {![info exists length] || - ![info exists name]} { - close $fp - return [ns_returnbadrequest] - } - set file $dir/$name - set tmp2 [ns_mktemp $file.putXXXXXX] - set fp2 [open $tmp2 w] - ns_cpfp $fp $fp2 $length - close $fp2 - ns_rename $tmp2 $file - unset name - unset length - } else { - set kv [split $line :] - set k [string trim [lindex $kv 0]] - set v [string trim [lindex $kv 1]] - switch [string tolower $k] { - content-name { - set name $v - } - content-length { - set length $v - } - } - } - } - close $fp - ns_unlink $tmp - } else { - - # - # Save an ordinary file. - # - - set tmp [ns_mktemp $file.putXXXXXX] - if {[catch {open $tmp w} res]} { - if {![nsv_get _ns_fastpath builddirs]} { - error $res - } - ### - # We can accomodate the case where an implied directory tree - # needs to be constructed. - ### - set fpath [file dirname $tmp] - if {![file isdirectory $fpath]} { - file mkdir $fpath - # Now, retry the open; allow error propogation - set fp [open $tmp w] - } else { - error $res - } - } else { - set fp $res - } - ns_conncptofp $fp - close $fp - ns_rename $tmp $file - } - } err]} { - ns_log error "put: save $url failed: $err" - return [ns_returnerror 500 "Save failed"] - } - ns_returnok - } --- 140,145 ---- |
From: Zoran V. <vas...@us...> - 2005-03-18 08:24:52
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14670 Modified Files: ChangeLog Log Message: See file. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ChangeLog 17 Mar 2005 20:21:50 -0000 1.22 --- ChangeLog 18 Mar 2005 08:24:40 -0000 1.23 *************** *** 1,2 **** --- 1,15 ---- + 2005-03-18 Zoran Vasiljevic <vas...@us...> + + * nsd/conn.c: Modified NsTclWriteContentObjCmd() to + consult reqPtr->avail instead of conn->contentLength + when examining how much bytes from the content is + still left to copy. The conn->contentLength is not + touched any more. + + * nsd/nsd.h: + * nsd/return.c: + * nsd/server.c: Removed handling of aolpress config + parameter (RFE #1165562) + 2005-03-17 Zoran Vasiljevic <vas...@us...> |
From: Zoran V. <vas...@us...> - 2005-03-18 08:21:16
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13693 Modified Files: nsd.h return.c server.c Log Message: Removed handling of aolpress config parameter (RFE #1165562) Index: nsd.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsd.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nsd.h 17 Mar 2005 17:49:12 -0000 1.3 --- nsd.h 18 Mar 2005 08:21:06 -0000 1.4 *************** *** 524,528 **** struct { - bool aolpress; bool flushcontent; bool modsince; --- 524,527 ---- Index: return.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/return.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** return.c 16 Feb 2005 08:39:33 -0000 1.1.1.1 --- return.c 18 Mar 2005 08:21:06 -0000 1.2 *************** *** 439,443 **** Ns_ConnSetRequiredHeaders(Ns_Conn *conn, char *type, int length) { - Conn *connPtr = (Conn *) conn; Ns_DString ds; --- 439,442 ---- *************** *** 451,462 **** Ns_DStringTrunc(&ds, 0); - /* - * Set the standard server header, prepending "NaviServer/2.0" - * if AOLpress support is enabled. - */ - - if (connPtr->servPtr->opts.aolpress) { - Ns_DStringAppend(&ds, "NaviServer/2.0 "); - } Ns_DStringVarAppend(&ds, Ns_InfoServerName(), "/", Ns_InfoServerVersion(), NULL); Ns_ConnCondSetHeaders(conn, "Server", ds.string); --- 450,453 ---- Index: server.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/server.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** server.c 16 Feb 2005 08:40:18 -0000 1.1.1.1 --- server.c 18 Mar 2005 08:21:06 -0000 1.2 *************** *** 222,228 **** servPtr->opts.realm = server; } - if (!Ns_ConfigGetBool(path, "enableaolpress", &servPtr->opts.aolpress)) { - servPtr->opts.aolpress = 0; - } if (!Ns_ConfigGetBool(path, "checkmodifiedsince", &servPtr->opts.modsince)) { servPtr->opts.modsince = 1; --- 222,225 ---- |
From: Zoran V. <vas...@us...> - 2005-03-18 08:13:09
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11288 Modified Files: conn.c Log Message: NsTclWriteContentObjCmd checks reqPtr->avail instead of conn->contentLength Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** conn.c 17 Mar 2005 20:21:14 -0000 1.5 --- conn.c 18 Mar 2005 08:12:56 -0000 1.6 *************** *** 1197,1200 **** --- 1197,1201 ---- int toCopy = 0; char *chanName; + Request *reqPtr; Tcl_Channel chan; *************** *** 1224,1236 **** } Tcl_Flush(chan); ! if (toCopy > itPtr->conn->contentLength || toCopy <= 0) { ! toCopy = itPtr->conn->contentLength; } ! if (Ns_ConnCopyToChannel(itPtr->conn, (unsigned)toCopy, chan) != NS_OK) { Tcl_SetResult(interp, "could not copy content", TCL_STATIC); return TCL_ERROR; } - - itPtr->conn->contentLength -= toCopy; return TCL_OK; --- 1225,1236 ---- } Tcl_Flush(chan); ! reqPtr = ((Conn *)itPtr->conn)->reqPtr; ! if (toCopy > reqPtr->avail || toCopy <= 0) { ! toCopy = reqPtr->avail; } ! if (Ns_ConnCopyToChannel(itPtr->conn, (size_t)toCopy, chan) != NS_OK) { Tcl_SetResult(interp, "could not copy content", TCL_STATIC); return TCL_ERROR; } return TCL_OK; |
From: Zoran V. <vas...@us...> - 2005-03-17 20:21:59
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18509 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ChangeLog 17 Mar 2005 18:25:56 -0000 1.21 --- ChangeLog 17 Mar 2005 20:21:50 -0000 1.22 *************** *** 2,5 **** --- 2,8 ---- * nsd/conn.c: Added [ns_conn channel] (RFE #1156141) + Also, added [ns_conncptofp ?-bytes toCopy? channel] + (RFE #1156899). This change scraps parsing of the + dummy connId argument left for 2.x server compat. * nsd/nsd.h |
From: Zoran V. <vas...@us...> - 2005-03-17 20:21:40
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18251/nsd Modified Files: conn.c Log Message: Implemented RFE #1156899. Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** conn.c 17 Mar 2005 18:24:54 -0000 1.4 --- conn.c 17 Mar 2005 20:21:14 -0000 1.5 *************** *** 1180,1184 **** * NsTclWriteContentObjCmd -- * ! * Implements ns_writecontent as obj command. * * Results: --- 1180,1184 ---- * NsTclWriteContentObjCmd -- * ! * Implements ns_conncptofp as obj command. * * Results: *************** *** 1194,1224 **** NsTclWriteContentObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv) { ! NsInterp *itPtr = arg; ! Tcl_Channel chan; ! if (objc != 2 && objc != 3) { ! Tcl_WrongNumArgs(interp, 1, objv, "?connid? channel"); return TCL_ERROR; } - if (objc == 3 && !NsIsIdConn(Tcl_GetString(objv[1]))) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "bad connid: \"", - Tcl_GetString(objv[1]), "\"", NULL); - return TCL_ERROR; - } if (itPtr->conn == NULL) { ! Tcl_SetResult(interp, "no connection", TCL_STATIC); return TCL_ERROR; } ! if (GetChan(interp, Tcl_GetString(objv[objc-1]), &chan) != TCL_OK) { ! return TCL_ERROR; } Tcl_Flush(chan); ! if (Ns_ConnCopyToChannel(itPtr->conn, (size_t)itPtr->conn->contentLength, ! chan) != NS_OK) { ! Tcl_SetResult(interp, "could not copy content (likely client disconnect)", ! TCL_STATIC); return TCL_ERROR; } return TCL_OK; } --- 1194,1237 ---- NsTclWriteContentObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv) { ! NsInterp *itPtr = arg; ! int toCopy = 0; ! char *chanName; ! Tcl_Channel chan; ! /* ! * Syntax: ns_conncptofp ?-bytes tocopy? channel ! */ ! ! Ns_ObjvSpec opts[] = { ! {"-bytes", Ns_ObjvInt, &toCopy, NULL}, ! {"--", Ns_ObjvBreak, NULL, NULL}, ! {NULL, NULL, NULL, NULL} ! }; ! Ns_ObjvSpec args[] = { ! {"channel", Ns_ObjvString, &chanName, NULL}, ! {NULL, NULL, NULL, NULL} ! }; ! ! if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) { return TCL_ERROR; } if (itPtr->conn == NULL) { ! Tcl_SetResult(interp, "no connection", TCL_STATIC); return TCL_ERROR; } ! if (GetChan(interp, chanName, &chan) != TCL_OK) { ! return TCL_ERROR; } Tcl_Flush(chan); ! if (toCopy > itPtr->conn->contentLength || toCopy <= 0) { ! toCopy = itPtr->conn->contentLength; ! } ! if (Ns_ConnCopyToChannel(itPtr->conn, (unsigned)toCopy, chan) != NS_OK) { ! Tcl_SetResult(interp, "could not copy content", TCL_STATIC); return TCL_ERROR; } + itPtr->conn->contentLength -= toCopy; + return TCL_OK; } |
From: Zoran V. <vas...@us...> - 2005-03-17 18:26:07
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18536 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ChangeLog 17 Mar 2005 17:51:00 -0000 1.20 --- ChangeLog 17 Mar 2005 18:25:56 -0000 1.21 *************** *** 1,4 **** --- 1,6 ---- 2005-03-17 Zoran Vasiljevic <vas...@us...> + * nsd/conn.c: Added [ns_conn channel] (RFE #1156141) + * nsd/nsd.h * nsd/unix.h |
From: Zoran V. <vas...@us...> - 2005-03-17 18:25:03
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18176 Modified Files: conn.c Log Message: Added ns_conn channel as per RFE #1156141 Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** conn.c 8 Mar 2005 04:59:39 -0000 1.3 --- conn.c 17 Mar 2005 18:24:54 -0000 1.4 *************** *** 42,45 **** --- 42,46 ---- static int GetIndices(Tcl_Interp *interp, Conn *connPtr, Tcl_Obj **objv, int *offPtr, int *lenPtr); + static int MakeConnChan(Tcl_Interp *interp, Ns_Conn *conn); *************** *** 841,845 **** "outputheaders", "peeraddr", "peerport", "port", "protocol", "query", "request", "server", "sock", "start", "status", ! "url", "urlc", "urlencoding", "urlv", "version", "write_encoded", NULL }; enum ISubCmdIdx { --- 842,847 ---- "outputheaders", "peeraddr", "peerport", "port", "protocol", "query", "request", "server", "sock", "start", "status", ! "url", "urlc", "urlencoding", "urlv", "version", "write_encoded", ! "channel", NULL }; enum ISubCmdIdx { *************** *** 851,855 **** CPeerPortIdx, CPortIdx, CProtocolIdx, CQueryIdx, CRequestIdx, CServerIdx, CSockIdx, CStartIdx, CStatusIdx, CUrlIdx, ! CUrlcIdx, CUrlEncodingIdx, CUrlvIdx, CVersionIdx, CWriteEncodedIdx } opt; --- 853,858 ---- CPeerPortIdx, CPortIdx, CProtocolIdx, CQueryIdx, CRequestIdx, CServerIdx, CSockIdx, CStartIdx, CStatusIdx, CUrlIdx, ! CUrlcIdx, CUrlEncodingIdx, CUrlvIdx, CVersionIdx, CWriteEncodedIdx, ! CChannelIdx } opt; *************** *** 1160,1164 **** } break; ! } --- 1163,1172 ---- } break; ! ! case CChannelIdx: ! if (MakeConnChan(interp, conn) != TCL_OK) { ! return TCL_ERROR; ! } ! break; } *************** *** 1383,1384 **** --- 1391,1448 ---- return TCL_OK; } + + /*---------------------------------------------------------------------------- + * MakeConnChan -- + * + * Wraps a Tcl channel arround the current connection socket + * and returns the channel handle to the caller. + * + * Result: + * A standard Tcl result. + * + * Side Effects: + * New channel registered in the current interpreter. The channel + * is set to blocking mode. + * + *---------------------------------------------------------------------------- + */ + static int + MakeConnChan(Tcl_Interp *interp, Ns_Conn *conn) + { + int sock; + Tcl_Channel chan; + + /* + * Flush the connection, so we can safely make a dup + * of the connection socket. Without this, we may + * dup some unwanted data in socket buffers which may + * confuse the receiving side. + */ + + Ns_WriteConn(conn, NULL, 0); + + /* + * Wrap the connection in channel and register it. + * Note we must duplicate the connection socket + * since the Tcl channel driver will try to close + * it when we tear down the channel. + */ + + sock = ns_sockdup(Ns_ConnSock(conn)); + if (sock == INVALID_SOCKET) { + Tcl_AppendResult(interp, Tcl_PosixError(interp), NULL); + return TCL_ERROR; + } + + chan = Tcl_MakeTcpClientChannel((ClientData)sock); + if (chan == NULL) { + Tcl_SetResult(interp, "can't wrap connection socket", TCL_STATIC); + return TCL_ERROR; + } + + Ns_SockSetBlocking(sock); + Tcl_RegisterChannel(interp, chan); + Tcl_SetResult(interp, Tcl_GetChannelName(chan), TCL_STATIC); + + return TCL_OK; + } |
From: Zoran V. <vas...@us...> - 2005-03-17 17:51:11
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9197 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ChangeLog 13 Mar 2005 02:09:52 -0000 1.19 --- ChangeLog 17 Mar 2005 17:51:00 -0000 1.20 *************** *** 1,2 **** --- 1,8 ---- + 2005-03-17 Zoran Vasiljevic <vas...@us...> + + * nsd/nsd.h + * nsd/unix.h + * nsd/nsmain.h: Added watchdog implementation (RFE #1156875) + 2005-03-12 Vlad Seryakov <vl...@cr...> |
From: Zoran V. <vas...@us...> - 2005-03-17 17:49:26
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8709 Modified Files: nsd.h nsmain.c unix.c Log Message: Added watchdog implementation. Index: unix.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/unix.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** unix.c 26 Feb 2005 13:21:22 -0000 1.2 --- unix.c 17 Mar 2005 17:49:12 -0000 1.3 *************** *** 181,185 **** */ ! void NsHandleSignals(void) { --- 181,185 ---- */ ! int NsHandleSignals(void) { *************** *** 214,217 **** --- 214,219 ---- ns_sigmask(SIG_UNBLOCK, &set, NULL); + + return sig; } Index: nsd.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsd.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nsd.h 24 Feb 2005 17:24:52 -0000 1.2 --- nsd.h 17 Mar 2005 17:49:12 -0000 1.3 *************** *** 3,7 **** * Version 1.1 (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.mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" --- 3,7 ---- * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 97,105 **** #ifdef _WIN32 ! #define NS_SIGTERM 1 ! #define NS_SIGHUP 2 #else - #define NS_SIGTERM SIGTERM #define NS_SIGHUP SIGHUP #endif --- 97,107 ---- #ifdef _WIN32 ! #define NS_SIGHUP 1 ! #define NS_SIGINT 2 ! #define NS_SIGTERM 15 #else #define NS_SIGHUP SIGHUP + #define NS_SIGINT SIGINT + #define NS_SIGTERM SIGTERM #endif *************** *** 858,862 **** extern void NsStartServers(void); extern void NsBlockSignals(int debug); ! extern void NsHandleSignals(void); extern void NsStopDrivers(void); extern void NsPreBind(char *bindargs, char *bindfile); --- 860,864 ---- extern void NsStartServers(void); extern void NsBlockSignals(int debug); ! extern int NsHandleSignals(void); extern void NsStopDrivers(void); extern void NsPreBind(char *bindargs, char *bindfile); Index: nsmain.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/nsmain.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nsmain.c 26 Feb 2005 13:22:17 -0000 1.2 --- nsmain.c 17 Mar 2005 17:49:12 -0000 1.3 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 31,35 **** * nsmain.c -- * ! * AOLserver Ns_Main() startup routine. */ --- 31,35 ---- * nsmain.c -- * ! * NaviServer Ns_Main() startup routine. */ *************** *** 47,50 **** --- 47,55 ---- */ + static int StartWatchedServer(void); + static void SysLog(int priority, char *fmt, ...); + static void WatchdogSigtermHandler(int sig); + static int WaitForServer(); + static void UsageError(char *msg); static void StatusMsg(int state); *************** *** 56,59 **** --- 61,85 ---- #endif + /* + * Setup timer/counter values for graceously waiting before trying + * to restart crippled server. This should be configurable from the + * server config file (ns/watchdog section or alike). + */ + + #define MAX_RESTART_SECONDS 64 /* Max time in sec to wait between restarts */ + #define MIN_WORK_SECONDS 128 /* After being up for # secs, reset timers */ + #define MAX_NUM_RESTARTS 256 /* Quit after somany unsuccessful restarts */ + + #ifndef _WIN32 + # ifdef LOG_DEBUG + # undef LOG_DEBUG /* Because this is used by the syslog facility as well */ + # endif + # include <syslog.h> + # include <signal.h> + # include <stdarg.h> + # include <unistd.h> + static int watchdogExit = 0; /* Watchdog loop toggle */ + #endif /* _WIN32 */ + /* *************** *** 62,66 **** * Ns_Main -- * ! * The AOLserver startup routine called from main(). Startup is * somewhat complicated to ensure certain things happen in the * correct order. --- 88,92 ---- * Ns_Main -- * ! * The NaviServer startup routine called from main(). Startup is * somewhat complicated to ensure certain things happen in the * correct order. *************** *** 78,82 **** Ns_Main(int argc, char **argv, Ns_ServerInitProc *initProc) { ! int i, fd; char *config; Ns_Time timeout; --- 104,108 ---- Ns_Main(int argc, char **argv, Ns_ServerInitProc *initProc) { ! int i, fd, sig; char *config; Ns_Time timeout; *************** *** 146,150 **** /* ! * AOLserver requires file descriptor 0 be open on /dev/null to * ensure the server never blocks reading stdin. */ --- 172,176 ---- /* ! * NaviServer requires file descriptor 0 be open on /dev/null to * ensure the server never blocks reading stdin. */ *************** *** 178,182 **** opterr = 0; ! while ((i = getopt(argc, argv, "hpzifVs:t:IRSkKdr:u:g:b:B:")) != -1) { switch (i) { case 'h': --- 204,208 ---- opterr = 0; ! while ((i = getopt(argc, argv, "hpzifwVs:t:IRSkKdr:u:g:b:B:")) != -1) { switch (i) { case 'h': *************** *** 185,188 **** --- 211,215 ---- case 'f': case 'i': + case 'w': case 'V': #ifdef _WIN32 *************** *** 195,199 **** UsageError("only one of -i, -f, -V, -I, -R, or -S may be specified"); #else ! UsageError("only one of -i, -f, or -V may be specified"); #endif } --- 222,226 ---- UsageError("only one of -i, -f, -V, -I, -R, or -S may be specified"); #else ! UsageError("only one of -i, -f, -w, or -V may be specified"); #endif } *************** *** 248,252 **** } if (mode == 'V') { ! printf("AOLserver/%s (%s)\n", NSD_VERSION, Ns_InfoLabel()); printf(" CVS Tag: %s\n", Ns_InfoTag()); printf(" Built: %s\n", Ns_InfoBuildDate()); --- 275,279 ---- } if (mode == 'V') { ! printf("NaviServer/%s (%s)\n", NSD_VERSION, Ns_InfoLabel()); printf(" CVS Tag: %s\n", Ns_InfoTag()); printf(" Built: %s\n", Ns_InfoBuildDate()); *************** *** 312,315 **** --- 339,368 ---- } } + + /* + * If running as privileged user (root) check given user/group + * information and bail-out if any of them not really known. + */ + + if (getuid() == 0) { + + /* + * OK, so the caller is running as root. In such cases + * he/she should have used "-u" to give the actual user + * to run as (may be root as well) and optionally "-g" + * to set the process group. We're picky about the group + * though. If we were not able to figure out to which + * group the user belongs to, we will abort, no mercy. + */ + + if (uid == -1) { + Ns_Fatal("nsmain: will not run without valid user; " + "must specify '-u username' parameter"); + } + if (gid == -1) { + Ns_Fatal("nsmain: will not run for unknown group; " + "must specify '-g group' parameter"); + } + } /* *************** *** 338,341 **** --- 391,428 ---- /* + * Fork into the background and create a new session. + */ + + if (mode == 0 || mode == 'w') { + i = ns_fork(); + if (i == -1) { + Ns_Fatal("nsmain: fork() failed: '%s'", strerror(errno)); + } + if (i > 0) { + return 0; + } + setsid(); /* Detaches from the controlling terminal device */ + } + + /* + * Optionally, start the watchdog/server process pair. + * The watchdog process will monitor and restart the server unless + * the server exits gracefully, either by calling exit(0) or get + * signalled by the SIGTERM signal. + * The watchdog process itself will exit when the server process + * exits gracefully, or, when get signalled by the SIGTERM signal. + * In the latter case, watchdog will pass the SIGTERM to the server + * process, so both of them will gracefully terminate. + */ + + if (mode == 'w') { + if (StartWatchedServer() == 0) { + return 0; + } + } else { + nsconf.pid = getpid(); + } + + /* * Pre-bind any sockets now, before a possible setuid from root * or chroot which may hide /etc/resolv.conf required to *************** *** 358,386 **** nsconf.home = "/"; } ! /* ! * If caller is running as the privileged user, determine and change ! * to the run time (given) user and/or group. */ if (getuid() == 0) { - - /* - * OK, so the caller is running as root. In such cases - * he/she should have used "-u" to give the actual user - * to run as (may be root as well) and optionally "-g" - * to set the process group. We're picky about the group - * though. If we were not able to figure out to which - * group the user belongs to, we will abort, no mercy. - */ - - if (uid == -1) { - Ns_Fatal("nsmain: will not run without valid user; " - "must specify '-u username' parameter"); - } - if (gid == -1) { - Ns_Fatal("nsmain: will not run for unknown group; " - "must specify '-g group' parameter"); - } /* --- 445,455 ---- nsconf.home = "/"; } ! /* ! * If caller is running as the privileged user, change ! * to the run time (given) user and/or group now. */ if (getuid() == 0) { /* *************** *** 421,442 **** } #endif ! ! /* ! * Fork into the background and create a new session if running ! * in daemon mode. ! */ ! ! if (mode == 0) { ! i = ns_fork(); ! if (i < 0) { ! Ns_Fatal("nsmain: fork() failed: '%s'", strerror(errno)); ! } ! if (i > 0) { ! return 0; ! } ! nsconf.pid = getpid(); ! setsid(); ! } ! /* * Finally, block all signals for the duration of startup to ensure any --- 490,494 ---- } #endif ! /* * Finally, block all signals for the duration of startup to ensure any *************** *** 654,658 **** */ ! NsHandleSignals(); /* --- 706,710 ---- */ ! sig = NsHandleSignals(); /* *************** *** 710,714 **** NsRemovePidFile(procname); StatusMsg(3); ! return 0; } --- 762,772 ---- NsRemovePidFile(procname); StatusMsg(3); ! ! /* ! * The server exits gracefully on NS_SIGTERM. ! * All other signals are propagated to the caller. ! */ ! ! return (sig == NS_SIGTERM) ? 0 : sig; } *************** *** 780,790 **** * NsTclShutdownObjCmd -- * ! * Implements ns_shutdown as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 838,850 ---- * NsTclShutdownObjCmd -- * ! * Shutdown the server, waiting at most timeout seconds for threads ! * to exit cleanly before giving up. * * Results: ! * Tcl result. * * Side effects: ! * If -restart was specified and watchdog is active, server ! * will be restarted. * *---------------------------------------------------------------------- *************** *** 794,813 **** NsTclShutdownObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj **objv) { ! int timeout; ! if (objc != 1 && objc != 2) { ! Tcl_WrongNumArgs(interp, 1, objv, "?timeout?"); return TCL_ERROR; } ! if (objc == 1) { timeout = nsconf.shutdowntimeout; - } else if (Tcl_GetIntFromObj(interp, objv[1], &timeout) != TCL_OK) { - return TCL_ERROR; } - Tcl_SetIntObj(Tcl_GetObjResult(interp), timeout); - Ns_MutexLock(&nsconf.state.lock); - nsconf.shutdowntimeout = timeout; Ns_MutexUnlock(&nsconf.state.lock); ! NsSendSignal(NS_SIGTERM); return TCL_OK; } --- 854,884 ---- NsTclShutdownObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj **objv) { ! int timeout = 0, signal = NS_SIGTERM; ! Ns_ObjvSpec opts[] = { ! {"-restart", Ns_ObjvBool, &signal, (void *) NS_SIGINT}, ! {"--", Ns_ObjvBreak, NULL, NULL}, ! {NULL, NULL, NULL, NULL} ! }; ! Ns_ObjvSpec args[] = { ! {"?timeout", Ns_ObjvInt, &timeout, NULL}, ! {NULL, NULL, NULL, NULL} ! }; ! ! if (Ns_ParseObjv(opts, args, interp, 1, objc, objv) != NS_OK) { return TCL_ERROR; } ! ! Ns_MutexLock(&nsconf.state.lock); ! if (timeout > 0) { ! nsconf.shutdowntimeout = timeout; ! } else { timeout = nsconf.shutdowntimeout; } Ns_MutexUnlock(&nsconf.state.lock); ! ! NsSendSignal(signal); ! Tcl_SetIntObj(Tcl_GetObjResult(interp), timeout); ! return TCL_OK; } *************** *** 899,902 **** --- 970,974 ---- " -i inittab mode\n" " -f foreground mode\n" + " -w watchdog mode: restart a failed server\n" #ifdef _WIN32 " -I Install win32 service\n" *************** *** 950,951 **** --- 1022,1205 ---- return config; } + + /* + *---------------------------------------------------------------------- + * + * SysLog -- + * + * Logs a message to the system log facility + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + static void + SysLog(int priority, char *fmt, ...) + { + va_list ap; + + openlog("nsd", LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); + va_start(ap, fmt); + vsyslog(priority, fmt, ap); + va_end(ap); + closelog(); + } + + /* + *---------------------------------------------------------------------- + * + * WatchdogSigtermHandler -- + * + * Handle SIGTERM and pass to server process. + * + * Results: + * None. + * + * Side effects: + * Watchdog will not restart the server. + * + *---------------------------------------------------------------------- + */ + + static void + WatchdogSigtermHandler(int sig) + { + kill((pid_t) nsconf.pid, sig); + watchdogExit = 1; + } + + /* + *---------------------------------------------------------------------- + * + * WaitForServer -- + * + * Waits for the server process to exit or die due to an uncaught + * signal. + * + * Results: + * NS_OK if the server exited cleanly, NS_ERROR otherwise. + * + * Side effects: + * May wait forever... + * + *---------------------------------------------------------------------- + */ + + static int + WaitForServer() + { + int ret, status; + pid_t pid; + char *msg; + + do { + pid = waitpid(nsconf.pid, &status, 0); + } while (pid == -1 && errno == EINTR); + + if (WIFEXITED(status)) { + ret = WEXITSTATUS(status); + msg = "exited"; + } else if (WIFSIGNALED(status)) { + ret = WTERMSIG(status); + msg = "terminated"; + } else { + msg = "killed"; + ret = -1; /* Some waitpid (or other unknown) failure? */ + } + + SysLog(LOG_NOTICE, "watchdog: server %d %s (%d).", nsconf.pid, msg, ret); + + return ret ? NS_ERROR : NS_OK; + } + + /* + *---------------------------------------------------------------------- + * + * StartWatchedServer -- + * + * Restart the server process until it exits 0 or we exceed the + * maximum number of restart attempts. + * + * Results: + * None. + * + * Side effects: + * Install SIGTERM handler for watchdog process. + * Sets the global nsconf.pid with the process ID of the server. + * + *---------------------------------------------------------------------- + */ + + static int + StartWatchedServer(void) + { + unsigned int setSigterm = 0, startTime, numRestarts = 0, restartWait = 0; + + SysLog(LOG_NOTICE, "watchdog: started."); + + do { + if (restartWait) { + SysLog(LOG_WARNING, + "watchdog: waiting %d seconds before restart %d.", + restartWait, numRestarts); + sleep(restartWait); + } + nsconf.pid = ns_fork(); + if (nsconf.pid == -1) { + SysLog(LOG_ERR, "watchdog: fork() failed: '%s'.", strerror(errno)); + Ns_Fatal("watchdog: fork() failed: '%s'.", strerror(errno)); + } + if (nsconf.pid == 0) { + /* Server process. */ + nsconf.pid = getpid(); + SysLog(LOG_NOTICE, "server: started."); + return nsconf.pid; + } + + /* Watchdog process */ + + /* + * Register SIGTERM handler so we can gracefully stop the server. + * The watchdog will exit w/o stopping the server if got signalled + * with any other signal, though. + */ + + if (setSigterm == 0) { + setSigterm = 1; + ns_signal(SIGTERM, WatchdogSigtermHandler); + } + + startTime = time(NULL); + + if (WaitForServer() == NS_OK) { + break; + } + + if ((time(NULL) - startTime) > MIN_WORK_SECONDS) { + restartWait = numRestarts = 0; + } + + if (++numRestarts > MAX_NUM_RESTARTS) { + SysLog(LOG_WARNING, "watchdog: exceeded restart limit of %d", + MAX_NUM_RESTARTS); + break; + } + + restartWait *= 2; + if (restartWait > MAX_RESTART_SECONDS) { + restartWait = MAX_RESTART_SECONDS; + } else if (restartWait == 0) { + restartWait = 1; + } + + } while (!watchdogExit); + + SysLog(LOG_NOTICE, "watchdog: exited."); + + return 0; + } |
From: Vlad S. <ser...@us...> - 2005-03-13 02:10:06
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23234 Modified Files: ChangeLog Makefile Log Message: modules nspd and nsext have been moved into modules/ section Index: Makefile =================================================================== RCS file: /cvsroot/naviserver/naviserver/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile 16 Feb 2005 16:45:43 -0000 1.2 --- Makefile 13 Mar 2005 02:09:53 -0000 1.3 *************** *** 34,38 **** include include/Makefile.global ! dirs = nsthread nsd nssock nscgi nscp nslog nsperm nsdb nsext nspd all: --- 34,38 ---- include include/Makefile.global ! dirs = nsthread nsd nssock nscgi nscp nslog nsperm nsdb all: Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ChangeLog 8 Mar 2005 20:15:55 -0000 1.18 --- ChangeLog 13 Mar 2005 02:09:52 -0000 1.19 *************** *** 1,2 **** --- 1,7 ---- + 2005-03-12 Vlad Seryakov <vl...@cr...> + + * nspd/ + * nsext/: moved modules out of the core into modules /section + 2005-03-08 Vlad Seryakov <vl...@cr...> |
From: Vlad S. <ser...@us...> - 2005-03-13 02:08:20
|
Update of /cvsroot/naviserver/naviserver/nspd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22882/nspd Removed Files: Makefile listen.c log.c main.c pd.h Log Message: nspd module has been moved into modules/ section --- listen.c DELETED --- --- pd.h DELETED --- --- Makefile DELETED --- --- main.c DELETED --- --- log.c DELETED --- |
From: Vlad S. <ser...@us...> - 2005-03-13 02:05:50
|
Update of /cvsroot/naviserver/naviserver/nsext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22299/nsext Removed Files: Makefile msg.c nsext.c Log Message: nsext module has been moved into modules/ section --- Makefile DELETED --- --- msg.c DELETED --- --- nsext.c DELETED --- |
From: Vlad S. <ser...@us...> - 2005-03-08 20:16:07
|
Update of /cvsroot/naviserver/naviserver/nslog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14961/nslog Modified Files: nslog.c Log Message: as Stephan pointed there is possibility for server to crash under some conditions accessing already freed extheaders pointer. So i put lock before putting extheaders values in the log, in most cases extheaders are empty so there is no overhead. Index: nslog.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nslog/nslog.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** nslog.c 7 Mar 2005 08:34:05 -0000 1.4 --- nslog.c 8 Mar 2005 20:15:55 -0000 1.5 *************** *** 380,383 **** --- 380,385 ---- } + status = NS_OK; + Ns_MutexLock(&logPtr->lock); /* Append the extended headers(if any). */ for (h = logPtr->extheaders; *h; h++) { *************** *** 389,395 **** /* Append the trailing newline and buffer and/or flush the line. */ - status = NS_OK; Ns_DStringAppend(&ds,"\n"); - Ns_MutexLock(&logPtr->lock); if (logPtr->maxlines <= 0) { status = LogFlush(logPtr,&ds); --- 391,395 ---- *************** *** 480,485 **** } Ns_MutexLock(&logPtr->lock); - /* Wait for others to finish logging extheaders */ - sleep(1); logPtr->extheaders = h1; Ns_MutexUnlock(&logPtr->lock); --- 480,483 ---- |
From: Vlad S. <ser...@us...> - 2005-03-08 20:16:07
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14961 Modified Files: ChangeLog Log Message: as Stephan pointed there is possibility for server to crash under some conditions accessing already freed extheaders pointer. So i put lock before putting extheaders values in the log, in most cases extheaders are empty so there is no overhead. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ChangeLog 8 Mar 2005 04:59:37 -0000 1.17 --- ChangeLog 8 Mar 2005 20:15:55 -0000 1.18 *************** *** 1,2 **** --- 1,9 ---- + 2005-03-08 Vlad Seryakov <vl...@cr...> + + * nslog/nslog.c: as Stephan pointed there is possibility for + server to crash under some conditions accessing already freed + extheaders pointer. So i put lock before putting extheaders values + in the log, in most cases extheaders are empty so there is no overhead. + 2005-03-07 Zoran Vasiljevic <vas...@us...> |
From: Vlad S. <ser...@us...> - 2005-03-08 04:59:51
|
Update of /cvsroot/naviserver/naviserver/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8043/include Modified Files: ns.h Log Message: Changed return status for Ns_ConnSetResponseStatus to void, corrected comments for this function Index: ns.h =================================================================== RCS file: /cvsroot/naviserver/naviserver/include/ns.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ns.h 5 Mar 2005 23:28:24 -0000 1.7 --- ns.h 8 Mar 2005 04:59:38 -0000 1.8 *************** *** 626,630 **** NS_EXTERN char *Ns_ConnServer(Ns_Conn *conn); NS_EXTERN int Ns_ConnResponseStatus(Ns_Conn *conn); ! NS_EXTERN int Ns_ConnSetResponseStatus(Ns_Conn *conn, int new_status); NS_EXTERN int Ns_ConnContentSent(Ns_Conn *conn); NS_EXTERN int Ns_ConnResponseLength(Ns_Conn *conn); --- 626,630 ---- NS_EXTERN char *Ns_ConnServer(Ns_Conn *conn); NS_EXTERN int Ns_ConnResponseStatus(Ns_Conn *conn); ! NS_EXTERN void Ns_ConnSetResponseStatus(Ns_Conn *conn, int new_status); NS_EXTERN int Ns_ConnContentSent(Ns_Conn *conn); NS_EXTERN int Ns_ConnResponseLength(Ns_Conn *conn); |
From: Vlad S. <ser...@us...> - 2005-03-08 04:59:51
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8043 Modified Files: ChangeLog Log Message: Changed return status for Ns_ConnSetResponseStatus to void, corrected comments for this function Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ChangeLog 7 Mar 2005 08:38:31 -0000 1.16 --- ChangeLog 8 Mar 2005 04:59:37 -0000 1.17 *************** *** 5,8 **** --- 5,14 ---- defined. + 2005-03-07 Vlad Seryakov <vl...@cr...> + + * include/hs.h: + * nsd/conn.c: changed return status for Ns_ConnSetResponseStatus + to void, corrected comments for this function. + 2005-03-06 Vlad Seryakov <vl...@cr...> |
From: Vlad S. <ser...@us...> - 2005-03-08 04:59:50
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8043/nsd Modified Files: conn.c Log Message: Changed return status for Ns_ConnSetResponseStatus to void, corrected comments for this function Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** conn.c 5 Mar 2005 23:28:25 -0000 1.2 --- conn.c 8 Mar 2005 04:59:39 -0000 1.3 *************** *** 242,246 **** * * Results: ! * Previous response status as an integer response code (e.g., 200 for OK) * * Side effects: --- 242,246 ---- * * Results: ! * None * * Side effects: *************** *** 250,254 **** */ ! int Ns_ConnSetResponseStatus(Ns_Conn *conn, int new_status) { --- 250,254 ---- */ ! void Ns_ConnSetResponseStatus(Ns_Conn *conn, int new_status) { *************** *** 256,260 **** connPtr->responseStatus = new_status; - return new_status; } --- 256,259 ---- |
From: Zoran V. <vas...@us...> - 2005-03-07 08:38:44
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26056 Modified Files: ChangeLog Log Message: See file Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ChangeLog 6 Mar 2005 22:48:26 -0000 1.15 --- ChangeLog 7 Mar 2005 08:38:31 -0000 1.16 *************** *** 1,2 **** --- 1,8 ---- + 2005-03-07 Zoran Vasiljevic <vas...@us...> + + * nslog/nslog.c: fixed bad handling of rollfmt arg which + caused segmetantion if the alternative rollfmt was not + defined. + 2005-03-06 Vlad Seryakov <vl...@cr...> |
From: Zoran V. <vas...@us...> - 2005-03-07 08:34:25
|
Update of /cvsroot/naviserver/naviserver/nslog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25017 Modified Files: nslog.c Log Message: Fixed wrong handling of rollfmt handling which caused segmentations. Index: nslog.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nslog/nslog.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** nslog.c 5 Mar 2005 23:28:25 -0000 1.3 --- nslog.c 7 Mar 2005 08:34:05 -0000 1.4 *************** *** 216,220 **** /* Get parameters from configuration file */ logPtr->rollfmt = Ns_ConfigGetValue(path,"rollfmt"); ! if (logPtr->rollfmt == NULL) { logPtr->rollfmt = ns_strdup(logPtr->rollfmt); } --- 216,220 ---- /* Get parameters from configuration file */ logPtr->rollfmt = Ns_ConfigGetValue(path,"rollfmt"); ! if (logPtr->rollfmt != NULL) { logPtr->rollfmt = ns_strdup(logPtr->rollfmt); } |
From: Vlad S. <ser...@us...> - 2005-03-06 22:48:56
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15462/nsd Modified Files: tclcmds.c tclmisc.c Log Message: added ns_sha1 command Index: tclmisc.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclmisc.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tclmisc.c 16 Feb 2005 08:40:12 -0000 1.1.1.1 --- tclmisc.c 6 Mar 2005 22:48:27 -0000 1.2 *************** *** 639,640 **** --- 639,1080 ---- } } + + /* + * The SHA1 routines are borrowed from libmd, which contains the following header: + * + * * sha.c - NIST Secure Hash Algorithm, FIPS PUB 180 and 180.1. + * * The algorithm is by spook(s) unknown at the U.S. National Security Agency. + * * + * * Written 2 September 1992, Peter C. Gutmann. + * * This implementation placed in the public domain. + * * + * * Modified 1 June 1993, Colin Plumb. + * * Modified for the new SHS based on Peter Gutmann's work, + * * 18 July 1994, Colin Plumb. + * * + * * Renamed to SHA and comments updated a bit 1 November 1995, Colin Plumb. + * * These modifications placed in the public domain. + * * + * * Comments to pg...@cs... + * * + * * Hacked for use in libmd by Martin Hinner <mh...@pe...> + * + * This Tcl library was hacked by Jon Salz <js...@mi...>. + * + */ + + static char hexChars[] = "0123456789ABCDEF"; + + typedef unsigned int u_int32_t; + typedef unsigned char u_int8_t; + + /*** FROM sha.h: ***/ + + /* + * Define to 1 for FIPS 180.1 version (with extra rotate in prescheduling), + * 0 for FIPS 180 version (with the mysterious "weakness" that the NSA + * isn't talking about). + */ + #define SHA_VERSION 1 + + #define SHA_BLOCKBYTES 64 + #define SHA_BLOCKWORDS 16 + + #define SHA_HASHBYTES 20 + #define SHA_HASHWORDS 5 + + /* SHA context. */ + typedef struct SHAContext { + unsigned int key[SHA_BLOCKWORDS]; + u_int32_t iv[SHA_HASHWORDS]; + #ifdef HAVE64 + u_int64_t bytes; + #else + u_int32_t bytesHi, bytesLo; + #endif + } SHA_CTX; + + /*** END sha.h ***/ + + /*** FROM sha.c: ***/ + + /* + Shuffle the bytes into big-endian order within words, as per the + SHA spec. + */ + static void + shaByteSwap (u_int32_t * dest, u_int8_t const *src, unsigned int words) + { + do + { + *dest++ = (u_int32_t) ((unsigned) src[0] << 8 | src[1]) << 16 | + ((unsigned) src[2] << 8 | src[3]); + src += 4; + } + while (--words); + } + + /* Initialize the SHA values */ + static void + SHAInit (SHA_CTX * ctx) + { + + /* Set the h-vars to their initial values */ + ctx->iv[0] = 0x67452301; + ctx->iv[1] = 0xEFCDAB89; + ctx->iv[2] = 0x98BADCFE; + ctx->iv[3] = 0x10325476; + ctx->iv[4] = 0xC3D2E1F0; + + /* Initialise bit count */ + #ifdef HAVE64 + ctx->bytes = 0; + #else + ctx->bytesHi = 0; + ctx->bytesLo = 0; + #endif + } + + /* + The SHA f()-functions. The f1 and f3 functions can be optimized to + save one boolean operation each - thanks to Rich Schroeppel, + rc...@cs... for discovering this. + The f3 function can be modified to use an addition to combine the + two halves rather than OR, allowing more opportunity for using + associativity in optimization. (Colin Plumb) + + Note that it may be necessary to add parentheses to these macros + if they are to be called with expressions as arguments. + */ + #define f1(x,y,z) ( z ^ (x & (y ^ z) ) ) /* Rounds 0-19 */ + #define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */ + #define f3(x,y,z) ( (x & y) + (z & (x ^ y) ) ) /* Rounds 40-59 */ + #define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */ + + /* The SHA Mysterious Constants. */ + #define K2 0x5A827999L /* Rounds 0 -19 - floor(sqrt(2) * 2^30) */ + #define K3 0x6ED9EBA1L /* Rounds 20-39 - floor(sqrt(3) * 2^30) */ + #define K5 0x8F1BBCDCL /* Rounds 40-59 - floor(sqrt(5) * 2^30) */ + #define K10 0xCA62C1D6L /* Rounds 60-79 - floor(sqrt(10) * 2^30) */ + + /* 32-bit rotate left - kludged with shifts */ + #define ROTL(n,X) ( (X << n) | (X >> (32-n)) ) + + /* + The initial expanding function + + The hash function is defined over an 80-word expanded input array W, + where the first 16 are copies of the input data, and the remaining 64 + are defined by W[i] = W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3]. This + implementation generates these values on the fly in a circular buffer. + + The new "corrected" FIPS 180.1 added a 1-bit left rotate to this + computation of W[i]. + + The expandx() version doesn't write the result back, which can be + used for the last three rounds since those outputs are never used. + */ + #if SHA_VERSION /* FIPS 180.1 */ + + #define expandx(W,i) (t = W[i&15] ^ W[(i-14)&15] ^ W[(i-8)&15] ^ W[(i-3)&15],\ + ROTL(1, t)) + #define expand(W,i) (W[i&15] = expandx(W,i)) + + #else /* Old FIPS 180 */ + + #define expandx(W,i) (W[i&15] ^ W[(i-14)&15] ^ W[(i-8)&15] ^ W[(i-3)&15]) + #define expand(W,i) (W[i&15] ^= W[(i-14)&15] ^ W[(i-8)&15] ^ W[(i-3)&15])a + + #endif /* SHA_VERSION */ + + /* + The prototype SHA sub-round + + The fundamental sub-round is + a' = e + ROTL(5,a) + f(b, c, d) + k + data; + b' = a; + c' = ROTL(30,b); + d' = c; + e' = d; + ... but this is implemented by unrolling the loop 5 times and renaming + the variables (e,a,b,c,d) = (a',b',c',d',e') each iteration. + */ + #define subRound(a, b, c, d, e, f, k, data) \ + ( e += ROTL(5,a) + f(b, c, d) + k + data, b = ROTL(30, b) ) + /* + The above code is replicated 20 times for each of the 4 functions, + using the next 20 values from the W[] array for "data" each time. + */ + + /* + Perform the SHA transformation. Note that this code, like MD5, seems to + break some optimizing compilers due to the complexity of the expressions + and the size of the basic block. It may be necessary to split it into + sections, e.g. based on the four subrounds + + Note that this corrupts the sha->key area. + */ + static void + SHATransform (struct SHAContext *sha) + { + register u_int32_t A, B, C, D, E; + #if SHA_VERSION + register u_int32_t t; + #endif + + /* Set up first buffer */ + A = sha->iv[0]; + B = sha->iv[1]; + C = sha->iv[2]; + D = sha->iv[3]; + E = sha->iv[4]; + + /* Heavy mangling, in 4 sub-rounds of 20 interations each. */ + subRound (A, B, C, D, E, f1, K2, sha->key[0]); + subRound (E, A, B, C, D, f1, K2, sha->key[1]); + subRound (D, E, A, B, C, f1, K2, sha->key[2]); + subRound (C, D, E, A, B, f1, K2, sha->key[3]); + subRound (B, C, D, E, A, f1, K2, sha->key[4]); + subRound (A, B, C, D, E, f1, K2, sha->key[5]); + subRound (E, A, B, C, D, f1, K2, sha->key[6]); + subRound (D, E, A, B, C, f1, K2, sha->key[7]); + subRound (C, D, E, A, B, f1, K2, sha->key[8]); + subRound (B, C, D, E, A, f1, K2, sha->key[9]); + subRound (A, B, C, D, E, f1, K2, sha->key[10]); + subRound (E, A, B, C, D, f1, K2, sha->key[11]); + subRound (D, E, A, B, C, f1, K2, sha->key[12]); + subRound (C, D, E, A, B, f1, K2, sha->key[13]); + subRound (B, C, D, E, A, f1, K2, sha->key[14]); + subRound (A, B, C, D, E, f1, K2, sha->key[15]); + subRound (E, A, B, C, D, f1, K2, expand (sha->key, 16)); + subRound (D, E, A, B, C, f1, K2, expand (sha->key, 17)); + subRound (C, D, E, A, B, f1, K2, expand (sha->key, 18)); + subRound (B, C, D, E, A, f1, K2, expand (sha->key, 19)); + + subRound (A, B, C, D, E, f2, K3, expand (sha->key, 20)); + subRound (E, A, B, C, D, f2, K3, expand (sha->key, 21)); + subRound (D, E, A, B, C, f2, K3, expand (sha->key, 22)); + subRound (C, D, E, A, B, f2, K3, expand (sha->key, 23)); + subRound (B, C, D, E, A, f2, K3, expand (sha->key, 24)); + subRound (A, B, C, D, E, f2, K3, expand (sha->key, 25)); + subRound (E, A, B, C, D, f2, K3, expand (sha->key, 26)); + subRound (D, E, A, B, C, f2, K3, expand (sha->key, 27)); + subRound (C, D, E, A, B, f2, K3, expand (sha->key, 28)); + subRound (B, C, D, E, A, f2, K3, expand (sha->key, 29)); + subRound (A, B, C, D, E, f2, K3, expand (sha->key, 30)); + subRound (E, A, B, C, D, f2, K3, expand (sha->key, 31)); + subRound (D, E, A, B, C, f2, K3, expand (sha->key, 32)); + subRound (C, D, E, A, B, f2, K3, expand (sha->key, 33)); + subRound (B, C, D, E, A, f2, K3, expand (sha->key, 34)); + subRound (A, B, C, D, E, f2, K3, expand (sha->key, 35)); + subRound (E, A, B, C, D, f2, K3, expand (sha->key, 36)); + subRound (D, E, A, B, C, f2, K3, expand (sha->key, 37)); + subRound (C, D, E, A, B, f2, K3, expand (sha->key, 38)); + subRound (B, C, D, E, A, f2, K3, expand (sha->key, 39)); + + subRound (A, B, C, D, E, f3, K5, expand (sha->key, 40)); + subRound (E, A, B, C, D, f3, K5, expand (sha->key, 41)); + subRound (D, E, A, B, C, f3, K5, expand (sha->key, 42)); + subRound (C, D, E, A, B, f3, K5, expand (sha->key, 43)); + subRound (B, C, D, E, A, f3, K5, expand (sha->key, 44)); + subRound (A, B, C, D, E, f3, K5, expand (sha->key, 45)); + subRound (E, A, B, C, D, f3, K5, expand (sha->key, 46)); + subRound (D, E, A, B, C, f3, K5, expand (sha->key, 47)); + subRound (C, D, E, A, B, f3, K5, expand (sha->key, 48)); + subRound (B, C, D, E, A, f3, K5, expand (sha->key, 49)); + subRound (A, B, C, D, E, f3, K5, expand (sha->key, 50)); + subRound (E, A, B, C, D, f3, K5, expand (sha->key, 51)); + subRound (D, E, A, B, C, f3, K5, expand (sha->key, 52)); + subRound (C, D, E, A, B, f3, K5, expand (sha->key, 53)); + subRound (B, C, D, E, A, f3, K5, expand (sha->key, 54)); + subRound (A, B, C, D, E, f3, K5, expand (sha->key, 55)); + subRound (E, A, B, C, D, f3, K5, expand (sha->key, 56)); + subRound (D, E, A, B, C, f3, K5, expand (sha->key, 57)); + subRound (C, D, E, A, B, f3, K5, expand (sha->key, 58)); + subRound (B, C, D, E, A, f3, K5, expand (sha->key, 59)); + + subRound (A, B, C, D, E, f4, K10, expand (sha->key, 60)); + subRound (E, A, B, C, D, f4, K10, expand (sha->key, 61)); + subRound (D, E, A, B, C, f4, K10, expand (sha->key, 62)); + subRound (C, D, E, A, B, f4, K10, expand (sha->key, 63)); + subRound (B, C, D, E, A, f4, K10, expand (sha->key, 64)); + subRound (A, B, C, D, E, f4, K10, expand (sha->key, 65)); + subRound (E, A, B, C, D, f4, K10, expand (sha->key, 66)); + subRound (D, E, A, B, C, f4, K10, expand (sha->key, 67)); + subRound (C, D, E, A, B, f4, K10, expand (sha->key, 68)); + subRound (B, C, D, E, A, f4, K10, expand (sha->key, 69)); + subRound (A, B, C, D, E, f4, K10, expand (sha->key, 70)); + subRound (E, A, B, C, D, f4, K10, expand (sha->key, 71)); + subRound (D, E, A, B, C, f4, K10, expand (sha->key, 72)); + subRound (C, D, E, A, B, f4, K10, expand (sha->key, 73)); + subRound (B, C, D, E, A, f4, K10, expand (sha->key, 74)); + subRound (A, B, C, D, E, f4, K10, expand (sha->key, 75)); + subRound (E, A, B, C, D, f4, K10, expand (sha->key, 76)); + subRound (D, E, A, B, C, f4, K10, expandx (sha->key, 77)); + subRound (C, D, E, A, B, f4, K10, expandx (sha->key, 78)); + subRound (B, C, D, E, A, f4, K10, expandx (sha->key, 79)); + + /* Build message digest */ + sha->iv[0] += A; + sha->iv[1] += B; + sha->iv[2] += C; + sha->iv[3] += D; + sha->iv[4] += E; + } + + /* Update SHA for a block of data. */ + static void + SHAUpdate (SHA_CTX * ctx, const unsigned char *buf, unsigned int len) + { + unsigned i; + + /* Update bitcount */ + + #ifdef HAVE64 + i = (unsigned) ctx->bytes % SHA_BLOCKBYTES; + ctx->bytes += len; + #else + u_int32_t t = ctx->bytesLo; + if ((ctx->bytesLo = t + len) < t) + ctx->bytesHi++; /* Carry from low to high */ + + i = (unsigned) t % SHA_BLOCKBYTES; /* Bytes already in ctx->key */ + #endif + + /* i is always less than SHA_BLOCKBYTES. */ + if (SHA_BLOCKBYTES - i > len) + { + memcpy ((u_int8_t *) ctx->key + i, buf, len); + return; + } + + if (i) + { /* First chunk is an odd size */ + memcpy ((u_int8_t *) ctx->key + i, buf, SHA_BLOCKBYTES - i); + shaByteSwap (ctx->key, (u_int8_t *) ctx->key, SHA_BLOCKWORDS); + SHATransform (ctx); + buf += SHA_BLOCKBYTES - i; + len -= SHA_BLOCKBYTES - i; + } + + /* Process data in 64-byte chunks */ + while (len >= SHA_BLOCKBYTES) + { + shaByteSwap (ctx->key, buf, SHA_BLOCKWORDS); + SHATransform (ctx); + buf += SHA_BLOCKBYTES; + len -= SHA_BLOCKBYTES; + } + + /* Handle any remaining bytes of data. */ + if (len) + memcpy (ctx->key, buf, len); + } + + /* + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ + + static void + SHAFinal (unsigned char digest[20], SHA_CTX * ctx) + { + #if HAVE64 + unsigned i = (unsigned) ctx->bytes % SHA_BLOCKBYTES; + #else + unsigned i = (unsigned) ctx->bytesLo % SHA_BLOCKBYTES; + #endif + u_int8_t *p = (u_int8_t *) ctx->key + i; /* First unused byte */ + u_int32_t t; + + /* Set the first char of padding to 0x80. There is always room. */ + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes (0..63) */ + i = SHA_BLOCKBYTES - 1 - i; + + if (i < 8) + { /* Padding forces an extra block */ + memset (p, 0, i); + shaByteSwap (ctx->key, (u_int8_t *) ctx->key, 16); + SHATransform (ctx); + p = (u_int8_t *) ctx->key; + i = 64; + } + memset (p, 0, i - 8); + shaByteSwap (ctx->key, (u_int8_t *) ctx->key, 14); + + /* Append length in bits and transform */ + #if HAVE64 + ctx->key[14] = (u_int32_t) (ctx->bytes >> 29); + ctx->key[15] = (u_int32_t) ctx->bytes << 3; + #else + ctx->key[14] = ctx->bytesHi << 3 | ctx->bytesLo >> 29; + ctx->key[15] = ctx->bytesLo << 3; + #endif + SHATransform (ctx); + + memcpy (digest, ctx->iv, sizeof (digest)); + for (i = 0; i < SHA_HASHWORDS; i++) + { + t = ctx->iv[i]; + digest[i * 4 + 0] = (u_int8_t) (t >> 24); + digest[i * 4 + 1] = (u_int8_t) (t >> 16); + digest[i * 4 + 2] = (u_int8_t) (t >> 8); + digest[i * 4 + 3] = (u_int8_t) t; + } + + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + } + + /*** END sha.c ***/ + + + + /* + *---------------------------------------------------------------------- + * + * SHA1Cmd -- + * + * Returns a 40-character, hex-encoded string containing the SHA1 + * hash of the first argument. + * + * Results: + * NS_OK + * + * Side effects: + * Tcl result is set to a string value. + * + *---------------------------------------------------------------------- + */ + + int + NsTclSHA1ObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) + { + SHA_CTX ctx; + char digest[20]; + char digestChars[41]; + int i; + char *str; + int strLen; + + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, "string"); + return TCL_ERROR; + } + + str = Tcl_GetStringFromObj(objv[1],&strLen); + SHAInit(&ctx); + SHAUpdate(&ctx, str, strLen); + SHAFinal(digest, &ctx); + + for (i = 0; i < 20; ++i) { + digestChars[i * 2] = hexChars[(unsigned char)(digest[i]) >> 4]; + digestChars[i * 2 + 1] = hexChars[(unsigned char)(digest[i]) & 0xF]; + } + digestChars[40] = '\0'; + + Tcl_AppendResult(interp, digestChars, NULL); + + return NS_OK; + } Index: tclcmds.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclcmds.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tclcmds.c 6 Mar 2005 18:37:07 -0000 1.3 --- tclcmds.c 6 Mar 2005 22:48:27 -0000 1.4 *************** *** 162,166 **** NsTclWriteContentObjCmd, NsTclWriteFpObjCmd, ! NsTclWriteObjCmd; extern Tcl_CmdProc --- 162,167 ---- NsTclWriteContentObjCmd, NsTclWriteFpObjCmd, ! NsTclWriteObjCmd, ! NsTclSHA1ObjCmd; extern Tcl_CmdProc *************** *** 259,262 **** --- 260,268 ---- {"ns_guesstype", NULL, NsTclGuessTypeObjCmd}, + /* + * tclmisc.c + */ + + {"ns_sha1", NULL, NsTclSHA1ObjCmd}, {"ns_striphtml", NsTclStripHtmlCmd, NULL}, {"ns_quotehtml", NsTclQuoteHtmlCmd, NULL}, |
From: Vlad S. <ser...@us...> - 2005-03-06 22:48:39
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15462 Modified Files: ChangeLog Log Message: added ns_sha1 command Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ChangeLog 6 Mar 2005 18:39:01 -0000 1.14 --- ChangeLog 6 Mar 2005 22:48:26 -0000 1.15 *************** *** 1,2 **** --- 1,7 ---- + 2005-03-06 Vlad Seryakov <vl...@cr...> + + * nsd/tclmisc.c: + * nsd/tclcmds.c: added ns_sha1 command. + 2005-03-06 Zoran Vasiljevic <vas...@us...> |
From: Zoran V. <vas...@us...> - 2005-03-06 18:39:12
|
Update of /cvsroot/naviserver/naviserver In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11800 Modified Files: ChangeLog Log Message: See file. Index: ChangeLog =================================================================== RCS file: /cvsroot/naviserver/naviserver/ChangeLog,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ChangeLog 5 Mar 2005 23:28:23 -0000 1.13 --- ChangeLog 6 Mar 2005 18:39:01 -0000 1.14 *************** *** 1,2 **** --- 1,7 ---- + 2005-03-06 Zoran Vasiljevic <vas...@us...> + + * nsd/tclxkeylist.c: + * nsd/tclcmds.c: added objectified version of TclX keyed lists. + 2005-03-05 Vlad Seryakov <vl...@cr...> |
From: Zoran V. <vas...@us...> - 2005-03-06 18:37:19
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11209/nsd Modified Files: tclcmds.c tclxkeylist.c Log Message: Added objectified interface to TclX keyed lists. Tcl-API and C-API are left compatible with older string interface. Index: tclcmds.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclcmds.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tclcmds.c 22 Feb 2005 20:33:32 -0000 1.2 --- tclcmds.c 6 Mar 2005 18:37:07 -0000 1.3 *************** *** 206,213 **** NsTclThreadCmd, NsTclUnscheduleCmd, ! Tcl_KeyldelCmd, ! Tcl_KeylgetCmd, ! Tcl_KeylkeysCmd, ! Tcl_KeylsetCmd; /* --- 206,213 ---- NsTclThreadCmd, NsTclUnscheduleCmd, ! TclX_KeyldelObjCmd, ! TclX_KeylgetObjCmd, ! TclX_KeylkeysObjCmd, ! TclX_KeylsetObjCmd; /* *************** *** 359,366 **** */ ! {"keyldel", Tcl_KeyldelCmd, NULL}, ! {"keylget", Tcl_KeylgetCmd, NULL}, ! {"keylkeys", Tcl_KeylkeysCmd, NULL}, ! {"keylset", Tcl_KeylsetCmd, NULL}, /* --- 359,366 ---- */ ! {"keyldel", TclX_KeyldelObjCmd, NULL}, ! {"keylget", TclX_KeylgetObjCmd, NULL}, ! {"keylkeys", TclX_KeylkeysObjCmd, NULL}, ! {"keylset", TclX_KeylsetObjCmd, NULL}, /* Index: tclxkeylist.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclxkeylist.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** tclxkeylist.c 16 Feb 2005 08:40:21 -0000 1.1.1.1 --- tclxkeylist.c 6 Mar 2005 18:37:07 -0000 1.2 *************** *** 2,9 **** * tclxkeylist.c -- * ! * Keyed list support, modified from the original ! * Tcl7.x based TclX and Tcl source. ! * ! * Copyright (c) 1995-1998 America Online Inc. * */ --- 2,7 ---- * tclxkeylist.c -- [...2707 lines suppressed...] ! ! Tcl_CreateObjCommand (interp, ! "keylset", ! TclX_KeylsetObjCmd, ! (ClientData) NULL, ! (Tcl_CmdDeleteProc*) NULL); ! ! Tcl_CreateObjCommand (interp, ! "keyldel", ! TclX_KeyldelObjCmd, ! (ClientData) NULL, ! (Tcl_CmdDeleteProc*) NULL); ! ! Tcl_CreateObjCommand (interp, ! "keylkeys", ! TclX_KeylkeysObjCmd, ! (ClientData) NULL, ! (Tcl_CmdDeleteProc*) NULL); } + |
From: Vlad S. <ser...@us...> - 2005-03-05 23:28:36
|
Update of /cvsroot/naviserver/naviserver/nslog In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1286/nslog Modified Files: nslog.c Log Message: Add Ns_ConnSetResponseStatus command to be able to se response status without touching headers. Also ns_conn status has been extended with ability to set response status if third argument is provided. ns_conn status ?newStatus? Index: nslog.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nslog/nslog.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** nslog.c 1 Mar 2005 21:39:57 -0000 1.2 --- nslog.c 5 Mar 2005 23:28:25 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- */ + static const char *RCSID = "@(#) $Header$, compiled: " __DATE__ " " __TIME__; /* *************** *** 170,177 **** /* Register the info callbacks just once. */ ! if(first) { ! Ns_RegisterProcInfo((void *)LogRollCallback,"logroll",LogArg); ! Ns_RegisterProcInfo((void *)LogCloseCallback,"logclose",LogArg); ! first = 0; } --- 171,178 ---- /* Register the info callbacks just once. */ ! if (first) { ! Ns_RegisterProcInfo((void *)LogRollCallback,"logroll",LogArg); ! Ns_RegisterProcInfo((void *)LogCloseCallback,"logclose",LogArg); ! first = 0; } *************** *** 193,247 **** path = Ns_ConfigGetPath(server,module,NULL); ! if(!(logPtr->file = Ns_ConfigGetValue(path,"file"))) logPtr->file = "access.log"; logPtr->file = ns_strdup(logPtr->file); ! if(Ns_PathIsAbsolute(logPtr->file) == NS_FALSE) { ! Ns_ModulePath(&ds,server,module,NULL,NULL); ! if(mkdir(ds.string,0755) != 0 && errno != EEXIST && errno != EISDIR) { ! Ns_Log(Error,"nslog: mkdir(%s) failed: %s",ds.string,strerror(errno)); ! Ns_DStringFree(&ds); ! return NS_ERROR; ! } ! Ns_DStringTrunc(&ds,0); ! Ns_ModulePath(&ds,server,module,logPtr->file,NULL); ! logPtr->file = Ns_DStringExport(&ds); } /* Get parameters from configuration file */ ! if((logPtr->rollfmt = Ns_ConfigGetValue(path,"rollfmt"))) ! logPtr->rollfmt = ns_strdup(logPtr->rollfmt); ! if(!Ns_ConfigGetInt(path,"maxbackup",&logPtr->maxbackup) || logPtr->maxbackup < 1) ! logPtr->maxbackup = 100; ! if(!Ns_ConfigGetInt(path,"maxbuffer",&logPtr->maxlines)) ! logPtr->maxlines = 0; ! if(!Ns_ConfigGetBool(path,"formattedTime",&opt) || opt) ! logPtr->flags |= LOG_FMTTIME; ! if(!Ns_ConfigGetBool(path,"logcombined",&opt) || opt) ! logPtr->flags |= LOG_COMBINED; ! if(Ns_ConfigGetBool(path,"logreqtime",&opt) && opt) ! logPtr->flags |= LOG_REQTIME; ! if(Ns_ConfigGetBool(path,"suppressquery",&opt) && opt) ! logPtr->flags |= LOG_SUPPRESSQUERY; ! if(Ns_ConfigGetBool(path,"checkforproxy",&opt) && opt) ! logPtr->flags |= LOG_CHECKFORPROXY; ! /* Schedule various log roll and shutdown options. */ ! if(!Ns_ConfigGetInt(path,"rollhour",&hour) || hour < 0 || hour > 23) ! hour = 0; ! if(!Ns_ConfigGetBool(path,"rolllog",&opt) || opt) ! Ns_ScheduleDaily((Ns_SchedProc *) LogRollCallback,logPtr,0,hour,0,NULL); ! ! if(Ns_ConfigGetBool(path,"rollonsignal",&opt) && opt) ! Ns_RegisterAtSignal(LogRollCallback,logPtr); ! /* Parse extended headers, it is just Tcl list of names */ Ns_DStringTrunc(&ds,0); Ns_DStringVarAppend(&ds,Ns_ConfigGet(path,"extendedheaders"),0); ! if(Tcl_SplitList(NULL,ds.string,&opt,&logPtr->extheaders) != TCL_OK) ! Ns_Log(Error,"nslog: invalid %s/extendedHeaders parameter: %s",path,ds.string); ! Ns_DStringFree(&ds); /* Open the log and register the trace. */ ! if(LogOpen(logPtr) != NS_OK) return NS_ERROR; Ns_RegisterServerTrace(server,LogTrace,logPtr); Ns_RegisterAtShutdown(LogCloseCallback,logPtr); --- 194,266 ---- path = Ns_ConfigGetPath(server,module,NULL); ! logPtr->file = Ns_ConfigGetValue(path,"file"); ! if (logPtr->file == NULL) { ! logPtr->file = "access.log"; ! } logPtr->file = ns_strdup(logPtr->file); ! ! if (Ns_PathIsAbsolute(logPtr->file) == NS_FALSE) { ! Ns_ModulePath(&ds,server,module,NULL,NULL); ! if (mkdir(ds.string,0755) != 0 && ! errno != EEXIST && ! errno != EISDIR) { ! Ns_Log(Error,"nslog: mkdir(%s) failed: %s",ds.string,strerror(errno)); ! Ns_DStringFree(&ds); ! return NS_ERROR; ! } ! Ns_DStringTrunc(&ds,0); ! Ns_ModulePath(&ds,server,module,logPtr->file,NULL); ! logPtr->file = Ns_DStringExport(&ds); } /* Get parameters from configuration file */ ! logPtr->rollfmt = Ns_ConfigGetValue(path,"rollfmt"); ! if (logPtr->rollfmt == NULL) { ! logPtr->rollfmt = ns_strdup(logPtr->rollfmt); ! } ! if (!Ns_ConfigGetInt(path,"maxbackup",&logPtr->maxbackup) || ! logPtr->maxbackup < 1) { ! logPtr->maxbackup = 100; ! } ! if (!Ns_ConfigGetInt(path,"maxbuffer",&logPtr->maxlines)) { ! logPtr->maxlines = 0; ! } ! if (!Ns_ConfigGetBool(path,"formattedTime",&opt) || opt) { ! logPtr->flags |= LOG_FMTTIME; ! } ! if (!Ns_ConfigGetBool(path,"logcombined",&opt) || opt) { ! logPtr->flags |= LOG_COMBINED; ! } ! if (Ns_ConfigGetBool(path,"logreqtime",&opt) && opt) { ! logPtr->flags |= LOG_REQTIME; ! } ! if (Ns_ConfigGetBool(path,"suppressquery",&opt) && opt) { ! logPtr->flags |= LOG_SUPPRESSQUERY; ! } ! if (Ns_ConfigGetBool(path,"checkforproxy",&opt) && opt) { ! logPtr->flags |= LOG_CHECKFORPROXY; ! } /* Schedule various log roll and shutdown options. */ ! if (!Ns_ConfigGetInt(path,"rollhour",&hour) || hour < 0 || hour > 23) { ! hour = 0; ! } ! if (!Ns_ConfigGetBool(path,"rolllog",&opt) || opt) { ! Ns_ScheduleDaily((Ns_SchedProc *) LogRollCallback,logPtr,0,hour,0,NULL); ! } ! if (Ns_ConfigGetBool(path,"rollonsignal",&opt) && opt) { ! Ns_RegisterAtSignal(LogRollCallback,logPtr); ! } /* Parse extended headers, it is just Tcl list of names */ Ns_DStringTrunc(&ds,0); Ns_DStringVarAppend(&ds,Ns_ConfigGet(path,"extendedheaders"),0); ! if (Tcl_SplitList(NULL,ds.string,&opt,&logPtr->extheaders) != TCL_OK) { ! Ns_Log(Error,"nslog: invalid %s/extendedHeaders parameter: %s",path,ds.string); ! } Ns_DStringFree(&ds); /* Open the log and register the trace. */ ! if (LogOpen(logPtr) != NS_OK) { ! return NS_ERROR; ! } Ns_RegisterServerTrace(server,LogTrace,logPtr); Ns_RegisterAtShutdown(LogCloseCallback,logPtr); *************** *** 279,285 **** /* Compute the request's elapsed time. */ ! if(logPtr->flags & LOG_REQTIME) { ! Ns_GetTime(&now); ! Ns_DiffTime(&now,Ns_ConnStartTime(conn),&diff); } --- 298,304 ---- /* Compute the request's elapsed time. */ ! if (logPtr->flags & LOG_REQTIME) { ! Ns_GetTime(&now); ! Ns_DiffTime(&now,Ns_ConnStartTime(conn),&diff); } *************** *** 291,335 **** */ ! if(logPtr->flags & LOG_CHECKFORPROXY) { ! if((p = Ns_SetIGet(conn->headers,"X-Forwarded-For")) && !strcmp(p,"unknown")) p = 0; } ! Ns_DStringAppend(&ds,p ? p : Ns_ConnPeer(conn)); ! if(conn->authUser == NULL) { ! Ns_DStringAppend(&ds," - - "); } else { ! p = conn->authUser; ! quote = 0; ! while(*p != '\0') { ! if(isspace((unsigned char) *p)) { ! quote = 1; ! break; ! } ! ++p; ! } ! if(quote) ! Ns_DStringVarAppend(&ds," - \"",conn->authUser,"\" ",NULL); ! else ! Ns_DStringVarAppend(&ds," - ",conn->authUser," ",NULL); } /* Append a common log format time stamp including GMT offset. */ ! if(!(logPtr->flags & LOG_FMTTIME)) ! sprintf(buf,"[%ld]",(long)time(NULL)); ! else ! Ns_LogTime(buf); ! Ns_DStringAppend(&ds,buf); /* Append the request line. */ ! if(conn->request && conn->request->line) { ! if(logPtr->flags & LOG_SUPPRESSQUERY) { ! /* Don't display query data. */ ! Ns_DStringVarAppend(&ds," \"",conn->request->url,"\" ",NULL); ! } else ! Ns_DStringVarAppend(&ds," \"",conn->request->line,"\" ",NULL); ! } else ! Ns_DStringAppend(&ds," \"\" "); ! /* Construct and append the HTTP status code and bytes sent. */ n = Ns_ConnResponseStatus(conn); --- 310,359 ---- */ ! if (logPtr->flags & LOG_CHECKFORPROXY) { ! p = Ns_SetIGet(conn->headers,"X-Forwarded-For"); ! if (p != NULL && !strcasecmp(p,"unknown")) { ! p = 0; ! } } ! Ns_DStringAppend(&ds,p && *p ? p : Ns_ConnPeer(conn)); ! if (conn->authUser == NULL) { ! Ns_DStringAppend(&ds," - - "); } else { ! p = conn->authUser; ! quote = 0; ! while (*p != '\0') { ! if (isspace((unsigned char) *p)) { ! quote = 1; ! break; ! } ! ++p; ! } ! if (quote) { ! Ns_DStringVarAppend(&ds," - \"",conn->authUser,"\" ",NULL); ! } else { ! Ns_DStringVarAppend(&ds," - ",conn->authUser," ",NULL); ! } } /* Append a common log format time stamp including GMT offset. */ ! if (!(logPtr->flags & LOG_FMTTIME)) { ! sprintf(buf,"[%ld]",(long)time(NULL)); ! } else { ! Ns_LogTime(buf); ! } Ns_DStringAppend(&ds,buf); /* Append the request line. */ ! if (conn->request && conn->request->line) { ! if (logPtr->flags & LOG_SUPPRESSQUERY) { ! /* Don't display query data. */ ! Ns_DStringVarAppend(&ds," \"",conn->request->url,"\" ",NULL); ! } else { ! Ns_DStringVarAppend(&ds," \"",conn->request->line,"\" ",NULL); ! } ! } else { ! Ns_DStringAppend(&ds," \"\" "); ! } /* Construct and append the HTTP status code and bytes sent. */ n = Ns_ConnResponseStatus(conn); *************** *** 337,359 **** Ns_DStringAppend(&ds,buf); ! if((logPtr->flags & LOG_COMBINED)) { ! /* Append the referer and user-agent headers(if any). */ ! Ns_DStringAppend(&ds,"\""); ! if((p = Ns_SetIGet(conn->headers,"referer"))) Ns_DStringAppend(&ds,p); ! Ns_DStringAppend(&ds,"\" \""); ! if((p = Ns_SetIGet(conn->headers,"user-agent"))) Ns_DStringAppend(&ds,p); ! Ns_DStringAppend(&ds,"\""); } /* Append the request's elapsed time(if enabled). */ ! if(logPtr->flags & LOG_REQTIME) { ! sprintf(buf," %d.%06ld",(int)diff.sec,diff.usec); ! Ns_DStringAppend(&ds,buf); } /* Append the extended headers(if any). */ ! for(h = logPtr->extheaders; *h; h++) { ! if(!(p = Ns_SetIGet(conn->headers,*h))) p = ""; ! Ns_DStringVarAppend(&ds," \"",p,"\"",NULL); } --- 361,389 ---- Ns_DStringAppend(&ds,buf); ! if ((logPtr->flags & LOG_COMBINED)) { ! /* Append the referer and user-agent headers(if any). */ ! Ns_DStringAppend(&ds,"\""); ! if ((p = Ns_SetIGet(conn->headers,"referer"))) { ! Ns_DStringAppend(&ds,p); ! } ! Ns_DStringAppend(&ds,"\" \""); ! if ((p = Ns_SetIGet(conn->headers,"user-agent"))) { ! Ns_DStringAppend(&ds,p); ! } ! Ns_DStringAppend(&ds,"\""); } /* Append the request's elapsed time(if enabled). */ ! if (logPtr->flags & LOG_REQTIME) { ! sprintf(buf," %d.%06ld",(int)diff.sec,diff.usec); ! Ns_DStringAppend(&ds,buf); } /* Append the extended headers(if any). */ ! for (h = logPtr->extheaders; *h; h++) { ! if (!(p = Ns_SetIGet(conn->headers,*h))) { ! p = ""; ! } ! Ns_DStringVarAppend(&ds," \"",p,"\"",NULL); } *************** *** 362,377 **** Ns_DStringAppend(&ds,"\n"); Ns_MutexLock(&logPtr->lock); ! if(logPtr->maxlines <= 0) { ! status = LogFlush(logPtr,&ds); } else { ! Ns_DStringNAppend(&logPtr->buffer,ds.string,ds.length); ! if(++logPtr->curlines > logPtr->maxlines) { ! status = LogFlush(logPtr,&logPtr->buffer); ! logPtr->curlines = 0; ! } } Ns_MutexUnlock(&logPtr->lock); Ns_DStringFree(&ds); ! if(status != NS_OK) Ns_Log(Error,"nslog: failed to flush log: %s",strerror(errno)); } --- 392,409 ---- Ns_DStringAppend(&ds,"\n"); Ns_MutexLock(&logPtr->lock); ! if (logPtr->maxlines <= 0) { ! status = LogFlush(logPtr,&ds); } else { ! Ns_DStringNAppend(&logPtr->buffer,ds.string,ds.length); ! if (++logPtr->curlines > logPtr->maxlines) { ! status = LogFlush(logPtr,&logPtr->buffer); ! logPtr->curlines = 0; ! } } Ns_MutexUnlock(&logPtr->lock); Ns_DStringFree(&ds); ! if (status != NS_OK) { ! Ns_Log(Error,"nslog: failed to flush log: %s",strerror(errno)); ! } } *************** *** 407,518 **** Log *logPtr = arg; ! if(argc < 2) { ! Tcl_AppendResult(interp,"wrong # args: should be: \"",argv[0]," command ?arg?\"",NULL); ! return TCL_ERROR; } ! if(STREQ(argv[1],"rollfmt")) { ! Ns_MutexLock(&logPtr->lock); ! if(argc > 2) { ! ns_free(logPtr->rollfmt); ! logPtr->rollfmt = ns_strdup(argv[2]); ! } ! Ns_MutexUnlock(&logPtr->lock); ! Tcl_SetResult(interp,logPtr->rollfmt,TCL_STATIC); ! } else ! ! if(STREQ(argv[1],"maxbackup")) { ! Ns_MutexLock(&logPtr->lock); ! if(argc > 2 && (logPtr->maxbackup = atoi(argv[2])) < 1) logPtr->maxbackup = 100; ! Tcl_SetObjResult(interp,Tcl_NewIntObj(logPtr->maxbackup)); ! Ns_MutexUnlock(&logPtr->lock); } else ! if(STREQ(argv[1],"maxbuffer")) { ! Ns_MutexLock(&logPtr->lock); ! if(argc > 2) logPtr->maxlines = atoi(argv[2]); ! Tcl_SetObjResult(interp,Tcl_NewIntObj(logPtr->maxlines)); ! Ns_MutexUnlock(&logPtr->lock); } else ! if(STREQ(argv[1],"extendedheaders")) { ! char **h,**h1,**h2 = logPtr->extheaders; ! Ns_DStringInit(&ds); ! if(argc > 2) { ! if(Tcl_SplitList(interp,argv[2],&status,&h1) != TCL_OK) return TCL_ERROR; Ns_MutexLock(&logPtr->lock); ! /* Wait for others to finish logging extheaders */ ! sleep(1); ! logPtr->extheaders = h1; Ns_MutexUnlock(&logPtr->lock); - if(h2) Tcl_Free((char*)h2); - } - for(h = logPtr->extheaders; *h; h++) Ns_DStringVarAppend(&ds,*h," ",NULL); - Tcl_AppendResult(interp,ds.string,0); - Ns_DStringFree(&ds); } else ! if(STREQ(argv[1],"flags")) { ! Ns_DStringInit(&ds); ! if(argc > 2) { ! status = 0; ! Ns_DStringAppend(&ds,argv[2]); ! Ns_StrToLower(ds.string); ! if(strstr(ds.string,"logcombined")) status |= LOG_COMBINED; ! if(strstr(ds.string,"formattedtime")) status |= LOG_FMTTIME; ! if(strstr(ds.string,"logreqtime")) status |= LOG_REQTIME; ! if(strstr(ds.string,"checkforproxy")) status |= LOG_CHECKFORPROXY; ! if(strstr(ds.string,"suppressquery")) status |= LOG_SUPPRESSQUERY; ! logPtr->flags = status; ! Ns_DStringTrunc(&ds,0); ! } ! if(logPtr->flags & LOG_COMBINED) Ns_DStringAppend(&ds,"logCombined "); ! if(logPtr->flags & LOG_FMTTIME) Ns_DStringAppend(&ds,"formattedTime "); ! if(logPtr->flags & LOG_REQTIME) Ns_DStringAppend(&ds,"logReqTime "); ! if(logPtr->flags & LOG_CHECKFORPROXY) Ns_DStringAppend(&ds,"checkForProxy "); ! if(logPtr->flags & LOG_SUPPRESSQUERY) Ns_DStringAppend(&ds,"suppressQuery "); ! Tcl_AppendResult(interp,ds.string,0); ! Ns_DStringFree(&ds); } else ! if(STREQ(argv[1],"file")) { ! if(argc > 2 && Ns_PathIsAbsolute(argv[2])) { ! Ns_MutexLock(&logPtr->lock); ! LogClose(logPtr); ! logPtr->file = ns_strdup(argv[2]); ! LogOpen(logPtr); ! Ns_MutexUnlock(&logPtr->lock); ! } ! Tcl_SetResult(interp,logPtr->file,TCL_STATIC); } else ! if(STREQ(argv[1],"roll")) { ! if(argc != 2 && argc != 3) { ! Tcl_AppendResult(interp,"wrong # args: should be: \"",argv[0]," ",argv[1]," ?file?\"",NULL); ! return TCL_ERROR; ! } ! Ns_MutexLock(&logPtr->lock); ! if(argc == 2) { ! status = LogRoll(logPtr); } else { ! status = NS_OK; ! if(access(argv[2],F_OK) == 0) status = Ns_RollFile(argv[2],logPtr->maxbackup); ! if(status == NS_OK) { ! if(rename(logPtr->file,argv[2]) != 0) { ! status = NS_ERROR; ! } else { ! LogFlush(logPtr,&logPtr->buffer); ! status = LogOpen(logPtr); ! } ! } } Ns_MutexUnlock(&logPtr->lock); ! if(status != NS_OK) { ! Tcl_AppendResult(interp,"could not roll \"",logPtr->file,"\": ",Tcl_PosixError(interp),NULL); ! return TCL_ERROR; } } else { ! Tcl_AppendResult(interp,"unknown command \"",argv[1],"\": should be file or roll",NULL); ! return TCL_ERROR; } return TCL_OK; --- 439,582 ---- Log *logPtr = arg; ! if (argc < 2) { ! Tcl_AppendResult(interp,"wrong # args: should be: \"",argv[0]," command ?arg?\"",NULL); ! return TCL_ERROR; } ! if (STREQ(argv[1],"rollfmt")) { ! Ns_MutexLock(&logPtr->lock); ! if(argc > 2) { ! ns_free(logPtr->rollfmt); ! logPtr->rollfmt = ns_strdup(argv[2]); ! } ! Ns_MutexUnlock(&logPtr->lock); ! Tcl_SetResult(interp,logPtr->rollfmt,TCL_STATIC); } else ! if (STREQ(argv[1],"maxbackup")) { ! Ns_MutexLock(&logPtr->lock); ! if(argc > 2 && (logPtr->maxbackup = atoi(argv[2])) < 1) { ! logPtr->maxbackup = 100; ! } ! Tcl_SetObjResult(interp,Tcl_NewIntObj(logPtr->maxbackup)); ! Ns_MutexUnlock(&logPtr->lock); } else ! if (STREQ(argv[1],"maxbuffer")) { Ns_MutexLock(&logPtr->lock); ! if (argc > 2) { ! logPtr->maxlines = atoi(argv[2]); ! } ! Tcl_SetObjResult(interp,Tcl_NewIntObj(logPtr->maxlines)); Ns_MutexUnlock(&logPtr->lock); } else ! if (STREQ(argv[1],"extendedheaders")) { ! char **h,**h1,**h2 = logPtr->extheaders; ! Ns_DStringInit(&ds); ! if (argc > 2) { ! if(Tcl_SplitList(interp,argv[2],&status,&h1) != TCL_OK) { ! return TCL_ERROR; ! } ! Ns_MutexLock(&logPtr->lock); ! /* Wait for others to finish logging extheaders */ ! sleep(1); ! logPtr->extheaders = h1; ! Ns_MutexUnlock(&logPtr->lock); ! if (h2) { ! Tcl_Free((char*)h2); ! } ! } ! for (h = logPtr->extheaders; *h; h++) { ! Ns_DStringVarAppend(&ds,*h," ",NULL); ! } ! Tcl_AppendResult(interp,ds.string,0); ! Ns_DStringFree(&ds); } else ! if (STREQ(argv[1],"flags")) { ! Ns_DStringInit(&ds); ! if (argc > 2) { ! status = 0; ! Ns_DStringAppend(&ds,argv[2]); ! Ns_StrToLower(ds.string); ! if (strstr(ds.string,"logcombined")) { ! status |= LOG_COMBINED; ! } ! if (strstr(ds.string,"formattedtime")) { ! status |= LOG_FMTTIME; ! } ! if (strstr(ds.string,"logreqtime")) { ! status |= LOG_REQTIME; ! } ! if (strstr(ds.string,"checkforproxy")) { ! status |= LOG_CHECKFORPROXY; ! } ! if (strstr(ds.string,"suppressquery")) { ! status |= LOG_SUPPRESSQUERY; ! } ! logPtr->flags = status; ! Ns_DStringTrunc(&ds,0); ! } ! if (logPtr->flags & LOG_COMBINED) { ! Ns_DStringAppend(&ds,"logCombined "); ! } ! if (logPtr->flags & LOG_FMTTIME) { ! Ns_DStringAppend(&ds,"formattedTime "); ! } ! if (logPtr->flags & LOG_REQTIME) { ! Ns_DStringAppend(&ds,"logReqTime "); ! } ! if (logPtr->flags & LOG_CHECKFORPROXY) { ! Ns_DStringAppend(&ds,"checkForProxy "); ! } ! if (logPtr->flags & LOG_SUPPRESSQUERY) { ! Ns_DStringAppend(&ds,"suppressQuery "); ! } ! Tcl_AppendResult(interp,ds.string,0); ! Ns_DStringFree(&ds); } else ! if (STREQ(argv[1],"file")) { ! if (argc > 2 && Ns_PathIsAbsolute(argv[2])) { ! Ns_MutexLock(&logPtr->lock); ! LogClose(logPtr); ! logPtr->file = ns_strdup(argv[2]); ! LogOpen(logPtr); ! Ns_MutexUnlock(&logPtr->lock); ! } ! Tcl_SetResult(interp,logPtr->file,TCL_STATIC); ! } else ! ! if (STREQ(argv[1],"roll")) { ! if (argc != 2 && argc != 3) { ! Tcl_AppendResult(interp,"wrong # args: should be: \"",argv[0]," ",argv[1]," ?file?\"",NULL); ! return TCL_ERROR; ! } ! Ns_MutexLock(&logPtr->lock); ! if (argc == 2) { ! status = LogRoll(logPtr); } else { ! status = NS_OK; ! if (access(argv[2],F_OK) == 0) { ! status = Ns_RollFile(argv[2],logPtr->maxbackup); ! } ! if (status == NS_OK) { ! if (rename(logPtr->file,argv[2]) != 0) { ! status = NS_ERROR; ! } else { ! LogFlush(logPtr,&logPtr->buffer); ! status = LogOpen(logPtr); ! } ! } } Ns_MutexUnlock(&logPtr->lock); ! if (status != NS_OK) { ! Tcl_AppendResult(interp,"could not roll \"",logPtr->file,"\": ",Tcl_PosixError(interp),NULL); ! return TCL_ERROR; } } else { ! Tcl_AppendResult(interp,"unknown command \"",argv[1],"\": should be file or roll",NULL); ! return TCL_ERROR; } return TCL_OK; *************** *** 567,575 **** fd = open(logPtr->file,O_APPEND|O_WRONLY|O_CREAT,0644); ! if(fd < 0) { ! Ns_Log(Error,"nslog: error '%s' opening '%s'",strerror(errno),logPtr->file); ! return NS_ERROR; } - if(logPtr->fd >= 0) close(logPtr->fd); logPtr->fd = fd; Ns_Log(Notice,"nslog: opened '%s'",logPtr->file); --- 631,641 ---- fd = open(logPtr->file,O_APPEND|O_WRONLY|O_CREAT,0644); ! if (fd < 0) { ! Ns_Log(Error,"nslog: error '%s' opening '%s'",strerror(errno),logPtr->file); ! return NS_ERROR; ! } ! if (logPtr->fd >= 0) { ! close(logPtr->fd); } logPtr->fd = fd; Ns_Log(Notice,"nslog: opened '%s'",logPtr->file); *************** *** 600,609 **** status = NS_OK; ! if(logPtr->fd >= 0) { ! Ns_Log(Notice,"nslog: closing '%s'",logPtr->file); ! status = LogFlush(logPtr,&logPtr->buffer); ! close(logPtr->fd); ! logPtr->fd = -1; ! Ns_DStringFree(&logPtr->buffer); } return status; --- 666,675 ---- status = NS_OK; ! if (logPtr->fd >= 0) { ! Ns_Log(Notice,"nslog: closing '%s'",logPtr->file); ! status = LogFlush(logPtr,&logPtr->buffer); ! close(logPtr->fd); ! logPtr->fd = -1; ! Ns_DStringFree(&logPtr->buffer); } return status; *************** *** 631,643 **** LogFlush(Log *logPtr,Ns_DString *dsPtr) { ! if(dsPtr->length > 0) { ! if(logPtr->fd >= 0 && write(logPtr->fd,dsPtr->string,(size_t)dsPtr->length) != dsPtr->length) { ! Ns_Log(Error,"nslog: logging disabled: write() failed: '%s'",strerror(errno)); ! close(logPtr->fd); ! logPtr->fd = -1; ! } ! Ns_DStringTrunc(dsPtr,0); } - if(logPtr->fd < 0) return NS_ERROR; return NS_OK; } --- 697,712 ---- LogFlush(Log *logPtr,Ns_DString *dsPtr) { ! if (dsPtr->length > 0) { ! if (logPtr->fd >= 0 && ! write(logPtr->fd,dsPtr->string,(size_t)dsPtr->length) != dsPtr->length) { ! Ns_Log(Error,"nslog: logging disabled: write() failed: '%s'",strerror(errno)); ! close(logPtr->fd); ! logPtr->fd = -1; ! } ! Ns_DStringTrunc(dsPtr,0); ! } ! if (logPtr->fd < 0) { ! return NS_ERROR; } return NS_OK; } *************** *** 671,695 **** LogClose(logPtr); ! if(access(logPtr->file,F_OK) == 0) { ! if(logPtr->rollfmt == NULL) { ! status = Ns_RollFile(logPtr->file,logPtr->maxbackup); } else { ! ptm = ns_localtime(&now); ! strftime(timeBuf,512,logPtr->rollfmt,ptm); ! Ns_DStringInit(&ds); ! Ns_DStringVarAppend(&ds,logPtr->file,".",timeBuf,NULL); ! if(access(ds.string,F_OK) == 0) { ! status = Ns_RollFile(ds.string,logPtr->maxbackup); ! } else ! if(errno != ENOENT) { ! Ns_Log(Error,"nslog: access(%s,F_OK) failed: '%s'",ds.string,strerror(errno)); ! status = NS_ERROR; ! } ! if(status == NS_OK && rename(logPtr->file,ds.string) != 0) { ! Ns_Log(Error,"nslog: rename(%s,%s) failed: '%s'",logPtr->file,ds.string,strerror(errno)); ! status = NS_ERROR; ! } ! Ns_DStringFree(&ds); ! if(status == NS_OK) status = Ns_PurgeFiles(logPtr->file,logPtr->maxbackup); } } --- 740,766 ---- LogClose(logPtr); ! if (access(logPtr->file,F_OK) == 0) { ! if (logPtr->rollfmt == NULL) { ! status = Ns_RollFile(logPtr->file,logPtr->maxbackup); } else { ! ptm = ns_localtime(&now); ! strftime(timeBuf,512,logPtr->rollfmt,ptm); ! Ns_DStringInit(&ds); ! Ns_DStringVarAppend(&ds,logPtr->file,".",timeBuf,NULL); ! if (access(ds.string,F_OK) == 0) { ! status = Ns_RollFile(ds.string,logPtr->maxbackup); ! } else ! if (errno != ENOENT) { ! Ns_Log(Error,"nslog: access(%s,F_OK) failed: '%s'",ds.string,strerror(errno)); ! status = NS_ERROR; ! } ! if (status == NS_OK && rename(logPtr->file,ds.string) != 0) { ! Ns_Log(Error,"nslog: rename(%s,%s) failed: '%s'",logPtr->file,ds.string,strerror(errno)); ! status = NS_ERROR; ! } ! Ns_DStringFree(&ds); ! if (status == NS_OK) { ! status = Ns_PurgeFiles(logPtr->file,logPtr->maxbackup); ! } } } *************** *** 724,728 **** status =(*proc)(logPtr); Ns_MutexUnlock(&logPtr->lock); ! if(status != NS_OK) Ns_Log(Error,"nslog: failed: %s '%s': '%s'",desc,logPtr->file,strerror(errno)); } --- 795,801 ---- status =(*proc)(logPtr); Ns_MutexUnlock(&logPtr->lock); ! if (status != NS_OK) { ! Ns_Log(Error,"nslog: failed: %s '%s': '%s'",desc,logPtr->file,strerror(errno)); ! } } |