pathrs 0.1.1__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.
- pathrs-0.1.1/COPYING.APACHE-2.0 +208 -0
- pathrs-0.1.1/PKG-INFO +231 -0
- pathrs-0.1.1/pathrs/__init__.py +21 -0
- pathrs-0.1.1/pathrs/_pathrs.py +391 -0
- pathrs-0.1.1/pathrs/pathrs_build.py +133 -0
- pathrs-0.1.1/pathrs.egg-info/PKG-INFO +231 -0
- pathrs-0.1.1/pathrs.egg-info/SOURCES.txt +11 -0
- pathrs-0.1.1/pathrs.egg-info/dependency_links.txt +1 -0
- pathrs-0.1.1/pathrs.egg-info/requires.txt +1 -0
- pathrs-0.1.1/pathrs.egg-info/top_level.txt +2 -0
- pathrs-0.1.1/pyproject.toml +59 -0
- pathrs-0.1.1/setup.cfg +4 -0
- pathrs-0.1.1/setup.py +44 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
NOTE: This license only applies to contrib/bindings and no other components of
|
|
2
|
+
libpathrs. Since these bindings are fairly trivial wrappers around the
|
|
3
|
+
shared library API of libpathrs, they aren't covered by the LGPL's
|
|
4
|
+
copyleft.
|
|
5
|
+
|
|
6
|
+
===============================================================================
|
|
7
|
+
|
|
8
|
+
Apache License
|
|
9
|
+
Version 2.0, January 2004
|
|
10
|
+
http://www.apache.org/licenses/
|
|
11
|
+
|
|
12
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
13
|
+
|
|
14
|
+
1. Definitions.
|
|
15
|
+
|
|
16
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
17
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
18
|
+
|
|
19
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
20
|
+
the copyright owner that is granting the License.
|
|
21
|
+
|
|
22
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
23
|
+
other entities that control, are controlled by, or are under common
|
|
24
|
+
control with that entity. For the purposes of this definition,
|
|
25
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
26
|
+
direction or management of such entity, whether by contract or
|
|
27
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
28
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
29
|
+
|
|
30
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
31
|
+
exercising permissions granted by this License.
|
|
32
|
+
|
|
33
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
34
|
+
including but not limited to software source code, documentation
|
|
35
|
+
source, and configuration files.
|
|
36
|
+
|
|
37
|
+
"Object" form shall mean any form resulting from mechanical
|
|
38
|
+
transformation or translation of a Source form, including but
|
|
39
|
+
not limited to compiled object code, generated documentation,
|
|
40
|
+
and conversions to other media types.
|
|
41
|
+
|
|
42
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
43
|
+
Object form, made available under the License, as indicated by a
|
|
44
|
+
copyright notice that is included in or attached to the work
|
|
45
|
+
(an example is provided in the Appendix below).
|
|
46
|
+
|
|
47
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
48
|
+
form, that is based on (or derived from) the Work and for which the
|
|
49
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
50
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
51
|
+
of this License, Derivative Works shall not include works that remain
|
|
52
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
53
|
+
the Work and Derivative Works thereof.
|
|
54
|
+
|
|
55
|
+
"Contribution" shall mean any work of authorship, including
|
|
56
|
+
the original version of the Work and any modifications or additions
|
|
57
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
58
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
59
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
60
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
61
|
+
means any form of electronic, verbal, or written communication sent
|
|
62
|
+
to the Licensor or its representatives, including but not limited to
|
|
63
|
+
communication on electronic mailing lists, source code control systems,
|
|
64
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
65
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
66
|
+
excluding communication that is conspicuously marked or otherwise
|
|
67
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
68
|
+
|
|
69
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
70
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
71
|
+
subsequently incorporated within the Work.
|
|
72
|
+
|
|
73
|
+
2. Grant of Copyright 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
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
77
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
78
|
+
Work and such Derivative Works in Source or Object form.
|
|
79
|
+
|
|
80
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
81
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
82
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
83
|
+
(except as stated in this section) patent license to make, have made,
|
|
84
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
85
|
+
where such license applies only to those patent claims licensable
|
|
86
|
+
by such Contributor that are necessarily infringed by their
|
|
87
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
88
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
89
|
+
institute patent litigation against any entity (including a
|
|
90
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
91
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
92
|
+
or contributory patent infringement, then any patent licenses
|
|
93
|
+
granted to You under this License for that Work shall terminate
|
|
94
|
+
as of the date such litigation is filed.
|
|
95
|
+
|
|
96
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
97
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
98
|
+
modifications, and in Source or Object form, provided that You
|
|
99
|
+
meet the following conditions:
|
|
100
|
+
|
|
101
|
+
(a) You must give any other recipients of the Work or
|
|
102
|
+
Derivative Works a copy of this License; and
|
|
103
|
+
|
|
104
|
+
(b) You must cause any modified files to carry prominent notices
|
|
105
|
+
stating that You changed the files; and
|
|
106
|
+
|
|
107
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
108
|
+
that You distribute, all copyright, patent, trademark, and
|
|
109
|
+
attribution notices from the Source form of the Work,
|
|
110
|
+
excluding those notices that do not pertain to any part of
|
|
111
|
+
the Derivative Works; and
|
|
112
|
+
|
|
113
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
114
|
+
distribution, then any Derivative Works that You distribute must
|
|
115
|
+
include a readable copy of the attribution notices contained
|
|
116
|
+
within such NOTICE file, excluding those notices that do not
|
|
117
|
+
pertain to any part of the Derivative Works, in at least one
|
|
118
|
+
of the following places: within a NOTICE text file distributed
|
|
119
|
+
as part of the Derivative Works; within the Source form or
|
|
120
|
+
documentation, if provided along with the Derivative Works; or,
|
|
121
|
+
within a display generated by the Derivative Works, if and
|
|
122
|
+
wherever such third-party notices normally appear. The contents
|
|
123
|
+
of the NOTICE file are for informational purposes only and
|
|
124
|
+
do not modify the License. You may add Your own attribution
|
|
125
|
+
notices within Derivative Works that You distribute, alongside
|
|
126
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
127
|
+
that such additional attribution notices cannot be construed
|
|
128
|
+
as modifying the License.
|
|
129
|
+
|
|
130
|
+
You may add Your own copyright statement to Your modifications and
|
|
131
|
+
may provide additional or different license terms and conditions
|
|
132
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
133
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
134
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
135
|
+
the conditions stated in this License.
|
|
136
|
+
|
|
137
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
138
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
139
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
140
|
+
this License, without any additional terms or conditions.
|
|
141
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
142
|
+
the terms of any separate license agreement you may have executed
|
|
143
|
+
with Licensor regarding such Contributions.
|
|
144
|
+
|
|
145
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
146
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
147
|
+
except as required for reasonable and customary use in describing the
|
|
148
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
149
|
+
|
|
150
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
151
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
152
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
153
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
154
|
+
implied, including, without limitation, any warranties or conditions
|
|
155
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
156
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
157
|
+
appropriateness of using or redistributing the Work and assume any
|
|
158
|
+
risks associated with Your exercise of permissions under this License.
|
|
159
|
+
|
|
160
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
161
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
162
|
+
unless required by applicable law (such as deliberate and grossly
|
|
163
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
164
|
+
liable to You for damages, including any direct, indirect, special,
|
|
165
|
+
incidental, or consequential damages of any character arising as a
|
|
166
|
+
result of this License or out of the use or inability to use the
|
|
167
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
168
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
169
|
+
other commercial damages or losses), even if such Contributor
|
|
170
|
+
has been advised of the possibility of such damages.
|
|
171
|
+
|
|
172
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
173
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
174
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
175
|
+
or other liability obligations and/or rights consistent with this
|
|
176
|
+
License. However, in accepting such obligations, You may act only
|
|
177
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
178
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
179
|
+
defend, and hold each Contributor harmless for any liability
|
|
180
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
181
|
+
of your accepting any such warranty or additional liability.
|
|
182
|
+
|
|
183
|
+
END OF TERMS AND CONDITIONS
|
|
184
|
+
|
|
185
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
186
|
+
|
|
187
|
+
To apply the Apache License to your work, attach the following
|
|
188
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
189
|
+
replaced with your own identifying information. (Don't include
|
|
190
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
191
|
+
comment syntax for the file format. We also recommend that a
|
|
192
|
+
file or class name and description of purpose be included on the
|
|
193
|
+
same "printed page" as the copyright notice for easier
|
|
194
|
+
identification within third-party archives.
|
|
195
|
+
|
|
196
|
+
Copyright [yyyy] [name of copyright owner]
|
|
197
|
+
|
|
198
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
199
|
+
you may not use this file except in compliance with the License.
|
|
200
|
+
You may obtain a copy of the License at
|
|
201
|
+
|
|
202
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
203
|
+
|
|
204
|
+
Unless required by applicable law or agreed to in writing, software
|
|
205
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
206
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
207
|
+
See the License for the specific language governing permissions and
|
|
208
|
+
limitations under the License.
|
pathrs-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pathrs
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Python bindings for libpathrs, a safe path resolution library for Linux.
|
|
5
|
+
Author-email: Aleksa Sarai <cyphar@cyphar.com>
|
|
6
|
+
Maintainer-email: Aleksa Sarai <cyphar@cyphar.com>
|
|
7
|
+
License: NOTE: This license only applies to contrib/bindings and no other components of
|
|
8
|
+
libpathrs. Since these bindings are fairly trivial wrappers around the
|
|
9
|
+
shared library API of libpathrs, they aren't covered by the LGPL's
|
|
10
|
+
copyleft.
|
|
11
|
+
|
|
12
|
+
===============================================================================
|
|
13
|
+
|
|
14
|
+
Apache License
|
|
15
|
+
Version 2.0, January 2004
|
|
16
|
+
http://www.apache.org/licenses/
|
|
17
|
+
|
|
18
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
19
|
+
|
|
20
|
+
1. Definitions.
|
|
21
|
+
|
|
22
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
23
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
24
|
+
|
|
25
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
26
|
+
the copyright owner that is granting the License.
|
|
27
|
+
|
|
28
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
29
|
+
other entities that control, are controlled by, or are under common
|
|
30
|
+
control with that entity. For the purposes of this definition,
|
|
31
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
32
|
+
direction or management of such entity, whether by contract or
|
|
33
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
34
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
35
|
+
|
|
36
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
37
|
+
exercising permissions granted by this License.
|
|
38
|
+
|
|
39
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
40
|
+
including but not limited to software source code, documentation
|
|
41
|
+
source, and configuration files.
|
|
42
|
+
|
|
43
|
+
"Object" form shall mean any form resulting from mechanical
|
|
44
|
+
transformation or translation of a Source form, including but
|
|
45
|
+
not limited to compiled object code, generated documentation,
|
|
46
|
+
and conversions to other media types.
|
|
47
|
+
|
|
48
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
49
|
+
Object form, made available under the License, as indicated by a
|
|
50
|
+
copyright notice that is included in or attached to the work
|
|
51
|
+
(an example is provided in the Appendix below).
|
|
52
|
+
|
|
53
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
54
|
+
form, that is based on (or derived from) the Work and for which the
|
|
55
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
56
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
57
|
+
of this License, Derivative Works shall not include works that remain
|
|
58
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
59
|
+
the Work and Derivative Works thereof.
|
|
60
|
+
|
|
61
|
+
"Contribution" shall mean any work of authorship, including
|
|
62
|
+
the original version of the Work and any modifications or additions
|
|
63
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
64
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
65
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
66
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
67
|
+
means any form of electronic, verbal, or written communication sent
|
|
68
|
+
to the Licensor or its representatives, including but not limited to
|
|
69
|
+
communication on electronic mailing lists, source code control systems,
|
|
70
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
71
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
72
|
+
excluding communication that is conspicuously marked or otherwise
|
|
73
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
74
|
+
|
|
75
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
76
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
77
|
+
subsequently incorporated within the Work.
|
|
78
|
+
|
|
79
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
83
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
84
|
+
Work and such Derivative Works in Source or Object form.
|
|
85
|
+
|
|
86
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
87
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
88
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
89
|
+
(except as stated in this section) patent license to make, have made,
|
|
90
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
91
|
+
where such license applies only to those patent claims licensable
|
|
92
|
+
by such Contributor that are necessarily infringed by their
|
|
93
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
94
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
95
|
+
institute patent litigation against any entity (including a
|
|
96
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
97
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
98
|
+
or contributory patent infringement, then any patent licenses
|
|
99
|
+
granted to You under this License for that Work shall terminate
|
|
100
|
+
as of the date such litigation is filed.
|
|
101
|
+
|
|
102
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
103
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
104
|
+
modifications, and in Source or Object form, provided that You
|
|
105
|
+
meet the following conditions:
|
|
106
|
+
|
|
107
|
+
(a) You must give any other recipients of the Work or
|
|
108
|
+
Derivative Works a copy of this License; and
|
|
109
|
+
|
|
110
|
+
(b) You must cause any modified files to carry prominent notices
|
|
111
|
+
stating that You changed the files; and
|
|
112
|
+
|
|
113
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
114
|
+
that You distribute, all copyright, patent, trademark, and
|
|
115
|
+
attribution notices from the Source form of the Work,
|
|
116
|
+
excluding those notices that do not pertain to any part of
|
|
117
|
+
the Derivative Works; and
|
|
118
|
+
|
|
119
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
120
|
+
distribution, then any Derivative Works that You distribute must
|
|
121
|
+
include a readable copy of the attribution notices contained
|
|
122
|
+
within such NOTICE file, excluding those notices that do not
|
|
123
|
+
pertain to any part of the Derivative Works, in at least one
|
|
124
|
+
of the following places: within a NOTICE text file distributed
|
|
125
|
+
as part of the Derivative Works; within the Source form or
|
|
126
|
+
documentation, if provided along with the Derivative Works; or,
|
|
127
|
+
within a display generated by the Derivative Works, if and
|
|
128
|
+
wherever such third-party notices normally appear. The contents
|
|
129
|
+
of the NOTICE file are for informational purposes only and
|
|
130
|
+
do not modify the License. You may add Your own attribution
|
|
131
|
+
notices within Derivative Works that You distribute, alongside
|
|
132
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
133
|
+
that such additional attribution notices cannot be construed
|
|
134
|
+
as modifying the License.
|
|
135
|
+
|
|
136
|
+
You may add Your own copyright statement to Your modifications and
|
|
137
|
+
may provide additional or different license terms and conditions
|
|
138
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
139
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
140
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
141
|
+
the conditions stated in this License.
|
|
142
|
+
|
|
143
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
144
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
145
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
146
|
+
this License, without any additional terms or conditions.
|
|
147
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
148
|
+
the terms of any separate license agreement you may have executed
|
|
149
|
+
with Licensor regarding such Contributions.
|
|
150
|
+
|
|
151
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
152
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
153
|
+
except as required for reasonable and customary use in describing the
|
|
154
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
155
|
+
|
|
156
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
157
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
158
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
159
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
160
|
+
implied, including, without limitation, any warranties or conditions
|
|
161
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
162
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
163
|
+
appropriateness of using or redistributing the Work and assume any
|
|
164
|
+
risks associated with Your exercise of permissions under this License.
|
|
165
|
+
|
|
166
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
167
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
168
|
+
unless required by applicable law (such as deliberate and grossly
|
|
169
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
170
|
+
liable to You for damages, including any direct, indirect, special,
|
|
171
|
+
incidental, or consequential damages of any character arising as a
|
|
172
|
+
result of this License or out of the use or inability to use the
|
|
173
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
174
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
175
|
+
other commercial damages or losses), even if such Contributor
|
|
176
|
+
has been advised of the possibility of such damages.
|
|
177
|
+
|
|
178
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
179
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
180
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
181
|
+
or other liability obligations and/or rights consistent with this
|
|
182
|
+
License. However, in accepting such obligations, You may act only
|
|
183
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
184
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
185
|
+
defend, and hold each Contributor harmless for any liability
|
|
186
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
187
|
+
of your accepting any such warranty or additional liability.
|
|
188
|
+
|
|
189
|
+
END OF TERMS AND CONDITIONS
|
|
190
|
+
|
|
191
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
192
|
+
|
|
193
|
+
To apply the Apache License to your work, attach the following
|
|
194
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
195
|
+
replaced with your own identifying information. (Don't include
|
|
196
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
197
|
+
comment syntax for the file format. We also recommend that a
|
|
198
|
+
file or class name and description of purpose be included on the
|
|
199
|
+
same "printed page" as the copyright notice for easier
|
|
200
|
+
identification within third-party archives.
|
|
201
|
+
|
|
202
|
+
Copyright [yyyy] [name of copyright owner]
|
|
203
|
+
|
|
204
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
205
|
+
you may not use this file except in compliance with the License.
|
|
206
|
+
You may obtain a copy of the License at
|
|
207
|
+
|
|
208
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
209
|
+
|
|
210
|
+
Unless required by applicable law or agreed to in writing, software
|
|
211
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
212
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
213
|
+
See the License for the specific language governing permissions and
|
|
214
|
+
limitations under the License.
|
|
215
|
+
|
|
216
|
+
Project-URL: Homepage, https://github.com/openSUSE/libpathrs
|
|
217
|
+
Project-URL: Repository, https://github.com/openSUSE/libpathrs
|
|
218
|
+
Keywords: libpathrs,pathrs
|
|
219
|
+
Platform: Linux
|
|
220
|
+
Classifier: Topic :: Security
|
|
221
|
+
Classifier: Topic :: System :: Filesystems
|
|
222
|
+
Classifier: Intended Audience :: Developers
|
|
223
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
224
|
+
Classifier: Natural Language :: English
|
|
225
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
226
|
+
Classifier: Programming Language :: Python
|
|
227
|
+
Classifier: Programming Language :: Python :: 3
|
|
228
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
229
|
+
Requires-Python: >=3.8
|
|
230
|
+
License-File: COPYING.APACHE-2.0
|
|
231
|
+
Requires-Dist: cffi>=1.10.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# libpathrs: safe path resolution on Linux
|
|
3
|
+
# Copyright (C) 2019-2024 Aleksa Sarai <cyphar@cyphar.com>
|
|
4
|
+
# Copyright (C) 2019-2024 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
from ._pathrs import *
|
|
19
|
+
|
|
20
|
+
# TODO: Figure out a way to keep this version up-to-date with Cargo.toml.
|
|
21
|
+
__version__ = "0.0.2"
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# libpathrs: safe path resolution on Linux
|
|
3
|
+
# Copyright (C) 2019-2024 Aleksa Sarai <cyphar@cyphar.com>
|
|
4
|
+
# Copyright (C) 2019-2024 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
import io
|
|
19
|
+
import os
|
|
20
|
+
import re
|
|
21
|
+
import sys
|
|
22
|
+
import copy
|
|
23
|
+
import fcntl
|
|
24
|
+
|
|
25
|
+
from ._libpathrs_cffi import ffi, lib as libpathrs_so
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
# core api
|
|
29
|
+
"Root", "Handle",
|
|
30
|
+
# procfs api
|
|
31
|
+
"PROC_SELF", "PROC_THREAD_SELF",
|
|
32
|
+
"proc_open", "proc_open_raw", "proc_readlink",
|
|
33
|
+
# error api
|
|
34
|
+
"Error",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
def _cstr(pystr):
|
|
38
|
+
return ffi.new("char[]", pystr.encode("utf8"))
|
|
39
|
+
|
|
40
|
+
def _pystr(cstr):
|
|
41
|
+
return ffi.string(cstr).decode("utf8")
|
|
42
|
+
|
|
43
|
+
def _pyptr(cptr):
|
|
44
|
+
return int(ffi.cast("uintptr_t", cptr))
|
|
45
|
+
|
|
46
|
+
def _cbuffer(size):
|
|
47
|
+
return ffi.new("char[%d]" % (size,))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class Error(Exception):
|
|
51
|
+
def __init__(self, message, *_, errno=None):
|
|
52
|
+
# Construct Exception.
|
|
53
|
+
super().__init__(message)
|
|
54
|
+
|
|
55
|
+
# Basic arguments.
|
|
56
|
+
self.message = message
|
|
57
|
+
self.errno = errno
|
|
58
|
+
|
|
59
|
+
# Pre-format the errno.
|
|
60
|
+
self.strerror = None
|
|
61
|
+
if self.errno is not None:
|
|
62
|
+
try:
|
|
63
|
+
self.strerror = os.strerror(errno)
|
|
64
|
+
except ValueError:
|
|
65
|
+
self.strerror = str(errno)
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def _fetch(cls, err_id):
|
|
69
|
+
if err_id >= 0:
|
|
70
|
+
return None
|
|
71
|
+
|
|
72
|
+
err = libpathrs_so.pathrs_errorinfo(err_id)
|
|
73
|
+
if err == ffi.NULL:
|
|
74
|
+
return None
|
|
75
|
+
|
|
76
|
+
description = _pystr(err.description)
|
|
77
|
+
errno = err.saved_errno or None
|
|
78
|
+
|
|
79
|
+
libpathrs_so.pathrs_errorinfo_free(err)
|
|
80
|
+
del err
|
|
81
|
+
|
|
82
|
+
return cls(description, errno=errno)
|
|
83
|
+
|
|
84
|
+
def __str__(self):
|
|
85
|
+
if self.errno is None:
|
|
86
|
+
return self.message
|
|
87
|
+
else:
|
|
88
|
+
return "%s (%s)" % (self.message, self.strerror)
|
|
89
|
+
|
|
90
|
+
def __repr__(self):
|
|
91
|
+
return "Error(%r, errno=%r)" % (self.message, self.errno)
|
|
92
|
+
|
|
93
|
+
def pprint(self, out=sys.stdout):
|
|
94
|
+
# Basic error information.
|
|
95
|
+
if self.errno is None:
|
|
96
|
+
print("pathrs error:", file=out)
|
|
97
|
+
else:
|
|
98
|
+
print("pathrs error [%s]:" % (self.strerror,), file=out)
|
|
99
|
+
print(" %s" % (self.message,), file=out)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
INTERNAL_ERROR = Error("tried to fetch libpathrs error but no error found")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _fileno(file):
|
|
106
|
+
if isinstance(file, int):
|
|
107
|
+
# file is a plain fd
|
|
108
|
+
return file
|
|
109
|
+
else:
|
|
110
|
+
# Assume there is a fileno method.
|
|
111
|
+
return file.fileno()
|
|
112
|
+
|
|
113
|
+
def _clonefile(file):
|
|
114
|
+
return fcntl.fcntl(fileno(file), fcntl.F_DUPFD_CLOEXEC)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class WrappedFd(object):
|
|
118
|
+
def __init__(self, file):
|
|
119
|
+
fd = _fileno(file)
|
|
120
|
+
if isinstance(file, io.IOBase):
|
|
121
|
+
# If this is a regular open file, we need to make a copy because
|
|
122
|
+
# you cannot leak files and so the GC might close it from
|
|
123
|
+
# underneath us.
|
|
124
|
+
fd = clonefd(fd)
|
|
125
|
+
self._fd = fd
|
|
126
|
+
|
|
127
|
+
def fileno(self):
|
|
128
|
+
if self._fd is None:
|
|
129
|
+
raise OSError(errno.EBADF, "Closed file descriptor")
|
|
130
|
+
return self._fd
|
|
131
|
+
|
|
132
|
+
def leak(self):
|
|
133
|
+
self._fd = None
|
|
134
|
+
|
|
135
|
+
def fdopen(self, mode="r"):
|
|
136
|
+
fd = self.fileno()
|
|
137
|
+
try:
|
|
138
|
+
file = os.fdopen(fd, mode)
|
|
139
|
+
self.leak()
|
|
140
|
+
return file
|
|
141
|
+
except:
|
|
142
|
+
# "Unleak" the file if there was an error.
|
|
143
|
+
self._fd = fd
|
|
144
|
+
raise
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def from_raw_fd(cls, fd):
|
|
148
|
+
return cls(fd)
|
|
149
|
+
|
|
150
|
+
def into_raw_fd(self):
|
|
151
|
+
fd = self.fileno()
|
|
152
|
+
self.leak()
|
|
153
|
+
return fd
|
|
154
|
+
|
|
155
|
+
def isclosed(self):
|
|
156
|
+
return self._fd is None
|
|
157
|
+
|
|
158
|
+
def close(self):
|
|
159
|
+
if not self.isclosed():
|
|
160
|
+
os.close(self._fd)
|
|
161
|
+
self._fd = None
|
|
162
|
+
|
|
163
|
+
def clone(self):
|
|
164
|
+
if self.isclosed():
|
|
165
|
+
raise ValueError("cannot clone closed file")
|
|
166
|
+
return self.__class__(_clonefile(self))
|
|
167
|
+
|
|
168
|
+
def __copy__(self):
|
|
169
|
+
# A "shallow copy" of a file is the same as a deep copy.
|
|
170
|
+
return copy.deepcopy(self)
|
|
171
|
+
|
|
172
|
+
def __deepcopy__(self, memo):
|
|
173
|
+
return self.clone()
|
|
174
|
+
|
|
175
|
+
def __del__(self):
|
|
176
|
+
self.close()
|
|
177
|
+
|
|
178
|
+
def __enter__(self):
|
|
179
|
+
return self
|
|
180
|
+
|
|
181
|
+
def __exit__(self, exc_type, exc_value, exc_traceback):
|
|
182
|
+
self.close()
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
# XXX: This is _super_ ugly but so is the one in CPython.
|
|
186
|
+
def _convert_mode(mode):
|
|
187
|
+
mode = set(mode)
|
|
188
|
+
flags = os.O_CLOEXEC
|
|
189
|
+
|
|
190
|
+
# We don't support O_CREAT or O_EXCL with libpathrs -- use creat().
|
|
191
|
+
if "x" in mode:
|
|
192
|
+
raise ValueError("pathrs doesn't support mode='x', use Root.creat()")
|
|
193
|
+
# Basic sanity-check to make sure we don't accept garbage modes.
|
|
194
|
+
if len(mode & {"r", "w", "a"}) > 1:
|
|
195
|
+
raise ValueError("must have exactly one of read/write/append mode")
|
|
196
|
+
|
|
197
|
+
read = False
|
|
198
|
+
write = False
|
|
199
|
+
|
|
200
|
+
if "+" in mode:
|
|
201
|
+
read = True
|
|
202
|
+
write = True
|
|
203
|
+
if "r" in mode:
|
|
204
|
+
read = True
|
|
205
|
+
if "w" in mode:
|
|
206
|
+
write = True
|
|
207
|
+
flags |= os.O_TRUNC
|
|
208
|
+
if "a" in mode:
|
|
209
|
+
write = True
|
|
210
|
+
flags |= os.O_APPEND
|
|
211
|
+
|
|
212
|
+
if read and write:
|
|
213
|
+
flags |= os.O_RDWR
|
|
214
|
+
elif write:
|
|
215
|
+
flags |= os.O_WRONLY
|
|
216
|
+
else:
|
|
217
|
+
flags |= os.O_RDONLY
|
|
218
|
+
|
|
219
|
+
# We don't care about "b" or "t" since that's just a Python thing.
|
|
220
|
+
return flags
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
PROC_ROOT = libpathrs_so.PATHRS_PROC_ROOT
|
|
224
|
+
PROC_SELF = libpathrs_so.PATHRS_PROC_SELF
|
|
225
|
+
PROC_THREAD_SELF = libpathrs_so.PATHRS_PROC_THREAD_SELF
|
|
226
|
+
|
|
227
|
+
def proc_open(base, path, mode="r", extra_flags=0):
|
|
228
|
+
flags = _convert_mode(mode) | extra_flags
|
|
229
|
+
with proc_open_raw(base, path, flags) as file:
|
|
230
|
+
return file.fdopen(mode)
|
|
231
|
+
|
|
232
|
+
def proc_open_raw(base, path, flags):
|
|
233
|
+
path = _cstr(path)
|
|
234
|
+
fd = libpathrs_so.pathrs_proc_open(base, path, flags)
|
|
235
|
+
if fd < 0:
|
|
236
|
+
raise Error._fetch(fd) or INTERNAL_ERROR
|
|
237
|
+
return WrappedFd(fd)
|
|
238
|
+
|
|
239
|
+
def proc_readlink(base, path):
|
|
240
|
+
# TODO: See if we can merge this with Root.readlink.
|
|
241
|
+
path = _cstr(path)
|
|
242
|
+
linkbuf_size = 128
|
|
243
|
+
while True:
|
|
244
|
+
linkbuf = _cbuffer(linkbuf_size)
|
|
245
|
+
n = libpathrs_so.pathrs_proc_readlink(base, path, linkbuf, linkbuf_size)
|
|
246
|
+
if n < 0:
|
|
247
|
+
raise Error._fetch(n) or INTERNAL_ERROR
|
|
248
|
+
elif n <= linkbuf_size:
|
|
249
|
+
return ffi.buffer(linkbuf, linkbuf_size)[:n].decode("latin1")
|
|
250
|
+
else:
|
|
251
|
+
# The contents were truncated. Unlike readlinkat, pathrs returns
|
|
252
|
+
# the size of the link when it checked. So use the returned size
|
|
253
|
+
# as a basis for the reallocated size (but in order to avoid a DoS
|
|
254
|
+
# where a magic-link is growing by a single byte each iteration,
|
|
255
|
+
# make sure we are a fair bit larger).
|
|
256
|
+
linkbuf_size += n
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
class Handle(WrappedFd):
|
|
260
|
+
def __init__(self, file):
|
|
261
|
+
# XXX: Is this necessary?
|
|
262
|
+
super().__init__(file)
|
|
263
|
+
|
|
264
|
+
@classmethod
|
|
265
|
+
def from_file(cls, file):
|
|
266
|
+
return cls(file)
|
|
267
|
+
|
|
268
|
+
def reopen(self, mode="r", extra_flags=0):
|
|
269
|
+
flags = _convert_mode(mode) | extra_flags
|
|
270
|
+
with self.reopen_raw(flags) as file:
|
|
271
|
+
return file.fdopen(mode)
|
|
272
|
+
|
|
273
|
+
def reopen_raw(self, flags):
|
|
274
|
+
fd = libpathrs_so.pathrs_reopen(self.fileno(), flags)
|
|
275
|
+
if fd < 0:
|
|
276
|
+
raise Error._fetch(fd) or INTERNAL_ERROR
|
|
277
|
+
return WrappedFd(fd)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
class Root(WrappedFd):
|
|
281
|
+
def __init__(self, file):
|
|
282
|
+
if isinstance(file, str):
|
|
283
|
+
path = _cstr(file)
|
|
284
|
+
fd = libpathrs_so.pathrs_root_open(path)
|
|
285
|
+
if fd < 0:
|
|
286
|
+
raise Error._fetch(fd) or INTERNAL_ERROR
|
|
287
|
+
file = fd
|
|
288
|
+
# XXX: Is this necessary?
|
|
289
|
+
super().__init__(file)
|
|
290
|
+
|
|
291
|
+
@classmethod
|
|
292
|
+
def open(cls, path):
|
|
293
|
+
return cls(path)
|
|
294
|
+
|
|
295
|
+
@classmethod
|
|
296
|
+
def from_file(cls, file):
|
|
297
|
+
return cls(file)
|
|
298
|
+
|
|
299
|
+
def resolve(self, path, follow_trailing=True):
|
|
300
|
+
path = _cstr(path)
|
|
301
|
+
if follow_trailing:
|
|
302
|
+
fd = libpathrs_so.pathrs_resolve(self.fileno(), path)
|
|
303
|
+
else:
|
|
304
|
+
fd = libpathrs_so.pathrs_resolve_nofollow(self.fileno(), path)
|
|
305
|
+
if fd < 0:
|
|
306
|
+
raise Error._fetch(fd) or INTERNAL_ERROR
|
|
307
|
+
return Handle(fd)
|
|
308
|
+
|
|
309
|
+
def readlink(self, path):
|
|
310
|
+
path = _cstr(path)
|
|
311
|
+
linkbuf_size = 128
|
|
312
|
+
while True:
|
|
313
|
+
linkbuf = _cbuffer(linkbuf_size)
|
|
314
|
+
n = libpathrs_so.pathrs_readlink(self.fileno(), path, linkbuf, linkbuf_size)
|
|
315
|
+
if n < 0:
|
|
316
|
+
raise Error._fetch(n) or INTERNAL_ERROR
|
|
317
|
+
elif n <= linkbuf_size:
|
|
318
|
+
return ffi.buffer(linkbuf, linkbuf_size)[:n].decode("latin1")
|
|
319
|
+
else:
|
|
320
|
+
# The contents were truncated. Unlike readlinkat, pathrs returns
|
|
321
|
+
# the size of the link when it checked. So use the returned size
|
|
322
|
+
# as a basis for the reallocated size (but in order to avoid a DoS
|
|
323
|
+
# where a magic-link is growing by a single byte each iteration,
|
|
324
|
+
# make sure we are a fair bit larger).
|
|
325
|
+
linkbuf_size += n
|
|
326
|
+
|
|
327
|
+
def creat(self, path, filemode, mode="r", extra_flags=0):
|
|
328
|
+
path = _cstr(path)
|
|
329
|
+
flags = _convert_mode(mode) | extra_flags
|
|
330
|
+
fd = libpathrs_so.pathrs_creat(self.fileno(), path, flags, filemode)
|
|
331
|
+
if fd < 0:
|
|
332
|
+
raise Error._fetch(fd) or INTERNAL_ERROR
|
|
333
|
+
return Handle(fd)
|
|
334
|
+
|
|
335
|
+
def rename(self, src, dst, flags=0):
|
|
336
|
+
src = _cstr(src)
|
|
337
|
+
dst = _cstr(dst)
|
|
338
|
+
err = libpathrs_so.pathrs_rename(self.fileno(), src, dst, flags)
|
|
339
|
+
if err < 0:
|
|
340
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
341
|
+
|
|
342
|
+
def rmdir(self, path):
|
|
343
|
+
path = _cstr(path)
|
|
344
|
+
err = libpathrs_so.pathrs_rmdir(self.fileno(), path)
|
|
345
|
+
if err < 0:
|
|
346
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
347
|
+
|
|
348
|
+
def unlink(self, path):
|
|
349
|
+
path = _cstr(path)
|
|
350
|
+
err = libpathrs_so.pathrs_unlink(self.fileno(), path)
|
|
351
|
+
if err < 0:
|
|
352
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
353
|
+
|
|
354
|
+
def remove_all(self, path):
|
|
355
|
+
path = _cstr(path)
|
|
356
|
+
err = libpathrs_so.pathrs_remove_all(self.fileno(), path)
|
|
357
|
+
if err < 0:
|
|
358
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
359
|
+
|
|
360
|
+
def mkdir(self, path, mode):
|
|
361
|
+
path = _cstr(path)
|
|
362
|
+
err = libpathrs_so.pathrs_mkdir(self.fileno(), path, mode)
|
|
363
|
+
if err < 0:
|
|
364
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
365
|
+
|
|
366
|
+
def mkdir_all(self, path, mode):
|
|
367
|
+
path = _cstr(path)
|
|
368
|
+
fd = libpathrs_so.pathrs_mkdir_all(self.fileno(), path, mode)
|
|
369
|
+
if fd < 0:
|
|
370
|
+
raise Error._fetch(fd) or INTERNAL_ERROR
|
|
371
|
+
return Handle(fd)
|
|
372
|
+
|
|
373
|
+
def mknod(self, path, mode, dev=0):
|
|
374
|
+
path = _cstr(path)
|
|
375
|
+
err = libpathrs_so.pathrs_mknod(self.fileno(), path, mode, dev)
|
|
376
|
+
if err < 0:
|
|
377
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
378
|
+
|
|
379
|
+
def hardlink(self, path, target):
|
|
380
|
+
path = _cstr(path)
|
|
381
|
+
target = _cstr(target)
|
|
382
|
+
err = libpathrs_so.pathrs_hardlink(self.fileno(), path, target)
|
|
383
|
+
if err < 0:
|
|
384
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
385
|
+
|
|
386
|
+
def symlink(self, path, target):
|
|
387
|
+
path = _cstr(path)
|
|
388
|
+
target = _cstr(target)
|
|
389
|
+
err = libpathrs_so.pathrs_symlink(self.fileno(), path, target)
|
|
390
|
+
if err < 0:
|
|
391
|
+
raise Error._fetch(err) or INTERNAL_ERROR
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# libpathrs: safe path resolution on Linux
|
|
3
|
+
# Copyright (C) 2019-2024 Aleksa Sarai <cyphar@cyphar.com>
|
|
4
|
+
# Copyright (C) 2019-2024 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
# This builds the _pathrs module (only needs to be done during the initial
|
|
19
|
+
# build of libpathrs, and can be redistributed alongside the pathrs.py wrapping
|
|
20
|
+
# library). It's much better than the ABI-mode of CFFI.
|
|
21
|
+
|
|
22
|
+
import re
|
|
23
|
+
import os
|
|
24
|
+
import sys
|
|
25
|
+
|
|
26
|
+
import cffi
|
|
27
|
+
|
|
28
|
+
def load_hdr(ffi, hdr_path):
|
|
29
|
+
with open(hdr_path) as f:
|
|
30
|
+
hdr = f.read()
|
|
31
|
+
|
|
32
|
+
# Drop all #-lines.
|
|
33
|
+
hdr = re.sub("^#.*$", "", hdr, flags=re.MULTILINE)
|
|
34
|
+
|
|
35
|
+
# Replace each struct-like body that has __CBINDGEN_ALIGNED before it,
|
|
36
|
+
# remove the __CBINDGEN_ALIGNED and add "...;" as the last field in the
|
|
37
|
+
# struct. This is how you tell cffi to get the proper alignment from the
|
|
38
|
+
# compiler (__attribute__((aligned(n))) is not supported by cdef).
|
|
39
|
+
hdr = re.sub(r"__CBINDGEN_ALIGNED\(\d+\)([^{;]*){([^}]+)}", r"\1 {\2 ...;}", hdr, flags=re.MULTILINE)
|
|
40
|
+
|
|
41
|
+
# Load the header.
|
|
42
|
+
ffi.cdef(hdr)
|
|
43
|
+
|
|
44
|
+
def create_ffibuilder(**kwargs):
|
|
45
|
+
ffibuilder = cffi.FFI()
|
|
46
|
+
ffibuilder.cdef("typedef uint32_t dev_t;")
|
|
47
|
+
|
|
48
|
+
# We need to use cdef to tell cffi what functions we need to FFI to. But we
|
|
49
|
+
# don't need the structs (I hope).
|
|
50
|
+
for include_dir in kwargs.get("include_dirs", []):
|
|
51
|
+
pathrs_hdr = os.path.join(include_dir, "pathrs.h")
|
|
52
|
+
if os.path.exists(pathrs_hdr):
|
|
53
|
+
load_hdr(ffibuilder, pathrs_hdr)
|
|
54
|
+
|
|
55
|
+
# Add a source and link to libpathrs.
|
|
56
|
+
ffibuilder.set_source("_libpathrs_cffi", "#include <pathrs.h>",
|
|
57
|
+
libraries=["pathrs"], **kwargs)
|
|
58
|
+
|
|
59
|
+
return ffibuilder
|
|
60
|
+
|
|
61
|
+
def find_rootdir():
|
|
62
|
+
# Figure out where the libpathrs source dir is.
|
|
63
|
+
root_dir = None
|
|
64
|
+
candidate = os.path.dirname(sys.path[0] or os.getcwd())
|
|
65
|
+
while candidate != "/":
|
|
66
|
+
try:
|
|
67
|
+
# Look for a Cargo.toml which says it's pathrs.
|
|
68
|
+
candidate_toml = os.path.join(candidate, "Cargo.toml")
|
|
69
|
+
with open(candidate_toml, "r") as f:
|
|
70
|
+
content = f.read()
|
|
71
|
+
if re.findall(r'^name = "pathrs"$', content, re.MULTILINE):
|
|
72
|
+
root_dir = candidate
|
|
73
|
+
break
|
|
74
|
+
except:
|
|
75
|
+
pass
|
|
76
|
+
candidate = os.path.dirname(candidate)
|
|
77
|
+
|
|
78
|
+
if not root_dir:
|
|
79
|
+
raise FileNotFoundError("Could not find pathrs source-dir root.")
|
|
80
|
+
|
|
81
|
+
return root_dir
|
|
82
|
+
|
|
83
|
+
def srcdir_ffibuilder(root_dir=None):
|
|
84
|
+
"""
|
|
85
|
+
Build the CFFI bindings using the provided root_dir as the root of a
|
|
86
|
+
pathrs source tree which has compiled cdylibs ready in target/*.
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
if root_dir is None:
|
|
90
|
+
root_dir = find_rootdir()
|
|
91
|
+
|
|
92
|
+
# Figure out which libs are usable.
|
|
93
|
+
library_dirs = (
|
|
94
|
+
os.path.join(root_dir, "target/%s/libpathrs.so" % (mode,))
|
|
95
|
+
for mode in ("debug", "release")
|
|
96
|
+
)
|
|
97
|
+
library_dirs = (so_path for so_path in library_dirs if os.path.exists(so_path))
|
|
98
|
+
library_dirs = sorted(library_dirs, key=lambda path: -os.path.getmtime(path))
|
|
99
|
+
library_dirs = [os.path.dirname(path) for path in library_dirs]
|
|
100
|
+
|
|
101
|
+
# Compile the libpathrs module.
|
|
102
|
+
return create_ffibuilder(include_dirs=[os.path.join(root_dir, "include")],
|
|
103
|
+
library_dirs=library_dirs)
|
|
104
|
+
|
|
105
|
+
def system_ffibuilder():
|
|
106
|
+
"""
|
|
107
|
+
Build the CFFI bindings using the installed libpathrs system libraries.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
return create_ffibuilder(include_dirs=[
|
|
111
|
+
"/usr/include",
|
|
112
|
+
"/usr/local/include"
|
|
113
|
+
])
|
|
114
|
+
|
|
115
|
+
if __name__ == "__main__":
|
|
116
|
+
try:
|
|
117
|
+
# Search for the compiled libraries to link to from our libpathrs
|
|
118
|
+
# source if running outside of setuptools as a regular program.
|
|
119
|
+
ffibuilder = find_ffibuilder()
|
|
120
|
+
except FileNotFoundError:
|
|
121
|
+
# If we couldn't find a valid library in the source dir, just fallback
|
|
122
|
+
# to using the system libraries.
|
|
123
|
+
ffibuilder = system_ffibuilder()
|
|
124
|
+
ffibuilder.compile(verbose=True)
|
|
125
|
+
elif os.environ.get("PATHRS_SRC_ROOT", "") != "":
|
|
126
|
+
# If we're running in setup tools, we can't easily find the source dir.
|
|
127
|
+
# However, distributions can set PATHRS_SRC_ROOT to the path of the
|
|
128
|
+
# libpathrs source directory to make it easier to build the python modules
|
|
129
|
+
# in the same %build script as the main library.
|
|
130
|
+
ffibuilder = srcdir_ffibuilder(root_dir=os.environ.get("PATHRS_SRC_ROOT"))
|
|
131
|
+
else:
|
|
132
|
+
# Use the system libraries if running inside standard setuptools.
|
|
133
|
+
ffibuilder = system_ffibuilder()
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pathrs
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Python bindings for libpathrs, a safe path resolution library for Linux.
|
|
5
|
+
Author-email: Aleksa Sarai <cyphar@cyphar.com>
|
|
6
|
+
Maintainer-email: Aleksa Sarai <cyphar@cyphar.com>
|
|
7
|
+
License: NOTE: This license only applies to contrib/bindings and no other components of
|
|
8
|
+
libpathrs. Since these bindings are fairly trivial wrappers around the
|
|
9
|
+
shared library API of libpathrs, they aren't covered by the LGPL's
|
|
10
|
+
copyleft.
|
|
11
|
+
|
|
12
|
+
===============================================================================
|
|
13
|
+
|
|
14
|
+
Apache License
|
|
15
|
+
Version 2.0, January 2004
|
|
16
|
+
http://www.apache.org/licenses/
|
|
17
|
+
|
|
18
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
19
|
+
|
|
20
|
+
1. Definitions.
|
|
21
|
+
|
|
22
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
23
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
24
|
+
|
|
25
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
26
|
+
the copyright owner that is granting the License.
|
|
27
|
+
|
|
28
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
29
|
+
other entities that control, are controlled by, or are under common
|
|
30
|
+
control with that entity. For the purposes of this definition,
|
|
31
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
32
|
+
direction or management of such entity, whether by contract or
|
|
33
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
34
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
35
|
+
|
|
36
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
37
|
+
exercising permissions granted by this License.
|
|
38
|
+
|
|
39
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
40
|
+
including but not limited to software source code, documentation
|
|
41
|
+
source, and configuration files.
|
|
42
|
+
|
|
43
|
+
"Object" form shall mean any form resulting from mechanical
|
|
44
|
+
transformation or translation of a Source form, including but
|
|
45
|
+
not limited to compiled object code, generated documentation,
|
|
46
|
+
and conversions to other media types.
|
|
47
|
+
|
|
48
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
49
|
+
Object form, made available under the License, as indicated by a
|
|
50
|
+
copyright notice that is included in or attached to the work
|
|
51
|
+
(an example is provided in the Appendix below).
|
|
52
|
+
|
|
53
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
54
|
+
form, that is based on (or derived from) the Work and for which the
|
|
55
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
56
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
57
|
+
of this License, Derivative Works shall not include works that remain
|
|
58
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
59
|
+
the Work and Derivative Works thereof.
|
|
60
|
+
|
|
61
|
+
"Contribution" shall mean any work of authorship, including
|
|
62
|
+
the original version of the Work and any modifications or additions
|
|
63
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
64
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
65
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
66
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
67
|
+
means any form of electronic, verbal, or written communication sent
|
|
68
|
+
to the Licensor or its representatives, including but not limited to
|
|
69
|
+
communication on electronic mailing lists, source code control systems,
|
|
70
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
71
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
72
|
+
excluding communication that is conspicuously marked or otherwise
|
|
73
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
74
|
+
|
|
75
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
76
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
77
|
+
subsequently incorporated within the Work.
|
|
78
|
+
|
|
79
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
80
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
81
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
82
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
83
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
84
|
+
Work and such Derivative Works in Source or Object form.
|
|
85
|
+
|
|
86
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
87
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
88
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
89
|
+
(except as stated in this section) patent license to make, have made,
|
|
90
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
91
|
+
where such license applies only to those patent claims licensable
|
|
92
|
+
by such Contributor that are necessarily infringed by their
|
|
93
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
94
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
95
|
+
institute patent litigation against any entity (including a
|
|
96
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
97
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
98
|
+
or contributory patent infringement, then any patent licenses
|
|
99
|
+
granted to You under this License for that Work shall terminate
|
|
100
|
+
as of the date such litigation is filed.
|
|
101
|
+
|
|
102
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
103
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
104
|
+
modifications, and in Source or Object form, provided that You
|
|
105
|
+
meet the following conditions:
|
|
106
|
+
|
|
107
|
+
(a) You must give any other recipients of the Work or
|
|
108
|
+
Derivative Works a copy of this License; and
|
|
109
|
+
|
|
110
|
+
(b) You must cause any modified files to carry prominent notices
|
|
111
|
+
stating that You changed the files; and
|
|
112
|
+
|
|
113
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
114
|
+
that You distribute, all copyright, patent, trademark, and
|
|
115
|
+
attribution notices from the Source form of the Work,
|
|
116
|
+
excluding those notices that do not pertain to any part of
|
|
117
|
+
the Derivative Works; and
|
|
118
|
+
|
|
119
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
120
|
+
distribution, then any Derivative Works that You distribute must
|
|
121
|
+
include a readable copy of the attribution notices contained
|
|
122
|
+
within such NOTICE file, excluding those notices that do not
|
|
123
|
+
pertain to any part of the Derivative Works, in at least one
|
|
124
|
+
of the following places: within a NOTICE text file distributed
|
|
125
|
+
as part of the Derivative Works; within the Source form or
|
|
126
|
+
documentation, if provided along with the Derivative Works; or,
|
|
127
|
+
within a display generated by the Derivative Works, if and
|
|
128
|
+
wherever such third-party notices normally appear. The contents
|
|
129
|
+
of the NOTICE file are for informational purposes only and
|
|
130
|
+
do not modify the License. You may add Your own attribution
|
|
131
|
+
notices within Derivative Works that You distribute, alongside
|
|
132
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
133
|
+
that such additional attribution notices cannot be construed
|
|
134
|
+
as modifying the License.
|
|
135
|
+
|
|
136
|
+
You may add Your own copyright statement to Your modifications and
|
|
137
|
+
may provide additional or different license terms and conditions
|
|
138
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
139
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
140
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
141
|
+
the conditions stated in this License.
|
|
142
|
+
|
|
143
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
144
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
145
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
146
|
+
this License, without any additional terms or conditions.
|
|
147
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
148
|
+
the terms of any separate license agreement you may have executed
|
|
149
|
+
with Licensor regarding such Contributions.
|
|
150
|
+
|
|
151
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
152
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
153
|
+
except as required for reasonable and customary use in describing the
|
|
154
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
155
|
+
|
|
156
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
157
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
158
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
159
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
160
|
+
implied, including, without limitation, any warranties or conditions
|
|
161
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
162
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
163
|
+
appropriateness of using or redistributing the Work and assume any
|
|
164
|
+
risks associated with Your exercise of permissions under this License.
|
|
165
|
+
|
|
166
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
167
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
168
|
+
unless required by applicable law (such as deliberate and grossly
|
|
169
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
170
|
+
liable to You for damages, including any direct, indirect, special,
|
|
171
|
+
incidental, or consequential damages of any character arising as a
|
|
172
|
+
result of this License or out of the use or inability to use the
|
|
173
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
174
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
175
|
+
other commercial damages or losses), even if such Contributor
|
|
176
|
+
has been advised of the possibility of such damages.
|
|
177
|
+
|
|
178
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
179
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
180
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
181
|
+
or other liability obligations and/or rights consistent with this
|
|
182
|
+
License. However, in accepting such obligations, You may act only
|
|
183
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
184
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
185
|
+
defend, and hold each Contributor harmless for any liability
|
|
186
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
187
|
+
of your accepting any such warranty or additional liability.
|
|
188
|
+
|
|
189
|
+
END OF TERMS AND CONDITIONS
|
|
190
|
+
|
|
191
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
192
|
+
|
|
193
|
+
To apply the Apache License to your work, attach the following
|
|
194
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
195
|
+
replaced with your own identifying information. (Don't include
|
|
196
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
197
|
+
comment syntax for the file format. We also recommend that a
|
|
198
|
+
file or class name and description of purpose be included on the
|
|
199
|
+
same "printed page" as the copyright notice for easier
|
|
200
|
+
identification within third-party archives.
|
|
201
|
+
|
|
202
|
+
Copyright [yyyy] [name of copyright owner]
|
|
203
|
+
|
|
204
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
205
|
+
you may not use this file except in compliance with the License.
|
|
206
|
+
You may obtain a copy of the License at
|
|
207
|
+
|
|
208
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
209
|
+
|
|
210
|
+
Unless required by applicable law or agreed to in writing, software
|
|
211
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
212
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
213
|
+
See the License for the specific language governing permissions and
|
|
214
|
+
limitations under the License.
|
|
215
|
+
|
|
216
|
+
Project-URL: Homepage, https://github.com/openSUSE/libpathrs
|
|
217
|
+
Project-URL: Repository, https://github.com/openSUSE/libpathrs
|
|
218
|
+
Keywords: libpathrs,pathrs
|
|
219
|
+
Platform: Linux
|
|
220
|
+
Classifier: Topic :: Security
|
|
221
|
+
Classifier: Topic :: System :: Filesystems
|
|
222
|
+
Classifier: Intended Audience :: Developers
|
|
223
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
224
|
+
Classifier: Natural Language :: English
|
|
225
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
226
|
+
Classifier: Programming Language :: Python
|
|
227
|
+
Classifier: Programming Language :: Python :: 3
|
|
228
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
229
|
+
Requires-Python: >=3.8
|
|
230
|
+
License-File: COPYING.APACHE-2.0
|
|
231
|
+
Requires-Dist: cffi>=1.10.0
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
COPYING.APACHE-2.0
|
|
2
|
+
pyproject.toml
|
|
3
|
+
setup.py
|
|
4
|
+
pathrs/__init__.py
|
|
5
|
+
pathrs/_pathrs.py
|
|
6
|
+
pathrs/pathrs_build.py
|
|
7
|
+
pathrs.egg-info/PKG-INFO
|
|
8
|
+
pathrs.egg-info/SOURCES.txt
|
|
9
|
+
pathrs.egg-info/dependency_links.txt
|
|
10
|
+
pathrs.egg-info/requires.txt
|
|
11
|
+
pathrs.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cffi>=1.10.0
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# libpathrs: safe path resolution on Linux
|
|
3
|
+
# Copyright (C) 2019-2024 Aleksa Sarai <cyphar@cyphar.com>
|
|
4
|
+
# Copyright (C) 2019-2024 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = [
|
|
20
|
+
"cffi>=1.10.0",
|
|
21
|
+
"setuptools>=61",
|
|
22
|
+
"toml>=0.10", # TODO: Remove this once we only support Python >= 3.11.
|
|
23
|
+
"wheel",
|
|
24
|
+
]
|
|
25
|
+
build-backend = "setuptools.build_meta"
|
|
26
|
+
|
|
27
|
+
[project]
|
|
28
|
+
name = "pathrs"
|
|
29
|
+
# TODO: Figure out a way to keep this version up-to-date with Cargo.toml.
|
|
30
|
+
version = "0.1.1"
|
|
31
|
+
description = "Python bindings for libpathrs, a safe path resolution library for Linux."
|
|
32
|
+
keywords = ["libpathrs", "pathrs"]
|
|
33
|
+
license = { file = "COPYING.APACHE-2.0" }
|
|
34
|
+
authors = [
|
|
35
|
+
{name = "Aleksa Sarai", email = "cyphar@cyphar.com"},
|
|
36
|
+
]
|
|
37
|
+
maintainers = [
|
|
38
|
+
{name = "Aleksa Sarai", email = "cyphar@cyphar.com"},
|
|
39
|
+
]
|
|
40
|
+
classifiers = [
|
|
41
|
+
"Topic :: Security",
|
|
42
|
+
"Topic :: System :: Filesystems",
|
|
43
|
+
"Intended Audience :: Developers",
|
|
44
|
+
"License :: OSI Approved :: Apache Software License",
|
|
45
|
+
"Natural Language :: English",
|
|
46
|
+
"Operating System :: POSIX :: Linux",
|
|
47
|
+
"Programming Language :: Python",
|
|
48
|
+
"Programming Language :: Python :: 3",
|
|
49
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
requires-python = ">= 3.8"
|
|
53
|
+
dependencies = [
|
|
54
|
+
"cffi>=1.10.0",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[project.urls]
|
|
58
|
+
Homepage = "https://github.com/openSUSE/libpathrs"
|
|
59
|
+
Repository = "https://github.com/openSUSE/libpathrs"
|
pathrs-0.1.1/setup.cfg
ADDED
pathrs-0.1.1/setup.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# libpathrs: safe path resolution on Linux
|
|
3
|
+
# Copyright (C) 2019-2024 Aleksa Sarai <cyphar@cyphar.com>
|
|
4
|
+
# Copyright (C) 2019-2024 SUSE LLC
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
import setuptools
|
|
19
|
+
|
|
20
|
+
# This is only needed for backwards compatibility with older versions.
|
|
21
|
+
def parse_pyproject():
|
|
22
|
+
try:
|
|
23
|
+
import tomllib
|
|
24
|
+
openmode = "rb"
|
|
25
|
+
except ImportError:
|
|
26
|
+
# TODO: Remove this once we only support Python >= 3.11.
|
|
27
|
+
import toml as tomllib
|
|
28
|
+
openmode = "r"
|
|
29
|
+
|
|
30
|
+
with open("pyproject.toml", openmode) as f:
|
|
31
|
+
return tomllib.load(f)
|
|
32
|
+
|
|
33
|
+
pyproject = parse_pyproject()
|
|
34
|
+
|
|
35
|
+
setuptools.setup(
|
|
36
|
+
# For backwards-compatibility with pre-pyproject setuptools.
|
|
37
|
+
name=pyproject["project"]["name"],
|
|
38
|
+
version=pyproject["project"]["version"],
|
|
39
|
+
install_requires=pyproject["project"]["dependencies"],
|
|
40
|
+
# Configure cffi building.
|
|
41
|
+
ext_package="pathrs",
|
|
42
|
+
platforms=["Linux"],
|
|
43
|
+
cffi_modules=["pathrs/pathrs_build.py:ffibuilder"],
|
|
44
|
+
)
|