-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpure_kloxo.patch
512 lines (454 loc) · 19.4 KB
/
pure_kloxo.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
diff -ruN pure-ftpd-1.0.49/configuration-file/Makefile.am pure-ftpd-1.0.49-new/configuration-file/Makefile.am
--- pure-ftpd-1.0.49/configuration-file/Makefile.am 1970-01-01 10:00:00.000000000 +1000
+++ pure-ftpd-1.0.49-new/configuration-file/Makefile.am 2019-12-27 07:48:25.677999999 +1100
@@ -0,0 +1,3 @@
+CLEANFILES = \
+ pure-config.pl \
+ pure-config.py
diff -ruN pure-ftpd-1.0.49/configuration-file/pure-config.pl.in pure-ftpd-1.0.49-new/configuration-file/pure-config.pl.in
--- pure-ftpd-1.0.49/configuration-file/pure-config.pl.in 1970-01-01 10:00:00.000000000 +1000
+++ pure-ftpd-1.0.49-new/configuration-file/pure-config.pl.in 2019-12-27 07:48:25.679000001 +1100
@@ -0,0 +1,127 @@
+#! @PERL@
+
+# (C) 2001-2013 Aristotle Pagaltzis
+# derived from code (C) 2001-2002 Frank Denis and Matthias Andree
+
+use strict;
+
+my ($conffile, @flg) = @ARGV;
+
+my $PUREFTPD;
+-x && ($PUREFTPD=$_, last) for qw(
+ ${exec_prefix}/sbin/pure-ftpd
+ /usr/local/pure-ftpd/sbin/pure-ftpd
+ /usr/local/pureftpd/sbin/pure-ftpd
+ /usr/local/sbin/pure-ftpd
+ /usr/sbin/pure-ftpd
+);
+
+my %simple_switch_for = (
+ IPV4Only => "-4",
+ IPV6Only => "-6",
+ ChrootEveryone => "-A",
+ BrokenClientsCompatibility => "-b",
+ Daemonize => "-B",
+ VerboseLog => "-d",
+ DisplayDotFiles => "-D",
+ AnonymousOnly => "-e",
+ NoAnonymous => "-E",
+ DontResolve => "-H",
+ AnonymousCanCreateDirs => "-M",
+ NATmode => "-N",
+ CallUploadScript => "-o",
+ AntiWarez => "-s",
+ AllowUserFXP => "-w",
+ AllowAnonymousFXP => "-W",
+ ProhibitDotFilesWrite => "-x",
+ ProhibitDotFilesRead => "-X",
+ AllowDotFiles => "-z",
+ AutoRename => "-r",
+ AnonymousCantUpload => "-i",
+ LogPID => "-1",
+ NoChmod => "-R",
+ KeepAllFiles => "-K",
+ CreateHomeDir => "-j",
+ NoRename => "-G",
+ CustomerProof => "-Z",
+ NoTruncate => "-0",
+);
+
+my %string_switch_for = (
+ FileSystemCharset => "-8",
+ ClientCharset => "-9",
+ SyslogFacility => "-f",
+ FortunesFile => "-F",
+ ForcePassiveIP => "-P",
+ Bind => "-S",
+ AnonymousBandwidth => "-t",
+ UserBandwidth => "-T",
+ TrustedIP => "-V",
+ AltLog => "-O",
+ PIDFile => "-g",
+ TLSCipherSuite => "-J",
+ CertFile => "-2",
+);
+
+my %numeric_switch_for = (
+ MaxIdleTime => "-I",
+ MaxDiskUsage => "-k",
+ TrustedGID => "-a",
+ MaxClientsNumber => "-c",
+ MaxClientsPerIP => "-C",
+ MaxLoad => "-m",
+ MinUID => "-u",
+ TLS => "-Y",
+);
+
+my %numpairb_switch_for = (
+ LimitRecursion => "-L",
+ PassivePortRange => "-p",
+ AnonymousRatio => "-q",
+ UserRatio => "-Q",
+);
+
+my %numpairc_switch_for = (
+ Umask => "-U",
+ Quota => "-n",
+ PerUserLimits => "-y",
+);
+
+my %auth_method_for = (
+ LDAPConfigFile => "ldap",
+ MySQLConfigFile => "mysql",
+ PGSQLConfigFile => "pgsql",
+ PureDB => "puredb",
+ ExtAuth => "extauth",
+);
+
+my $simple_switch = qr/(@{[join "|", keys %simple_switch_for ]})\s+yes/i;
+my $string_switch = qr/(@{[join "|", keys %string_switch_for ]})\s+(\S+)/i;
+my $numeric_switch = qr/(@{[join "|", keys %numeric_switch_for ]})\s+(\d+)/i;
+my $numpairb_switch = qr/(@{[join "|", keys %numpairb_switch_for ]})\s+(\d+)\s+(\d+)/i;
+my $numpairc_switch = qr/(@{[join "|", keys %numpairc_switch_for ]})\s+(\d+):(\d+)/i;
+my $auth_method = qr/(@{[join "|", keys %auth_method_for ]})\s+(\S+)/i;
+
+die "Usage: pure-config.pl <configuration file> [extra options]\n"
+ unless defined $conffile;
+
+open CONF, "< $conffile" or die "Can't open $conffile: $!\n";
+
+!/^\s*(?:$|#)/ and (chomp, push @flg,
+ /$simple_switch/i ? ($simple_switch_for{$1}) :
+ /$string_switch/i ? ($string_switch_for{$1} . $2) :
+ /$numeric_switch/i ? ($numeric_switch_for{$1} . $2) :
+ /$numpairb_switch/i ? ($numpairb_switch_for{$1} . "$2:$3") :
+ /$numpairc_switch/i ? ($numpairc_switch_for{$1} . "$2:$3") :
+ /$auth_method/i ? ("-l" . "$auth_method_for{$1}:$2") :
+ /UnixAuthentication\s+yes/i ? ("-l" . "unix") :
+ /PAMAuthentication\s+yes/i ? ("-l" . "pam") :
+ ()
+) while <CONF>;
+
+close CONF;
+
+if (-t STDOUT) {
+ print "Running: $PUREFTPD ", join(" ", @flg), "\n";
+}
+exec { $PUREFTPD } ($PUREFTPD, @flg) or die "cannot exec $PUREFTPD: $!";
diff -ruN pure-ftpd-1.0.49/configuration-file/pure-config.py.in pure-ftpd-1.0.49-new/configuration-file/pure-config.py.in
--- pure-ftpd-1.0.49/configuration-file/pure-config.py.in 1970-01-01 10:00:00.000000000 +1000
+++ pure-ftpd-1.0.49-new/configuration-file/pure-config.py.in 2019-12-27 07:48:25.679000001 +1100
@@ -0,0 +1,188 @@
+#! @PYTHON@
+
+# Original pure-config.py by Frank Denis <j at pureftpd dot org>
+# Copyright 2001 by Joshua Rodman <joshua_rodman at yahoo dot com>,
+# Modifications Copyright 2001-2009 by Matthias Andree
+#
+# All Rights Reserved
+#
+# Permission to use, copy, modify, and distribute this software
+# in original or modified form for any purpose and without fee
+# is hereby granted, provided that the above copyright notice
+# appear in all copies.
+#
+# Joshua Rodman DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS, IN NO EVENT SHALL Joshua Rodman BE LIABLE FOR
+# ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+"""Pure-FTPd configuration parser.
+
+ Parse pure-ftpd configuration file to options.
+ If run directly, execute the program.
+
+"""
+import re
+import os
+import sys
+
+# autoconf stuff
+if '@sbindir@'[0] == '/':
+ pureftpd = '@sbindir@/pure-ftpd'
+else:
+ pureftpd = '@prefix@/sbin/pure-ftpd'
+
+argv = sys.argv[1:]
+try:
+ conffile = argv.pop(0)
+except IndexError:
+ print("Usage:", sys.argv[0], "<configuration file> [extra options]")
+ sys.exit(1)
+
+comment = re.compile("[ ]*#+.*")
+
+# option_tuple members are lists as follows:
+# 0 - case insensitive regex to match
+# 1 - flag to use
+# remaining - 'None' are placeholders for items matched by the regex
+# the matched items and literal strings are concatenated
+# into a literal option which follows the flag
+
+option_tuple = (
+ ["IPV4Only[\s]+yes", "-4" ],
+ ["IPV6Only[\s]+yes", "-6" ],
+ ["FileSystemCharset\s+(\S+)", "-8", None ],
+ ["ClientCharset\s+(\S+)", "-9", None ],
+ ["ChrootEveryone[\s]+yes", "-A" ],
+ ["TrustedGID[\s]+([\d]+)", "-a", None ],
+ ["BrokenClientsCompatibility[\s]+yes", "-b" ],
+ ["MaxClientsNumber\s+(\d+)", "-c", None ],
+ ["Daemonize\s+yes", "-B" ],
+ ["MaxClientsPerIP\s+(\d+)", "-C", None ],
+ ["VerboseLog\s+yes", "-d" ],
+ ["DisplayDotFiles\s+yes", "-D" ],
+ ["AnonymousOnly\s+yes", "-e" ],
+ ["MaxDiskUsage\s+(\d+)", "-k", None ],
+ ["NoAnonymous\s+yes", "-E" ],
+ ["SyslogFacility\s+(\S+)", "-f", None ],
+ ["FortunesFile\s+(\S+)", "-F", None ],
+ ["DontResolve\s+yes", "-H" ],
+ ["MaxIdleTime\s+(\d+)", "-I", None ],
+ ["LDAPConfigFile\s+(\S+)", "-l", "ldap:", None ],
+ ["MySQLConfigFile\s+(\S+)", "-l", "mysql:", None ],
+ ["PGSQLConfigFile\s+(\S+)", "-l", "pgsql:", None ],
+ ["PureDB\s+(\S+)", "-l", "puredb:", None ],
+ ["ExtAuth\s+(\S+)", "-l", "extauth:",None ],
+ ["PAMAuthentication\s+yes", "-l", "pam" ],
+ ["UnixAuthentication\s+yes", "-l", "unix" ],
+ ["LimitRecursion\s+(\d+)\s+(\d+)", "-L", None, ":", None ],
+ ["AnonymousCanCreateDirs\s+yes", "-M" ],
+ ["MaxLoad\s+(\d+)", "-m", None ],
+ ["NATmode\s+yes", "-N" ],
+ ["CallUploadScript\s+yes", "-o" ],
+ ["PassivePortRange\s+(\d+)\s+(\d+)", "-p", None, ":", None ],
+ ["ForcePassiveIP\s+(\S+)", "-P", None ],
+ ["AnonymousRatio\s+(\d+)\s+(\d+)", "-q", None, ":", None ],
+ ["UserRatio\s+(\d+)\s+(\d+)", "-Q", None, ":", None ],
+ ["AntiWarez\s+yes", "-s" ],
+ ["Bind\s+(\S+)", "-S", None ],
+ ["AnonymousBandwidth\s+([:0-9]+)", "-t", None ],
+ ["UserBandwidth\s+([:0-9]+)", "-T", None ],
+ ["Quota\s+([:0-9]+)", "-n", None ],
+ ["Umask\s+(\d+):(\d+)", "-U", None, ":", None ],
+ ["MinUID\s+(\d+)", "-u", None ],
+ ["AllowUserFXP\s+yes", "-w" ],
+ ["AllowAnonymousFXP\s+yes", "-W" ],
+ ["ProhibitDotFilesWrite\s+yes", "-x" ],
+ ["ProhibitDotFilesRead\s+yes", "-X" ],
+ ["AllowDotFiles\s+yes", "-z" ],
+ ["AutoRename\s+yes", "-r" ],
+ ["AnonymousCantUpload\s+yes", "-i" ],
+ ["TrustedIP\s+(\S+)", "-V", None ],
+ ["LogPID\s+yes", "-1" ],
+ ["AltLog\s+(\S+)", "-O", None ],
+ ["NoChmod\s+yes", "-R" ],
+ ["KeepAllFiles\s+yes", "-K" ],
+ ["CreateHomeDir\s+yes", "-j" ],
+ ["NoRename\s+yes", "-G" ],
+ ["CustomerProof\s+yes", "-Z" ],
+ ["NoTruncate\s+yes", "-0" ],
+ ["PIDFile\s+(\S+)", "-g", None ],
+ ["TLSCipherSuite\s+(\S+)", "-J", None ],
+ ["PerUserLimits\s+([:0-9]+)", "-y", None ],
+ ["CertFile\s+(\S+)", "-2", None ],
+ ["TLS\s+(\d)", "-Y", None ])
+
+for option in option_tuple:
+ option[0] = re.compile(option[0], re.IGNORECASE)
+
+
+def build_argument(match, controls):
+ """construct an argument string
+ match: a match object containing argument values
+ controls: a list controlling the format of the argument
+
+ Return parameter as string"""
+
+ argument = ""
+ value = 1
+
+ for control in controls:
+ if control:
+ # concat the literal string
+ argument = argument + control
+ else:
+ # concat a value
+ argument = argument + match.group(value)
+ value = value + 1
+
+ return argument
+
+
+def parse(file_obj):
+ """parse/extract a pure-ftpd configuration
+ file_obj: a readlines() capable object containing the configurion
+
+ Returns list of arguments as appropriate for exec()"""
+
+ args = [pureftpd]
+
+ for line in file_obj.readlines():
+ if comment.search(line):
+ continue
+
+ for option in option_tuple:
+ match = option[0].search(line)
+ if match:
+ args.append(option[1])
+
+ if len(option) <= 2:
+ # The option takes no argument
+ continue
+
+ argument = build_argument(match, option[2:])
+ args.append(argument)
+
+ return args
+
+
+def parse_filename(filename=conffile):
+ """parse/extract a pure-ftpd from a named file
+ filename: text path to file
+
+ Returns list of arguments as appropriate for exec()"""
+
+ file_obj = open(filename)
+ return parse(file_obj)
+
+if __name__ == '__main__':
+ args = parse_filename()
+
+ if os.isatty(1):
+ print("Running:", args + argv)
+
+ os.execv(pureftpd, args + argv)
diff -ruN pure-ftpd-1.0.49/configure.ac pure-ftpd-1.0.49-new/configure.ac
--- pure-ftpd-1.0.49/configure.ac 2019-04-03 21:41:30.000000000 +1100
+++ pure-ftpd-1.0.49-new/configure.ac 2019-12-27 07:53:06.555000491 +1100
@@ -96,6 +96,18 @@
AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"])
+AC_ARG_VAR(PERL,local path to the perl interpreter)
+perl_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/perl/bin:/opt/perl/usr/bin:/opt/perl/usr/local/bin"
+AC_PATH_PROG(PERL,perl,/usr/bin/env perl,$perl_possible_path)
+
+AC_ARG_VAR(PYTHON,local path to the python interpreter)
+python_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/python/bin:/opt/python/usr/bin:/opt/python/usr/local/bin"
+AC_PATH_PROG(PYTHON,python,/usr/bin/env python,$python_possible_path)
+
+if test -d /usr/local/include; then
+ CPPFLAGS="$CPPFLAGS -I/usr/local/include"
+fi
+
if test "x$cross_compiling" != "xyes"; then
for path in \
/usr/kerberos \
@@ -1465,6 +1477,9 @@
AC_CONFIG_FILES(Makefile src/Makefile pam/Makefile man/Makefile
gui/Makefile m4/Makefile pure-ftpd.conf puredb/Makefile
puredb/src/Makefile
+configuration-file/Makefile
+configuration-file/pure-config.pl
+configuration-file/pure-config.py
man/pure-ftpd.8 man/pure-ftpwho.8 man/pure-mrtginfo.8 man/pure-uploadscript.8
man/pure-statsdecode.8 man/pure-quotacheck.8 man/pure-pw.8 man/pure-pwconvert.8
man/pure-authd.8 man/pure-certd.8)
diff -ruN pure-ftpd-1.0.49/Makefile.am pure-ftpd-1.0.49-new/Makefile.am
--- pure-ftpd-1.0.49/Makefile.am 2019-03-26 05:04:04.000000000 +1100
+++ pure-ftpd-1.0.49-new/Makefile.am 2019-12-27 07:48:25.675999998 +1100
@@ -43,6 +43,7 @@
man \
pam \
gui \
+ configuration-file \
m4
install-data-local:
diff -ruN pure-ftpd-1.0.49/pam/pure-ftpd pure-ftpd-1.0.49-new/pam/pure-ftpd
--- pure-ftpd-1.0.49/pam/pure-ftpd 2018-01-04 23:13:36.000000000 +1100
+++ pure-ftpd-1.0.49-new/pam/pure-ftpd 2019-12-27 07:47:49.249000002 +1100
@@ -4,12 +4,13 @@
# Install it in /etc/pam.d/pure-ftpd or add to /etc/pam.conf
auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
+auth include password-auth
auth required pam_shells.so
auth required pam_nologin.so
-account required pam_stack.so service=system-auth
+account include password-auth
-password required pam_stack.so service=system-auth
-
-session required pam_stack.so service=system-auth
+password include password-auth
+session required pam_loginuid.so
+session include password-auth
diff -ruN pure-ftpd-1.0.49/pure-ftpd.conf.in pure-ftpd-1.0.49-new/pure-ftpd.conf.in
--- pure-ftpd-1.0.49/pure-ftpd.conf.in 2019-03-26 02:48:42.000000000 +1100
+++ pure-ftpd-1.0.49-new/pure-ftpd.conf.in 2019-12-27 07:48:08.410000001 +1100
@@ -9,7 +9,7 @@
# instead of command-line options, please run the
# following command :
#
-# @sbindir@/sbin/pure-ftpd @sysconfdir@/pure-ftpd.conf
+# @sbindir@/pure-ftpd @sysconfdir@/pure-ftpd.conf
#
# Online documentation:
# https://www.pureftpd.org/project/pure-ftpd/doc
@@ -42,7 +42,7 @@
# Run as a background process
-
+# Important: this must be set to 'yes' for the systemd service to work.
Daemonize yes
@@ -106,34 +106,34 @@
# LDAP configuration file (see README.LDAP)
-# LDAPConfigFile /etc/pureftpd-ldap.conf
+# LDAPConfigFile @sysconfigdir@/pureftpd-ldap.conf
# MySQL configuration file (see README.MySQL)
-# MySQLConfigFile /etc/pureftpd-mysql.conf
+# MySQLConfigFile @sysconfigdir@/pureftpd-mysql.conf
# PostgreSQL configuration file (see README.PGSQL)
-# PGSQLConfigFile /etc/pureftpd-pgsql.conf
+# PGSQLConfigFile @sysconfigdir@/pureftpd-pgsql.conf
# PureDB user database (see README.Virtual-Users)
-# PureDB /etc/pureftpd.pdb
+# PureDB @sysconfigdir@/pureftpd.pdb
# Path to pure-authd socket (see README.Authentication-Modules)
-# ExtAuth /var/run/ftpd.sock
+# ExtAuth @localstatedir@/run/ftpd.sock
# If you want to enable PAM authentication, uncomment the following line
-# PAMAuthentication yes
+PAMAuthentication yes
@@ -238,8 +238,7 @@
# For example, a value of 100 prevents all users whose user id is below
# 100 from logging in. If you want "root" to be able to log in, use 0.
-MinUID 100
-
+MinUID 1000
# Allow FXP transfers for authenticated users.
@@ -277,7 +276,7 @@
# Prevent anonymous users from uploading new files (no = upload is allowed)
-AnonymousCantUpload no
+AnonymousCantUpload yes
@@ -301,21 +300,21 @@
# fw.c9x.org - jedi [13/Apr/2017:19:36:39] "GET /ftp/linux.tar.bz2" 200 21809338
# This log file can then be processed by common HTTP traffic analyzers.
-# AltLog clf:/var/log/pureftpd.log
+AltLog clf:@localstatedir@/log/pureftpd.log
# Create an additional log file with transfers logged in a format optimized
# for statistic reports.
-# AltLog stats:/var/log/pureftpd.log
+# AltLog stats:@localstatedir@/log/pureftpd.log
# Create an additional log file with transfers logged in the standard W3C
# format (compatible with many HTTP log analyzers)
-# AltLog w3c:/var/log/pureftpd.log
+# AltLog w3c:@localstatedir@/log/pureftpd.log
@@ -346,9 +345,9 @@
# If your pure-ftpd has been compiled with standalone support, you can change
-# the location of the pid file. The default is /var/run/pure-ftpd.pid
+# the location of the pid file. The default is @localstatedir@/run/pure-ftpd.pid
-# PIDFile /var/run/pure-ftpd.pid
+#PIDFile @localstatedir@/run/pure-ftpd.pid