mirror.py-rsync-server 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mirror_py_rsync_server-1.0.0/LICENSE +201 -0
- mirror_py_rsync_server-1.0.0/PKG-INFO +200 -0
- mirror_py_rsync_server-1.0.0/README.md +188 -0
- mirror_py_rsync_server-1.0.0/mirror.py_rsync_server.egg-info/PKG-INFO +200 -0
- mirror_py_rsync_server-1.0.0/mirror.py_rsync_server.egg-info/SOURCES.txt +11 -0
- mirror_py_rsync_server-1.0.0/mirror.py_rsync_server.egg-info/dependency_links.txt +1 -0
- mirror_py_rsync_server-1.0.0/mirror.py_rsync_server.egg-info/entry_points.txt +2 -0
- mirror_py_rsync_server-1.0.0/mirror.py_rsync_server.egg-info/requires.txt +1 -0
- mirror_py_rsync_server-1.0.0/mirror.py_rsync_server.egg-info/top_level.txt +1 -0
- mirror_py_rsync_server-1.0.0/mirror_plugin_rsync_server/__init__.py +709 -0
- mirror_py_rsync_server-1.0.0/pyproject.toml +23 -0
- mirror_py_rsync_server-1.0.0/setup.cfg +4 -0
- mirror_py_rsync_server-1.0.0/tests/test_rsync_server.py +950 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mirror.py-rsync-server
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: mirror.py event plug-in that generates rsyncd.conf and rsyncd.secrets from the package list.
|
|
5
|
+
Author: SPARCS KAIST
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: mirror.py>=1.0.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# mirror.py rsync-server plugin
|
|
14
|
+
|
|
15
|
+
An event plugin for [mirror.py](https://github.com/sparcs-kaist/mirror.py) that generates
|
|
16
|
+
`rsyncd.conf` and `rsyncd.secrets` from the live mirror package list plus a sidecar
|
|
17
|
+
`rsync.json` configuration file. The plugin regenerates both files automatically when the
|
|
18
|
+
mirror daemon starts (`MASTER.INIT.POST`) and whenever the package set changes via
|
|
19
|
+
`mirror config reload` (`MASTER.CONFIG_RELOAD.POST`).
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## How it works
|
|
23
|
+
|
|
24
|
+
The plugin listens on two mirror.py events:
|
|
25
|
+
|
|
26
|
+
- `MASTER.INIT.POST` — fires once when the master daemon finishes starting up.
|
|
27
|
+
- `MASTER.CONFIG_RELOAD.POST` — fires after `mirror config reload` has loaded a new
|
|
28
|
+
configuration. Until the mirror.py core ships this event, regeneration happens at
|
|
29
|
+
daemon start only; the listener signature accepts `(*args, **kwargs)` so it is
|
|
30
|
+
forward-compatible.
|
|
31
|
+
|
|
32
|
+
**File generation only.** The plugin writes `rsyncd.conf` and `rsyncd.secrets`; it does
|
|
33
|
+
not start, stop, or signal the rsyncd process. This is intentional: rsyncd re-reads
|
|
34
|
+
`rsyncd.conf` and the secrets file on every incoming client connection, so adding or
|
|
35
|
+
removing mirror modules takes effect immediately with no reload signal needed.
|
|
36
|
+
|
|
37
|
+
Writes are atomic (via a temporary file in the same directory followed by `os.replace`).
|
|
38
|
+
If the generated content is identical to what is already on disk, the file is not
|
|
39
|
+
rewritten. Regeneration runs under a module-level lock so concurrent event firings do not
|
|
40
|
+
race.
|
|
41
|
+
|
|
42
|
+
Packages with `settings.hidden: true` are completely excluded — they appear in neither
|
|
43
|
+
the public nor the private module list.
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
Install the plugin into the same Python environment as mirror.py:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Enable the plugin in mirror.py's `config.json`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
"plugins": { "rsync-server": { "enabled": true } }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The plugin's own settings live in `rsync.json`, **not** in the `plugins` block of
|
|
61
|
+
`config.json`. See the Configuration section below.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
`rsync.json` must live in the same directory as mirror.py's `config.json` (default path:
|
|
67
|
+
`/etc/mirror/rsync.json`).
|
|
68
|
+
|
|
69
|
+
See [`rsync.json.example`](rsync.json.example) for a complete, realistic example.
|
|
70
|
+
|
|
71
|
+
All keys are optional and fall back to the defaults listed below.
|
|
72
|
+
|
|
73
|
+
| Key | Type | Default | Description |
|
|
74
|
+
|-----|------|---------|-------------|
|
|
75
|
+
| `rsyncd_conf` | string (absolute path) | `/etc/rsyncd.conf` | Destination path for the generated `rsyncd.conf`. |
|
|
76
|
+
| `secrets_file` | string (absolute path) | `/etc/rsyncd.secrets` | Destination path for the generated secrets file. Also emitted as `secrets file` in the global section of `rsyncd.conf`. |
|
|
77
|
+
| `users` | object | `{}` | Map of `username` to `password`. Written to the secrets file in insertion order. |
|
|
78
|
+
| `global` | object | `{}` | Raw rsyncd parameter passthrough. Keys and values are emitted in insertion order as `key = value` lines in the global section. Values may be strings, integers, or booleans (booleans render as `true`/`false`). The key `secrets file` is managed by the plugin and is rejected if placed here. |
|
|
79
|
+
| `private_modules.enabled` | boolean | `true` | When `false`, no `[.Name]` private module sections are generated. |
|
|
80
|
+
| `private_modules.auth_users` | string | `*` | Value written to `auth users` in every private module section. |
|
|
81
|
+
| `private_modules.list` | boolean | `false` | Value written to `list` in every private module section. |
|
|
82
|
+
| `private_modules.lock_file` | string (absolute path) | `/var/run/rsyncd-private.lock` | Value written to `lock file` in every private module section. The private modules share this lock file, giving them a separate max-connections accounting pool independent of the public modules. |
|
|
83
|
+
|
|
84
|
+
Unknown top-level keys and unknown `private_modules` keys are rejected with a `ValueError`
|
|
85
|
+
at load time (typo protection). Any validation failure leaves previously generated files
|
|
86
|
+
untouched.
|
|
87
|
+
|
|
88
|
+
**SECURITY NOTE:** `rsync.json` contains plaintext passwords. Restrict its permissions:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
chmod 600 /etc/mirror/rsync.json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The plugin logs a warning if `rsync.json` is group- or other-readable. The generated
|
|
95
|
+
`rsyncd.secrets` file is always written with mode `0600`, as required by rsyncd's strict
|
|
96
|
+
modes.
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## Generated output
|
|
100
|
+
|
|
101
|
+
Given a package named `ArchLinux` with `src = rsync://rsync.archlinux.org/ftp_tier1` and
|
|
102
|
+
`dst = /mirror/ftp/ArchLinux`, and the global settings from `rsync.json.example`, the
|
|
103
|
+
plugin produces:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
# WARNING: DO NOT EDIT!! Generated by the mirror.py rsync-server plugin.
|
|
107
|
+
uid = rsync
|
|
108
|
+
gid = nogroup
|
|
109
|
+
use chroot = no
|
|
110
|
+
max connections = 20
|
|
111
|
+
motd file = /mirror/etc/motd
|
|
112
|
+
log file = /var/log/geoul/rsyncd/all.log
|
|
113
|
+
transfer logging = yes
|
|
114
|
+
log format = %o %a - %u [%t] "%P/%f" - %l
|
|
115
|
+
pid file = /var/run/rsyncd.pid
|
|
116
|
+
exclude = .~tmp~
|
|
117
|
+
|
|
118
|
+
secrets file = /mirror/etc/rsyncd.secrets
|
|
119
|
+
|
|
120
|
+
[ArchLinux]
|
|
121
|
+
path = /mirror/ftp/ArchLinux
|
|
122
|
+
comment = from rsync://rsync.archlinux.org/ftp_tier1
|
|
123
|
+
|
|
124
|
+
[.ArchLinux]
|
|
125
|
+
path = /mirror/ftp/ArchLinux
|
|
126
|
+
comment = private module for ArchLinux without connection limits for authorized mirrors
|
|
127
|
+
auth users = *
|
|
128
|
+
list = false
|
|
129
|
+
lock file = /var/run/rsyncd-private.lock
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Each package produces a public/private module pair:
|
|
133
|
+
|
|
134
|
+
- `[Name]` is the public module. It is visible in `rsync host::` listings and carries a
|
|
135
|
+
`comment = from <upstream src>` line. The comment line is omitted when a package has
|
|
136
|
+
no upstream `src` (for example, locally synced packages).
|
|
137
|
+
- `[.Name]` is the authenticated, unlisted private twin. The leading dot hides it from
|
|
138
|
+
`rsync host::` listings. Access is gated by `auth users` and the secrets file. This
|
|
139
|
+
module has its own lock file, so its connection accounting is independent of the public
|
|
140
|
+
module's `max connections` limit.
|
|
141
|
+
|
|
142
|
+
Modules are sorted by package name. The static header contains no timestamp so that
|
|
143
|
+
identical content is detected and the file is not rewritten unnecessarily.
|
|
144
|
+
|
|
145
|
+
The secrets file (`rsyncd.secrets`) contains one `username:password` line per entry in
|
|
146
|
+
`users`, written in insertion order, with no header line.
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
## Running rsyncd
|
|
150
|
+
|
|
151
|
+
Point rsyncd at the generated configuration file:
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
rsync --daemon --config=/etc/rsyncd.conf
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## Operational notes
|
|
159
|
+
|
|
160
|
+
**Changing users or rsync settings.** Edit `rsync.json`, then run:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
mirror config reload
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
No daemon restart is needed for module or authentication changes. rsyncd picks up the
|
|
167
|
+
new `rsyncd.conf` and `rsyncd.secrets` on the next incoming client connection.
|
|
168
|
+
|
|
169
|
+
**Parameters that require an rsyncd restart.** Daemon-socket parameters such as `port`,
|
|
170
|
+
`address`, and `pid file` are read by rsyncd only at startup. Changing them in `rsync.json`
|
|
171
|
+
and running `mirror config reload` will update the generated file, but rsyncd itself must
|
|
172
|
+
be restarted for these to take effect. Module-level parameters (path, auth, comment, etc.)
|
|
173
|
+
apply per connection and do not require a restart.
|
|
174
|
+
|
|
175
|
+
**Private module connection accounting.** The private modules share the lock file
|
|
176
|
+
specified by `private_modules.lock_file`. This gives them a separate max-connections pool
|
|
177
|
+
rather than unlimited connections — the pool size is controlled by rsyncd's global
|
|
178
|
+
`max connections` parameter applied against that lock file independently from the public
|
|
179
|
+
modules' lock file.
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
Set up a virtual environment and install the plugin alongside mirror.py:
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
uv venv
|
|
188
|
+
uv pip install -e /path/to/mirror.py -e . pytest
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Run the test suite:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
uv run pytest
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
Apache-2.0
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# mirror.py rsync-server plugin
|
|
2
|
+
|
|
3
|
+
An event plugin for [mirror.py](https://github.com/sparcs-kaist/mirror.py) that generates
|
|
4
|
+
`rsyncd.conf` and `rsyncd.secrets` from the live mirror package list plus a sidecar
|
|
5
|
+
`rsync.json` configuration file. The plugin regenerates both files automatically when the
|
|
6
|
+
mirror daemon starts (`MASTER.INIT.POST`) and whenever the package set changes via
|
|
7
|
+
`mirror config reload` (`MASTER.CONFIG_RELOAD.POST`).
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## How it works
|
|
11
|
+
|
|
12
|
+
The plugin listens on two mirror.py events:
|
|
13
|
+
|
|
14
|
+
- `MASTER.INIT.POST` — fires once when the master daemon finishes starting up.
|
|
15
|
+
- `MASTER.CONFIG_RELOAD.POST` — fires after `mirror config reload` has loaded a new
|
|
16
|
+
configuration. Until the mirror.py core ships this event, regeneration happens at
|
|
17
|
+
daemon start only; the listener signature accepts `(*args, **kwargs)` so it is
|
|
18
|
+
forward-compatible.
|
|
19
|
+
|
|
20
|
+
**File generation only.** The plugin writes `rsyncd.conf` and `rsyncd.secrets`; it does
|
|
21
|
+
not start, stop, or signal the rsyncd process. This is intentional: rsyncd re-reads
|
|
22
|
+
`rsyncd.conf` and the secrets file on every incoming client connection, so adding or
|
|
23
|
+
removing mirror modules takes effect immediately with no reload signal needed.
|
|
24
|
+
|
|
25
|
+
Writes are atomic (via a temporary file in the same directory followed by `os.replace`).
|
|
26
|
+
If the generated content is identical to what is already on disk, the file is not
|
|
27
|
+
rewritten. Regeneration runs under a module-level lock so concurrent event firings do not
|
|
28
|
+
race.
|
|
29
|
+
|
|
30
|
+
Packages with `settings.hidden: true` are completely excluded — they appear in neither
|
|
31
|
+
the public nor the private module list.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Install the plugin into the same Python environment as mirror.py:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Enable the plugin in mirror.py's `config.json`:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
"plugins": { "rsync-server": { "enabled": true } }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The plugin's own settings live in `rsync.json`, **not** in the `plugins` block of
|
|
49
|
+
`config.json`. See the Configuration section below.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Configuration
|
|
53
|
+
|
|
54
|
+
`rsync.json` must live in the same directory as mirror.py's `config.json` (default path:
|
|
55
|
+
`/etc/mirror/rsync.json`).
|
|
56
|
+
|
|
57
|
+
See [`rsync.json.example`](rsync.json.example) for a complete, realistic example.
|
|
58
|
+
|
|
59
|
+
All keys are optional and fall back to the defaults listed below.
|
|
60
|
+
|
|
61
|
+
| Key | Type | Default | Description |
|
|
62
|
+
|-----|------|---------|-------------|
|
|
63
|
+
| `rsyncd_conf` | string (absolute path) | `/etc/rsyncd.conf` | Destination path for the generated `rsyncd.conf`. |
|
|
64
|
+
| `secrets_file` | string (absolute path) | `/etc/rsyncd.secrets` | Destination path for the generated secrets file. Also emitted as `secrets file` in the global section of `rsyncd.conf`. |
|
|
65
|
+
| `users` | object | `{}` | Map of `username` to `password`. Written to the secrets file in insertion order. |
|
|
66
|
+
| `global` | object | `{}` | Raw rsyncd parameter passthrough. Keys and values are emitted in insertion order as `key = value` lines in the global section. Values may be strings, integers, or booleans (booleans render as `true`/`false`). The key `secrets file` is managed by the plugin and is rejected if placed here. |
|
|
67
|
+
| `private_modules.enabled` | boolean | `true` | When `false`, no `[.Name]` private module sections are generated. |
|
|
68
|
+
| `private_modules.auth_users` | string | `*` | Value written to `auth users` in every private module section. |
|
|
69
|
+
| `private_modules.list` | boolean | `false` | Value written to `list` in every private module section. |
|
|
70
|
+
| `private_modules.lock_file` | string (absolute path) | `/var/run/rsyncd-private.lock` | Value written to `lock file` in every private module section. The private modules share this lock file, giving them a separate max-connections accounting pool independent of the public modules. |
|
|
71
|
+
|
|
72
|
+
Unknown top-level keys and unknown `private_modules` keys are rejected with a `ValueError`
|
|
73
|
+
at load time (typo protection). Any validation failure leaves previously generated files
|
|
74
|
+
untouched.
|
|
75
|
+
|
|
76
|
+
**SECURITY NOTE:** `rsync.json` contains plaintext passwords. Restrict its permissions:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
chmod 600 /etc/mirror/rsync.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The plugin logs a warning if `rsync.json` is group- or other-readable. The generated
|
|
83
|
+
`rsyncd.secrets` file is always written with mode `0600`, as required by rsyncd's strict
|
|
84
|
+
modes.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## Generated output
|
|
88
|
+
|
|
89
|
+
Given a package named `ArchLinux` with `src = rsync://rsync.archlinux.org/ftp_tier1` and
|
|
90
|
+
`dst = /mirror/ftp/ArchLinux`, and the global settings from `rsync.json.example`, the
|
|
91
|
+
plugin produces:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
# WARNING: DO NOT EDIT!! Generated by the mirror.py rsync-server plugin.
|
|
95
|
+
uid = rsync
|
|
96
|
+
gid = nogroup
|
|
97
|
+
use chroot = no
|
|
98
|
+
max connections = 20
|
|
99
|
+
motd file = /mirror/etc/motd
|
|
100
|
+
log file = /var/log/geoul/rsyncd/all.log
|
|
101
|
+
transfer logging = yes
|
|
102
|
+
log format = %o %a - %u [%t] "%P/%f" - %l
|
|
103
|
+
pid file = /var/run/rsyncd.pid
|
|
104
|
+
exclude = .~tmp~
|
|
105
|
+
|
|
106
|
+
secrets file = /mirror/etc/rsyncd.secrets
|
|
107
|
+
|
|
108
|
+
[ArchLinux]
|
|
109
|
+
path = /mirror/ftp/ArchLinux
|
|
110
|
+
comment = from rsync://rsync.archlinux.org/ftp_tier1
|
|
111
|
+
|
|
112
|
+
[.ArchLinux]
|
|
113
|
+
path = /mirror/ftp/ArchLinux
|
|
114
|
+
comment = private module for ArchLinux without connection limits for authorized mirrors
|
|
115
|
+
auth users = *
|
|
116
|
+
list = false
|
|
117
|
+
lock file = /var/run/rsyncd-private.lock
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Each package produces a public/private module pair:
|
|
121
|
+
|
|
122
|
+
- `[Name]` is the public module. It is visible in `rsync host::` listings and carries a
|
|
123
|
+
`comment = from <upstream src>` line. The comment line is omitted when a package has
|
|
124
|
+
no upstream `src` (for example, locally synced packages).
|
|
125
|
+
- `[.Name]` is the authenticated, unlisted private twin. The leading dot hides it from
|
|
126
|
+
`rsync host::` listings. Access is gated by `auth users` and the secrets file. This
|
|
127
|
+
module has its own lock file, so its connection accounting is independent of the public
|
|
128
|
+
module's `max connections` limit.
|
|
129
|
+
|
|
130
|
+
Modules are sorted by package name. The static header contains no timestamp so that
|
|
131
|
+
identical content is detected and the file is not rewritten unnecessarily.
|
|
132
|
+
|
|
133
|
+
The secrets file (`rsyncd.secrets`) contains one `username:password` line per entry in
|
|
134
|
+
`users`, written in insertion order, with no header line.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## Running rsyncd
|
|
138
|
+
|
|
139
|
+
Point rsyncd at the generated configuration file:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
rsync --daemon --config=/etc/rsyncd.conf
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Operational notes
|
|
147
|
+
|
|
148
|
+
**Changing users or rsync settings.** Edit `rsync.json`, then run:
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
mirror config reload
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
No daemon restart is needed for module or authentication changes. rsyncd picks up the
|
|
155
|
+
new `rsyncd.conf` and `rsyncd.secrets` on the next incoming client connection.
|
|
156
|
+
|
|
157
|
+
**Parameters that require an rsyncd restart.** Daemon-socket parameters such as `port`,
|
|
158
|
+
`address`, and `pid file` are read by rsyncd only at startup. Changing them in `rsync.json`
|
|
159
|
+
and running `mirror config reload` will update the generated file, but rsyncd itself must
|
|
160
|
+
be restarted for these to take effect. Module-level parameters (path, auth, comment, etc.)
|
|
161
|
+
apply per connection and do not require a restart.
|
|
162
|
+
|
|
163
|
+
**Private module connection accounting.** The private modules share the lock file
|
|
164
|
+
specified by `private_modules.lock_file`. This gives them a separate max-connections pool
|
|
165
|
+
rather than unlimited connections — the pool size is controlled by rsyncd's global
|
|
166
|
+
`max connections` parameter applied against that lock file independently from the public
|
|
167
|
+
modules' lock file.
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## Development
|
|
171
|
+
|
|
172
|
+
Set up a virtual environment and install the plugin alongside mirror.py:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
uv venv
|
|
176
|
+
uv pip install -e /path/to/mirror.py -e . pytest
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Run the test suite:
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
uv run pytest
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
Apache-2.0
|