[Pkg-ocaml-maint-commits] r3858 - in /trunk/projects/approx/trunk: ./ debian/ doc/ etc/
ecc-guest at users.alioth.debian.org
ecc-guest at users.alioth.debian.org
Mon Jun 18 23:32:24 UTC 2007
Author: ecc-guest
Date: Mon Jun 18 23:32:24 2007
New Revision: 3858
URL: http://svn.debian.org/wsvn/?sc=1&rev=3858
Log:
changed debian/rules to use cdbs
improve postinst check for conflict with apt-proxy
make sure cronjob doesn't fail if approx has been removed
or cache directory is empty
require configuration parameters to begin with '$' to distinguish
them from repository names
added $verbose parameter to control logging of informational messages
added $syslog parameter to specify the syslog facility
added $user and $group parameters to control the approx daemon's user
and group [Alexandra N. Kossovsky <sasha at oktetlabs.ru>]
don't assume deluser is still available in postrm
migrated to Ocamlnet 2
changed dependency from ocaml-tools to ocamlmakefile
Added:
trunk/projects/approx/trunk/debian/approx.docs
trunk/projects/approx/trunk/debian/approx.install
trunk/projects/approx/trunk/debian/approx.manpages
trunk/projects/approx/trunk/mkversion
- copied, changed from r2953, trunk/projects/approx/trunk/gen_version
Removed:
trunk/projects/approx/trunk/gen_version
Modified:
trunk/projects/approx/trunk/Makefile
trunk/projects/approx/trunk/approx.ml
trunk/projects/approx/trunk/config.ml
trunk/projects/approx/trunk/debian/NEWS
trunk/projects/approx/trunk/debian/approx.cron.weekly
trunk/projects/approx/trunk/debian/approx.postinst
trunk/projects/approx/trunk/debian/approx.postrm
trunk/projects/approx/trunk/debian/changelog
trunk/projects/approx/trunk/debian/control
trunk/projects/approx/trunk/debian/rules
trunk/projects/approx/trunk/default_config.ml
trunk/projects/approx/trunk/default_config.mli
trunk/projects/approx/trunk/doc/approx.conf.5
trunk/projects/approx/trunk/etc/approx.conf
trunk/projects/approx/trunk/gc.ml
trunk/projects/approx/trunk/ifaddr.c
trunk/projects/approx/trunk/log.ml
trunk/projects/approx/trunk/log.mli
trunk/projects/approx/trunk/server.ml
trunk/projects/approx/trunk/server.mli
trunk/projects/approx/trunk/url.ml
trunk/projects/approx/trunk/util.ml
trunk/projects/approx/trunk/util.mli
Modified: trunk/projects/approx/trunk/Makefile
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/Makefile?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/Makefile (original)
+++ trunk/projects/approx/trunk/Makefile Mon Jun 18 23:32:24 2007
@@ -1,5 +1,5 @@
# approx: proxy server for Debian archive files
-# Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+# Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
# Released under the GNU General Public License
export OCAMLMAKEFILE = /usr/share/ocamlmakefile/OCamlMakefile
@@ -7,9 +7,14 @@
export OCAMLFLAGS = -warn-error A
define PROJ_server
- SOURCES = util.ml config.ml default_config.ml log.ml url.ml control_file.ml release.ml ifaddr.c internet.mli server.ml version.ml approx.ml
- INCDIRS = +pcre +syslog +netstring +cgi +nethttpd +sha
- LIBS = unix pcre syslog netstring cgi nethttpd sha
+ SIDE_EFFECT = $(shell ./mkversion > version.ml)
+ SOURCES = util.ml config.ml default_config.ml log.ml url.ml control_file.ml release.ml ifaddr.c internet.mli version.ml server.ml approx.ml
+ INCDIRS = +pcre +syslog +netsys +netstring +netcgi1 +nethttpd-for-netcgi1 +sha
+ LIBS = unix pcre syslog netsys netstring cgi nethttpd-for-netcgi1 sha
+# use this after the next release of ocamlnet2
+# (a bug in the current release prevents this from working)
+# INCDIRS = +pcre +syslog +netsys +netstring +netcgi2 +nethttpd-for-netcgi2 +sha
+# LIBS = unix pcre syslog netsys netstring netcgi nethttpd-for-netcgi2 sha
RESULT = approx
endef
export PROJ_server
@@ -36,5 +41,7 @@
all: native-code
+export TRASH = version.ml
+
%:
@$(MAKE) -f $(OCAMLMAKEFILE) subprojs SUBTARGET=$@
Modified: trunk/projects/approx/trunk/approx.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/approx.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/approx.ml (original)
+++ trunk/projects/approx/trunk/approx.ml Mon Jun 18 23:32:24 2007
@@ -1,13 +1,12 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
open Printf
open Unix
-open Nethttpd_types
open Util
open Default_config
-open Log (* Log.error_message shadows Unix.error_message *)
+open Log
let usage () =
prerr_endline
@@ -22,7 +21,7 @@
let version () =
eprintf "%s %s\n" Version.name Version.number;
prerr_endline
- "Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>\n\
+ "Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>\n\
Released under the GNU General Public License"
let foreground = ref false
@@ -36,8 +35,6 @@
done;
if not !foreground then use_syslog ()
-let exception_message exc = error_message "%s" (string_of_exception exc)
-
let print_config () =
let units u = function
| 0 -> ""
@@ -45,13 +42,16 @@
| n -> sprintf " %d %ss" n u
in
info_message "Version: %s %s" Version.name Version.number;
- info_message "Config file: %s" config_file;
info_message "Interface: %s" interface;
info_message "Port: %d" port;
- info_message "Cache: %s" cache_dir;
info_message "Interval:%s%s"
(units "hour" (interval / 60)) (units "minute" (interval mod 60));
info_message "Max wait: %d" max_wait;
+ info_message "Max rate: %s" max_rate;
+ info_message "User: %s" user;
+ info_message "Group: %s" group;
+ info_message "Syslog: %s" syslog;
+ info_message "Verbose: %B" verbose;
info_message "Debug: %B" debug
let http_time t =
@@ -68,7 +68,7 @@
if Sys.file_exists name' then
if n < max_wait then
begin
- if n = 0 then
+ if n = 0 && verbose then
info_message "Waiting for download of %s to complete" name;
sleep 1;
wait (n+1)
@@ -94,7 +94,7 @@
(* Deliver a file from the local cache *)
let deliver_local name env =
- if not debug then info_message "%s" name;
+ if verbose && not debug then info_message "%s" name;
let size = file_size name in
env#set_output_header_fields (proxy_headers size (file_modtime name));
if debug then print_headers "Cache hit" env#output_header_fields;
@@ -241,7 +241,7 @@
| Not_modified -> "Not modified"
| File_not_found -> "File not found"
-let send_header size modtime (cgi : Netcgi_types.cgi_activation) =
+let send_header size modtime (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =
let headers = proxy_headers size modtime in
let fields = List.map (fun (name, value) -> (name, [value])) headers in
cgi#set_header ~status: `Ok ~fields ();
@@ -366,7 +366,7 @@
let cleanup_after name =
let rm file =
- info_message "Removing invalid file %s" file;
+ if verbose then info_message "Removing invalid file %s" file;
Sys.remove file
in
if Sys.file_exists name then
@@ -393,9 +393,9 @@
let serve_remote url name ims mod_time cgi =
let respond code =
- raise (Standard_response (code, None, None))
- in
- info_message "%s" url;
+ raise (Nethttpd_types.Standard_response (code, None, None))
+ in
+ if verbose then info_message "%s" url;
let status =
try download_url url name (max ims mod_time) cgi
with e ->
@@ -423,13 +423,14 @@
let remote_service url name ims mod_time =
object
- method process_body env =
- let cgi =
- (* buffered activation runs out of memory on large downloads *)
- Nethttpd_services.std_activation `Std_activation_unbuffered env
- in
+ method process_body _ =
object
- method generate_response _ = serve_remote url name ims mod_time cgi
+ method generate_response env =
+ let cgi =
+ (* buffered activation runs out of memory on large downloads *)
+ Nethttpd_services.std_activation `Std_activation_unbuffered env
+ in
+ serve_remote url name ims mod_time cgi
end
end
@@ -455,8 +456,8 @@
(* since older versions of apt do not know about Release.gpg,
we fetch it now to ensure the cache will be consistent
for other clients using secure apt *)
- (try Url.download_file ~url: (url ^ ".gpg") ~file: (name ^ ".gpg")
- with e -> exception_message e)
+ let url, file = url ^ ".gpg", name ^ ".gpg" in
+ (try Url.download_file ~url ~file with e -> exception_message e)
| _ ->
()
@@ -481,7 +482,7 @@
let serve_file env =
(* handle URL-encoded '+', '~', etc. *)
- let path = Netencoding.Url.decode ~plus:false env#cgi_request_uri in
+ let path = Netencoding.Url.decode ~plus: false env#cgi_request_uri in
let headers = env#input_header_fields in
if debug then print_headers (sprintf "Request %s" path) headers;
try
@@ -493,28 +494,29 @@
`Std_response (`Forbidden, None, Some msg)
let proxy_service =
- object (_self)
+ object
method name = "proxy_service"
method def_term = `Proxy_service
method print fmt = Format.fprintf fmt "%s" "proxy_service"
-
method process_header env =
- (match env#remote_socket_addr with
- | ADDR_INET (host, port) ->
- info_message "Connection from %s:%d" (string_of_inet_addr host) port
- | ADDR_UNIX path ->
- failwith ("connection from UNIX socket " ^ path));
- if env#cgi_request_method = "GET" && env#cgi_query_string = "" then
- serve_file env
- else
- `Std_response (`Forbidden, None, Some "Invalid request line")
+ match env#remote_socket_addr with
+ | ADDR_INET (host, port) ->
+ if verbose then
+ info_message "Connection from %s:%d"
+ (string_of_inet_addr host) port;
+ if env#cgi_request_method = "GET" && env#cgi_query_string = "" then
+ serve_file env
+ else
+ `Std_response (`Forbidden, None, Some "Invalid request line")
+ | ADDR_UNIX path ->
+ failwith ("connection from UNIX socket " ^ path)
end
let server () =
try
Sys.chdir cache_dir;
- print_config ();
- Server.main ~user: "approx" ~interface port proxy_service
+ if verbose then print_config ();
+ Server.main ~user ~group ~interface port proxy_service
with e ->
exception_message e;
exit 1
Modified: trunk/projects/approx/trunk/config.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/config.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/config.ml (original)
+++ trunk/projects/approx/trunk/config.ml Mon Jun 18 23:32:24 2007
@@ -31,6 +31,28 @@
| Some v -> v
| None -> raise Not_found)
+(* This version provides backwards compatibility for parameters
+ without an initial '$' *)
+
+let get_generic convert ?default k =
+ let not_found () =
+ match default with
+ | Some v -> v
+ | None -> raise Not_found
+ in
+ try convert (List.assoc k !map)
+ with Not_found ->
+ if k <> "" && k.[0] = '$' then
+ let k = substring ~from: 1 k in
+ try
+ let v = convert (List.assoc k !map) in
+ Printf.eprintf "/etc/approx/approx.conf: \"%s\" should be \"$%s\"\n%!"
+ k k;
+ v
+ with Not_found -> not_found ()
+ else
+ not_found ()
+
let get = get_generic (fun x -> x)
let get_int = get_generic int_of_string
Modified: trunk/projects/approx/trunk/debian/NEWS
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/NEWS?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/NEWS (original)
+++ trunk/projects/approx/trunk/debian/NEWS Mon Jun 18 23:32:24 2007
@@ -1,3 +1,12 @@
+approx (2.9.0) unstable; urgency=low
+
+Configuration parameters in /etc/approx/approx.conf should now begin
+with '$' to distinguish them from repository names. The old style is
+still accepted with a warning message.
+
+Several parameters have been added: $user, $group, $syslog, $verbose.
+See the approx.conf man page for details.
+
approx (2.06) unstable; urgency=low
A new configuration variable, interface, forces approx to listen for
Modified: trunk/projects/approx/trunk/debian/approx.cron.weekly
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/approx.cron.weekly?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/approx.cron.weekly (original)
+++ trunk/projects/approx/trunk/debian/approx.cron.weekly Mon Jun 18 23:32:24 2007
@@ -1,10 +1,11 @@
-#!/bin/sh -e
+#!/bin/sh
# Garbage collect the approx(8) cache
/usr/sbin/gc_approx --quiet
# Remove any empty directories
-# The trailing /. makes it work when /var/cache/approx is a symlink
-find /var/cache/approx/. -type d -empty | xargs --no-run-if-empty rmdir
+cd /var/cache/approx/ && \
+ find -type d -empty | \
+ xargs --no-run-if-empty rmdir --parents --ignore-fail-on-non-empty
Added: trunk/projects/approx/trunk/debian/approx.docs
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/approx.docs?rev=3858&op=file
==============================================================================
--- trunk/projects/approx/trunk/debian/approx.docs (added)
+++ trunk/projects/approx/trunk/debian/approx.docs Mon Jun 18 23:32:24 2007
@@ -1,0 +1,1 @@
+doc/README.concurrency
Added: trunk/projects/approx/trunk/debian/approx.install
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/approx.install?rev=3858&op=file
==============================================================================
--- trunk/projects/approx/trunk/debian/approx.install (added)
+++ trunk/projects/approx/trunk/debian/approx.install Mon Jun 18 23:32:24 2007
@@ -1,0 +1,3 @@
+approx usr/sbin
+gc_approx usr/sbin
+etc/approx.conf etc/approx
Added: trunk/projects/approx/trunk/debian/approx.manpages
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/approx.manpages?rev=3858&op=file
==============================================================================
--- trunk/projects/approx/trunk/debian/approx.manpages (added)
+++ trunk/projects/approx/trunk/debian/approx.manpages Mon Jun 18 23:32:24 2007
@@ -1,0 +1,3 @@
+doc/approx.8
+doc/gc_approx.8
+doc/approx.conf.5
Modified: trunk/projects/approx/trunk/debian/approx.postinst
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/approx.postinst?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/approx.postinst (original)
+++ trunk/projects/approx/trunk/debian/approx.postinst Mon Jun 18 23:32:24 2007
@@ -1,9 +1,6 @@
#!/bin/sh -e
-action="$1"
-oldversion="$2"
-
-if [ "$action" != "configure" ]; then
+if [ "$1" != "configure" ]; then
exit 0
fi
@@ -44,7 +41,7 @@
# check for potential conflict with apt-proxy
port=$(approx_config port 9999)
-if [ -x /etc/init.d/apt-proxy ] && [ "$port" = 9999 ]; then
+if [ -x /usr/sbin/apt-proxy ] && [ "$port" = 9999 ]; then
cat >&2 <<EOF
Warning: apt-proxy appears to be installed also.
For compatibility with client sources.list files,
@@ -55,5 +52,3 @@
fi
#DEBHELPER#
-
-# -*- shell-script-mode -*-
Modified: trunk/projects/approx/trunk/debian/approx.postrm
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/approx.postrm?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/approx.postrm (original)
+++ trunk/projects/approx/trunk/debian/approx.postrm Mon Jun 18 23:32:24 2007
@@ -1,21 +1,13 @@
#!/bin/sh -e
-action="$1"
-
-if [ "$action" != "purge" ]; then
- exit 0
-fi
-
-rm -rf /var/cache/approx
-
-if getent passwd approx >/dev/null; then
- deluser --quiet approx
-fi
-
-if getent group approx >/dev/null; then
- delgroup --quiet approx
+if [ "$1" = "purge" ]; then
+ rm -rf /var/cache/approx
+ if getent passwd approx >/dev/null; then
+ deluser --quiet approx || true
+ fi
+ if getent group approx >/dev/null; then
+ delgroup --quiet approx || true
+ fi
fi
#DEBHELPER#
-
-# -*- shell-script-mode -*-
Modified: trunk/projects/approx/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/changelog?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/changelog (original)
+++ trunk/projects/approx/trunk/debian/changelog Mon Jun 18 23:32:24 2007
@@ -1,8 +1,24 @@
-approx (2.8.1) unstable; urgency=low
-
- * Change dependency on ocaml-tools to ocamlmakefile [Ralf Treinen]
-
- --
+approx (2.9.0) unstable; urgency=low
+
+ * Changed debian/rules to use cdbs
+ * Improve postinst check for conflict with apt-proxy
+ (closes: #395375)
+ * Make sure cronjob doesn't fail if approx has been removed
+ or cache directory is empty (closes: #404819, #416361)
+ * Require configuration parameters to begin with '$' to distinguish
+ them from repository names
+ * Added $verbose parameter to control logging of informational messages
+ (closes: #403514)
+ * Added $syslog parameter to specify the syslog facility
+ (closes: #406504)
+ * Added $user and $group parameters to control the approx daemon's user
+ and group [Alexandra N. Kossovsky <sasha at oktetlabs.ru>]
+ (closes: #423836)
+ * Don't assume deluser is still available in postrm (closes: #416643)
+ * Migrated to Ocamlnet 2 (closes: #420478)
+ * Changed dependency from ocaml-tools to ocamlmakefile (closes: #428723)
+
+ -- Eric Cooper <ecc at cmu.edu> Wed, 13 Jun 2007 16:04:53 -0400
approx (2.8.0) unstable; urgency=low
Modified: trunk/projects/approx/trunk/debian/control
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/control?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/control (original)
+++ trunk/projects/approx/trunk/debian/control Mon Jun 18 23:32:24 2007
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Eric Cooper <ecc at cmu.edu>
Uploaders: Sven Luther <luther at debian.org>, Stefano Zacchiroli <zack at debian.org>
-Build-Depends: debhelper (>= 5.0), ocaml-nox (>= 3.09), ocaml-best-compilers, ocamlmakefile, libocamlnet-ocaml-dev (>= 1.1), libpcre-ocaml-dev (>= 5.11), libsyslog-ocaml-dev (>= 1.3), libsha-ocaml-dev (>= 1.3)
+Build-Depends: debhelper (>= 5.0), cdbs, ocamlmakefile, ocaml-nox (>= 3.09), ocaml-best-compilers, libnethttpd-ocaml-dev (>= 2.2), libpcre-ocaml-dev (>= 5.11), libsha-ocaml-dev (>= 1.3), libsyslog-ocaml-dev (>= 1.3)
Standards-Version: 3.7.2
XS-Vcs-Svn: svn://svn.debian.org/svn/pkg-ocaml-maint/trunk/projects/approx
Modified: trunk/projects/approx/trunk/debian/rules
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/debian/rules?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/debian/rules (original)
+++ trunk/projects/approx/trunk/debian/rules Mon Jun 18 23:32:24 2007
@@ -1,64 +1,13 @@
#!/usr/bin/make -f
-OCAMLABI = $(shell ocamlc -version)
-BYTECODE = $(shell [ -x /usr/bin/ocamlopt ] || echo yes)
-OCAMLRUN = $(if $(BYTECODE),ocaml-base-nox-$(OCAMLABI))
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/makefile.mk
+include /usr/share/cdbs/1/class/ocaml.mk
-build: build-stamp
-build-stamp:
- dh_testdir
- ./gen_version > version.ml
- $(MAKE) $(if $(BYTECODE),byte-code,native-code)
- touch build-stamp
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp
- -$(MAKE) clean
- dh_clean version.ml
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- dh_install approx gc_approx usr/sbin
- dh_install etc/approx.conf etc/approx
-
-binary-indep: build install
-
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs doc/README.concurrency
- dh_installexamples
-# dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installcatalogs
-# dh_installpam
-# dh_installmime
- dh_installinit
- dh_installcron
-# dh_installinfo
-# dh_undocumented
- dh_installman doc/*.[1-8]
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_python
-# dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol -- -VF:OCamlRun="$(OCAMLRUN)"
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
+ DEB_MAKE_BUILD_TARGET = native-code
+ DEB_DH_GENCONTROL_ARGS += -VF:OCamlRun=""
+else
+ DEB_MAKE_BUILD_TARGET = byte-code
+ DEB_DH_GENCONTROL_ARGS += -VF:OCamlRun="ocaml-base-nox-$(OCAML_ABI)"
+endif
Modified: trunk/projects/approx/trunk/default_config.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/default_config.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/default_config.ml (original)
+++ trunk/projects/approx/trunk/default_config.ml Mon Jun 18 23:32:24 2007
@@ -9,9 +9,13 @@
let () = read config_file
-let interface = get "interface" ~default: "any"
-let port = get_int "port" ~default: 9999 (* for compatibility with apt-proxy *)
-let interval = get_int "interval" ~default: 720 (* minutes *)
-let max_wait = get_int "max_wait" ~default: 10 (* seconds *)
-let max_rate = get "max_rate" ~default: "unlimited"
-let debug = get_bool "debug" ~default: false
+let interface = get "$interface" ~default: "any"
+let port = get_int "$port" ~default: 9999 (* compatible with apt-proxy *)
+let interval = get_int "$interval" ~default: 720 (* minutes *)
+let max_wait = get_int "$max_wait" ~default: 10 (* seconds *)
+let max_rate = get "$max_rate" ~default: "unlimited"
+let user = get "$user" ~default: "approx"
+let group = get "$group" ~default: "approx"
+let syslog = get "$syslog" ~default: "daemon"
+let debug = get_bool "$debug" ~default: false
+let verbose = get_bool "$verbose" ~default: false || debug
Modified: trunk/projects/approx/trunk/default_config.mli
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/default_config.mli?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/default_config.mli (original)
+++ trunk/projects/approx/trunk/default_config.mli Mon Jun 18 23:32:24 2007
@@ -10,4 +10,8 @@
val interval : int (* minutes *)
val max_wait : int (* seconds *)
val max_rate : string (* bytes/second with optional K, M, or G suffix *)
+val user : string
+val group : string
+val syslog : string
+val verbose : bool
val debug : bool
Modified: trunk/projects/approx/trunk/doc/approx.conf.5
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/doc/approx.conf.5?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/doc/approx.conf.5 (original)
+++ trunk/projects/approx/trunk/doc/approx.conf.5 Mon Jun 18 23:32:24 2007
@@ -18,31 +18,43 @@
a name/value pair, separated by white space.
Comments start with a "#" character and continue to the end of the line.
.PP
-The following names have special meaning:
-.IP interface
+Names that begin with the "$" character are reserved for use as
+configuration parameters. The following parameters are currently defined:
+.IP $interface
Specifies the name of the network interface on which the
.BR approx (8)
server listens for HTTP requests (default: any)
-.IP port
+.IP $port
Specifies the TCP port on which the
.BR approx (8)
server listens for HTTP requests (default: 9999)
-.IP interval
+.IP $interval
Specifies the time in minutes after which a cached file will be
considered too old to deliver without first checking with the remote
repository for a newer version (default: 720, or 12 hours)
-.IP max_wait
+.IP $max_wait
Specifies how many seconds an
.BR approx (8)
process will wait for a concurrent download of a file to complete,
before attempting to download the file itself (default: 10)
-.IP max_rate
+.IP $max_rate
Specifies the maximum download rate from remote repositories,
in bytes per second (default: unlimited).
The value may be suffixed with "K", "M", or "G"
to indicate kilobytes, megabytes, or gigabytes per second, respectively.
-.IP debug
-Specifies whether debugging messages should be printed
+.IP "$user, $group"
+Specifies the name of the user and group to use after the daemon drops
+privileges (default: "approx")
+.IP $syslog
+Specifies the
+.BR syslog (3)
+facility to use when logging (default: "daemon")
+.IP $verbose
+Specifies whether informational messages should be printed in the log
+(default:
+.BR false )
+.IP $debug
+Specifies whether debugging messages should be printed in the log
(default:
.BR false )
.PP
Modified: trunk/projects/approx/trunk/etc/approx.conf
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/etc/approx.conf?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/etc/approx.conf (original)
+++ trunk/projects/approx/trunk/etc/approx.conf Mon Jun 18 23:32:24 2007
@@ -2,12 +2,16 @@
# to uncomment them unless you want a different value.
# See approx.conf(5) for details.
-#interface any
-#port 9999
-#interval 720
-#max_wait 10
-#max_rate unlimited
-#debug false
+#$interface any
+#$port 9999
+#$interval 720
+#$max_wait 10
+#$max_rate unlimited
+#$user approx
+#$group approx
+#$syslog daemon
+#$verbose false
+#$debug false
# Here are some examples of remote repository mappings.
# See http://www.debian.org/mirror/list for mirror sites.
Modified: trunk/projects/approx/trunk/gc.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/gc.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/gc.ml (original)
+++ trunk/projects/approx/trunk/gc.ml Mon Jun 18 23:32:24 2007
@@ -188,7 +188,7 @@
iter_status gc
let garbage_collect () =
- drop_privileges "approx";
+ drop_privileges ~user ~group;
mark ();
sweep ()
Modified: trunk/projects/approx/trunk/ifaddr.c
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/ifaddr.c?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/ifaddr.c (original)
+++ trunk/projects/approx/trunk/ifaddr.c Mon Jun 18 23:32:24 2007
@@ -1,5 +1,5 @@
/* approx: proxy server for Debian archive files
- Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License */
#include <stdlib.h>
@@ -12,11 +12,11 @@
static int
ifaddr(char *name, /* OUT */ struct in_addr *addr)
{
+ struct ifreq r;
+ int i;
int s = socket(PF_INET, SOCK_STREAM, 0);
if (s == -1)
return 0;
- struct ifreq r;
- int i;
for (i = 0; i < sizeof(r.ifr_name); i++) {
if ((r.ifr_name[i] = name[i]) == '\0')
break;
@@ -35,6 +35,16 @@
#include <caml/memory.h>
#include <caml/mlvalues.h>
+/*
+ * defined in otherlibs/unix/socketaddr.c
+ */
+extern value alloc_inet_addr(struct in_addr *);
+
+/*
+ * defined in asmrun/fail.c
+ */
+extern void caml_raise_not_found(void);
+
value
inet_addr_of_interface(value name)
{
@@ -43,5 +53,6 @@
if (ifaddr(String_val(name), &addr))
CAMLreturn(alloc_inet_addr(&addr));
else
- raise_not_found();
+ caml_raise_not_found();
+ return Val_unit; /* not reached, but eliminates gcc warning */
}
Modified: trunk/projects/approx/trunk/log.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/log.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/log.ml (original)
+++ trunk/projects/approx/trunk/log.ml Mon Jun 18 23:32:24 2007
@@ -1,8 +1,9 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
open Printf
+open Util
let printer = ref (fun _ msg -> prerr_string msg; flush stderr)
@@ -21,10 +22,39 @@
let info_message fmt = message `LOG_INFO fmt
let debug_message fmt = message `LOG_DEBUG fmt
+let exception_message exc = error_message "%s" (string_of_exception exc)
+
+let facility =
+ match Default_config.syslog with
+ | "auth" -> `LOG_AUTH
+ | "authpriv" -> `LOG_AUTHPRIV
+ | "console" -> `LOG_CONSOLE
+ | "cron" -> `LOG_CRON
+ | "daemon" -> `LOG_DAEMON
+ | "ftp" -> `LOG_FTP
+ | "kern" -> `LOG_KERN
+ | "lpr" -> `LOG_LPR
+ | "mail" -> `LOG_MAIL
+ | "news" -> `LOG_NEWS
+ | "ntp" -> `LOG_NTP
+ | "security" -> `LOG_SECURITY
+ | "syslog" -> `LOG_SYSLOG
+ | "user" -> `LOG_USER
+ | "uucp" -> `LOG_UUCP
+ | "local0" -> `LOG_LOCAL0
+ | "local1" -> `LOG_LOCAL1
+ | "local2" -> `LOG_LOCAL2
+ | "local3" -> `LOG_LOCAL3
+ | "local4" -> `LOG_LOCAL4
+ | "local5" -> `LOG_LOCAL5
+ | "local6" -> `LOG_LOCAL6
+ | "local7" -> `LOG_LOCAL7
+ | fac -> error_message "Unknown syslog facility: %s" fac; `LOG_DAEMON
+
let use_syslog () =
let prog = Filename.basename Sys.argv.(0) in
try
- let log = Syslog.openlog ~facility: `LOG_DAEMON prog in
+ let log = Syslog.openlog ~facility prog in
printer := Syslog.syslog log
with _ ->
error_message "Cannot connect to system logger";
Modified: trunk/projects/approx/trunk/log.mli
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/log.mli?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/log.mli (original)
+++ trunk/projects/approx/trunk/log.mli Mon Jun 18 23:32:24 2007
@@ -1,5 +1,5 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
val use_syslog : unit -> unit
@@ -7,3 +7,5 @@
val error_message : ('a, unit, string, unit) format4 -> 'a
val info_message : ('a, unit, string, unit) format4 -> 'a
val debug_message : ('a, unit, string, unit) format4 -> 'a
+
+val exception_message : exn -> unit
Copied: trunk/projects/approx/trunk/mkversion (from r2953, trunk/projects/approx/trunk/gen_version)
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/mkversion?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/gen_version (original)
+++ trunk/projects/approx/trunk/mkversion Mon Jun 18 23:32:24 2007
@@ -18,7 +18,10 @@
}
sub write_version() {
+ my $t = localtime;
print <<EOF;
+(* Automatically generated by $0 on $t *)
+
let name = "$name"
let number = "$number"
EOF
Modified: trunk/projects/approx/trunk/server.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/server.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/server.ml (original)
+++ trunk/projects/approx/trunk/server.ml Mon Jun 18 23:32:24 2007
@@ -1,5 +1,5 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
open Printf
@@ -7,7 +7,7 @@
open Nethttp
open Nethttpd_reactor
open Util
-open Log (* Log.error_message shadows Unix.error_message *)
+open Log
let error_response code =
let msg =
@@ -17,24 +17,28 @@
sprintf "<html><title>%d %s</title><body><h1>%d: %s</h1></body></html>"
code msg code msg
+let version = Version.name ^ "/" ^ Version.number
+
let config =
object
+ (* http_protocol_config *)
method config_max_reqline_length = 256
method config_max_header_length = 32768
method config_max_trailer_length = 32768
method config_limit_pipeline_length = 5
method config_limit_pipeline_size = 250000
-
+ method config_announce_server = `Ocamlnet_and version
+ (* http_processor_config *)
method config_timeout_next_request = 15.
method config_timeout = 300.
- method config_cgi = Netcgi_env.default_config
+ method config_cgi = Netcgi1_compat.Netcgi_env.default_config
method config_error_response n = error_response n
method config_log_error _ _ _ _ msg = error_message "%s" msg
-
+ (* http_reactor_config *)
method config_reactor_synch = `Write
end
-let main ~user ~interface port service =
+let main ~user ~group ~interface port service =
let sock = socket PF_INET SOCK_STREAM 0 in
setsockopt sock SO_REUSEADDR true;
let addr =
@@ -43,7 +47,7 @@
in
bind sock (ADDR_INET (addr, port));
listen sock 10;
- drop_privileges user;
+ drop_privileges ~user ~group;
while true do
let fd, _ = accept sock in
set_nonblock fd;
Modified: trunk/projects/approx/trunk/server.mli
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/server.mli?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/server.mli (original)
+++ trunk/projects/approx/trunk/server.mli Mon Jun 18 23:32:24 2007
@@ -2,4 +2,4 @@
Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
-val main : user:string -> interface:string -> int -> 'a Nethttpd_types.http_service -> unit
+val main : user:string -> group:string -> interface:string -> int -> 'a Nethttpd_types.http_service -> unit
Modified: trunk/projects/approx/trunk/url.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/url.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/url.ml (original)
+++ trunk/projects/approx/trunk/url.ml Mon Jun 18 23:32:24 2007
@@ -54,16 +54,16 @@
in
loop ()
-let finish chan =
+let finish desc chan =
if Unix.close_process_in chan <> Unix.WEXITED 0 then
- failwith "download failed"
+ failwith (desc ^ " failed")
let head url callback =
let cmd = head_command url in
if debug then debug_message "Command: %s" cmd;
let chan = Unix.open_process_in cmd in
iter_headers chan callback;
- finish chan
+ finish ("head of " ^ url) chan
let download_command headers header_callback =
let hdr_opts = List.map (fun h -> "--header " ^ quoted_string h) headers in
@@ -92,7 +92,7 @@
| Some proc -> iter_headers chan proc
| None -> ());
iter_body chan callback;
- finish chan
+ finish ("download of " ^ url) chan
let download_file ~url ~file =
let file' = file ^ ".tmp" in
Modified: trunk/projects/approx/trunk/util.ml
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/util.ml?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/util.ml (original)
+++ trunk/projects/approx/trunk/util.ml Mon Jun 18 23:32:24 2007
@@ -1,5 +1,5 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2006 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2007 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
open Unix
@@ -143,9 +143,9 @@
let file_sha1sum = let module F = FileDigest(Sha1) in F.sum
let file_sha256sum = let module F = FileDigest(Sha256) in F.sum
-let drop_privileges name =
- setgid (getgrnam name).gr_gid;
- setuid (getpwnam name).pw_uid
+let drop_privileges ~user ~group =
+ setgid (getgrnam group).gr_gid;
+ setuid (getpwnam user).pw_uid
let packages_variants = [ "Packages"; "Packages.gz"; "Packages.bz2" ]
@@ -181,8 +181,8 @@
| Failure str -> String.capitalize str
| Invalid_argument str -> "Invalid argument: " ^ str
| Sys_error str -> str
- | Unix.Unix_error (err, str, arg) ->
- let msg = Printf.sprintf "%s: %s" str (Unix.error_message err) in
+ | Unix_error (err, str, arg) ->
+ let msg = Printf.sprintf "%s: %s" str (error_message err) in
if arg <> "" then Printf.sprintf "%s (%s)" msg arg
else msg
| e -> Printexc.to_string e
Modified: trunk/projects/approx/trunk/util.mli
URL: http://svn.debian.org/wsvn/trunk/projects/approx/trunk/util.mli?rev=3858&op=diff
==============================================================================
--- trunk/projects/approx/trunk/util.mli (original)
+++ trunk/projects/approx/trunk/util.mli Mon Jun 18 23:32:24 2007
@@ -96,7 +96,7 @@
(* Drop privileges (user and group ID) to those of the specified name *)
-val drop_privileges : string -> unit
+val drop_privileges : user:string -> group:string -> unit
(* Check whether a file is a Sources file *)
More information about the Pkg-ocaml-maint-commits
mailing list