summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgios M. Zarkadas <gz@member.fsf.org>2015-07-18 22:33:42 +0300
committerGeorgios M. Zarkadas <gz@member.fsf.org>2015-07-18 22:33:42 +0300
commite39e86797ad1794ba617eb6a967f095f91d3062b (patch)
tree273baba98cb20372ec62311603884e8e3f2aaaf9
parent7a3870d31cb2aea26ba63d0daec67936336d2348 (diff)
Merged rest of 0.6.21+nmu6 changes except debian subdirectory.
-rw-r--r--Makefile14
-rw-r--r--config/apache-dhelp-2.2.conf53
-rw-r--r--config/apache-dhelp.conf14
-rw-r--r--examples/index_package_doc.rb4
-rw-r--r--lib/dhelp.rb8
-rw-r--r--lib/dhelp/exporter/cgimap.rb9
-rw-r--r--lib/dhelp/exporter/html.rb4
-rwxr-xr-xsrc/dhelp_fetcher.rb2
-rwxr-xr-xsrc/dhelp_parse.rb19
-rw-r--r--test/doc-base/pica-manual2
-rw-r--r--test/tc_dhelpdocumentpool.rb2
-rw-r--r--test/tc_docbasedocument.rb2
-rw-r--r--test/ts_dhelp.rb2
13 files changed, 103 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index 0339356..35f830a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# Makefile for dhelp project
-# Copyright (C) 2005 Esteban Manchado Velázquez <zoso@debian.org>
+# Copyright (C) 2005 Esteban Manchado Velázquez <zoso@debian.org>
# Copyright (C) 2012 Georgios M. Zarkadas <gz@member.fsf.org>
# This file is free software; you can redistribute it and/or modify it
@@ -33,13 +33,17 @@ sharedir = $(DESTDIR_)/share/$(PACKAGE)
docdir = $(DESTDIR_)/share/doc/$(PACKAGE)
# The caller should define VENDOR_RUBY to use the new location for ruby
-# libraries from wheezy and onwards. Undefine it to backport the package
-# to previous Debian releases.
+# libraries from squeeze and onwards; OLD_VENDOR_RUBY for wheezy and onwards.
+# Undefine it to backport the package to previous Debian releases.
ifdef VENDOR_RUBY
-rubydir = $(DESTDIR_)/lib/ruby/vendor_ruby/1.8
+rubydir = $(DESTDIR_)/lib/ruby/vendor_ruby/
else
+ ifdef OLD_VENDOR_RUBY
+rubydir = $(DESTDIR_)/lib/ruby/vendor_ruby/1.8
+ else
rubydir = $(DESTDIR_)/lib/ruby/1.8
+ endif
endif
# Templates and Perl-related variables
@@ -94,7 +98,7 @@ install-doc:
## Our and web servers configuration under /etc
install-conf:
install -D --mode=644 config/dhelp.conf-sample $(confdir)/dhelp.conf
- install -D --mode=644 config/apache-dhelp.conf $(confdir)/apache2/conf.d/dhelp.conf
+ install -D --mode=644 config/apache-dhelp-2.2.conf $(confdir)/apache2/conf.d/dhelp.conf
install -D --mode=644 config/apache-dhelp.conf $(confdir)/apache2/conf-available/dhelp.conf
install -D --mode=644 config/lighttpd-dhelp.conf $(confdir)/lighttpd/conf-available/95-dhelp.conf
diff --git a/config/apache-dhelp-2.2.conf b/config/apache-dhelp-2.2.conf
new file mode 100644
index 0000000..ff20368
--- /dev/null
+++ b/config/apache-dhelp-2.2.conf
@@ -0,0 +1,53 @@
+# This config file is for Apache version 2.2.x and is installed
+# into /etc/apache2/conf.d. It is ignored by Apache version 2.4.x;
+# that has its own configuration file available in
+# /etc/apache2/conf-available
+<Location ~ /cgi-bin/d(search|help_fetcher)(\?.*)?>
+ order deny,allow
+ deny from all
+ allow from localhost
+ Options -Indexes -MultiViews
+</Location>
+
+<Directory /usr/share/doc>
+ order deny,allow
+ deny from all
+ allow from localhost
+ Options Indexes MultiViews FollowSymLinks
+</Directory>
+
+# The following directives are needed for the operation of Debian Online Help
+# and are assumed to already be enabled on the server's configuration:
+#
+#Alias /doc /usr/share/doc
+#
+#ScriptAlias /cgi-bin /usr/lib/cgi-bin
+#<Directory /usr/lib/cgi-bin>
+# AllowOverride None
+# Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+# order allow,deny
+# allow from all
+#</Directory>
+#
+# Note that enabling /doc/ alias may result in a security vulnerability,
+# specifically CVE-2012-0216. Thus newer versions of the apache2 package
+# do NOT have the /doc/ alias enabled by default.
+#
+# See http://www.debian.org/security/2012/dsa-2452 for reference and to
+# decide whether the conditions stated there apply to your case.
+#
+# Then, enable the /doc/ alias by uncommenting the line above, if you judge
+# that it is secure to do so. Else you can uncomment the following two lines
+# to allow a secure partial operation of Debian Online Help, even if the
+# above vulnerability is present:
+#
+#Alias /doc/HTML /usr/share/doc/HTML
+#Alias /doc/dhelp/css /usr/share/doc/dhelp/css
+#
+# Using the above two alias you will be able to see descriptions and search
+# for terms, but the documents themselves will be inaccessible. You will need
+# to manually add an alias directive *for each document* that you want it to
+# become accessible.
+#
+# See also /usr/share/doc/dhelp/README.Debian for more information.
+
diff --git a/config/apache-dhelp.conf b/config/apache-dhelp.conf
index 48a2ccd..ae9dda2 100644
--- a/config/apache-dhelp.conf
+++ b/config/apache-dhelp.conf
@@ -1,14 +1,14 @@
+# This config file is for Apache version 2.4.x and is installed
+# into /etc/apache2/conf-available. It is ignored by Apache version 2.2.x;
+# that has its own configuration file available in
+# /etc/apache2/conf.d
<Location ~ /cgi-bin/d(search|help_fetcher)(\?.*)?>
- order deny,allow
- deny from all
- allow from localhost
+ Require local
Options -Indexes -MultiViews
</Location>
<Directory /usr/share/doc>
- order deny,allow
- deny from all
- allow from localhost
+ Require local
Options Indexes MultiViews FollowSymLinks
</Directory>
@@ -27,7 +27,7 @@
# Note that enabling /doc/ alias may result in a security vulnerability,
# specifically CVE-2012-0216. Thus newer versions of the apache2 package
# do NOT have the /doc/ alias enabled by default.
-#
+#
# See http://www.debian.org/security/2012/dsa-2452 for reference and to
# decide whether the conditions stated there apply to your case.
#
diff --git a/examples/index_package_doc.rb b/examples/index_package_doc.rb
index 391a67d..1ac0e0e 100644
--- a/examples/index_package_doc.rb
+++ b/examples/index_package_doc.rb
@@ -37,10 +37,10 @@ EOF
# If the index doesn't exist, we have to force non-incremental indexing
options = {}
index_file = '/var/lib/dhelp/documents.index'
-if File.exists? index_file and File.size(index_file) == 0
+if File.exist? index_file and File.size(index_file) == 0
FileUtils.rm_f index_file
end
-unless File.exists? index_file
+unless File.exist? index_file
options[:incremental] = false
end
diff --git a/lib/dhelp.rb b/lib/dhelp.rb
index 1fa3a84..4cc2697 100644
--- a/lib/dhelp.rb
+++ b/lib/dhelp.rb
@@ -1,7 +1,7 @@
=begin
Ruby support library for dhelp database access
- Copyright (C) 2005 Esteban Manchado Velázquez
+ Copyright (C) 2005 Esteban Manchado Velázquez
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -544,7 +544,7 @@ module Dhelp
# Returns the pending-documents-list-for-indexing contents as an array
def read_pending_file
- # Don't use File.exists? to avoid races; use exceptions instead
+ # Don't use File.exist? to avoid races; use exceptions instead
begin
IO.readlines(pending_file)
rescue Errno::ENOENT
@@ -572,7 +572,7 @@ module Dhelp
# Returns true if already indexing
def is_indexing?
i_file = (incremental ? "#{index_file}.new" : index_file)
- File.exists?(i_file) and File.size(i_file) == 0
+ File.exist?(i_file) and File.size(i_file) == 0
end
# Index the list of given dirs/files with index++. Directories are indexed
@@ -588,7 +588,7 @@ module Dhelp
# If the index doesn't exist yet and we're doing incremental,
# switch to non-incremental mode and create it. That way we will
# have at least a partial index until the next rebuild cron job.
- if incremental and not File.exists?(index_file)
+ if incremental and not File.exist?(index_file)
@opts[:incremental] = false
cmd = "#{indexpp_cmd} #{indexpp_options} -"
end
diff --git a/lib/dhelp/exporter/cgimap.rb b/lib/dhelp/exporter/cgimap.rb
index d3e8c4e..2de36bd 100644
--- a/lib/dhelp/exporter/cgimap.rb
+++ b/lib/dhelp/exporter/cgimap.rb
@@ -62,9 +62,14 @@ module Dhelp::Exporter
}
end
+ @@pkgs_status = {}
+
# Return true if the package associated to this item is installed.
def installed?(item)
- return package_status(item) == "installed"
+ return @@pkgs_status[item] if @@pkgs_status[item] != nil
+
+ @@pkgs_status[item] = package_status(item) == "installed"
+ return @@pkgs_status[item]
end
end # class BaseMap
@@ -93,7 +98,7 @@ module Dhelp::Exporter
# From debian wheezy's man2html and onwards
# the script is inside a 'man' subdirectory.
- if File.exists?("/usr/lib/cgi-bin/man/man2html")
+ if File.exist?("/usr/lib/cgi-bin/man/man2html")
return "<a href=\"/cgi-bin/man/man2html\">" + _(MAN2HTML) + "</a>"
else
return "<a href=\"/cgi-bin/man2html\">" + _(MAN2HTML) + "</a>"
diff --git a/lib/dhelp/exporter/html.rb b/lib/dhelp/exporter/html.rb
index 736a8f2..0d25944 100644
--- a/lib/dhelp/exporter/html.rb
+++ b/lib/dhelp/exporter/html.rb
@@ -33,7 +33,7 @@ module Dhelp::Exporter
Don't put files in this directory!
dhelp will delete *all* files in this directory when creating a new index.
-Esteban Manchado Velázquez (zoso@debian.org)
+Esteban Manchado Velázquez (zoso@debian.org)
EOREADME
end
end
@@ -81,7 +81,7 @@ EOREADME
make_page(index_template, export_dir, "index.html")
- rescue Errno::EACCES => e
+ rescue Errno::EACCES # => e
$stderr.puts "Don't have permissions to regenerate the HTML help"
exit 1
end
diff --git a/src/dhelp_fetcher.rb b/src/dhelp_fetcher.rb
index af3ad5b..94fba68 100755
--- a/src/dhelp_fetcher.rb
+++ b/src/dhelp_fetcher.rb
@@ -1,4 +1,4 @@
-#!/usr/bin/ruby1.8 -w
+#!/usr/bin/ruby -w
require 'cgi'
require 'erb'
diff --git a/src/dhelp_parse.rb b/src/dhelp_parse.rb
index 27d7891..2dfb5df 100755
--- a/src/dhelp_parse.rb
+++ b/src/dhelp_parse.rb
@@ -1,4 +1,4 @@
-#!/usr/bin/ruby1.8 -w
+#!/usr/bin/ruby -w
=begin
Documentation generator for dhelp
@@ -24,6 +24,11 @@
PREFIX = '/usr'
DEFAULT_INDEX_ROOT = "#{PREFIX}/share/doc/HTML"
+# Set default file format as UTF-8, without printing a warning
+old_verbose, $VERBOSE = $VERBOSE, false
+Encoding.default_external = "UTF-8"
+$VERBOSE = old_verbose
+
require 'dhelp'
require 'dhelp/exporter/html'
include Dhelp
@@ -89,10 +94,12 @@ Written by #{AUTHOR}."
opts.on('-a FILE[...]', MSG_DOC_ADD) { |files|
@action = :add
+ files = [files] if files.is_a? String
@doc_base_files = files
}
opts.on('-d FILE[...]', MSG_DOC_RMV) { |files|
@action = :delete
+ files = [files] if files.is_a? String
@doc_base_files = files
}
opts.on('-i', MSG_INDEX) { @action = :index }
@@ -111,10 +118,15 @@ Written by #{AUTHOR}."
end
optparse.summary_width = 16
optparse.parse!
+
+ if @action == nil
+ $stderr.puts optparse
+ exit 1
+ end
end
def packaged_configured?
- File.exists? '/var/lib/dhelp/configured'
+ File.exist? '/var/lib/dhelp/configured'
end
# Adds the documents supplied in command-line to the pool.
@@ -195,9 +207,6 @@ Written by #{AUTHOR}."
when :reindex
# Recreate the pool, without doing a full indexing.
pool.rebuild(false)
- else
- $stderr.puts usage
- return 1
end
# Always executed
diff --git a/test/doc-base/pica-manual b/test/doc-base/pica-manual
index 3c64f29..99e8f8c 100644
--- a/test/doc-base/pica-manual
+++ b/test/doc-base/pica-manual
@@ -1,6 +1,6 @@
Document: pica-manual
Title: PICA Manual
-Author: Esteban Manchado Velázquez
+Author: Esteban Manchado Velázquez
Abstract: This manual describes what PICA is
and how it can be used to administer your
machines and keep them up-to-date and secure.
diff --git a/test/tc_dhelpdocumentpool.rb b/test/tc_dhelpdocumentpool.rb
index e07f93e..16984c2 100644
--- a/test/tc_dhelpdocumentpool.rb
+++ b/test/tc_dhelpdocumentpool.rb
@@ -106,7 +106,7 @@ class TC_DhelpDocumentPool < Test::Unit::TestCase
# Now, once everything is indexed, force a reindexing (like the cron job)
FileUtils.rm_f TEST_INDEX_FILE
@pool.rebuild
- assert File.exists?(TEST_INDEX_FILE),
+ assert File.exist?(TEST_INDEX_FILE),
"Index file should exist after rebuilding"
assert(File.size(TEST_INDEX_FILE) > 0,
"Index file should have non-zero size after rebuilding")
diff --git a/test/tc_docbasedocument.rb b/test/tc_docbasedocument.rb
index 70fe227..22bf4a9 100644
--- a/test/tc_docbasedocument.rb
+++ b/test/tc_docbasedocument.rb
@@ -12,7 +12,7 @@ class TC_DocBaseDocument < Test::Unit::TestCase
assert_equal 'pica-manual', file.document
assert_equal 'PICA Manual', file.title
- assert_equal 'Esteban Manchado Velázquez', file.author
+ assert_equal 'Esteban Manchado Velázquez', file.author
assert_equal 'Admin', file.section
assert_equal "This manual describes what PICA is and how it can be used to administer your machines and keep them up-to-date and secure.", file.abstract
diff --git a/test/ts_dhelp.rb b/test/ts_dhelp.rb
index 35e271d..1d1e37f 100644
--- a/test/ts_dhelp.rb
+++ b/test/ts_dhelp.rb
@@ -1,7 +1,7 @@
=begin
Testsuite for the Ruby parts of dhelp
- Copyright (C) 2005 Esteban Manchado Velázquez
+ Copyright (C) 2005 Esteban Manchado Velázquez
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by