Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc.
@ 2020-05-12  0:27 Philip Prindeville
  2020-05-12  9:30 ` Jan Engelhardt
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Prindeville @ 2020-05-12  0:27 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Jan Engelhardt, Philip Prindeville

From: Philip Prindeville <philipp@redfish-solutions.com>

Also change the default destination directory to /usr/share/xt_geoip
as most distros use this now.  Update the documentation.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
---
 geoip/xt_geoip_build   |  4 +++-
 geoip/xt_geoip_build.1 | 10 +++++-----
 geoip/xt_geoip_fetch   |  3 ++-
 geoip/xt_geoip_fetch.1 |  3 ++-
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
index e7ad9bfdcc1e3b617ada77872f9be87e126b885f..edb05426554f799524610ce55cbfe738b838ba0e 100644
--- a/geoip/xt_geoip_build
+++ b/geoip/xt_geoip_build
@@ -5,6 +5,7 @@
 #	Copyright Philip Prindeville, 2018
 #	Copyright Arjen de Korte, 2020
 #
+
 use Getopt::Long;
 use Net::CIDR::Lite;
 use Socket qw(AF_INET AF_INET6 inet_pton);
@@ -17,8 +18,9 @@ my $csv = Text::CSV_XS->new({
 	binary => 1,
 	eol => $/,
 }); # or Text::CSV
+
 my $source_dir = ".";
-my $target_dir = ".";
+my $target_dir = "/usr/share/xt_geoip";
 
 &Getopt::Long::Configure(qw(bundling));
 &GetOptions(
diff --git a/geoip/xt_geoip_build.1 b/geoip/xt_geoip_build.1
index 3b6ead31edd405688e692d1244fd6726dd529875..2513f34effffee82a206afca057328f5b86385d5 100644
--- a/geoip/xt_geoip_build.1
+++ b/geoip/xt_geoip_build.1
@@ -22,13 +22,13 @@ script requires it to be called with a path.
 .PP Options
 .TP
 \fB\-D\fP \fItarget_dir\fP
-Specifies the target directory into which the files are to be put. Defaults to ".".
+Specifies the target directory into which the files are to be put.
+Defaults to "/usr/share/xt_geoip".
 .TP
 \fB\-S\fP \fIsource_dir\fP
-Specifies the source directory from which to read the three files by the name
-of \fBGeoLite2\-Country\-Blocks\-IPv4.csv\fP,
-\fBGeoLite2\-Country\-Blocks\-IPv6.csv\fP and
-\fBGeoLite2\-Country\-Locations\-en.csv\fP. Defaults to ".".
+Specifies the source directory from which to read the file
+\fBdbip-country-lite.csv\fP.
+Defaults to ".".
 .SH Application
 .PP
 Shell commands to build the databases and put them to where they are expected:
diff --git a/geoip/xt_geoip_fetch b/geoip/xt_geoip_fetch
index 06245195fb5166ac005b5021fa0f811e5e511c78..790ae36c68b45a63811eed69782e21ee180c8632 100755
--- a/geoip/xt_geoip_fetch
+++ b/geoip/xt_geoip_fetch
@@ -3,6 +3,7 @@
 #	Utility to query GeoIP database
 #	Copyright Philip Prindeville, 2018
 #
+
 use Getopt::Long;
 use Socket qw(AF_INET AF_INET6 inet_ntop);
 use warnings;
@@ -11,7 +12,7 @@ use strict;
 sub AF_INET_SIZE() { 4 }
 sub AF_INET6_SIZE() { 16 }
 
-my $target_dir = ".";
+my $target_dir = "/usr/share/xt_geoip";
 my $ipv4 = 0;
 my $ipv6 = 0;
 
diff --git a/geoip/xt_geoip_fetch.1 b/geoip/xt_geoip_fetch.1
index 7280c74b9ab520e61293a304207dfafee07cbe47..d51feea9328d654e98a24cc52ce7a168c15319d0 100644
--- a/geoip/xt_geoip_fetch.1
+++ b/geoip/xt_geoip_fetch.1
@@ -15,7 +15,8 @@ further processing.
 .PP Options
 .TP
 \fB\-D\fP \fIdatabase_dir\fP
-Specifies the directory into which the files have been put. Defaults to ".".
+Specifies the directory into which the files have been put.
+Defaults to "/usr/share/xt_geoip".
 .TP
 \fB-4\fP
 Specifies IPv4 data only.
-- 
2.17.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc.
  2020-05-12  0:27 [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc Philip Prindeville
@ 2020-05-12  9:30 ` Jan Engelhardt
  2020-05-12 16:51   ` Philip Prindeville
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Engelhardt @ 2020-05-12  9:30 UTC (permalink / raw)
  To: Philip Prindeville; +Cc: netfilter-devel


On Tuesday 2020-05-12 02:27, Philip Prindeville wrote:
>
>Also change the default destination directory to /usr/share/xt_geoip
>as most distros use this now.  Update the documentation.

This would break the current expectation that an unprivileged user,
using an unmodified incantation of the command, can run the program
and not run into a permission error.

Maybe there are some "nicer" approaches? I'm calling for further inspirations.

>-my $target_dir = ".";
>+my $target_dir = "/usr/share/xt_geoip";

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc.
  2020-05-12  9:30 ` Jan Engelhardt
@ 2020-05-12 16:51   ` Philip Prindeville
  2020-05-12 20:50     ` Jan Engelhardt
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Prindeville @ 2020-05-12 16:51 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: netfilter-devel



> On May 12, 2020, at 3:30 AM, Jan Engelhardt <jengelh@inai.de> wrote:
> 
> 
> On Tuesday 2020-05-12 02:27, Philip Prindeville wrote:
>> 
>> Also change the default destination directory to /usr/share/xt_geoip
>> as most distros use this now.  Update the documentation.
> 
> This would break the current expectation that an unprivileged user,
> using an unmodified incantation of the command, can run the program
> and not run into a permission error.
> 
> Maybe there are some "nicer" approaches? I'm calling for further inspirations.


I’m open to suggestions.

We could default it to a system path only when running as root, for instance.


> 
>> -my $target_dir = ".";
>> +my $target_dir = "/usr/share/xt_geoip";


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc.
  2020-05-12 16:51   ` Philip Prindeville
@ 2020-05-12 20:50     ` Jan Engelhardt
  2020-05-12 23:50       ` Philip Prindeville
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Engelhardt @ 2020-05-12 20:50 UTC (permalink / raw)
  To: Philip Prindeville; +Cc: netfilter-devel


On Tuesday 2020-05-12 18:51, Philip Prindeville wrote:
>>> Also change the default destination directory to /usr/share/xt_geoip
>>> as most distros use this now.  Update the documentation.
>> 
>> Maybe there are some "nicer" approaches? I'm calling for further inspirations.
>
>I’m open to suggestions.

This has been floating around my mind.

 geoip/xt_geoip_build   | 1 +
 geoip/xt_geoip_build.1 | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
index 750bf98..7bafa5f 100755
--- a/geoip/xt_geoip_build
+++ b/geoip/xt_geoip_build
@@ -24,6 +24,7 @@ my $target_dir = ".";
 &GetOptions(
 	"D=s" => \$target_dir,
 	"i=s" => \$input_file,
+	"s" => sub { $target_dir = "/usr/share/xt_geoip"; },
 );
 
 if (!-d $target_dir) {
diff --git a/geoip/xt_geoip_build.1 b/geoip/xt_geoip_build.1
index ac3e6d3..598177f 100644
--- a/geoip/xt_geoip_build.1
+++ b/geoip/xt_geoip_build.1
@@ -27,11 +27,15 @@ Specifies the target directory into which the files are to be put. Defaults to "
 \fB\-i\fP \fIinput_file\fP
 Specifies the source location of the DBIP CSV file. Defaults to
 "dbip-country-lite.csv". Use "-" to read from stdin.
+.TP
+\fB\-s\fP
+"System mode". Equivalent to \fB\-D /usr/share/xt_geoip\fP.
 .SH Application
 .PP
-Shell commands to build the databases and put them to where they are expected:
+Shell commands to build the databases and put them to where they are expected
+(usually run as root):
 .PP
-xt_geoip_build \-D /usr/share/xt_geoip
+xt_geoip_build \-s
 .SH See also
 .PP
 xt_geoip_dl(1)
-- 
2.26.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc.
  2020-05-12 20:50     ` Jan Engelhardt
@ 2020-05-12 23:50       ` Philip Prindeville
  0 siblings, 0 replies; 5+ messages in thread
From: Philip Prindeville @ 2020-05-12 23:50 UTC (permalink / raw)
  To: Jan Engelhardt; +Cc: netfilter-devel



> On May 12, 2020, at 2:50 PM, Jan Engelhardt <jengelh@inai.de> wrote:
> 
> 
> On Tuesday 2020-05-12 18:51, Philip Prindeville wrote:
>>>> Also change the default destination directory to /usr/share/xt_geoip
>>>> as most distros use this now.  Update the documentation.
>>> 
>>> Maybe there are some "nicer" approaches? I'm calling for further inspirations.
>> 
>> I’m open to suggestions.
> 
> This has been floating around my mind.


Problem with this change is that "-D foo -s” and “-s -D foo” have different semantics… Should probably make the two options mutually exclusive.

-Philip

> 
> geoip/xt_geoip_build   | 1 +
> geoip/xt_geoip_build.1 | 8 ++++++--
> 2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/geoip/xt_geoip_build b/geoip/xt_geoip_build
> index 750bf98..7bafa5f 100755
> --- a/geoip/xt_geoip_build
> +++ b/geoip/xt_geoip_build
> @@ -24,6 +24,7 @@ my $target_dir = ".";
> &GetOptions(
> 	"D=s" => \$target_dir,
> 	"i=s" => \$input_file,
> +	"s" => sub { $target_dir = "/usr/share/xt_geoip"; },
> );
> 
> if (!-d $target_dir) {
> diff --git a/geoip/xt_geoip_build.1 b/geoip/xt_geoip_build.1
> index ac3e6d3..598177f 100644
> --- a/geoip/xt_geoip_build.1
> +++ b/geoip/xt_geoip_build.1
> @@ -27,11 +27,15 @@ Specifies the target directory into which the files are to be put. Defaults to "
> \fB\-i\fP \fIinput_file\fP
> Specifies the source location of the DBIP CSV file. Defaults to
> "dbip-country-lite.csv". Use "-" to read from stdin.
> +.TP
> +\fB\-s\fP
> +"System mode". Equivalent to \fB\-D /usr/share/xt_geoip\fP.
> .SH Application
> .PP
> -Shell commands to build the databases and put them to where they are expected:
> +Shell commands to build the databases and put them to where they are expected
> +(usually run as root):
> .PP
> -xt_geoip_build \-D /usr/share/xt_geoip
> +xt_geoip_build \-s
> .SH See also
> .PP
> xt_geoip_dl(1)
> -- 
> 2.26.2
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12  0:27 [PATCH v1 1/1] xtables-addons: geoip: update scripts for DBIP names, etc Philip Prindeville
2020-05-12  9:30 ` Jan Engelhardt
2020-05-12 16:51   ` Philip Prindeville
2020-05-12 20:50     ` Jan Engelhardt
2020-05-12 23:50       ` Philip Prindeville

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org
	public-inbox-index netfilter-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git