Compare commits
1818 Commits
http-clien
...
master
Author | SHA1 | Date | |
---|---|---|---|
7daf199610 | |||
|
23c185e3e0 | ||
682e0e94f7 | |||
814f0cd184 | |||
15a8137c99 | |||
7d662bb020 | |||
df6205c482 | |||
7a9d897c14 | |||
183498df7e | |||
53695fbb11 | |||
|
ca10f8ce62 | ||
|
978c6d2704 | ||
eebbc9908b | |||
b37ac53aaf | |||
be4a1bdf7a | |||
7cad0ca9fe | |||
bd6ac3068b | |||
1e634131ca | |||
87c61def9b | |||
11a3bd3e1b | |||
243b200fb8 | |||
700cf74001 | |||
95ac5c8fc6 | |||
68225c1933 | |||
1e0843d2ce | |||
b853443c9e | |||
7a684add89 | |||
63e714d1b1 | |||
3675c6b16c | |||
7f8bb14112 | |||
a4290909b4 | |||
36fb39553d | |||
18abdbf2d9 | |||
89ac09bbe1 | |||
65bf155326 | |||
6801bf9d88 | |||
456200e747 | |||
09e199a176 | |||
2ecc61ad92 | |||
dd8b23ff86 | |||
d78e7af80c | |||
cf8ed4211b | |||
39931d98b9 | |||
ac18c044e1 | |||
e5c941b4d7 | |||
065b307d60 | |||
5eaae9916d | |||
5d0a7b71a2 | |||
b4600b8183 | |||
f465243fc6 | |||
e4b0e8debf | |||
d9d13dda5f | |||
aef10a699e | |||
b413ade4db | |||
190d308ddf | |||
4314146247 | |||
4831798c9e | |||
e999e6f5b8 | |||
3ad785c116 | |||
be3db87410 | |||
57d23c477d | |||
0ec07636fb | |||
bdd15ad6e7 | |||
96f7aa5c62 | |||
2fdf896fbd | |||
251c82ee9f | |||
c2186bb33c | |||
1a9d43ea1a | |||
9de324d3c3 | |||
b53acfe61f | |||
|
c92f71471d | ||
2a79c669a5 | |||
9b2d326c38 | |||
2bfca3760c | |||
0f7f5347d8 | |||
80703d7b29 | |||
942685f396 | |||
02744ff4a0 | |||
c74409b9a5 | |||
1c32dbc88a | |||
ab17270761 | |||
d0538a50e0 | |||
318ac21e41 | |||
3e9bb7c369 | |||
2c64cd0f02 | |||
59e6b65249 | |||
91ef2c7666 | |||
935cb5541b | |||
9a7eb11c73 | |||
4b338ccfd8 | |||
ca92b29ffe | |||
ec4e69e89d | |||
c225f2cfee | |||
e325728f38 | |||
c9a44d211e | |||
4b3ffd8570 | |||
3e9746cf0c | |||
950155cbe3 | |||
dd978ff2fd | |||
4bbaffaa6f | |||
2a12362e75 | |||
411ac8dc31 | |||
b837a93176 | |||
1c56e782d2 | |||
c6c61ca486 | |||
6ae312c1f9 | |||
f6cf4cb90c | |||
3ff65219e8 | |||
e33f554838 | |||
2850f343b9 | |||
|
8d6445c632 | ||
|
de611e0d4e | ||
|
6fec9d4737 | ||
|
856e48aa14 | ||
|
2cafd9d2bc | ||
|
87ec8c756f | ||
2ece023c0f | |||
16e20ed474 | |||
afd7e7dc4f | |||
d46bdbf959 | |||
cac3cec135 | |||
4e0efff4c4 | |||
71b7c96ddd | |||
5ff61cdf86 | |||
7d0ba7fc62 | |||
bfe56aed1f | |||
a1103c05a5 | |||
125125b9db | |||
4eec582f1b | |||
e969489ca2 | |||
ec4a657b42 | |||
55030d83da | |||
|
dfe213824f | ||
c680a9f33b | |||
df192ee18e | |||
|
008def2ff4 | ||
|
3976daddb7 | ||
524cdbbeb1 | |||
a01c5acfe2 | |||
|
6689312ac5 | ||
e214695a3e | |||
|
9d7f99bd00 | ||
3cea6ef97c | |||
3b0f131a65 | |||
|
e0a3020e34 | ||
|
0e46b9509a | ||
|
d3474d0cd9 | ||
|
5c3dad1bb9 | ||
|
987cdaf313 | ||
|
835352428a | ||
|
8f4246e716 | ||
|
1353a2fd20 | ||
|
aa9fbdbfc2 | ||
3a8cdf9967 | |||
2caf491e9d | |||
d277e56121 | |||
335099ad19 | |||
b1106985ec | |||
cd8ce9aaa9 | |||
18f0cb086b | |||
dee54445bf | |||
|
2df59fd1b3 | ||
2e5dee8e1a | |||
c6aa5c3ed7 | |||
47ef380ebd | |||
d6601b0353 | |||
0eba225723 | |||
e7d91d138b | |||
0103e2771e | |||
b6246734e4 | |||
6146c3494f | |||
e5a7a2da70 | |||
6047614a16 | |||
6a86e9e77e | |||
4132447e04 | |||
9d223730de | |||
ad9199568b | |||
0d91c2ac14 | |||
8644ca41e1 | |||
|
6051c0cfbc | ||
67d977ce39 | |||
8b6b3d2fbe | |||
a5d228ba89 | |||
a7be1e7068 | |||
30a10d871a | |||
90b0281c1c | |||
|
bba92baeb1 | ||
e06a1c03d4 | |||
0171f2e870 | |||
da078c7362 | |||
94b4b7c455 | |||
6aa486594a | |||
2c3148abcc | |||
dde32fa72e | |||
675ab17fff | |||
9fcacbd96b | |||
ba4c6e5b99 | |||
f2b139b58b | |||
a44bf5884d | |||
64c1d63d33 | |||
0300d8f2cc | |||
|
bb395b652d | ||
59bfdd9a30 | |||
d85accb08e | |||
c7439d3c89 | |||
38cd5ad8ed | |||
5fd0fa8d8e | |||
452ca8cca2 | |||
5f73320b29 | |||
d14526059b | |||
b1cde06bd0 | |||
0adb602a96 | |||
f9a2b21cb0 | |||
e73cf4033e | |||
5f0c6f60b8 | |||
29c9611152 | |||
e90ca97441 | |||
1fb0387101 | |||
|
1981a12e67 | ||
|
eae197ccb3 | ||
|
15c6ed2b8d | ||
fbb648d984 | |||
|
c914a284de | ||
9a17eaa32a | |||
480d6be02f | |||
3e907bd890 | |||
|
d999c3dfbf | ||
41d44b037d | |||
9d8d6e3293 | |||
|
8696a1c710 | ||
2f107197d4 | |||
486a1bac25 | |||
a73ce186b5 | |||
76204aa366 | |||
502f0ea62f | |||
e7e6663017 | |||
e27fed09f3 | |||
9eeac00714 | |||
c0ffb22d6a | |||
f0b145d8dd | |||
bb700281a3 | |||
|
fcdec4ba2c | ||
371eda962f | |||
50252d8613 | |||
78c393a16e | |||
9c3478075f | |||
7e7c11fda4 | |||
bff14761ac | |||
99ddcc938f | |||
e2301e2fa7 | |||
c52096671e | |||
64f03a2f18 | |||
|
a72b78ef96 | ||
|
b17849c258 | ||
d759535faa | |||
|
c25c07aa61 | ||
|
5f361e1e0b | ||
|
bcb498de20 | ||
|
fd6ff9f8ec | ||
|
69d311f0b4 | ||
|
fde0e712ac | ||
|
c60aa767ca | ||
|
78df858ba1 | ||
|
f1f4d5e836 | ||
|
2726e83235 | ||
|
f23631054a | ||
|
9189f9a65a | ||
|
7076472bde | ||
a2a605ad89 | |||
|
8fae9a5083 | ||
|
6f07b6a343 | ||
|
dfebfc9504 | ||
|
36463ebf97 | ||
|
f400f43b8c | ||
a3748507ca | |||
|
c92875882a | ||
|
2df2e3da40 | ||
|
cf1e8659b0 | ||
|
fb2e3f2740 | ||
578162f461 | |||
|
29bc40f65b | ||
|
aafb77df7c | ||
|
dc1a813305 | ||
|
16c7ecabe2 | ||
|
e1d8ba869a | ||
|
38db038953 | ||
|
bcdf2b23f1 | ||
|
83b82c328b | ||
c149ee8d2b | |||
|
c10924274d | ||
|
e13c5a99af | ||
6623e4b1c8 | |||
5170baf074 | |||
d143daeb9a | |||
699b183f62 | |||
09d72e7c97 | |||
d551cc8077 | |||
4698639da9 | |||
e67a9c93fe | |||
621cc5782b | |||
482503ca0a | |||
2fb7328a6e | |||
06eae56646 | |||
bdbbeb1040 | |||
1eed02c8c7 | |||
6d325a1804 | |||
a05f272b58 | |||
07dfb1e94b | |||
6ff07d3dbc | |||
0da5572164 | |||
422b99a222 | |||
055df584a4 | |||
9798e0f1d2 | |||
a43fa7d63e | |||
4361ef7a72 | |||
|
3218aaa378 | ||
186a37cf3e | |||
|
7b1f591cc4 | ||
0ecd244177 | |||
e14600ae75 | |||
0884756139 | |||
4c539d62c1 | |||
f5b58d1db7 | |||
18f6a74d08 | |||
becb3436d0 | |||
1f220cd488 | |||
572ee06bbb | |||
6e1380ef2e | |||
3e83a7fd83 | |||
34ac9cec4d | |||
513f7446b3 | |||
aed478153d | |||
210816769a | |||
42bf21c86e | |||
4b34cddcda | |||
1ba2361fea | |||
278a3005d1 | |||
|
78d68e381a | ||
17ffc459db | |||
afcb482866 | |||
c28de19faa | |||
7ae952c82e | |||
|
98098035c9 | ||
acdc0786ba | |||
7fa72a8892 | |||
fa22920e51 | |||
f084fbce43 | |||
|
1850c00e9d | ||
c20deceaa8 | |||
89e4145baf | |||
|
f5f7c26d8a | ||
784942ca58 | |||
75de2a7bc1 | |||
ea6c8d338c | |||
ae625b181c | |||
89ae54a083 | |||
1bd73591ba | |||
f709f6e714 | |||
3d7e07c371 | |||
8bf17379ac | |||
4b1225ad71 | |||
d628848af6 | |||
48381be001 | |||
b547324253 | |||
2b1599c234 | |||
7ac8989dfc | |||
cd6666ed30 | |||
5b7478438a | |||
4a830d9fb7 | |||
785fb895b4 | |||
75e801e9e6 | |||
6ffd5328a4 | |||
ed509e482b | |||
420323f43b | |||
432962792c | |||
cb193f6069 | |||
2f268b6a25 | |||
580606af14 | |||
faa1c3992b | |||
d17efef853 | |||
179d4dd493 | |||
e03c5ee4a1 | |||
e57a8abd3d | |||
5fa10390a3 | |||
e1e6f579d5 | |||
72f8e53344 | |||
9c464ec9fc | |||
1c9b296a5e | |||
|
275522584e | ||
|
804520c4bb | ||
|
9d25581f3c | ||
|
e798037d80 | ||
|
2afe5858cb | ||
f575dcdad6 | |||
6cf9967e7c | |||
15a75d790a | |||
988672ea75 | |||
6d3e8d65e1 | |||
895e4b3f18 | |||
20f0505120 | |||
31e83cac5e | |||
|
9baba88f75 | ||
d3a1115b99 | |||
6d46849fec | |||
53e324bfee | |||
2e39b7b603 | |||
048932bf50 | |||
69d325bf90 | |||
3d1b8859cd | |||
db89ca9942 | |||
bba009d98c | |||
9d954ea174 | |||
da9c9049d2 | |||
a4c00d2c56 | |||
|
b30f565871 | ||
|
fa378a1d34 | ||
|
119efb1ff4 | ||
1fb4101b49 | |||
ec8333b223 | |||
54b979aa0b | |||
ba274307c0 | |||
|
a623d0809d | ||
e00899d176 | |||
a38ca1954b | |||
3f5a19c63e | |||
525e9672e8 | |||
070c6e1cf1 | |||
195fd00e0a | |||
733d014c19 | |||
16039769d5 | |||
5eeb8ca9fc | |||
317a06bbc3 | |||
f693adcd7c | |||
ac88d2bd50 | |||
a427146de5 | |||
a16bcddeaa | |||
74edf1fc07 | |||
1e32639873 | |||
0704d2640a | |||
26a6368d79 | |||
54af66d115 | |||
850799c21a | |||
d4834d7541 | |||
2895dd9d13 | |||
eb9a0b66c4 | |||
8d0432b961 | |||
ab2c01d1c9 | |||
fffaa65b7f | |||
703be0a706 | |||
4be97ffd7c | |||
009f9211a9 | |||
109187eb6f | |||
e881705323 | |||
ea06c155a7 | |||
d4732e15a7 | |||
db6f784a1f | |||
82e3837dd9 | |||
957c5918b8 | |||
9d4c923649 | |||
24c36ef856 | |||
2783b8f693 | |||
d5a680e3c6 | |||
d1075987de | |||
e116a2392e | |||
7dd6f1f4a4 | |||
4d82c37539 | |||
801b1edfa7 | |||
c1b67e1787 | |||
70dd106549 | |||
b098aa4e65 | |||
74b784fcfb | |||
673db344d6 | |||
5594a19c02 | |||
|
a5bc13fe50 | ||
a5f2067d76 | |||
be8fa57be1 | |||
6ad9963889 | |||
bcddb05b1d | |||
f7d2033e25 | |||
6ce7649cfe | |||
cb0d8b80c3 | |||
95869f9560 | |||
e8586cf993 | |||
d195a3f86c | |||
b171afa09d | |||
5cf49bffac | |||
5659de8516 | |||
0cd2b6d549 | |||
ae092de4b6 | |||
a7e6e7c27d | |||
175a301a0d | |||
823458910b | |||
2abcb46199 | |||
75b891147a | |||
de208f004e | |||
ecb0676fea | |||
957867ff1c | |||
b1b21f000d | |||
fbbafc33be | |||
4a46de4c49 | |||
77419ea41d | |||
043500e8e8 | |||
e924ad8278 | |||
010db93b93 | |||
9fdc6eebe8 | |||
7c8d013b6e | |||
96eb0c3532 | |||
94c01ee362 | |||
4297a46f13 | |||
c07e1bbc8f | |||
9ee2df3841 | |||
3c5505d222 | |||
|
70df740f9d | ||
|
761f3253c3 | ||
787edc17af | |||
9902adab6d | |||
156b4724f3 | |||
e9575aba5c | |||
81c7f6a32a | |||
|
ab97c80b80 | ||
|
04369673ef | ||
|
63dfdc2da6 | ||
14de382129 | |||
d97c10dbe6 | |||
|
8420bf093e | ||
|
5e28074522 | ||
c842c41a78 | |||
8b93eaad59 | |||
2cba97cf1c | |||
7d74178295 | |||
c37bef55e9 | |||
837ba8b46a | |||
|
c25e73408a | ||
|
71c3172cf5 | ||
|
1f2855a107 | ||
|
d949c4375e | ||
|
22f0081303 | ||
5562be18e3 | |||
6baa891424 | |||
a544feffb3 | |||
3b6bb0df46 | |||
60299b6bb8 | |||
4d20f4e07c | |||
5f6b5f845d | |||
b0fecce0d1 | |||
|
27c06ddde7 | ||
3154d2839b | |||
|
511d8d5ed8 | ||
fe22405ee1 | |||
ea828cd13a | |||
00fa70b9de | |||
823275363c | |||
2f299ee48d | |||
284fe1b3b6 | |||
35bda8d67a | |||
7a2a5074fa | |||
ce239ab88e | |||
f3c703d655 | |||
b6ff5bc764 | |||
b8aeb1f935 | |||
9673d28d3e | |||
99a51d67a1 | |||
b0ef0590a2 | |||
256e1942f2 | |||
aa71f0dfa1 | |||
04d527c98a | |||
|
ca5c5550ab | ||
7b59621179 | |||
9d59463ded | |||
|
3d49f79beb | ||
|
e9740d13fc | ||
|
2bd5a8fe1a | ||
|
0acccae523 | ||
974112016e | |||
9fb2889696 | |||
63f22b28d7 | |||
9a72fa13d5 | |||
86a8a32032 | |||
13e01ab453 | |||
873dd77a6f | |||
544c618473 | |||
a264cb088e | |||
1a43fddca9 | |||
|
9ceb66ef21 | ||
|
7cbe38b011 | ||
|
3bbc1edb19 | ||
|
b8dac2d7cd | ||
bdfb1a3a9b | |||
9b8b3e8126 | |||
d657c17df4 | |||
|
0e1fd68d93 | ||
|
c7eceb2330 | ||
|
e143c06697 | ||
|
29da21f5dc | ||
028696d4be | |||
4022edb12e | |||
fde5044194 | |||
3af1286ab7 | |||
bcff46d3d4 | |||
d1c72cdff4 | |||
565bb59f45 | |||
aae3f31c50 | |||
0ce9b5d352 | |||
bf0e5b37ca | |||
fe620835be | |||
c7dc77e6bc | |||
05c72a3de6 | |||
0653844931 | |||
7661046bcb | |||
16888a12d4 | |||
9f7df33692 | |||
b7007aa100 | |||
03dfd0cba0 | |||
0e64d1f22f | |||
c7774450bf | |||
9375255452 | |||
b8b3a16589 | |||
e1d86c77d0 | |||
001d33eabb | |||
2845425099 | |||
c56b9ec3ce | |||
68c81577a4 | |||
b5fb8772fe | |||
5741e069ad | |||
df89ddcdf5 | |||
c9e1261af2 | |||
d5efc86d85 | |||
430b655785 | |||
1cffa358b8 | |||
ca89112a8e | |||
65f02a5a7a | |||
9ccf29903e | |||
e4b8c9748a | |||
3318c30cee | |||
b9aba98cd5 | |||
55fdc41137 | |||
c9790e5823 | |||
fa924eac15 | |||
db4e411dfd | |||
48aee1e76c | |||
2a2ace603b | |||
25f9ac71ca | |||
61e2801838 | |||
e60b8ee238 | |||
dc0ea5a59c | |||
10e704cd73 | |||
8004cc0537 | |||
0a2373f407 | |||
96f87eaf5f | |||
e9bd687b8f | |||
3ffa38cf98 | |||
a770c4bcca | |||
f648a6e698 | |||
a72a12b96d | |||
591c54b5f7 | |||
a6a54f34cf | |||
f7811961b5 | |||
ee778e1177 | |||
5787a662ed | |||
fce654f3c7 | |||
0f052c3465 | |||
c733810fdc | |||
5130cb013b | |||
991e540c11 | |||
a34d9b7b89 | |||
4e62f559fa | |||
8c3d2b6740 | |||
b6779f4d75 | |||
b036c9861f | |||
02cd773c2a | |||
3964d06f5d | |||
|
e83612a06c | ||
cf6c666b59 | |||
ee0ec370c7 | |||
ea0e35ddf0 | |||
99c8501d47 | |||
f8a1fed1f2 | |||
9ad1f7cb97 | |||
0856a96738 | |||
ee9801a8c2 | |||
cfecc11b43 | |||
3d36348563 | |||
dcbee9c7dc | |||
2d88b1197e | |||
6c12dc0d6f | |||
a4b69f29dc | |||
1680c5c448 | |||
e74fb45680 | |||
d19ab05a11 | |||
433c73b23c | |||
2aa5211886 | |||
81e7c02807 | |||
a2373f2056 | |||
ba8e4f6ac6 | |||
76acc9a5f5 | |||
92bd333552 | |||
70a451b63e | |||
cfe6c47cd7 | |||
8eeb32c495 | |||
fdcd6822c4 | |||
71390c84da | |||
84d01b1091 | |||
8f9faaa39e | |||
0898244b2a | |||
0c70feb09c | |||
f9a38e616d | |||
e511fc3c0a | |||
3ff670134c | |||
4c0160bb28 | |||
c1e0baedd3 | |||
8f7d937e26 | |||
604a6fc92b | |||
8c205fd18c | |||
41ecf897fb | |||
4c9c6e9223 | |||
8be71c4c5c | |||
01d310e630 | |||
96cb99e1b5 | |||
2e08efeed7 | |||
04fceb3134 | |||
1f0a891bab | |||
6c63a65983 | |||
199d3b7aee | |||
04fc04f586 | |||
3f96a6460a | |||
bfcaa7f6fb | |||
e2bd4c4880 | |||
ab702bba9b | |||
8afabf3ffb | |||
ebf6c60a10 | |||
9a8291d391 | |||
a6426901c5 | |||
3b7dd36aa6 | |||
dc635a6601 | |||
08ec1bd923 | |||
b78aab884e | |||
36e192ec32 | |||
510675622b | |||
651722b935 | |||
7a0d5a95c1 | |||
2c583bcae9 | |||
ab36d4418e | |||
f146c77797 | |||
d863ac570b | |||
d05fad49a1 | |||
fbbc4497ca | |||
4223586e62 | |||
c859b3ee2b | |||
8a16b0de7c | |||
9faf17634b | |||
66a62c170c | |||
5186d959bc | |||
09a8a0bda0 | |||
191f49adfc | |||
|
26b79c5763 | ||
c72841ca58 | |||
63350dab71 | |||
d110d20879 | |||
b4e58478c3 | |||
12d2acd7fd | |||
6073ebe476 | |||
5c026591cb | |||
907365ddff | |||
684953464b | |||
6b978b42bc | |||
6831337289 | |||
e40777a5d3 | |||
51690d1df3 | |||
72a06e964c | |||
9ffd402481 | |||
dee8d4bc09 | |||
6c57661797 | |||
b9ff7c5af4 | |||
072161ada2 | |||
a67b3e8a57 | |||
c9216fb444 | |||
2aac17ac5f | |||
17a403b8ce | |||
b245c11b1d | |||
2ed047515e | |||
b16e561384 | |||
|
2ebff1e887 | ||
655ee432f8 | |||
67b7b2f292 | |||
66961101c6 | |||
326af49a8f | |||
3a7ed5ee2d | |||
56fa798406 | |||
|
3fd9fae66a | ||
|
5d43168370 | ||
|
f8548fefb3 | ||
|
3565c32d51 | ||
7fab328acc | |||
a043b82b27 | |||
20652fed94 | |||
6fc52a4ec7 | |||
834bcfa02c | |||
c99ecc0a66 | |||
061e5dd832 | |||
c97ade81fa | |||
82a22fe993 | |||
dbadcf1858 | |||
ff8865c5c3 | |||
9833dee925 | |||
aac2874f8f | |||
17524b21b3 | |||
3f0befe30d | |||
76c286f95e | |||
0c415314b6 | |||
717f386077 | |||
7a841a480b | |||
43ea85b495 | |||
8a6badca1d | |||
4064803e23 | |||
2e03b075f8 | |||
fe9c125bd6 | |||
503fd57d7c | |||
e74e746213 | |||
065f9c4965 | |||
32f3c36589 | |||
c2a8d39fb4 | |||
f08cbe70fb | |||
a9630d0802 | |||
c5c6c431b5 | |||
71d78d2d72 | |||
ccecda2eff | |||
3a5f8d6139 | |||
74e0f39bc2 | |||
274978a8a7 | |||
8eea9bd6a5 | |||
626a2dd020 | |||
6b6ce221e0 | |||
d038c361c0 | |||
c05876cc60 | |||
b9c4c9a0b7 | |||
6697e804ee | |||
2c57def8f1 | |||
62b16e957b | |||
18d7bdd85c | |||
190b5dedba | |||
886e45f788 | |||
360daf2a09 | |||
7bb67dd4c6 | |||
72c4ea70c4 | |||
0ae42dd71e | |||
1df1e7eb98 | |||
9592021c48 | |||
9a9c3b340e | |||
abd64cb3fa | |||
b366a50af1 | |||
e4b9eeefc6 | |||
4d7a8557eb | |||
c23357df81 | |||
f728d5aa23 | |||
ac59563adf | |||
b2d2996077 | |||
df2337abf9 | |||
d68ab3b657 | |||
c10821c332 | |||
219cba5fc7 | |||
8e3c74958a | |||
ed08e0b166 | |||
168f2e6d16 | |||
4574f3aa4f | |||
2a11e85a95 | |||
69df100b18 | |||
920b027a32 | |||
9f8c9c228d | |||
9d8fdfe090 | |||
01956d694d | |||
09d2a1e815 | |||
ccfaedb7ad | |||
356a69f575 | |||
752efad4bf | |||
05adb224e9 | |||
bf1a3fbbe8 | |||
8b14b22b12 | |||
b8b47a45ba | |||
2b9e51cc31 | |||
d9fa0cdb45 | |||
288af4abc6 | |||
e77b2c39f9 | |||
87e5d526cb | |||
2b33dd4871 | |||
62b68cfa3e | |||
|
af14227862 | ||
|
eb0e9df6ab | ||
f1cc2ebf20 | |||
74f14c68a4 | |||
5dc5c2094e | |||
940b5842b6 | |||
d19602d06f | |||
ae85f7152e | |||
|
2cb40af62f | ||
|
569b46f0c4 | ||
|
6b0c915077 | ||
|
237ed173ee | ||
c0c6cd4fb3 | |||
1f100623a7 | |||
f137d5cc21 | |||
aea8af513b | |||
c846e52acb | |||
19e7f0df34 | |||
cd218ce025 | |||
c381f47a72 | |||
a68355cb7d | |||
f53a10825e | |||
21bbb8be1c | |||
ab44e9d2ac | |||
32497f3a6f | |||
c06c6b6f12 | |||
26335150b7 | |||
5298aacac9 | |||
|
7832399fb3 | ||
|
2b60830203 | ||
|
b9bf29ba2c | ||
00d67c270e | |||
2826fec975 | |||
29a34f5edf | |||
c100daeba5 | |||
ac66f6747e | |||
014f1ff125 | |||
c4991425ab | |||
1c770aad58 | |||
7c8912d48c | |||
67d9a0bd2c | |||
0115e2a13c | |||
e2f36611a1 | |||
9143ac97c5 | |||
b5b09d0ca2 | |||
fa79f75072 | |||
6459af419e | |||
2ff2655db0 | |||
c4ab59f7bf | |||
a62365141e | |||
5ae649bccb | |||
2095b17d06 | |||
336514b3e2 | |||
37707e1df8 | |||
57aa30c7af | |||
78c6dd5404 | |||
c101c228d7 | |||
0f6874bc0f | |||
399d89dae5 | |||
ba6b540869 | |||
249c5a5c59 | |||
e2c59230b5 | |||
1d1ace096e | |||
0381ccef64 | |||
e5a0f836a4 | |||
463915da1a | |||
ae7bc508e8 | |||
d21e0473bc | |||
df05feb766 | |||
e0dafa2093 | |||
f1e01e8b18 | |||
8a770de33e | |||
b3aeb3246f | |||
1fc3e0ee5d | |||
f2dcfbdc5f | |||
23d77ce1b4 | |||
0e6688c2bc | |||
7ef1ef688f | |||
3b8f2e8307 | |||
0af7aaef3c | |||
b8907335ba | |||
0073ca769b | |||
8a286156f6 | |||
5a39ead523 | |||
d2b4eccac2 | |||
be9b3a3857 | |||
a8e6fca128 | |||
0483133857 | |||
30d9eb5634 | |||
9fe7af3335 | |||
bedfb3d114 | |||
c19dd5ee8b | |||
6ae3bfe395 | |||
4f82e80dad | |||
8e8198546f | |||
9497e310ca | |||
02135bdbae | |||
041a341879 | |||
15dd810d67 | |||
7982f3aec0 | |||
2fb07201c7 | |||
b5ca01dc4f | |||
fa523d590e | |||
523f2f57e1 | |||
d662682fb5 | |||
ff2b06a5e8 | |||
aece305003 | |||
ef8da9bcec | |||
3cd55beab1 | |||
6766501858 | |||
d5b41683ca | |||
ff8dbe111d | |||
28d4071fac | |||
31a523755f | |||
3d1d8f1af7 | |||
167f6d0683 | |||
8580487b61 | |||
a8b1c33280 | |||
fca2a4134b | |||
f90741f4d3 | |||
ba4b45f7fb | |||
4767f3db5b | |||
709658462c | |||
c431c0ae00 | |||
6f61b5dbef | |||
c42c4b64f9 | |||
d3a36c2c9a | |||
6799e9616e | |||
|
e8d962ac44 | ||
ac1e145028 | |||
2fdf121167 | |||
dcca8b0bf2 | |||
b1f891b005 | |||
648dcc7287 | |||
2175f7dd3d | |||
aff90a52f1 | |||
0f14dee72a | |||
ae2031174e | |||
c163278c64 | |||
d10133f06f | |||
4377fc663e | |||
487e236882 | |||
|
8fc128e89b | ||
|
737f72f90f | ||
|
c3aab65521 | ||
|
972474f79a | ||
bc64d2ade0 | |||
|
eddda55fe6 | ||
|
13aca91231 | ||
|
6011242eae | ||
|
cadb5086e1 | ||
|
10a30bbf38 | ||
|
6ac7a75bab | ||
bbd11bfa26 | |||
75548fa02d | |||
fb6956009f | |||
e029117c3e | |||
bc7c01de90 | |||
cfcd8a4c20 | |||
5e17eb7ca7 | |||
|
756727ffe2 | ||
6bc602dead | |||
056c79e813 | |||
68bbf31a86 | |||
b58f380e75 | |||
48c54bf374 | |||
51da1578f4 | |||
|
488f25aed6 | ||
|
d60f58cf43 | ||
|
7a6a119829 | ||
|
f0fb019c70 | ||
|
0f98ec6b78 | ||
|
107fed6e60 | ||
|
59a9a770a5 | ||
|
20bcb26e3d | ||
d355c46250 | |||
787c927de6 | |||
d15ff7bc67 | |||
7c5c35f1b0 | |||
001b090bc6 | |||
db8207f8b9 | |||
e5918de7af | |||
d2346a543a | |||
c057b4ae5c | |||
b962bf4af9 | |||
c54dc05d92 | |||
8c72bf697e | |||
cc8cf3d12a | |||
9bdf6bde17 | |||
8363495843 | |||
bc80b1048f | |||
d61981bc1b | |||
4ccdc5dd6c | |||
3240118226 | |||
254989d63d | |||
283f2a6e46 | |||
94637dfbab | |||
3e26d7057c | |||
3f710112f3 | |||
34df41b44a | |||
3897434ef0 | |||
375dba9dd1 | |||
2edd1fb583 | |||
11326060fb | |||
d343c01737 | |||
3925f78721 | |||
d98e54a743 | |||
13143b8e4d | |||
3a7895e5ea | |||
2893b2e2d2 | |||
987436fed2 | |||
|
be82565775 | ||
|
f8d0243146 | ||
96ac66e909 | |||
e5947f3490 | |||
b35fe15703 | |||
a269b60282 | |||
fc6f7ffd73 | |||
430dc2d20b | |||
77c464870f | |||
dda38ec52b | |||
|
f6b6b36eb7 | ||
|
3986677b06 | ||
1fb048777c | |||
e9c335eecc | |||
a7c7186aa4 | |||
|
d7f82d643c | ||
|
15560a06b1 | ||
e38bd61066 | |||
b086261c3c | |||
8c098d4e17 | |||
e3a9c095c6 | |||
678bdd7915 | |||
14fc6b7281 | |||
a2555cecc5 | |||
9d6e469f79 | |||
982c0a0fcf | |||
f8cfcd4038 | |||
4d465efef1 | |||
d667160027 | |||
|
df55d972cf | ||
|
df758d828b | ||
7bc00c4e68 | |||
bfc50e269c | |||
cea71beb4d | |||
8247c0b00b | |||
f624a83e87 | |||
951e676bee | |||
281f310394 | |||
|
8c486e8d46 | ||
c029713f23 | |||
b86e2a1d5b | |||
099a6b9dcd | |||
3b13624117 | |||
fad1efcefa | |||
1701b8a2f4 | |||
608ee07940 | |||
|
a0c2a5ccec | ||
cd41d3af97 | |||
b5aafdee61 | |||
9d9e4bb44e | |||
c708283547 | |||
a4ddf95c8d | |||
ddbb396bf3 | |||
e2a7c320ac | |||
06f998fa5e | |||
c48c73d34d | |||
cfb6ab31ab | |||
|
eac15541e8 | ||
984acebff8 | |||
4cf2d125dd | |||
6701093c3b | |||
e9fdc073c6 | |||
57c791106b | |||
fcba151fad | |||
3b24f503d1 | |||
bd18fd9aa1 | |||
|
c2c5625685 | ||
|
ce6fb0bb1e | ||
|
dcfb3afdad | ||
50c91345e8 | |||
af3ecae792 | |||
|
300cfd3ba6 | ||
|
bb430fa0b7 | ||
|
80fa7965a4 | ||
9975a2d4ba | |||
|
d1735bc446 | ||
dbf1d6f420 | |||
0a0fbd0cb6 | |||
f13f53b910 | |||
6dfc04a9f6 | |||
72133d0002 | |||
6e07e9e56b | |||
e903aeb555 | |||
2792f6f4b6 | |||
|
80eb72ce49 | ||
|
2c6d0382cf | ||
|
e1bec789b0 | ||
|
5683493cae | ||
|
ae5e213b59 | ||
|
911089f334 | ||
|
6b89646c1e | ||
|
960d5ce79f | ||
|
90ed0895d6 | ||
|
7471f4f4dc | ||
|
781cf8eed5 | ||
|
236da31af6 | ||
|
1f760af880 | ||
|
62d03b776b | ||
|
37ea18a0d8 | ||
|
083dc59a8f | ||
|
a45d069cad | ||
|
fdbcd4fafd | ||
|
f3c1c925ed | ||
|
8f6a7ba39c | ||
|
f212eb4570 | ||
|
0d118e2fe1 | ||
|
c0f46ef81f | ||
|
476513b0a7 | ||
|
9a511669a8 | ||
|
a16a25a3cd | ||
|
8666fcd120 | ||
|
521ab0aedb | ||
|
1cfff674b7 | ||
88d1d19f55 | |||
0fb1da5c3a | |||
b32f88e9a6 | |||
9d2421fac5 | |||
043e288fbf | |||
32e34876e2 | |||
f12a2b3821 | |||
844b4decab | |||
53ca60596d | |||
2d2894b0f4 | |||
21d30cd8ce | |||
b38a569124 | |||
810607e84f | |||
442ddfd4e4 | |||
096103e65a | |||
60a56c337c | |||
11c1b2cc6c | |||
45db3bd913 | |||
6d76561340 | |||
00caeba067 | |||
5a34191b88 | |||
85003900d7 | |||
0c666a6bbe | |||
e4e52ebf6b | |||
4512468108 | |||
d3e3ebd63f | |||
ce616d3eb3 | |||
5837e04e6e | |||
95ca79f3f8 | |||
706fe1ffcc | |||
2774f026e8 | |||
07604a2eb5 | |||
|
03d77f5006 | ||
fdf45e0fe6 | |||
1dc9ad7a57 | |||
cc51d7b454 | |||
c439693a8f | |||
af8c097092 | |||
|
71e6dbfdca | ||
|
692cd1616b | ||
|
4e3dbea5d0 | ||
|
fd2add78bd | ||
|
e9da8ab439 | ||
|
9c22ba9d45 | ||
|
e5d3080b54 | ||
|
5995a8b592 | ||
|
bc6d006c57 | ||
|
b148d8e2e7 | ||
|
4f7d41a8cc | ||
|
5efe2e5f7a | ||
|
338f5f309d | ||
9639e695e2 | |||
d2a2bde321 | |||
c85ff686b6 | |||
48d3b3bc3e | |||
94bd01aaca | |||
|
ba51cbad6f | ||
|
511272e86d | ||
|
873f75da9f | ||
|
42d4a66493 | ||
|
9a79af6fd2 | ||
|
63f10a1871 | ||
|
9686ee9826 | ||
|
4729364e99 | ||
|
91d982c7b2 | ||
|
8b7c22440e | ||
|
761b8cc750 | ||
3bdc82c99b | |||
|
9b3d55a095 | ||
db4e9fa432 | |||
530c25c6a1 | |||
1c2cf98850 | |||
b35dbca22e | |||
a4a7f73fb7 | |||
fd0ea3d858 | |||
bbbe52f453 | |||
|
e2daf5381c | ||
9e181b8820 | |||
a6108f8319 | |||
7a2570019a | |||
c5b4e82b48 | |||
4ed72fb517 | |||
5217aa0a1d | |||
3caf91c640 | |||
eb26a5133f | |||
9e9402a3a2 | |||
bc13a4555d | |||
eaad2caf25 | |||
6143cdf2e0 | |||
2c7176d998 | |||
327b80cf56 | |||
005c9fbb83 | |||
42134fd2a5 | |||
bc85a7d9c3 | |||
7e14fd4a08 | |||
bf74d1e828 | |||
f04708e8ae | |||
80e1924e5f | |||
c7393bd7c5 | |||
664713bb13 | |||
01715fdefc | |||
ab9b24e109 | |||
34ecb1a56e | |||
e3aef38f75 | |||
ead2b76050 | |||
2f35513f6e | |||
8573c99088 | |||
dfe63332b2 | |||
767ae48c7b | |||
f4160464c0 | |||
a572b1d5f0 | |||
82587d26b5 | |||
ec98826e6d | |||
b4fcd05e8f | |||
1345ec938b | |||
227f3acaa5 | |||
c20636f597 | |||
c2d437150a | |||
9ff1467612 | |||
9218efd71a | |||
bcd244a92a | |||
7de552ed82 | |||
5cf297a4d2 | |||
d86f84eef4 | |||
83458c6c1e | |||
b862ca52a9 | |||
928f4a97de | |||
e8d79c9d38 | |||
59e1eee8ce | |||
57c8ffda35 | |||
abbe51614d | |||
171ebd213d | |||
2a240cbd09 | |||
068fa3454c | |||
6b2bcbf2ce | |||
19e46dac18 | |||
e96c863120 | |||
a30b3c84d7 | |||
0ad5dc4583 | |||
7189998f3b | |||
b6b24b8e0b | |||
8e820c6e89 | |||
c74784a37c | |||
3d940cffcf | |||
0df044b284 | |||
f576b9fb20 | |||
5e00264119 | |||
|
05eeba32fa | ||
|
61019ecd49 | ||
|
bed06d1334 | ||
|
f09f4bd1b7 | ||
|
a3b11f21bb | ||
|
69a461d9c3 | ||
|
1dfe5cfecf | ||
|
8e4550657e | ||
|
aee7fa52c3 | ||
|
d166cc84a1 | ||
|
bb7229d224 | ||
|
708cd5ead9 | ||
|
f7986cb4da | ||
|
395aeb415d | ||
|
830fb70492 | ||
|
6379a26afb | ||
|
2277013c76 | ||
|
8934e0e6bd | ||
|
59519febbc | ||
|
46fcdd356c | ||
|
9f343c45e8 | ||
|
931904f388 | ||
|
a40d0cbb5c | ||
|
9f5df9db10 | ||
|
d26ddf7015 | ||
|
9515065407 | ||
|
82a8c61cf6 | ||
|
3fae516ce4 | ||
|
33eaa765d7 | ||
|
3b3dde8413 | ||
|
118a2744fe | ||
|
2e3dceecf8 | ||
|
07fb04bb74 | ||
|
8a1dbe9dbb | ||
|
4ef3622616 | ||
|
82a704ab44 | ||
|
0cb22945fe | ||
|
d09adf9159 | ||
|
0b959c56fb | ||
|
ec29332657 | ||
|
0f6381e67b | ||
|
877b55e21d | ||
|
fa11ca665f | ||
d9d196439f | |||
a34fc4ad4f | |||
b4d52b88c1 | |||
3fc3d27361 | |||
56b86add38 | |||
a608a105e3 | |||
2e3e413f6c | |||
dfb6c09133 | |||
9636276c17 | |||
41783ff027 | |||
08b0ecd057 | |||
7e31798446 | |||
534afa6e8d | |||
b56c44a210 | |||
ef0c94fddd | |||
f14c281841 | |||
b40cefee35 | |||
ff32ccfb50 | |||
581108ab65 | |||
54e8e3efb0 | |||
4dcc63606e | |||
a396b6044d | |||
94e5d2e19f | |||
a0976eee70 | |||
61494d8c4b | |||
2b34c2dd69 | |||
afc30b87dd | |||
|
ed0a63eb0c | ||
9ba590dd90 | |||
d4bffd2c4a | |||
650f0a3e4e | |||
fd6ccf8f0a | |||
d9fe4b8723 | |||
da2e7e0411 | |||
79d6a50e44 | |||
a13a5e5d20 | |||
82743dda2b | |||
|
6f80dd1fcc | ||
1325dce493 | |||
ac21c19b7e | |||
2b4088d068 | |||
d86dc9b1d7 | |||
9982311c87 | |||
40c88d0b66 | |||
e0ee1c2f94 | |||
b4fa2780eb | |||
df86183e97 | |||
f7868dc646 | |||
e742be7693 | |||
924bc8698d | |||
5214c35b20 | |||
700e04535a | |||
fedc0bbef6 | |||
468fc5ade9 | |||
2c077db36b | |||
f80638bba4 | |||
860aa0dafd | |||
27510b3b51 | |||
96bcbbeeec | |||
8a632eb3b4 | |||
aa992c0e5d | |||
810870e3a5 | |||
d584e7b21b | |||
e93ac62c81 | |||
0d7d6c8382 | |||
5cd9ce8835 | |||
443522d526 | |||
9061e60518 | |||
d65ab434b2 | |||
cff592db82 | |||
97029e8102 | |||
|
828fd9eb10 | ||
03800d3b74 | |||
a47304e599 | |||
7b050e9fe2 | |||
687a1d0c88 | |||
e09e3c264d | |||
b56431b4e3 | |||
70ad50010d | |||
|
ca3a249bea | ||
|
4337cdc38d | ||
9f92e0bc86 | |||
98751cf8fb | |||
2f62067d96 | |||
2cb1554244 | |||
6f3c143228 | |||
9793fc6888 | |||
043cab08ae | |||
b7c83780da | |||
cff11135ff | |||
b94a4123eb | |||
8ef1c8b5d4 | |||
132d331e7c | |||
734916728c | |||
5f6ed1292d | |||
a7dc03af50 | |||
5a86a28d67 | |||
a905c6322c | |||
49ccadd470 | |||
9f0ac0ee19 | |||
7e0f839ff8 | |||
1e9ee260e7 | |||
0b7d447aaf | |||
16a9336d31 | |||
7d13836fea | |||
b645c4d57e | |||
5db43cd908 | |||
93cd421ca3 | |||
ec7130dac6 | |||
f2b8cc530c | |||
de765088d1 | |||
|
e11188aa99 | ||
0c6699c3c6 | |||
c5858be6b8 | |||
ffe00c7b1f | |||
43114959fd | |||
b1c3ffd729 | |||
4f1a9e95a2 | |||
f6a4f55384 | |||
672b179446 | |||
3111387e5a | |||
f8fda269f1 | |||
fbac593739 | |||
c80e54dff5 | |||
4a86b2479e | |||
7bb2552d0f | |||
ad21640cd9 | |||
e4aad4e645 | |||
adf44ba141 | |||
8707b194fd | |||
77bb7c4aba | |||
7383fdd0c0 | |||
f4201d946a | |||
d5b5f1fddd | |||
910d660732 | |||
ab4ad3a1bb | |||
13b27101f1 | |||
44b5d0dcff | |||
df54b3711f | |||
197288453f | |||
00d5691a13 | |||
561b6684ce | |||
a13bb3154d | |||
fd9d3faf9f | |||
f6cc467e95 | |||
ef978c1230 | |||
52af598473 | |||
2acacd46c2 | |||
4b2f9ddb40 | |||
0d3dc4eba2 | |||
824faa8091 | |||
d10cdfdf57 | |||
5e911793ce | |||
8c87c9aeb7 | |||
9da5998a5c | |||
08943dadca | |||
7fac7226c5 | |||
9686c8ebf9 | |||
4bf96d0ec9 | |||
34add82bee | |||
f46e7e8c4b | |||
3baf254251 | |||
10ca9ea827 | |||
4a50c8ecb7 | |||
47d9766c78 | |||
45ab69960f | |||
d3505d4ee6 | |||
9297d1a2f8 | |||
56feb7c09e | |||
bede4b8712 | |||
95c1c55f22 | |||
f547a6eb68 | |||
|
453a29fdf7 | ||
|
1a5f0259f4 | ||
|
d6fa61e223 | ||
eab82b5d63 | |||
c455b521a9 | |||
b4f9e12293 | |||
bbd353ea3a | |||
4189c5de69 | |||
dee3218723 | |||
3c803a9f58 | |||
a9b0c0fbc9 | |||
38b6c918f9 | |||
6e584c96c4 | |||
20338f7d14 | |||
1a995a5d63 | |||
f964382175 | |||
0c7f60fae6 | |||
413e63d1ca | |||
8b000f4e48 | |||
b0522507be | |||
d4bcf7021e | |||
48cf0b1f67 | |||
d82e189c01 | |||
e5a60d1b9a | |||
ff067351cb | |||
345712a617 | |||
118dac6907 | |||
5ca40caf81 | |||
d858187fd4 | |||
bd65517df1 | |||
b1acad6c95 | |||
a8333281ac | |||
2fdb08ac00 | |||
|
bd4e5a2314 | ||
34ed317b6b | |||
|
14661502ab | ||
097754ffdf | |||
|
f26ec6d295 | ||
858d430845 | |||
5134eccbf8 | |||
28b4737758 | |||
|
5c43ff4c9e | ||
|
53db68e39f | ||
9e628e34dd | |||
|
62d5d53232 | ||
|
56569a0698 | ||
|
ef44f818d0 | ||
|
8944ed6e36 | ||
51805b27aa | |||
0ec64510b3 | |||
20152443da | |||
|
7c8929fe9f | ||
5617516c93 | |||
f6fe08367d | |||
a5f02133e2 | |||
|
8ed9b4432d | ||
|
db1d05e8ad | ||
eae58137c8 | |||
b0f90c096f | |||
e8361c564a | |||
|
54db9c9a92 | ||
|
73db341dc8 | ||
5fd30b412b | |||
|
bbe2e87640 | ||
|
67f59f6895 | ||
|
3e2df2e111 | ||
824d2149c6 | |||
|
c86dbe043b | ||
|
8043ac7f51 | ||
|
ead9d31647 | ||
|
a08e624309 | ||
b20371c3ac | |||
0589a7cbcc | |||
cf48961063 | |||
6046582b9c | |||
82aa6c70ea | |||
e829bd8235 | |||
66f989e691 | |||
eebb91fbb0 | |||
1d3e88bdfe | |||
fbb03dee7e | |||
|
88e5afb70f | ||
67eabfd3af | |||
cd1dd8c29e | |||
08ddb591b7 | |||
3e841b3c68 | |||
53f5a08924 | |||
d368863c3d | |||
c76cce5830 | |||
4fef93b7b1 | |||
241dadbeb5 | |||
12459c2544 | |||
e250d6013f | |||
0d41d180d6 | |||
|
ef251ce17e | ||
956e11c3f8 | |||
951b0843b2 | |||
a4e4080a1b | |||
2aa91c5d91 | |||
6471b3877f | |||
778ee142d5 | |||
1140132a25 | |||
c5c299179d | |||
0ce4549eb8 | |||
97d568ddd6 | |||
ea58465240 | |||
7afd262b1b | |||
34ceaa0823 | |||
57c34a07f2 | |||
73d1d97f1f | |||
f7ed1a4bde | |||
bdd80d0229 | |||
0238f70c64 | |||
24ff430c45 | |||
281fb14d4c | |||
03bac93929 | |||
1ae0c2a654 | |||
8140936bd3 | |||
8786acf476 | |||
c460d4c743 | |||
5294adf0d7 | |||
00f3fa35fd | |||
9c9aa4f9c0 | |||
e23a187cc4 | |||
3e429945dc | |||
8be2a8eed7 | |||
6b65167581 | |||
9d7914e69a | |||
6c62884b24 | |||
965d2a3ba8 | |||
40a1cc98c6 | |||
4c2d4ee6bd | |||
9276664465 | |||
a94bcdb92d | |||
5da5fabfef | |||
05cc55c52d | |||
571df1349c | |||
cbbb75062c | |||
bb7c4205db | |||
b2027f1625 | |||
65945c87df | |||
081582d3e1 | |||
bf240af518 | |||
a269131e2d | |||
59ece98fdc | |||
563924ff26 | |||
8ee3f55428 | |||
93c17607b5 | |||
8b4c239444 | |||
8bef17bf59 | |||
a649146a39 | |||
9d6a5313ab | |||
de09c950d5 | |||
47838b1bd9 | |||
02b360e2a9 | |||
c10ab15e0c | |||
46f3da1a94 | |||
7ec9d90aab | |||
326bf510c9 | |||
ce3d1f4309 | |||
b31ba883e4 | |||
e5d1c04616 | |||
34ff0ed9cf | |||
85bd87d5f3 | |||
8b274214af | |||
069e3102f4 | |||
8623b32721 | |||
6342e8edf0 | |||
bbd8f0c84c | |||
873c951d6e | |||
d9c864d3c5 | |||
4280d7109a | |||
c8855c068f | |||
90503061e9 | |||
672ebf6426 | |||
fd76fde23a | |||
e24c9a3ffe | |||
2641d50c21 | |||
202f3ea3ba | |||
4f09e3ff7e | |||
1148219130 | |||
4b47800dfb | |||
e2c4db9132 | |||
90af68b211 | |||
80603662b4 | |||
d2c5d4dfd9 | |||
6f1b8b4041 | |||
f63b2bf744 | |||
71cb75c170 | |||
dac64f5718 | |||
27b2d2ac7d | |||
47142dd376 | |||
d071a7e51b | |||
5c45884f5f | |||
cafedd73a2 | |||
7163b77837 | |||
122c54b51e | |||
b9d7d7d007 | |||
9050c9792a | |||
aac8f760ad | |||
7d334c18f5 | |||
86b0e4b31b | |||
af811f3dbc | |||
d30d2ac8a5 | |||
86a4b10de6 | |||
cfa7049ab9 | |||
391676e90a | |||
34e4ece8b5 | |||
cf6443d83f | |||
846cf92fa4 | |||
ab568901f8 | |||
bfda95c0d6 | |||
fb1875ee5b | |||
185d4f869b | |||
2ac8b61aa8 | |||
8739cb4656 | |||
826900cc41 | |||
ec6bbdbf06 | |||
15a188c501 | |||
b5440fc7d2 | |||
4b21adadf1 | |||
78ae77780b | |||
ccb95bcbee | |||
21ac670bbe | |||
8b54dee66c | |||
dad926f3ba | |||
a298d949b5 | |||
e1cf11f9d4 | |||
a046f16308 | |||
97cd43792d | |||
08693e6d3a | |||
e2227da8d2 | |||
5f20e4c583 | |||
f82f1a12dd | |||
53148fd1c9 | |||
8985101b2a | |||
d1949c8490 | |||
b7faae1203 | |||
b6a9d35c3e | |||
6cb6c7a448 | |||
22a5ad739e | |||
14c91bdd78 | |||
2c638cd2e2 | |||
9e59f484e3 | |||
ac8419ecb2 | |||
3ecdb63063 | |||
cfe24428fa |
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = LF
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.hs]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
max_line_length = 80
|
4946
.github/ghc-8.10.3-linux.alpine.files
vendored
Normal file
4946
.github/ghc-8.10.3-linux.alpine.files
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8734
.github/ghc-8.10.3-linux.files
vendored
Normal file
8734
.github/ghc-8.10.3-linux.files
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10321
.github/ghc-8.10.3-windows.files
vendored
Normal file
10321
.github/ghc-8.10.3-windows.files
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
.github/ghcup-run.files
vendored
Normal file
37
.github/ghcup-run.files
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
.
|
||||||
|
./cabal
|
||||||
|
./ghc
|
||||||
|
./ghc-8.10.7
|
||||||
|
./ghc-pkg
|
||||||
|
./ghc-pkg-8.10.7
|
||||||
|
./ghci
|
||||||
|
./ghci-8.10.7
|
||||||
|
./haddock
|
||||||
|
./haddock-8.10.7
|
||||||
|
./haskell-language-server-8.10.6
|
||||||
|
./haskell-language-server-8.10.6~1.6.1.0
|
||||||
|
./haskell-language-server-8.10.7
|
||||||
|
./haskell-language-server-8.10.7~1.6.1.0
|
||||||
|
./haskell-language-server-8.6.5
|
||||||
|
./haskell-language-server-8.6.5~1.6.1.0
|
||||||
|
./haskell-language-server-8.8.4
|
||||||
|
./haskell-language-server-8.8.4~1.6.1.0
|
||||||
|
./haskell-language-server-9.0.1
|
||||||
|
./haskell-language-server-9.0.1~1.6.1.0
|
||||||
|
./haskell-language-server-9.0.2
|
||||||
|
./haskell-language-server-9.0.2~1.6.1.0
|
||||||
|
./haskell-language-server-9.2.1
|
||||||
|
./haskell-language-server-9.2.1~1.6.1.0
|
||||||
|
./haskell-language-server-wrapper
|
||||||
|
./haskell-language-server-wrapper-1.6.1.0
|
||||||
|
./hp2ps
|
||||||
|
./hp2ps-8.10.7
|
||||||
|
./hpc
|
||||||
|
./hpc-8.10.7
|
||||||
|
./hsc2hs
|
||||||
|
./hsc2hs-8.10.7
|
||||||
|
./runghc
|
||||||
|
./runghc-8.10.7
|
||||||
|
./runhaskell
|
||||||
|
./runhaskell-8.10.7
|
||||||
|
./stack
|
31
.github/ghcup-run.files.alpine
vendored
Normal file
31
.github/ghcup-run.files.alpine
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
.
|
||||||
|
./cabal
|
||||||
|
./ghc
|
||||||
|
./ghc-8.10.7
|
||||||
|
./ghc-pkg
|
||||||
|
./ghc-pkg-8.10.7
|
||||||
|
./ghci
|
||||||
|
./ghci-8.10.7
|
||||||
|
./haddock
|
||||||
|
./haddock-8.10.7
|
||||||
|
./haskell-language-server-8.10.7
|
||||||
|
./haskell-language-server-8.10.7~1.6.1.0
|
||||||
|
./haskell-language-server-8.8.4
|
||||||
|
./haskell-language-server-8.8.4~1.6.1.0
|
||||||
|
./haskell-language-server-9.0.2
|
||||||
|
./haskell-language-server-9.0.2~1.6.1.0
|
||||||
|
./haskell-language-server-9.2.1
|
||||||
|
./haskell-language-server-9.2.1~1.6.1.0
|
||||||
|
./haskell-language-server-wrapper
|
||||||
|
./haskell-language-server-wrapper-1.6.1.0
|
||||||
|
./hp2ps
|
||||||
|
./hp2ps-8.10.7
|
||||||
|
./hpc
|
||||||
|
./hpc-8.10.7
|
||||||
|
./hsc2hs
|
||||||
|
./hsc2hs-8.10.7
|
||||||
|
./runghc
|
||||||
|
./runghc-8.10.7
|
||||||
|
./runhaskell
|
||||||
|
./runhaskell-8.10.7
|
||||||
|
./stack
|
81
.github/ghcup-run.files.windows
vendored
Normal file
81
.github/ghcup-run.files.windows
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
.
|
||||||
|
./cabal.exe
|
||||||
|
./cabal.shim
|
||||||
|
./ghc-8.10.7.exe
|
||||||
|
./ghc-8.10.7.shim
|
||||||
|
./ghc-pkg-8.10.7.exe
|
||||||
|
./ghc-pkg-8.10.7.shim
|
||||||
|
./ghc-pkg.exe
|
||||||
|
./ghc-pkg.shim
|
||||||
|
./ghc.exe
|
||||||
|
./ghc.shim
|
||||||
|
./ghci-8.10.7.exe
|
||||||
|
./ghci-8.10.7.shim
|
||||||
|
./ghci.exe
|
||||||
|
./ghci.shim
|
||||||
|
./ghcii-8.10.7.sh-8.10.7.exe
|
||||||
|
./ghcii-8.10.7.sh-8.10.7.shim
|
||||||
|
./ghcii-8.10.7.sh.exe
|
||||||
|
./ghcii-8.10.7.sh.shim
|
||||||
|
./ghcii.sh-8.10.7.exe
|
||||||
|
./ghcii.sh-8.10.7.shim
|
||||||
|
./ghcii.sh.exe
|
||||||
|
./ghcii.sh.shim
|
||||||
|
./haddock-8.10.7.exe
|
||||||
|
./haddock-8.10.7.shim
|
||||||
|
./haddock.exe
|
||||||
|
./haddock.shim
|
||||||
|
./haskell-language-server-8.10.6.exe
|
||||||
|
./haskell-language-server-8.10.6.shim
|
||||||
|
./haskell-language-server-8.10.6~1.6.1.0.exe
|
||||||
|
./haskell-language-server-8.10.6~1.6.1.0.shim
|
||||||
|
./haskell-language-server-8.10.7.exe
|
||||||
|
./haskell-language-server-8.10.7.shim
|
||||||
|
./haskell-language-server-8.10.7~1.6.1.0.exe
|
||||||
|
./haskell-language-server-8.10.7~1.6.1.0.shim
|
||||||
|
./haskell-language-server-8.6.5.exe
|
||||||
|
./haskell-language-server-8.6.5.shim
|
||||||
|
./haskell-language-server-8.6.5~1.6.1.0.exe
|
||||||
|
./haskell-language-server-8.6.5~1.6.1.0.shim
|
||||||
|
./haskell-language-server-8.8.4.exe
|
||||||
|
./haskell-language-server-8.8.4.shim
|
||||||
|
./haskell-language-server-8.8.4~1.6.1.0.exe
|
||||||
|
./haskell-language-server-8.8.4~1.6.1.0.shim
|
||||||
|
./haskell-language-server-9.0.1.exe
|
||||||
|
./haskell-language-server-9.0.1.shim
|
||||||
|
./haskell-language-server-9.0.1~1.6.1.0.exe
|
||||||
|
./haskell-language-server-9.0.1~1.6.1.0.shim
|
||||||
|
./haskell-language-server-9.0.2.exe
|
||||||
|
./haskell-language-server-9.0.2.shim
|
||||||
|
./haskell-language-server-9.0.2~1.6.1.0.exe
|
||||||
|
./haskell-language-server-9.0.2~1.6.1.0.shim
|
||||||
|
./haskell-language-server-9.2.1.exe
|
||||||
|
./haskell-language-server-9.2.1.shim
|
||||||
|
./haskell-language-server-9.2.1~1.6.1.0.exe
|
||||||
|
./haskell-language-server-9.2.1~1.6.1.0.shim
|
||||||
|
./haskell-language-server-wrapper-1.6.1.0.exe
|
||||||
|
./haskell-language-server-wrapper-1.6.1.0.shim
|
||||||
|
./haskell-language-server-wrapper.exe
|
||||||
|
./haskell-language-server-wrapper.shim
|
||||||
|
./hp2ps-8.10.7.exe
|
||||||
|
./hp2ps-8.10.7.shim
|
||||||
|
./hp2ps.exe
|
||||||
|
./hp2ps.shim
|
||||||
|
./hpc-8.10.7.exe
|
||||||
|
./hpc-8.10.7.shim
|
||||||
|
./hpc.exe
|
||||||
|
./hpc.shim
|
||||||
|
./hsc2hs-8.10.7.exe
|
||||||
|
./hsc2hs-8.10.7.shim
|
||||||
|
./hsc2hs.exe
|
||||||
|
./hsc2hs.shim
|
||||||
|
./runghc-8.10.7.exe
|
||||||
|
./runghc-8.10.7.shim
|
||||||
|
./runghc.exe
|
||||||
|
./runghc.shim
|
||||||
|
./runhaskell-8.10.7.exe
|
||||||
|
./runhaskell-8.10.7.shim
|
||||||
|
./runhaskell.exe
|
||||||
|
./runhaskell.shim
|
||||||
|
./stack.exe
|
||||||
|
./stack.shim
|
109
.github/release.yaml
vendored
Normal file
109
.github/release.yaml
vendored
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
name: Create Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
draft_release:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ github.ref }}
|
||||||
|
body: |
|
||||||
|
Changes in this Release
|
||||||
|
- First Change
|
||||||
|
- Second Change
|
||||||
|
draft: true
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
release-mac:
|
||||||
|
name: Create Release for macOS
|
||||||
|
needs: draft_release
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- macOS-10.15
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: haskell/actions/setup@v1.2
|
||||||
|
with:
|
||||||
|
ghc-version: 8.10.4
|
||||||
|
cabal-version: 3.4.0.0
|
||||||
|
|
||||||
|
- name: create ~/.local/bin
|
||||||
|
run: mkdir -p "$HOME/.local/bin"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Add ~/.local/bin to PATH
|
||||||
|
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Update cabal cache
|
||||||
|
run: cabal update
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Install cabal dependencies
|
||||||
|
run: cabal build --only-dependencies
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cabal build -w ghc-${GHC_VERSION} --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" -ftui
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: cp "$(cabal list-bin exe:ghcup)" ~/.local/bin/ghcup
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Strip
|
||||||
|
run: strip ~/.local/bin/ghcup
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: cabal test --constraint="zlib +bundled-c-zlib" --constraint="lzma +static" all
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Install git
|
||||||
|
run: brew install git
|
||||||
|
|
||||||
|
- name: set HOME
|
||||||
|
run: echo "HOME=$HOME" >> $GITHUB_ENV
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Set ASSET_PATH
|
||||||
|
run: echo "ASSET_PATH=$HOME/.local/bin/ghcup" >> $GITHUB_ENV
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Upload Release Asset
|
||||||
|
id: upload-release-asset
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ needs.draft_release.outputs.upload_url }}
|
||||||
|
asset_path: ${{ env.ASSET_PATH }}
|
||||||
|
asset_name: ghcup-${{ matrix.os }}
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
|
- if: always()
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: plan.json
|
||||||
|
path: ./dist-newstyle/cache/plan.json
|
||||||
|
|
18
.github/scripts/bootstrap.sh
vendored
Normal file
18
.github/scripts/bootstrap.sh
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
. .github/scripts/env.sh
|
||||||
|
|
||||||
|
mkdir -p "$CI_PROJECT_DIR"/.local/bin
|
||||||
|
|
||||||
|
git describe --always
|
||||||
|
|
||||||
|
### build
|
||||||
|
|
||||||
|
./scripts/bootstrap/bootstrap-haskell
|
||||||
|
|
||||||
|
[ "$(ghc --numeric-version)" = "${BOOTSTRAP_HASKELL_GHC_VERSION}" ]
|
||||||
|
# https://github.com/actions/runner-images/issues/7061
|
||||||
|
[ "$(ghcup config | grep --color=never meta-mode)" = "meta-mode: Lax" ]
|
||||||
|
|
27
.github/scripts/brew.sh
vendored
Normal file
27
.github/scripts/brew.sh
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
. .github/scripts/env.sh
|
||||||
|
|
||||||
|
if [ -e "$HOME/.brew" ] ; then
|
||||||
|
(
|
||||||
|
cd "$HOME/.brew"
|
||||||
|
git fetch --depth 1
|
||||||
|
git reset --hard origin/master
|
||||||
|
)
|
||||||
|
else
|
||||||
|
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
|
||||||
|
fi
|
||||||
|
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
|
||||||
|
|
||||||
|
mkdir -p $CI_PROJECT_DIR/.brew_cache
|
||||||
|
export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache
|
||||||
|
mkdir -p $CI_PROJECT_DIR/.brew_logs
|
||||||
|
export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs
|
||||||
|
mkdir -p /private/tmp/.brew_tmp
|
||||||
|
export HOMEBREW_TEMP=/private/tmp/.brew_tmp
|
||||||
|
|
||||||
|
brew update
|
||||||
|
brew install ${1+"$@"}
|
||||||
|
|
37
.github/scripts/build.sh
vendored
Normal file
37
.github/scripts/build.sh
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
. .github/scripts/common.sh
|
||||||
|
|
||||||
|
git_describe
|
||||||
|
|
||||||
|
# ensure ghcup
|
||||||
|
install_ghcup
|
||||||
|
|
||||||
|
# ensure cabal-cache
|
||||||
|
download_cabal_cache "$HOME/.local/bin/cabal-cache"
|
||||||
|
|
||||||
|
# install toolchain (if necessary)
|
||||||
|
ghcup -v install ghc --set --force "$GHC_VER"
|
||||||
|
ghcup -v install cabal --force "$CABAL_VER"
|
||||||
|
ghc --version
|
||||||
|
cabal --version
|
||||||
|
GHC="ghc-${GHC_VER}"
|
||||||
|
|
||||||
|
# build
|
||||||
|
ecabal update
|
||||||
|
build_with_cache --project-file=cabal.project.release -w "${GHC}" --enable-tests
|
||||||
|
|
||||||
|
# set up artifacts
|
||||||
|
mkdir -p out
|
||||||
|
binary=$(cabal --project-file=cabal.project.release list-bin ghcup)
|
||||||
|
binary_test=$(cabal --project-file=cabal.project.release list-bin ghcup-test)
|
||||||
|
binary_opttest=$(cabal --project-file=cabal.project.release list-bin ghcup-optparse-test)
|
||||||
|
ver=$("${binary}" --numeric-version)
|
||||||
|
strip_binary "${binary}"
|
||||||
|
cp "${binary}" "out/${ARTIFACT}-${ver}${ext}"
|
||||||
|
cp "${binary_test}" "out/test-${ARTIFACT}-${ver}${ext}"
|
||||||
|
cp "${binary_opttest}" "out/test-optparse-${ARTIFACT}-${ver}${ext}"
|
||||||
|
cp ./dist-newstyle/cache/plan.json "out/${ARTIFACT}.plan.json"
|
||||||
|
|
13
.github/scripts/cabal-cache.sh
vendored
Normal file
13
.github/scripts/cabal-cache.sh
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
case "$(uname -s)" in
|
||||||
|
MSYS_*|MINGW*)
|
||||||
|
ext=".exe"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ext=""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "cabal-cache disabled (CABAL_CACHE_DISABLE set)"
|
||||||
|
|
174
.github/scripts/common.sh
vendored
Normal file
174
.github/scripts/common.sh
vendored
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. .github/scripts/env.sh
|
||||||
|
|
||||||
|
ecabal() {
|
||||||
|
cabal "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
nonfatal() {
|
||||||
|
"$@" || "$* failed"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_from() {
|
||||||
|
if [ "${RUNNER_OS}" != "Windows" ] ; then
|
||||||
|
cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cabal-cache.sh sync-from-archive \
|
||||||
|
--host-name-override=${S3_HOST} \
|
||||||
|
--host-port-override=443 \
|
||||||
|
--host-ssl-override=True \
|
||||||
|
--region us-west-2 \
|
||||||
|
$([ "${RUNNER_OS}" != "Windows" ] && echo --store-path="$cabal_store_path") \
|
||||||
|
--archive-uri "s3://ghcup-hs/${RUNNER_OS}-${ARCH}-${DISTRO}"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_to() {
|
||||||
|
if [ "${RUNNER_OS}" != "Windows" ] ; then
|
||||||
|
cabal_store_path="$(dirname "$(cabal help user-config | tail -n 1 | xargs)")/store"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cabal-cache.sh sync-to-archive \
|
||||||
|
--host-name-override=${S3_HOST} \
|
||||||
|
--host-port-override=443 \
|
||||||
|
--host-ssl-override=True \
|
||||||
|
--region us-west-2 \
|
||||||
|
$([ "${RUNNER_OS}" != "Windows" ] && echo --store-path="$cabal_store_path") \
|
||||||
|
--archive-uri "s3://ghcup-hs/${RUNNER_OS}-${ARCH}-${DISTRO}"
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_eghcup() {
|
||||||
|
"$GHCUP_BIN/ghcup${ext}" -v -c "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
eghcup() {
|
||||||
|
if [ "${OS}" = "Windows" ] ; then
|
||||||
|
"$GHCUP_BIN/ghcup${ext}" -c -s "file:${GITHUB_WORKSPACE//\\//}/data/metadata/ghcup-${JSON_VERSION}.yaml" "$@"
|
||||||
|
else
|
||||||
|
"$GHCUP_BIN/ghcup${ext}" -c -s "file://$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sha_sum() {
|
||||||
|
if [ "${OS}" = "FreeBSD" ] ; then
|
||||||
|
sha256 "$@"
|
||||||
|
else
|
||||||
|
sha256sum "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
git_describe() {
|
||||||
|
git config --global --get-all safe.directory | grep '^\*$' || git config --global --add safe.directory "*"
|
||||||
|
git describe --always
|
||||||
|
}
|
||||||
|
|
||||||
|
download_cabal_cache() {
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
mkdir -p "$HOME/.local/bin"
|
||||||
|
dest="$HOME/.local/bin/cabal-cache"
|
||||||
|
url=""
|
||||||
|
exe=""
|
||||||
|
cd /tmp
|
||||||
|
case "${RUNNER_OS}" in
|
||||||
|
"Linux")
|
||||||
|
case "${ARCH}" in
|
||||||
|
"32") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/i386-linux-cabal-cache
|
||||||
|
;;
|
||||||
|
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-linux-cabal-cache
|
||||||
|
;;
|
||||||
|
"ARM64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/aarch64-linux-cabal-cache
|
||||||
|
;;
|
||||||
|
"ARM") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/armv7-linux-cabal-cache
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
"FreeBSD")
|
||||||
|
url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-portbld-freebsd-cabal-cache
|
||||||
|
;;
|
||||||
|
"Windows")
|
||||||
|
exe=".exe"
|
||||||
|
url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-mingw64-cabal-cache
|
||||||
|
;;
|
||||||
|
"macOS")
|
||||||
|
case "${ARCH}" in
|
||||||
|
"ARM64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/aarch64-apple-darwin-cabal-cache
|
||||||
|
;;
|
||||||
|
"64") url=https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal-cache/experimental5/x86_64-apple-darwin-cabal-cache
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -n "${url}" ] ; then
|
||||||
|
case "${url##*.}" in
|
||||||
|
"gz")
|
||||||
|
curl -L -o - "${url}" | gunzip > cabal-cache${exe}
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
curl -o cabal-cache${exe} -L "${url}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
sha_sum cabal-cache${exe}
|
||||||
|
mv "cabal-cache${exe}" "${dest}${exe}"
|
||||||
|
chmod +x "${dest}${exe}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# install shell wrapper
|
||||||
|
cp "${CI_PROJECT_DIR}"/.github/scripts/cabal-cache.sh "$HOME"/.local/bin/
|
||||||
|
chmod +x "$HOME"/.local/bin/cabal-cache.sh
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
build_with_cache() {
|
||||||
|
ecabal configure "$@"
|
||||||
|
ecabal build --dependencies-only "$@" --dry-run
|
||||||
|
sync_from
|
||||||
|
ecabal build --dependencies-only "$@" || sync_to
|
||||||
|
sync_to
|
||||||
|
ecabal build "$@"
|
||||||
|
sync_to
|
||||||
|
}
|
||||||
|
|
||||||
|
install_ghcup() {
|
||||||
|
case "${RUNNER_OS}" in
|
||||||
|
"Linux")
|
||||||
|
case "${ARCH}" in
|
||||||
|
"ARM"*)
|
||||||
|
if command -v ghcup ; then
|
||||||
|
mkdir -p "$GHCUP_BIN"
|
||||||
|
cp "$(command -v ghcup)" "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
else
|
||||||
|
install_ghcup_curl_sh
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*) install_ghcup_curl_sh
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*) install_ghcup_curl_sh
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
install_ghcup_curl_sh() {
|
||||||
|
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=yes sh
|
||||||
|
}
|
||||||
|
|
||||||
|
strip_binary() {
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
local binary=$1
|
||||||
|
case "$(uname -s)" in
|
||||||
|
"Darwin"|"darwin")
|
||||||
|
;;
|
||||||
|
MSYS_*|MINGW*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
strip -s "${binary}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
)
|
||||||
|
}
|
74
.github/scripts/cross.sh
vendored
Normal file
74
.github/scripts/cross.sh
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
. .github/scripts/common.sh
|
||||||
|
|
||||||
|
run() {
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "${OS}" = "Windows" ] ; then
|
||||||
|
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/ghcup
|
||||||
|
else
|
||||||
|
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup
|
||||||
|
fi
|
||||||
|
|
||||||
|
git_describe
|
||||||
|
|
||||||
|
rm -rf "${GHCUP_DIR}"
|
||||||
|
mkdir -p "${GHCUP_BIN}"
|
||||||
|
|
||||||
|
cp "out/${ARTIFACT}"-* "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
cp "out/test-${ARTIFACT}"-* "ghcup-test${ext}"
|
||||||
|
chmod +x "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
chmod +x "ghcup-test${ext}"
|
||||||
|
|
||||||
|
"$GHCUP_BIN/ghcup${ext}" --version
|
||||||
|
eghcup --version
|
||||||
|
sha_sum "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
sha_sum "$(raw_eghcup --offline whereis ghcup)"
|
||||||
|
|
||||||
|
|
||||||
|
### cross build
|
||||||
|
|
||||||
|
eghcup --numeric-version
|
||||||
|
|
||||||
|
eghcup install ghc "${GHC_VER}"
|
||||||
|
eghcup set ghc "${GHC_VER}"
|
||||||
|
eghcup install cabal "${CABAL_VER}"
|
||||||
|
|
||||||
|
cabal --version
|
||||||
|
|
||||||
|
eghcup debug-info
|
||||||
|
|
||||||
|
ecabal update
|
||||||
|
|
||||||
|
"${WRAPPER}" "$GHCUP_BIN/ghcup${ext}" -c -s "file://$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml" -v \
|
||||||
|
compile ghc \
|
||||||
|
$(if [ -n "${HADRIAN_FLAVOUR}" ] ; then printf "%s" "--flavour=${HADRIAN_FLAVOUR}" ; else true ; fi) \
|
||||||
|
-j "$(nproc)" \
|
||||||
|
-v "${GHC_TARGET_VERSION}" \
|
||||||
|
-b "${GHC_VER}" \
|
||||||
|
-x "${CROSS}" \
|
||||||
|
-- ${BUILD_CONF_ARGS}
|
||||||
|
eghcup set ghc "${CROSS}-${GHC_TARGET_VERSION}"
|
||||||
|
|
||||||
|
[ "$($(eghcup whereis ghc "${CROSS}-${GHC_TARGET_VERSION}") --numeric-version)" = "${GHC_TARGET_VERSION}" ]
|
||||||
|
|
||||||
|
# test that doing fishy symlinks into GHCup dir doesn't cause weird stuff on 'ghcup nuke'
|
||||||
|
mkdir no_nuke/
|
||||||
|
mkdir no_nuke/bar
|
||||||
|
echo 'foo' > no_nuke/file
|
||||||
|
echo 'bar' > no_nuke/bar/file
|
||||||
|
ln -s "$CI_PROJECT_DIR"/no_nuke/ "${GHCUP_DIR}"/cache/no_nuke
|
||||||
|
ln -s "$CI_PROJECT_DIR"/no_nuke/ "${GHCUP_DIR}"/logs/no_nuke
|
||||||
|
|
||||||
|
# nuke
|
||||||
|
eghcup nuke
|
||||||
|
[ ! -e "${GHCUP_DIR}" ]
|
||||||
|
|
||||||
|
# make sure nuke doesn't resolve symlinks
|
||||||
|
[ -e "$CI_PROJECT_DIR"/no_nuke/file ]
|
||||||
|
[ -e "$CI_PROJECT_DIR"/no_nuke/bar/file ]
|
||||||
|
|
34
.github/scripts/env.sh
vendored
Normal file
34
.github/scripts/env.sh
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "${RUNNER_OS}" = "Windows" ] ; then
|
||||||
|
ext=".exe"
|
||||||
|
else
|
||||||
|
ext=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
export TZ=Asia/Singapore
|
||||||
|
|
||||||
|
if [ "${RUNNER_OS}" = "freebsd" ] ; then
|
||||||
|
export RUNNER_OS=FreeBSD
|
||||||
|
fi
|
||||||
|
|
||||||
|
export OS="$RUNNER_OS"
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
|
if [ "${RUNNER_OS}" = "Windows" ] ; then
|
||||||
|
# on windows use pwd to get unix style path
|
||||||
|
CI_PROJECT_DIR="$(pwd)"
|
||||||
|
export CI_PROJECT_DIR
|
||||||
|
export GHCUP_INSTALL_BASE_PREFIX="/c"
|
||||||
|
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/ghcup/bin"
|
||||||
|
export PATH="$GHCUP_BIN:$PATH"
|
||||||
|
export CABAL_DIR="C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
|
||||||
|
else
|
||||||
|
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
|
||||||
|
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
|
||||||
|
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin"
|
||||||
|
export PATH="$GHCUP_BIN:$PATH"
|
||||||
|
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
|
||||||
|
export CABAL_CACHE="$CI_PROJECT_DIR/cabal-cache"
|
||||||
|
fi
|
72
.github/scripts/hls.sh
vendored
Normal file
72
.github/scripts/hls.sh
vendored
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
. .github/scripts/common.sh
|
||||||
|
|
||||||
|
mkdir -p "$CI_PROJECT_DIR"/.local/bin
|
||||||
|
|
||||||
|
### build
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${OS}" = "Windows" ] ; then
|
||||||
|
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/ghcup
|
||||||
|
else
|
||||||
|
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "${GHCUP_DIR}"
|
||||||
|
mkdir -p "${GHCUP_BIN}"
|
||||||
|
|
||||||
|
ls -lah out
|
||||||
|
find out
|
||||||
|
cp "out/${ARTIFACT}"-* "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
chmod +x "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
echo "$PATH"
|
||||||
|
|
||||||
|
"$GHCUP_BIN/ghcup${ext}" --version
|
||||||
|
eghcup --version
|
||||||
|
sha_sum "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
sha_sum "$(raw_eghcup --offline whereis ghcup)"
|
||||||
|
|
||||||
|
git_describe
|
||||||
|
|
||||||
|
eghcup install ghc "${GHC_VERSION}"
|
||||||
|
eghcup install cabal "${CABAL_VERSION}"
|
||||||
|
|
||||||
|
ecabal update
|
||||||
|
|
||||||
|
if ! command -v cabal-cache ; then
|
||||||
|
download_cabal_cache "$HOME/.local/bin/cabal-cache"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! cabal-cache version ; then
|
||||||
|
build_cabal_cache "$HOME/.local/bin"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
eghcup debug-info
|
||||||
|
|
||||||
|
(
|
||||||
|
cd /tmp
|
||||||
|
git clone --depth 1 --branch "${HLS_TARGET_VERSION}" \
|
||||||
|
https://github.com/haskell/haskell-language-server.git \
|
||||||
|
"haskell-language-server-${HLS_TARGET_VERSION}"
|
||||||
|
cd "haskell-language-server-${HLS_TARGET_VERSION}/"
|
||||||
|
ecabal configure -w "ghc-${GHC_VERSION}" --disable-profiling --disable-tests --jobs="$(nproc)"
|
||||||
|
ecabal build --dependencies-only -w "ghc-${GHC_VERSION}" --disable-profiling --disable-tests --jobs="$(nproc)" --dry-run
|
||||||
|
sync_from
|
||||||
|
ecabal build --dependencies-only -w "ghc-${GHC_VERSION}" --disable-profiling --disable-tests --jobs="$(nproc)" || sync_to
|
||||||
|
sync_to
|
||||||
|
)
|
||||||
|
|
||||||
|
eghcup -v compile hls -j "$(nproc)" -g "${HLS_TARGET_VERSION}" --ghc "${GHC_VERSION}"
|
||||||
|
|
||||||
|
[ "$($(eghcup whereis hls "${HLS_TARGET_VERSION}") --numeric-version)" = "${HLS_TARGET_VERSION}" ] ||
|
||||||
|
[ "$($(eghcup whereis hls "${HLS_TARGET_VERSION}") --numeric-version | sed 's/.0$//')" = "${HLS_TARGET_VERSION}" ]
|
||||||
|
|
||||||
|
# nuke
|
||||||
|
eghcup nuke
|
||||||
|
[ ! -e "${GHCUP_DIR}" ]
|
||||||
|
|
272
.github/scripts/test.sh
vendored
Normal file
272
.github/scripts/test.sh
vendored
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
. .github/scripts/common.sh
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${OS}" = "Windows" ] ; then
|
||||||
|
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/ghcup
|
||||||
|
else
|
||||||
|
GHCUP_DIR="${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup
|
||||||
|
fi
|
||||||
|
|
||||||
|
env
|
||||||
|
git_describe
|
||||||
|
|
||||||
|
rm -rf "${GHCUP_DIR}"
|
||||||
|
mkdir -p "${GHCUP_BIN}"
|
||||||
|
|
||||||
|
cp "out/${ARTIFACT}"-* "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
cp "out/test-${ARTIFACT}"-* "ghcup-test${ext}"
|
||||||
|
cp "out/test-optparse-${ARTIFACT}"-* "ghcup-test-optparse${ext}"
|
||||||
|
chmod +x "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
chmod +x "ghcup-test${ext}"
|
||||||
|
chmod +x "ghcup-test-optparse${ext}"
|
||||||
|
|
||||||
|
"$GHCUP_BIN/ghcup${ext}" --version
|
||||||
|
eghcup --version
|
||||||
|
sha_sum "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
sha_sum "$(raw_eghcup --offline whereis ghcup)"
|
||||||
|
|
||||||
|
### Haskell test suite
|
||||||
|
|
||||||
|
./"ghcup-test${ext}"
|
||||||
|
./"ghcup-test-optparse${ext}"
|
||||||
|
rm "ghcup-test${ext}" "ghcup-test-optparse${ext}"
|
||||||
|
|
||||||
|
### manual cli based testing
|
||||||
|
|
||||||
|
eghcup --numeric-version
|
||||||
|
|
||||||
|
# test PATH on windows wrt msys2
|
||||||
|
# https://github.com/haskell/ghcup-hs/pull/992/checks
|
||||||
|
if [ "${OS}" = "Windows" ] ; then
|
||||||
|
eghcup run -m -- sh -c 'echo $PATH' | sed 's/:/\n/' | grep '^/mingw64/bin$'
|
||||||
|
fi
|
||||||
|
|
||||||
|
eghcup install ghc "${GHC_VER}"
|
||||||
|
eghcup unset ghc "${GHC_VER}"
|
||||||
|
ls -lah "$(eghcup whereis -d ghc "${GHC_VER}")"
|
||||||
|
[ "$($(eghcup whereis ghc "${GHC_VER}") --numeric-version)" = "${GHC_VER}" ]
|
||||||
|
[ "$(eghcup run -q --ghc "${GHC_VER}" -- ghc --numeric-version)" = "${GHC_VER}" ]
|
||||||
|
[ "$(ghcup run -q --ghc "${GHC_VER}" -- ghc -e 'Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)')" = "$($(ghcup whereis ghc "${GHC_VER}") -e 'Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)')" ]
|
||||||
|
eghcup set ghc "${GHC_VER}"
|
||||||
|
eghcup install cabal "${CABAL_VER}"
|
||||||
|
[ "$($(eghcup whereis cabal "${CABAL_VER}") --numeric-version)" = "${CABAL_VER}" ]
|
||||||
|
eghcup unset cabal
|
||||||
|
"$GHCUP_BIN"/cabal --version && exit 1 || echo yes
|
||||||
|
|
||||||
|
# make sure no cabal is set when running 'ghcup run' to check that PATH propagages properly
|
||||||
|
# https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/375
|
||||||
|
[ "$(eghcup run -q --cabal "${CABAL_VER}" -- cabal --numeric-version)" = "${CABAL_VER}" ]
|
||||||
|
eghcup set cabal "${CABAL_VER}"
|
||||||
|
|
||||||
|
[ "$($(eghcup whereis cabal "${CABAL_VER}") --numeric-version)" = "${CABAL_VER}" ]
|
||||||
|
|
||||||
|
if [ "${OS}" != "FreeBSD" ] ; then
|
||||||
|
if [ "${ARCH}" = "64" ] && [ "${DISTRO}" != "Alpine" ] ; then
|
||||||
|
eghcup run --ghc 8.10.7 --cabal 3.4.1.0 --hls 1.6.1.0 --stack 2.7.3 --install --bindir "$(pwd)/.bin"
|
||||||
|
if [ "${OS}" = "Windows" ] ; then
|
||||||
|
cat "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup-run.files.windows" | sort > expected.txt
|
||||||
|
elif [ "${DISTRO}" = "Alpine" ] ; then
|
||||||
|
cat "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup-run.files.alpine" | sort > expected.txt
|
||||||
|
else
|
||||||
|
cat "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup-run.files" | sort > expected.txt
|
||||||
|
fi
|
||||||
|
(cd ".bin" && find . | sort) > actual.txt
|
||||||
|
diff --strip-trailing-cr -w -u actual.txt expected.txt
|
||||||
|
rm actual.txt expected.txt
|
||||||
|
rm -rf .bin
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cabal --version
|
||||||
|
|
||||||
|
eghcup debug-info
|
||||||
|
|
||||||
|
# also test etags
|
||||||
|
eghcup list
|
||||||
|
eghcup list -t ghc
|
||||||
|
eghcup list -t cabal
|
||||||
|
|
||||||
|
ghc_ver=$(ghc --numeric-version)
|
||||||
|
ghc --version
|
||||||
|
"ghc-${ghc_ver}" --version
|
||||||
|
if [ "${OS}" != "Windows" ] ; then
|
||||||
|
ghci --version
|
||||||
|
"ghci-${ghc_ver}" --version
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "${OS}" = "macOS" ] && [ "${ARCH}" = "ARM64" ] ; then
|
||||||
|
# missing bindists
|
||||||
|
echo
|
||||||
|
elif [ "${OS}" = "FreeBSD" ] ; then
|
||||||
|
# not enough space
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
# test installing new ghc doesn't mess with currently set GHC
|
||||||
|
# https://gitlab.haskell.org/haskell/ghcup-hs/issues/7
|
||||||
|
if [ "${OS}" = "Linux" ] ; then
|
||||||
|
eghcup --downloader=wget prefetch ghc 8.10.3
|
||||||
|
eghcup --offline install ghc 8.10.3
|
||||||
|
if [ "${ARCH}" = "64" ] ; then
|
||||||
|
if [ "${DISTRO}" = "Alpine" ] ; then
|
||||||
|
(cat "$( cd "$(dirname "$0")" ; pwd -P )/../ghc-8.10.3-linux.alpine.files" | sort) > expected.txt
|
||||||
|
else
|
||||||
|
(cat "$( cd "$(dirname "$0")" ; pwd -P )/../ghc-8.10.3-linux.files" | sort) > expected.txt
|
||||||
|
fi
|
||||||
|
(cd "${GHCUP_DIR}/ghc/8.10.3/" && find . | sort) > actual.txt
|
||||||
|
# ignore docs
|
||||||
|
sed -i '/share\/doc/d' actual.txt
|
||||||
|
sed -i '/share\/doc/d' expected.txt
|
||||||
|
diff --strip-trailing-cr -w -u actual.txt expected.txt
|
||||||
|
rm actual.txt expected.txt
|
||||||
|
fi
|
||||||
|
elif [ "${OS}" = "Windows" ] ; then
|
||||||
|
eghcup prefetch ghc 8.10.3
|
||||||
|
eghcup --offline install ghc 8.10.3
|
||||||
|
(cat "$( cd "$(dirname "$0")" ; pwd -P )/../ghc-8.10.3-windows.files" | sort) > expected.txt
|
||||||
|
(cd "${GHCUP_DIR}/ghc/8.10.3/" && find . | sort) > actual.txt
|
||||||
|
diff --strip-trailing-cr -w -u actual.txt expected.txt
|
||||||
|
rm actual.txt expected.txt
|
||||||
|
else
|
||||||
|
eghcup prefetch ghc 8.10.3
|
||||||
|
eghcup --offline install ghc 8.10.3
|
||||||
|
fi
|
||||||
|
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
||||||
|
eghcup --offline set 8.10.3
|
||||||
|
eghcup set 8.10.3
|
||||||
|
[ "$(ghc --numeric-version)" = "8.10.3" ]
|
||||||
|
eghcup set "${GHC_VER}"
|
||||||
|
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
||||||
|
eghcup unset ghc
|
||||||
|
"$GHCUP_BIN"/ghc --numeric-version && exit 1 || echo yes
|
||||||
|
eghcup set "${GHC_VER}"
|
||||||
|
eghcup --offline rm 8.10.3
|
||||||
|
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
||||||
|
|
||||||
|
|
||||||
|
ls -lah "$GHCUP_BIN"
|
||||||
|
|
||||||
|
if [ "${OS}" = "macOS" ] ; then
|
||||||
|
eghcup install hls
|
||||||
|
$(eghcup whereis hls) --version
|
||||||
|
|
||||||
|
eghcup install stack
|
||||||
|
$(eghcup whereis stack) --version
|
||||||
|
elif [ "${OS}" = "Linux" ] ; then
|
||||||
|
if [ "${ARCH}" = "64" ] && [ "${DISTRO}" != "Alpine" ] ; then
|
||||||
|
eghcup install hls
|
||||||
|
haskell-language-server-wrapper --version
|
||||||
|
eghcup unset hls
|
||||||
|
"$GHCUP_BIN"/haskell-language-server-wrapper --version && exit 1 || echo yes
|
||||||
|
|
||||||
|
eghcup install stack
|
||||||
|
stack --version
|
||||||
|
eghcup unset stack
|
||||||
|
"$GHCUP_BIN"/stack --version && exit 1 || echo yes
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# check that lazy loading works for 'whereis'
|
||||||
|
cp "$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml" "$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml.bak"
|
||||||
|
echo '**' > "$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml"
|
||||||
|
eghcup whereis ghc "$(ghc --numeric-version)"
|
||||||
|
mv -f "$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml.bak" "$CI_PROJECT_DIR/data/metadata/ghcup-${JSON_VERSION}.yaml"
|
||||||
|
|
||||||
|
eghcup rm "$(ghc --numeric-version)"
|
||||||
|
|
||||||
|
# https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/116
|
||||||
|
if [ "${OS}" = "Linux" ] ; then
|
||||||
|
if [ "${ARCH}" = "64" ] ; then
|
||||||
|
eghcup install cabal -u https://downloads.haskell.org/~ghcup/unofficial-bindists/cabal/3.7.0.0-pre20220407/cabal-install-3.7-x86_64-linux-alpine.tar.xz 3.4.0.0-rc4
|
||||||
|
eghcup rm cabal 3.4.0.0-rc4
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
eghcup gc -c
|
||||||
|
|
||||||
|
# test etags
|
||||||
|
rm -f "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml"
|
||||||
|
raw_eghcup -s "https://www.haskell.org/ghcup/data/ghcup-${JSON_VERSION}.yaml" list
|
||||||
|
# snapshot yaml and etags file
|
||||||
|
etag=$(cat "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml.etags")
|
||||||
|
sha=$(sha_sum "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml")
|
||||||
|
# invalidate access time timer, which is 5minutes, so we re-download
|
||||||
|
touch -a -m -t '199901010101' "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml"
|
||||||
|
# redownload same file with some newlines added
|
||||||
|
raw_eghcup -s https://raw.githubusercontent.com/haskell/ghcup-metadata/exp/ghcup-${JSON_VERSION}.yaml list
|
||||||
|
# snapshot new yaml and etags file
|
||||||
|
etag2=$(cat "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml.etags")
|
||||||
|
sha2=$(sha_sum "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml")
|
||||||
|
# compare
|
||||||
|
[ "${etag}" != "${etag2}" ]
|
||||||
|
[ "${sha}" != "${sha2}" ]
|
||||||
|
# invalidate access time timer, which is 5minutes, but don't expect a re-download
|
||||||
|
touch -a -m -t '199901010101' "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml"
|
||||||
|
# this time, we expect the same hash and etag
|
||||||
|
raw_eghcup -s https://raw.githubusercontent.com/haskell/ghcup-metadata/exp/ghcup-${JSON_VERSION}.yaml list
|
||||||
|
etag3=$(cat "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml.etags")
|
||||||
|
sha3=$(sha_sum "${GHCUP_DIR}/cache/ghcup-${JSON_VERSION}.yaml")
|
||||||
|
[ "${etag2}" = "${etag3}" ]
|
||||||
|
[ "${sha2}" = "${sha3}" ]
|
||||||
|
|
||||||
|
# test isolated installs
|
||||||
|
if [ "${DISTRO}" != "Alpine" ] ; then
|
||||||
|
eghcup install ghc -i "$(pwd)/isolated" 8.10.5
|
||||||
|
[ "$(isolated/bin/ghc --numeric-version)" = "8.10.5" ]
|
||||||
|
! eghcup install ghc -i "$(pwd)/isolated" 8.10.5
|
||||||
|
if [ "${ARCH}" = "64" ] ; then
|
||||||
|
if [ "${OS}" = "Linux" ] || [ "${OS}" = "Windows" ] ; then
|
||||||
|
eghcup install cabal -i "$(pwd)/isolated" 3.4.0.0
|
||||||
|
[ "$(isolated/cabal --numeric-version)" = "3.4.0.0" ]
|
||||||
|
eghcup install stack -i "$(pwd)/isolated" 2.7.3
|
||||||
|
[ "$(isolated/stack --numeric-version)" = "2.7.3" ]
|
||||||
|
eghcup install hls -i "$(pwd)/isolated" 1.3.0
|
||||||
|
[ "$(isolated/haskell-language-server-wrapper --numeric-version)" = "1.3.0" ] ||
|
||||||
|
[ "$(isolated/haskell-language-server-wrapper --numeric-version)" = "1.3.0.0" ]
|
||||||
|
|
||||||
|
# test that isolated installs don't clean up target directory
|
||||||
|
cat <<EOF > "${GHCUP_BIN}/gmake"
|
||||||
|
#!/bin/bash
|
||||||
|
exit 1
|
||||||
|
EOF
|
||||||
|
chmod +x "${GHCUP_BIN}/gmake"
|
||||||
|
mkdir isolated_tainted/
|
||||||
|
touch isolated_tainted/lol
|
||||||
|
|
||||||
|
! eghcup install ghc -i "$(pwd)/isolated_tainted" 8.10.5 --force
|
||||||
|
[ -e "$(pwd)/isolated_tainted/lol" ]
|
||||||
|
rm "${GHCUP_BIN}/gmake"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
eghcup upgrade
|
||||||
|
eghcup upgrade -f
|
||||||
|
|
||||||
|
# restore old ghcup, because we want to test nuke
|
||||||
|
cp "out/${ARTIFACT}"-* "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
chmod +x "$GHCUP_BIN/ghcup${ext}"
|
||||||
|
|
||||||
|
# test that doing fishy symlinks into GHCup dir doesn't cause weird stuff on 'ghcup nuke'
|
||||||
|
mkdir no_nuke/
|
||||||
|
mkdir no_nuke/bar
|
||||||
|
echo 'foo' > no_nuke/file
|
||||||
|
echo 'bar' > no_nuke/bar/file
|
||||||
|
ln -s "$CI_PROJECT_DIR"/no_nuke/ "${GHCUP_DIR}"/cache/no_nuke
|
||||||
|
ln -s "$CI_PROJECT_DIR"/no_nuke/ "${GHCUP_DIR}"/logs/no_nuke
|
||||||
|
|
||||||
|
# nuke
|
||||||
|
eghcup nuke
|
||||||
|
[ ! -e "${GHCUP_DIR}" ]
|
||||||
|
|
||||||
|
# make sure nuke doesn't resolve symlinks
|
||||||
|
[ -e "$CI_PROJECT_DIR"/no_nuke/file ]
|
||||||
|
[ -e "$CI_PROJECT_DIR"/no_nuke/bar/file ]
|
||||||
|
|
60
.github/workflows/bootstrap.yaml
vendored
Normal file
60
.github/workflows/bootstrap.yaml
vendored
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
name: Bootstrap tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bootstrap:
|
||||||
|
name: bootstrap
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
BOOTSTRAP_HASKELL_CABAL_VERSION: 3.6.2.0
|
||||||
|
BOOTSTRAP_HASKELL_GHC_VERSION: 8.10.7
|
||||||
|
BOOTSTRAP_HASKELL_NONINTERACTIVE: yes
|
||||||
|
ARCH: 64
|
||||||
|
JSON_VERSION: "0.0.7"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
- os: macOS-11
|
||||||
|
DISTRO: na
|
||||||
|
- os: windows-latest
|
||||||
|
DISTRO: na
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- if: runner.os == 'Linux'
|
||||||
|
name: Run bootstrap
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl gzip
|
||||||
|
sh ./.github/scripts/bootstrap.sh
|
||||||
|
env:
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
|
||||||
|
- if: runner.os == 'macOS'
|
||||||
|
name: Run bootstrap
|
||||||
|
run: sh ./.github/scripts/bootstrap.sh
|
||||||
|
env:
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
|
||||||
|
- if: runner.os == 'Windows'
|
||||||
|
name: Run bootstrap
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
|
||||||
|
$curDir = Get-Location
|
||||||
|
Write-Host "Current Working Directory: $curDir"
|
||||||
|
./scripts/bootstrap/bootstrap-haskell.ps1 -InstallDir ${GITHUB_WORKSPACE} -BootstrapUrl ("{0}/scripts/bootstrap/bootstrap-haskell" -f $curDir) -InBash -Msys2Env "MINGW64"
|
||||||
|
shell: pwsh
|
||||||
|
|
39
.github/workflows/cabal.project.yaml
vendored
Normal file
39
.github/workflows/cabal.project.yaml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: Test cabal.project files
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: '0 2 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build binary
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macOS-latest, macOS-11, windows-latest, ubuntu-latest]
|
||||||
|
ghc: ["8.10.7", "9.0.2", "9.2.8", "9.4.8"]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Run build
|
||||||
|
run: |
|
||||||
|
env
|
||||||
|
ghcup --version
|
||||||
|
ghcup run -i --cabal latest -- cabal update
|
||||||
|
ghcup run -i --cabal latest --ghc ${GHC_VER} -- cabal build --project-file=cabal.ghc${GHC_VER//./}.project
|
||||||
|
env:
|
||||||
|
GHC_VER: ${{ matrix.ghc }}
|
||||||
|
shell: bash
|
||||||
|
|
37
.github/workflows/cache.yaml
vendored
Normal file
37
.github/workflows/cache.yaml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: Cache eviction
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
key:
|
||||||
|
description: Which cache to evict
|
||||||
|
required: true
|
||||||
|
default: '/'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- FreeBSD-64-na
|
||||||
|
- Linux-32-Alpine
|
||||||
|
- Linux-64-Alpine
|
||||||
|
- Linux-64-Ubuntu
|
||||||
|
- Linux-ARM-Ubuntu
|
||||||
|
- Linux-ARM64-Ubuntu
|
||||||
|
- Windows-64-na
|
||||||
|
- macOS-64-na
|
||||||
|
- macOS-ARM64-na
|
||||||
|
- /
|
||||||
|
jobs:
|
||||||
|
evict:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Remove from S3
|
||||||
|
uses: vitorsgomes/s3-rm-action@master
|
||||||
|
with:
|
||||||
|
args: --recursive
|
||||||
|
env:
|
||||||
|
AWS_S3_ENDPOINT: https://${{ secrets.S3_HOST }}
|
||||||
|
AWS_S3_BUCKET: ghcup-hs
|
||||||
|
AWS_REGION: us-west-2
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
PATH_TO_DELETE: ${{ github.event.inputs.key }}
|
147
.github/workflows/cross.yaml
vendored
Normal file
147
.github/workflows/cross.yaml
vendored
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
name: Test cross bindists
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: '0 2 * * *'
|
||||||
|
|
||||||
|
env:
|
||||||
|
CABAL_CACHE_DISABLE: ${{ vars.CABAL_CACHE_DISABLE }}
|
||||||
|
CABAL_CACHE_NONFATAL: yes
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build linux binary
|
||||||
|
runs-on: [self-hosted, Linux, X64, maerwald]
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.3.0
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ secrets.S3_HOST }}
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
GHC_VER: 8.10.7
|
||||||
|
ARCH: 64
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Run build
|
||||||
|
uses: docker://hasufell/alpine-haskell:3.12
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ env.ARTIFACT }}
|
||||||
|
ARCH: ${{ env.ARCH }}
|
||||||
|
GHC_VER: ${{ env.GHC_VER }}
|
||||||
|
DISTRO: Alpine
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
|
||||||
|
- if: always()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: |
|
||||||
|
./out/*
|
||||||
|
|
||||||
|
test-cross-linux:
|
||||||
|
name: Test linux cross
|
||||||
|
needs: "build"
|
||||||
|
runs-on: [self-hosted, Linux, X64]
|
||||||
|
container:
|
||||||
|
image: registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:a9297a370025101b479cfd4977f8f910814e03ab
|
||||||
|
options: --user root
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.3.0
|
||||||
|
BUILD_CONF_ARGS: "--enable-unregisterised"
|
||||||
|
HADRIAN_FLAVOUR: ""
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
GHC_VER: 8.10.6
|
||||||
|
GHC_TARGET_VERSION: "8.10.7"
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: Debian
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
CROSS: "arm-linux-gnueabihf"
|
||||||
|
WRAPPER: "run"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- name: Run test (64 bit linux)
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl gzip libstdc++-11-dev
|
||||||
|
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
|
||||||
|
sudo dpkg --add-architecture armhf
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y libncurses-dev:armhf libstdc++-11-dev:armhf
|
||||||
|
# ld.bfd is broken on armv7: https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
||||||
|
update-alternatives --install "/usr/bin/x86_64-linux-gnu-ld" "ld" "/usr/bin/x86_64-linux-gnu-ld.gold" 20
|
||||||
|
update-alternatives --install "/usr/bin/x86_64-linux-gnu-ld" "ld" "/usr/bin/x86_64-linux-gnu-ld.bfd" 10
|
||||||
|
update-alternatives --set "ld" "/usr/bin/x86_64-linux-gnu-ld.gold"
|
||||||
|
update-alternatives --install "/usr/bin/arm-linux-gnueabihf-ld" "ld-arm" "/usr/bin/arm-linux-gnueabihf-ld.gold" 20
|
||||||
|
update-alternatives --install "/usr/bin/arm-linux-gnueabihf-ld" "ld-arm" "/usr/bin/arm-linux-gnueabihf-ld.bfd" 10
|
||||||
|
update-alternatives --set "ld-arm" "/usr/bin/arm-linux-gnueabihf-ld.gold"
|
||||||
|
sh .github/scripts/cross.sh
|
||||||
|
|
||||||
|
test-cross-js:
|
||||||
|
name: Test GHC JS cross
|
||||||
|
needs: "build"
|
||||||
|
runs-on: [self-hosted, Linux, X64]
|
||||||
|
container:
|
||||||
|
image: registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb12:a9297a370025101b479cfd4977f8f910814e03ab
|
||||||
|
options: --user root
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.3.0
|
||||||
|
BUILD_CONF_ARGS: ""
|
||||||
|
HADRIAN_FLAVOUR: "default+native_bignum"
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
GHC_VER: 9.6.2
|
||||||
|
GHC_TARGET_VERSION: "9.6.2"
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: Debian
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
CROSS: "javascript-unknown-ghcjs"
|
||||||
|
WRAPPER: "emconfigure"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- name: Run test (64 bit linux)
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl gzip
|
||||||
|
git clone https://github.com/emscripten-core/emsdk.git
|
||||||
|
cd emsdk
|
||||||
|
./emsdk install latest
|
||||||
|
./emsdk activate latest
|
||||||
|
. ./emsdk_env.sh
|
||||||
|
cd ..
|
||||||
|
bash .github/scripts/cross.sh
|
||||||
|
|
127
.github/workflows/docker.yaml
vendored
Normal file
127
.github/workflows/docker.yaml
vendored
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
name: Docker image builds
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker-alpine32:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push (alpine 32bit)
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./docker/alpine32
|
||||||
|
push: true
|
||||||
|
tags: hasufell/i386-alpine-haskell:3.12
|
||||||
|
platforms: |
|
||||||
|
linux/i386
|
||||||
|
linux/amd64
|
||||||
|
|
||||||
|
docker-alpine:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Build and push (alpine 64bit)
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./docker/alpine64
|
||||||
|
push: true
|
||||||
|
tags: hasufell/alpine-haskell:3.12
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
docker-arm32:
|
||||||
|
runs-on: [self-hosted, Linux, ARM64]
|
||||||
|
steps:
|
||||||
|
- uses: docker://arm64v8/ubuntu:focal
|
||||||
|
name: Cleanup (aarch64 linux)
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
args: "find . -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push (debian buster)
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./docker/arm32v7/buster
|
||||||
|
push: true
|
||||||
|
tags: hasufell/arm32v7-debian-haskell:10
|
||||||
|
platforms: linux/arm
|
||||||
|
|
||||||
|
- name: Build and push (ubuntu focal)
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./docker/arm32v7/focal
|
||||||
|
push: true
|
||||||
|
tags: hasufell/arm32v7-ubuntu-haskell:focal
|
||||||
|
platforms: linux/arm
|
||||||
|
|
||||||
|
docker-aarch:
|
||||||
|
runs-on: [self-hosted, Linux, ARM64]
|
||||||
|
steps:
|
||||||
|
- uses: docker://arm64v8/ubuntu:focal
|
||||||
|
name: Cleanup (aarch64 linux)
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
args: "find . -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push (debian buster)
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./docker/arm64v8/buster
|
||||||
|
push: true
|
||||||
|
tags: hasufell/arm64v8-debian-haskell:10
|
||||||
|
platforms: linux/arm64
|
||||||
|
|
||||||
|
- name: Build and push (ubuntu focal)
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./docker/arm64v8/focal
|
||||||
|
push: true
|
||||||
|
tags: hasufell/arm64v8-ubuntu-haskell:focal
|
||||||
|
platforms: linux/arm64
|
26
.github/workflows/hlint.yaml
vendored
Normal file
26
.github/workflows/hlint.yaml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: Hlint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
hlint:
|
||||||
|
name: hlint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
JSON_VERSION: "0.0.7"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Run hlint
|
||||||
|
run: curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s -- -r lib/ test/
|
33
.github/workflows/mkdocs.yaml
vendored
Normal file
33
.github/workflows/mkdocs.yaml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: MkDocs
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
mkdocs:
|
||||||
|
name: mkdocs
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
JSON_VERSION: "0.0.7"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Install mkdocs deps
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y python3-pip
|
||||||
|
sudo pip3 install mkdocs
|
||||||
|
|
||||||
|
- name: Run mkdocs
|
||||||
|
run: |
|
||||||
|
mkdocs build
|
581
.github/workflows/release.yaml
vendored
Normal file
581
.github/workflows/release.yaml
vendored
Normal file
@ -0,0 +1,581 @@
|
|||||||
|
name: Build and release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: '0 2 * * *'
|
||||||
|
|
||||||
|
env:
|
||||||
|
CABAL_CACHE_DISABLE: ${{ vars.CABAL_CACHE_DISABLE }}
|
||||||
|
CABAL_CACHE_NONFATAL: yes
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
name: Build linux binary
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.2.0
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ secrets.S3_HOST }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARTIFACT: "i386-linux-ghcup"
|
||||||
|
GHC_VER: 8.10.7
|
||||||
|
ARCH: 32
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- if: matrix.ARCH == '32'
|
||||||
|
name: Run build (32 bit linux)
|
||||||
|
uses: docker://hasufell/i386-alpine-haskell:3.12
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: Alpine
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
|
||||||
|
- if: matrix.ARCH == '64'
|
||||||
|
name: Run build (64 bit linux)
|
||||||
|
uses: docker://hasufell/alpine-haskell:3.12
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: Alpine
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
|
||||||
|
- if: always()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: |
|
||||||
|
./out/*
|
||||||
|
|
||||||
|
|
||||||
|
build-arm:
|
||||||
|
name: Build ARM binary
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.6.2.0
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ secrets.S3_HOST }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: [self-hosted, Linux, ARM64, maerwald]
|
||||||
|
ARTIFACT: "armv7-linux-ghcup"
|
||||||
|
GHC_VER: 9.2.8
|
||||||
|
ARCH: ARM
|
||||||
|
- os: [self-hosted, Linux, ARM64, maerwald]
|
||||||
|
ARTIFACT: "aarch64-linux-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: ARM64
|
||||||
|
steps:
|
||||||
|
- name: git config
|
||||||
|
run: |
|
||||||
|
git config --global --get-all safe.directory | grep '^\*$' || git config --global --add safe.directory "*"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- if: matrix.ARCH == 'ARM'
|
||||||
|
uses: docker://hasufell/arm32v7-debian-haskell:10
|
||||||
|
name: Run build (armv7 linux)
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
LD: ld.gold
|
||||||
|
|
||||||
|
- if: matrix.ARCH == 'ARM64'
|
||||||
|
uses: docker://hasufell/arm64v8-debian-haskell:10
|
||||||
|
name: Run build (aarch64 linux)
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
|
||||||
|
- if: always()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: |
|
||||||
|
./out/*
|
||||||
|
|
||||||
|
build-macwin:
|
||||||
|
name: Build binary (Mac/Win)
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.2.0
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ secrets.S3_HOST }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: [self-hosted, macOS, ARM64]
|
||||||
|
ARTIFACT: "aarch64-apple-darwin-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: ARM64
|
||||||
|
- os: macOS-11
|
||||||
|
ARTIFACT: "x86_64-apple-darwin-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
- os: windows-latest
|
||||||
|
ARTIFACT: "x86_64-mingw64-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- if: matrix.ARCH == 'ARM64' && runner.os == 'macOS'
|
||||||
|
name: Run build
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/brew.sh git coreutils llvm@13 autoconf automake
|
||||||
|
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$HOME/.brew/opt/llvm@13/bin:$PATH"
|
||||||
|
export CC="$HOME/.brew/opt/llvm@13/bin/clang"
|
||||||
|
export CXX="$HOME/.brew/opt/llvm@13/bin/clang++"
|
||||||
|
export LD=ld
|
||||||
|
export AR="$HOME/.brew/opt/llvm@13/bin/llvm-ar"
|
||||||
|
export RANLIB="$HOME/.brew/opt/llvm@13/bin/llvm-ranlib"
|
||||||
|
bash .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: na
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
HOMEBREW_CHANGE_ARCH_TO_ARM: 1
|
||||||
|
|
||||||
|
- if: matrix.ARCH == '64' && runner.os == 'macOS'
|
||||||
|
name: Run build (windows/mac)
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/brew.sh coreutils
|
||||||
|
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
|
||||||
|
bash .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: na
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
HOMEBREW_CHANGE_ARCH_TO_ARM: 1
|
||||||
|
|
||||||
|
- if: runner.os == 'Windows'
|
||||||
|
name: Run build (windows/mac)
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/brew.sh git coreutils autoconf automake
|
||||||
|
bash .github/scripts/build.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: na
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ env.S3_HOST }}
|
||||||
|
HOMEBREW_CHANGE_ARCH_TO_ARM: 1
|
||||||
|
|
||||||
|
- if: always()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: |
|
||||||
|
./out/*
|
||||||
|
|
||||||
|
build-freebsd:
|
||||||
|
name: Build binary (FreeBSD)
|
||||||
|
runs-on: [self-hosted, FreeBSD, X64]
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.2.0
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ secrets.S3_HOST }}
|
||||||
|
ARTIFACT: "x86_64-portbld-freebsd-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: na
|
||||||
|
RUNNER_OS: FreeBSD
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Run build
|
||||||
|
run: |
|
||||||
|
sed -i.bak -e 's/quarterly/latest/' /etc/pkg/FreeBSD.conf
|
||||||
|
pkg install -y ghc hs-cabal-install git bash misc/compat10x misc/compat11x misc/compat12x gmake llvm14 libiconv
|
||||||
|
tzsetup Etc/GMT
|
||||||
|
adjkerntz -a
|
||||||
|
bash .github/scripts/build.sh
|
||||||
|
- if: always()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: |
|
||||||
|
./out/*
|
||||||
|
|
||||||
|
test-linux:
|
||||||
|
name: Test linux
|
||||||
|
needs: "build-linux"
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.2.0
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARTIFACT: "i386-linux-ghcup"
|
||||||
|
GHC_VER: 8.10.7
|
||||||
|
ARCH: 32
|
||||||
|
DISTRO: Alpine
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: Alpine
|
||||||
|
- os: ubuntu-latest
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- if: matrix.ARCH == '32' && matrix.DISTRO == 'Alpine'
|
||||||
|
name: Run test (32 bit linux Alpine)
|
||||||
|
uses: docker://hasufell/i386-alpine-haskell:3.12
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
|
||||||
|
- if: matrix.ARCH == '64' && matrix.DISTRO == 'Alpine'
|
||||||
|
name: Run test (64 bit linux Alpine)
|
||||||
|
uses: docker://hasufell/alpine-haskell:3.12
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
|
||||||
|
- if: matrix.DISTRO != 'Alpine'
|
||||||
|
name: Run test (64 bit linux)
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl gzip
|
||||||
|
sh .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
|
||||||
|
- if: failure()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: testfiles
|
||||||
|
path: |
|
||||||
|
./test/ghcup-test/golden/unix/GHCupInfo*json
|
||||||
|
|
||||||
|
test-arm:
|
||||||
|
name: Test ARM
|
||||||
|
needs: "build-arm"
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.6.2.0
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: [self-hosted, Linux, ARM64, maerwald]
|
||||||
|
ARTIFACT: "armv7-linux-ghcup"
|
||||||
|
GHC_VER: 9.2.8
|
||||||
|
ARCH: ARM
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
- os: [self-hosted, Linux, ARM64, maerwald]
|
||||||
|
ARTIFACT: "aarch64-linux-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: ARM64
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- if: matrix.ARCH == 'ARM'
|
||||||
|
uses: docker://hasufell/arm32v7-debian-haskell:10
|
||||||
|
name: Run test (armv7 linux)
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
LD: ld.gold
|
||||||
|
|
||||||
|
- if: matrix.ARCH == 'ARM64'
|
||||||
|
uses: docker://hasufell/arm64v8-debian-haskell:10
|
||||||
|
name: Run test (aarch64 linux)
|
||||||
|
with:
|
||||||
|
args: sh .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
|
||||||
|
- if: failure()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: testfiles
|
||||||
|
path: |
|
||||||
|
./test/ghcup-test/golden/unix/GHCupInfo*json
|
||||||
|
|
||||||
|
test-macwin:
|
||||||
|
name: Test Mac/Win
|
||||||
|
needs: "build-macwin"
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.2.0
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: [self-hosted, macOS, ARM64]
|
||||||
|
ARTIFACT: "aarch64-apple-darwin-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: ARM64
|
||||||
|
DISTRO: na
|
||||||
|
- os: macOS-11
|
||||||
|
ARTIFACT: "x86_64-apple-darwin-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: na
|
||||||
|
- os: windows-latest
|
||||||
|
ARTIFACT: "x86_64-mingw64-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: na
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- if: runner.os == 'macOS'
|
||||||
|
name: Run test
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/brew.sh coreutils
|
||||||
|
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
|
||||||
|
bash .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
HOMEBREW_CHANGE_ARCH_TO_ARM: 1
|
||||||
|
|
||||||
|
- if: runner.os != 'macOS'
|
||||||
|
name: Run test
|
||||||
|
run: bash .github/scripts/test.sh
|
||||||
|
env:
|
||||||
|
ARTIFACT: ${{ matrix.ARTIFACT }}
|
||||||
|
ARCH: ${{ matrix.ARCH }}
|
||||||
|
GHC_VER: ${{ matrix.GHC_VER }}
|
||||||
|
DISTRO: ${{ matrix.DISTRO }}
|
||||||
|
HOMEBREW_CHANGE_ARCH_TO_ARM: 1
|
||||||
|
|
||||||
|
- if: failure() && runner.os == 'Windows'
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: testfiles
|
||||||
|
path: |
|
||||||
|
./test/ghcup-test/golden/windows/GHCupInfo*json
|
||||||
|
|
||||||
|
- if: failure() && runner.os != 'Windows'
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: testfiles
|
||||||
|
path: |
|
||||||
|
./test/ghcup-test/golden/unix/GHCupInfo*json
|
||||||
|
test-freebsd:
|
||||||
|
name: Test FreeBSD
|
||||||
|
needs: "build-freebsd"
|
||||||
|
runs-on: [self-hosted, FreeBSD, X64]
|
||||||
|
env:
|
||||||
|
CABAL_VER: 3.10.2.0
|
||||||
|
MACOSX_DEPLOYMENT_TARGET: 10.13
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
ARTIFACT: "x86_64-portbld-freebsd-ghcup"
|
||||||
|
GHC_VER: 9.4.8
|
||||||
|
ARCH: 64
|
||||||
|
DISTRO: na
|
||||||
|
RUNNER_OS: FreeBSD
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- name: Run test
|
||||||
|
run: |
|
||||||
|
bash .github/scripts/test.sh
|
||||||
|
|
||||||
|
- if: failure()
|
||||||
|
name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: testfiles
|
||||||
|
path: |
|
||||||
|
./test/ghcup-test/golden/unix/GHCupInfo*json
|
||||||
|
hls:
|
||||||
|
name: hls
|
||||||
|
needs: build-linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GHC_VERSION: "8.10.7"
|
||||||
|
HLS_TARGET_VERSION: "1.8.0.0"
|
||||||
|
CABAL_VERSION: "3.8.1.0"
|
||||||
|
JSON_VERSION: "0.0.8"
|
||||||
|
ARTIFACT: "x86_64-linux-ghcup"
|
||||||
|
DISTRO: Ubuntu
|
||||||
|
ARCH: 64
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
S3_HOST: ${{ secrets.S3_HOST }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- name: Run hls build
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl gzip
|
||||||
|
sh .github/scripts/hls.sh
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: release
|
||||||
|
needs: ["test-linux", "test-arm", "test-macwin", "test-freebsd", "hls"]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
draft: true
|
||||||
|
files: |
|
||||||
|
./out/*
|
28
.github/workflows/shellcheck.yaml
vendored
Normal file
28
.github/workflows/shellcheck.yaml
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
name: Shellcheck
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
shellcheck:
|
||||||
|
name: shellcheck
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
JSON_VERSION: "0.0.7"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Run shellcheck
|
||||||
|
uses: docker://koalaman/shellcheck-alpine
|
||||||
|
with:
|
||||||
|
args: shellcheck scripts/bootstrap/bootstrap-haskell
|
29
.github/workflows/shimgen.yaml
vendored
Normal file
29
.github/workflows/shimgen.yaml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Shimgen CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-shimgen:
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
|
||||||
|
- name: compile
|
||||||
|
run: cl /O1 scoop-better-shimexe/shim.c
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: shim.exe
|
||||||
|
path: shim.exe
|
||||||
|
|
35
.github/workflows/stack.yaml
vendored
Normal file
35
.github/workflows/stack.yaml
vendored
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
name: Test stack.yaml
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: '0 2 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build binary
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macOS-latest, macOS-11, windows-latest, ubuntu-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Run build
|
||||||
|
run: |
|
||||||
|
env
|
||||||
|
ghcup --version
|
||||||
|
ghcup run -i --stack latest -- stack build
|
||||||
|
shell: bash
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -4,6 +4,7 @@ codex.tags
|
|||||||
dist-newstyle/
|
dist-newstyle/
|
||||||
cabal.project.local
|
cabal.project.local
|
||||||
.stack-work/
|
.stack-work/
|
||||||
|
.hiefiles/
|
||||||
bin/
|
bin/
|
||||||
/*.prof
|
/*.prof
|
||||||
/*.ps
|
/*.ps
|
||||||
@ -12,3 +13,6 @@ tags
|
|||||||
TAGS
|
TAGS
|
||||||
/tmp/
|
/tmp/
|
||||||
.entangled
|
.entangled
|
||||||
|
release/
|
||||||
|
releases/
|
||||||
|
site/
|
||||||
|
198
.gitlab-ci.yml
198
.gitlab-ci.yml
@ -1,198 +0,0 @@
|
|||||||
variables:
|
|
||||||
GIT_SSL_NO_VERIFY: "1"
|
|
||||||
|
|
||||||
# Commit of ghc/ci-images repository from which to pull Docker images
|
|
||||||
DOCKER_REV: 1ac7f435c9312f10422a82d304194778378e2a1a
|
|
||||||
|
|
||||||
############################################################
|
|
||||||
# CI Step
|
|
||||||
############################################################
|
|
||||||
|
|
||||||
.debian:
|
|
||||||
image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
|
|
||||||
tags:
|
|
||||||
- x86_64-linux
|
|
||||||
variables:
|
|
||||||
OS: "LINUX"
|
|
||||||
|
|
||||||
.alpine:64bit:
|
|
||||||
image: "alpine:edge"
|
|
||||||
tags:
|
|
||||||
- x86_64-linux
|
|
||||||
variables:
|
|
||||||
OS: "LINUX"
|
|
||||||
BIT: "64"
|
|
||||||
|
|
||||||
.alpine:32bit:
|
|
||||||
image: "i386/alpine:edge"
|
|
||||||
tags:
|
|
||||||
- x86_64-linux
|
|
||||||
variables:
|
|
||||||
OS: "LINUX"
|
|
||||||
BIT: "32"
|
|
||||||
|
|
||||||
.darwin:
|
|
||||||
tags:
|
|
||||||
- x86_64-darwin
|
|
||||||
variables:
|
|
||||||
OS: "DARWIN"
|
|
||||||
|
|
||||||
.freebsd:
|
|
||||||
tags:
|
|
||||||
- x86_64-freebsd
|
|
||||||
variables:
|
|
||||||
OS: "FREEBSD"
|
|
||||||
|
|
||||||
.root_cleanup:
|
|
||||||
after_script:
|
|
||||||
- BUILD_DIR=$CI_PROJECT_DIR
|
|
||||||
- echo "Cleaning $BUILD_DIR"
|
|
||||||
- cd $HOME
|
|
||||||
- test -n "$BUILD_DIR"
|
|
||||||
- shopt -s extglob
|
|
||||||
- rm -Rf "$BUILD_DIR"/!(out)
|
|
||||||
- exit 0
|
|
||||||
|
|
||||||
.test_ghcup_version:
|
|
||||||
script:
|
|
||||||
- ./.gitlab/script/ghcup_version.sh
|
|
||||||
variables:
|
|
||||||
JSON_VERSION: "0.0.2"
|
|
||||||
|
|
||||||
.test_ghcup_version:linux:
|
|
||||||
extends:
|
|
||||||
- .test_ghcup_version
|
|
||||||
- .debian
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/linux/install_deps.sh
|
|
||||||
|
|
||||||
.test_ghcup_version:darwin:
|
|
||||||
extends:
|
|
||||||
- .test_ghcup_version
|
|
||||||
- .darwin
|
|
||||||
- .root_cleanup
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/darwin/install_deps.sh
|
|
||||||
|
|
||||||
.test_ghcup_version:freebsd:
|
|
||||||
extends:
|
|
||||||
- .test_ghcup_version
|
|
||||||
- .freebsd
|
|
||||||
- .root_cleanup
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/freebsd/install_deps.sh
|
|
||||||
|
|
||||||
.release_ghcup:
|
|
||||||
script:
|
|
||||||
- ./.gitlab/script/ghcup_release.sh
|
|
||||||
artifacts:
|
|
||||||
expire_in: 2 week
|
|
||||||
paths:
|
|
||||||
- out
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
|
|
||||||
######## linux test ########
|
|
||||||
|
|
||||||
test:linux:recommended:
|
|
||||||
extends: .test_ghcup_version:linux
|
|
||||||
variables:
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
|
|
||||||
test:linux:latest:
|
|
||||||
extends: .test_ghcup_version:linux
|
|
||||||
variables:
|
|
||||||
GHC_VERSION: "8.10.1"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
|
|
||||||
######## darwin test ########
|
|
||||||
|
|
||||||
test:mac:recommended:
|
|
||||||
extends: .test_ghcup_version:darwin
|
|
||||||
variables:
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
|
|
||||||
test:mac:latest:
|
|
||||||
extends: .test_ghcup_version:darwin
|
|
||||||
variables:
|
|
||||||
GHC_VERSION: "8.10.1"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
|
|
||||||
######## freebsd test ########
|
|
||||||
|
|
||||||
test:freebsd:recommended:
|
|
||||||
extends: .test_ghcup_version:freebsd
|
|
||||||
variables:
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
|
|
||||||
test:freebsd:latest:
|
|
||||||
extends: .test_ghcup_version:freebsd
|
|
||||||
variables:
|
|
||||||
GHC_VERSION: "8.10.1"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
|
|
||||||
######## linux release ########
|
|
||||||
|
|
||||||
release:linux:64bit:
|
|
||||||
extends:
|
|
||||||
- .alpine:64bit
|
|
||||||
- .release_ghcup
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/linux/alpine/install_deps.sh
|
|
||||||
variables:
|
|
||||||
ARTIFACT: "x86_64-linux-ghcup"
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
|
|
||||||
|
|
||||||
release:linux:32bit:
|
|
||||||
extends:
|
|
||||||
- .alpine:32bit
|
|
||||||
- .release_ghcup
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/linux/alpine/install_deps.sh
|
|
||||||
variables:
|
|
||||||
ARTIFACT: "i386-linux-ghcup"
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
|
|
||||||
|
|
||||||
######## darwin release ########
|
|
||||||
|
|
||||||
release:darwin:
|
|
||||||
extends:
|
|
||||||
- .darwin
|
|
||||||
- .release_ghcup
|
|
||||||
- .root_cleanup
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/darwin/install_deps.sh
|
|
||||||
variables:
|
|
||||||
ARTIFACT: "x86_64-apple-darwin-ghcup"
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
MACOSX_DEPLOYMENT_TARGET: "10.7"
|
|
||||||
|
|
||||||
|
|
||||||
######## freebsd release ########
|
|
||||||
|
|
||||||
release:freebsd:
|
|
||||||
extends:
|
|
||||||
- .freebsd
|
|
||||||
- .release_ghcup
|
|
||||||
- .root_cleanup
|
|
||||||
before_script:
|
|
||||||
- ./.gitlab/before_script/freebsd/install_deps.sh
|
|
||||||
variables:
|
|
||||||
ARTIFACT: "x86_64-portbld-freebsd-ghcup"
|
|
||||||
GHC_VERSION: "8.8.3"
|
|
||||||
CABAL_VERSION: "3.2.0.0"
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env"
|
|
||||||
|
|
||||||
mkdir -p "${TMPDIR}"
|
|
||||||
|
|
||||||
curl -sSfL https://downloads.haskell.org/~ghcup/x86_64-apple-darwin-ghcup > ./ghcup-bin
|
|
||||||
chmod +x ghcup-bin
|
|
||||||
|
|
||||||
./ghcup-bin install ${GHC_VERSION}
|
|
||||||
./ghcup-bin set ${GHC_VERSION}
|
|
||||||
./ghcup-bin install-cabal ${CABAL_VERSION}
|
|
||||||
|
|
||||||
exit 0
|
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
# pkg install --force --yes --no-repo-update curl gcc gmp gmake ncurses perl5 libffi libiconv
|
|
||||||
|
|
||||||
. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env"
|
|
||||||
|
|
||||||
mkdir -p "${TMPDIR}"
|
|
||||||
|
|
||||||
curl -sSfL https://downloads.haskell.org/~ghcup/x86_64-portbld-freebsd-ghcup > ./ghcup-bin
|
|
||||||
chmod +x ghcup-bin
|
|
||||||
|
|
||||||
./ghcup-bin install ${GHC_VERSION}
|
|
||||||
./ghcup-bin install-cabal ${CABAL_VERSION}
|
|
||||||
./ghcup-bin set ${GHC_VERSION}
|
|
||||||
|
|
||||||
exit 0
|
|
@ -1,53 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
. "$( cd "$(dirname "$0")" ; pwd -P )/../../../ghcup_env"
|
|
||||||
|
|
||||||
mkdir -p "${TMPDIR}"
|
|
||||||
|
|
||||||
apk add --no-cache \
|
|
||||||
curl \
|
|
||||||
gcc \
|
|
||||||
g++ \
|
|
||||||
gmp-dev \
|
|
||||||
ncurses-dev \
|
|
||||||
libffi-dev \
|
|
||||||
make \
|
|
||||||
xz \
|
|
||||||
tar \
|
|
||||||
perl
|
|
||||||
|
|
||||||
ln -sf libncurses.so /usr/lib/libtinfo.so
|
|
||||||
ln -sf libncursesw.so.6 /usr/lib/libtinfow.so.6
|
|
||||||
ln -sf libtinfow.so.6 /usr/lib/libtinfow.so
|
|
||||||
|
|
||||||
if [ "${BIT}" = "32" ] ; then
|
|
||||||
curl -sSfL https://downloads.haskell.org/ghcup/i386-linux-ghcup > ./ghcup-bin
|
|
||||||
else
|
|
||||||
curl -sSfL https://downloads.haskell.org/ghcup/x86_64-linux-ghcup > ./ghcup-bin
|
|
||||||
fi
|
|
||||||
chmod +x ghcup-bin
|
|
||||||
./ghcup-bin install ${GHC_VERSION}
|
|
||||||
./ghcup-bin install-cabal ${CABAL_VERSION}
|
|
||||||
|
|
||||||
# utils
|
|
||||||
apk add --no-cache \
|
|
||||||
bash \
|
|
||||||
git
|
|
||||||
|
|
||||||
## Package specific
|
|
||||||
apk add --no-cache \
|
|
||||||
zlib \
|
|
||||||
zlib-dev \
|
|
||||||
zlib-static \
|
|
||||||
gmp \
|
|
||||||
gmp-dev \
|
|
||||||
openssl-dev \
|
|
||||||
openssl-libs-static \
|
|
||||||
xz \
|
|
||||||
xz-dev \
|
|
||||||
ncurses-static
|
|
||||||
|
|
||||||
ln -sf libncursesw.a /usr/lib/libtinfow.a
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
. "$( cd "$(dirname "$0")" ; pwd -P )/../../ghcup_env"
|
|
||||||
|
|
||||||
mkdir -p "${TMPDIR}"
|
|
||||||
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev git wget
|
|
||||||
|
|
||||||
curl -sSfL https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup > ./ghcup-bin
|
|
||||||
chmod +x ghcup-bin
|
|
||||||
|
|
||||||
./ghcup-bin install ${GHC_VERSION}
|
|
||||||
./ghcup-bin set ${GHC_VERSION}
|
|
||||||
./ghcup-bin install-cabal ${CABAL_VERSION}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
|
|
||||||
export PATH="$CI_PROJECT_DIR/.ghcup/bin:$CI_PROJECT_DIR/.local/bin:$PATH"
|
|
||||||
export TMPDIR="$CI_PROJECT_DIR/tmp"
|
|
@ -1,39 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
. "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup_env"
|
|
||||||
|
|
||||||
mkdir -p "$CI_PROJECT_DIR"/.local/bin
|
|
||||||
|
|
||||||
ecabal() {
|
|
||||||
cabal --store-dir="$(pwd)"/.store "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
git describe
|
|
||||||
|
|
||||||
# build
|
|
||||||
ecabal update
|
|
||||||
|
|
||||||
if [ "${OS}" = "LINUX" ] ; then
|
|
||||||
if [ "${BIT}" = "32" ] ; then
|
|
||||||
ecabal build -w ghc-${GHC_VERSION} --ghc-options='-split-sections -optl-static' -ftui -ftar
|
|
||||||
else
|
|
||||||
ecabal build -w ghc-${GHC_VERSION} --ghc-options='-split-sections -optl-static' -ftui -finternal-downloader
|
|
||||||
fi
|
|
||||||
elif [ "${OS}" = "FREEBSD" ] ; then
|
|
||||||
ecabal build -w ghc-${GHC_VERSION} --ghc-options='-split-sections' --constraint="zlib static" -ftui
|
|
||||||
else
|
|
||||||
ecabal build -w ghc-${GHC_VERSION} --constraint="zlib static" --constraint="lzma static" -ftui
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir out
|
|
||||||
cp "$(ecabal new-exec -w ghc-${GHC_VERSION} --verbose=0 --offline sh -- -c 'command -v ghcup')" .
|
|
||||||
ver=$(./ghcup --numeric-version)
|
|
||||||
if [ "${OS}" = "DARWIN" ] ; then
|
|
||||||
strip ./ghcup
|
|
||||||
else
|
|
||||||
strip -s ./ghcup
|
|
||||||
fi
|
|
||||||
cp ghcup out/${ARTIFACT}-${ver}
|
|
||||||
|
|
@ -1,92 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
. "$( cd "$(dirname "$0")" ; pwd -P )/../ghcup_env"
|
|
||||||
|
|
||||||
mkdir -p "$CI_PROJECT_DIR"/.local/bin
|
|
||||||
|
|
||||||
ecabal() {
|
|
||||||
cabal --store-dir="$(pwd)"/.store "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
eghcup() {
|
|
||||||
ghcup -v -c -s file://$(pwd)/ghcup-${JSON_VERSION}.json "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
git describe --always
|
|
||||||
|
|
||||||
### build
|
|
||||||
|
|
||||||
ecabal update
|
|
||||||
|
|
||||||
if [ "${OS}" = "DARWIN" ] ; then
|
|
||||||
ecabal build -w ghc-${GHC_VERSION} -ftui
|
|
||||||
else
|
|
||||||
ecabal build -w ghc-${GHC_VERSION} -finternal-downloader -ftui
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup')" .
|
|
||||||
cp "$(ecabal new-exec --enable-tests --verbose=0 --offline sh -- -c 'command -v ghcup-gen')" .
|
|
||||||
|
|
||||||
cp ./ghcup "$CI_PROJECT_DIR"/.local/bin/ghcup
|
|
||||||
cp ./ghcup-gen "$CI_PROJECT_DIR"/.local/bin/ghcup-gen
|
|
||||||
|
|
||||||
### cleanup
|
|
||||||
|
|
||||||
rm -rf "${GHCUP_INSTALL_BASE_PREFIX}"/.ghcup
|
|
||||||
|
|
||||||
|
|
||||||
### manual cli based testing
|
|
||||||
|
|
||||||
|
|
||||||
ghcup-gen check -f ghcup-${JSON_VERSION}.json
|
|
||||||
|
|
||||||
eghcup --numeric-version
|
|
||||||
|
|
||||||
# TODO: rm once we have tarballs
|
|
||||||
if [ "${OS}" = "FREEBSD" ] ; then
|
|
||||||
GHC_VERSION=8.6.3
|
|
||||||
CABAL_VERSION=2.4.1.0
|
|
||||||
fi
|
|
||||||
|
|
||||||
eghcup install ${GHC_VERSION}
|
|
||||||
eghcup set ${GHC_VERSION}
|
|
||||||
eghcup install-cabal ${CABAL_VERSION}
|
|
||||||
|
|
||||||
cabal --version
|
|
||||||
|
|
||||||
eghcup debug-info
|
|
||||||
|
|
||||||
eghcup list
|
|
||||||
eghcup list -t ghc
|
|
||||||
eghcup list -t cabal
|
|
||||||
|
|
||||||
ghc_ver=$(ghc --numeric-version)
|
|
||||||
ghc --version
|
|
||||||
ghci --version
|
|
||||||
ghc-$(ghc --numeric-version) --version
|
|
||||||
ghci-$(ghc --numeric-version) --version
|
|
||||||
|
|
||||||
|
|
||||||
# test installing new ghc doesn't mess with currently set GHC
|
|
||||||
# https://gitlab.haskell.org/haskell/ghcup-hs/issues/7
|
|
||||||
if [ "${OS}" = "LINUX" ] ; then
|
|
||||||
eghcup --downloader=wget install 8.4.4
|
|
||||||
else # test wget a bit
|
|
||||||
eghcup install 8.4.4
|
|
||||||
fi
|
|
||||||
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
|
||||||
eghcup set 8.4.4
|
|
||||||
eghcup set 8.4.4
|
|
||||||
[ "$(ghc --numeric-version)" = "8.4.4" ]
|
|
||||||
eghcup set ${GHC_VERSION}
|
|
||||||
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
|
||||||
eghcup rm 8.4.4
|
|
||||||
[ "$(ghc --numeric-version)" = "${ghc_ver}" ]
|
|
||||||
|
|
||||||
eghcup rm $(ghc --numeric-version)
|
|
||||||
|
|
||||||
eghcup upgrade
|
|
||||||
eghcup upgrade -f
|
|
||||||
|
|
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[submodule "data/metadata"]
|
||||||
|
path = data/metadata
|
||||||
|
url = https://github.com/haskell/ghcup-metadata.git
|
||||||
|
branch = develop
|
84
.hlint.yaml
Normal file
84
.hlint.yaml
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# HLint configuration file
|
||||||
|
# https://github.com/ndmitchell/hlint
|
||||||
|
##########################
|
||||||
|
|
||||||
|
# This file contains a template configuration file, which is typically
|
||||||
|
# placed as .hlint.yaml in the root of your project
|
||||||
|
|
||||||
|
|
||||||
|
# Warnings currently triggered by your code
|
||||||
|
- ignore: {name: "Redundant bang pattern"}
|
||||||
|
- ignore: {name: "Use camelCase"}
|
||||||
|
- ignore: {name: "Use if"}
|
||||||
|
- ignore: {name: "Use newtype instead of data"}
|
||||||
|
- ignore: {name: "Use <$>"}
|
||||||
|
- ignore: {name: "Use mapMaybe"}
|
||||||
|
- ignore: {name: "Use const"}
|
||||||
|
- ignore: {name: "Use list comprehension"}
|
||||||
|
- ignore: {name: "Redundant multi-way if"}
|
||||||
|
- ignore: {name: "Redundant lambda"}
|
||||||
|
- ignore: {name: "Avoid lambda"}
|
||||||
|
- ignore: {name: "Use uncurry"}
|
||||||
|
- ignore: {name: "Use replicateM"}
|
||||||
|
- ignore: {name: "Use unless"}
|
||||||
|
- ignore: {name: "Redundant irrefutable pattern"}
|
||||||
|
|
||||||
|
|
||||||
|
# Specify additional command line arguments
|
||||||
|
#
|
||||||
|
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
|
||||||
|
|
||||||
|
|
||||||
|
# Control which extensions/flags/modules/functions can be used
|
||||||
|
#
|
||||||
|
# - extensions:
|
||||||
|
# - default: false # all extension are banned by default
|
||||||
|
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
|
||||||
|
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
|
||||||
|
#
|
||||||
|
# - flags:
|
||||||
|
# - {name: -w, within: []} # -w is allowed nowhere
|
||||||
|
#
|
||||||
|
# - modules:
|
||||||
|
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
|
||||||
|
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
|
||||||
|
#
|
||||||
|
# - functions:
|
||||||
|
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
|
||||||
|
|
||||||
|
|
||||||
|
# Add custom hints for this project
|
||||||
|
#
|
||||||
|
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
|
||||||
|
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
|
||||||
|
|
||||||
|
# The hints are named by the string they display in warning messages.
|
||||||
|
# For example, if you see a warning starting like
|
||||||
|
#
|
||||||
|
# Main.hs:116:51: Warning: Redundant ==
|
||||||
|
#
|
||||||
|
# You can refer to that hint with `{name: Redundant ==}` (see below).
|
||||||
|
|
||||||
|
# Turn on hints that are off by default
|
||||||
|
#
|
||||||
|
# Ban "module X(module X) where", to require a real export list
|
||||||
|
# - warn: {name: Use explicit module export list}
|
||||||
|
#
|
||||||
|
# Replace a $ b $ c with a . b $ c
|
||||||
|
# - group: {name: dollar, enabled: true}
|
||||||
|
#
|
||||||
|
# Generalise map to fmap, ++ to <>
|
||||||
|
# - group: {name: generalise, enabled: true}
|
||||||
|
|
||||||
|
|
||||||
|
# Ignore some builtin hints
|
||||||
|
# - ignore: {name: Use let}
|
||||||
|
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
|
||||||
|
|
||||||
|
|
||||||
|
# Define some custom infix operators
|
||||||
|
# - fixity: infixr 3 ~^#^~
|
||||||
|
|
||||||
|
|
||||||
|
# To generate a suitable file for HLint do:
|
||||||
|
# $ hlint --default > .hlint.yaml
|
25
.travis.yml
25
.travis.yml
@ -1,25 +0,0 @@
|
|||||||
jobs:
|
|
||||||
include:
|
|
||||||
- os: osx
|
|
||||||
osx_image: xcode10.1
|
|
||||||
language: generic
|
|
||||||
env: ARTIFACT=x86_64-apple-darwin-10.13-ghcup
|
|
||||||
|
|
||||||
- os: osx
|
|
||||||
osx_image: xcode11.3
|
|
||||||
language: generic
|
|
||||||
env: ARTIFACT=x86_64-apple-darwin-10.14-ghcup
|
|
||||||
|
|
||||||
script: ".travis/build.sh"
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: releases
|
|
||||||
api_key:
|
|
||||||
secure: GQESg4TcYf3PQJRRaZV/kWS0hsF+OFnH2+EcwpgnIcfx4+aogMyprdh745KtBXe1FlFN1luKHksFjqceqhcg/xcNyeCJiSnLWMn4D/i4WUperEHseRBi5yZZCB1AvOjIlHrE4DS3a8pyEm1GV3G7CKY5Fu8jBjof2SnyENfd7fofhjtNHWmeFS+jBn8HRDf1YaSRYxzTw6uHLrPLsybfgQZVl7babMu/38Ghin0f5pz5OlNokzDxaubIYQHOZ7st7YndHJtBWWql/KualBWbMILy88dUVQBnbqQLP2P8d1ME8ILUjJVqz33HiRU0JzlEJyWfbvEjcJ6iD8M6n4nXTaxfu3i2UhhGsQ6SSBNKssMP4tji8nkNpMqG59wLQ/zhcetEm71fKkgJNrIMNllkqlWSo5K74IqqP9kiLg/qm8ipOJjui0gPk8tZXKcV+ztX1d1OVCapoLfiDM5l/0LLQXaTOXOV1x3e5LLQ/w2doNiH3eh5CV4II9dRu7owpaiiMBHMssmT0pH99jEeF6giHLKtt3y7l2GWoRLPdhsZZ54gxsaBxZt9GuypmkbNcr97CEnAVaWij5v0CF3w4rAWqy/tAxQpIDJOIOQBgmwG5WrBAKyKrFvEpBL5a8BPcRWJDvqKC83QeWpvPrEVdgJevC6ZN1MKzrb2SiPOwC2Kerc=
|
|
||||||
file: $ARTIFACT
|
|
||||||
on:
|
|
||||||
repo: haskell/ghcup-hs
|
|
||||||
tags: true
|
|
||||||
skip_cleanup: true
|
|
||||||
draft: true
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
## install ghc via old ghcup
|
|
||||||
|
|
||||||
mkdir -p ~/.ghcup/bin
|
|
||||||
curl https://gitlab.haskell.org/haskell/ghcup/raw/master/ghcup > ~/.ghcup/bin/ghcup
|
|
||||||
chmod +x ~/.ghcup/bin/ghcup
|
|
||||||
|
|
||||||
export PATH="$HOME/.ghcup/bin:$PATH"
|
|
||||||
|
|
||||||
ghcup install 8.8.3
|
|
||||||
ghcup install-cabal 3.2.0.0
|
|
||||||
ghcup set 8.8.3
|
|
||||||
|
|
||||||
|
|
||||||
## install ghcup
|
|
||||||
|
|
||||||
cabal update
|
|
||||||
cabal build --constraint="zlib static" --constraint="lzma static" -ftui
|
|
||||||
cp "$(cabal new-exec --verbose=0 --offline sh -- -c 'command -v ghcup')" .
|
|
||||||
strip ./ghcup
|
|
||||||
cp ghcup "./${ARTIFACT}"
|
|
1
3rdparty/libarchive/.gitattributes
vendored
1
3rdparty/libarchive/.gitattributes
vendored
@ -1 +0,0 @@
|
|||||||
*.chs linguist-language=Haskell
|
|
14
3rdparty/libarchive/.gitignore
vendored
14
3rdparty/libarchive/.gitignore
vendored
@ -1,14 +0,0 @@
|
|||||||
*.swp
|
|
||||||
.ghc.environment*
|
|
||||||
tags
|
|
||||||
*.prof
|
|
||||||
*.hp
|
|
||||||
*.eventlog
|
|
||||||
dist-newstyle
|
|
||||||
*.tar
|
|
||||||
*.chi
|
|
||||||
*.chs.h
|
|
||||||
.hspec-failures
|
|
||||||
.stack-work
|
|
||||||
libarchive-*.tar.*
|
|
||||||
libarchive-*/
|
|
13
3rdparty/libarchive/.hlint.yaml
vendored
13
3rdparty/libarchive/.hlint.yaml
vendored
@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
- functions:
|
|
||||||
- {name: undefined, within: []}
|
|
||||||
- {name: traceShowId, within: []}
|
|
||||||
- {name: print, within: []}
|
|
||||||
- {name: traceShow, within: []}
|
|
||||||
- {name: nullPtr, within: [Codec.Archive.Unpack, Codec.Archive.Foreign.Archive]}
|
|
||||||
|
|
||||||
- error: {lhs: "if p then x else pure ()", rhs: "when p x"}
|
|
||||||
- ignore: {name: Use lambda-case}
|
|
||||||
|
|
||||||
- fixity: infixr 8 .*
|
|
||||||
- fixity: infixr 8 .**
|
|
4
3rdparty/libarchive/.hspec
vendored
4
3rdparty/libarchive/.hspec
vendored
@ -1,4 +0,0 @@
|
|||||||
--fail-fast
|
|
||||||
--failure-report .hspec-failures
|
|
||||||
--rerun
|
|
||||||
--rerun-all-on-success
|
|
24
3rdparty/libarchive/.stylish-haskell.yaml
vendored
24
3rdparty/libarchive/.stylish-haskell.yaml
vendored
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
steps:
|
|
||||||
- simple_align:
|
|
||||||
cases: true
|
|
||||||
top_level_patterns: true
|
|
||||||
records: true
|
|
||||||
- imports:
|
|
||||||
align: global
|
|
||||||
list_align: after_alias
|
|
||||||
pad_module_names: true
|
|
||||||
long_list_align: inline
|
|
||||||
empty_list_align: inherit
|
|
||||||
list_padding: 4
|
|
||||||
separate_lists: true
|
|
||||||
space_surround: false
|
|
||||||
- language_pragmas:
|
|
||||||
style: vertical
|
|
||||||
align: true
|
|
||||||
remove_redundant: false
|
|
||||||
|
|
||||||
- trailing_whitespace: {}
|
|
||||||
columns: 160
|
|
||||||
newline: native
|
|
||||||
language_extensions: [FlexibleContexts]
|
|
152
3rdparty/libarchive/CHANGELOG.md
vendored
152
3rdparty/libarchive/CHANGELOG.md
vendored
@ -1,152 +0,0 @@
|
|||||||
# libarchive
|
|
||||||
|
|
||||||
## 2.2.5.0
|
|
||||||
|
|
||||||
* Speed improvements in places
|
|
||||||
* Add `throwArchiveM` convenience function
|
|
||||||
|
|
||||||
## 2.2.4.0
|
|
||||||
|
|
||||||
* Add convenience functions for `.xar` archives
|
|
||||||
|
|
||||||
## 2.2.3.0
|
|
||||||
|
|
||||||
* Add convenience functions for working with `.cpio` archives
|
|
||||||
|
|
||||||
## 2.2.2.0
|
|
||||||
|
|
||||||
* Add `Ord` instance to `Entry`, `Symlink`, `EntryContent`, `Ownership`
|
|
||||||
* Make `content` field of `Entry` lazy
|
|
||||||
* Add `Eq` instance to `ArchiveEncryption`
|
|
||||||
|
|
||||||
## 2.2.1.0
|
|
||||||
|
|
||||||
* Add `Exception` instance for `ArchiveResult`
|
|
||||||
|
|
||||||
## 2.2.0.2
|
|
||||||
|
|
||||||
* Use `bracket` where it doesn't crash GHC
|
|
||||||
|
|
||||||
## 2.2.0.1
|
|
||||||
|
|
||||||
* Use `bracket` in a few places where it doesn't crash GHC
|
|
||||||
|
|
||||||
## 2.2.0.0
|
|
||||||
|
|
||||||
* Haskell `Entry` type now includes `Symlink` field
|
|
||||||
|
|
||||||
## 2.1.3.2
|
|
||||||
|
|
||||||
* Fix segfault in strict function
|
|
||||||
|
|
||||||
## 2.1.3.0
|
|
||||||
|
|
||||||
* `archiveVersionString` &c. are now pure
|
|
||||||
|
|
||||||
## 2.1.2.1
|
|
||||||
|
|
||||||
* Fixed bug that would cause segfaults on lazy bytestrings with large chunks
|
|
||||||
|
|
||||||
## 2.1.2.0
|
|
||||||
|
|
||||||
* More complete API
|
|
||||||
|
|
||||||
## 2.1.1.0
|
|
||||||
|
|
||||||
* Remove weeds, export things that were missing from past releases
|
|
||||||
|
|
||||||
## 2.1.0.1
|
|
||||||
|
|
||||||
* `packEntries` and friends now detect hardlinks
|
|
||||||
* Add `Cabal` to `custom-setup` depends to ensure builds work with stack
|
|
||||||
|
|
||||||
## 2.1.0.0
|
|
||||||
|
|
||||||
* Remove `archiveEntryAclNext` since it doesn't exist in the static linked
|
|
||||||
library. This means `libarchive` can be used in profiling builds.
|
|
||||||
|
|
||||||
## 2.0.0.2
|
|
||||||
|
|
||||||
* Export `FilePtr` type constructor
|
|
||||||
* Clean up spurious code
|
|
||||||
|
|
||||||
## 2.0.0.1
|
|
||||||
|
|
||||||
* Polish documentation
|
|
||||||
|
|
||||||
## 2.0.0.0
|
|
||||||
|
|
||||||
* Fix typo in documentation
|
|
||||||
* Improve docs
|
|
||||||
* `archiveReadOpenMemory` now accepts an argument of type `Ptr a` rather
|
|
||||||
than `Ptr CChar`
|
|
||||||
* `unpackToDirLazy`, `unpackArchive`, and `archiveUnpackToDir` now occur in the `ArchiveM` monad
|
|
||||||
* `readArchiveBSL` and `readArchiveBS` now return `Either ArchiveResult [Entry]` rather than
|
|
||||||
failing silently
|
|
||||||
* `readArchiveFile` now returns an `ArchiveM [Entry]` rather than returning an
|
|
||||||
`IO [Entry]`
|
|
||||||
* `enriesToFile`, `entriesToFile7Zip`, and `entriesToFileZip` now occur in the
|
|
||||||
`ArchiveM` monad
|
|
||||||
* Make various parts of an `Entry` optional
|
|
||||||
* Add `packToFile` functions and `packFiles` functions
|
|
||||||
* Remove `ArchiveError` newtype, replace it with `ArchiveResult`
|
|
||||||
* Fix bug in `archiveEntryMTimeIsSet`
|
|
||||||
* Add `archiveEntryACLEntryInherited`, `archiveEntryACLStyleSolaris`,
|
|
||||||
`archiveEntryACLStyleSeparatorComma`, `archiveEntryACLStyleCompact`
|
|
||||||
* Add `archiveReadDiskNoAcl`, `archiveReadDiskNoFFlags`
|
|
||||||
* Depend on `libarchive` >= 3.4.0
|
|
||||||
* Remove `Raw` modules, use c2hs throughout.
|
|
||||||
* Fix potential bug with lazy bytestrings of nonstandard size
|
|
||||||
|
|
||||||
## 1.0.5.1
|
|
||||||
|
|
||||||
* Add `cross` flag
|
|
||||||
|
|
||||||
## 1.0.5.0
|
|
||||||
|
|
||||||
* Add facilities for lazy packing, e.g. `entriesToBSL`
|
|
||||||
* Minor documentation fixes
|
|
||||||
|
|
||||||
## 1.0.4.0
|
|
||||||
|
|
||||||
* Add `noOpenCallback`
|
|
||||||
* Add various facilities for lazy/streaming archives, viz. `unpackToDirLazy`,
|
|
||||||
`bslToArchive`, and `readArchiveBSL`.
|
|
||||||
* Remove `unsafe` stuff everywhere
|
|
||||||
|
|
||||||
## 1.0.3.0
|
|
||||||
|
|
||||||
* Fix types for `archive_set_read_callback` and
|
|
||||||
`archive_read_set_seek_callback`
|
|
||||||
|
|
||||||
## 1.0.2.0
|
|
||||||
|
|
||||||
* Add `Eq` instance for `ArchiveFormat`
|
|
||||||
|
|
||||||
## 1.0.1.0
|
|
||||||
|
|
||||||
* Remove functions from libarchive 3.3.3
|
|
||||||
|
|
||||||
## 1.0.0.0
|
|
||||||
|
|
||||||
* Get rid of `cbits`
|
|
||||||
* Add low-level FFI bindings
|
|
||||||
* Add high-level functions for unpacking archives
|
|
||||||
|
|
||||||
## 0.2.1.2
|
|
||||||
|
|
||||||
* Stream from a file when using `unpackArchive`
|
|
||||||
|
|
||||||
## 0.2.1.1
|
|
||||||
|
|
||||||
* Preserve modification times by default
|
|
||||||
|
|
||||||
## 0.2.1.0
|
|
||||||
|
|
||||||
* Enable autodetection of archive format/compression
|
|
||||||
* Slightly improved docs
|
|
||||||
* Rename `unpackTarball` to `unpackArchive`
|
|
||||||
|
|
||||||
## 0.2.0.0
|
|
||||||
|
|
||||||
* Fix bug in paths
|
|
11
3rdparty/libarchive/LICENSE
vendored
11
3rdparty/libarchive/LICENSE
vendored
@ -1,11 +0,0 @@
|
|||||||
Copyright Vanessa McHale (c) 2018-2020
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
42
3rdparty/libarchive/Makefile
vendored
42
3rdparty/libarchive/Makefile
vendored
@ -1,42 +0,0 @@
|
|||||||
.PHONY: clean
|
|
||||||
|
|
||||||
MAKEFLAGS += --warn-undefined-variables --no-builtin-rules -j
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
|
||||||
setup: test/data/ghc-8.8.1-src.tar test/data/alsa-lib-1.1.9.tar test/data/llvm-9.0.0.src.tar test/data/ATS2-Postiats-0.3.13.tar test/data/libarchive-1.0.5.1.tar
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf dist-newstyle dist test/data/*.tar* test/data/*.tgz *.hp *.prof *.chi *.chs.h stack.yaml.lock .hspec-failures .stack-work tags *.svg
|
|
||||||
|
|
||||||
test/data:
|
|
||||||
mkdir -p $@
|
|
||||||
|
|
||||||
test/data/ghc-8.8.1-src.tar: test/data/ghc-8.8.1-src.tar.xz
|
|
||||||
xz -d -f $^
|
|
||||||
|
|
||||||
test/data/alsa-lib-1.1.9.tar: test/data/alsa-lib-1.1.9.tar.bz2
|
|
||||||
bzip2 -d -f $^
|
|
||||||
|
|
||||||
test/data/llvm-9.0.0.src.tar: test/data/llvm-9.0.0.src.tar.xz
|
|
||||||
xz -d -f $^
|
|
||||||
|
|
||||||
test/data/ATS2-Postiats-0.3.13.tar: test/data/ATS2-Postiats-0.3.13.tgz
|
|
||||||
gunzip -f $^
|
|
||||||
|
|
||||||
test/data/libarchive-1.0.5.1.tar: test/data/libarchive-1.0.5.1.tar.gz
|
|
||||||
gunzip -f $^
|
|
||||||
|
|
||||||
test/data/ghc-8.8.1-src.tar.xz: test/data
|
|
||||||
wget https://downloads.haskell.org/~ghc/8.8.1/ghc-8.8.1-src.tar.xz -O $@
|
|
||||||
|
|
||||||
test/data/alsa-lib-1.1.9.tar.bz2: test/data
|
|
||||||
wget https://www.alsa-project.org/files/pub/lib/alsa-lib-1.1.9.tar.bz2 -O $@
|
|
||||||
|
|
||||||
test/data/llvm-9.0.0.src.tar.xz: test/data
|
|
||||||
wget http://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz -O $@
|
|
||||||
|
|
||||||
test/data/ATS2-Postiats-0.3.13.tgz: test/data
|
|
||||||
wget http://ats-lang.sourceforge.net/IMPLEMENT/Postiats/ATS2-Postiats-0.3.13.tgz -O $@
|
|
||||||
|
|
||||||
test/data/libarchive-1.0.5.1.tar.gz: test/data
|
|
||||||
wget http://hackage.haskell.org/package/libarchive-1.0.5.1/libarchive-1.0.5.1.tar.gz -O $@
|
|
28
3rdparty/libarchive/README.md
vendored
28
3rdparty/libarchive/README.md
vendored
@ -1,28 +0,0 @@
|
|||||||
# libarchive
|
|
||||||
|
|
||||||
[![Hackage CI](https://matrix.hackage.haskell.org/api/v2/packages/libarchive/badge)](https://matrix.hackage.haskell.org/package/libarchive)
|
|
||||||
[![Hackage](https://img.shields.io/hackage/v/libarchive.svg)](http://hackage.haskell.org/package/libarchive)
|
|
||||||
[![Dependencies of latest version on Hackage](https://img.shields.io/hackage-deps/v/libarchive.svg)](https://hackage.haskell.org/package/libarchive)
|
|
||||||
|
|
||||||
This contains Haskell bindings to
|
|
||||||
[libarchive](http://libarchive.org/). It was created as an alternative to
|
|
||||||
[tar](http://hackage.haskell.org/package/tar) and
|
|
||||||
[tar-conduit](http://hackage.haskell.org/package/tar-conduit), but it supports
|
|
||||||
more archive formats.
|
|
||||||
|
|
||||||
It has a high-level Haskell API for creating and unpacking archives in addition
|
|
||||||
to the C API. Like the `tar` package, it can stream from lazy `ByteString`s.
|
|
||||||
|
|
||||||
## Hacking
|
|
||||||
|
|
||||||
To run the test suite, first run
|
|
||||||
|
|
||||||
```
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
so that you have appropriate test data downloaded.
|
|
||||||
|
|
||||||
## Performance
|
|
||||||
|
|
||||||
`libarchive` is faster than `tar` or `tar-conduit` when unpacking archives.
|
|
6
3rdparty/libarchive/Setup.hs
vendored
6
3rdparty/libarchive/Setup.hs
vendored
@ -1,6 +0,0 @@
|
|||||||
module Main (main) where
|
|
||||||
|
|
||||||
import Distribution.C2Hs (defaultMainC2Hs)
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main = defaultMainC2Hs
|
|
26
3rdparty/libarchive/TODO.md
vendored
26
3rdparty/libarchive/TODO.md
vendored
@ -1,26 +0,0 @@
|
|||||||
# Code Maintenance
|
|
||||||
- [ ] Test suite
|
|
||||||
- [ ] Figure out how to test for memory leaks
|
|
||||||
- [ ] Space leak via Neil Mitchell
|
|
||||||
- [ ] Valgrind?
|
|
||||||
- [x] Test edge cases (non-standard chunk sizes)
|
|
||||||
- [ ] Test multithreaded (start unpacking in one thread)
|
|
||||||
- [ ] CI
|
|
||||||
- [x] Nix integration (`cabal2nix`)
|
|
||||||
- [x] Dependent on upstream
|
|
||||||
# Performance
|
|
||||||
- [ ] Fix actual laziness (?) -> appears downstream in sak in particular
|
|
||||||
conditions
|
|
||||||
# Bugs
|
|
||||||
- [ ] segfault (libarchive?) when I mess with .tar files
|
|
||||||
- [ ] librachive haskell broken? my .7z and .xar outputs aren't great
|
|
||||||
- [ ] Fix space leak in converting stuff (bad; also from verify-archive)
|
|
||||||
# Features
|
|
||||||
- [ ] xar? 7zip?
|
|
||||||
# Documentation
|
|
||||||
- [ ] Add example in haddocks
|
|
||||||
- [ ] Document ability to use via `archive-sig`/`archive-libarchive`.
|
|
||||||
# Upstream
|
|
||||||
- [ ] PVP for signatures?
|
|
||||||
- [ ] sig: specify compatible stuff? versions not clear...
|
|
||||||
- [ ] GHC: `bracket` branch? What is going on??
|
|
13
3rdparty/libarchive/bash/display
vendored
13
3rdparty/libarchive/bash/display
vendored
@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
case "$(uname)" in
|
|
||||||
"Darwin") svg_open="open";;
|
|
||||||
*) svg_open="firefox";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
cabal build mem --enable-profiling -w ghc-8.10.1
|
|
||||||
"$(fd '^mem$' -t x -I)" +RTS -h
|
|
||||||
hp2pretty mem.hp
|
|
||||||
$svg_open mem.svg
|
|
55
3rdparty/libarchive/bench/Bench.hs
vendored
55
3rdparty/libarchive/bench/Bench.hs
vendored
@ -1,55 +0,0 @@
|
|||||||
module Main (main) where
|
|
||||||
|
|
||||||
import Codec.Archive
|
|
||||||
import Codec.Archive.Tar (Entries (..), FormatError)
|
|
||||||
import qualified Codec.Archive.Tar as Tar
|
|
||||||
import Control.Monad (void)
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
|
||||||
import Criterion.Main
|
|
||||||
import qualified Data.ByteString.Lazy as BSL
|
|
||||||
import Data.Conduit.Tar as TarConduit
|
|
||||||
import System.IO.Temp (withSystemTempDirectory)
|
|
||||||
|
|
||||||
roundtrip :: BSL.ByteString -> Either ArchiveResult BSL.ByteString
|
|
||||||
roundtrip = fmap entriesToBSL . readArchiveBSL
|
|
||||||
|
|
||||||
failTar :: Entries a -> Either a [Tar.Entry]
|
|
||||||
failTar (Next e es) = (e :) <$> failTar es
|
|
||||||
failTar Done = Right []
|
|
||||||
failTar (Fail e) = Left e
|
|
||||||
|
|
||||||
roundtripTar :: BSL.ByteString -> Either FormatError BSL.ByteString
|
|
||||||
roundtripTar = fmap Tar.write . failTar . Tar.read
|
|
||||||
|
|
||||||
unpack :: IO (Either ArchiveResult ())
|
|
||||||
unpack = withSystemTempDirectory "libarchive" $
|
|
||||||
\fp -> runArchiveM $ unpackArchive "test/data/libarchive-1.0.5.1.tar" fp
|
|
||||||
|
|
||||||
unpackHs :: IO (Either ArchiveResult ())
|
|
||||||
unpackHs = withSystemTempDirectory "libarchive" $
|
|
||||||
\fp -> runArchiveM $ unpackToDirLazy fp =<< liftIO (BSL.readFile "test/data/libarchive-1.0.5.1.tar")
|
|
||||||
|
|
||||||
extractTar :: IO ()
|
|
||||||
extractTar = withSystemTempDirectory "tar" $
|
|
||||||
\fp -> Tar.extract fp "test/data/libarchive-1.0.5.1.tar"
|
|
||||||
|
|
||||||
-- I'm not even sure why I'm benchmarking this since it doesn't work
|
|
||||||
unpackTarConduit :: IO ()
|
|
||||||
unpackTarConduit = withSystemTempDirectory "tar" $
|
|
||||||
\fp -> void $ TarConduit.extractTarballLenient "test/data/libarchive-1.0.5.1.tar" (Just fp)
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main =
|
|
||||||
defaultMain [ env file $ \ f ->
|
|
||||||
bgroup "roundtrip"
|
|
||||||
[ bench "libarchive" $ nf roundtrip f
|
|
||||||
, bench "tar" $ nf roundtripTar f
|
|
||||||
]
|
|
||||||
, bgroup "unpack"
|
|
||||||
[ bench "libarchive (via bytestring)" $ nfIO unpackHs
|
|
||||||
, bench "libarchive (C API)" $ nfIO unpack
|
|
||||||
, bench "tar" $ nfIO extractTar
|
|
||||||
, bench "tarConduit" $ nfIO unpackTarConduit
|
|
||||||
]
|
|
||||||
]
|
|
||||||
where file = BSL.readFile "test/data/libarchive-1.0.5.1.tar"
|
|
1197
3rdparty/libarchive/c/archive.h
vendored
1197
3rdparty/libarchive/c/archive.h
vendored
File diff suppressed because it is too large
Load Diff
2097
3rdparty/libarchive/c/archive_acl.c
vendored
2097
3rdparty/libarchive/c/archive_acl.c
vendored
File diff suppressed because it is too large
Load Diff
83
3rdparty/libarchive/c/archive_acl_private.h
vendored
83
3rdparty/libarchive/c/archive_acl_private.h
vendored
@ -1,83 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2010 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ACL_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_ACL_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_string.h"
|
|
||||||
|
|
||||||
struct archive_acl_entry {
|
|
||||||
struct archive_acl_entry *next;
|
|
||||||
int type; /* E.g., access or default */
|
|
||||||
int tag; /* E.g., user/group/other/mask */
|
|
||||||
int permset; /* r/w/x bits */
|
|
||||||
int id; /* uid/gid for user/group */
|
|
||||||
struct archive_mstring name; /* uname/gname */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct archive_acl {
|
|
||||||
mode_t mode;
|
|
||||||
struct archive_acl_entry *acl_head;
|
|
||||||
struct archive_acl_entry *acl_p;
|
|
||||||
int acl_state; /* See acl_next for details. */
|
|
||||||
wchar_t *acl_text_w;
|
|
||||||
char *acl_text;
|
|
||||||
int acl_types;
|
|
||||||
};
|
|
||||||
|
|
||||||
void archive_acl_clear(struct archive_acl *);
|
|
||||||
void archive_acl_copy(struct archive_acl *, struct archive_acl *);
|
|
||||||
int archive_acl_count(struct archive_acl *, int);
|
|
||||||
int archive_acl_types(struct archive_acl *);
|
|
||||||
int archive_acl_reset(struct archive_acl *, int);
|
|
||||||
int archive_acl_next(struct archive *, struct archive_acl *, int,
|
|
||||||
int *, int *, int *, int *, const char **);
|
|
||||||
|
|
||||||
int archive_acl_add_entry(struct archive_acl *, int, int, int, int, const char *);
|
|
||||||
int archive_acl_add_entry_w_len(struct archive_acl *,
|
|
||||||
int, int, int, int, const wchar_t *, size_t);
|
|
||||||
int archive_acl_add_entry_len(struct archive_acl *,
|
|
||||||
int, int, int, int, const char *, size_t);
|
|
||||||
|
|
||||||
wchar_t *archive_acl_to_text_w(struct archive_acl *, ssize_t *, int,
|
|
||||||
struct archive *);
|
|
||||||
char *archive_acl_to_text_l(struct archive_acl *, ssize_t *, int,
|
|
||||||
struct archive_string_conv *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ACL text parser.
|
|
||||||
*/
|
|
||||||
int archive_acl_from_text_w(struct archive_acl *, const wchar_t * /* wtext */,
|
|
||||||
int /* type */);
|
|
||||||
int archive_acl_from_text_l(struct archive_acl *, const char * /* text */,
|
|
||||||
int /* type */, struct archive_string_conv *);
|
|
||||||
|
|
||||||
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
|
|
195
3rdparty/libarchive/c/archive_blake2.h
vendored
195
3rdparty/libarchive/c/archive_blake2.h
vendored
@ -1,195 +0,0 @@
|
|||||||
/*
|
|
||||||
BLAKE2 reference source code package - reference C implementations
|
|
||||||
|
|
||||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
|
||||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
|
||||||
your option. The terms of these licenses can be found at:
|
|
||||||
|
|
||||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
||||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
|
||||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
More information about the BLAKE2 hash function can be found at
|
|
||||||
https://blake2.net.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_BLAKE2_H
|
|
||||||
#define ARCHIVE_BLAKE2_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
|
|
||||||
#else
|
|
||||||
#define BLAKE2_PACKED(x) x __attribute__((packed))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum blake2s_constant
|
|
||||||
{
|
|
||||||
BLAKE2S_BLOCKBYTES = 64,
|
|
||||||
BLAKE2S_OUTBYTES = 32,
|
|
||||||
BLAKE2S_KEYBYTES = 32,
|
|
||||||
BLAKE2S_SALTBYTES = 8,
|
|
||||||
BLAKE2S_PERSONALBYTES = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
enum blake2b_constant
|
|
||||||
{
|
|
||||||
BLAKE2B_BLOCKBYTES = 128,
|
|
||||||
BLAKE2B_OUTBYTES = 64,
|
|
||||||
BLAKE2B_KEYBYTES = 64,
|
|
||||||
BLAKE2B_SALTBYTES = 16,
|
|
||||||
BLAKE2B_PERSONALBYTES = 16
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct blake2s_state__
|
|
||||||
{
|
|
||||||
uint32_t h[8];
|
|
||||||
uint32_t t[2];
|
|
||||||
uint32_t f[2];
|
|
||||||
uint8_t buf[BLAKE2S_BLOCKBYTES];
|
|
||||||
size_t buflen;
|
|
||||||
size_t outlen;
|
|
||||||
uint8_t last_node;
|
|
||||||
} blake2s_state;
|
|
||||||
|
|
||||||
typedef struct blake2b_state__
|
|
||||||
{
|
|
||||||
uint64_t h[8];
|
|
||||||
uint64_t t[2];
|
|
||||||
uint64_t f[2];
|
|
||||||
uint8_t buf[BLAKE2B_BLOCKBYTES];
|
|
||||||
size_t buflen;
|
|
||||||
size_t outlen;
|
|
||||||
uint8_t last_node;
|
|
||||||
} blake2b_state;
|
|
||||||
|
|
||||||
typedef struct blake2sp_state__
|
|
||||||
{
|
|
||||||
blake2s_state S[8][1];
|
|
||||||
blake2s_state R[1];
|
|
||||||
uint8_t buf[8 * BLAKE2S_BLOCKBYTES];
|
|
||||||
size_t buflen;
|
|
||||||
size_t outlen;
|
|
||||||
} blake2sp_state;
|
|
||||||
|
|
||||||
typedef struct blake2bp_state__
|
|
||||||
{
|
|
||||||
blake2b_state S[4][1];
|
|
||||||
blake2b_state R[1];
|
|
||||||
uint8_t buf[4 * BLAKE2B_BLOCKBYTES];
|
|
||||||
size_t buflen;
|
|
||||||
size_t outlen;
|
|
||||||
} blake2bp_state;
|
|
||||||
|
|
||||||
BLAKE2_PACKED(struct blake2s_param__
|
|
||||||
{
|
|
||||||
uint8_t digest_length; /* 1 */
|
|
||||||
uint8_t key_length; /* 2 */
|
|
||||||
uint8_t fanout; /* 3 */
|
|
||||||
uint8_t depth; /* 4 */
|
|
||||||
uint32_t leaf_length; /* 8 */
|
|
||||||
uint32_t node_offset; /* 12 */
|
|
||||||
uint16_t xof_length; /* 14 */
|
|
||||||
uint8_t node_depth; /* 15 */
|
|
||||||
uint8_t inner_length; /* 16 */
|
|
||||||
/* uint8_t reserved[0]; */
|
|
||||||
uint8_t salt[BLAKE2S_SALTBYTES]; /* 24 */
|
|
||||||
uint8_t personal[BLAKE2S_PERSONALBYTES]; /* 32 */
|
|
||||||
});
|
|
||||||
|
|
||||||
typedef struct blake2s_param__ blake2s_param;
|
|
||||||
|
|
||||||
BLAKE2_PACKED(struct blake2b_param__
|
|
||||||
{
|
|
||||||
uint8_t digest_length; /* 1 */
|
|
||||||
uint8_t key_length; /* 2 */
|
|
||||||
uint8_t fanout; /* 3 */
|
|
||||||
uint8_t depth; /* 4 */
|
|
||||||
uint32_t leaf_length; /* 8 */
|
|
||||||
uint32_t node_offset; /* 12 */
|
|
||||||
uint32_t xof_length; /* 16 */
|
|
||||||
uint8_t node_depth; /* 17 */
|
|
||||||
uint8_t inner_length; /* 18 */
|
|
||||||
uint8_t reserved[14]; /* 32 */
|
|
||||||
uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */
|
|
||||||
uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */
|
|
||||||
});
|
|
||||||
|
|
||||||
typedef struct blake2b_param__ blake2b_param;
|
|
||||||
|
|
||||||
typedef struct blake2xs_state__
|
|
||||||
{
|
|
||||||
blake2s_state S[1];
|
|
||||||
blake2s_param P[1];
|
|
||||||
} blake2xs_state;
|
|
||||||
|
|
||||||
typedef struct blake2xb_state__
|
|
||||||
{
|
|
||||||
blake2b_state S[1];
|
|
||||||
blake2b_param P[1];
|
|
||||||
} blake2xb_state;
|
|
||||||
|
|
||||||
/* Padded structs result in a compile-time error */
|
|
||||||
enum {
|
|
||||||
BLAKE2_DUMMY_1 = 1/(sizeof(blake2s_param) == BLAKE2S_OUTBYTES),
|
|
||||||
BLAKE2_DUMMY_2 = 1/(sizeof(blake2b_param) == BLAKE2B_OUTBYTES)
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Streaming API */
|
|
||||||
int blake2s_init( blake2s_state *S, size_t outlen );
|
|
||||||
int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen );
|
|
||||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P );
|
|
||||||
int blake2s_update( blake2s_state *S, const void *in, size_t inlen );
|
|
||||||
int blake2s_final( blake2s_state *S, void *out, size_t outlen );
|
|
||||||
|
|
||||||
int blake2b_init( blake2b_state *S, size_t outlen );
|
|
||||||
int blake2b_init_key( blake2b_state *S, size_t outlen, const void *key, size_t keylen );
|
|
||||||
int blake2b_init_param( blake2b_state *S, const blake2b_param *P );
|
|
||||||
int blake2b_update( blake2b_state *S, const void *in, size_t inlen );
|
|
||||||
int blake2b_final( blake2b_state *S, void *out, size_t outlen );
|
|
||||||
|
|
||||||
int blake2sp_init( blake2sp_state *S, size_t outlen );
|
|
||||||
int blake2sp_init_key( blake2sp_state *S, size_t outlen, const void *key, size_t keylen );
|
|
||||||
int blake2sp_update( blake2sp_state *S, const void *in, size_t inlen );
|
|
||||||
int blake2sp_final( blake2sp_state *S, void *out, size_t outlen );
|
|
||||||
|
|
||||||
int blake2bp_init( blake2bp_state *S, size_t outlen );
|
|
||||||
int blake2bp_init_key( blake2bp_state *S, size_t outlen, const void *key, size_t keylen );
|
|
||||||
int blake2bp_update( blake2bp_state *S, const void *in, size_t inlen );
|
|
||||||
int blake2bp_final( blake2bp_state *S, void *out, size_t outlen );
|
|
||||||
|
|
||||||
/* Variable output length API */
|
|
||||||
int blake2xs_init( blake2xs_state *S, const size_t outlen );
|
|
||||||
int blake2xs_init_key( blake2xs_state *S, const size_t outlen, const void *key, size_t keylen );
|
|
||||||
int blake2xs_update( blake2xs_state *S, const void *in, size_t inlen );
|
|
||||||
int blake2xs_final(blake2xs_state *S, void *out, size_t outlen);
|
|
||||||
|
|
||||||
int blake2xb_init( blake2xb_state *S, const size_t outlen );
|
|
||||||
int blake2xb_init_key( blake2xb_state *S, const size_t outlen, const void *key, size_t keylen );
|
|
||||||
int blake2xb_update( blake2xb_state *S, const void *in, size_t inlen );
|
|
||||||
int blake2xb_final(blake2xb_state *S, void *out, size_t outlen);
|
|
||||||
|
|
||||||
/* Simple API */
|
|
||||||
int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
int blake2b( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
|
|
||||||
int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
int blake2bp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
|
|
||||||
int blake2xs( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
int blake2xb( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
|
|
||||||
/* This is simply an alias for blake2b */
|
|
||||||
int blake2( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen );
|
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
161
3rdparty/libarchive/c/archive_blake2_impl.h
vendored
161
3rdparty/libarchive/c/archive_blake2_impl.h
vendored
@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
BLAKE2 reference source code package - reference C implementations
|
|
||||||
|
|
||||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
|
||||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
|
||||||
your option. The terms of these licenses can be found at:
|
|
||||||
|
|
||||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
||||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
|
||||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
More information about the BLAKE2 hash function can be found at
|
|
||||||
https://blake2.net.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_BLAKE2_IMPL_H
|
|
||||||
#define ARCHIVE_BLAKE2_IMPL_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#if !defined(__cplusplus) && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
#define BLAKE2_INLINE __inline
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
#define BLAKE2_INLINE __inline__
|
|
||||||
#else
|
|
||||||
#define BLAKE2_INLINE
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define BLAKE2_INLINE inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static BLAKE2_INLINE uint32_t load32( const void *src )
|
|
||||||
{
|
|
||||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
|
||||||
uint32_t w;
|
|
||||||
memcpy(&w, src, sizeof w);
|
|
||||||
return w;
|
|
||||||
#else
|
|
||||||
const uint8_t *p = ( const uint8_t * )src;
|
|
||||||
return (( uint32_t )( p[0] ) << 0) |
|
|
||||||
(( uint32_t )( p[1] ) << 8) |
|
|
||||||
(( uint32_t )( p[2] ) << 16) |
|
|
||||||
(( uint32_t )( p[3] ) << 24) ;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE uint64_t load64( const void *src )
|
|
||||||
{
|
|
||||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
|
||||||
uint64_t w;
|
|
||||||
memcpy(&w, src, sizeof w);
|
|
||||||
return w;
|
|
||||||
#else
|
|
||||||
const uint8_t *p = ( const uint8_t * )src;
|
|
||||||
return (( uint64_t )( p[0] ) << 0) |
|
|
||||||
(( uint64_t )( p[1] ) << 8) |
|
|
||||||
(( uint64_t )( p[2] ) << 16) |
|
|
||||||
(( uint64_t )( p[3] ) << 24) |
|
|
||||||
(( uint64_t )( p[4] ) << 32) |
|
|
||||||
(( uint64_t )( p[5] ) << 40) |
|
|
||||||
(( uint64_t )( p[6] ) << 48) |
|
|
||||||
(( uint64_t )( p[7] ) << 56) ;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE uint16_t load16( const void *src )
|
|
||||||
{
|
|
||||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
|
||||||
uint16_t w;
|
|
||||||
memcpy(&w, src, sizeof w);
|
|
||||||
return w;
|
|
||||||
#else
|
|
||||||
const uint8_t *p = ( const uint8_t * )src;
|
|
||||||
return ( uint16_t )((( uint32_t )( p[0] ) << 0) |
|
|
||||||
(( uint32_t )( p[1] ) << 8));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE void store16( void *dst, uint16_t w )
|
|
||||||
{
|
|
||||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
|
||||||
memcpy(dst, &w, sizeof w);
|
|
||||||
#else
|
|
||||||
uint8_t *p = ( uint8_t * )dst;
|
|
||||||
*p++ = ( uint8_t )w; w >>= 8;
|
|
||||||
*p++ = ( uint8_t )w;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE void store32( void *dst, uint32_t w )
|
|
||||||
{
|
|
||||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
|
||||||
memcpy(dst, &w, sizeof w);
|
|
||||||
#else
|
|
||||||
uint8_t *p = ( uint8_t * )dst;
|
|
||||||
p[0] = (uint8_t)(w >> 0);
|
|
||||||
p[1] = (uint8_t)(w >> 8);
|
|
||||||
p[2] = (uint8_t)(w >> 16);
|
|
||||||
p[3] = (uint8_t)(w >> 24);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE void store64( void *dst, uint64_t w )
|
|
||||||
{
|
|
||||||
#if defined(NATIVE_LITTLE_ENDIAN)
|
|
||||||
memcpy(dst, &w, sizeof w);
|
|
||||||
#else
|
|
||||||
uint8_t *p = ( uint8_t * )dst;
|
|
||||||
p[0] = (uint8_t)(w >> 0);
|
|
||||||
p[1] = (uint8_t)(w >> 8);
|
|
||||||
p[2] = (uint8_t)(w >> 16);
|
|
||||||
p[3] = (uint8_t)(w >> 24);
|
|
||||||
p[4] = (uint8_t)(w >> 32);
|
|
||||||
p[5] = (uint8_t)(w >> 40);
|
|
||||||
p[6] = (uint8_t)(w >> 48);
|
|
||||||
p[7] = (uint8_t)(w >> 56);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE uint64_t load48( const void *src )
|
|
||||||
{
|
|
||||||
const uint8_t *p = ( const uint8_t * )src;
|
|
||||||
return (( uint64_t )( p[0] ) << 0) |
|
|
||||||
(( uint64_t )( p[1] ) << 8) |
|
|
||||||
(( uint64_t )( p[2] ) << 16) |
|
|
||||||
(( uint64_t )( p[3] ) << 24) |
|
|
||||||
(( uint64_t )( p[4] ) << 32) |
|
|
||||||
(( uint64_t )( p[5] ) << 40) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE void store48( void *dst, uint64_t w )
|
|
||||||
{
|
|
||||||
uint8_t *p = ( uint8_t * )dst;
|
|
||||||
p[0] = (uint8_t)(w >> 0);
|
|
||||||
p[1] = (uint8_t)(w >> 8);
|
|
||||||
p[2] = (uint8_t)(w >> 16);
|
|
||||||
p[3] = (uint8_t)(w >> 24);
|
|
||||||
p[4] = (uint8_t)(w >> 32);
|
|
||||||
p[5] = (uint8_t)(w >> 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE uint32_t rotr32( const uint32_t w, const unsigned c )
|
|
||||||
{
|
|
||||||
return ( w >> c ) | ( w << ( 32 - c ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static BLAKE2_INLINE uint64_t rotr64( const uint64_t w, const unsigned c )
|
|
||||||
{
|
|
||||||
return ( w >> c ) | ( w << ( 64 - c ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* prevents compiler optimizing out memset() */
|
|
||||||
static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)
|
|
||||||
{
|
|
||||||
static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
|
|
||||||
memset_v(v, 0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
367
3rdparty/libarchive/c/archive_blake2s_ref.c
vendored
367
3rdparty/libarchive/c/archive_blake2s_ref.c
vendored
@ -1,367 +0,0 @@
|
|||||||
/*
|
|
||||||
BLAKE2 reference source code package - reference C implementations
|
|
||||||
|
|
||||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
|
||||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
|
||||||
your option. The terms of these licenses can be found at:
|
|
||||||
|
|
||||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
||||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
|
||||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
More information about the BLAKE2 hash function can be found at
|
|
||||||
https://blake2.net.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "archive_blake2.h"
|
|
||||||
#include "archive_blake2_impl.h"
|
|
||||||
|
|
||||||
static const uint32_t blake2s_IV[8] =
|
|
||||||
{
|
|
||||||
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
|
|
||||||
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t blake2s_sigma[10][16] =
|
|
||||||
{
|
|
||||||
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
|
|
||||||
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
|
|
||||||
{ 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
|
|
||||||
{ 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
|
|
||||||
{ 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
|
|
||||||
{ 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
|
|
||||||
{ 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
|
|
||||||
{ 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
|
|
||||||
{ 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
|
|
||||||
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void blake2s_set_lastnode( blake2s_state *S )
|
|
||||||
{
|
|
||||||
S->f[1] = (uint32_t)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some helper functions, not necessarily useful */
|
|
||||||
static int blake2s_is_lastblock( const blake2s_state *S )
|
|
||||||
{
|
|
||||||
return S->f[0] != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void blake2s_set_lastblock( blake2s_state *S )
|
|
||||||
{
|
|
||||||
if( S->last_node ) blake2s_set_lastnode( S );
|
|
||||||
|
|
||||||
S->f[0] = (uint32_t)-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void blake2s_increment_counter( blake2s_state *S, const uint32_t inc )
|
|
||||||
{
|
|
||||||
S->t[0] += inc;
|
|
||||||
S->t[1] += ( S->t[0] < inc );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void blake2s_init0( blake2s_state *S )
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
memset( S, 0, sizeof( blake2s_state ) );
|
|
||||||
|
|
||||||
for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* init2 xors IV with input parameter block */
|
|
||||||
int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
|
|
||||||
{
|
|
||||||
const unsigned char *p = ( const unsigned char * )( P );
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
blake2s_init0( S );
|
|
||||||
|
|
||||||
/* IV XOR ParamBlock */
|
|
||||||
for( i = 0; i < 8; ++i )
|
|
||||||
S->h[i] ^= load32( &p[i * 4] );
|
|
||||||
|
|
||||||
S->outlen = P->digest_length;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Sequential blake2s initialization */
|
|
||||||
int blake2s_init( blake2s_state *S, size_t outlen )
|
|
||||||
{
|
|
||||||
blake2s_param P[1];
|
|
||||||
|
|
||||||
/* Move interval verification here? */
|
|
||||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
|
||||||
|
|
||||||
P->digest_length = (uint8_t)outlen;
|
|
||||||
P->key_length = 0;
|
|
||||||
P->fanout = 1;
|
|
||||||
P->depth = 1;
|
|
||||||
store32( &P->leaf_length, 0 );
|
|
||||||
store32( &P->node_offset, 0 );
|
|
||||||
store16( &P->xof_length, 0 );
|
|
||||||
P->node_depth = 0;
|
|
||||||
P->inner_length = 0;
|
|
||||||
/* memset(P->reserved, 0, sizeof(P->reserved) ); */
|
|
||||||
memset( P->salt, 0, sizeof( P->salt ) );
|
|
||||||
memset( P->personal, 0, sizeof( P->personal ) );
|
|
||||||
return blake2s_init_param( S, P );
|
|
||||||
}
|
|
||||||
|
|
||||||
int blake2s_init_key( blake2s_state *S, size_t outlen, const void *key, size_t keylen )
|
|
||||||
{
|
|
||||||
blake2s_param P[1];
|
|
||||||
|
|
||||||
if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
|
|
||||||
|
|
||||||
if ( !key || !keylen || keylen > BLAKE2S_KEYBYTES ) return -1;
|
|
||||||
|
|
||||||
P->digest_length = (uint8_t)outlen;
|
|
||||||
P->key_length = (uint8_t)keylen;
|
|
||||||
P->fanout = 1;
|
|
||||||
P->depth = 1;
|
|
||||||
store32( &P->leaf_length, 0 );
|
|
||||||
store32( &P->node_offset, 0 );
|
|
||||||
store16( &P->xof_length, 0 );
|
|
||||||
P->node_depth = 0;
|
|
||||||
P->inner_length = 0;
|
|
||||||
/* memset(P->reserved, 0, sizeof(P->reserved) ); */
|
|
||||||
memset( P->salt, 0, sizeof( P->salt ) );
|
|
||||||
memset( P->personal, 0, sizeof( P->personal ) );
|
|
||||||
|
|
||||||
if( blake2s_init_param( S, P ) < 0 ) return -1;
|
|
||||||
|
|
||||||
{
|
|
||||||
uint8_t block[BLAKE2S_BLOCKBYTES];
|
|
||||||
memset( block, 0, BLAKE2S_BLOCKBYTES );
|
|
||||||
memcpy( block, key, keylen );
|
|
||||||
blake2s_update( S, block, BLAKE2S_BLOCKBYTES );
|
|
||||||
secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from stack */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define G(r,i,a,b,c,d) \
|
|
||||||
do { \
|
|
||||||
a = a + b + m[blake2s_sigma[r][2*i+0]]; \
|
|
||||||
d = rotr32(d ^ a, 16); \
|
|
||||||
c = c + d; \
|
|
||||||
b = rotr32(b ^ c, 12); \
|
|
||||||
a = a + b + m[blake2s_sigma[r][2*i+1]]; \
|
|
||||||
d = rotr32(d ^ a, 8); \
|
|
||||||
c = c + d; \
|
|
||||||
b = rotr32(b ^ c, 7); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
#define ROUND(r) \
|
|
||||||
do { \
|
|
||||||
G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
|
|
||||||
G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
|
|
||||||
G(r,2,v[ 2],v[ 6],v[10],v[14]); \
|
|
||||||
G(r,3,v[ 3],v[ 7],v[11],v[15]); \
|
|
||||||
G(r,4,v[ 0],v[ 5],v[10],v[15]); \
|
|
||||||
G(r,5,v[ 1],v[ 6],v[11],v[12]); \
|
|
||||||
G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
|
|
||||||
G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
|
|
||||||
} while(0)
|
|
||||||
|
|
||||||
static void blake2s_compress( blake2s_state *S, const uint8_t in[BLAKE2S_BLOCKBYTES] )
|
|
||||||
{
|
|
||||||
uint32_t m[16];
|
|
||||||
uint32_t v[16];
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
for( i = 0; i < 16; ++i ) {
|
|
||||||
m[i] = load32( in + i * sizeof( m[i] ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i = 0; i < 8; ++i ) {
|
|
||||||
v[i] = S->h[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
v[ 8] = blake2s_IV[0];
|
|
||||||
v[ 9] = blake2s_IV[1];
|
|
||||||
v[10] = blake2s_IV[2];
|
|
||||||
v[11] = blake2s_IV[3];
|
|
||||||
v[12] = S->t[0] ^ blake2s_IV[4];
|
|
||||||
v[13] = S->t[1] ^ blake2s_IV[5];
|
|
||||||
v[14] = S->f[0] ^ blake2s_IV[6];
|
|
||||||
v[15] = S->f[1] ^ blake2s_IV[7];
|
|
||||||
|
|
||||||
ROUND( 0 );
|
|
||||||
ROUND( 1 );
|
|
||||||
ROUND( 2 );
|
|
||||||
ROUND( 3 );
|
|
||||||
ROUND( 4 );
|
|
||||||
ROUND( 5 );
|
|
||||||
ROUND( 6 );
|
|
||||||
ROUND( 7 );
|
|
||||||
ROUND( 8 );
|
|
||||||
ROUND( 9 );
|
|
||||||
|
|
||||||
for( i = 0; i < 8; ++i ) {
|
|
||||||
S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef G
|
|
||||||
#undef ROUND
|
|
||||||
|
|
||||||
int blake2s_update( blake2s_state *S, const void *pin, size_t inlen )
|
|
||||||
{
|
|
||||||
const unsigned char * in = (const unsigned char *)pin;
|
|
||||||
if( inlen > 0 )
|
|
||||||
{
|
|
||||||
size_t left = S->buflen;
|
|
||||||
size_t fill = BLAKE2S_BLOCKBYTES - left;
|
|
||||||
if( inlen > fill )
|
|
||||||
{
|
|
||||||
S->buflen = 0;
|
|
||||||
memcpy( S->buf + left, in, fill ); /* Fill buffer */
|
|
||||||
blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
|
|
||||||
blake2s_compress( S, S->buf ); /* Compress */
|
|
||||||
in += fill; inlen -= fill;
|
|
||||||
while(inlen > BLAKE2S_BLOCKBYTES) {
|
|
||||||
blake2s_increment_counter(S, BLAKE2S_BLOCKBYTES);
|
|
||||||
blake2s_compress( S, in );
|
|
||||||
in += BLAKE2S_BLOCKBYTES;
|
|
||||||
inlen -= BLAKE2S_BLOCKBYTES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
memcpy( S->buf + S->buflen, in, inlen );
|
|
||||||
S->buflen += inlen;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int blake2s_final( blake2s_state *S, void *out, size_t outlen )
|
|
||||||
{
|
|
||||||
uint8_t buffer[BLAKE2S_OUTBYTES] = {0};
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if( out == NULL || outlen < S->outlen )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if( blake2s_is_lastblock( S ) )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
blake2s_increment_counter( S, ( uint32_t )S->buflen );
|
|
||||||
blake2s_set_lastblock( S );
|
|
||||||
memset( S->buf + S->buflen, 0, BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */
|
|
||||||
blake2s_compress( S, S->buf );
|
|
||||||
|
|
||||||
for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
|
|
||||||
store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
|
|
||||||
|
|
||||||
memcpy( out, buffer, outlen );
|
|
||||||
secure_zero_memory(buffer, sizeof(buffer));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int blake2s( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen )
|
|
||||||
{
|
|
||||||
blake2s_state S[1];
|
|
||||||
|
|
||||||
/* Verify parameters */
|
|
||||||
if ( NULL == in && inlen > 0 ) return -1;
|
|
||||||
|
|
||||||
if ( NULL == out ) return -1;
|
|
||||||
|
|
||||||
if ( NULL == key && keylen > 0) return -1;
|
|
||||||
|
|
||||||
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
|
|
||||||
|
|
||||||
if( keylen > BLAKE2S_KEYBYTES ) return -1;
|
|
||||||
|
|
||||||
if( keylen > 0 )
|
|
||||||
{
|
|
||||||
if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( blake2s_init( S, outlen ) < 0 ) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
blake2s_update( S, ( const uint8_t * )in, inlen );
|
|
||||||
blake2s_final( S, out, outlen );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(SUPERCOP)
|
|
||||||
int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen )
|
|
||||||
{
|
|
||||||
return blake2s( out, BLAKE2S_OUTBYTES, in, inlen, NULL, 0 );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BLAKE2S_SELFTEST)
|
|
||||||
#include <string.h>
|
|
||||||
#include "blake2-kat.h"
|
|
||||||
int main( void )
|
|
||||||
{
|
|
||||||
uint8_t key[BLAKE2S_KEYBYTES];
|
|
||||||
uint8_t buf[BLAKE2_KAT_LENGTH];
|
|
||||||
size_t i, step;
|
|
||||||
|
|
||||||
for( i = 0; i < BLAKE2S_KEYBYTES; ++i )
|
|
||||||
key[i] = ( uint8_t )i;
|
|
||||||
|
|
||||||
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
|
||||||
buf[i] = ( uint8_t )i;
|
|
||||||
|
|
||||||
/* Test simple API */
|
|
||||||
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
|
||||||
{
|
|
||||||
uint8_t hash[BLAKE2S_OUTBYTES];
|
|
||||||
blake2s( hash, BLAKE2S_OUTBYTES, buf, i, key, BLAKE2S_KEYBYTES );
|
|
||||||
|
|
||||||
if( 0 != memcmp( hash, blake2s_keyed_kat[i], BLAKE2S_OUTBYTES ) )
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test streaming API */
|
|
||||||
for(step = 1; step < BLAKE2S_BLOCKBYTES; ++step) {
|
|
||||||
for (i = 0; i < BLAKE2_KAT_LENGTH; ++i) {
|
|
||||||
uint8_t hash[BLAKE2S_OUTBYTES];
|
|
||||||
blake2s_state S;
|
|
||||||
uint8_t * p = buf;
|
|
||||||
size_t mlen = i;
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if( (err = blake2s_init_key(&S, BLAKE2S_OUTBYTES, key, BLAKE2S_KEYBYTES)) < 0 ) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (mlen >= step) {
|
|
||||||
if ( (err = blake2s_update(&S, p, step)) < 0 ) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
mlen -= step;
|
|
||||||
p += step;
|
|
||||||
}
|
|
||||||
if ( (err = blake2s_update(&S, p, mlen)) < 0) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if ( (err = blake2s_final(&S, hash, BLAKE2S_OUTBYTES)) < 0) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != memcmp(hash, blake2s_keyed_kat[i], BLAKE2S_OUTBYTES)) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
puts( "ok" );
|
|
||||||
return 0;
|
|
||||||
fail:
|
|
||||||
puts("error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
359
3rdparty/libarchive/c/archive_blake2sp_ref.c
vendored
359
3rdparty/libarchive/c/archive_blake2sp_ref.c
vendored
@ -1,359 +0,0 @@
|
|||||||
/*
|
|
||||||
BLAKE2 reference source code package - reference C implementations
|
|
||||||
|
|
||||||
Copyright 2012, Samuel Neves <sneves@dei.uc.pt>. You may use this under the
|
|
||||||
terms of the CC0, the OpenSSL Licence, or the Apache Public License 2.0, at
|
|
||||||
your option. The terms of these licenses can be found at:
|
|
||||||
|
|
||||||
- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
|
|
||||||
- OpenSSL license : https://www.openssl.org/source/license.html
|
|
||||||
- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
More information about the BLAKE2 hash function can be found at
|
|
||||||
https://blake2.net.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if defined(_OPENMP)
|
|
||||||
#include <omp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_blake2.h"
|
|
||||||
#include "archive_blake2_impl.h"
|
|
||||||
|
|
||||||
#define PARALLELISM_DEGREE 8
|
|
||||||
|
|
||||||
/*
|
|
||||||
blake2sp_init_param defaults to setting the expecting output length
|
|
||||||
from the digest_length parameter block field.
|
|
||||||
|
|
||||||
In some cases, however, we do not want this, as the output length
|
|
||||||
of these instances is given by inner_length instead.
|
|
||||||
*/
|
|
||||||
static int blake2sp_init_leaf_param( blake2s_state *S, const blake2s_param *P )
|
|
||||||
{
|
|
||||||
int err = blake2s_init_param(S, P);
|
|
||||||
S->outlen = P->inner_length;
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int blake2sp_init_leaf( blake2s_state *S, size_t outlen, size_t keylen, uint32_t offset )
|
|
||||||
{
|
|
||||||
blake2s_param P[1];
|
|
||||||
P->digest_length = (uint8_t)outlen;
|
|
||||||
P->key_length = (uint8_t)keylen;
|
|
||||||
P->fanout = PARALLELISM_DEGREE;
|
|
||||||
P->depth = 2;
|
|
||||||
store32( &P->leaf_length, 0 );
|
|
||||||
store32( &P->node_offset, offset );
|
|
||||||
store16( &P->xof_length, 0 );
|
|
||||||
P->node_depth = 0;
|
|
||||||
P->inner_length = BLAKE2S_OUTBYTES;
|
|
||||||
memset( P->salt, 0, sizeof( P->salt ) );
|
|
||||||
memset( P->personal, 0, sizeof( P->personal ) );
|
|
||||||
return blake2sp_init_leaf_param( S, P );
|
|
||||||
}
|
|
||||||
|
|
||||||
static int blake2sp_init_root( blake2s_state *S, size_t outlen, size_t keylen )
|
|
||||||
{
|
|
||||||
blake2s_param P[1];
|
|
||||||
P->digest_length = (uint8_t)outlen;
|
|
||||||
P->key_length = (uint8_t)keylen;
|
|
||||||
P->fanout = PARALLELISM_DEGREE;
|
|
||||||
P->depth = 2;
|
|
||||||
store32( &P->leaf_length, 0 );
|
|
||||||
store32( &P->node_offset, 0 );
|
|
||||||
store16( &P->xof_length, 0 );
|
|
||||||
P->node_depth = 1;
|
|
||||||
P->inner_length = BLAKE2S_OUTBYTES;
|
|
||||||
memset( P->salt, 0, sizeof( P->salt ) );
|
|
||||||
memset( P->personal, 0, sizeof( P->personal ) );
|
|
||||||
return blake2s_init_param( S, P );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int blake2sp_init( blake2sp_state *S, size_t outlen )
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
|
|
||||||
|
|
||||||
memset( S->buf, 0, sizeof( S->buf ) );
|
|
||||||
S->buflen = 0;
|
|
||||||
S->outlen = outlen;
|
|
||||||
|
|
||||||
if( blake2sp_init_root( S->R, outlen, 0 ) < 0 )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
if( blake2sp_init_leaf( S->S[i], outlen, 0, (uint32_t)i ) < 0 ) return -1;
|
|
||||||
|
|
||||||
S->R->last_node = 1;
|
|
||||||
S->S[PARALLELISM_DEGREE - 1]->last_node = 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int blake2sp_init_key( blake2sp_state *S, size_t outlen, const void *key, size_t keylen )
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
|
|
||||||
|
|
||||||
if( !key || !keylen || keylen > BLAKE2S_KEYBYTES ) return -1;
|
|
||||||
|
|
||||||
memset( S->buf, 0, sizeof( S->buf ) );
|
|
||||||
S->buflen = 0;
|
|
||||||
S->outlen = outlen;
|
|
||||||
|
|
||||||
if( blake2sp_init_root( S->R, outlen, keylen ) < 0 )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
if( blake2sp_init_leaf( S->S[i], outlen, keylen, (uint32_t)i ) < 0 ) return -1;
|
|
||||||
|
|
||||||
S->R->last_node = 1;
|
|
||||||
S->S[PARALLELISM_DEGREE - 1]->last_node = 1;
|
|
||||||
{
|
|
||||||
uint8_t block[BLAKE2S_BLOCKBYTES];
|
|
||||||
memset( block, 0, BLAKE2S_BLOCKBYTES );
|
|
||||||
memcpy( block, key, keylen );
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
blake2s_update( S->S[i], block, BLAKE2S_BLOCKBYTES );
|
|
||||||
|
|
||||||
secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from stack */
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int blake2sp_update( blake2sp_state *S, const void *pin, size_t inlen )
|
|
||||||
{
|
|
||||||
const unsigned char * in = (const unsigned char *)pin;
|
|
||||||
size_t left = S->buflen;
|
|
||||||
size_t fill = sizeof( S->buf ) - left;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if( left && inlen >= fill )
|
|
||||||
{
|
|
||||||
memcpy( S->buf + left, in, fill );
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
blake2s_update( S->S[i], S->buf + i * BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES );
|
|
||||||
|
|
||||||
in += fill;
|
|
||||||
inlen -= fill;
|
|
||||||
left = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_OPENMP)
|
|
||||||
#pragma omp parallel shared(S), num_threads(PARALLELISM_DEGREE)
|
|
||||||
#else
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if defined(_OPENMP)
|
|
||||||
size_t i = omp_get_thread_num();
|
|
||||||
#endif
|
|
||||||
size_t inlen__ = inlen;
|
|
||||||
const unsigned char *in__ = ( const unsigned char * )in;
|
|
||||||
in__ += i * BLAKE2S_BLOCKBYTES;
|
|
||||||
|
|
||||||
while( inlen__ >= PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES )
|
|
||||||
{
|
|
||||||
blake2s_update( S->S[i], in__, BLAKE2S_BLOCKBYTES );
|
|
||||||
in__ += PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES;
|
|
||||||
inlen__ -= PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
in += inlen - inlen % ( PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES );
|
|
||||||
inlen %= PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES;
|
|
||||||
|
|
||||||
if( inlen > 0 )
|
|
||||||
memcpy( S->buf + left, in, inlen );
|
|
||||||
|
|
||||||
S->buflen = left + inlen;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int blake2sp_final( blake2sp_state *S, void *out, size_t outlen )
|
|
||||||
{
|
|
||||||
uint8_t hash[PARALLELISM_DEGREE][BLAKE2S_OUTBYTES];
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
if(out == NULL || outlen < S->outlen) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
{
|
|
||||||
if( S->buflen > i * BLAKE2S_BLOCKBYTES )
|
|
||||||
{
|
|
||||||
size_t left = S->buflen - i * BLAKE2S_BLOCKBYTES;
|
|
||||||
|
|
||||||
if( left > BLAKE2S_BLOCKBYTES ) left = BLAKE2S_BLOCKBYTES;
|
|
||||||
|
|
||||||
blake2s_update( S->S[i], S->buf + i * BLAKE2S_BLOCKBYTES, left );
|
|
||||||
}
|
|
||||||
|
|
||||||
blake2s_final( S->S[i], hash[i], BLAKE2S_OUTBYTES );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
blake2s_update( S->R, hash[i], BLAKE2S_OUTBYTES );
|
|
||||||
|
|
||||||
return blake2s_final( S->R, out, S->outlen );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int blake2sp( void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen )
|
|
||||||
{
|
|
||||||
uint8_t hash[PARALLELISM_DEGREE][BLAKE2S_OUTBYTES];
|
|
||||||
blake2s_state S[PARALLELISM_DEGREE][1];
|
|
||||||
blake2s_state FS[1];
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
/* Verify parameters */
|
|
||||||
if ( NULL == in && inlen > 0 ) return -1;
|
|
||||||
|
|
||||||
if ( NULL == out ) return -1;
|
|
||||||
|
|
||||||
if ( NULL == key && keylen > 0) return -1;
|
|
||||||
|
|
||||||
if( !outlen || outlen > BLAKE2S_OUTBYTES ) return -1;
|
|
||||||
|
|
||||||
if( keylen > BLAKE2S_KEYBYTES ) return -1;
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
if( blake2sp_init_leaf( S[i], outlen, keylen, (uint32_t)i ) < 0 ) return -1;
|
|
||||||
|
|
||||||
S[PARALLELISM_DEGREE - 1]->last_node = 1; /* mark last node */
|
|
||||||
|
|
||||||
if( keylen > 0 )
|
|
||||||
{
|
|
||||||
uint8_t block[BLAKE2S_BLOCKBYTES];
|
|
||||||
memset( block, 0, BLAKE2S_BLOCKBYTES );
|
|
||||||
memcpy( block, key, keylen );
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
blake2s_update( S[i], block, BLAKE2S_BLOCKBYTES );
|
|
||||||
|
|
||||||
secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from stack */
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_OPENMP)
|
|
||||||
#pragma omp parallel shared(S,hash), num_threads(PARALLELISM_DEGREE)
|
|
||||||
#else
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if defined(_OPENMP)
|
|
||||||
size_t i = omp_get_thread_num();
|
|
||||||
#endif
|
|
||||||
size_t inlen__ = inlen;
|
|
||||||
const unsigned char *in__ = ( const unsigned char * )in;
|
|
||||||
in__ += i * BLAKE2S_BLOCKBYTES;
|
|
||||||
|
|
||||||
while( inlen__ >= PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES )
|
|
||||||
{
|
|
||||||
blake2s_update( S[i], in__, BLAKE2S_BLOCKBYTES );
|
|
||||||
in__ += PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES;
|
|
||||||
inlen__ -= PARALLELISM_DEGREE * BLAKE2S_BLOCKBYTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( inlen__ > i * BLAKE2S_BLOCKBYTES )
|
|
||||||
{
|
|
||||||
const size_t left = inlen__ - i * BLAKE2S_BLOCKBYTES;
|
|
||||||
const size_t len = left <= BLAKE2S_BLOCKBYTES ? left : BLAKE2S_BLOCKBYTES;
|
|
||||||
blake2s_update( S[i], in__, len );
|
|
||||||
}
|
|
||||||
|
|
||||||
blake2s_final( S[i], hash[i], BLAKE2S_OUTBYTES );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( blake2sp_init_root( FS, outlen, keylen ) < 0 )
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
FS->last_node = 1;
|
|
||||||
|
|
||||||
for( i = 0; i < PARALLELISM_DEGREE; ++i )
|
|
||||||
blake2s_update( FS, hash[i], BLAKE2S_OUTBYTES );
|
|
||||||
|
|
||||||
return blake2s_final( FS, out, outlen );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(BLAKE2SP_SELFTEST)
|
|
||||||
#include <string.h>
|
|
||||||
#include "blake2-kat.h"
|
|
||||||
int main( void )
|
|
||||||
{
|
|
||||||
uint8_t key[BLAKE2S_KEYBYTES];
|
|
||||||
uint8_t buf[BLAKE2_KAT_LENGTH];
|
|
||||||
size_t i, step;
|
|
||||||
|
|
||||||
for( i = 0; i < BLAKE2S_KEYBYTES; ++i )
|
|
||||||
key[i] = ( uint8_t )i;
|
|
||||||
|
|
||||||
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
|
||||||
buf[i] = ( uint8_t )i;
|
|
||||||
|
|
||||||
/* Test simple API */
|
|
||||||
for( i = 0; i < BLAKE2_KAT_LENGTH; ++i )
|
|
||||||
{
|
|
||||||
uint8_t hash[BLAKE2S_OUTBYTES];
|
|
||||||
blake2sp( hash, BLAKE2S_OUTBYTES, buf, i, key, BLAKE2S_KEYBYTES );
|
|
||||||
|
|
||||||
if( 0 != memcmp( hash, blake2sp_keyed_kat[i], BLAKE2S_OUTBYTES ) )
|
|
||||||
{
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Test streaming API */
|
|
||||||
for(step = 1; step < BLAKE2S_BLOCKBYTES; ++step) {
|
|
||||||
for (i = 0; i < BLAKE2_KAT_LENGTH; ++i) {
|
|
||||||
uint8_t hash[BLAKE2S_OUTBYTES];
|
|
||||||
blake2sp_state S;
|
|
||||||
uint8_t * p = buf;
|
|
||||||
size_t mlen = i;
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if( (err = blake2sp_init_key(&S, BLAKE2S_OUTBYTES, key, BLAKE2S_KEYBYTES)) < 0 ) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (mlen >= step) {
|
|
||||||
if ( (err = blake2sp_update(&S, p, step)) < 0 ) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
mlen -= step;
|
|
||||||
p += step;
|
|
||||||
}
|
|
||||||
if ( (err = blake2sp_update(&S, p, mlen)) < 0) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if ( (err = blake2sp_final(&S, hash, BLAKE2S_OUTBYTES)) < 0) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != memcmp(hash, blake2sp_keyed_kat[i], BLAKE2S_OUTBYTES)) {
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
puts( "ok" );
|
|
||||||
return 0;
|
|
||||||
fail:
|
|
||||||
puts("error");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
175
3rdparty/libarchive/c/archive_check_magic.c
vendored
175
3rdparty/libarchive/c/archive_check_magic.c
vendored
@ -1,175 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2010 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD: head/lib/libarchive/archive_check_magic.c 201089 2009-12-28 02:20:23Z kientzle $");
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
#include <windows.h>
|
|
||||||
#include <winbase.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_private.h"
|
|
||||||
|
|
||||||
static void
|
|
||||||
errmsg(const char *m)
|
|
||||||
{
|
|
||||||
size_t s = strlen(m);
|
|
||||||
ssize_t written;
|
|
||||||
|
|
||||||
while (s > 0) {
|
|
||||||
written = write(2, m, strlen(m));
|
|
||||||
if (written <= 0)
|
|
||||||
return;
|
|
||||||
m += written;
|
|
||||||
s -= written;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static __LA_DEAD void
|
|
||||||
diediedie(void)
|
|
||||||
{
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
|
|
||||||
/* Cause a breakpoint exception */
|
|
||||||
DebugBreak();
|
|
||||||
#endif
|
|
||||||
abort(); /* Terminate the program abnormally. */
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
state_name(unsigned s)
|
|
||||||
{
|
|
||||||
switch (s) {
|
|
||||||
case ARCHIVE_STATE_NEW: return ("new");
|
|
||||||
case ARCHIVE_STATE_HEADER: return ("header");
|
|
||||||
case ARCHIVE_STATE_DATA: return ("data");
|
|
||||||
case ARCHIVE_STATE_EOF: return ("eof");
|
|
||||||
case ARCHIVE_STATE_CLOSED: return ("closed");
|
|
||||||
case ARCHIVE_STATE_FATAL: return ("fatal");
|
|
||||||
default: return ("??");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
archive_handle_type_name(unsigned m)
|
|
||||||
{
|
|
||||||
switch (m) {
|
|
||||||
case ARCHIVE_WRITE_MAGIC: return ("archive_write");
|
|
||||||
case ARCHIVE_READ_MAGIC: return ("archive_read");
|
|
||||||
case ARCHIVE_WRITE_DISK_MAGIC: return ("archive_write_disk");
|
|
||||||
case ARCHIVE_READ_DISK_MAGIC: return ("archive_read_disk");
|
|
||||||
case ARCHIVE_MATCH_MAGIC: return ("archive_match");
|
|
||||||
default: return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static char *
|
|
||||||
write_all_states(char *buff, unsigned int states)
|
|
||||||
{
|
|
||||||
unsigned int lowbit;
|
|
||||||
|
|
||||||
buff[0] = '\0';
|
|
||||||
|
|
||||||
/* A trick for computing the lowest set bit. */
|
|
||||||
while ((lowbit = states & (1 + ~states)) != 0) {
|
|
||||||
states &= ~lowbit; /* Clear the low bit. */
|
|
||||||
strcat(buff, state_name(lowbit));
|
|
||||||
if (states != 0)
|
|
||||||
strcat(buff, "/");
|
|
||||||
}
|
|
||||||
return buff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check magic value and current state.
|
|
||||||
* Magic value mismatches are fatal and result in calls to abort().
|
|
||||||
* State mismatches return ARCHIVE_FATAL.
|
|
||||||
* Otherwise, returns ARCHIVE_OK.
|
|
||||||
*
|
|
||||||
* This is designed to catch serious programming errors that violate
|
|
||||||
* the libarchive API.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
__archive_check_magic(struct archive *a, unsigned int magic,
|
|
||||||
unsigned int state, const char *function)
|
|
||||||
{
|
|
||||||
char states1[64];
|
|
||||||
char states2[64];
|
|
||||||
const char *handle_type;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If this isn't some form of archive handle,
|
|
||||||
* then the library user has screwed up so bad that
|
|
||||||
* we don't even have a reliable way to report an error.
|
|
||||||
*/
|
|
||||||
handle_type = archive_handle_type_name(a->magic);
|
|
||||||
|
|
||||||
if (!handle_type) {
|
|
||||||
errmsg("PROGRAMMER ERROR: Function ");
|
|
||||||
errmsg(function);
|
|
||||||
errmsg(" invoked with invalid archive handle.\n");
|
|
||||||
diediedie();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a->magic != magic) {
|
|
||||||
archive_set_error(a, -1,
|
|
||||||
"PROGRAMMER ERROR: Function '%s' invoked"
|
|
||||||
" on '%s' archive object, which is not supported.",
|
|
||||||
function,
|
|
||||||
handle_type);
|
|
||||||
a->state = ARCHIVE_STATE_FATAL;
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((a->state & state) == 0) {
|
|
||||||
/* If we're already FATAL, don't overwrite the error. */
|
|
||||||
if (a->state != ARCHIVE_STATE_FATAL)
|
|
||||||
archive_set_error(a, -1,
|
|
||||||
"INTERNAL ERROR: Function '%s' invoked with"
|
|
||||||
" archive structure in state '%s',"
|
|
||||||
" should be in state '%s'",
|
|
||||||
function,
|
|
||||||
write_all_states(states1, a->state),
|
|
||||||
write_all_states(states2, state));
|
|
||||||
a->state = ARCHIVE_STATE_FATAL;
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
}
|
|
||||||
return ARCHIVE_OK;
|
|
||||||
}
|
|
227
3rdparty/libarchive/c/archive_cmdline.c
vendored
227
3rdparty/libarchive/c/archive_cmdline.c
vendored
@ -1,227 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
__FBSDID("$FreeBSD$");
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
# include <string.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
# include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_cmdline_private.h"
|
|
||||||
#include "archive_string.h"
|
|
||||||
|
|
||||||
static int cmdline_set_path(struct archive_cmdline *, const char *);
|
|
||||||
static int cmdline_add_arg(struct archive_cmdline *, const char *);
|
|
||||||
|
|
||||||
static ssize_t
|
|
||||||
extract_quotation(struct archive_string *as, const char *p)
|
|
||||||
{
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
for (s = p + 1; *s;) {
|
|
||||||
if (*s == '\\') {
|
|
||||||
if (s[1] != '\0') {
|
|
||||||
archive_strappend_char(as, s[1]);
|
|
||||||
s += 2;
|
|
||||||
} else
|
|
||||||
s++;
|
|
||||||
} else if (*s == '"')
|
|
||||||
break;
|
|
||||||
else {
|
|
||||||
archive_strappend_char(as, s[0]);
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*s != '"')
|
|
||||||
return (ARCHIVE_FAILED);/* Invalid sequence. */
|
|
||||||
return ((ssize_t)(s + 1 - p));
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t
|
|
||||||
get_argument(struct archive_string *as, const char *p)
|
|
||||||
{
|
|
||||||
const char *s = p;
|
|
||||||
|
|
||||||
archive_string_empty(as);
|
|
||||||
|
|
||||||
/* Skip beginning space characters. */
|
|
||||||
while (*s != '\0' && *s == ' ')
|
|
||||||
s++;
|
|
||||||
/* Copy non-space characters. */
|
|
||||||
while (*s != '\0' && *s != ' ') {
|
|
||||||
if (*s == '\\') {
|
|
||||||
if (s[1] != '\0') {
|
|
||||||
archive_strappend_char(as, s[1]);
|
|
||||||
s += 2;
|
|
||||||
} else {
|
|
||||||
s++;/* Ignore this character.*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (*s == '"') {
|
|
||||||
ssize_t q = extract_quotation(as, s);
|
|
||||||
if (q < 0)
|
|
||||||
return (ARCHIVE_FAILED);/* Invalid sequence. */
|
|
||||||
s += q;
|
|
||||||
} else {
|
|
||||||
archive_strappend_char(as, s[0]);
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ((ssize_t)(s - p));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set up command line arguments.
|
|
||||||
* Returns ARCHIVE_OK if everything okey.
|
|
||||||
* Returns ARCHIVE_FAILED if there is a lack of the `"' terminator or an
|
|
||||||
* empty command line.
|
|
||||||
* Returns ARCHIVE_FATAL if no memory.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
__archive_cmdline_parse(struct archive_cmdline *data, const char *cmd)
|
|
||||||
{
|
|
||||||
struct archive_string as;
|
|
||||||
const char *p;
|
|
||||||
ssize_t al;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
archive_string_init(&as);
|
|
||||||
|
|
||||||
/* Get first argument as a command path. */
|
|
||||||
al = get_argument(&as, cmd);
|
|
||||||
if (al < 0) {
|
|
||||||
r = ARCHIVE_FAILED;/* Invalid sequence. */
|
|
||||||
goto exit_function;
|
|
||||||
}
|
|
||||||
if (archive_strlen(&as) == 0) {
|
|
||||||
r = ARCHIVE_FAILED;/* An empty command path. */
|
|
||||||
goto exit_function;
|
|
||||||
}
|
|
||||||
r = cmdline_set_path(data, as.s);
|
|
||||||
if (r != ARCHIVE_OK)
|
|
||||||
goto exit_function;
|
|
||||||
p = strrchr(as.s, '/');
|
|
||||||
if (p == NULL)
|
|
||||||
p = as.s;
|
|
||||||
else
|
|
||||||
p++;
|
|
||||||
r = cmdline_add_arg(data, p);
|
|
||||||
if (r != ARCHIVE_OK)
|
|
||||||
goto exit_function;
|
|
||||||
cmd += al;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
al = get_argument(&as, cmd);
|
|
||||||
if (al < 0) {
|
|
||||||
r = ARCHIVE_FAILED;/* Invalid sequence. */
|
|
||||||
goto exit_function;
|
|
||||||
}
|
|
||||||
if (al == 0)
|
|
||||||
break;
|
|
||||||
cmd += al;
|
|
||||||
if (archive_strlen(&as) == 0 && *cmd == '\0')
|
|
||||||
break;
|
|
||||||
r = cmdline_add_arg(data, as.s);
|
|
||||||
if (r != ARCHIVE_OK)
|
|
||||||
goto exit_function;
|
|
||||||
}
|
|
||||||
r = ARCHIVE_OK;
|
|
||||||
exit_function:
|
|
||||||
archive_string_free(&as);
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the program path.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
cmdline_set_path(struct archive_cmdline *data, const char *path)
|
|
||||||
{
|
|
||||||
char *newptr;
|
|
||||||
|
|
||||||
newptr = realloc(data->path, strlen(path) + 1);
|
|
||||||
if (newptr == NULL)
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
data->path = newptr;
|
|
||||||
strcpy(data->path, path);
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add a argument for the program.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
cmdline_add_arg(struct archive_cmdline *data, const char *arg)
|
|
||||||
{
|
|
||||||
char **newargv;
|
|
||||||
|
|
||||||
if (data->path == NULL)
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
|
|
||||||
newargv = realloc(data->argv, (data->argc + 2) * sizeof(char *));
|
|
||||||
if (newargv == NULL)
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
data->argv = newargv;
|
|
||||||
data->argv[data->argc] = strdup(arg);
|
|
||||||
if (data->argv[data->argc] == NULL)
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
/* Set the terminator of argv. */
|
|
||||||
data->argv[++data->argc] = NULL;
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct archive_cmdline *
|
|
||||||
__archive_cmdline_allocate(void)
|
|
||||||
{
|
|
||||||
return (struct archive_cmdline *)
|
|
||||||
calloc(1, sizeof(struct archive_cmdline));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release the resources.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
__archive_cmdline_free(struct archive_cmdline *data)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (data) {
|
|
||||||
free(data->path);
|
|
||||||
if (data->argv != NULL) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; data->argv[i] != NULL; i++)
|
|
||||||
free(data->argv[i]);
|
|
||||||
free(data->argv);
|
|
||||||
}
|
|
||||||
free(data);
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
47
3rdparty/libarchive/c/archive_cmdline_private.h
vendored
47
3rdparty/libarchive/c/archive_cmdline_private.h
vendored
@ -1,47 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2012 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_CMDLINE_PRIVATE_H
|
|
||||||
#define ARCHIVE_CMDLINE_PRIVATE_H
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#ifndef __LIBARCHIVE_TEST
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct archive_cmdline {
|
|
||||||
char *path;
|
|
||||||
char **argv;
|
|
||||||
int argc;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct archive_cmdline *__archive_cmdline_allocate(void);
|
|
||||||
int __archive_cmdline_parse(struct archive_cmdline *, const char *);
|
|
||||||
int __archive_cmdline_free(struct archive_cmdline *);
|
|
||||||
|
|
||||||
#endif
|
|
83
3rdparty/libarchive/c/archive_crc32.h
vendored
83
3rdparty/libarchive/c/archive_crc32.h
vendored
@ -1,83 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2009 Joerg Sonnenberger
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: head/lib/libarchive/archive_crc32.h 201102 2009-12-28 03:11:36Z kientzle $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_CRC32_H
|
|
||||||
#define ARCHIVE_CRC32_H
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* When zlib is unavailable, we should still be able to validate
|
|
||||||
* uncompressed zip archives. That requires us to be able to compute
|
|
||||||
* the CRC32 check value. This is a drop-in compatible replacement
|
|
||||||
* for crc32() from zlib. It's slower than the zlib implementation,
|
|
||||||
* but still pretty fast: This runs about 300MB/s on my 3GHz P4
|
|
||||||
* compared to about 800MB/s for the zlib implementation.
|
|
||||||
*/
|
|
||||||
static unsigned long
|
|
||||||
crc32(unsigned long crc, const void *_p, size_t len)
|
|
||||||
{
|
|
||||||
unsigned long crc2, b, i;
|
|
||||||
const unsigned char *p = _p;
|
|
||||||
static volatile int crc_tbl_inited = 0;
|
|
||||||
static unsigned long crc_tbl[256];
|
|
||||||
|
|
||||||
if (!crc_tbl_inited) {
|
|
||||||
for (b = 0; b < 256; ++b) {
|
|
||||||
crc2 = b;
|
|
||||||
for (i = 8; i > 0; --i) {
|
|
||||||
if (crc2 & 1)
|
|
||||||
crc2 = (crc2 >> 1) ^ 0xedb88320UL;
|
|
||||||
else
|
|
||||||
crc2 = (crc2 >> 1);
|
|
||||||
}
|
|
||||||
crc_tbl[b] = crc2;
|
|
||||||
}
|
|
||||||
crc_tbl_inited = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
crc = crc ^ 0xffffffffUL;
|
|
||||||
/* A use of this loop is about 20% - 30% faster than
|
|
||||||
* no use version in any optimization option of gcc. */
|
|
||||||
for (;len >= 8; len -= 8) {
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
}
|
|
||||||
while (len--)
|
|
||||||
crc = crc_tbl[(crc ^ *p++) & 0xff] ^ (crc >> 8);
|
|
||||||
return (crc ^ 0xffffffffUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
519
3rdparty/libarchive/c/archive_cryptor.c
vendored
519
3rdparty/libarchive/c/archive_cryptor.c
vendored
@ -1,519 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_cryptor_private.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* On systems that do not support any recognized crypto libraries,
|
|
||||||
* this file will normally define no usable symbols.
|
|
||||||
*
|
|
||||||
* But some compilers and linkers choke on empty object files, so
|
|
||||||
* define a public symbol that will always exist. This could
|
|
||||||
* be removed someday if this file gains another always-present
|
|
||||||
* symbol definition.
|
|
||||||
*/
|
|
||||||
int __libarchive_cryptor_build_hack(void) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
|
||||||
|
|
||||||
static int
|
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len)
|
|
||||||
{
|
|
||||||
CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)pw,
|
|
||||||
pw_len, salt, salt_len, kCCPRFHmacAlgSHA1, rounds,
|
|
||||||
derived_key, derived_key_len);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma comment(lib, "Bcrypt.lib")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len)
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
BCRYPT_ALG_HANDLE hAlg;
|
|
||||||
|
|
||||||
status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_SHA1_ALGORITHM,
|
|
||||||
MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
|
||||||
if (!BCRYPT_SUCCESS(status))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
status = BCryptDeriveKeyPBKDF2(hAlg,
|
|
||||||
(PUCHAR)(uintptr_t)pw, (ULONG)pw_len,
|
|
||||||
(PUCHAR)(uintptr_t)salt, (ULONG)salt_len, rounds,
|
|
||||||
(PUCHAR)derived_key, (ULONG)derived_key_len, 0);
|
|
||||||
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
|
|
||||||
return (BCRYPT_SUCCESS(status)) ? 0: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_PKCS5_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len)
|
|
||||||
{
|
|
||||||
mbedtls_md_context_t ctx;
|
|
||||||
const mbedtls_md_info_t *info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
mbedtls_md_init(&ctx);
|
|
||||||
info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA1);
|
|
||||||
if (info == NULL) {
|
|
||||||
mbedtls_md_free(&ctx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
ret = mbedtls_md_setup(&ctx, info, 1);
|
|
||||||
if (ret != 0) {
|
|
||||||
mbedtls_md_free(&ctx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
ret = mbedtls_pkcs5_pbkdf2_hmac(&ctx, (const unsigned char *)pw,
|
|
||||||
pw_len, salt, salt_len, rounds, derived_key_len, derived_key);
|
|
||||||
|
|
||||||
mbedtls_md_free(&ctx);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_PBKDF2_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len) {
|
|
||||||
pbkdf2_hmac_sha1((unsigned)pw_len, (const uint8_t *)pw, rounds,
|
|
||||||
salt_len, salt, derived_key_len, derived_key);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_PKCS5_PBKDF2_HMAC_SHA1)
|
|
||||||
|
|
||||||
static int
|
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len) {
|
|
||||||
|
|
||||||
PKCS5_PBKDF2_HMAC_SHA1(pw, pw_len, salt, salt_len, rounds,
|
|
||||||
derived_key_len, derived_key);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Stub */
|
|
||||||
static int
|
|
||||||
pbkdf2_sha1(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len) {
|
|
||||||
(void)pw; /* UNUSED */
|
|
||||||
(void)pw_len; /* UNUSED */
|
|
||||||
(void)salt; /* UNUSED */
|
|
||||||
(void)salt_len; /* UNUSED */
|
|
||||||
(void)rounds; /* UNUSED */
|
|
||||||
(void)derived_key; /* UNUSED */
|
|
||||||
(void)derived_key_len; /* UNUSED */
|
|
||||||
return -1; /* UNSUPPORTED */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
|
||||||
# if MAC_OS_X_VERSION_MAX_ALLOWED < 1090
|
|
||||||
# define kCCAlgorithmAES kCCAlgorithmAES128
|
|
||||||
# endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
CCCryptorStatus r;
|
|
||||||
|
|
||||||
ctx->key_len = key_len;
|
|
||||||
memcpy(ctx->key, key, key_len);
|
|
||||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
|
||||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
|
||||||
r = CCCryptorCreateWithMode(kCCEncrypt, kCCModeECB, kCCAlgorithmAES,
|
|
||||||
ccNoPadding, NULL, key, key_len, NULL, 0, 0, 0, &ctx->ctx);
|
|
||||||
return (r == kCCSuccess)? 0: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
CCCryptorRef ref = ctx->ctx;
|
|
||||||
CCCryptorStatus r;
|
|
||||||
|
|
||||||
r = CCCryptorReset(ref, NULL);
|
|
||||||
if (r != kCCSuccess && r != kCCUnimplemented)
|
|
||||||
return -1;
|
|
||||||
r = CCCryptorUpdate(ref, ctx->nonce, AES_BLOCK_SIZE, ctx->encr_buf,
|
|
||||||
AES_BLOCK_SIZE, NULL);
|
|
||||||
return (r == kCCSuccess)? 0: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
memset(ctx->key, 0, ctx->key_len);
|
|
||||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
BCRYPT_ALG_HANDLE hAlg;
|
|
||||||
BCRYPT_KEY_HANDLE hKey;
|
|
||||||
DWORD keyObj_len, aes_key_len;
|
|
||||||
PBYTE keyObj;
|
|
||||||
ULONG result;
|
|
||||||
NTSTATUS status;
|
|
||||||
BCRYPT_KEY_LENGTHS_STRUCT key_lengths;
|
|
||||||
|
|
||||||
ctx->hAlg = NULL;
|
|
||||||
ctx->hKey = NULL;
|
|
||||||
ctx->keyObj = NULL;
|
|
||||||
switch (key_len) {
|
|
||||||
case 16: aes_key_len = 128; break;
|
|
||||||
case 24: aes_key_len = 192; break;
|
|
||||||
case 32: aes_key_len = 256; break;
|
|
||||||
default: return -1;
|
|
||||||
}
|
|
||||||
status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_AES_ALGORITHM,
|
|
||||||
MS_PRIMITIVE_PROVIDER, 0);
|
|
||||||
if (!BCRYPT_SUCCESS(status))
|
|
||||||
return -1;
|
|
||||||
status = BCryptGetProperty(hAlg, BCRYPT_KEY_LENGTHS, (PUCHAR)&key_lengths,
|
|
||||||
sizeof(key_lengths), &result, 0);
|
|
||||||
if (!BCRYPT_SUCCESS(status)) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (key_lengths.dwMinLength > aes_key_len
|
|
||||||
|| key_lengths.dwMaxLength < aes_key_len) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
status = BCryptGetProperty(hAlg, BCRYPT_OBJECT_LENGTH, (PUCHAR)&keyObj_len,
|
|
||||||
sizeof(keyObj_len), &result, 0);
|
|
||||||
if (!BCRYPT_SUCCESS(status)) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
keyObj = (PBYTE)HeapAlloc(GetProcessHeap(), 0, keyObj_len);
|
|
||||||
if (keyObj == NULL) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
status = BCryptSetProperty(hAlg, BCRYPT_CHAINING_MODE,
|
|
||||||
(PUCHAR)BCRYPT_CHAIN_MODE_ECB, sizeof(BCRYPT_CHAIN_MODE_ECB), 0);
|
|
||||||
if (!BCRYPT_SUCCESS(status)) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
HeapFree(GetProcessHeap(), 0, keyObj);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
status = BCryptGenerateSymmetricKey(hAlg, &hKey,
|
|
||||||
keyObj, keyObj_len,
|
|
||||||
(PUCHAR)(uintptr_t)key, (ULONG)key_len, 0);
|
|
||||||
if (!BCRYPT_SUCCESS(status)) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
HeapFree(GetProcessHeap(), 0, keyObj);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->hAlg = hAlg;
|
|
||||||
ctx->hKey = hKey;
|
|
||||||
ctx->keyObj = keyObj;
|
|
||||||
ctx->keyObj_len = keyObj_len;
|
|
||||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
NTSTATUS status;
|
|
||||||
ULONG result;
|
|
||||||
|
|
||||||
status = BCryptEncrypt(ctx->hKey, (PUCHAR)ctx->nonce, AES_BLOCK_SIZE,
|
|
||||||
NULL, NULL, 0, (PUCHAR)ctx->encr_buf, AES_BLOCK_SIZE,
|
|
||||||
&result, 0);
|
|
||||||
return BCRYPT_SUCCESS(status) ? 0 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (ctx->hAlg != NULL) {
|
|
||||||
BCryptCloseAlgorithmProvider(ctx->hAlg, 0);
|
|
||||||
ctx->hAlg = NULL;
|
|
||||||
BCryptDestroyKey(ctx->hKey);
|
|
||||||
ctx->hKey = NULL;
|
|
||||||
HeapFree(GetProcessHeap(), 0, ctx->keyObj);
|
|
||||||
ctx->keyObj = NULL;
|
|
||||||
}
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
mbedtls_aes_init(&ctx->ctx);
|
|
||||||
ctx->key_len = key_len;
|
|
||||||
memcpy(ctx->key, key, key_len);
|
|
||||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
|
||||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
if (mbedtls_aes_setkey_enc(&ctx->ctx, ctx->key,
|
|
||||||
ctx->key_len * 8) != 0)
|
|
||||||
return (-1);
|
|
||||||
if (mbedtls_aes_crypt_ecb(&ctx->ctx, MBEDTLS_AES_ENCRYPT, ctx->nonce,
|
|
||||||
ctx->encr_buf) != 0)
|
|
||||||
return (-1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
mbedtls_aes_free(&ctx->ctx);
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
ctx->key_len = key_len;
|
|
||||||
memcpy(ctx->key, key, key_len);
|
|
||||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
|
||||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
|
||||||
memset(&ctx->ctx, 0, sizeof(ctx->ctx));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
aes_set_encrypt_key(&ctx->ctx, ctx->key_len, ctx->key);
|
|
||||||
aes_encrypt(&ctx->ctx, AES_BLOCK_SIZE, ctx->encr_buf, ctx->nonce);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBCRYPTO)
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
if ((ctx->ctx = EVP_CIPHER_CTX_new()) == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
switch (key_len) {
|
|
||||||
case 16: ctx->type = EVP_aes_128_ecb(); break;
|
|
||||||
case 24: ctx->type = EVP_aes_192_ecb(); break;
|
|
||||||
case 32: ctx->type = EVP_aes_256_ecb(); break;
|
|
||||||
default: ctx->type = NULL; return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->key_len = key_len;
|
|
||||||
memcpy(ctx->key, key, key_len);
|
|
||||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
|
||||||
ctx->encr_pos = AES_BLOCK_SIZE;
|
|
||||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
|
||||||
if (!EVP_CIPHER_CTX_reset(ctx->ctx)) {
|
|
||||||
EVP_CIPHER_CTX_free(ctx->ctx);
|
|
||||||
ctx->ctx = NULL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
EVP_CIPHER_CTX_init(ctx->ctx);
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
int outl = 0;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
r = EVP_EncryptInit_ex(ctx->ctx, ctx->type, NULL, ctx->key, NULL);
|
|
||||||
if (r == 0)
|
|
||||||
return -1;
|
|
||||||
r = EVP_EncryptUpdate(ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
|
|
||||||
AES_BLOCK_SIZE);
|
|
||||||
if (r == 0 || outl != AES_BLOCK_SIZE)
|
|
||||||
return -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
EVP_CIPHER_CTX_free(ctx->ctx);
|
|
||||||
memset(ctx->key, 0, ctx->key_len);
|
|
||||||
memset(ctx->nonce, 0, sizeof(ctx->nonce));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define ARCHIVE_CRYPTOR_STUB
|
|
||||||
/* Stub */
|
|
||||||
static int
|
|
||||||
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
(void)ctx; /* UNUSED */
|
|
||||||
(void)key; /* UNUSED */
|
|
||||||
(void)key_len; /* UNUSED */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
(void)ctx; /* UNUSED */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_release(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
(void)ctx; /* UNUSED */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARCHIVE_CRYPTOR_STUB
|
|
||||||
static int
|
|
||||||
aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
|
|
||||||
size_t in_len, uint8_t * const out, size_t *out_len)
|
|
||||||
{
|
|
||||||
(void)ctx; /* UNUSED */
|
|
||||||
(void)in; /* UNUSED */
|
|
||||||
(void)in_len; /* UNUSED */
|
|
||||||
(void)out; /* UNUSED */
|
|
||||||
(void)out_len; /* UNUSED */
|
|
||||||
aes_ctr_encrypt_counter(ctx); /* UNUSED */ /* Fix unused function warning */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
static void
|
|
||||||
aes_ctr_increase_counter(archive_crypto_ctx *ctx)
|
|
||||||
{
|
|
||||||
uint8_t *const nonce = ctx->nonce;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
for (j = 0; j < 8; j++) {
|
|
||||||
if (++nonce[j])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
aes_ctr_update(archive_crypto_ctx *ctx, const uint8_t * const in,
|
|
||||||
size_t in_len, uint8_t * const out, size_t *out_len)
|
|
||||||
{
|
|
||||||
uint8_t *const ebuf = ctx->encr_buf;
|
|
||||||
unsigned pos = ctx->encr_pos;
|
|
||||||
unsigned max = (unsigned)((in_len < *out_len)? in_len: *out_len);
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for (i = 0; i < max; ) {
|
|
||||||
if (pos == AES_BLOCK_SIZE) {
|
|
||||||
aes_ctr_increase_counter(ctx);
|
|
||||||
if (aes_ctr_encrypt_counter(ctx) != 0)
|
|
||||||
return -1;
|
|
||||||
while (max -i >= AES_BLOCK_SIZE) {
|
|
||||||
for (pos = 0; pos < AES_BLOCK_SIZE; pos++)
|
|
||||||
out[i+pos] = in[i+pos] ^ ebuf[pos];
|
|
||||||
i += AES_BLOCK_SIZE;
|
|
||||||
aes_ctr_increase_counter(ctx);
|
|
||||||
if (aes_ctr_encrypt_counter(ctx) != 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pos = 0;
|
|
||||||
if (i >= max)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
out[i] = in[i] ^ ebuf[pos++];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ctx->encr_pos = pos;
|
|
||||||
*out_len = i;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_CRYPTOR_STUB */
|
|
||||||
|
|
||||||
|
|
||||||
const struct archive_cryptor __archive_cryptor =
|
|
||||||
{
|
|
||||||
&pbkdf2_sha1,
|
|
||||||
&aes_ctr_init,
|
|
||||||
&aes_ctr_update,
|
|
||||||
&aes_ctr_release,
|
|
||||||
&aes_ctr_init,
|
|
||||||
&aes_ctr_update,
|
|
||||||
&aes_ctr_release,
|
|
||||||
};
|
|
179
3rdparty/libarchive/c/archive_cryptor_private.h
vendored
179
3rdparty/libarchive/c/archive_cryptor_private.h
vendored
@ -1,179 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_CRYPTOR_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* On systems that do not support any recognized crypto libraries,
|
|
||||||
* the archive_cryptor.c file will normally define no usable symbols.
|
|
||||||
*
|
|
||||||
* But some compilers and linkers choke on empty object files, so
|
|
||||||
* define a public symbol that will always exist. This could
|
|
||||||
* be removed someday if this file gains another always-present
|
|
||||||
* symbol definition.
|
|
||||||
*/
|
|
||||||
int __libarchive_cryptor_build_hack(void);
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
# include <AvailabilityMacros.h>
|
|
||||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
|
|
||||||
# define ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARCHIVE_CRYPTOR_USE_Apple_CommonCrypto
|
|
||||||
#include <CommonCrypto/CommonCryptor.h>
|
|
||||||
#include <CommonCrypto/CommonKeyDerivation.h>
|
|
||||||
#define AES_BLOCK_SIZE 16
|
|
||||||
#define AES_MAX_KEY_SIZE kCCKeySizeAES256
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
CCCryptorRef ctx;
|
|
||||||
uint8_t key[AES_MAX_KEY_SIZE];
|
|
||||||
unsigned key_len;
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE];
|
|
||||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
|
||||||
unsigned encr_pos;
|
|
||||||
} archive_crypto_ctx;
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
|
||||||
#include <bcrypt.h>
|
|
||||||
|
|
||||||
/* Common in other bcrypt implementations, but missing from VS2008. */
|
|
||||||
#ifndef BCRYPT_SUCCESS
|
|
||||||
#define BCRYPT_SUCCESS(r) ((NTSTATUS)(r) == STATUS_SUCCESS)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define AES_MAX_KEY_SIZE 32
|
|
||||||
#define AES_BLOCK_SIZE 16
|
|
||||||
typedef struct {
|
|
||||||
BCRYPT_ALG_HANDLE hAlg;
|
|
||||||
BCRYPT_KEY_HANDLE hKey;
|
|
||||||
PBYTE keyObj;
|
|
||||||
DWORD keyObj_len;
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE];
|
|
||||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
|
||||||
unsigned encr_pos;
|
|
||||||
} archive_crypto_ctx;
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_AES_H)
|
|
||||||
#include <mbedtls/aes.h>
|
|
||||||
#include <mbedtls/md.h>
|
|
||||||
#include <mbedtls/pkcs5.h>
|
|
||||||
|
|
||||||
#define AES_MAX_KEY_SIZE 32
|
|
||||||
#define AES_BLOCK_SIZE 16
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
mbedtls_aes_context ctx;
|
|
||||||
uint8_t key[AES_MAX_KEY_SIZE];
|
|
||||||
unsigned key_len;
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE];
|
|
||||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
|
||||||
unsigned encr_pos;
|
|
||||||
} archive_crypto_ctx;
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H)
|
|
||||||
#if defined(HAVE_NETTLE_PBKDF2_H)
|
|
||||||
#include <nettle/pbkdf2.h>
|
|
||||||
#endif
|
|
||||||
#include <nettle/aes.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
struct aes_ctx ctx;
|
|
||||||
uint8_t key[AES_MAX_KEY_SIZE];
|
|
||||||
unsigned key_len;
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE];
|
|
||||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
|
||||||
unsigned encr_pos;
|
|
||||||
} archive_crypto_ctx;
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBCRYPTO)
|
|
||||||
#include "archive_openssl_evp_private.h"
|
|
||||||
#define AES_BLOCK_SIZE 16
|
|
||||||
#define AES_MAX_KEY_SIZE 32
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
EVP_CIPHER_CTX *ctx;
|
|
||||||
const EVP_CIPHER *type;
|
|
||||||
uint8_t key[AES_MAX_KEY_SIZE];
|
|
||||||
unsigned key_len;
|
|
||||||
uint8_t nonce[AES_BLOCK_SIZE];
|
|
||||||
uint8_t encr_buf[AES_BLOCK_SIZE];
|
|
||||||
unsigned encr_pos;
|
|
||||||
} archive_crypto_ctx;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define AES_BLOCK_SIZE 16
|
|
||||||
#define AES_MAX_KEY_SIZE 32
|
|
||||||
typedef int archive_crypto_ctx;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* defines */
|
|
||||||
#define archive_pbkdf2_sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)\
|
|
||||||
__archive_cryptor.pbkdf2sha1(pw, pw_len, salt, salt_len, rounds, dk, dk_len)
|
|
||||||
|
|
||||||
#define archive_decrypto_aes_ctr_init(ctx, key, key_len) \
|
|
||||||
__archive_cryptor.decrypto_aes_ctr_init(ctx, key, key_len)
|
|
||||||
#define archive_decrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
|
|
||||||
__archive_cryptor.decrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
|
|
||||||
#define archive_decrypto_aes_ctr_release(ctx) \
|
|
||||||
__archive_cryptor.decrypto_aes_ctr_release(ctx)
|
|
||||||
|
|
||||||
#define archive_encrypto_aes_ctr_init(ctx, key, key_len) \
|
|
||||||
__archive_cryptor.encrypto_aes_ctr_init(ctx, key, key_len)
|
|
||||||
#define archive_encrypto_aes_ctr_update(ctx, in, in_len, out, out_len) \
|
|
||||||
__archive_cryptor.encrypto_aes_ctr_update(ctx, in, in_len, out, out_len)
|
|
||||||
#define archive_encrypto_aes_ctr_release(ctx) \
|
|
||||||
__archive_cryptor.encrypto_aes_ctr_release(ctx)
|
|
||||||
|
|
||||||
/* Minimal interface to cryptographic functionality for internal use in
|
|
||||||
* libarchive */
|
|
||||||
struct archive_cryptor
|
|
||||||
{
|
|
||||||
/* PKCS5 PBKDF2 HMAC-SHA1 */
|
|
||||||
int (*pbkdf2sha1)(const char *pw, size_t pw_len, const uint8_t *salt,
|
|
||||||
size_t salt_len, unsigned rounds, uint8_t *derived_key,
|
|
||||||
size_t derived_key_len);
|
|
||||||
/* AES CTR mode(little endian version) */
|
|
||||||
int (*decrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
|
|
||||||
int (*decrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
|
|
||||||
size_t, uint8_t *, size_t *);
|
|
||||||
int (*decrypto_aes_ctr_release)(archive_crypto_ctx *);
|
|
||||||
int (*encrypto_aes_ctr_init)(archive_crypto_ctx *, const uint8_t *, size_t);
|
|
||||||
int (*encrypto_aes_ctr_update)(archive_crypto_ctx *, const uint8_t *,
|
|
||||||
size_t, uint8_t *, size_t *);
|
|
||||||
int (*encrypto_aes_ctr_release)(archive_crypto_ctx *);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const struct archive_cryptor __archive_cryptor;
|
|
||||||
|
|
||||||
#endif
|
|
1499
3rdparty/libarchive/c/archive_digest.c
vendored
1499
3rdparty/libarchive/c/archive_digest.c
vendored
File diff suppressed because it is too large
Load Diff
412
3rdparty/libarchive/c/archive_digest_private.h
vendored
412
3rdparty/libarchive/c/archive_digest_private.h
vendored
@ -1,412 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* Copyright (c) 2011 Andres Mejia
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_DIGEST_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_DIGEST_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Crypto support in various Operating Systems:
|
|
||||||
*
|
|
||||||
* NetBSD:
|
|
||||||
* - MD5 and SHA1 in libc: without _ after algorithm name
|
|
||||||
* - SHA2 in libc: with _ after algorithm name
|
|
||||||
*
|
|
||||||
* OpenBSD:
|
|
||||||
* - MD5, SHA1 and SHA2 in libc: without _ after algorithm name
|
|
||||||
* - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name
|
|
||||||
*
|
|
||||||
* DragonFly and FreeBSD:
|
|
||||||
* - MD5 libmd: without _ after algorithm name
|
|
||||||
* - SHA1, SHA256 and SHA512 in libmd: with _ after algorithm name
|
|
||||||
*
|
|
||||||
* Mac OS X (10.4 and later):
|
|
||||||
* - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm name
|
|
||||||
*
|
|
||||||
* OpenSSL:
|
|
||||||
* - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name
|
|
||||||
*
|
|
||||||
* Windows:
|
|
||||||
* - MD5, SHA1 and SHA2 in archive_crypto.c using Windows crypto API
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* libc crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBC)
|
|
||||||
#include <md5.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
|
|
||||||
#include <rmd160.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
|
|
||||||
#include <sha1.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBC3) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBC2) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBC3) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
|
|
||||||
#include <sha2.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* libmd crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBMD) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_RMD160_LIBMD) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_LIBMD) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBMD) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
|
|
||||||
#define ARCHIVE_CRYPTO_LIBMD 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBMD)
|
|
||||||
#include <md5.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
|
|
||||||
#include <ripemd.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
|
|
||||||
#include <sha.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
|
|
||||||
#include <sha256.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
|
|
||||||
#include <sha512.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* libSystem crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
|
|
||||||
#include <CommonCrypto/CommonDigest.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* mbed TLS crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
|
|
||||||
#include <mbedtls/md5.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS)
|
|
||||||
#include <mbedtls/ripemd160.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
|
|
||||||
#include <mbedtls/sha1.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
|
|
||||||
#include <mbedtls/sha256.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
|
|
||||||
#include <mbedtls/sha512.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Nettle crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_NETTLE)
|
|
||||||
#include <nettle/md5.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
|
|
||||||
#include <nettle/ripemd160.h>
|
|
||||||
#endif
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA1_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
|
|
||||||
#include <nettle/sha.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* OpenSSL crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_RMD160_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
|
|
||||||
#define ARCHIVE_CRYPTO_OPENSSL 1
|
|
||||||
#include "archive_openssl_evp_private.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Windows crypto headers */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_WIN) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_WIN) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_WIN) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_WIN) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
|
||||||
#include <windows.h>
|
|
||||||
#include <wincrypt.h>
|
|
||||||
typedef struct {
|
|
||||||
int valid;
|
|
||||||
HCRYPTPROV cryptProv;
|
|
||||||
HCRYPTHASH hash;
|
|
||||||
} Digest_CTX;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* typedefs */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBC)
|
|
||||||
typedef MD5_CTX archive_md5_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_MD5_LIBMD)
|
|
||||||
typedef MD5_CTX archive_md5_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
|
|
||||||
typedef CC_MD5_CTX archive_md5_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
|
|
||||||
typedef mbedtls_md5_context archive_md5_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
|
|
||||||
typedef struct md5_ctx archive_md5_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
|
|
||||||
typedef EVP_MD_CTX *archive_md5_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_MD5_WIN)
|
|
||||||
typedef Digest_CTX archive_md5_ctx;
|
|
||||||
#else
|
|
||||||
typedef unsigned char archive_md5_ctx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_RMD160_LIBC)
|
|
||||||
typedef RMD160_CTX archive_rmd160_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
|
|
||||||
typedef RIPEMD160_CTX archive_rmd160_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS)
|
|
||||||
typedef mbedtls_ripemd160_context archive_rmd160_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
|
|
||||||
typedef struct ripemd160_ctx archive_rmd160_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
|
|
||||||
typedef EVP_MD_CTX *archive_rmd160_ctx;
|
|
||||||
#else
|
|
||||||
typedef unsigned char archive_rmd160_ctx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA1_LIBC)
|
|
||||||
typedef SHA1_CTX archive_sha1_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD)
|
|
||||||
typedef SHA1_CTX archive_sha1_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM)
|
|
||||||
typedef CC_SHA1_CTX archive_sha1_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
|
|
||||||
typedef mbedtls_sha1_context archive_sha1_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
|
|
||||||
typedef struct sha1_ctx archive_sha1_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
|
|
||||||
typedef EVP_MD_CTX *archive_sha1_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
|
|
||||||
typedef Digest_CTX archive_sha1_ctx;
|
|
||||||
#else
|
|
||||||
typedef unsigned char archive_sha1_ctx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA256_LIBC)
|
|
||||||
typedef SHA256_CTX archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2)
|
|
||||||
typedef SHA256_CTX archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3)
|
|
||||||
typedef SHA2_CTX archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD)
|
|
||||||
typedef SHA256_CTX archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM)
|
|
||||||
typedef CC_SHA256_CTX archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
|
|
||||||
typedef mbedtls_sha256_context archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
|
|
||||||
typedef struct sha256_ctx archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
|
|
||||||
typedef EVP_MD_CTX *archive_sha256_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
|
|
||||||
typedef Digest_CTX archive_sha256_ctx;
|
|
||||||
#else
|
|
||||||
typedef unsigned char archive_sha256_ctx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA384_LIBC)
|
|
||||||
typedef SHA384_CTX archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2)
|
|
||||||
typedef SHA384_CTX archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3)
|
|
||||||
typedef SHA2_CTX archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM)
|
|
||||||
typedef CC_SHA512_CTX archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS)
|
|
||||||
typedef mbedtls_sha512_context archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
|
|
||||||
typedef struct sha384_ctx archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
|
|
||||||
typedef EVP_MD_CTX *archive_sha384_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
|
|
||||||
typedef Digest_CTX archive_sha384_ctx;
|
|
||||||
#else
|
|
||||||
typedef unsigned char archive_sha384_ctx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA512_LIBC)
|
|
||||||
typedef SHA512_CTX archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2)
|
|
||||||
typedef SHA512_CTX archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3)
|
|
||||||
typedef SHA2_CTX archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD)
|
|
||||||
typedef SHA512_CTX archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
|
|
||||||
typedef CC_SHA512_CTX archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
|
|
||||||
typedef mbedtls_sha512_context archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
|
|
||||||
typedef struct sha512_ctx archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
|
|
||||||
typedef EVP_MD_CTX *archive_sha512_ctx;
|
|
||||||
#elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
|
||||||
typedef Digest_CTX archive_sha512_ctx;
|
|
||||||
#else
|
|
||||||
typedef unsigned char archive_sha512_ctx;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* defines */
|
|
||||||
#if defined(ARCHIVE_CRYPTO_MD5_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_MD5_LIBMD) || \
|
|
||||||
defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_MD5_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_MD5_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_MD5_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_MD5_WIN)
|
|
||||||
#define ARCHIVE_HAS_MD5
|
|
||||||
#endif
|
|
||||||
#define archive_md5_init(ctx)\
|
|
||||||
__archive_digest.md5init(ctx)
|
|
||||||
#define archive_md5_final(ctx, md)\
|
|
||||||
__archive_digest.md5final(ctx, md)
|
|
||||||
#define archive_md5_update(ctx, buf, n)\
|
|
||||||
__archive_digest.md5update(ctx, buf, n)
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_RMD160_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_RMD160_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
|
|
||||||
#define ARCHIVE_HAS_RMD160
|
|
||||||
#endif
|
|
||||||
#define archive_rmd160_init(ctx)\
|
|
||||||
__archive_digest.rmd160init(ctx)
|
|
||||||
#define archive_rmd160_final(ctx, md)\
|
|
||||||
__archive_digest.rmd160final(ctx, md)
|
|
||||||
#define archive_rmd160_update(ctx, buf, n)\
|
|
||||||
__archive_digest.rmd160update(ctx, buf, n)
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA1_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_LIBMD) || \
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA1_WIN)
|
|
||||||
#define ARCHIVE_HAS_SHA1
|
|
||||||
#endif
|
|
||||||
#define archive_sha1_init(ctx)\
|
|
||||||
__archive_digest.sha1init(ctx)
|
|
||||||
#define archive_sha1_final(ctx, md)\
|
|
||||||
__archive_digest.sha1final(ctx, md)
|
|
||||||
#define archive_sha1_update(ctx, buf, n)\
|
|
||||||
__archive_digest.sha1update(ctx, buf, n)
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA256_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBC2) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBC3) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBMD) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA256_WIN)
|
|
||||||
#define ARCHIVE_HAS_SHA256
|
|
||||||
#endif
|
|
||||||
#define archive_sha256_init(ctx)\
|
|
||||||
__archive_digest.sha256init(ctx)
|
|
||||||
#define archive_sha256_final(ctx, md)\
|
|
||||||
__archive_digest.sha256final(ctx, md)
|
|
||||||
#define archive_sha256_update(ctx, buf, n)\
|
|
||||||
__archive_digest.sha256update(ctx, buf, n)
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA384_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBC2) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBC3) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA384_WIN)
|
|
||||||
#define ARCHIVE_HAS_SHA384
|
|
||||||
#endif
|
|
||||||
#define archive_sha384_init(ctx)\
|
|
||||||
__archive_digest.sha384init(ctx)
|
|
||||||
#define archive_sha384_final(ctx, md)\
|
|
||||||
__archive_digest.sha384final(ctx, md)
|
|
||||||
#define archive_sha384_update(ctx, buf, n)\
|
|
||||||
__archive_digest.sha384update(ctx, buf, n)
|
|
||||||
|
|
||||||
#if defined(ARCHIVE_CRYPTO_SHA512_LIBC) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBC2) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBC3) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBMD) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_NETTLE) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) ||\
|
|
||||||
defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
|
||||||
#define ARCHIVE_HAS_SHA512
|
|
||||||
#endif
|
|
||||||
#define archive_sha512_init(ctx)\
|
|
||||||
__archive_digest.sha512init(ctx)
|
|
||||||
#define archive_sha512_final(ctx, md)\
|
|
||||||
__archive_digest.sha512final(ctx, md)
|
|
||||||
#define archive_sha512_update(ctx, buf, n)\
|
|
||||||
__archive_digest.sha512update(ctx, buf, n)
|
|
||||||
|
|
||||||
/* Minimal interface to digest functionality for internal use in libarchive */
|
|
||||||
struct archive_digest
|
|
||||||
{
|
|
||||||
/* Message Digest */
|
|
||||||
int (*md5init)(archive_md5_ctx *ctx);
|
|
||||||
int (*md5update)(archive_md5_ctx *, const void *, size_t);
|
|
||||||
int (*md5final)(archive_md5_ctx *, void *);
|
|
||||||
int (*rmd160init)(archive_rmd160_ctx *);
|
|
||||||
int (*rmd160update)(archive_rmd160_ctx *, const void *, size_t);
|
|
||||||
int (*rmd160final)(archive_rmd160_ctx *, void *);
|
|
||||||
int (*sha1init)(archive_sha1_ctx *);
|
|
||||||
int (*sha1update)(archive_sha1_ctx *, const void *, size_t);
|
|
||||||
int (*sha1final)(archive_sha1_ctx *, void *);
|
|
||||||
int (*sha256init)(archive_sha256_ctx *);
|
|
||||||
int (*sha256update)(archive_sha256_ctx *, const void *, size_t);
|
|
||||||
int (*sha256final)(archive_sha256_ctx *, void *);
|
|
||||||
int (*sha384init)(archive_sha384_ctx *);
|
|
||||||
int (*sha384update)(archive_sha384_ctx *, const void *, size_t);
|
|
||||||
int (*sha384final)(archive_sha384_ctx *, void *);
|
|
||||||
int (*sha512init)(archive_sha512_ctx *);
|
|
||||||
int (*sha512update)(archive_sha512_ctx *, const void *, size_t);
|
|
||||||
int (*sha512final)(archive_sha512_ctx *, void *);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const struct archive_digest __archive_digest;
|
|
||||||
|
|
||||||
#endif
|
|
559
3rdparty/libarchive/c/archive_disk_acl_darwin.c
vendored
559
3rdparty/libarchive/c/archive_disk_acl_darwin.c
vendored
@ -1,559 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2017 Martin Matuska
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_DARWIN
|
|
||||||
|
|
||||||
#ifdef HAVE_FCNTL_H
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_MEMBERSHIP_H
|
|
||||||
#include <membership.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_ACL_H
|
|
||||||
#define _ACL_PRIVATE /* For debugging */
|
|
||||||
#include <sys/acl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_read_disk_private.h"
|
|
||||||
#include "archive_write_disk_private.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const int a_perm; /* Libarchive permission or flag */
|
|
||||||
const int p_perm; /* Platform permission or flag */
|
|
||||||
} acl_perm_map_t;
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_nfs4_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER},
|
|
||||||
#if HAVE_DECL_ACL_SYNCHRONIZE
|
|
||||||
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_perm_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_nfs4_flag_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_flag_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
|
|
||||||
|
|
||||||
static int translate_guid(struct archive *a, acl_entry_t acl_entry,
|
|
||||||
int *ae_id, int *ae_tag, const char **ae_name)
|
|
||||||
{
|
|
||||||
void *q;
|
|
||||||
uid_t ugid;
|
|
||||||
int r, idtype;
|
|
||||||
|
|
||||||
q = acl_get_qualifier(acl_entry);
|
|
||||||
if (q == NULL)
|
|
||||||
return (1);
|
|
||||||
r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype);
|
|
||||||
if (r != 0) {
|
|
||||||
acl_free(q);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (idtype == ID_TYPE_UID) {
|
|
||||||
*ae_tag = ARCHIVE_ENTRY_ACL_USER;
|
|
||||||
*ae_id = ugid;
|
|
||||||
*ae_name = archive_read_disk_uname(a, *ae_id);
|
|
||||||
} else if (idtype == ID_TYPE_GID) {
|
|
||||||
*ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
|
|
||||||
*ae_id = ugid;
|
|
||||||
*ae_name = archive_read_disk_gname(a, *ae_id);
|
|
||||||
} else
|
|
||||||
r = 1;
|
|
||||||
|
|
||||||
acl_free(q);
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
add_trivial_nfs4_acl(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
mode_t mode;
|
|
||||||
int i;
|
|
||||||
const int rperm = ARCHIVE_ENTRY_ACL_READ_DATA;
|
|
||||||
const int wperm = ARCHIVE_ENTRY_ACL_WRITE_DATA |
|
|
||||||
ARCHIVE_ENTRY_ACL_APPEND_DATA;
|
|
||||||
const int eperm = ARCHIVE_ENTRY_ACL_EXECUTE;
|
|
||||||
const int pubset = ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
|
|
||||||
ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
|
|
||||||
ARCHIVE_ENTRY_ACL_READ_ACL |
|
|
||||||
ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
|
|
||||||
const int ownset = pubset | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
|
|
||||||
ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
|
|
||||||
ARCHIVE_ENTRY_ACL_WRITE_ACL |
|
|
||||||
ARCHIVE_ENTRY_ACL_WRITE_OWNER;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
const int type;
|
|
||||||
const int tag;
|
|
||||||
int permset;
|
|
||||||
} tacl_entry[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
|
|
||||||
{ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
|
|
||||||
{ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0},
|
|
||||||
{ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, ownset},
|
|
||||||
{ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_GROUP_OBJ, pubset},
|
|
||||||
{ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EVERYONE, pubset}
|
|
||||||
};
|
|
||||||
|
|
||||||
mode = archive_entry_mode(entry);
|
|
||||||
|
|
||||||
/* Permissions for everyone@ */
|
|
||||||
if (mode & 0004)
|
|
||||||
tacl_entry[5].permset |= rperm;
|
|
||||||
if (mode & 0002)
|
|
||||||
tacl_entry[5].permset |= wperm;
|
|
||||||
if (mode & 0001)
|
|
||||||
tacl_entry[5].permset |= eperm;
|
|
||||||
|
|
||||||
/* Permissions for group@ */
|
|
||||||
if (mode & 0040)
|
|
||||||
tacl_entry[4].permset |= rperm;
|
|
||||||
else if (mode & 0004)
|
|
||||||
tacl_entry[2].permset |= rperm;
|
|
||||||
if (mode & 0020)
|
|
||||||
tacl_entry[4].permset |= wperm;
|
|
||||||
else if (mode & 0002)
|
|
||||||
tacl_entry[2].permset |= wperm;
|
|
||||||
if (mode & 0010)
|
|
||||||
tacl_entry[4].permset |= eperm;
|
|
||||||
else if (mode & 0001)
|
|
||||||
tacl_entry[2].permset |= eperm;
|
|
||||||
|
|
||||||
/* Permissions for owner@ */
|
|
||||||
if (mode & 0400) {
|
|
||||||
tacl_entry[3].permset |= rperm;
|
|
||||||
if (!(mode & 0040) && (mode & 0004))
|
|
||||||
tacl_entry[0].permset |= rperm;
|
|
||||||
} else if ((mode & 0040) || (mode & 0004))
|
|
||||||
tacl_entry[1].permset |= rperm;
|
|
||||||
if (mode & 0200) {
|
|
||||||
tacl_entry[3].permset |= wperm;
|
|
||||||
if (!(mode & 0020) && (mode & 0002))
|
|
||||||
tacl_entry[0].permset |= wperm;
|
|
||||||
} else if ((mode & 0020) || (mode & 0002))
|
|
||||||
tacl_entry[1].permset |= wperm;
|
|
||||||
if (mode & 0100) {
|
|
||||||
tacl_entry[3].permset |= eperm;
|
|
||||||
if (!(mode & 0010) && (mode & 0001))
|
|
||||||
tacl_entry[0].permset |= eperm;
|
|
||||||
} else if ((mode & 0010) || (mode & 0001))
|
|
||||||
tacl_entry[1].permset |= eperm;
|
|
||||||
|
|
||||||
for (i = 0; i < 6; i++) {
|
|
||||||
if (tacl_entry[i].permset != 0) {
|
|
||||||
archive_entry_acl_add_entry(entry,
|
|
||||||
tacl_entry[i].type, tacl_entry[i].permset,
|
|
||||||
tacl_entry[i].tag, -1, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
translate_acl(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, acl_t acl)
|
|
||||||
{
|
|
||||||
acl_tag_t acl_tag;
|
|
||||||
acl_flagset_t acl_flagset;
|
|
||||||
acl_entry_t acl_entry;
|
|
||||||
acl_permset_t acl_permset;
|
|
||||||
int i, entry_acl_type;
|
|
||||||
int r, s, ae_id, ae_tag, ae_perm;
|
|
||||||
const char *ae_name;
|
|
||||||
|
|
||||||
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
|
|
||||||
if (s == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get first ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (s == 0) {
|
|
||||||
ae_id = -1;
|
|
||||||
ae_name = NULL;
|
|
||||||
ae_perm = 0;
|
|
||||||
|
|
||||||
if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get ACL tag type");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
switch (acl_tag) {
|
|
||||||
case ACL_EXTENDED_ALLOW:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
|
|
||||||
r = translate_guid(&a->archive, acl_entry,
|
|
||||||
&ae_id, &ae_tag, &ae_name);
|
|
||||||
break;
|
|
||||||
case ACL_EXTENDED_DENY:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
|
|
||||||
r = translate_guid(&a->archive, acl_entry,
|
|
||||||
&ae_id, &ae_tag, &ae_name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Skip types that libarchive can't support. */
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip if translate_guid() above failed */
|
|
||||||
if (r != 0) {
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
|
||||||
* in the ae_perm bitmap.
|
|
||||||
*
|
|
||||||
* acl_get_flagset_np() fails with non-NFSv4 ACLs
|
|
||||||
*/
|
|
||||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get flagset from a NFSv4 ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
r = acl_get_flag_np(acl_flagset,
|
|
||||||
acl_nfs4_flag_map[i].p_perm);
|
|
||||||
if (r == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to check flag in a NFSv4 "
|
|
||||||
"ACL flagset");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
} else if (r)
|
|
||||||
ae_perm |= acl_nfs4_flag_map[i].a_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get ACL permission set");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
|
|
||||||
/*
|
|
||||||
* acl_get_perm() is spelled differently on different
|
|
||||||
* platforms; see above.
|
|
||||||
*/
|
|
||||||
r = acl_get_perm_np(acl_permset,
|
|
||||||
acl_nfs4_perm_map[i].p_perm);
|
|
||||||
if (r == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to check permission in an ACL "
|
|
||||||
"permission set");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
} else if (r)
|
|
||||||
ae_perm |= acl_nfs4_perm_map[i].a_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !HAVE_DECL_ACL_SYNCHRONIZE
|
|
||||||
/* On Mac OS X without ACL_SYNCHRONIZE assume it is set */
|
|
||||||
ae_perm |= ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
archive_entry_acl_add_entry(entry, entry_acl_type,
|
|
||||||
ae_perm, ae_tag,
|
|
||||||
ae_id, ae_name);
|
|
||||||
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
set_acl(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl,
|
|
||||||
int ae_requested_type, const char *tname)
|
|
||||||
{
|
|
||||||
acl_t acl;
|
|
||||||
acl_entry_t acl_entry;
|
|
||||||
acl_permset_t acl_permset;
|
|
||||||
acl_flagset_t acl_flagset;
|
|
||||||
int ret;
|
|
||||||
int ae_type, ae_permset, ae_tag, ae_id;
|
|
||||||
uuid_t ae_uuid;
|
|
||||||
uid_t ae_uid;
|
|
||||||
gid_t ae_gid;
|
|
||||||
const char *ae_name;
|
|
||||||
int entries;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
entries = archive_acl_reset(abstract_acl, ae_requested_type);
|
|
||||||
if (entries == 0)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
|
|
||||||
if (ae_requested_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
errno = ENOENT;
|
|
||||||
archive_set_error(a, errno, "Unsupported ACL type");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
acl = acl_init(entries);
|
|
||||||
if (acl == (acl_t)NULL) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to initialize ACL working storage");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
|
||||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
|
||||||
/*
|
|
||||||
* Mac OS doesn't support NFSv4 ACLs for
|
|
||||||
* owner@, group@ and everyone@.
|
|
||||||
* We skip any of these ACLs found.
|
|
||||||
*/
|
|
||||||
if (ae_tag == ARCHIVE_ENTRY_ACL_USER_OBJ ||
|
|
||||||
ae_tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ ||
|
|
||||||
ae_tag == ARCHIVE_ENTRY_ACL_EVERYONE)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (acl_create_entry(&acl, &acl_entry) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to create a new ACL entry");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ae_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_EXTENDED_ALLOW);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DENY:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_EXTENDED_DENY);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* We don't support any other types on MacOS */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ae_tag) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER:
|
|
||||||
ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
|
|
||||||
if (mbr_uid_to_uuid(ae_uid, ae_uuid) != 0)
|
|
||||||
continue;
|
|
||||||
if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
|
|
||||||
continue;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP:
|
|
||||||
ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
|
|
||||||
if (mbr_gid_to_uuid(ae_gid, ae_uuid) != 0)
|
|
||||||
continue;
|
|
||||||
if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
|
|
||||||
continue;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL tag");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to get ACL permission set");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
if (acl_clear_perms(acl_permset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to clear ACL permissions");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
|
|
||||||
if (ae_permset & acl_nfs4_perm_map[i].a_perm) {
|
|
||||||
if (acl_add_perm(acl_permset,
|
|
||||||
acl_nfs4_perm_map[i].p_perm) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to add ACL permission");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* acl_get_flagset_np() fails with non-NFSv4 ACLs
|
|
||||||
*/
|
|
||||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to get flagset from an NFSv4 ACL entry");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
if (acl_clear_flags_np(acl_flagset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to clear flags from an NFSv4 ACL flagset");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
|
|
||||||
if (acl_add_flag_np(acl_flagset,
|
|
||||||
acl_nfs4_flag_map[i].p_perm) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to add flag to "
|
|
||||||
"NFSv4 ACL flagset");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fd >= 0) {
|
|
||||||
if (acl_set_fd_np(fd, acl, ACL_TYPE_EXTENDED) == 0)
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
else {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set acl on fd: %s", tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (acl_set_link_np(name, ACL_TYPE_EXTENDED, acl) != 0) {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno, "Failed to set acl: %s",
|
|
||||||
tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit_free:
|
|
||||||
acl_free(acl);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, int *fd)
|
|
||||||
{
|
|
||||||
const char *accpath;
|
|
||||||
acl_t acl;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
accpath = NULL;
|
|
||||||
|
|
||||||
if (*fd < 0) {
|
|
||||||
accpath = archive_read_disk_entry_setup_path(a, entry, fd);
|
|
||||||
if (accpath == NULL)
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_clear(entry);
|
|
||||||
|
|
||||||
acl = NULL;
|
|
||||||
|
|
||||||
if (*fd >= 0)
|
|
||||||
acl = acl_get_fd_np(*fd, ACL_TYPE_EXTENDED);
|
|
||||||
else if (!a->follow_symlinks)
|
|
||||||
acl = acl_get_link_np(accpath, ACL_TYPE_EXTENDED);
|
|
||||||
else
|
|
||||||
acl = acl_get_file(accpath, ACL_TYPE_EXTENDED);
|
|
||||||
|
|
||||||
if (acl != NULL) {
|
|
||||||
r = translate_acl(a, entry, acl);
|
|
||||||
acl_free(acl);
|
|
||||||
acl = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate NFSv4 ACLs");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Because Mac OS doesn't support owner@, group@ and everyone@
|
|
||||||
* ACLs we need to add NFSv4 ACLs mirroring the file mode to
|
|
||||||
* the archive entry. Otherwise extraction on non-Mac platforms
|
|
||||||
* would lead to an invalid file mode.
|
|
||||||
*/
|
|
||||||
if ((archive_entry_acl_types(entry) &
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0)
|
|
||||||
add_trivial_nfs4_acl(entry);
|
|
||||||
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl, __LA_MODE_T mode)
|
|
||||||
{
|
|
||||||
int ret = ARCHIVE_OK;
|
|
||||||
|
|
||||||
(void)mode; /* UNUSED */
|
|
||||||
|
|
||||||
if ((archive_acl_types(abstract_acl) &
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
|
|
||||||
}
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_DARWIN */
|
|
702
3rdparty/libarchive/c/archive_disk_acl_freebsd.c
vendored
702
3rdparty/libarchive/c/archive_disk_acl_freebsd.c
vendored
@ -1,702 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2009 Tim Kientzle
|
|
||||||
* Copyright (c) 2010-2012 Michihiro NAKAJIMA
|
|
||||||
* Copyright (c) 2017 Martin Matuska
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD
|
|
||||||
|
|
||||||
#ifdef HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_FCNTL_H
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_ACL_H
|
|
||||||
#define _ACL_PRIVATE /* For debugging */
|
|
||||||
#include <sys/acl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_read_disk_private.h"
|
|
||||||
#include "archive_write_disk_private.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const int a_perm; /* Libarchive permission or flag */
|
|
||||||
const int p_perm; /* Platform permission or flag */
|
|
||||||
} acl_perm_map_t;
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_posix_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_posix_perm_map_size =
|
|
||||||
(int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
static const acl_perm_map_t acl_nfs4_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
|
|
||||||
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_perm_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_nfs4_flag_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
|
|
||||||
#ifdef ACL_ENTRY_INHERITED
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_flag_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
|
|
||||||
#endif /* ARCHIVE_ACL_FREEBSD_NFS4 */
|
|
||||||
|
|
||||||
static int
|
|
||||||
translate_acl(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
|
|
||||||
{
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
int brand;
|
|
||||||
acl_flagset_t acl_flagset;
|
|
||||||
acl_entry_type_t acl_type;
|
|
||||||
#endif
|
|
||||||
acl_tag_t acl_tag;
|
|
||||||
acl_entry_t acl_entry;
|
|
||||||
acl_permset_t acl_permset;
|
|
||||||
int i, entry_acl_type, perm_map_size;
|
|
||||||
const acl_perm_map_t *perm_map;
|
|
||||||
int r, s, ae_id, ae_tag, ae_perm;
|
|
||||||
void *q;
|
|
||||||
const char *ae_name;
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
// FreeBSD "brands" ACLs as POSIX.1e or NFSv4
|
|
||||||
// Make sure the "brand" on this ACL is consistent
|
|
||||||
// with the default_entry_acl_type bits provided.
|
|
||||||
if (acl_get_brand_np(acl, &brand) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to read ACL brand");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
switch (brand) {
|
|
||||||
case ACL_BRAND_POSIX:
|
|
||||||
switch (default_entry_acl_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Invalid ACL entry type for POSIX.1e ACL");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ACL_BRAND_NFS4:
|
|
||||||
if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Invalid ACL entry type for NFSv4 ACL");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unknown ACL brand");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
|
|
||||||
if (s == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get first ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (s == 1) {
|
|
||||||
ae_id = -1;
|
|
||||||
ae_name = NULL;
|
|
||||||
ae_perm = 0;
|
|
||||||
|
|
||||||
if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get ACL tag type");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
switch (acl_tag) {
|
|
||||||
case ACL_USER:
|
|
||||||
q = acl_get_qualifier(acl_entry);
|
|
||||||
if (q != NULL) {
|
|
||||||
ae_id = (int)*(uid_t *)q;
|
|
||||||
acl_free(q);
|
|
||||||
ae_name = archive_read_disk_uname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
}
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER;
|
|
||||||
break;
|
|
||||||
case ACL_GROUP:
|
|
||||||
q = acl_get_qualifier(acl_entry);
|
|
||||||
if (q != NULL) {
|
|
||||||
ae_id = (int)*(gid_t *)q;
|
|
||||||
acl_free(q);
|
|
||||||
ae_name = archive_read_disk_gname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
}
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
|
|
||||||
break;
|
|
||||||
case ACL_MASK:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_MASK;
|
|
||||||
break;
|
|
||||||
case ACL_USER_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
|
|
||||||
break;
|
|
||||||
case ACL_GROUP_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
|
|
||||||
break;
|
|
||||||
case ACL_OTHER:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
|
|
||||||
break;
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
case ACL_EVERYONE:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
/* Skip types that libarchive can't support. */
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX acl_type maps to allow/deny/audit/YYYY bits
|
|
||||||
entry_acl_type = default_entry_acl_type;
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
/*
|
|
||||||
* acl_get_entry_type_np() fails with non-NFSv4 ACLs
|
|
||||||
*/
|
|
||||||
if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno, "Failed "
|
|
||||||
"to get ACL type from a NFSv4 ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
switch (acl_type) {
|
|
||||||
case ACL_ENTRY_TYPE_ALLOW:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
|
|
||||||
break;
|
|
||||||
case ACL_ENTRY_TYPE_DENY:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
|
|
||||||
break;
|
|
||||||
case ACL_ENTRY_TYPE_AUDIT:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT;
|
|
||||||
break;
|
|
||||||
case ACL_ENTRY_TYPE_ALARM:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Invalid NFSv4 ACL entry type");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
|
||||||
* in the ae_perm bitmap.
|
|
||||||
*
|
|
||||||
* acl_get_flagset_np() fails with non-NFSv4 ACLs
|
|
||||||
*/
|
|
||||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get flagset from a NFSv4 "
|
|
||||||
"ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
r = acl_get_flag_np(acl_flagset,
|
|
||||||
acl_nfs4_flag_map[i].p_perm);
|
|
||||||
if (r == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to check flag in a NFSv4 "
|
|
||||||
"ACL flagset");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
} else if (r)
|
|
||||||
ae_perm |= acl_nfs4_flag_map[i].a_perm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get ACL permission set");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
perm_map_size = acl_nfs4_perm_map_size;
|
|
||||||
perm_map = acl_nfs4_perm_map;
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
perm_map_size = acl_posix_perm_map_size;
|
|
||||||
perm_map = acl_posix_perm_map;
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < perm_map_size; ++i) {
|
|
||||||
r = acl_get_perm_np(acl_permset, perm_map[i].p_perm);
|
|
||||||
if (r == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to check permission in an ACL "
|
|
||||||
"permission set");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
} else if (r)
|
|
||||||
ae_perm |= perm_map[i].a_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_add_entry(entry, entry_acl_type,
|
|
||||||
ae_perm, ae_tag,
|
|
||||||
ae_id, ae_name);
|
|
||||||
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
if (s == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get next ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
set_acl(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl,
|
|
||||||
int ae_requested_type, const char *tname)
|
|
||||||
{
|
|
||||||
int acl_type = 0;
|
|
||||||
acl_t acl;
|
|
||||||
acl_entry_t acl_entry;
|
|
||||||
acl_permset_t acl_permset;
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
acl_flagset_t acl_flagset;
|
|
||||||
int r;
|
|
||||||
#endif
|
|
||||||
int ret;
|
|
||||||
int ae_type, ae_permset, ae_tag, ae_id;
|
|
||||||
int perm_map_size;
|
|
||||||
const acl_perm_map_t *perm_map;
|
|
||||||
uid_t ae_uid;
|
|
||||||
gid_t ae_gid;
|
|
||||||
const char *ae_name;
|
|
||||||
int entries;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
entries = archive_acl_reset(abstract_acl, ae_requested_type);
|
|
||||||
if (entries == 0)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
|
|
||||||
|
|
||||||
switch (ae_requested_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
|
||||||
acl_type = ACL_TYPE_ACCESS;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
|
||||||
acl_type = ACL_TYPE_DEFAULT;
|
|
||||||
break;
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
|
|
||||||
acl_type = ACL_TYPE_NFS4;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
errno = ENOENT;
|
|
||||||
archive_set_error(a, errno, "Unsupported ACL type");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
acl = acl_init(entries);
|
|
||||||
if (acl == (acl_t)NULL) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to initialize ACL working storage");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
|
||||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
|
||||||
if (acl_create_entry(&acl, &acl_entry) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to create a new ACL entry");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
switch (ae_tag) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER:
|
|
||||||
ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
|
|
||||||
acl_set_tag_type(acl_entry, ACL_USER);
|
|
||||||
acl_set_qualifier(acl_entry, &ae_uid);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP:
|
|
||||||
ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
|
|
||||||
acl_set_tag_type(acl_entry, ACL_GROUP);
|
|
||||||
acl_set_qualifier(acl_entry, &ae_gid);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER_OBJ:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_USER_OBJ);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_GROUP_OBJ);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_MASK:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_MASK);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_OTHER:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_OTHER);
|
|
||||||
break;
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
case ARCHIVE_ENTRY_ACL_EVERYONE:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_EVERYONE);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL tag");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
r = 0;
|
|
||||||
switch (ae_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
|
|
||||||
r = acl_set_entry_type_np(acl_entry,
|
|
||||||
ACL_ENTRY_TYPE_ALLOW);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DENY:
|
|
||||||
r = acl_set_entry_type_np(acl_entry,
|
|
||||||
ACL_ENTRY_TYPE_DENY);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
|
|
||||||
r = acl_set_entry_type_np(acl_entry,
|
|
||||||
ACL_ENTRY_TYPE_AUDIT);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
|
|
||||||
r = acl_set_entry_type_np(acl_entry,
|
|
||||||
ACL_ENTRY_TYPE_ALARM);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
|
||||||
// These don't translate directly into the system ACL.
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL entry type");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set ACL entry type");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to get ACL permission set");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
if (acl_clear_perms(acl_permset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to clear ACL permissions");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
perm_map_size = acl_nfs4_perm_map_size;
|
|
||||||
perm_map = acl_nfs4_perm_map;
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
perm_map_size = acl_posix_perm_map_size;
|
|
||||||
perm_map = acl_posix_perm_map;
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < perm_map_size; ++i) {
|
|
||||||
if (ae_permset & perm_map[i].a_perm) {
|
|
||||||
if (acl_add_perm(acl_permset,
|
|
||||||
perm_map[i].p_perm) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to add ACL permission");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
/*
|
|
||||||
* acl_get_flagset_np() fails with non-NFSv4 ACLs
|
|
||||||
*/
|
|
||||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to get flagset from an NFSv4 "
|
|
||||||
"ACL entry");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
if (acl_clear_flags_np(acl_flagset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to clear flags from an NFSv4 "
|
|
||||||
"ACL flagset");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
|
|
||||||
if (acl_add_flag_np(acl_flagset,
|
|
||||||
acl_nfs4_flag_map[i].p_perm) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to add flag to "
|
|
||||||
"NFSv4 ACL flagset");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try restoring the ACL through 'fd' if we can. */
|
|
||||||
if (fd >= 0) {
|
|
||||||
if (acl_set_fd_np(fd, acl, acl_type) == 0)
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
else {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set acl on fd: %s", tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if HAVE_ACL_SET_LINK_NP
|
|
||||||
else if (acl_set_link_np(name, acl_type, acl) != 0)
|
|
||||||
#else
|
|
||||||
/* FreeBSD older than 8.0 */
|
|
||||||
else if (acl_set_file(name, acl_type, acl) != 0)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno, "Failed to set acl: %s",
|
|
||||||
tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit_free:
|
|
||||||
acl_free(acl);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, int *fd)
|
|
||||||
{
|
|
||||||
const char *accpath;
|
|
||||||
acl_t acl;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
accpath = NULL;
|
|
||||||
|
|
||||||
if (*fd < 0) {
|
|
||||||
accpath = archive_read_disk_entry_setup_path(a, entry, fd);
|
|
||||||
if (accpath == NULL)
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_clear(entry);
|
|
||||||
|
|
||||||
acl = NULL;
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
/* Try NFSv4 ACL first. */
|
|
||||||
if (*fd >= 0)
|
|
||||||
acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
|
|
||||||
else if (!a->follow_symlinks)
|
|
||||||
acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
|
|
||||||
else
|
|
||||||
acl = acl_get_file(accpath, ACL_TYPE_NFS4);
|
|
||||||
|
|
||||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
|
||||||
if (acl != NULL && acl_is_trivial_np(acl, &r) == 0 && r == 1) {
|
|
||||||
acl_free(acl);
|
|
||||||
acl = NULL;
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acl != NULL) {
|
|
||||||
r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
|
||||||
acl_free(acl);
|
|
||||||
acl = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate NFSv4 ACLs");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Retrieve access ACL from file. */
|
|
||||||
if (*fd >= 0)
|
|
||||||
acl = acl_get_fd_np(*fd, ACL_TYPE_ACCESS);
|
|
||||||
#if HAVE_ACL_GET_LINK_NP
|
|
||||||
else if (!a->follow_symlinks)
|
|
||||||
acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
|
|
||||||
#else
|
|
||||||
else if ((!a->follow_symlinks)
|
|
||||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
|
||||||
/* We can't get the ACL of a symlink, so we assume it can't
|
|
||||||
have one. */
|
|
||||||
acl = NULL;
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
|
|
||||||
|
|
||||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
|
||||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
|
||||||
if (acl != NULL && acl_is_trivial_np(acl, &r) == 0 && r == 1) {
|
|
||||||
acl_free(acl);
|
|
||||||
acl = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (acl != NULL) {
|
|
||||||
r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
|
||||||
acl_free(acl);
|
|
||||||
acl = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate access ACLs");
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only directories can have default ACLs. */
|
|
||||||
if (S_ISDIR(archive_entry_mode(entry))) {
|
|
||||||
if (*fd >= 0)
|
|
||||||
acl = acl_get_fd_np(*fd, ACL_TYPE_DEFAULT);
|
|
||||||
else
|
|
||||||
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
|
|
||||||
if (acl != NULL) {
|
|
||||||
r = translate_acl(a, entry, acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
|
|
||||||
acl_free(acl);
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate default ACLs");
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl, __LA_MODE_T mode)
|
|
||||||
{
|
|
||||||
int ret = ARCHIVE_OK;
|
|
||||||
|
|
||||||
(void)mode; /* UNUSED */
|
|
||||||
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
|
|
||||||
if (ret != ARCHIVE_OK)
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
|
|
||||||
|
|
||||||
/* Simultaneous POSIX.1e and NFSv4 is not supported */
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4
|
|
||||||
else if ((archive_acl_types(abstract_acl) &
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_FREEBSD */
|
|
743
3rdparty/libarchive/c/archive_disk_acl_linux.c
vendored
743
3rdparty/libarchive/c/archive_disk_acl_linux.c
vendored
@ -1,743 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2009 Tim Kientzle
|
|
||||||
* Copyright (c) 2010-2012 Michihiro NAKAJIMA
|
|
||||||
* Copyright (c) 2017 Martin Matuska
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBACL || ARCHIVE_ACL_LIBRICHACL
|
|
||||||
|
|
||||||
#ifdef HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_FCNTL_H
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_ACL_LIBACL_H
|
|
||||||
#include <acl/libacl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_ACL_H
|
|
||||||
#include <sys/acl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_RICHACL_H
|
|
||||||
#include <sys/richacl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_read_disk_private.h"
|
|
||||||
#include "archive_write_disk_private.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const int a_perm; /* Libarchive permission or flag */
|
|
||||||
const int p_perm; /* Platform permission or flag */
|
|
||||||
} acl_perm_map_t;
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
static const acl_perm_map_t acl_posix_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_posix_perm_map_size =
|
|
||||||
(int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
|
|
||||||
#endif /* ARCHIVE_ACL_LIBACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
static const acl_perm_map_t acl_nfs4_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, RICHACE_EXECUTE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_DATA, RICHACE_READ_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, RICHACE_LIST_DIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_DATA, RICHACE_WRITE_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_FILE, RICHACE_ADD_FILE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_APPEND_DATA, RICHACE_APPEND_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, RICHACE_ADD_SUBDIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, RICHACE_READ_NAMED_ATTRS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, RICHACE_WRITE_NAMED_ATTRS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE_CHILD, RICHACE_DELETE_CHILD},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, RICHACE_READ_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, RICHACE_WRITE_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE, RICHACE_DELETE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ACL, RICHACE_READ_ACL},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ACL, RICHACE_WRITE_ACL},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, RICHACE_WRITE_OWNER},
|
|
||||||
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, RICHACE_SYNCHRONIZE}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_perm_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_nfs4_flag_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, RICHACE_FILE_INHERIT_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, RICHACE_DIRECTORY_INHERIT_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, RICHACE_NO_PROPAGATE_INHERIT_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, RICHACE_INHERIT_ONLY_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, RICHACE_INHERITED_ACE}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_flag_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
|
|
||||||
#endif /* ARCHIVE_ACL_LIBRICHACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
/*
|
|
||||||
* Translate POSIX.1e ACLs into libarchive internal structure
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
translate_acl(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
|
|
||||||
{
|
|
||||||
acl_tag_t acl_tag;
|
|
||||||
acl_entry_t acl_entry;
|
|
||||||
acl_permset_t acl_permset;
|
|
||||||
int i, entry_acl_type;
|
|
||||||
int r, s, ae_id, ae_tag, ae_perm;
|
|
||||||
void *q;
|
|
||||||
const char *ae_name;
|
|
||||||
|
|
||||||
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
|
|
||||||
if (s == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get first ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (s == 1) {
|
|
||||||
ae_id = -1;
|
|
||||||
ae_name = NULL;
|
|
||||||
ae_perm = 0;
|
|
||||||
|
|
||||||
if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get ACL tag type");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
switch (acl_tag) {
|
|
||||||
case ACL_USER:
|
|
||||||
q = acl_get_qualifier(acl_entry);
|
|
||||||
if (q != NULL) {
|
|
||||||
ae_id = (int)*(uid_t *)q;
|
|
||||||
acl_free(q);
|
|
||||||
ae_name = archive_read_disk_uname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
}
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER;
|
|
||||||
break;
|
|
||||||
case ACL_GROUP:
|
|
||||||
q = acl_get_qualifier(acl_entry);
|
|
||||||
if (q != NULL) {
|
|
||||||
ae_id = (int)*(gid_t *)q;
|
|
||||||
acl_free(q);
|
|
||||||
ae_name = archive_read_disk_gname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
}
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
|
|
||||||
break;
|
|
||||||
case ACL_MASK:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_MASK;
|
|
||||||
break;
|
|
||||||
case ACL_USER_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
|
|
||||||
break;
|
|
||||||
case ACL_GROUP_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
|
|
||||||
break;
|
|
||||||
case ACL_OTHER:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Skip types that libarchive can't support. */
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX acl_type maps to allow/deny/audit/YYYY bits
|
|
||||||
entry_acl_type = default_entry_acl_type;
|
|
||||||
|
|
||||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get ACL permission set");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_posix_perm_map_size; ++i) {
|
|
||||||
r = acl_get_perm(acl_permset,
|
|
||||||
acl_posix_perm_map[i].p_perm);
|
|
||||||
if (r == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to check permission in an ACL "
|
|
||||||
"permission set");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
} else if (r)
|
|
||||||
ae_perm |= acl_posix_perm_map[i].a_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_add_entry(entry, entry_acl_type,
|
|
||||||
ae_perm, ae_tag,
|
|
||||||
ae_id, ae_name);
|
|
||||||
|
|
||||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
|
||||||
if (s == -1) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Failed to get next ACL entry");
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
/*
|
|
||||||
* Translate RichACL into libarchive internal ACL
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
translate_richacl(struct archive_read_disk *a, struct archive_entry *entry,
|
|
||||||
struct richacl *richacl)
|
|
||||||
{
|
|
||||||
int ae_id, ae_tag, ae_perm;
|
|
||||||
int entry_acl_type, i;
|
|
||||||
const char *ae_name;
|
|
||||||
|
|
||||||
struct richace *richace;
|
|
||||||
|
|
||||||
richacl_for_each_entry(richace, richacl) {
|
|
||||||
ae_name = NULL;
|
|
||||||
ae_tag = 0;
|
|
||||||
ae_perm = 0;
|
|
||||||
ae_id = -1;
|
|
||||||
|
|
||||||
switch (richace->e_type) {
|
|
||||||
case RICHACE_ACCESS_ALLOWED_ACE_TYPE:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
|
|
||||||
break;
|
|
||||||
case RICHACE_ACCESS_DENIED_ACE_TYPE:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
|
|
||||||
break;
|
|
||||||
default: /* Unknown entry type, skip */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unsupported */
|
|
||||||
if (richace->e_flags & RICHACE_UNMAPPED_WHO)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (richace->e_flags & RICHACE_SPECIAL_WHO) {
|
|
||||||
switch (richace->e_id) {
|
|
||||||
case RICHACE_OWNER_SPECIAL_ID:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
|
|
||||||
break;
|
|
||||||
case RICHACE_GROUP_SPECIAL_ID:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
|
|
||||||
break;
|
|
||||||
case RICHACE_EVERYONE_SPECIAL_ID:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
|
|
||||||
break;
|
|
||||||
default: /* Unknown special ID type */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ae_id = richace->e_id;
|
|
||||||
if (richace->e_flags & RICHACE_IDENTIFIER_GROUP) {
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
|
|
||||||
ae_name = archive_read_disk_gname(&a->archive,
|
|
||||||
(gid_t)(richace->e_id));
|
|
||||||
} else {
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER;
|
|
||||||
ae_name = archive_read_disk_uname(&a->archive,
|
|
||||||
(uid_t)(richace->e_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
if ((richace->e_flags &
|
|
||||||
acl_nfs4_flag_map[i].p_perm) != 0)
|
|
||||||
ae_perm |= acl_nfs4_flag_map[i].a_perm;
|
|
||||||
}
|
|
||||||
for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
|
|
||||||
if ((richace->e_mask &
|
|
||||||
acl_nfs4_perm_map[i].p_perm) != 0)
|
|
||||||
ae_perm |=
|
|
||||||
acl_nfs4_perm_map[i].a_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_add_entry(entry, entry_acl_type,
|
|
||||||
ae_perm, ae_tag, ae_id, ae_name);
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBRICHACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
static int
|
|
||||||
_richacl_mode_to_mask(short mode)
|
|
||||||
{
|
|
||||||
int mask = 0;
|
|
||||||
|
|
||||||
if (mode & S_IROTH)
|
|
||||||
mask |= RICHACE_POSIX_MODE_READ;
|
|
||||||
if (mode & S_IWOTH)
|
|
||||||
mask |= RICHACE_POSIX_MODE_WRITE;
|
|
||||||
if (mode & S_IXOTH)
|
|
||||||
mask |= RICHACE_POSIX_MODE_EXEC;
|
|
||||||
|
|
||||||
return (mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_richacl_mode_to_masks(struct richacl *richacl, __LA_MODE_T mode)
|
|
||||||
{
|
|
||||||
richacl->a_owner_mask = _richacl_mode_to_mask((mode & 0700) >> 6);
|
|
||||||
richacl->a_group_mask = _richacl_mode_to_mask((mode & 0070) >> 3);
|
|
||||||
richacl->a_other_mask = _richacl_mode_to_mask(mode & 0007);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBRICHACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
static int
|
|
||||||
set_richacl(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl, __LA_MODE_T mode,
|
|
||||||
int ae_requested_type, const char *tname)
|
|
||||||
{
|
|
||||||
int ae_type, ae_permset, ae_tag, ae_id;
|
|
||||||
uid_t ae_uid;
|
|
||||||
gid_t ae_gid;
|
|
||||||
const char *ae_name;
|
|
||||||
int entries;
|
|
||||||
int i;
|
|
||||||
int ret;
|
|
||||||
int e = 0;
|
|
||||||
struct richacl *richacl = NULL;
|
|
||||||
struct richace *richace;
|
|
||||||
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
entries = archive_acl_reset(abstract_acl, ae_requested_type);
|
|
||||||
if (entries == 0)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
|
|
||||||
if (ae_requested_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
errno = ENOENT;
|
|
||||||
archive_set_error(a, errno, "Unsupported ACL type");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
richacl = richacl_alloc(entries);
|
|
||||||
if (richacl == NULL) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to initialize RichACL working storage");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
e = 0;
|
|
||||||
|
|
||||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
|
||||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
|
||||||
richace = &(richacl->a_entries[e]);
|
|
||||||
|
|
||||||
richace->e_flags = 0;
|
|
||||||
richace->e_mask = 0;
|
|
||||||
|
|
||||||
switch (ae_tag) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER:
|
|
||||||
ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
|
|
||||||
richace->e_id = ae_uid;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP:
|
|
||||||
ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
|
|
||||||
richace->e_id = ae_gid;
|
|
||||||
richace->e_flags |= RICHACE_IDENTIFIER_GROUP;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER_OBJ:
|
|
||||||
richace->e_flags |= RICHACE_SPECIAL_WHO;
|
|
||||||
richace->e_id = RICHACE_OWNER_SPECIAL_ID;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
|
|
||||||
richace->e_flags |= RICHACE_SPECIAL_WHO;
|
|
||||||
richace->e_id = RICHACE_GROUP_SPECIAL_ID;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_EVERYONE:
|
|
||||||
richace->e_flags |= RICHACE_SPECIAL_WHO;
|
|
||||||
richace->e_id = RICHACE_EVERYONE_SPECIAL_ID;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL tag");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ae_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
|
|
||||||
richace->e_type =
|
|
||||||
RICHACE_ACCESS_ALLOWED_ACE_TYPE;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DENY:
|
|
||||||
richace->e_type =
|
|
||||||
RICHACE_ACCESS_DENIED_ACE_TYPE;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL entry type");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
|
|
||||||
if (ae_permset & acl_nfs4_perm_map[i].a_perm)
|
|
||||||
richace->e_mask |= acl_nfs4_perm_map[i].p_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
if (ae_permset &
|
|
||||||
acl_nfs4_flag_map[i].a_perm)
|
|
||||||
richace->e_flags |= acl_nfs4_flag_map[i].p_perm;
|
|
||||||
}
|
|
||||||
e++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fill RichACL masks */
|
|
||||||
_richacl_mode_to_masks(richacl, mode);
|
|
||||||
|
|
||||||
if (fd >= 0) {
|
|
||||||
if (richacl_set_fd(fd, richacl) == 0)
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
else {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set richacl on fd: %s", tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (richacl_set_file(name, richacl) != 0) {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno, "Failed to set richacl: %s",
|
|
||||||
tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit_free:
|
|
||||||
richacl_free(richacl);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_RICHACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
static int
|
|
||||||
set_acl(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl,
|
|
||||||
int ae_requested_type, const char *tname)
|
|
||||||
{
|
|
||||||
int acl_type = 0;
|
|
||||||
int ae_type, ae_permset, ae_tag, ae_id;
|
|
||||||
uid_t ae_uid;
|
|
||||||
gid_t ae_gid;
|
|
||||||
const char *ae_name;
|
|
||||||
int entries;
|
|
||||||
int i;
|
|
||||||
int ret;
|
|
||||||
acl_t acl = NULL;
|
|
||||||
acl_entry_t acl_entry;
|
|
||||||
acl_permset_t acl_permset;
|
|
||||||
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
entries = archive_acl_reset(abstract_acl, ae_requested_type);
|
|
||||||
if (entries == 0)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
|
|
||||||
switch (ae_requested_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
|
||||||
acl_type = ACL_TYPE_ACCESS;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
|
||||||
acl_type = ACL_TYPE_DEFAULT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errno = ENOENT;
|
|
||||||
archive_set_error(a, errno, "Unsupported ACL type");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
acl = acl_init(entries);
|
|
||||||
if (acl == (acl_t)NULL) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to initialize ACL working storage");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
|
||||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
|
||||||
|
|
||||||
if (acl_create_entry(&acl, &acl_entry) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to create a new ACL entry");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ae_tag) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER:
|
|
||||||
ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
|
|
||||||
acl_set_tag_type(acl_entry, ACL_USER);
|
|
||||||
acl_set_qualifier(acl_entry, &ae_uid);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP:
|
|
||||||
ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
|
|
||||||
acl_set_tag_type(acl_entry, ACL_GROUP);
|
|
||||||
acl_set_qualifier(acl_entry, &ae_gid);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER_OBJ:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_USER_OBJ);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_GROUP_OBJ);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_MASK:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_MASK);
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_OTHER:
|
|
||||||
acl_set_tag_type(acl_entry, ACL_OTHER);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL tag");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to get ACL permission set");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
if (acl_clear_perms(acl_permset) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to clear ACL permissions");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_posix_perm_map_size; ++i) {
|
|
||||||
if (ae_permset & acl_posix_perm_map[i].a_perm) {
|
|
||||||
if (acl_add_perm(acl_permset,
|
|
||||||
acl_posix_perm_map[i].p_perm) != 0) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to add ACL permission");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fd >= 0 && ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
|
|
||||||
if (acl_set_fd(fd, acl) == 0)
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
else {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set acl on fd: %s", tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (acl_set_file(name, acl_type, acl) != 0) {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno, "Failed to set acl: %s",
|
|
||||||
tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit_free:
|
|
||||||
acl_free(acl);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBACL */
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, int *fd)
|
|
||||||
{
|
|
||||||
const char *accpath;
|
|
||||||
int r;
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
acl_t acl;
|
|
||||||
#endif
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
struct richacl *richacl;
|
|
||||||
mode_t mode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
accpath = NULL;
|
|
||||||
r = ARCHIVE_OK;
|
|
||||||
|
|
||||||
/* For default ACLs we need reachable accpath */
|
|
||||||
if (*fd < 0 || S_ISDIR(archive_entry_mode(entry))) {
|
|
||||||
accpath = archive_read_disk_entry_setup_path(a, entry, fd);
|
|
||||||
if (accpath == NULL)
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_clear(entry);
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
acl = NULL;
|
|
||||||
#endif
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
richacl = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
/* Try NFSv4 ACL first. */
|
|
||||||
if (*fd >= 0)
|
|
||||||
richacl = richacl_get_fd(*fd);
|
|
||||||
else if ((!a->follow_symlinks)
|
|
||||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
|
||||||
/* We can't get the ACL of a symlink, so we assume it can't
|
|
||||||
have one */
|
|
||||||
richacl = NULL;
|
|
||||||
else
|
|
||||||
richacl = richacl_get_file(accpath);
|
|
||||||
|
|
||||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
|
||||||
if (richacl != NULL) {
|
|
||||||
mode = archive_entry_mode(entry);
|
|
||||||
if (richacl_equiv_mode(richacl, &mode) == 0) {
|
|
||||||
richacl_free(richacl);
|
|
||||||
richacl = NULL;
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (richacl != NULL) {
|
|
||||||
r = translate_richacl(a, entry, richacl);
|
|
||||||
richacl_free(richacl);
|
|
||||||
richacl = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate NFSv4 ACLs");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBRICHACL */
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
/* Retrieve access ACL from file. */
|
|
||||||
if (*fd >= 0)
|
|
||||||
acl = acl_get_fd(*fd);
|
|
||||||
else if ((!a->follow_symlinks)
|
|
||||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
|
||||||
/* We can't get the ACL of a symlink, so we assume it can't
|
|
||||||
have one. */
|
|
||||||
acl = NULL;
|
|
||||||
else
|
|
||||||
acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
|
|
||||||
|
|
||||||
if (acl != NULL) {
|
|
||||||
r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
|
||||||
acl_free(acl);
|
|
||||||
acl = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate access ACLs");
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only directories can have default ACLs. */
|
|
||||||
if (S_ISDIR(archive_entry_mode(entry))) {
|
|
||||||
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
|
|
||||||
if (acl != NULL) {
|
|
||||||
r = translate_acl(a, entry, acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
|
|
||||||
acl_free(acl);
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate default ACLs");
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBACL */
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl, __LA_MODE_T mode)
|
|
||||||
{
|
|
||||||
int ret = ARCHIVE_OK;
|
|
||||||
|
|
||||||
#if !ARCHIVE_ACL_LIBRICHACL
|
|
||||||
(void)mode; /* UNUSED */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_LIBRICHACL
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
|
|
||||||
ret = set_richacl(a, fd, name, abstract_acl, mode,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
#endif /* ARCHIVE_ACL_LIBRICHACL */
|
|
||||||
#if ARCHIVE_ACL_LIBACL
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
|
|
||||||
if (ret != ARCHIVE_OK)
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBACL */
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_LIBACL || ARCHIVE_ACL_LIBRICHACL */
|
|
819
3rdparty/libarchive/c/archive_disk_acl_sunos.c
vendored
819
3rdparty/libarchive/c/archive_disk_acl_sunos.c
vendored
@ -1,819 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2017 Martin Matuska
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS
|
|
||||||
|
|
||||||
#ifdef HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_FCNTL_H
|
|
||||||
#include <fcntl.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_ACL_H
|
|
||||||
#define _ACL_PRIVATE /* For debugging */
|
|
||||||
#include <sys/acl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_read_disk_private.h"
|
|
||||||
#include "archive_write_disk_private.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const int a_perm; /* Libarchive permission or flag */
|
|
||||||
const int p_perm; /* Platform permission or flag */
|
|
||||||
} acl_perm_map_t;
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_posix_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, S_IXOTH },
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE, S_IWOTH },
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ, S_IROTH }
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_posix_perm_map_size =
|
|
||||||
(int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
static const acl_perm_map_t acl_nfs4_perm_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES},
|
|
||||||
{ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL},
|
|
||||||
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER},
|
|
||||||
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int acl_nfs4_perm_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
|
|
||||||
|
|
||||||
static const acl_perm_map_t acl_nfs4_flag_map[] = {
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG},
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG},
|
|
||||||
#ifdef ACE_INHERITED_ACE
|
|
||||||
{ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
const int acl_nfs4_flag_map_size =
|
|
||||||
(int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
|
|
||||||
|
|
||||||
#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
|
|
||||||
|
|
||||||
static void *
|
|
||||||
sunacl_get(int cmd, int *aclcnt, int fd, const char *path)
|
|
||||||
{
|
|
||||||
int cnt, cntcmd;
|
|
||||||
size_t size;
|
|
||||||
void *aclp;
|
|
||||||
|
|
||||||
if (cmd == GETACL) {
|
|
||||||
cntcmd = GETACLCNT;
|
|
||||||
size = sizeof(aclent_t);
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else if (cmd == ACE_GETACL) {
|
|
||||||
cntcmd = ACE_GETACLCNT;
|
|
||||||
size = sizeof(ace_t);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else {
|
|
||||||
errno = EINVAL;
|
|
||||||
*aclcnt = -1;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
aclp = NULL;
|
|
||||||
cnt = -2;
|
|
||||||
|
|
||||||
while (cnt == -2 || (cnt == -1 && errno == ENOSPC)) {
|
|
||||||
if (path != NULL)
|
|
||||||
cnt = acl(path, cntcmd, 0, NULL);
|
|
||||||
else
|
|
||||||
cnt = facl(fd, cntcmd, 0, NULL);
|
|
||||||
|
|
||||||
if (cnt > 0) {
|
|
||||||
if (aclp == NULL)
|
|
||||||
aclp = malloc(cnt * size);
|
|
||||||
else
|
|
||||||
aclp = realloc(NULL, cnt * size);
|
|
||||||
if (aclp != NULL) {
|
|
||||||
if (path != NULL)
|
|
||||||
cnt = acl(path, cmd, cnt, aclp);
|
|
||||||
else
|
|
||||||
cnt = facl(fd, cmd, cnt, aclp);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
free(aclp);
|
|
||||||
aclp = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*aclcnt = cnt;
|
|
||||||
return (aclp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if acl is trivial
|
|
||||||
* This is a FreeBSD acl_is_trivial_np() implementation for Solaris
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
sun_acl_is_trivial(void *aclp, int aclcnt, mode_t mode, int is_nfs4,
|
|
||||||
int is_dir, int *trivialp)
|
|
||||||
{
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
int i, p;
|
|
||||||
const uint32_t rperm = ACE_READ_DATA;
|
|
||||||
const uint32_t wperm = ACE_WRITE_DATA | ACE_APPEND_DATA;
|
|
||||||
const uint32_t eperm = ACE_EXECUTE;
|
|
||||||
const uint32_t pubset = ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS |
|
|
||||||
ACE_READ_ACL | ACE_SYNCHRONIZE;
|
|
||||||
const uint32_t ownset = pubset | ACE_WRITE_ATTRIBUTES |
|
|
||||||
ACE_WRITE_NAMED_ATTRS | ACE_WRITE_ACL | ACE_WRITE_OWNER;
|
|
||||||
|
|
||||||
ace_t *ace;
|
|
||||||
ace_t tace[6];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (aclp == NULL || trivialp == NULL)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
*trivialp = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* POSIX.1e ACLs marked with ACL_IS_TRIVIAL are compatible with
|
|
||||||
* FreeBSD acl_is_trivial_np(). On Solaris they have 4 entries,
|
|
||||||
* including mask.
|
|
||||||
*/
|
|
||||||
if (!is_nfs4) {
|
|
||||||
if (aclcnt == 4)
|
|
||||||
*trivialp = 1;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
/*
|
|
||||||
* Continue with checking NFSv4 ACLs
|
|
||||||
*
|
|
||||||
* Create list of trivial ace's to be compared
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* owner@ allow pre */
|
|
||||||
tace[0].a_flags = ACE_OWNER;
|
|
||||||
tace[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
|
|
||||||
tace[0].a_access_mask = 0;
|
|
||||||
|
|
||||||
/* owner@ deny */
|
|
||||||
tace[1].a_flags = ACE_OWNER;
|
|
||||||
tace[1].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
|
|
||||||
tace[1].a_access_mask = 0;
|
|
||||||
|
|
||||||
/* group@ deny */
|
|
||||||
tace[2].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
|
|
||||||
tace[2].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
|
|
||||||
tace[2].a_access_mask = 0;
|
|
||||||
|
|
||||||
/* owner@ allow */
|
|
||||||
tace[3].a_flags = ACE_OWNER;
|
|
||||||
tace[3].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
|
|
||||||
tace[3].a_access_mask = ownset;
|
|
||||||
|
|
||||||
/* group@ allow */
|
|
||||||
tace[4].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
|
|
||||||
tace[4].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
|
|
||||||
tace[4].a_access_mask = pubset;
|
|
||||||
|
|
||||||
/* everyone@ allow */
|
|
||||||
tace[5].a_flags = ACE_EVERYONE;
|
|
||||||
tace[5].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
|
|
||||||
tace[5].a_access_mask = pubset;
|
|
||||||
|
|
||||||
/* Permissions for everyone@ */
|
|
||||||
if (mode & 0004)
|
|
||||||
tace[5].a_access_mask |= rperm;
|
|
||||||
if (mode & 0002)
|
|
||||||
tace[5].a_access_mask |= wperm;
|
|
||||||
if (mode & 0001)
|
|
||||||
tace[5].a_access_mask |= eperm;
|
|
||||||
|
|
||||||
/* Permissions for group@ */
|
|
||||||
if (mode & 0040)
|
|
||||||
tace[4].a_access_mask |= rperm;
|
|
||||||
else if (mode & 0004)
|
|
||||||
tace[2].a_access_mask |= rperm;
|
|
||||||
if (mode & 0020)
|
|
||||||
tace[4].a_access_mask |= wperm;
|
|
||||||
else if (mode & 0002)
|
|
||||||
tace[2].a_access_mask |= wperm;
|
|
||||||
if (mode & 0010)
|
|
||||||
tace[4].a_access_mask |= eperm;
|
|
||||||
else if (mode & 0001)
|
|
||||||
tace[2].a_access_mask |= eperm;
|
|
||||||
|
|
||||||
/* Permissions for owner@ */
|
|
||||||
if (mode & 0400) {
|
|
||||||
tace[3].a_access_mask |= rperm;
|
|
||||||
if (!(mode & 0040) && (mode & 0004))
|
|
||||||
tace[0].a_access_mask |= rperm;
|
|
||||||
} else if ((mode & 0040) || (mode & 0004))
|
|
||||||
tace[1].a_access_mask |= rperm;
|
|
||||||
if (mode & 0200) {
|
|
||||||
tace[3].a_access_mask |= wperm;
|
|
||||||
if (!(mode & 0020) && (mode & 0002))
|
|
||||||
tace[0].a_access_mask |= wperm;
|
|
||||||
} else if ((mode & 0020) || (mode & 0002))
|
|
||||||
tace[1].a_access_mask |= wperm;
|
|
||||||
if (mode & 0100) {
|
|
||||||
tace[3].a_access_mask |= eperm;
|
|
||||||
if (!(mode & 0010) && (mode & 0001))
|
|
||||||
tace[0].a_access_mask |= eperm;
|
|
||||||
} else if ((mode & 0010) || (mode & 0001))
|
|
||||||
tace[1].a_access_mask |= eperm;
|
|
||||||
|
|
||||||
/* Check if the acl count matches */
|
|
||||||
p = 3;
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
if (tace[i].a_access_mask != 0)
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
if (aclcnt != p)
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
p = 0;
|
|
||||||
for (i = 0; i < 6; i++) {
|
|
||||||
if (tace[i].a_access_mask != 0) {
|
|
||||||
ace = &((ace_t *)aclp)[p];
|
|
||||||
/*
|
|
||||||
* Illumos added ACE_DELETE_CHILD to write perms for
|
|
||||||
* directories. We have to check against that, too.
|
|
||||||
*/
|
|
||||||
if (ace->a_flags != tace[i].a_flags ||
|
|
||||||
ace->a_type != tace[i].a_type ||
|
|
||||||
(ace->a_access_mask != tace[i].a_access_mask &&
|
|
||||||
(!is_dir || (tace[i].a_access_mask & wperm) == 0 ||
|
|
||||||
ace->a_access_mask !=
|
|
||||||
(tace[i].a_access_mask | ACE_DELETE_CHILD))))
|
|
||||||
return (0);
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*trivialp = 1;
|
|
||||||
#else /* !ARCHIVE_ACL_SUNOS_NFS4 */
|
|
||||||
(void)is_dir; /* UNUSED */
|
|
||||||
(void)aclp; /* UNUSED */
|
|
||||||
#endif /* !ARCHIVE_ACL_SUNOS_NFS4 */
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Translate Solaris POSIX.1e and NFSv4 ACLs into libarchive internal ACL
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
translate_acl(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, void *aclp, int aclcnt,
|
|
||||||
int default_entry_acl_type)
|
|
||||||
{
|
|
||||||
int e, i;
|
|
||||||
int ae_id, ae_tag, ae_perm;
|
|
||||||
int entry_acl_type;
|
|
||||||
const char *ae_name;
|
|
||||||
aclent_t *aclent;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
ace_t *ace;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (aclcnt <= 0)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
|
|
||||||
for (e = 0; e < aclcnt; e++) {
|
|
||||||
ae_name = NULL;
|
|
||||||
ae_tag = 0;
|
|
||||||
ae_perm = 0;
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
if (default_entry_acl_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
ace = &((ace_t *)aclp)[e];
|
|
||||||
ae_id = ace->a_who;
|
|
||||||
|
|
||||||
switch(ace->a_type) {
|
|
||||||
case ACE_ACCESS_ALLOWED_ACE_TYPE:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
|
|
||||||
break;
|
|
||||||
case ACE_ACCESS_DENIED_ACE_TYPE:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
|
|
||||||
break;
|
|
||||||
case ACE_SYSTEM_AUDIT_ACE_TYPE:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
|
|
||||||
break;
|
|
||||||
case ACE_SYSTEM_ALARM_ACE_TYPE:
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Unknown entry type, skip */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ace->a_flags & ACE_OWNER) != 0)
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
|
|
||||||
else if ((ace->a_flags & ACE_GROUP) != 0)
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
|
|
||||||
else if ((ace->a_flags & ACE_EVERYONE) != 0)
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
|
|
||||||
else if ((ace->a_flags & ACE_IDENTIFIER_GROUP) != 0) {
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
|
|
||||||
ae_name = archive_read_disk_gname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
} else {
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER;
|
|
||||||
ae_name = archive_read_disk_uname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
if ((ace->a_flags &
|
|
||||||
acl_nfs4_flag_map[i].p_perm) != 0)
|
|
||||||
ae_perm |= acl_nfs4_flag_map[i].a_perm;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
|
|
||||||
if ((ace->a_access_mask &
|
|
||||||
acl_nfs4_perm_map[i].p_perm) != 0)
|
|
||||||
ae_perm |= acl_nfs4_perm_map[i].a_perm;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
|
|
||||||
if (default_entry_acl_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
|
|
||||||
aclent = &((aclent_t *)aclp)[e];
|
|
||||||
if ((aclent->a_type & ACL_DEFAULT) != 0)
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
|
|
||||||
else
|
|
||||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
|
|
||||||
ae_id = aclent->a_id;
|
|
||||||
|
|
||||||
switch(aclent->a_type) {
|
|
||||||
case DEF_USER:
|
|
||||||
case USER:
|
|
||||||
ae_name = archive_read_disk_uname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER;
|
|
||||||
break;
|
|
||||||
case DEF_GROUP:
|
|
||||||
case GROUP:
|
|
||||||
ae_name = archive_read_disk_gname(&a->archive,
|
|
||||||
ae_id);
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
|
|
||||||
break;
|
|
||||||
case DEF_CLASS_OBJ:
|
|
||||||
case CLASS_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_MASK;
|
|
||||||
break;
|
|
||||||
case DEF_USER_OBJ:
|
|
||||||
case USER_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
|
|
||||||
break;
|
|
||||||
case DEF_GROUP_OBJ:
|
|
||||||
case GROUP_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
|
|
||||||
break;
|
|
||||||
case DEF_OTHER_OBJ:
|
|
||||||
case OTHER_OBJ:
|
|
||||||
ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Unknown tag type, skip */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < acl_posix_perm_map_size; ++i) {
|
|
||||||
if ((aclent->a_perm &
|
|
||||||
acl_posix_perm_map[i].p_perm) != 0)
|
|
||||||
ae_perm |= acl_posix_perm_map[i].a_perm;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
|
|
||||||
archive_entry_acl_add_entry(entry, entry_acl_type,
|
|
||||||
ae_perm, ae_tag, ae_id, ae_name);
|
|
||||||
}
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
set_acl(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl,
|
|
||||||
int ae_requested_type, const char *tname)
|
|
||||||
{
|
|
||||||
aclent_t *aclent;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
ace_t *ace;
|
|
||||||
#endif
|
|
||||||
int cmd, e, r;
|
|
||||||
void *aclp;
|
|
||||||
int ret;
|
|
||||||
int ae_type, ae_permset, ae_tag, ae_id;
|
|
||||||
int perm_map_size;
|
|
||||||
const acl_perm_map_t *perm_map;
|
|
||||||
uid_t ae_uid;
|
|
||||||
gid_t ae_gid;
|
|
||||||
const char *ae_name;
|
|
||||||
int entries;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
entries = archive_acl_reset(abstract_acl, ae_requested_type);
|
|
||||||
if (entries == 0)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
|
|
||||||
|
|
||||||
switch (ae_requested_type) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
|
|
||||||
cmd = SETACL;
|
|
||||||
aclp = malloc(entries * sizeof(aclent_t));
|
|
||||||
break;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
|
|
||||||
cmd = ACE_SETACL;
|
|
||||||
aclp = malloc(entries * sizeof(ace_t));
|
|
||||||
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
errno = ENOENT;
|
|
||||||
archive_set_error(a, errno, "Unsupported ACL type");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aclp == NULL) {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Can't allocate memory for acl buffer");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
e = 0;
|
|
||||||
|
|
||||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
|
||||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
|
||||||
aclent = NULL;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
ace = NULL;
|
|
||||||
#endif
|
|
||||||
if (cmd == SETACL) {
|
|
||||||
aclent = &((aclent_t *)aclp)[e];
|
|
||||||
aclent->a_id = -1;
|
|
||||||
aclent->a_type = 0;
|
|
||||||
aclent->a_perm = 0;
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else { /* cmd == ACE_SETACL */
|
|
||||||
ace = &((ace_t *)aclp)[e];
|
|
||||||
ace->a_who = -1;
|
|
||||||
ace->a_access_mask = 0;
|
|
||||||
ace->a_flags = 0;
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
|
|
||||||
|
|
||||||
switch (ae_tag) {
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER:
|
|
||||||
ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
|
|
||||||
if (aclent != NULL) {
|
|
||||||
aclent->a_id = ae_uid;
|
|
||||||
aclent->a_type |= USER;
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else {
|
|
||||||
ace->a_who = ae_uid;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP:
|
|
||||||
ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
|
|
||||||
if (aclent != NULL) {
|
|
||||||
aclent->a_id = ae_gid;
|
|
||||||
aclent->a_type |= GROUP;
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else {
|
|
||||||
ace->a_who = ae_gid;
|
|
||||||
ace->a_flags |= ACE_IDENTIFIER_GROUP;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_USER_OBJ:
|
|
||||||
if (aclent != NULL)
|
|
||||||
aclent->a_type |= USER_OBJ;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else {
|
|
||||||
ace->a_flags |= ACE_OWNER;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
|
|
||||||
if (aclent != NULL)
|
|
||||||
aclent->a_type |= GROUP_OBJ;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else {
|
|
||||||
ace->a_flags |= ACE_GROUP;
|
|
||||||
ace->a_flags |= ACE_IDENTIFIER_GROUP;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_MASK:
|
|
||||||
if (aclent != NULL)
|
|
||||||
aclent->a_type |= CLASS_OBJ;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_OTHER:
|
|
||||||
if (aclent != NULL)
|
|
||||||
aclent->a_type |= OTHER_OBJ;
|
|
||||||
break;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
case ARCHIVE_ENTRY_ACL_EVERYONE:
|
|
||||||
if (ace != NULL)
|
|
||||||
ace->a_flags |= ACE_EVERYONE;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL tag");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = 0;
|
|
||||||
switch (ae_type) {
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
|
|
||||||
if (ace != NULL)
|
|
||||||
ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
|
|
||||||
else
|
|
||||||
r = -1;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DENY:
|
|
||||||
if (ace != NULL)
|
|
||||||
ace->a_type = ACE_ACCESS_DENIED_ACE_TYPE;
|
|
||||||
else
|
|
||||||
r = -1;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
|
|
||||||
if (ace != NULL)
|
|
||||||
ace->a_type = ACE_SYSTEM_AUDIT_ACE_TYPE;
|
|
||||||
else
|
|
||||||
r = -1;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
|
|
||||||
if (ace != NULL)
|
|
||||||
ace->a_type = ACE_SYSTEM_ALARM_ACE_TYPE;
|
|
||||||
else
|
|
||||||
r = -1;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
|
||||||
if (aclent == NULL)
|
|
||||||
r = -1;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
|
||||||
if (aclent != NULL)
|
|
||||||
aclent->a_type |= ACL_DEFAULT;
|
|
||||||
else
|
|
||||||
r = -1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unsupported ACL entry type");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r != 0) {
|
|
||||||
errno = EINVAL;
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set ACL entry type");
|
|
||||||
ret = ARCHIVE_FAILED;
|
|
||||||
goto exit_free;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
perm_map_size = acl_nfs4_perm_map_size;
|
|
||||||
perm_map = acl_nfs4_perm_map;
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
perm_map_size = acl_posix_perm_map_size;
|
|
||||||
perm_map = acl_posix_perm_map;
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (i = 0; i < perm_map_size; ++i) {
|
|
||||||
if (ae_permset & perm_map[i].a_perm) {
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
if (ae_requested_type ==
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4)
|
|
||||||
ace->a_access_mask |=
|
|
||||||
perm_map[i].p_perm;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
aclent->a_perm |= perm_map[i].p_perm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
|
||||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
|
||||||
if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
|
|
||||||
ace->a_flags |=
|
|
||||||
acl_nfs4_flag_map[i].p_perm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
e++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Try restoring the ACL through 'fd' if we can. */
|
|
||||||
if (fd >= 0) {
|
|
||||||
if (facl(fd, cmd, entries, aclp) == 0)
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
else {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno,
|
|
||||||
"Failed to set acl on fd: %s", tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (acl(name, cmd, entries, aclp) != 0) {
|
|
||||||
if (errno == EOPNOTSUPP) {
|
|
||||||
/* Filesystem doesn't support ACLs */
|
|
||||||
ret = ARCHIVE_OK;
|
|
||||||
} else {
|
|
||||||
archive_set_error(a, errno, "Failed to set acl: %s",
|
|
||||||
tname);
|
|
||||||
ret = ARCHIVE_WARN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit_free:
|
|
||||||
free(aclp);
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
|
|
||||||
struct archive_entry *entry, int *fd)
|
|
||||||
{
|
|
||||||
const char *accpath;
|
|
||||||
void *aclp;
|
|
||||||
int aclcnt;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
accpath = NULL;
|
|
||||||
|
|
||||||
if (*fd < 0) {
|
|
||||||
accpath = archive_read_disk_entry_setup_path(a, entry, fd);
|
|
||||||
if (accpath == NULL)
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
|
|
||||||
archive_entry_acl_clear(entry);
|
|
||||||
|
|
||||||
aclp = NULL;
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
if (*fd >= 0)
|
|
||||||
aclp = sunacl_get(ACE_GETACL, &aclcnt, *fd, NULL);
|
|
||||||
else if ((!a->follow_symlinks)
|
|
||||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
|
||||||
/* We can't get the ACL of a symlink, so we assume it can't
|
|
||||||
have one. */
|
|
||||||
aclp = NULL;
|
|
||||||
else
|
|
||||||
aclp = sunacl_get(ACE_GETACL, &aclcnt, 0, accpath);
|
|
||||||
|
|
||||||
if (aclp != NULL && sun_acl_is_trivial(aclp, aclcnt,
|
|
||||||
archive_entry_mode(entry), 1, S_ISDIR(archive_entry_mode(entry)),
|
|
||||||
&r) == 0 && r == 1) {
|
|
||||||
free(aclp);
|
|
||||||
aclp = NULL;
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aclp != NULL) {
|
|
||||||
r = translate_acl(a, entry, aclp, aclcnt,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
|
||||||
free(aclp);
|
|
||||||
aclp = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate NFSv4 ACLs");
|
|
||||||
}
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
|
|
||||||
|
|
||||||
/* Retrieve POSIX.1e ACLs from file. */
|
|
||||||
if (*fd >= 0)
|
|
||||||
aclp = sunacl_get(GETACL, &aclcnt, *fd, NULL);
|
|
||||||
else if ((!a->follow_symlinks)
|
|
||||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
|
||||||
/* We can't get the ACL of a symlink, so we assume it can't
|
|
||||||
have one. */
|
|
||||||
aclp = NULL;
|
|
||||||
else
|
|
||||||
aclp = sunacl_get(GETACL, &aclcnt, 0, accpath);
|
|
||||||
|
|
||||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
|
||||||
if (aclp != NULL && sun_acl_is_trivial(aclp, aclcnt,
|
|
||||||
archive_entry_mode(entry), 0, S_ISDIR(archive_entry_mode(entry)),
|
|
||||||
&r) == 0 && r == 1) {
|
|
||||||
free(aclp);
|
|
||||||
aclp = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aclp != NULL)
|
|
||||||
{
|
|
||||||
r = translate_acl(a, entry, aclp, aclcnt,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
|
||||||
free(aclp);
|
|
||||||
aclp = NULL;
|
|
||||||
|
|
||||||
if (r != ARCHIVE_OK) {
|
|
||||||
archive_set_error(&a->archive, errno,
|
|
||||||
"Couldn't translate access ACLs");
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
|
|
||||||
struct archive_acl *abstract_acl, __LA_MODE_T mode)
|
|
||||||
{
|
|
||||||
int ret = ARCHIVE_OK;
|
|
||||||
|
|
||||||
(void)mode; /* UNUSED */
|
|
||||||
|
|
||||||
if ((archive_acl_types(abstract_acl)
|
|
||||||
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
|
|
||||||
/* Solaris writes POSIX.1e access and default ACLs together */
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, "posix1e");
|
|
||||||
|
|
||||||
/* Simultaneous POSIX.1e and NFSv4 is not supported */
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#if ARCHIVE_ACL_SUNOS_NFS4
|
|
||||||
else if ((archive_acl_types(abstract_acl) &
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
|
|
||||||
ret = set_acl(a, fd, name, abstract_acl,
|
|
||||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return (ret);
|
|
||||||
}
|
|
||||||
#endif /* ARCHIVE_ACL_SUNOS */
|
|
195
3rdparty/libarchive/c/archive_endian.h
vendored
195
3rdparty/libarchive/c/archive_endian.h
vendored
@ -1,195 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2002 Thomas Moestl <tmm@FreeBSD.org>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: head/lib/libarchive/archive_endian.h 201085 2009-12-28 02:17:15Z kientzle $
|
|
||||||
*
|
|
||||||
* Borrowed from FreeBSD's <sys/endian.h>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ENDIAN_H_INCLUDED
|
|
||||||
#define ARCHIVE_ENDIAN_H_INCLUDED
|
|
||||||
|
|
||||||
/* Note: This is a purely internal header! */
|
|
||||||
/* Do not use this outside of libarchive internal code! */
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Disabling inline keyword for compilers known to choke on it:
|
|
||||||
* - Watcom C++ in C code. (For any version?)
|
|
||||||
* - SGI MIPSpro
|
|
||||||
* - Microsoft Visual C++ 6.0 (supposedly newer versions too)
|
|
||||||
* - IBM VisualAge 6 (XL v6)
|
|
||||||
* - Sun WorkShop C (SunPro) before 5.9
|
|
||||||
*/
|
|
||||||
#if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__)
|
|
||||||
#define inline
|
|
||||||
#elif defined(__IBMC__) && __IBMC__ < 700
|
|
||||||
#define inline
|
|
||||||
#elif defined(__SUNPRO_C) && __SUNPRO_C < 0x590
|
|
||||||
#define inline
|
|
||||||
#elif defined(_MSC_VER) || defined(__osf__)
|
|
||||||
#define inline __inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
|
|
||||||
|
|
||||||
static inline uint16_t
|
|
||||||
archive_be16dec(const void *pp)
|
|
||||||
{
|
|
||||||
unsigned char const *p = (unsigned char const *)pp;
|
|
||||||
|
|
||||||
/* Store into unsigned temporaries before left shifting, to avoid
|
|
||||||
promotion to signed int and then left shifting into the sign bit,
|
|
||||||
which is undefined behaviour. */
|
|
||||||
unsigned int p1 = p[1];
|
|
||||||
unsigned int p0 = p[0];
|
|
||||||
|
|
||||||
return ((p0 << 8) | p1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
archive_be32dec(const void *pp)
|
|
||||||
{
|
|
||||||
unsigned char const *p = (unsigned char const *)pp;
|
|
||||||
|
|
||||||
/* Store into unsigned temporaries before left shifting, to avoid
|
|
||||||
promotion to signed int and then left shifting into the sign bit,
|
|
||||||
which is undefined behaviour. */
|
|
||||||
unsigned int p3 = p[3];
|
|
||||||
unsigned int p2 = p[2];
|
|
||||||
unsigned int p1 = p[1];
|
|
||||||
unsigned int p0 = p[0];
|
|
||||||
|
|
||||||
return ((p0 << 24) | (p1 << 16) | (p2 << 8) | p3);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
archive_be64dec(const void *pp)
|
|
||||||
{
|
|
||||||
unsigned char const *p = (unsigned char const *)pp;
|
|
||||||
|
|
||||||
return (((uint64_t)archive_be32dec(p) << 32) | archive_be32dec(p + 4));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint16_t
|
|
||||||
archive_le16dec(const void *pp)
|
|
||||||
{
|
|
||||||
unsigned char const *p = (unsigned char const *)pp;
|
|
||||||
|
|
||||||
/* Store into unsigned temporaries before left shifting, to avoid
|
|
||||||
promotion to signed int and then left shifting into the sign bit,
|
|
||||||
which is undefined behaviour. */
|
|
||||||
unsigned int p1 = p[1];
|
|
||||||
unsigned int p0 = p[0];
|
|
||||||
|
|
||||||
return ((p1 << 8) | p0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t
|
|
||||||
archive_le32dec(const void *pp)
|
|
||||||
{
|
|
||||||
unsigned char const *p = (unsigned char const *)pp;
|
|
||||||
|
|
||||||
/* Store into unsigned temporaries before left shifting, to avoid
|
|
||||||
promotion to signed int and then left shifting into the sign bit,
|
|
||||||
which is undefined behaviour. */
|
|
||||||
unsigned int p3 = p[3];
|
|
||||||
unsigned int p2 = p[2];
|
|
||||||
unsigned int p1 = p[1];
|
|
||||||
unsigned int p0 = p[0];
|
|
||||||
|
|
||||||
return ((p3 << 24) | (p2 << 16) | (p1 << 8) | p0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t
|
|
||||||
archive_le64dec(const void *pp)
|
|
||||||
{
|
|
||||||
unsigned char const *p = (unsigned char const *)pp;
|
|
||||||
|
|
||||||
return (((uint64_t)archive_le32dec(p + 4) << 32) | archive_le32dec(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
archive_be16enc(void *pp, uint16_t u)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *)pp;
|
|
||||||
|
|
||||||
p[0] = (u >> 8) & 0xff;
|
|
||||||
p[1] = u & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
archive_be32enc(void *pp, uint32_t u)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *)pp;
|
|
||||||
|
|
||||||
p[0] = (u >> 24) & 0xff;
|
|
||||||
p[1] = (u >> 16) & 0xff;
|
|
||||||
p[2] = (u >> 8) & 0xff;
|
|
||||||
p[3] = u & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
archive_be64enc(void *pp, uint64_t u)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *)pp;
|
|
||||||
|
|
||||||
archive_be32enc(p, (uint32_t)(u >> 32));
|
|
||||||
archive_be32enc(p + 4, (uint32_t)(u & 0xffffffff));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
archive_le16enc(void *pp, uint16_t u)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *)pp;
|
|
||||||
|
|
||||||
p[0] = u & 0xff;
|
|
||||||
p[1] = (u >> 8) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
archive_le32enc(void *pp, uint32_t u)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *)pp;
|
|
||||||
|
|
||||||
p[0] = u & 0xff;
|
|
||||||
p[1] = (u >> 8) & 0xff;
|
|
||||||
p[2] = (u >> 16) & 0xff;
|
|
||||||
p[3] = (u >> 24) & 0xff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
archive_le64enc(void *pp, uint64_t u)
|
|
||||||
{
|
|
||||||
unsigned char *p = (unsigned char *)pp;
|
|
||||||
|
|
||||||
archive_le32enc(p, (uint32_t)(u & 0xffffffff));
|
|
||||||
archive_le32enc(p + 4, (uint32_t)(u >> 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
2066
3rdparty/libarchive/c/archive_entry.c
vendored
2066
3rdparty/libarchive/c/archive_entry.c
vendored
File diff suppressed because it is too large
Load Diff
708
3rdparty/libarchive/c/archive_entry.h
vendored
708
3rdparty/libarchive/c/archive_entry.h
vendored
@ -1,708 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2008 Tim Kientzle
|
|
||||||
* Copyright (c) 2016 Martin Matuska
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: head/lib/libarchive/archive_entry.h 201096 2009-12-28 02:41:27Z kientzle $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ENTRY_H_INCLUDED
|
|
||||||
#define ARCHIVE_ENTRY_H_INCLUDED
|
|
||||||
|
|
||||||
/* Note: Compiler will complain if this does not match archive.h! */
|
|
||||||
#define ARCHIVE_VERSION_NUMBER 3004003
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note: archive_entry.h is for use outside of libarchive; the
|
|
||||||
* configuration headers (config.h, archive_platform.h, etc.) are
|
|
||||||
* purely internal. Do NOT use HAVE_XXX configuration macros to
|
|
||||||
* control the behavior of this header! If you must conditionalize,
|
|
||||||
* use predefined compiler and/or platform macros.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <stddef.h> /* for wchar_t */
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get a suitable 64-bit integer type. */
|
|
||||||
#if !defined(__LA_INT64_T_DEFINED)
|
|
||||||
# if ARCHIVE_VERSION_NUMBER < 4000000
|
|
||||||
#define __LA_INT64_T la_int64_t
|
|
||||||
# endif
|
|
||||||
#define __LA_INT64_T_DEFINED
|
|
||||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
|
||||||
typedef __int64 la_int64_t;
|
|
||||||
# else
|
|
||||||
#include <unistd.h>
|
|
||||||
# if defined(_SCO_DS) || defined(__osf__)
|
|
||||||
typedef long long la_int64_t;
|
|
||||||
# else
|
|
||||||
typedef int64_t la_int64_t;
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The la_ssize_t should match the type used in 'struct stat' */
|
|
||||||
#if !defined(__LA_SSIZE_T_DEFINED)
|
|
||||||
/* Older code relied on the __LA_SSIZE_T macro; after 4.0 we'll switch to the typedef exclusively. */
|
|
||||||
# if ARCHIVE_VERSION_NUMBER < 4000000
|
|
||||||
#define __LA_SSIZE_T la_ssize_t
|
|
||||||
# endif
|
|
||||||
#define __LA_SSIZE_T_DEFINED
|
|
||||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
|
||||||
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
|
|
||||||
typedef ssize_t la_ssize_t;
|
|
||||||
# elif defined(_WIN64)
|
|
||||||
typedef __int64 la_ssize_t;
|
|
||||||
# else
|
|
||||||
typedef long la_ssize_t;
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# include <unistd.h> /* ssize_t */
|
|
||||||
typedef ssize_t la_ssize_t;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get a suitable definition for mode_t */
|
|
||||||
#if ARCHIVE_VERSION_NUMBER >= 3999000
|
|
||||||
/* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */
|
|
||||||
# define __LA_MODE_T int
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
|
|
||||||
# define __LA_MODE_T unsigned short
|
|
||||||
#else
|
|
||||||
# define __LA_MODE_T mode_t
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Large file support for Android */
|
|
||||||
#ifdef __ANDROID__
|
|
||||||
#include "android_lf.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* On Windows, define LIBARCHIVE_STATIC if you're building or using a
|
|
||||||
* .lib. The default here assumes you're building a DLL. Only
|
|
||||||
* libarchive source should ever define __LIBARCHIVE_BUILD.
|
|
||||||
*/
|
|
||||||
#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
|
|
||||||
# ifdef __LIBARCHIVE_BUILD
|
|
||||||
# ifdef __GNUC__
|
|
||||||
# define __LA_DECL __attribute__((dllexport)) extern
|
|
||||||
# else
|
|
||||||
# define __LA_DECL __declspec(dllexport)
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
# ifdef __GNUC__
|
|
||||||
# define __LA_DECL
|
|
||||||
# else
|
|
||||||
# define __LA_DECL __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
/* Static libraries on all platforms and shared libraries on non-Windows. */
|
|
||||||
# define __LA_DECL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
|
|
||||||
# define __LA_DEPRECATED __attribute__((deprecated))
|
|
||||||
#else
|
|
||||||
# define __LA_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Description of an archive entry.
|
|
||||||
*
|
|
||||||
* You can think of this as "struct stat" with some text fields added in.
|
|
||||||
*
|
|
||||||
* TODO: Add "comment", "charset", and possibly other entries that are
|
|
||||||
* supported by "pax interchange" format. However, GNU, ustar, cpio,
|
|
||||||
* and other variants don't support these features, so they're not an
|
|
||||||
* excruciatingly high priority right now.
|
|
||||||
*
|
|
||||||
* TODO: "pax interchange" format allows essentially arbitrary
|
|
||||||
* key/value attributes to be attached to any entry. Supporting
|
|
||||||
* such extensions may make this library useful for special
|
|
||||||
* applications (e.g., a package manager could attach special
|
|
||||||
* package-management attributes to each entry).
|
|
||||||
*/
|
|
||||||
struct archive;
|
|
||||||
struct archive_entry;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* File-type constants. These are returned from archive_entry_filetype()
|
|
||||||
* and passed to archive_entry_set_filetype().
|
|
||||||
*
|
|
||||||
* These values match S_XXX defines on every platform I've checked,
|
|
||||||
* including Windows, AIX, Linux, Solaris, and BSD. They're
|
|
||||||
* (re)defined here because platforms generally don't define the ones
|
|
||||||
* they don't support. For example, Windows doesn't define S_IFLNK or
|
|
||||||
* S_IFBLK. Instead of having a mass of conditional logic and system
|
|
||||||
* checks to define any S_XXX values that aren't supported locally,
|
|
||||||
* I've just defined a new set of such constants so that
|
|
||||||
* libarchive-based applications can manipulate and identify archive
|
|
||||||
* entries properly even if the hosting platform can't store them on
|
|
||||||
* disk.
|
|
||||||
*
|
|
||||||
* These values are also used directly within some portable formats,
|
|
||||||
* such as cpio. If you find a platform that varies from these, the
|
|
||||||
* correct solution is to leave these alone and translate from these
|
|
||||||
* portable values to platform-native values when entries are read from
|
|
||||||
* or written to disk.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* In libarchive 4.0, we can drop the casts here.
|
|
||||||
* They're needed to work around Borland C's broken mode_t.
|
|
||||||
*/
|
|
||||||
#define AE_IFMT ((__LA_MODE_T)0170000)
|
|
||||||
#define AE_IFREG ((__LA_MODE_T)0100000)
|
|
||||||
#define AE_IFLNK ((__LA_MODE_T)0120000)
|
|
||||||
#define AE_IFSOCK ((__LA_MODE_T)0140000)
|
|
||||||
#define AE_IFCHR ((__LA_MODE_T)0020000)
|
|
||||||
#define AE_IFBLK ((__LA_MODE_T)0060000)
|
|
||||||
#define AE_IFDIR ((__LA_MODE_T)0040000)
|
|
||||||
#define AE_IFIFO ((__LA_MODE_T)0010000)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Symlink types
|
|
||||||
*/
|
|
||||||
#define AE_SYMLINK_TYPE_UNDEFINED 0
|
|
||||||
#define AE_SYMLINK_TYPE_FILE 1
|
|
||||||
#define AE_SYMLINK_TYPE_DIRECTORY 2
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Basic object manipulation
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL struct archive_entry *archive_entry_clear(struct archive_entry *);
|
|
||||||
/* The 'clone' function does a deep copy; all of the strings are copied too. */
|
|
||||||
__LA_DECL struct archive_entry *archive_entry_clone(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_free(struct archive_entry *);
|
|
||||||
__LA_DECL struct archive_entry *archive_entry_new(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This form of archive_entry_new2() will pull character-set
|
|
||||||
* conversion information from the specified archive handle. The
|
|
||||||
* older archive_entry_new(void) form is equivalent to calling
|
|
||||||
* archive_entry_new2(NULL) and will result in the use of an internal
|
|
||||||
* default character-set conversion.
|
|
||||||
*/
|
|
||||||
__LA_DECL struct archive_entry *archive_entry_new2(struct archive *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve fields from an archive_entry.
|
|
||||||
*
|
|
||||||
* There are a number of implicit conversions among these fields. For
|
|
||||||
* example, if a regular string field is set and you read the _w wide
|
|
||||||
* character field, the entry will implicitly convert narrow-to-wide
|
|
||||||
* using the current locale. Similarly, dev values are automatically
|
|
||||||
* updated when you write devmajor or devminor and vice versa.
|
|
||||||
*
|
|
||||||
* In addition, fields can be "set" or "unset." Unset string fields
|
|
||||||
* return NULL, non-string fields have _is_set() functions to test
|
|
||||||
* whether they've been set. You can "unset" a string field by
|
|
||||||
* assigning NULL; non-string fields have _unset() functions to
|
|
||||||
* unset them.
|
|
||||||
*
|
|
||||||
* Note: There is one ambiguity in the above; string fields will
|
|
||||||
* also return NULL when implicit character set conversions fail.
|
|
||||||
* This is usually what you want.
|
|
||||||
*/
|
|
||||||
__LA_DECL time_t archive_entry_atime(struct archive_entry *);
|
|
||||||
__LA_DECL long archive_entry_atime_nsec(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_atime_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL time_t archive_entry_birthtime(struct archive_entry *);
|
|
||||||
__LA_DECL long archive_entry_birthtime_nsec(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_birthtime_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL time_t archive_entry_ctime(struct archive_entry *);
|
|
||||||
__LA_DECL long archive_entry_ctime_nsec(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_ctime_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL dev_t archive_entry_dev(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_dev_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL dev_t archive_entry_devmajor(struct archive_entry *);
|
|
||||||
__LA_DECL dev_t archive_entry_devminor(struct archive_entry *);
|
|
||||||
__LA_DECL __LA_MODE_T archive_entry_filetype(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_fflags(struct archive_entry *,
|
|
||||||
unsigned long * /* set */,
|
|
||||||
unsigned long * /* clear */);
|
|
||||||
__LA_DECL const char *archive_entry_fflags_text(struct archive_entry *);
|
|
||||||
__LA_DECL la_int64_t archive_entry_gid(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_gname(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_gname_utf8(struct archive_entry *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
|
|
||||||
__LA_DECL la_int64_t archive_entry_ino(struct archive_entry *);
|
|
||||||
__LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_ino_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);
|
|
||||||
__LA_DECL time_t archive_entry_mtime(struct archive_entry *);
|
|
||||||
__LA_DECL long archive_entry_mtime_nsec(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_mtime_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL unsigned int archive_entry_nlink(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_pathname(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_pathname_utf8(struct archive_entry *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
|
|
||||||
__LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *);
|
|
||||||
__LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
|
|
||||||
__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
|
|
||||||
__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);
|
|
||||||
__LA_DECL la_int64_t archive_entry_size(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_size_is_set(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_strmode(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_symlink(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_symlink_utf8(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_symlink_type(struct archive_entry *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);
|
|
||||||
__LA_DECL la_int64_t archive_entry_uid(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_uname(struct archive_entry *);
|
|
||||||
__LA_DECL const char *archive_entry_uname_utf8(struct archive_entry *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set fields in an archive_entry.
|
|
||||||
*
|
|
||||||
* Note: Before libarchive 2.4, there were 'set' and 'copy' versions
|
|
||||||
* of the string setters. 'copy' copied the actual string, 'set' just
|
|
||||||
* stored the pointer. In libarchive 2.4 and later, strings are
|
|
||||||
* always copied.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
|
|
||||||
__LA_DECL void archive_entry_unset_atime(struct archive_entry *);
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
|
|
||||||
#endif
|
|
||||||
__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
|
|
||||||
__LA_DECL void archive_entry_unset_birthtime(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long);
|
|
||||||
__LA_DECL void archive_entry_unset_ctime(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t);
|
|
||||||
__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t);
|
|
||||||
__LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t);
|
|
||||||
__LA_DECL void archive_entry_set_filetype(struct archive_entry *, unsigned int);
|
|
||||||
__LA_DECL void archive_entry_set_fflags(struct archive_entry *,
|
|
||||||
unsigned long /* set */, unsigned long /* clear */);
|
|
||||||
/* Returns pointer to start of first invalid token, or NULL if none. */
|
|
||||||
/* Note that all recognized tokens are processed, regardless. */
|
|
||||||
__LA_DECL const char *archive_entry_copy_fflags_text(struct archive_entry *,
|
|
||||||
const char *);
|
|
||||||
__LA_DECL const wchar_t *archive_entry_copy_fflags_text_w(struct archive_entry *,
|
|
||||||
const wchar_t *);
|
|
||||||
__LA_DECL void archive_entry_set_gid(struct archive_entry *, la_int64_t);
|
|
||||||
__LA_DECL void archive_entry_set_gname(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_gname_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_gname(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_gname_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_hardlink_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_ino(struct archive_entry *, la_int64_t);
|
|
||||||
__LA_DECL void archive_entry_set_ino64(struct archive_entry *, la_int64_t);
|
|
||||||
__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_link_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);
|
|
||||||
__LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);
|
|
||||||
__LA_DECL void archive_entry_unset_mtime(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);
|
|
||||||
__LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_pathname_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
|
|
||||||
__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
|
|
||||||
__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
|
|
||||||
__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
|
|
||||||
__LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t);
|
|
||||||
__LA_DECL void archive_entry_unset_size(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_sourcepath_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_symlink_type(struct archive_entry *, int);
|
|
||||||
__LA_DECL void archive_entry_set_symlink_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_uid(struct archive_entry *, la_int64_t);
|
|
||||||
__LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_uname_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
|
|
||||||
__LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *);
|
|
||||||
__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);
|
|
||||||
__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);
|
|
||||||
/*
|
|
||||||
* Routines to bulk copy fields to/from a platform-native "struct
|
|
||||||
* stat." Libarchive used to just store a struct stat inside of each
|
|
||||||
* archive_entry object, but this created issues when trying to
|
|
||||||
* manipulate archives on systems different than the ones they were
|
|
||||||
* created on.
|
|
||||||
*
|
|
||||||
* TODO: On Linux and other LFS systems, provide both stat32 and
|
|
||||||
* stat64 versions of these functions and all of the macro glue so
|
|
||||||
* that archive_entry_stat is magically defined to
|
|
||||||
* archive_entry_stat32 or archive_entry_stat64 as appropriate.
|
|
||||||
*/
|
|
||||||
__LA_DECL const struct stat *archive_entry_stat(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Storage for Mac OS-specific AppleDouble metadata information.
|
|
||||||
* Apple-format tar files store a separate binary blob containing
|
|
||||||
* encoded metadata with ACL, extended attributes, etc.
|
|
||||||
* This provides a place to store that blob.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL const void * archive_entry_mac_metadata(struct archive_entry *, size_t *);
|
|
||||||
__LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const void *, size_t);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ACL routines. This used to simply store and return text-format ACL
|
|
||||||
* strings, but that proved insufficient for a number of reasons:
|
|
||||||
* = clients need control over uname/uid and gname/gid mappings
|
|
||||||
* = there are many different ACL text formats
|
|
||||||
* = would like to be able to read/convert archives containing ACLs
|
|
||||||
* on platforms that lack ACL libraries
|
|
||||||
*
|
|
||||||
* This last point, in particular, forces me to implement a reasonably
|
|
||||||
* complete set of ACL support routines.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Permission bits.
|
|
||||||
*/
|
|
||||||
#define ARCHIVE_ENTRY_ACL_EXECUTE 0x00000001
|
|
||||||
#define ARCHIVE_ENTRY_ACL_WRITE 0x00000002
|
|
||||||
#define ARCHIVE_ENTRY_ACL_READ 0x00000004
|
|
||||||
#define ARCHIVE_ENTRY_ACL_READ_DATA 0x00000008
|
|
||||||
#define ARCHIVE_ENTRY_ACL_LIST_DIRECTORY 0x00000008
|
|
||||||
#define ARCHIVE_ENTRY_ACL_WRITE_DATA 0x00000010
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ADD_FILE 0x00000010
|
|
||||||
#define ARCHIVE_ENTRY_ACL_APPEND_DATA 0x00000020
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY 0x00000020
|
|
||||||
#define ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS 0x00000040
|
|
||||||
#define ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS 0x00000080
|
|
||||||
#define ARCHIVE_ENTRY_ACL_DELETE_CHILD 0x00000100
|
|
||||||
#define ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES 0x00000200
|
|
||||||
#define ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES 0x00000400
|
|
||||||
#define ARCHIVE_ENTRY_ACL_DELETE 0x00000800
|
|
||||||
#define ARCHIVE_ENTRY_ACL_READ_ACL 0x00001000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_WRITE_ACL 0x00002000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_WRITE_OWNER 0x00004000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_SYNCHRONIZE 0x00008000
|
|
||||||
|
|
||||||
#define ARCHIVE_ENTRY_ACL_PERMS_POSIX1E \
|
|
||||||
(ARCHIVE_ENTRY_ACL_EXECUTE \
|
|
||||||
| ARCHIVE_ENTRY_ACL_WRITE \
|
|
||||||
| ARCHIVE_ENTRY_ACL_READ)
|
|
||||||
|
|
||||||
#define ARCHIVE_ENTRY_ACL_PERMS_NFS4 \
|
|
||||||
(ARCHIVE_ENTRY_ACL_EXECUTE \
|
|
||||||
| ARCHIVE_ENTRY_ACL_READ_DATA \
|
|
||||||
| ARCHIVE_ENTRY_ACL_LIST_DIRECTORY \
|
|
||||||
| ARCHIVE_ENTRY_ACL_WRITE_DATA \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ADD_FILE \
|
|
||||||
| ARCHIVE_ENTRY_ACL_APPEND_DATA \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY \
|
|
||||||
| ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS \
|
|
||||||
| ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS \
|
|
||||||
| ARCHIVE_ENTRY_ACL_DELETE_CHILD \
|
|
||||||
| ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES \
|
|
||||||
| ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES \
|
|
||||||
| ARCHIVE_ENTRY_ACL_DELETE \
|
|
||||||
| ARCHIVE_ENTRY_ACL_READ_ACL \
|
|
||||||
| ARCHIVE_ENTRY_ACL_WRITE_ACL \
|
|
||||||
| ARCHIVE_ENTRY_ACL_WRITE_OWNER \
|
|
||||||
| ARCHIVE_ENTRY_ACL_SYNCHRONIZE)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Inheritance values (NFS4 ACLs only); included in permset.
|
|
||||||
*/
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x01000000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT 0x02000000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT 0x04000000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT 0x08000000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY 0x10000000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS 0x20000000
|
|
||||||
#define ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS 0x40000000
|
|
||||||
|
|
||||||
#define ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4 \
|
|
||||||
(ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS \
|
|
||||||
| ARCHIVE_ENTRY_ACL_ENTRY_INHERITED)
|
|
||||||
|
|
||||||
/* We need to be able to specify combinations of these. */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_ACCESS 0x00000100 /* POSIX.1e only */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_DEFAULT 0x00000200 /* POSIX.1e only */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_ALLOW 0x00000400 /* NFS4 only */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_DENY 0x00000800 /* NFS4 only */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_AUDIT 0x00001000 /* NFS4 only */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_ALARM 0x00002000 /* NFS4 only */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_POSIX1E (ARCHIVE_ENTRY_ACL_TYPE_ACCESS \
|
|
||||||
| ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
|
|
||||||
#define ARCHIVE_ENTRY_ACL_TYPE_NFS4 (ARCHIVE_ENTRY_ACL_TYPE_ALLOW \
|
|
||||||
| ARCHIVE_ENTRY_ACL_TYPE_DENY \
|
|
||||||
| ARCHIVE_ENTRY_ACL_TYPE_AUDIT \
|
|
||||||
| ARCHIVE_ENTRY_ACL_TYPE_ALARM)
|
|
||||||
|
|
||||||
/* Tag values mimic POSIX.1e */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_USER 10001 /* Specified user. */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_USER_OBJ 10002 /* User who owns the file. */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_GROUP 10003 /* Specified group. */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_GROUP_OBJ 10004 /* Group who owns the file. */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_MASK 10005 /* Modify group access (POSIX.1e only) */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_OTHER 10006 /* Public (POSIX.1e only) */
|
|
||||||
#define ARCHIVE_ENTRY_ACL_EVERYONE 10107 /* Everyone (NFS4 only) */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the ACL by clearing it and adding entries one at a time.
|
|
||||||
* Unlike the POSIX.1e ACL routines, you must specify the type
|
|
||||||
* (access/default) for each entry. Internally, the ACL data is just
|
|
||||||
* a soup of entries. API calls here allow you to retrieve just the
|
|
||||||
* entries of interest. This design (which goes against the spirit of
|
|
||||||
* POSIX.1e) is useful for handling archive formats that combine
|
|
||||||
* default and access information in a single ACL list.
|
|
||||||
*/
|
|
||||||
__LA_DECL void archive_entry_acl_clear(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_acl_add_entry(struct archive_entry *,
|
|
||||||
int /* type */, int /* permset */, int /* tag */,
|
|
||||||
int /* qual */, const char * /* name */);
|
|
||||||
__LA_DECL int archive_entry_acl_add_entry_w(struct archive_entry *,
|
|
||||||
int /* type */, int /* permset */, int /* tag */,
|
|
||||||
int /* qual */, const wchar_t * /* name */);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To retrieve the ACL, first "reset", then repeatedly ask for the
|
|
||||||
* "next" entry. The want_type parameter allows you to request only
|
|
||||||
* certain types of entries.
|
|
||||||
*/
|
|
||||||
__LA_DECL int archive_entry_acl_reset(struct archive_entry *, int /* want_type */);
|
|
||||||
__LA_DECL int archive_entry_acl_next(struct archive_entry *, int /* want_type */,
|
|
||||||
int * /* type */, int * /* permset */, int * /* tag */,
|
|
||||||
int * /* qual */, const char ** /* name */);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Construct a text-format ACL. The flags argument is a bitmask that
|
|
||||||
* can include any of the following:
|
|
||||||
*
|
|
||||||
* Flags only for archive entries with POSIX.1e ACL:
|
|
||||||
* ARCHIVE_ENTRY_ACL_TYPE_ACCESS - Include POSIX.1e "access" entries.
|
|
||||||
* ARCHIVE_ENTRY_ACL_TYPE_DEFAULT - Include POSIX.1e "default" entries.
|
|
||||||
* ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each
|
|
||||||
* default ACL entry.
|
|
||||||
* ARCHIVE_ENTRY_ACL_STYLE_SOLARIS - Output only one colon after "other" and
|
|
||||||
* "mask" entries.
|
|
||||||
*
|
|
||||||
* Flags only for archive entries with NFSv4 ACL:
|
|
||||||
* ARCHIVE_ENTRY_ACL_STYLE_COMPACT - Do not output the minus character for
|
|
||||||
* unset permissions and flags in NFSv4 ACL permission and flag fields
|
|
||||||
*
|
|
||||||
* Flags for for archive entries with POSIX.1e ACL or NFSv4 ACL:
|
|
||||||
* ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID - Include extra numeric ID field in
|
|
||||||
* each ACL entry.
|
|
||||||
* ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA - Separate entries with comma
|
|
||||||
* instead of newline.
|
|
||||||
*/
|
|
||||||
#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 0x00000001
|
|
||||||
#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 0x00000002
|
|
||||||
#define ARCHIVE_ENTRY_ACL_STYLE_SOLARIS 0x00000004
|
|
||||||
#define ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMA 0x00000008
|
|
||||||
#define ARCHIVE_ENTRY_ACL_STYLE_COMPACT 0x00000010
|
|
||||||
|
|
||||||
__LA_DECL wchar_t *archive_entry_acl_to_text_w(struct archive_entry *,
|
|
||||||
la_ssize_t * /* len */, int /* flags */);
|
|
||||||
__LA_DECL char *archive_entry_acl_to_text(struct archive_entry *,
|
|
||||||
la_ssize_t * /* len */, int /* flags */);
|
|
||||||
__LA_DECL int archive_entry_acl_from_text_w(struct archive_entry *,
|
|
||||||
const wchar_t * /* wtext */, int /* type */);
|
|
||||||
__LA_DECL int archive_entry_acl_from_text(struct archive_entry *,
|
|
||||||
const char * /* text */, int /* type */);
|
|
||||||
|
|
||||||
/* Deprecated constants */
|
|
||||||
#define OLD_ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024
|
|
||||||
#define OLD_ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048
|
|
||||||
|
|
||||||
/* Deprecated functions */
|
|
||||||
__LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *,
|
|
||||||
int /* flags */) __LA_DEPRECATED;
|
|
||||||
__LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
|
|
||||||
int /* flags */) __LA_DEPRECATED;
|
|
||||||
|
|
||||||
/* Return bitmask of ACL types in an archive entry */
|
|
||||||
__LA_DECL int archive_entry_acl_types(struct archive_entry *);
|
|
||||||
|
|
||||||
/* Return a count of entries matching 'want_type' */
|
|
||||||
__LA_DECL int archive_entry_acl_count(struct archive_entry *, int /* want_type */);
|
|
||||||
|
|
||||||
/* Return an opaque ACL object. */
|
|
||||||
/* There's not yet anything clients can actually do with this... */
|
|
||||||
struct archive_acl;
|
|
||||||
__LA_DECL struct archive_acl *archive_entry_acl(struct archive_entry *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* extended attributes
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL void archive_entry_xattr_clear(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_xattr_add_entry(struct archive_entry *,
|
|
||||||
const char * /* name */, const void * /* value */,
|
|
||||||
size_t /* size */);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To retrieve the xattr list, first "reset", then repeatedly ask for the
|
|
||||||
* "next" entry.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL int archive_entry_xattr_count(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_xattr_reset(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_xattr_next(struct archive_entry *,
|
|
||||||
const char ** /* name */, const void ** /* value */, size_t *);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* sparse
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL void archive_entry_sparse_clear(struct archive_entry *);
|
|
||||||
__LA_DECL void archive_entry_sparse_add_entry(struct archive_entry *,
|
|
||||||
la_int64_t /* offset */, la_int64_t /* length */);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To retrieve the xattr list, first "reset", then repeatedly ask for the
|
|
||||||
* "next" entry.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL int archive_entry_sparse_count(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_sparse_reset(struct archive_entry *);
|
|
||||||
__LA_DECL int archive_entry_sparse_next(struct archive_entry *,
|
|
||||||
la_int64_t * /* offset */, la_int64_t * /* length */);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Utility to match up hardlinks.
|
|
||||||
*
|
|
||||||
* The 'struct archive_entry_linkresolver' is a cache of archive entries
|
|
||||||
* for files with multiple links. Here's how to use it:
|
|
||||||
* 1. Create a lookup object with archive_entry_linkresolver_new()
|
|
||||||
* 2. Tell it the archive format you're using.
|
|
||||||
* 3. Hand each archive_entry to archive_entry_linkify().
|
|
||||||
* That function will return 0, 1, or 2 entries that should
|
|
||||||
* be written.
|
|
||||||
* 4. Call archive_entry_linkify(resolver, NULL) until
|
|
||||||
* no more entries are returned.
|
|
||||||
* 5. Call archive_entry_linkresolver_free(resolver) to free resources.
|
|
||||||
*
|
|
||||||
* The entries returned have their hardlink and size fields updated
|
|
||||||
* appropriately. If an entry is passed in that does not refer to
|
|
||||||
* a file with multiple links, it is returned unchanged. The intention
|
|
||||||
* is that you should be able to simply filter all entries through
|
|
||||||
* this machine.
|
|
||||||
*
|
|
||||||
* To make things more efficient, be sure that each entry has a valid
|
|
||||||
* nlinks value. The hardlink cache uses this to track when all links
|
|
||||||
* have been found. If the nlinks value is zero, it will keep every
|
|
||||||
* name in the cache indefinitely, which can use a lot of memory.
|
|
||||||
*
|
|
||||||
* Note that archive_entry_size() is reset to zero if the file
|
|
||||||
* body should not be written to the archive. Pay attention!
|
|
||||||
*/
|
|
||||||
struct archive_entry_linkresolver;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There are three different strategies for marking hardlinks.
|
|
||||||
* The descriptions below name them after the best-known
|
|
||||||
* formats that rely on each strategy:
|
|
||||||
*
|
|
||||||
* "Old cpio" is the simplest, it always returns any entry unmodified.
|
|
||||||
* As far as I know, only cpio formats use this. Old cpio archives
|
|
||||||
* store every link with the full body; the onus is on the dearchiver
|
|
||||||
* to detect and properly link the files as they are restored.
|
|
||||||
* "tar" is also pretty simple; it caches a copy the first time it sees
|
|
||||||
* any link. Subsequent appearances are modified to be hardlink
|
|
||||||
* references to the first one without any body. Used by all tar
|
|
||||||
* formats, although the newest tar formats permit the "old cpio" strategy
|
|
||||||
* as well. This strategy is very simple for the dearchiver,
|
|
||||||
* and reasonably straightforward for the archiver.
|
|
||||||
* "new cpio" is trickier. It stores the body only with the last
|
|
||||||
* occurrence. The complication is that we might not
|
|
||||||
* see every link to a particular file in a single session, so
|
|
||||||
* there's no easy way to know when we've seen the last occurrence.
|
|
||||||
* The solution here is to queue one link until we see the next.
|
|
||||||
* At the end of the session, you can enumerate any remaining
|
|
||||||
* entries by calling archive_entry_linkify(NULL) and store those
|
|
||||||
* bodies. If you have a file with three links l1, l2, and l3,
|
|
||||||
* you'll get the following behavior if you see all three links:
|
|
||||||
* linkify(l1) => NULL (the resolver stores l1 internally)
|
|
||||||
* linkify(l2) => l1 (resolver stores l2, you write l1)
|
|
||||||
* linkify(l3) => l2, l3 (all links seen, you can write both).
|
|
||||||
* If you only see l1 and l2, you'll get this behavior:
|
|
||||||
* linkify(l1) => NULL
|
|
||||||
* linkify(l2) => l1
|
|
||||||
* linkify(NULL) => l2 (at end, you retrieve remaining links)
|
|
||||||
* As the name suggests, this strategy is used by newer cpio variants.
|
|
||||||
* It's noticeably more complex for the archiver, slightly more complex
|
|
||||||
* for the dearchiver than the tar strategy, but makes it straightforward
|
|
||||||
* to restore a file using any link by simply continuing to scan until
|
|
||||||
* you see a link that is stored with a body. In contrast, the tar
|
|
||||||
* strategy requires you to rescan the archive from the beginning to
|
|
||||||
* correctly extract an arbitrary link.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__LA_DECL struct archive_entry_linkresolver *archive_entry_linkresolver_new(void);
|
|
||||||
__LA_DECL void archive_entry_linkresolver_set_strategy(
|
|
||||||
struct archive_entry_linkresolver *, int /* format_code */);
|
|
||||||
__LA_DECL void archive_entry_linkresolver_free(struct archive_entry_linkresolver *);
|
|
||||||
__LA_DECL void archive_entry_linkify(struct archive_entry_linkresolver *,
|
|
||||||
struct archive_entry **, struct archive_entry **);
|
|
||||||
__LA_DECL struct archive_entry *archive_entry_partial_links(
|
|
||||||
struct archive_entry_linkresolver *res, unsigned int *links);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is meaningless outside of this header. */
|
|
||||||
#undef __LA_DECL
|
|
||||||
|
|
||||||
#endif /* !ARCHIVE_ENTRY_H_INCLUDED */
|
|
75
3rdparty/libarchive/c/archive_entry_copy_bhfi.c
vendored
75
3rdparty/libarchive/c/archive_entry_copy_bhfi.c
vendored
@ -1,75 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD$");
|
|
||||||
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_entry.h"
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
|
|
||||||
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
|
|
||||||
|
|
||||||
__inline static void
|
|
||||||
fileTimeToUtc(const FILETIME *filetime, time_t *t, long *ns)
|
|
||||||
{
|
|
||||||
ULARGE_INTEGER utc;
|
|
||||||
|
|
||||||
utc.HighPart = filetime->dwHighDateTime;
|
|
||||||
utc.LowPart = filetime->dwLowDateTime;
|
|
||||||
if (utc.QuadPart >= EPOC_TIME) {
|
|
||||||
utc.QuadPart -= EPOC_TIME;
|
|
||||||
*t = (time_t)(utc.QuadPart / 10000000); /* milli seconds base */
|
|
||||||
*ns = (long)(utc.QuadPart % 10000000) * 100;/* nano seconds base */
|
|
||||||
} else {
|
|
||||||
*t = 0;
|
|
||||||
*ns = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_copy_bhfi(struct archive_entry *entry,
|
|
||||||
BY_HANDLE_FILE_INFORMATION *bhfi)
|
|
||||||
{
|
|
||||||
time_t secs;
|
|
||||||
long nsecs;
|
|
||||||
|
|
||||||
fileTimeToUtc(&bhfi->ftLastAccessTime, &secs, &nsecs);
|
|
||||||
archive_entry_set_atime(entry, secs, nsecs);
|
|
||||||
fileTimeToUtc(&bhfi->ftLastWriteTime, &secs, &nsecs);
|
|
||||||
archive_entry_set_mtime(entry, secs, nsecs);
|
|
||||||
fileTimeToUtc(&bhfi->ftCreationTime, &secs, &nsecs);
|
|
||||||
archive_entry_set_birthtime(entry, secs, nsecs);
|
|
||||||
archive_entry_set_ctime(entry, secs, nsecs);
|
|
||||||
archive_entry_set_dev(entry, bhfi->dwVolumeSerialNumber);
|
|
||||||
archive_entry_set_ino64(entry, (((int64_t)bhfi->nFileIndexHigh) << 32)
|
|
||||||
+ bhfi->nFileIndexLow);
|
|
||||||
archive_entry_set_nlink(entry, bhfi->nNumberOfLinks);
|
|
||||||
archive_entry_set_size(entry, (((int64_t)bhfi->nFileSizeHigh) << 32)
|
|
||||||
+ bhfi->nFileSizeLow);
|
|
||||||
/* archive_entry_set_mode(entry, st->st_mode); */
|
|
||||||
}
|
|
||||||
#endif
|
|
83
3rdparty/libarchive/c/archive_entry_copy_stat.c
vendored
83
3rdparty/libarchive/c/archive_entry_copy_stat.c
vendored
@ -1,83 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_copy_stat.c 189466 2009-03-07 00:52:02Z kientzle $");
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_entry.h"
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_copy_stat(struct archive_entry *entry, const struct stat *st)
|
|
||||||
{
|
|
||||||
#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, st->st_atimespec.tv_nsec);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctimespec.tv_nsec);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtimespec.tv_nsec);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, st->st_atim.tv_nsec);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctim.tv_nsec);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtim.tv_nsec);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIME_NSEC
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, st->st_atime_nsec);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_nsec);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_nsec);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIME_N
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, st->st_atime_n);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_n);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_n);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_UMTIME
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, st->st_uatime * 1000);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_uctime * 1000);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_umtime * 1000);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, st->st_atime_usec * 1000);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_usec * 1000);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_usec * 1000);
|
|
||||||
#else
|
|
||||||
archive_entry_set_atime(entry, st->st_atime, 0);
|
|
||||||
archive_entry_set_ctime(entry, st->st_ctime, 0);
|
|
||||||
archive_entry_set_mtime(entry, st->st_mtime, 0);
|
|
||||||
#endif
|
|
||||||
#if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
|
|
||||||
archive_entry_set_birthtime(entry, st->st_birthtime, st->st_birthtimespec.tv_nsec);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_BIRTHTIME
|
|
||||||
archive_entry_set_birthtime(entry, st->st_birthtime, 0);
|
|
||||||
#else
|
|
||||||
archive_entry_unset_birthtime(entry);
|
|
||||||
#endif
|
|
||||||
archive_entry_set_dev(entry, st->st_dev);
|
|
||||||
archive_entry_set_gid(entry, st->st_gid);
|
|
||||||
archive_entry_set_uid(entry, st->st_uid);
|
|
||||||
archive_entry_set_ino(entry, st->st_ino);
|
|
||||||
archive_entry_set_nlink(entry, st->st_nlink);
|
|
||||||
archive_entry_set_rdev(entry, st->st_rdev);
|
|
||||||
archive_entry_set_size(entry, st->st_size);
|
|
||||||
archive_entry_set_mode(entry, st->st_mode);
|
|
||||||
}
|
|
447
3rdparty/libarchive/c/archive_entry_link_resolver.c
vendored
447
3rdparty/libarchive/c/archive_entry_link_resolver.c
vendored
@ -1,447 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_link_resolver.c 201100 2009-12-28 03:05:31Z kientzle $");
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_entry.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is mostly a pretty straightforward hash table implementation.
|
|
||||||
* The only interesting bit is the different strategies used to
|
|
||||||
* match up links. These strategies match those used by various
|
|
||||||
* archiving formats:
|
|
||||||
* tar - content stored with first link, remainder refer back to it.
|
|
||||||
* This requires us to match each subsequent link up with the
|
|
||||||
* first appearance.
|
|
||||||
* cpio - Old cpio just stored body with each link, match-ups were
|
|
||||||
* implicit. This is trivial.
|
|
||||||
* new cpio - New cpio only stores body with last link, match-ups
|
|
||||||
* are implicit. This is actually quite tricky; see the notes
|
|
||||||
* below.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Users pass us a format code, we translate that into a strategy here. */
|
|
||||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_TAR 0
|
|
||||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_MTREE 1
|
|
||||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO 2
|
|
||||||
#define ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO 3
|
|
||||||
|
|
||||||
/* Initial size of link cache. */
|
|
||||||
#define links_cache_initial_size 1024
|
|
||||||
|
|
||||||
struct links_entry {
|
|
||||||
struct links_entry *next;
|
|
||||||
struct links_entry *previous;
|
|
||||||
struct archive_entry *canonical;
|
|
||||||
struct archive_entry *entry;
|
|
||||||
size_t hash;
|
|
||||||
unsigned int links; /* # links not yet seen */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct archive_entry_linkresolver {
|
|
||||||
struct links_entry **buckets;
|
|
||||||
struct links_entry *spare;
|
|
||||||
unsigned long number_entries;
|
|
||||||
size_t number_buckets;
|
|
||||||
int strategy;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NEXT_ENTRY_DEFERRED 1
|
|
||||||
#define NEXT_ENTRY_PARTIAL 2
|
|
||||||
#define NEXT_ENTRY_ALL (NEXT_ENTRY_DEFERRED | NEXT_ENTRY_PARTIAL)
|
|
||||||
|
|
||||||
static struct links_entry *find_entry(struct archive_entry_linkresolver *,
|
|
||||||
struct archive_entry *);
|
|
||||||
static void grow_hash(struct archive_entry_linkresolver *);
|
|
||||||
static struct links_entry *insert_entry(struct archive_entry_linkresolver *,
|
|
||||||
struct archive_entry *);
|
|
||||||
static struct links_entry *next_entry(struct archive_entry_linkresolver *,
|
|
||||||
int);
|
|
||||||
|
|
||||||
struct archive_entry_linkresolver *
|
|
||||||
archive_entry_linkresolver_new(void)
|
|
||||||
{
|
|
||||||
struct archive_entry_linkresolver *res;
|
|
||||||
|
|
||||||
/* Check for positive power-of-two */
|
|
||||||
if (links_cache_initial_size == 0 ||
|
|
||||||
(links_cache_initial_size & (links_cache_initial_size - 1)) != 0)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
res = calloc(1, sizeof(struct archive_entry_linkresolver));
|
|
||||||
if (res == NULL)
|
|
||||||
return (NULL);
|
|
||||||
res->number_buckets = links_cache_initial_size;
|
|
||||||
res->buckets = calloc(res->number_buckets, sizeof(res->buckets[0]));
|
|
||||||
if (res->buckets == NULL) {
|
|
||||||
free(res);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
return (res);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_linkresolver_set_strategy(struct archive_entry_linkresolver *res,
|
|
||||||
int fmt)
|
|
||||||
{
|
|
||||||
int fmtbase = fmt & ARCHIVE_FORMAT_BASE_MASK;
|
|
||||||
|
|
||||||
switch (fmtbase) {
|
|
||||||
case ARCHIVE_FORMAT_7ZIP:
|
|
||||||
case ARCHIVE_FORMAT_AR:
|
|
||||||
case ARCHIVE_FORMAT_ZIP:
|
|
||||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_FORMAT_CPIO:
|
|
||||||
switch (fmt) {
|
|
||||||
case ARCHIVE_FORMAT_CPIO_SVR4_NOCRC:
|
|
||||||
case ARCHIVE_FORMAT_CPIO_SVR4_CRC:
|
|
||||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ARCHIVE_FORMAT_MTREE:
|
|
||||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_MTREE;
|
|
||||||
break;
|
|
||||||
case ARCHIVE_FORMAT_ISO9660:
|
|
||||||
case ARCHIVE_FORMAT_SHAR:
|
|
||||||
case ARCHIVE_FORMAT_TAR:
|
|
||||||
case ARCHIVE_FORMAT_XAR:
|
|
||||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_TAR;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
res->strategy = ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_linkresolver_free(struct archive_entry_linkresolver *res)
|
|
||||||
{
|
|
||||||
struct links_entry *le;
|
|
||||||
|
|
||||||
if (res == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while ((le = next_entry(res, NEXT_ENTRY_ALL)) != NULL)
|
|
||||||
archive_entry_free(le->entry);
|
|
||||||
free(res->buckets);
|
|
||||||
free(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_linkify(struct archive_entry_linkresolver *res,
|
|
||||||
struct archive_entry **e, struct archive_entry **f)
|
|
||||||
{
|
|
||||||
struct links_entry *le;
|
|
||||||
struct archive_entry *t;
|
|
||||||
|
|
||||||
*f = NULL; /* Default: Don't return a second entry. */
|
|
||||||
|
|
||||||
if (*e == NULL) {
|
|
||||||
le = next_entry(res, NEXT_ENTRY_DEFERRED);
|
|
||||||
if (le != NULL) {
|
|
||||||
*e = le->entry;
|
|
||||||
le->entry = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If it has only one link, then we're done. */
|
|
||||||
if (archive_entry_nlink(*e) == 1)
|
|
||||||
return;
|
|
||||||
/* Directories, devices never have hardlinks. */
|
|
||||||
if (archive_entry_filetype(*e) == AE_IFDIR
|
|
||||||
|| archive_entry_filetype(*e) == AE_IFBLK
|
|
||||||
|| archive_entry_filetype(*e) == AE_IFCHR)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (res->strategy) {
|
|
||||||
case ARCHIVE_ENTRY_LINKIFY_LIKE_TAR:
|
|
||||||
le = find_entry(res, *e);
|
|
||||||
if (le != NULL) {
|
|
||||||
archive_entry_unset_size(*e);
|
|
||||||
archive_entry_copy_hardlink(*e,
|
|
||||||
archive_entry_pathname(le->canonical));
|
|
||||||
} else
|
|
||||||
insert_entry(res, *e);
|
|
||||||
return;
|
|
||||||
case ARCHIVE_ENTRY_LINKIFY_LIKE_MTREE:
|
|
||||||
le = find_entry(res, *e);
|
|
||||||
if (le != NULL) {
|
|
||||||
archive_entry_copy_hardlink(*e,
|
|
||||||
archive_entry_pathname(le->canonical));
|
|
||||||
} else
|
|
||||||
insert_entry(res, *e);
|
|
||||||
return;
|
|
||||||
case ARCHIVE_ENTRY_LINKIFY_LIKE_OLD_CPIO:
|
|
||||||
/* This one is trivial. */
|
|
||||||
return;
|
|
||||||
case ARCHIVE_ENTRY_LINKIFY_LIKE_NEW_CPIO:
|
|
||||||
le = find_entry(res, *e);
|
|
||||||
if (le != NULL) {
|
|
||||||
/*
|
|
||||||
* Put the new entry in le, return the
|
|
||||||
* old entry from le.
|
|
||||||
*/
|
|
||||||
t = *e;
|
|
||||||
*e = le->entry;
|
|
||||||
le->entry = t;
|
|
||||||
/* Make the old entry into a hardlink. */
|
|
||||||
archive_entry_unset_size(*e);
|
|
||||||
archive_entry_copy_hardlink(*e,
|
|
||||||
archive_entry_pathname(le->canonical));
|
|
||||||
/* If we ran out of links, return the
|
|
||||||
* final entry as well. */
|
|
||||||
if (le->links == 0) {
|
|
||||||
*f = le->entry;
|
|
||||||
le->entry = NULL;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* If we haven't seen it, tuck it away
|
|
||||||
* for future use.
|
|
||||||
*/
|
|
||||||
le = insert_entry(res, *e);
|
|
||||||
if (le == NULL)
|
|
||||||
/* XXX We should return an error code XXX */
|
|
||||||
return;
|
|
||||||
le->entry = *e;
|
|
||||||
*e = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct links_entry *
|
|
||||||
find_entry(struct archive_entry_linkresolver *res,
|
|
||||||
struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct links_entry *le;
|
|
||||||
size_t hash, bucket;
|
|
||||||
dev_t dev;
|
|
||||||
int64_t ino;
|
|
||||||
|
|
||||||
/* Free a held entry. */
|
|
||||||
if (res->spare != NULL) {
|
|
||||||
archive_entry_free(res->spare->canonical);
|
|
||||||
archive_entry_free(res->spare->entry);
|
|
||||||
free(res->spare);
|
|
||||||
res->spare = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev = archive_entry_dev(entry);
|
|
||||||
ino = archive_entry_ino64(entry);
|
|
||||||
hash = (size_t)(dev ^ ino);
|
|
||||||
|
|
||||||
/* Try to locate this entry in the links cache. */
|
|
||||||
bucket = hash & (res->number_buckets - 1);
|
|
||||||
for (le = res->buckets[bucket]; le != NULL; le = le->next) {
|
|
||||||
if (le->hash == hash
|
|
||||||
&& dev == archive_entry_dev(le->canonical)
|
|
||||||
&& ino == archive_entry_ino64(le->canonical)) {
|
|
||||||
/*
|
|
||||||
* Decrement link count each time and release
|
|
||||||
* the entry if it hits zero. This saves
|
|
||||||
* memory and is necessary for detecting
|
|
||||||
* missed links.
|
|
||||||
*/
|
|
||||||
--le->links;
|
|
||||||
if (le->links > 0)
|
|
||||||
return (le);
|
|
||||||
/* Remove it from this hash bucket. */
|
|
||||||
if (le->previous != NULL)
|
|
||||||
le->previous->next = le->next;
|
|
||||||
if (le->next != NULL)
|
|
||||||
le->next->previous = le->previous;
|
|
||||||
if (res->buckets[bucket] == le)
|
|
||||||
res->buckets[bucket] = le->next;
|
|
||||||
res->number_entries--;
|
|
||||||
/* Defer freeing this entry. */
|
|
||||||
res->spare = le;
|
|
||||||
return (le);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct links_entry *
|
|
||||||
next_entry(struct archive_entry_linkresolver *res, int mode)
|
|
||||||
{
|
|
||||||
struct links_entry *le;
|
|
||||||
size_t bucket;
|
|
||||||
|
|
||||||
/* Free a held entry. */
|
|
||||||
if (res->spare != NULL) {
|
|
||||||
archive_entry_free(res->spare->canonical);
|
|
||||||
archive_entry_free(res->spare->entry);
|
|
||||||
free(res->spare);
|
|
||||||
res->spare = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look for next non-empty bucket in the links cache. */
|
|
||||||
for (bucket = 0; bucket < res->number_buckets; bucket++) {
|
|
||||||
for (le = res->buckets[bucket]; le != NULL; le = le->next) {
|
|
||||||
if (le->entry != NULL &&
|
|
||||||
(mode & NEXT_ENTRY_DEFERRED) == 0)
|
|
||||||
continue;
|
|
||||||
if (le->entry == NULL &&
|
|
||||||
(mode & NEXT_ENTRY_PARTIAL) == 0)
|
|
||||||
continue;
|
|
||||||
/* Remove it from this hash bucket. */
|
|
||||||
if (le->next != NULL)
|
|
||||||
le->next->previous = le->previous;
|
|
||||||
if (le->previous != NULL)
|
|
||||||
le->previous->next = le->next;
|
|
||||||
else
|
|
||||||
res->buckets[bucket] = le->next;
|
|
||||||
res->number_entries--;
|
|
||||||
/* Defer freeing this entry. */
|
|
||||||
res->spare = le;
|
|
||||||
return (le);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct links_entry *
|
|
||||||
insert_entry(struct archive_entry_linkresolver *res,
|
|
||||||
struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct links_entry *le;
|
|
||||||
size_t hash, bucket;
|
|
||||||
|
|
||||||
/* Add this entry to the links cache. */
|
|
||||||
le = calloc(1, sizeof(struct links_entry));
|
|
||||||
if (le == NULL)
|
|
||||||
return (NULL);
|
|
||||||
le->canonical = archive_entry_clone(entry);
|
|
||||||
|
|
||||||
/* If the links cache is getting too full, enlarge the hash table. */
|
|
||||||
if (res->number_entries > res->number_buckets * 2)
|
|
||||||
grow_hash(res);
|
|
||||||
|
|
||||||
hash = (size_t)(archive_entry_dev(entry) ^ archive_entry_ino64(entry));
|
|
||||||
bucket = hash & (res->number_buckets - 1);
|
|
||||||
|
|
||||||
/* If we could allocate the entry, record it. */
|
|
||||||
if (res->buckets[bucket] != NULL)
|
|
||||||
res->buckets[bucket]->previous = le;
|
|
||||||
res->number_entries++;
|
|
||||||
le->next = res->buckets[bucket];
|
|
||||||
le->previous = NULL;
|
|
||||||
res->buckets[bucket] = le;
|
|
||||||
le->hash = hash;
|
|
||||||
le->links = archive_entry_nlink(entry) - 1;
|
|
||||||
return (le);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
grow_hash(struct archive_entry_linkresolver *res)
|
|
||||||
{
|
|
||||||
struct links_entry *le, **new_buckets;
|
|
||||||
size_t new_size;
|
|
||||||
size_t i, bucket;
|
|
||||||
|
|
||||||
/* Try to enlarge the bucket list. */
|
|
||||||
new_size = res->number_buckets * 2;
|
|
||||||
if (new_size < res->number_buckets)
|
|
||||||
return;
|
|
||||||
new_buckets = calloc(new_size, sizeof(struct links_entry *));
|
|
||||||
|
|
||||||
if (new_buckets == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (i = 0; i < res->number_buckets; i++) {
|
|
||||||
while (res->buckets[i] != NULL) {
|
|
||||||
/* Remove entry from old bucket. */
|
|
||||||
le = res->buckets[i];
|
|
||||||
res->buckets[i] = le->next;
|
|
||||||
|
|
||||||
/* Add entry to new bucket. */
|
|
||||||
bucket = le->hash & (new_size - 1);
|
|
||||||
|
|
||||||
if (new_buckets[bucket] != NULL)
|
|
||||||
new_buckets[bucket]->previous = le;
|
|
||||||
le->next = new_buckets[bucket];
|
|
||||||
le->previous = NULL;
|
|
||||||
new_buckets[bucket] = le;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(res->buckets);
|
|
||||||
res->buckets = new_buckets;
|
|
||||||
res->number_buckets = new_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct archive_entry *
|
|
||||||
archive_entry_partial_links(struct archive_entry_linkresolver *res,
|
|
||||||
unsigned int *links)
|
|
||||||
{
|
|
||||||
struct archive_entry *e;
|
|
||||||
struct links_entry *le;
|
|
||||||
|
|
||||||
/* Free a held entry. */
|
|
||||||
if (res->spare != NULL) {
|
|
||||||
archive_entry_free(res->spare->canonical);
|
|
||||||
archive_entry_free(res->spare->entry);
|
|
||||||
free(res->spare);
|
|
||||||
res->spare = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
le = next_entry(res, NEXT_ENTRY_PARTIAL);
|
|
||||||
if (le != NULL) {
|
|
||||||
e = le->canonical;
|
|
||||||
if (links != NULL)
|
|
||||||
*links = le->links;
|
|
||||||
le->canonical = NULL;
|
|
||||||
} else {
|
|
||||||
e = NULL;
|
|
||||||
if (links != NULL)
|
|
||||||
*links = 0;
|
|
||||||
}
|
|
||||||
return (e);
|
|
||||||
}
|
|
92
3rdparty/libarchive/c/archive_entry_locale.h
vendored
92
3rdparty/libarchive/c/archive_entry_locale.h
vendored
@ -1,92 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2011 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ENTRY_LOCALE_H_INCLUDED
|
|
||||||
#define ARCHIVE_ENTRY_LOCALE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct archive_entry;
|
|
||||||
struct archive_string_conv;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Utility functions to set and get entry attributes by translating
|
|
||||||
* character-set. These are designed for use in format readers and writers.
|
|
||||||
*
|
|
||||||
* The return code and interface of these are quite different from other
|
|
||||||
* functions for archive_entry defined in archive_entry.h.
|
|
||||||
* Common return code are:
|
|
||||||
* Return 0 if the string conversion succeeded.
|
|
||||||
* Return -1 if the string conversion failed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define archive_entry_gname_l _archive_entry_gname_l
|
|
||||||
int _archive_entry_gname_l(struct archive_entry *,
|
|
||||||
const char **, size_t *, struct archive_string_conv *);
|
|
||||||
#define archive_entry_hardlink_l _archive_entry_hardlink_l
|
|
||||||
int _archive_entry_hardlink_l(struct archive_entry *,
|
|
||||||
const char **, size_t *, struct archive_string_conv *);
|
|
||||||
#define archive_entry_pathname_l _archive_entry_pathname_l
|
|
||||||
int _archive_entry_pathname_l(struct archive_entry *,
|
|
||||||
const char **, size_t *, struct archive_string_conv *);
|
|
||||||
#define archive_entry_symlink_l _archive_entry_symlink_l
|
|
||||||
int _archive_entry_symlink_l(struct archive_entry *,
|
|
||||||
const char **, size_t *, struct archive_string_conv *);
|
|
||||||
#define archive_entry_uname_l _archive_entry_uname_l
|
|
||||||
int _archive_entry_uname_l(struct archive_entry *,
|
|
||||||
const char **, size_t *, struct archive_string_conv *);
|
|
||||||
#define archive_entry_acl_text_l _archive_entry_acl_text_l
|
|
||||||
int _archive_entry_acl_text_l(struct archive_entry *, int,
|
|
||||||
const char **, size_t *, struct archive_string_conv *) __LA_DEPRECATED;
|
|
||||||
#define archive_entry_acl_to_text_l _archive_entry_acl_to_text_l
|
|
||||||
char *_archive_entry_acl_to_text_l(struct archive_entry *, ssize_t *, int,
|
|
||||||
struct archive_string_conv *);
|
|
||||||
#define archive_entry_acl_from_text_l _archive_entry_acl_from_text_l
|
|
||||||
int _archive_entry_acl_from_text_l(struct archive_entry *, const char* text,
|
|
||||||
int type, struct archive_string_conv *);
|
|
||||||
#define archive_entry_copy_gname_l _archive_entry_copy_gname_l
|
|
||||||
int _archive_entry_copy_gname_l(struct archive_entry *,
|
|
||||||
const char *, size_t, struct archive_string_conv *);
|
|
||||||
#define archive_entry_copy_hardlink_l _archive_entry_copy_hardlink_l
|
|
||||||
int _archive_entry_copy_hardlink_l(struct archive_entry *,
|
|
||||||
const char *, size_t, struct archive_string_conv *);
|
|
||||||
#define archive_entry_copy_link_l _archive_entry_copy_link_l
|
|
||||||
int _archive_entry_copy_link_l(struct archive_entry *,
|
|
||||||
const char *, size_t, struct archive_string_conv *);
|
|
||||||
#define archive_entry_copy_pathname_l _archive_entry_copy_pathname_l
|
|
||||||
int _archive_entry_copy_pathname_l(struct archive_entry *,
|
|
||||||
const char *, size_t, struct archive_string_conv *);
|
|
||||||
#define archive_entry_copy_symlink_l _archive_entry_copy_symlink_l
|
|
||||||
int _archive_entry_copy_symlink_l(struct archive_entry *,
|
|
||||||
const char *, size_t, struct archive_string_conv *);
|
|
||||||
#define archive_entry_copy_uname_l _archive_entry_copy_uname_l
|
|
||||||
int _archive_entry_copy_uname_l(struct archive_entry *,
|
|
||||||
const char *, size_t, struct archive_string_conv *);
|
|
||||||
|
|
||||||
#endif /* ARCHIVE_ENTRY_LOCALE_H_INCLUDED */
|
|
184
3rdparty/libarchive/c/archive_entry_private.h
vendored
184
3rdparty/libarchive/c/archive_entry_private.h
vendored
@ -1,184 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: head/lib/libarchive/archive_entry_private.h 201096 2009-12-28 02:41:27Z kientzle $
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_acl_private.h"
|
|
||||||
#include "archive_string.h"
|
|
||||||
|
|
||||||
struct ae_xattr {
|
|
||||||
struct ae_xattr *next;
|
|
||||||
|
|
||||||
char *name;
|
|
||||||
void *value;
|
|
||||||
size_t size;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ae_sparse {
|
|
||||||
struct ae_sparse *next;
|
|
||||||
|
|
||||||
int64_t offset;
|
|
||||||
int64_t length;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Description of an archive entry.
|
|
||||||
*
|
|
||||||
* Basically, this is a "struct stat" with a few text fields added in.
|
|
||||||
*
|
|
||||||
* TODO: Add "comment", "charset", and possibly other entries
|
|
||||||
* that are supported by "pax interchange" format. However, GNU, ustar,
|
|
||||||
* cpio, and other variants don't support these features, so they're not an
|
|
||||||
* excruciatingly high priority right now.
|
|
||||||
*
|
|
||||||
* TODO: "pax interchange" format allows essentially arbitrary
|
|
||||||
* key/value attributes to be attached to any entry. Supporting
|
|
||||||
* such extensions may make this library useful for special
|
|
||||||
* applications (e.g., a package manager could attach special
|
|
||||||
* package-management attributes to each entry). There are tricky
|
|
||||||
* API issues involved, so this is not going to happen until
|
|
||||||
* there's a real demand for it.
|
|
||||||
*
|
|
||||||
* TODO: Design a good API for handling sparse files.
|
|
||||||
*/
|
|
||||||
struct archive_entry {
|
|
||||||
struct archive *archive;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Note that ae_stat.st_mode & AE_IFMT can be 0!
|
|
||||||
*
|
|
||||||
* This occurs when the actual file type of the object is not
|
|
||||||
* in the archive. For example, 'tar' archives store
|
|
||||||
* hardlinks without marking the type of the underlying
|
|
||||||
* object.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We have a "struct aest" for holding file metadata rather than just
|
|
||||||
* a "struct stat" because on some platforms the "struct stat" has
|
|
||||||
* fields which are too narrow to hold the range of possible values;
|
|
||||||
* we don't want to lose information if we read an archive and write
|
|
||||||
* out another (e.g., in "tar -cf new.tar @old.tar").
|
|
||||||
*
|
|
||||||
* The "stat" pointer points to some form of platform-specific struct
|
|
||||||
* stat; it is declared as a void * rather than a struct stat * as
|
|
||||||
* some platforms have multiple varieties of stat structures.
|
|
||||||
*/
|
|
||||||
void *stat;
|
|
||||||
int stat_valid; /* Set to 0 whenever a field in aest changes. */
|
|
||||||
|
|
||||||
struct aest {
|
|
||||||
int64_t aest_atime;
|
|
||||||
uint32_t aest_atime_nsec;
|
|
||||||
int64_t aest_ctime;
|
|
||||||
uint32_t aest_ctime_nsec;
|
|
||||||
int64_t aest_mtime;
|
|
||||||
uint32_t aest_mtime_nsec;
|
|
||||||
int64_t aest_birthtime;
|
|
||||||
uint32_t aest_birthtime_nsec;
|
|
||||||
int64_t aest_gid;
|
|
||||||
int64_t aest_ino;
|
|
||||||
uint32_t aest_nlink;
|
|
||||||
uint64_t aest_size;
|
|
||||||
int64_t aest_uid;
|
|
||||||
/*
|
|
||||||
* Because converting between device codes and
|
|
||||||
* major/minor values is platform-specific and
|
|
||||||
* inherently a bit risky, we only do that conversion
|
|
||||||
* lazily. That way, we will do a better job of
|
|
||||||
* preserving information in those cases where no
|
|
||||||
* conversion is actually required.
|
|
||||||
*/
|
|
||||||
int aest_dev_is_broken_down;
|
|
||||||
dev_t aest_dev;
|
|
||||||
dev_t aest_devmajor;
|
|
||||||
dev_t aest_devminor;
|
|
||||||
int aest_rdev_is_broken_down;
|
|
||||||
dev_t aest_rdev;
|
|
||||||
dev_t aest_rdevmajor;
|
|
||||||
dev_t aest_rdevminor;
|
|
||||||
} ae_stat;
|
|
||||||
|
|
||||||
int ae_set; /* bitmap of fields that are currently set */
|
|
||||||
#define AE_SET_HARDLINK 1
|
|
||||||
#define AE_SET_SYMLINK 2
|
|
||||||
#define AE_SET_ATIME 4
|
|
||||||
#define AE_SET_CTIME 8
|
|
||||||
#define AE_SET_MTIME 16
|
|
||||||
#define AE_SET_BIRTHTIME 32
|
|
||||||
#define AE_SET_SIZE 64
|
|
||||||
#define AE_SET_INO 128
|
|
||||||
#define AE_SET_DEV 256
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use aes here so that we get transparent mbs<->wcs conversions.
|
|
||||||
*/
|
|
||||||
struct archive_mstring ae_fflags_text; /* Text fflags per fflagstostr(3) */
|
|
||||||
unsigned long ae_fflags_set; /* Bitmap fflags */
|
|
||||||
unsigned long ae_fflags_clear;
|
|
||||||
struct archive_mstring ae_gname; /* Name of owning group */
|
|
||||||
struct archive_mstring ae_hardlink; /* Name of target for hardlink */
|
|
||||||
struct archive_mstring ae_pathname; /* Name of entry */
|
|
||||||
struct archive_mstring ae_symlink; /* symlink contents */
|
|
||||||
struct archive_mstring ae_uname; /* Name of owner */
|
|
||||||
|
|
||||||
/* Not used within libarchive; useful for some clients. */
|
|
||||||
struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */
|
|
||||||
|
|
||||||
#define AE_ENCRYPTION_NONE 0
|
|
||||||
#define AE_ENCRYPTION_DATA 1
|
|
||||||
#define AE_ENCRYPTION_METADATA 2
|
|
||||||
char encryption;
|
|
||||||
|
|
||||||
void *mac_metadata;
|
|
||||||
size_t mac_metadata_size;
|
|
||||||
|
|
||||||
/* ACL support. */
|
|
||||||
struct archive_acl acl;
|
|
||||||
|
|
||||||
/* extattr support. */
|
|
||||||
struct ae_xattr *xattr_head;
|
|
||||||
struct ae_xattr *xattr_p;
|
|
||||||
|
|
||||||
/* sparse support. */
|
|
||||||
struct ae_sparse *sparse_head;
|
|
||||||
struct ae_sparse *sparse_tail;
|
|
||||||
struct ae_sparse *sparse_p;
|
|
||||||
|
|
||||||
/* Miscellaneous. */
|
|
||||||
char strmode[12];
|
|
||||||
|
|
||||||
/* Symlink type support */
|
|
||||||
int ae_symlink_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
|
|
156
3rdparty/libarchive/c/archive_entry_sparse.c
vendored
156
3rdparty/libarchive/c/archive_entry_sparse.c
vendored
@ -1,156 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* Copyright (c) 2010-2011 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD$");
|
|
||||||
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_entry_private.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* sparse handling
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_sparse_clear(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct ae_sparse *sp;
|
|
||||||
|
|
||||||
while (entry->sparse_head != NULL) {
|
|
||||||
sp = entry->sparse_head->next;
|
|
||||||
free(entry->sparse_head);
|
|
||||||
entry->sparse_head = sp;
|
|
||||||
}
|
|
||||||
entry->sparse_tail = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_sparse_add_entry(struct archive_entry *entry,
|
|
||||||
la_int64_t offset, la_int64_t length)
|
|
||||||
{
|
|
||||||
struct ae_sparse *sp;
|
|
||||||
|
|
||||||
if (offset < 0 || length < 0)
|
|
||||||
/* Invalid value */
|
|
||||||
return;
|
|
||||||
if (offset > INT64_MAX - length ||
|
|
||||||
offset + length > archive_entry_size(entry))
|
|
||||||
/* A value of "length" parameter is too large. */
|
|
||||||
return;
|
|
||||||
if ((sp = entry->sparse_tail) != NULL) {
|
|
||||||
if (sp->offset + sp->length > offset)
|
|
||||||
/* Invalid value. */
|
|
||||||
return;
|
|
||||||
if (sp->offset + sp->length == offset) {
|
|
||||||
if (sp->offset + sp->length + length < 0)
|
|
||||||
/* A value of "length" parameter is
|
|
||||||
* too large. */
|
|
||||||
return;
|
|
||||||
/* Expand existing sparse block size. */
|
|
||||||
sp->length += length;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sp = (struct ae_sparse *)malloc(sizeof(*sp))) == NULL)
|
|
||||||
/* XXX Error XXX */
|
|
||||||
return;
|
|
||||||
|
|
||||||
sp->offset = offset;
|
|
||||||
sp->length = length;
|
|
||||||
sp->next = NULL;
|
|
||||||
|
|
||||||
if (entry->sparse_head == NULL)
|
|
||||||
entry->sparse_head = entry->sparse_tail = sp;
|
|
||||||
else {
|
|
||||||
/* Add a new sparse block to the tail of list. */
|
|
||||||
if (entry->sparse_tail != NULL)
|
|
||||||
entry->sparse_tail->next = sp;
|
|
||||||
entry->sparse_tail = sp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* returns number of the sparse entries
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
archive_entry_sparse_count(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct ae_sparse *sp;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for (sp = entry->sparse_head; sp != NULL; sp = sp->next)
|
|
||||||
count++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sanity check if this entry is exactly sparse.
|
|
||||||
* If amount of sparse blocks is just one and it indicates the whole
|
|
||||||
* file data, we should remove it and return zero.
|
|
||||||
*/
|
|
||||||
if (count == 1) {
|
|
||||||
sp = entry->sparse_head;
|
|
||||||
if (sp->offset == 0 &&
|
|
||||||
sp->length >= archive_entry_size(entry)) {
|
|
||||||
count = 0;
|
|
||||||
archive_entry_sparse_clear(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (count);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_entry_sparse_reset(struct archive_entry * entry)
|
|
||||||
{
|
|
||||||
entry->sparse_p = entry->sparse_head;
|
|
||||||
|
|
||||||
return archive_entry_sparse_count(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_entry_sparse_next(struct archive_entry * entry,
|
|
||||||
la_int64_t *offset, la_int64_t *length)
|
|
||||||
{
|
|
||||||
if (entry->sparse_p) {
|
|
||||||
*offset = entry->sparse_p->offset;
|
|
||||||
*length = entry->sparse_p->length;
|
|
||||||
|
|
||||||
entry->sparse_p = entry->sparse_p->next;
|
|
||||||
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
} else {
|
|
||||||
*offset = 0;
|
|
||||||
*length = 0;
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* end of sparse handling
|
|
||||||
*/
|
|
118
3rdparty/libarchive/c/archive_entry_stat.c
vendored
118
3rdparty/libarchive/c/archive_entry_stat.c
vendored
@ -1,118 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_stat.c 201100 2009-12-28 03:05:31Z kientzle $");
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_entry_private.h"
|
|
||||||
|
|
||||||
const struct stat *
|
|
||||||
archive_entry_stat(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct stat *st;
|
|
||||||
if (entry->stat == NULL) {
|
|
||||||
entry->stat = calloc(1, sizeof(*st));
|
|
||||||
if (entry->stat == NULL)
|
|
||||||
return (NULL);
|
|
||||||
entry->stat_valid = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If none of the underlying fields have been changed, we
|
|
||||||
* don't need to regenerate. In theory, we could use a bitmap
|
|
||||||
* here to flag only those items that have changed, but the
|
|
||||||
* extra complexity probably isn't worth it. It will be very
|
|
||||||
* rare for anyone to change just one field then request a new
|
|
||||||
* stat structure.
|
|
||||||
*/
|
|
||||||
if (entry->stat_valid)
|
|
||||||
return (entry->stat);
|
|
||||||
|
|
||||||
st = entry->stat;
|
|
||||||
/*
|
|
||||||
* Use the public interfaces to extract items, so that
|
|
||||||
* the appropriate conversions get invoked.
|
|
||||||
*/
|
|
||||||
st->st_atime = archive_entry_atime(entry);
|
|
||||||
#if HAVE_STRUCT_STAT_ST_BIRTHTIME
|
|
||||||
st->st_birthtime = archive_entry_birthtime(entry);
|
|
||||||
#endif
|
|
||||||
st->st_ctime = archive_entry_ctime(entry);
|
|
||||||
st->st_mtime = archive_entry_mtime(entry);
|
|
||||||
st->st_dev = archive_entry_dev(entry);
|
|
||||||
st->st_gid = (gid_t)archive_entry_gid(entry);
|
|
||||||
st->st_uid = (uid_t)archive_entry_uid(entry);
|
|
||||||
st->st_ino = (ino_t)archive_entry_ino64(entry);
|
|
||||||
st->st_nlink = archive_entry_nlink(entry);
|
|
||||||
st->st_rdev = archive_entry_rdev(entry);
|
|
||||||
st->st_size = (off_t)archive_entry_size(entry);
|
|
||||||
st->st_mode = archive_entry_mode(entry);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* On systems that support high-res timestamps, copy that
|
|
||||||
* information into struct stat.
|
|
||||||
*/
|
|
||||||
#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
|
|
||||||
st->st_atimespec.tv_nsec = archive_entry_atime_nsec(entry);
|
|
||||||
st->st_ctimespec.tv_nsec = archive_entry_ctime_nsec(entry);
|
|
||||||
st->st_mtimespec.tv_nsec = archive_entry_mtime_nsec(entry);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
|
|
||||||
st->st_atim.tv_nsec = archive_entry_atime_nsec(entry);
|
|
||||||
st->st_ctim.tv_nsec = archive_entry_ctime_nsec(entry);
|
|
||||||
st->st_mtim.tv_nsec = archive_entry_mtime_nsec(entry);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIME_N
|
|
||||||
st->st_atime_n = archive_entry_atime_nsec(entry);
|
|
||||||
st->st_ctime_n = archive_entry_ctime_nsec(entry);
|
|
||||||
st->st_mtime_n = archive_entry_mtime_nsec(entry);
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_UMTIME
|
|
||||||
st->st_uatime = archive_entry_atime_nsec(entry) / 1000;
|
|
||||||
st->st_uctime = archive_entry_ctime_nsec(entry) / 1000;
|
|
||||||
st->st_umtime = archive_entry_mtime_nsec(entry) / 1000;
|
|
||||||
#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
|
|
||||||
st->st_atime_usec = archive_entry_atime_nsec(entry) / 1000;
|
|
||||||
st->st_ctime_usec = archive_entry_ctime_nsec(entry) / 1000;
|
|
||||||
st->st_mtime_usec = archive_entry_mtime_nsec(entry) / 1000;
|
|
||||||
#endif
|
|
||||||
#if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
|
|
||||||
st->st_birthtimespec.tv_nsec = archive_entry_birthtime_nsec(entry);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: On Linux, store 32 or 64 here depending on whether
|
|
||||||
* the cached stat structure is a stat32 or a stat64. This
|
|
||||||
* will allow us to support both variants interchangeably.
|
|
||||||
*/
|
|
||||||
entry->stat_valid = 1;
|
|
||||||
|
|
||||||
return (st);
|
|
||||||
}
|
|
87
3rdparty/libarchive/c/archive_entry_strmode.c
vendored
87
3rdparty/libarchive/c/archive_entry_strmode.c
vendored
@ -1,87 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_strmode.c,v 1.4 2008/06/15 05:14:01 kientzle Exp $");
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_entry_private.h"
|
|
||||||
|
|
||||||
const char *
|
|
||||||
archive_entry_strmode(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
static const mode_t permbits[] =
|
|
||||||
{ 0400, 0200, 0100, 0040, 0020, 0010, 0004, 0002, 0001 };
|
|
||||||
char *bp = entry->strmode;
|
|
||||||
mode_t mode;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Fill in a default string, then selectively override. */
|
|
||||||
strcpy(bp, "?rwxrwxrwx ");
|
|
||||||
|
|
||||||
mode = archive_entry_mode(entry);
|
|
||||||
switch (archive_entry_filetype(entry)) {
|
|
||||||
case AE_IFREG: bp[0] = '-'; break;
|
|
||||||
case AE_IFBLK: bp[0] = 'b'; break;
|
|
||||||
case AE_IFCHR: bp[0] = 'c'; break;
|
|
||||||
case AE_IFDIR: bp[0] = 'd'; break;
|
|
||||||
case AE_IFLNK: bp[0] = 'l'; break;
|
|
||||||
case AE_IFSOCK: bp[0] = 's'; break;
|
|
||||||
case AE_IFIFO: bp[0] = 'p'; break;
|
|
||||||
default:
|
|
||||||
if (archive_entry_hardlink(entry) != NULL) {
|
|
||||||
bp[0] = 'h';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 9; i++)
|
|
||||||
if (!(mode & permbits[i]))
|
|
||||||
bp[i+1] = '-';
|
|
||||||
|
|
||||||
if (mode & S_ISUID) {
|
|
||||||
if (mode & 0100) bp[3] = 's';
|
|
||||||
else bp[3] = 'S';
|
|
||||||
}
|
|
||||||
if (mode & S_ISGID) {
|
|
||||||
if (mode & 0010) bp[6] = 's';
|
|
||||||
else bp[6] = 'S';
|
|
||||||
}
|
|
||||||
if (mode & S_ISVTX) {
|
|
||||||
if (mode & 0001) bp[9] = 't';
|
|
||||||
else bp[9] = 'T';
|
|
||||||
}
|
|
||||||
if (archive_entry_acl_types(entry) != 0)
|
|
||||||
bp[10] = '+';
|
|
||||||
|
|
||||||
return (bp);
|
|
||||||
}
|
|
156
3rdparty/libarchive/c/archive_entry_xattr.c
vendored
156
3rdparty/libarchive/c/archive_entry_xattr.c
vendored
@ -1,156 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_xattr.c 201096 2009-12-28 02:41:27Z kientzle $");
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LIMITS_H
|
|
||||||
#include <limits.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_LINUX_FS_H
|
|
||||||
#include <linux/fs.h> /* for Linux file flags */
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
|
|
||||||
* As the include guards don't agree, the order of include is important.
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_LINUX_EXT2_FS_H
|
|
||||||
#include <linux/ext2_fs.h> /* for Linux file flags */
|
|
||||||
#endif
|
|
||||||
#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__)
|
|
||||||
#include <ext2fs/ext2_fs.h> /* for Linux file flags */
|
|
||||||
#endif
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_WCHAR_H
|
|
||||||
#include <wchar.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_entry.h"
|
|
||||||
#include "archive_private.h"
|
|
||||||
#include "archive_entry_private.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* extended attribute handling
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_xattr_clear(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct ae_xattr *xp;
|
|
||||||
|
|
||||||
while (entry->xattr_head != NULL) {
|
|
||||||
xp = entry->xattr_head->next;
|
|
||||||
free(entry->xattr_head->name);
|
|
||||||
free(entry->xattr_head->value);
|
|
||||||
free(entry->xattr_head);
|
|
||||||
entry->xattr_head = xp;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry->xattr_head = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
archive_entry_xattr_add_entry(struct archive_entry *entry,
|
|
||||||
const char *name, const void *value, size_t size)
|
|
||||||
{
|
|
||||||
struct ae_xattr *xp;
|
|
||||||
|
|
||||||
if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
|
|
||||||
__archive_errx(1, "Out of memory");
|
|
||||||
|
|
||||||
if ((xp->name = strdup(name)) == NULL)
|
|
||||||
__archive_errx(1, "Out of memory");
|
|
||||||
|
|
||||||
if ((xp->value = malloc(size)) != NULL) {
|
|
||||||
memcpy(xp->value, value, size);
|
|
||||||
xp->size = size;
|
|
||||||
} else
|
|
||||||
xp->size = 0;
|
|
||||||
|
|
||||||
xp->next = entry->xattr_head;
|
|
||||||
entry->xattr_head = xp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* returns number of the extended attribute entries
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
archive_entry_xattr_count(struct archive_entry *entry)
|
|
||||||
{
|
|
||||||
struct ae_xattr *xp;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
|
|
||||||
count++;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_entry_xattr_reset(struct archive_entry * entry)
|
|
||||||
{
|
|
||||||
entry->xattr_p = entry->xattr_head;
|
|
||||||
|
|
||||||
return archive_entry_xattr_count(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
archive_entry_xattr_next(struct archive_entry * entry,
|
|
||||||
const char **name, const void **value, size_t *size)
|
|
||||||
{
|
|
||||||
if (entry->xattr_p) {
|
|
||||||
*name = entry->xattr_p->name;
|
|
||||||
*value = entry->xattr_p->value;
|
|
||||||
*size = entry->xattr_p->size;
|
|
||||||
|
|
||||||
entry->xattr_p = entry->xattr_p->next;
|
|
||||||
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
} else {
|
|
||||||
*name = NULL;
|
|
||||||
*value = NULL;
|
|
||||||
*size = (size_t)0;
|
|
||||||
return (ARCHIVE_WARN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* end of xattr handling
|
|
||||||
*/
|
|
1165
3rdparty/libarchive/c/archive_getdate.c
vendored
1165
3rdparty/libarchive/c/archive_getdate.c
vendored
File diff suppressed because it is too large
Load Diff
39
3rdparty/libarchive/c/archive_getdate.h
vendored
39
3rdparty/libarchive/c/archive_getdate.h
vendored
@ -1,39 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2015 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_GETDATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_GETDATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
time_t __archive_get_date(time_t now, const char *);
|
|
||||||
|
|
||||||
#endif
|
|
305
3rdparty/libarchive/c/archive_hmac.c
vendored
305
3rdparty/libarchive/c/archive_hmac.c
vendored
@ -1,305 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#include "archive.h"
|
|
||||||
#include "archive_hmac_private.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* On systems that do not support any recognized crypto libraries,
|
|
||||||
* the archive_hmac.c file is expected to define no usable symbols.
|
|
||||||
*
|
|
||||||
* But some compilers and linkers choke on empty object files, so
|
|
||||||
* define a public symbol that will always exist. This could
|
|
||||||
* be removed someday if this file gains another always-present
|
|
||||||
* symbol definition.
|
|
||||||
*/
|
|
||||||
int __libarchive_hmac_build_hack(void) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
|
|
||||||
|
|
||||||
static int
|
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
CCHmacInit(ctx, kCCHmacAlgSHA1, key, key_len);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
|
||||||
size_t data_len)
|
|
||||||
{
|
|
||||||
CCHmacUpdate(ctx, data, data_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
|
||||||
{
|
|
||||||
CCHmacFinal(ctx, out);
|
|
||||||
*out_len = 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|
||||||
{
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
|
||||||
|
|
||||||
#ifndef BCRYPT_HASH_REUSABLE_FLAG
|
|
||||||
# define BCRYPT_HASH_REUSABLE_FLAG 0x00000020
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
|
||||||
#endif
|
|
||||||
BCRYPT_ALG_HANDLE hAlg;
|
|
||||||
BCRYPT_HASH_HANDLE hHash;
|
|
||||||
DWORD hash_len;
|
|
||||||
PBYTE hash;
|
|
||||||
ULONG result;
|
|
||||||
NTSTATUS status;
|
|
||||||
|
|
||||||
ctx->hAlg = NULL;
|
|
||||||
status = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_SHA1_ALGORITHM,
|
|
||||||
MS_PRIMITIVE_PROVIDER, BCRYPT_ALG_HANDLE_HMAC_FLAG);
|
|
||||||
if (!BCRYPT_SUCCESS(status))
|
|
||||||
return -1;
|
|
||||||
status = BCryptGetProperty(hAlg, BCRYPT_HASH_LENGTH, (PUCHAR)&hash_len,
|
|
||||||
sizeof(hash_len), &result, 0);
|
|
||||||
if (!BCRYPT_SUCCESS(status)) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
hash = (PBYTE)HeapAlloc(GetProcessHeap(), 0, hash_len);
|
|
||||||
if (hash == NULL) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
status = BCryptCreateHash(hAlg, &hHash, NULL, 0,
|
|
||||||
(PUCHAR)key, (ULONG)key_len, BCRYPT_HASH_REUSABLE_FLAG);
|
|
||||||
if (!BCRYPT_SUCCESS(status)) {
|
|
||||||
BCryptCloseAlgorithmProvider(hAlg, 0);
|
|
||||||
HeapFree(GetProcessHeap(), 0, hash);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->hAlg = hAlg;
|
|
||||||
ctx->hHash = hHash;
|
|
||||||
ctx->hash_len = hash_len;
|
|
||||||
ctx->hash = hash;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
|
||||||
size_t data_len)
|
|
||||||
{
|
|
||||||
BCryptHashData(ctx->hHash, (PUCHAR)(uintptr_t)data, (ULONG)data_len, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
|
||||||
{
|
|
||||||
BCryptFinishHash(ctx->hHash, ctx->hash, ctx->hash_len, 0);
|
|
||||||
if (ctx->hash_len == *out_len)
|
|
||||||
memcpy(out, ctx->hash, *out_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|
||||||
{
|
|
||||||
if (ctx->hAlg != NULL) {
|
|
||||||
BCryptCloseAlgorithmProvider(ctx->hAlg, 0);
|
|
||||||
HeapFree(GetProcessHeap(), 0, ctx->hash);
|
|
||||||
ctx->hAlg = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_MD_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
const mbedtls_md_info_t *info;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
mbedtls_md_init(ctx);
|
|
||||||
info = mbedtls_md_info_from_type(MBEDTLS_MD_SHA1);
|
|
||||||
if (info == NULL) {
|
|
||||||
mbedtls_md_free(ctx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
ret = mbedtls_md_setup(ctx, info, 1);
|
|
||||||
if (ret != 0) {
|
|
||||||
mbedtls_md_free(ctx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
ret = mbedtls_md_hmac_starts(ctx, key, key_len);
|
|
||||||
if (ret != 0) {
|
|
||||||
mbedtls_md_free(ctx);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
|
||||||
size_t data_len)
|
|
||||||
{
|
|
||||||
mbedtls_md_hmac_update(ctx, data, data_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
|
||||||
{
|
|
||||||
(void)out_len; /* UNUSED */
|
|
||||||
|
|
||||||
mbedtls_md_hmac_finish(ctx, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|
||||||
{
|
|
||||||
mbedtls_md_free(ctx);
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H)
|
|
||||||
|
|
||||||
static int
|
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
hmac_sha1_set_key(ctx, key_len, key);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
|
||||||
size_t data_len)
|
|
||||||
{
|
|
||||||
hmac_sha1_update(ctx, data_len, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
|
||||||
{
|
|
||||||
hmac_sha1_digest(ctx, (unsigned)*out_len, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|
||||||
{
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBCRYPTO)
|
|
||||||
|
|
||||||
static int
|
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
*ctx = HMAC_CTX_new();
|
|
||||||
if (*ctx == NULL)
|
|
||||||
return -1;
|
|
||||||
HMAC_Init_ex(*ctx, key, key_len, EVP_sha1(), NULL);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
|
||||||
size_t data_len)
|
|
||||||
{
|
|
||||||
HMAC_Update(*ctx, data, data_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
|
||||||
{
|
|
||||||
unsigned int len = (unsigned int)*out_len;
|
|
||||||
|
|
||||||
HMAC_Final(*ctx, out, &len);
|
|
||||||
*out_len = len;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|
||||||
{
|
|
||||||
HMAC_CTX_free(*ctx);
|
|
||||||
*ctx = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/* Stub */
|
|
||||||
static int
|
|
||||||
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
|
|
||||||
{
|
|
||||||
(void)ctx;/* UNUSED */
|
|
||||||
(void)key;/* UNUSED */
|
|
||||||
(void)key_len;/* UNUSED */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
|
|
||||||
size_t data_len)
|
|
||||||
{
|
|
||||||
(void)ctx;/* UNUSED */
|
|
||||||
(void)data;/* UNUSED */
|
|
||||||
(void)data_len;/* UNUSED */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
|
|
||||||
{
|
|
||||||
(void)ctx;/* UNUSED */
|
|
||||||
(void)out;/* UNUSED */
|
|
||||||
(void)out_len;/* UNUSED */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
|
|
||||||
{
|
|
||||||
(void)ctx;/* UNUSED */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const struct archive_hmac __archive_hmac = {
|
|
||||||
&__hmac_sha1_init,
|
|
||||||
&__hmac_sha1_update,
|
|
||||||
&__hmac_sha1_final,
|
|
||||||
&__hmac_sha1_cleanup,
|
|
||||||
};
|
|
110
3rdparty/libarchive/c/archive_hmac_private.h
vendored
110
3rdparty/libarchive/c/archive_hmac_private.h
vendored
@ -1,110 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2014 Michihiro NAKAJIMA
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_HMAC_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_HMAC_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* On systems that do not support any recognized crypto libraries,
|
|
||||||
* the archive_hmac.c file is expected to define no usable symbols.
|
|
||||||
*
|
|
||||||
* But some compilers and linkers choke on empty object files, so
|
|
||||||
* define a public symbol that will always exist. This could
|
|
||||||
* be removed someday if this file gains another always-present
|
|
||||||
* symbol definition.
|
|
||||||
*/
|
|
||||||
int __libarchive_hmac_build_hack(void);
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
# include <AvailabilityMacros.h>
|
|
||||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
# define ARCHIVE_HMAC_USE_Apple_CommonCrypto
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ARCHIVE_HMAC_USE_Apple_CommonCrypto
|
|
||||||
#include <CommonCrypto/CommonHMAC.h>
|
|
||||||
|
|
||||||
typedef CCHmacContext archive_hmac_sha1_ctx;
|
|
||||||
|
|
||||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
|
|
||||||
#include <bcrypt.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
BCRYPT_ALG_HANDLE hAlg;
|
|
||||||
BCRYPT_HASH_HANDLE hHash;
|
|
||||||
DWORD hash_len;
|
|
||||||
PBYTE hash;
|
|
||||||
|
|
||||||
} archive_hmac_sha1_ctx;
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBMBEDCRYPTO) && defined(HAVE_MBEDTLS_MD_H)
|
|
||||||
#include <mbedtls/md.h>
|
|
||||||
|
|
||||||
typedef mbedtls_md_context_t archive_hmac_sha1_ctx;
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H)
|
|
||||||
#include <nettle/hmac.h>
|
|
||||||
|
|
||||||
typedef struct hmac_sha1_ctx archive_hmac_sha1_ctx;
|
|
||||||
|
|
||||||
#elif defined(HAVE_LIBCRYPTO)
|
|
||||||
#include "archive_openssl_hmac_private.h"
|
|
||||||
|
|
||||||
typedef HMAC_CTX* archive_hmac_sha1_ctx;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
typedef int archive_hmac_sha1_ctx;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* HMAC */
|
|
||||||
#define archive_hmac_sha1_init(ctx, key, key_len)\
|
|
||||||
__archive_hmac.__hmac_sha1_init(ctx, key, key_len)
|
|
||||||
#define archive_hmac_sha1_update(ctx, data, data_len)\
|
|
||||||
__archive_hmac.__hmac_sha1_update(ctx, data, data_len)
|
|
||||||
#define archive_hmac_sha1_final(ctx, out, out_len)\
|
|
||||||
__archive_hmac.__hmac_sha1_final(ctx, out, out_len)
|
|
||||||
#define archive_hmac_sha1_cleanup(ctx)\
|
|
||||||
__archive_hmac.__hmac_sha1_cleanup(ctx)
|
|
||||||
|
|
||||||
|
|
||||||
struct archive_hmac {
|
|
||||||
/* HMAC */
|
|
||||||
int (*__hmac_sha1_init)(archive_hmac_sha1_ctx *, const uint8_t *,
|
|
||||||
size_t);
|
|
||||||
void (*__hmac_sha1_update)(archive_hmac_sha1_ctx *, const uint8_t *,
|
|
||||||
size_t);
|
|
||||||
void (*__hmac_sha1_final)(archive_hmac_sha1_ctx *, uint8_t *, size_t *);
|
|
||||||
void (*__hmac_sha1_cleanup)(archive_hmac_sha1_ctx *);
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const struct archive_hmac __archive_hmac;
|
|
||||||
#endif /* ARCHIVE_HMAC_PRIVATE_H_INCLUDED */
|
|
1875
3rdparty/libarchive/c/archive_match.c
vendored
1875
3rdparty/libarchive/c/archive_match.c
vendored
File diff suppressed because it is too large
Load Diff
@ -1,53 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_OPENSSL_EVP_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <openssl/evp.h>
|
|
||||||
#include <openssl/opensslv.h>
|
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
||||||
#include <stdlib.h> /* malloc, free */
|
|
||||||
#include <string.h> /* memset */
|
|
||||||
static inline EVP_MD_CTX *EVP_MD_CTX_new(void)
|
|
||||||
{
|
|
||||||
EVP_MD_CTX *ctx = (EVP_MD_CTX *)calloc(1, sizeof(EVP_MD_CTX));
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
|
|
||||||
{
|
|
||||||
EVP_MD_CTX_cleanup(ctx);
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
free(ctx);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_OPENSSL_HMAC_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <openssl/hmac.h>
|
|
||||||
#include <openssl/opensslv.h>
|
|
||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
|
|
||||||
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
|
|
||||||
#include <stdlib.h> /* malloc, free */
|
|
||||||
#include <string.h> /* memset */
|
|
||||||
static inline HMAC_CTX *HMAC_CTX_new(void)
|
|
||||||
{
|
|
||||||
HMAC_CTX *ctx = (HMAC_CTX *)calloc(1, sizeof(HMAC_CTX));
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void HMAC_CTX_free(HMAC_CTX *ctx)
|
|
||||||
{
|
|
||||||
HMAC_CTX_cleanup(ctx);
|
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
|
||||||
free(ctx);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
218
3rdparty/libarchive/c/archive_options.c
vendored
218
3rdparty/libarchive/c/archive_options.c
vendored
@ -1,218 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2011 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD$");
|
|
||||||
|
|
||||||
#ifdef HAVE_ERRNO_H
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_options_private.h"
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
parse_option(const char **str,
|
|
||||||
const char **mod, const char **opt, const char **val);
|
|
||||||
|
|
||||||
int
|
|
||||||
_archive_set_option(struct archive *a,
|
|
||||||
const char *m, const char *o, const char *v,
|
|
||||||
int magic, const char *fn, option_handler use_option)
|
|
||||||
{
|
|
||||||
const char *mp, *op, *vp;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
archive_check_magic(a, magic, ARCHIVE_STATE_NEW, fn);
|
|
||||||
|
|
||||||
mp = (m != NULL && m[0] != '\0') ? m : NULL;
|
|
||||||
op = (o != NULL && o[0] != '\0') ? o : NULL;
|
|
||||||
vp = (v != NULL && v[0] != '\0') ? v : NULL;
|
|
||||||
|
|
||||||
if (op == NULL && vp == NULL)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
if (op == NULL) {
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC, "Empty option");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
r = use_option(a, mp, op, vp);
|
|
||||||
if (r == ARCHIVE_WARN - 1) {
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unknown module name: `%s'", mp);
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
if (r == ARCHIVE_WARN) {
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Undefined option: `%s%s%s%s%s%s'",
|
|
||||||
vp?"":"!", mp?mp:"", mp?":":"", op, vp?"=":"", vp?vp:"");
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
return (r);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
_archive_set_either_option(struct archive *a, const char *m, const char *o, const char *v,
|
|
||||||
option_handler use_format_option, option_handler use_filter_option)
|
|
||||||
{
|
|
||||||
int r1, r2;
|
|
||||||
|
|
||||||
if (o == NULL && v == NULL)
|
|
||||||
return (ARCHIVE_OK);
|
|
||||||
if (o == NULL)
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
|
|
||||||
r1 = use_format_option(a, m, o, v);
|
|
||||||
if (r1 == ARCHIVE_FATAL)
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
|
|
||||||
r2 = use_filter_option(a, m, o, v);
|
|
||||||
if (r2 == ARCHIVE_FATAL)
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
|
|
||||||
if (r2 == ARCHIVE_WARN - 1)
|
|
||||||
return r1;
|
|
||||||
return r1 > r2 ? r1 : r2;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
_archive_set_options(struct archive *a, const char *options,
|
|
||||||
int magic, const char *fn, option_handler use_option)
|
|
||||||
{
|
|
||||||
int allok = 1, anyok = 0, ignore_mod_err = 0, r;
|
|
||||||
char *data;
|
|
||||||
const char *s, *mod, *opt, *val;
|
|
||||||
|
|
||||||
archive_check_magic(a, magic, ARCHIVE_STATE_NEW, fn);
|
|
||||||
|
|
||||||
if (options == NULL || options[0] == '\0')
|
|
||||||
return ARCHIVE_OK;
|
|
||||||
|
|
||||||
if ((data = strdup(options)) == NULL) {
|
|
||||||
archive_set_error(a,
|
|
||||||
ENOMEM, "Out of memory adding file to list");
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
}
|
|
||||||
s = (const char *)data;
|
|
||||||
|
|
||||||
do {
|
|
||||||
mod = opt = val = NULL;
|
|
||||||
|
|
||||||
parse_option(&s, &mod, &opt, &val);
|
|
||||||
if (mod == NULL && opt != NULL &&
|
|
||||||
strcmp("__ignore_wrong_module_name__", opt) == 0) {
|
|
||||||
/* Ignore module name error */
|
|
||||||
if (val != NULL) {
|
|
||||||
ignore_mod_err = 1;
|
|
||||||
anyok = 1;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = use_option(a, mod, opt, val);
|
|
||||||
if (r == ARCHIVE_FATAL) {
|
|
||||||
free(data);
|
|
||||||
return (ARCHIVE_FATAL);
|
|
||||||
}
|
|
||||||
if (r == ARCHIVE_FAILED && mod != NULL) {
|
|
||||||
free(data);
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
if (r == ARCHIVE_WARN - 1) {
|
|
||||||
if (ignore_mod_err)
|
|
||||||
continue;
|
|
||||||
/* The module name is wrong. */
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Unknown module name: `%s'", mod);
|
|
||||||
free(data);
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
if (r == ARCHIVE_WARN) {
|
|
||||||
/* The option name is wrong. No-one used this. */
|
|
||||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
|
||||||
"Undefined option: `%s%s%s'",
|
|
||||||
mod?mod:"", mod?":":"", opt);
|
|
||||||
free(data);
|
|
||||||
return (ARCHIVE_FAILED);
|
|
||||||
}
|
|
||||||
if (r == ARCHIVE_OK)
|
|
||||||
anyok = 1;
|
|
||||||
else
|
|
||||||
allok = 0;
|
|
||||||
} while (s != NULL);
|
|
||||||
|
|
||||||
free(data);
|
|
||||||
return allok ? ARCHIVE_OK : anyok ? ARCHIVE_WARN : ARCHIVE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
parse_option(const char **s, const char **m, const char **o, const char **v)
|
|
||||||
{
|
|
||||||
const char *end, *mod, *opt, *val;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
end = NULL;
|
|
||||||
mod = NULL;
|
|
||||||
opt = *s;
|
|
||||||
val = "1";
|
|
||||||
|
|
||||||
p = strchr(opt, ',');
|
|
||||||
|
|
||||||
if (p != NULL) {
|
|
||||||
*p = '\0';
|
|
||||||
end = ((const char *)p) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 == strlen(opt)) {
|
|
||||||
*s = end;
|
|
||||||
*m = NULL;
|
|
||||||
*o = NULL;
|
|
||||||
*v = NULL;
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = strchr(opt, ':');
|
|
||||||
if (p != NULL) {
|
|
||||||
*p = '\0';
|
|
||||||
mod = opt;
|
|
||||||
opt = ++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = strchr(opt, '=');
|
|
||||||
if (p != NULL) {
|
|
||||||
*p = '\0';
|
|
||||||
val = ++p;
|
|
||||||
} else if (opt[0] == '!') {
|
|
||||||
++opt;
|
|
||||||
val = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*s = end;
|
|
||||||
*m = mod;
|
|
||||||
*o = opt;
|
|
||||||
*v = val;
|
|
||||||
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
51
3rdparty/libarchive/c/archive_options_private.h
vendored
51
3rdparty/libarchive/c/archive_options_private.h
vendored
@ -1,51 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2011 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_OPTIONS_PRIVATE_H_INCLUDED
|
|
||||||
#define ARCHIVE_OPTIONS_PRIVATE_H_INCLUDED
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD$");
|
|
||||||
|
|
||||||
#include "archive_private.h"
|
|
||||||
|
|
||||||
typedef int (*option_handler)(struct archive *a,
|
|
||||||
const char *mod, const char *opt, const char *val);
|
|
||||||
|
|
||||||
int
|
|
||||||
_archive_set_option(struct archive *a,
|
|
||||||
const char *mod, const char *opt, const char *val,
|
|
||||||
int magic, const char *fn, option_handler use_option);
|
|
||||||
|
|
||||||
int
|
|
||||||
_archive_set_options(struct archive *a, const char *options,
|
|
||||||
int magic, const char *fn, option_handler use_option);
|
|
||||||
|
|
||||||
int
|
|
||||||
_archive_set_either_option(struct archive *a,
|
|
||||||
const char *m, const char *o, const char *v,
|
|
||||||
option_handler use_format_option, option_handler use_filter_option);
|
|
||||||
|
|
||||||
#endif
|
|
336
3rdparty/libarchive/c/archive_pack_dev.c
vendored
336
3rdparty/libarchive/c/archive_pack_dev.c
vendored
@ -1,336 +0,0 @@
|
|||||||
/* $NetBSD: pack_dev.c,v 1.12 2013/06/14 16:28:20 tsutsui Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Charles M. Hannum.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Originally from NetBSD's mknod(8) source. */
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
|
|
||||||
#if HAVE_SYS_CDEFS_H
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#endif
|
|
||||||
#if !defined(lint)
|
|
||||||
__RCSID("$NetBSD$");
|
|
||||||
#endif /* not lint */
|
|
||||||
|
|
||||||
#ifdef HAVE_LIMITS_H
|
|
||||||
#include <limits.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef HAVE_STDLIB_H
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#endif
|
|
||||||
#if MAJOR_IN_MKDEV
|
|
||||||
#include <sys/mkdev.h>
|
|
||||||
#define HAVE_MAJOR
|
|
||||||
#elif MAJOR_IN_SYSMACROS
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#define HAVE_MAJOR
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_pack_dev.h"
|
|
||||||
|
|
||||||
static pack_t pack_netbsd;
|
|
||||||
static pack_t pack_freebsd;
|
|
||||||
static pack_t pack_8_8;
|
|
||||||
static pack_t pack_12_20;
|
|
||||||
static pack_t pack_14_18;
|
|
||||||
static pack_t pack_8_24;
|
|
||||||
static pack_t pack_bsdos;
|
|
||||||
static int compare_format(const void *, const void *);
|
|
||||||
|
|
||||||
static const char iMajorError[] = "invalid major number";
|
|
||||||
static const char iMinorError[] = "invalid minor number";
|
|
||||||
static const char tooManyFields[] = "too many fields for format";
|
|
||||||
|
|
||||||
/* This is blatantly stolen from libarchive/archive_entry.c,
|
|
||||||
* in an attempt to get this to play nice on MinGW... */
|
|
||||||
#if !defined(HAVE_MAJOR) && !defined(major)
|
|
||||||
/* Replacement for major/minor/makedev. */
|
|
||||||
#define major(x) ((int)(0x00ff & ((x) >> 8)))
|
|
||||||
#define minor(x) ((int)(0xffff00ff & (x)))
|
|
||||||
#define makedev(maj,min) ((0xff00 & ((maj)<<8)) | (0xffff00ff & (min)))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Play games to come up with a suitable makedev() definition. */
|
|
||||||
#ifdef __QNXNTO__
|
|
||||||
/* QNX. <sigh> */
|
|
||||||
#include <sys/netmgr.h>
|
|
||||||
#define apd_makedev(maj, min) makedev(ND_LOCAL_NODE, (maj), (min))
|
|
||||||
#elif defined makedev
|
|
||||||
/* There's a "makedev" macro. */
|
|
||||||
#define apd_makedev(maj, min) makedev((maj), (min))
|
|
||||||
#elif defined mkdev || ((defined _WIN32 || defined __WIN32__) && !defined(__CYGWIN__))
|
|
||||||
/* Windows. <sigh> */
|
|
||||||
#define apd_makedev(maj, min) mkdev((maj), (min))
|
|
||||||
#else
|
|
||||||
/* There's a "makedev" function. */
|
|
||||||
#define apd_makedev(maj, min) makedev((maj), (min))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* exported */
|
|
||||||
dev_t
|
|
||||||
pack_native(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = apd_makedev(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
else if ((unsigned long)minor(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_netbsd(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_netbsd(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_netbsd(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
else if ((unsigned long)minor_netbsd(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define major_freebsd(x) ((int32_t)(((x) & 0x0000ff00) >> 8))
|
|
||||||
#define minor_freebsd(x) ((int32_t)(((x) & 0xffff00ff) >> 0))
|
|
||||||
#define makedev_freebsd(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \
|
|
||||||
(((y) << 0) & 0xffff00ff)))
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_freebsd(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_freebsd(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_freebsd(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)minor_freebsd(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define major_8_8(x) ((int32_t)(((x) & 0x0000ff00) >> 8))
|
|
||||||
#define minor_8_8(x) ((int32_t)(((x) & 0x000000ff) >> 0))
|
|
||||||
#define makedev_8_8(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \
|
|
||||||
(((y) << 0) & 0x000000ff)))
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_8_8(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_8_8(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_8_8(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)minor_8_8(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define major_12_20(x) ((int32_t)(((x) & 0xfff00000) >> 20))
|
|
||||||
#define minor_12_20(x) ((int32_t)(((x) & 0x000fffff) >> 0))
|
|
||||||
#define makedev_12_20(x,y) ((dev_t)((((x) << 20) & 0xfff00000) | \
|
|
||||||
(((y) << 0) & 0x000fffff)))
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_12_20(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_12_20(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_12_20(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)minor_12_20(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define major_14_18(x) ((int32_t)(((x) & 0xfffc0000) >> 18))
|
|
||||||
#define minor_14_18(x) ((int32_t)(((x) & 0x0003ffff) >> 0))
|
|
||||||
#define makedev_14_18(x,y) ((dev_t)((((x) << 18) & 0xfffc0000) | \
|
|
||||||
(((y) << 0) & 0x0003ffff)))
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_14_18(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_14_18(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_14_18(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)minor_14_18(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define major_8_24(x) ((int32_t)(((x) & 0xff000000) >> 24))
|
|
||||||
#define minor_8_24(x) ((int32_t)(((x) & 0x00ffffff) >> 0))
|
|
||||||
#define makedev_8_24(x,y) ((dev_t)((((x) << 24) & 0xff000000) | \
|
|
||||||
(((y) << 0) & 0x00ffffff)))
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_8_24(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_8_24(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_8_24(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)minor_8_24(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define major_12_12_8(x) ((int32_t)(((x) & 0xfff00000) >> 20))
|
|
||||||
#define unit_12_12_8(x) ((int32_t)(((x) & 0x000fff00) >> 8))
|
|
||||||
#define subunit_12_12_8(x) ((int32_t)(((x) & 0x000000ff) >> 0))
|
|
||||||
#define makedev_12_12_8(x,y,z) ((dev_t)((((x) << 20) & 0xfff00000) | \
|
|
||||||
(((y) << 8) & 0x000fff00) | \
|
|
||||||
(((z) << 0) & 0x000000ff)))
|
|
||||||
|
|
||||||
static dev_t
|
|
||||||
pack_bsdos(int n, unsigned long numbers[], const char **error)
|
|
||||||
{
|
|
||||||
dev_t dev = 0;
|
|
||||||
|
|
||||||
if (n == 2) {
|
|
||||||
dev = makedev_12_20(numbers[0], numbers[1]);
|
|
||||||
if ((unsigned long)major_12_20(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)minor_12_20(dev) != numbers[1])
|
|
||||||
*error = iMinorError;
|
|
||||||
} else if (n == 3) {
|
|
||||||
dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]);
|
|
||||||
if ((unsigned long)major_12_12_8(dev) != numbers[0])
|
|
||||||
*error = iMajorError;
|
|
||||||
if ((unsigned long)unit_12_12_8(dev) != numbers[1])
|
|
||||||
*error = "invalid unit number";
|
|
||||||
if ((unsigned long)subunit_12_12_8(dev) != numbers[2])
|
|
||||||
*error = "invalid subunit number";
|
|
||||||
} else
|
|
||||||
*error = tooManyFields;
|
|
||||||
return (dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* list of formats and pack functions */
|
|
||||||
/* this list must be sorted lexically */
|
|
||||||
static const struct format {
|
|
||||||
const char *name;
|
|
||||||
pack_t *pack;
|
|
||||||
} formats[] = {
|
|
||||||
{"386bsd", pack_8_8},
|
|
||||||
{"4bsd", pack_8_8},
|
|
||||||
{"bsdos", pack_bsdos},
|
|
||||||
{"freebsd", pack_freebsd},
|
|
||||||
{"hpux", pack_8_24},
|
|
||||||
{"isc", pack_8_8},
|
|
||||||
{"linux", pack_8_8},
|
|
||||||
{"native", pack_native},
|
|
||||||
{"netbsd", pack_netbsd},
|
|
||||||
{"osf1", pack_12_20},
|
|
||||||
{"sco", pack_8_8},
|
|
||||||
{"solaris", pack_14_18},
|
|
||||||
{"sunos", pack_8_8},
|
|
||||||
{"svr3", pack_8_8},
|
|
||||||
{"svr4", pack_14_18},
|
|
||||||
{"ultrix", pack_8_8},
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
|
||||||
compare_format(const void *key, const void *element)
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
const struct format *format;
|
|
||||||
|
|
||||||
name = key;
|
|
||||||
format = element;
|
|
||||||
|
|
||||||
return (strcmp(name, format->name));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pack_t *
|
|
||||||
pack_find(const char *name)
|
|
||||||
{
|
|
||||||
struct format *format;
|
|
||||||
|
|
||||||
format = bsearch(name, formats,
|
|
||||||
sizeof(formats)/sizeof(formats[0]),
|
|
||||||
sizeof(formats[0]), compare_format);
|
|
||||||
if (format == 0)
|
|
||||||
return (NULL);
|
|
||||||
return (format->pack);
|
|
||||||
}
|
|
49
3rdparty/libarchive/c/archive_pack_dev.h
vendored
49
3rdparty/libarchive/c/archive_pack_dev.h
vendored
@ -1,49 +0,0 @@
|
|||||||
/* $NetBSD: pack_dev.h,v 1.8 2013/06/14 16:28:20 tsutsui Exp $ */
|
|
||||||
|
|
||||||
/*-
|
|
||||||
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
* by Charles M. Hannum.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Originally from NetBSD's mknod(8) source. */
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_PACK_DEV_H
|
|
||||||
#define ARCHIVE_PACK_DEV_H
|
|
||||||
|
|
||||||
typedef dev_t pack_t(int, unsigned long [], const char **);
|
|
||||||
|
|
||||||
pack_t *pack_find(const char *);
|
|
||||||
pack_t pack_native;
|
|
||||||
|
|
||||||
#define major_netbsd(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
|
|
||||||
#define minor_netbsd(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
|
|
||||||
(((x) & 0x000000ff) >> 0)))
|
|
||||||
#define makedev_netbsd(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
|
|
||||||
(((y) << 12) & 0xfff00000) | \
|
|
||||||
(((y) << 0) & 0x000000ff)))
|
|
||||||
|
|
||||||
#endif /* ARCHIVE_PACK_DEV_H */
|
|
459
3rdparty/libarchive/c/archive_pathmatch.c
vendored
459
3rdparty/libarchive/c/archive_pathmatch.c
vendored
@ -1,459 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer
|
|
||||||
* in this position and unchanged.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "archive_platform.h"
|
|
||||||
__FBSDID("$FreeBSD$");
|
|
||||||
|
|
||||||
#ifdef HAVE_STRING_H
|
|
||||||
#include <string.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_WCHAR_H
|
|
||||||
#include <wchar.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "archive_pathmatch.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check whether a character 'c' is matched by a list specification [...]:
|
|
||||||
* * Leading '!' or '^' negates the class.
|
|
||||||
* * <char>-<char> is a range of characters
|
|
||||||
* * \<char> removes any special meaning for <char>
|
|
||||||
*
|
|
||||||
* Some interesting boundary cases:
|
|
||||||
* a-d-e is one range (a-d) followed by two single characters - and e.
|
|
||||||
* \a-\d is same as a-d
|
|
||||||
* a\-d is three single characters: a, d, -
|
|
||||||
* Trailing - is not special (so [a-] is two characters a and -).
|
|
||||||
* Initial - is not special ([a-] is same as [-a] is same as [\\-a])
|
|
||||||
* This function never sees a trailing \.
|
|
||||||
* [] always fails
|
|
||||||
* [!] always succeeds
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
pm_list(const char *start, const char *end, const char c, int flags)
|
|
||||||
{
|
|
||||||
const char *p = start;
|
|
||||||
char rangeStart = '\0', nextRangeStart;
|
|
||||||
int match = 1, nomatch = 0;
|
|
||||||
|
|
||||||
/* This will be used soon... */
|
|
||||||
(void)flags; /* UNUSED */
|
|
||||||
|
|
||||||
/* If this is a negated class, return success for nomatch. */
|
|
||||||
if ((*p == '!' || *p == '^') && p < end) {
|
|
||||||
match = 0;
|
|
||||||
nomatch = 1;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (p < end) {
|
|
||||||
nextRangeStart = '\0';
|
|
||||||
switch (*p) {
|
|
||||||
case '-':
|
|
||||||
/* Trailing or initial '-' is not special. */
|
|
||||||
if ((rangeStart == '\0') || (p == end - 1)) {
|
|
||||||
if (*p == c)
|
|
||||||
return (match);
|
|
||||||
} else {
|
|
||||||
char rangeEnd = *++p;
|
|
||||||
if (rangeEnd == '\\')
|
|
||||||
rangeEnd = *++p;
|
|
||||||
if ((rangeStart <= c) && (c <= rangeEnd))
|
|
||||||
return (match);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
++p;
|
|
||||||
/* Fall through */
|
|
||||||
default:
|
|
||||||
if (*p == c)
|
|
||||||
return (match);
|
|
||||||
nextRangeStart = *p; /* Possible start of range. */
|
|
||||||
}
|
|
||||||
rangeStart = nextRangeStart;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
return (nomatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
pm_list_w(const wchar_t *start, const wchar_t *end, const wchar_t c, int flags)
|
|
||||||
{
|
|
||||||
const wchar_t *p = start;
|
|
||||||
wchar_t rangeStart = L'\0', nextRangeStart;
|
|
||||||
int match = 1, nomatch = 0;
|
|
||||||
|
|
||||||
/* This will be used soon... */
|
|
||||||
(void)flags; /* UNUSED */
|
|
||||||
|
|
||||||
/* If this is a negated class, return success for nomatch. */
|
|
||||||
if ((*p == L'!' || *p == L'^') && p < end) {
|
|
||||||
match = 0;
|
|
||||||
nomatch = 1;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (p < end) {
|
|
||||||
nextRangeStart = L'\0';
|
|
||||||
switch (*p) {
|
|
||||||
case L'-':
|
|
||||||
/* Trailing or initial '-' is not special. */
|
|
||||||
if ((rangeStart == L'\0') || (p == end - 1)) {
|
|
||||||
if (*p == c)
|
|
||||||
return (match);
|
|
||||||
} else {
|
|
||||||
wchar_t rangeEnd = *++p;
|
|
||||||
if (rangeEnd == L'\\')
|
|
||||||
rangeEnd = *++p;
|
|
||||||
if ((rangeStart <= c) && (c <= rangeEnd))
|
|
||||||
return (match);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case L'\\':
|
|
||||||
++p;
|
|
||||||
/* Fall through */
|
|
||||||
default:
|
|
||||||
if (*p == c)
|
|
||||||
return (match);
|
|
||||||
nextRangeStart = *p; /* Possible start of range. */
|
|
||||||
}
|
|
||||||
rangeStart = nextRangeStart;
|
|
||||||
++p;
|
|
||||||
}
|
|
||||||
return (nomatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If s is pointing to "./", ".//", "./././" or the like, skip it.
|
|
||||||
*/
|
|
||||||
static const char *
|
|
||||||
pm_slashskip(const char *s) {
|
|
||||||
while ((*s == '/')
|
|
||||||
|| (s[0] == '.' && s[1] == '/')
|
|
||||||
|| (s[0] == '.' && s[1] == '\0'))
|
|
||||||
++s;
|
|
||||||
return (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const wchar_t *
|
|
||||||
pm_slashskip_w(const wchar_t *s) {
|
|
||||||
while ((*s == L'/')
|
|
||||||
|| (s[0] == L'.' && s[1] == L'/')
|
|
||||||
|| (s[0] == L'.' && s[1] == L'\0'))
|
|
||||||
++s;
|
|
||||||
return (s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
pm(const char *p, const char *s, int flags)
|
|
||||||
{
|
|
||||||
const char *end;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ignore leading './', './/', '././', etc.
|
|
||||||
*/
|
|
||||||
if (s[0] == '.' && s[1] == '/')
|
|
||||||
s = pm_slashskip(s + 1);
|
|
||||||
if (p[0] == '.' && p[1] == '/')
|
|
||||||
p = pm_slashskip(p + 1);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
switch (*p) {
|
|
||||||
case '\0':
|
|
||||||
if (s[0] == '/') {
|
|
||||||
if (flags & PATHMATCH_NO_ANCHOR_END)
|
|
||||||
return (1);
|
|
||||||
/* "dir" == "dir/" == "dir/." */
|
|
||||||
s = pm_slashskip(s);
|
|
||||||
}
|
|
||||||
return (*s == '\0');
|
|
||||||
case '?':
|
|
||||||
/* ? always succeeds, unless we hit end of 's' */
|
|
||||||
if (*s == '\0')
|
|
||||||
return (0);
|
|
||||||
break;
|
|
||||||
case '*':
|
|
||||||
/* "*" == "**" == "***" ... */
|
|
||||||
while (*p == '*')
|
|
||||||
++p;
|
|
||||||
/* Trailing '*' always succeeds. */
|
|
||||||
if (*p == '\0')
|
|
||||||
return (1);
|
|
||||||
while (*s) {
|
|
||||||
if (archive_pathmatch(p, s, flags))
|
|
||||||
return (1);
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
case '[':
|
|
||||||
/*
|
|
||||||
* Find the end of the [...] character class,
|
|
||||||
* ignoring \] that might occur within the class.
|
|
||||||
*/
|
|
||||||
end = p + 1;
|
|
||||||
while (*end != '\0' && *end != ']') {
|
|
||||||
if (*end == '\\' && end[1] != '\0')
|
|
||||||
++end;
|
|
||||||
++end;
|
|
||||||
}
|
|
||||||
if (*end == ']') {
|
|
||||||
/* We found [...], try to match it. */
|
|
||||||
if (!pm_list(p + 1, end, *s, flags))
|
|
||||||
return (0);
|
|
||||||
p = end; /* Jump to trailing ']' char. */
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
/* No final ']', so just match '['. */
|
|
||||||
if (*p != *s)
|
|
||||||
return (0);
|
|
||||||
break;
|
|
||||||
case '\\':
|
|
||||||
/* Trailing '\\' matches itself. */
|
|
||||||
if (p[1] == '\0') {
|
|
||||||
if (*s != '\\')
|
|
||||||
return (0);
|
|
||||||
} else {
|
|
||||||
++p;
|
|
||||||
if (*p != *s)
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '/':
|
|
||||||
if (*s != '/' && *s != '\0')
|
|
||||||
return (0);
|
|
||||||
/* Note: pattern "/\./" won't match "/";
|
|
||||||
* pm_slashskip() correctly stops at backslash. */
|
|
||||||
p = pm_slashskip(p);
|
|
||||||
s = pm_slashskip(s);
|
|
||||||
if (*p == '\0' && (flags & PATHMATCH_NO_ANCHOR_END))
|
|
||||||
return (1);
|
|
||||||
--p; /* Counteract the increment below. */
|
|
||||||
--s;
|
|
||||||
break;
|
|
||||||
case '$':
|
|
||||||
/* '$' is special only at end of pattern and only
|
|
||||||
* if PATHMATCH_NO_ANCHOR_END is specified. */
|
|
||||||
if (p[1] == '\0' && (flags & PATHMATCH_NO_ANCHOR_END)){
|
|
||||||
/* "dir" == "dir/" == "dir/." */
|
|
||||||
return (*pm_slashskip(s) == '\0');
|
|
||||||
}
|
|
||||||
/* Otherwise, '$' is not special. */
|
|
||||||
/* FALL THROUGH */
|
|
||||||
default:
|
|
||||||
if (*p != *s)
|
|
||||||
return (0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++p;
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
pm_w(const wchar_t *p, const wchar_t *s, int flags)
|
|
||||||
{
|
|
||||||
const wchar_t *end;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ignore leading './', './/', '././', etc.
|
|
||||||
*/
|
|
||||||
if (s[0] == L'.' && s[1] == L'/')
|
|
||||||
s = pm_slashskip_w(s + 1);
|
|
||||||
if (p[0] == L'.' && p[1] == L'/')
|
|
||||||
p = pm_slashskip_w(p + 1);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
switch (*p) {
|
|
||||||
case L'\0':
|
|
||||||
if (s[0] == L'/') {
|
|
||||||
if (flags & PATHMATCH_NO_ANCHOR_END)
|
|
||||||
return (1);
|
|
||||||
/* "dir" == "dir/" == "dir/." */
|
|
||||||
s = pm_slashskip_w(s);
|
|
||||||
}
|
|
||||||
return (*s == L'\0');
|
|
||||||
case L'?':
|
|
||||||
/* ? always succeeds, unless we hit end of 's' */
|
|
||||||
if (*s == L'\0')
|
|
||||||
return (0);
|
|
||||||
break;
|
|
||||||
case L'*':
|
|
||||||
/* "*" == "**" == "***" ... */
|
|
||||||
while (*p == L'*')
|
|
||||||
++p;
|
|
||||||
/* Trailing '*' always succeeds. */
|
|
||||||
if (*p == L'\0')
|
|
||||||
return (1);
|
|
||||||
while (*s) {
|
|
||||||
if (archive_pathmatch_w(p, s, flags))
|
|
||||||
return (1);
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
case L'[':
|
|
||||||
/*
|
|
||||||
* Find the end of the [...] character class,
|
|
||||||
* ignoring \] that might occur within the class.
|
|
||||||
*/
|
|
||||||
end = p + 1;
|
|
||||||
while (*end != L'\0' && *end != L']') {
|
|
||||||
if (*end == L'\\' && end[1] != L'\0')
|
|
||||||
++end;
|
|
||||||
++end;
|
|
||||||
}
|
|
||||||
if (*end == L']') {
|
|
||||||
/* We found [...], try to match it. */
|
|
||||||
if (!pm_list_w(p + 1, end, *s, flags))
|
|
||||||
return (0);
|
|
||||||
p = end; /* Jump to trailing ']' char. */
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
/* No final ']', so just match '['. */
|
|
||||||
if (*p != *s)
|
|
||||||
return (0);
|
|
||||||
break;
|
|
||||||
case L'\\':
|
|
||||||
/* Trailing '\\' matches itself. */
|
|
||||||
if (p[1] == L'\0') {
|
|
||||||
if (*s != L'\\')
|
|
||||||
return (0);
|
|
||||||
} else {
|
|
||||||
++p;
|
|
||||||
if (*p != *s)
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case L'/':
|
|
||||||
if (*s != L'/' && *s != L'\0')
|
|
||||||
return (0);
|
|
||||||
/* Note: pattern "/\./" won't match "/";
|
|
||||||
* pm_slashskip() correctly stops at backslash. */
|
|
||||||
p = pm_slashskip_w(p);
|
|
||||||
s = pm_slashskip_w(s);
|
|
||||||
if (*p == L'\0' && (flags & PATHMATCH_NO_ANCHOR_END))
|
|
||||||
return (1);
|
|
||||||
--p; /* Counteract the increment below. */
|
|
||||||
--s;
|
|
||||||
break;
|
|
||||||
case L'$':
|
|
||||||
/* '$' is special only at end of pattern and only
|
|
||||||
* if PATHMATCH_NO_ANCHOR_END is specified. */
|
|
||||||
if (p[1] == L'\0' && (flags & PATHMATCH_NO_ANCHOR_END)){
|
|
||||||
/* "dir" == "dir/" == "dir/." */
|
|
||||||
return (*pm_slashskip_w(s) == L'\0');
|
|
||||||
}
|
|
||||||
/* Otherwise, '$' is not special. */
|
|
||||||
/* FALL THROUGH */
|
|
||||||
default:
|
|
||||||
if (*p != *s)
|
|
||||||
return (0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++p;
|
|
||||||
++s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Main entry point. */
|
|
||||||
int
|
|
||||||
__archive_pathmatch(const char *p, const char *s, int flags)
|
|
||||||
{
|
|
||||||
/* Empty pattern only matches the empty string. */
|
|
||||||
if (p == NULL || *p == '\0')
|
|
||||||
return (s == NULL || *s == '\0');
|
|
||||||
|
|
||||||
/* Leading '^' anchors the start of the pattern. */
|
|
||||||
if (*p == '^') {
|
|
||||||
++p;
|
|
||||||
flags &= ~PATHMATCH_NO_ANCHOR_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*p == '/' && *s != '/')
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
/* Certain patterns anchor implicitly. */
|
|
||||||
if (*p == '*' || *p == '/') {
|
|
||||||
while (*p == '/')
|
|
||||||
++p;
|
|
||||||
while (*s == '/')
|
|
||||||
++s;
|
|
||||||
return (pm(p, s, flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If start is unanchored, try to match start of each path element. */
|
|
||||||
if (flags & PATHMATCH_NO_ANCHOR_START) {
|
|
||||||
for ( ; s != NULL; s = strchr(s, '/')) {
|
|
||||||
if (*s == '/')
|
|
||||||
s++;
|
|
||||||
if (pm(p, s, flags))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Default: Match from beginning. */
|
|
||||||
return (pm(p, s, flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
__archive_pathmatch_w(const wchar_t *p, const wchar_t *s, int flags)
|
|
||||||
{
|
|
||||||
/* Empty pattern only matches the empty string. */
|
|
||||||
if (p == NULL || *p == L'\0')
|
|
||||||
return (s == NULL || *s == L'\0');
|
|
||||||
|
|
||||||
/* Leading '^' anchors the start of the pattern. */
|
|
||||||
if (*p == L'^') {
|
|
||||||
++p;
|
|
||||||
flags &= ~PATHMATCH_NO_ANCHOR_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*p == L'/' && *s != L'/')
|
|
||||||
return (0);
|
|
||||||
|
|
||||||
/* Certain patterns anchor implicitly. */
|
|
||||||
if (*p == L'*' || *p == L'/') {
|
|
||||||
while (*p == L'/')
|
|
||||||
++p;
|
|
||||||
while (*s == L'/')
|
|
||||||
++s;
|
|
||||||
return (pm_w(p, s, flags));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If start is unanchored, try to match start of each path element. */
|
|
||||||
if (flags & PATHMATCH_NO_ANCHOR_START) {
|
|
||||||
for ( ; s != NULL; s = wcschr(s, L'/')) {
|
|
||||||
if (*s == L'/')
|
|
||||||
s++;
|
|
||||||
if (pm_w(p, s, flags))
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Default: Match from beginning. */
|
|
||||||
return (pm_w(p, s, flags));
|
|
||||||
}
|
|
52
3rdparty/libarchive/c/archive_pathmatch.h
vendored
52
3rdparty/libarchive/c/archive_pathmatch.h
vendored
@ -1,52 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer
|
|
||||||
* in this position and unchanged.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_PATHMATCH_H
|
|
||||||
#define ARCHIVE_PATHMATCH_H
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#ifndef __LIBARCHIVE_TEST
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Don't anchor at beginning unless the pattern starts with "^" */
|
|
||||||
#define PATHMATCH_NO_ANCHOR_START 1
|
|
||||||
/* Don't anchor at end unless the pattern ends with "$" */
|
|
||||||
#define PATHMATCH_NO_ANCHOR_END 2
|
|
||||||
|
|
||||||
/* Note that "^" and "$" are not special unless you set the corresponding
|
|
||||||
* flag above. */
|
|
||||||
|
|
||||||
int __archive_pathmatch(const char *p, const char *s, int flags);
|
|
||||||
int __archive_pathmatch_w(const wchar_t *p, const wchar_t *s, int flags);
|
|
||||||
|
|
||||||
#define archive_pathmatch(p, s, f) __archive_pathmatch(p, s, f)
|
|
||||||
#define archive_pathmatch_w(p, s, f) __archive_pathmatch_w(p, s, f)
|
|
||||||
|
|
||||||
#endif
|
|
202
3rdparty/libarchive/c/archive_platform.h
vendored
202
3rdparty/libarchive/c/archive_platform.h
vendored
@ -1,202 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2003-2007 Tim Kientzle
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD: head/lib/libarchive/archive_platform.h 201090 2009-12-28 02:22:04Z kientzle $
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This header is the first thing included in any of the libarchive
|
|
||||||
* source files. As far as possible, platform-specific issues should
|
|
||||||
* be dealt with here and not within individual source files. I'm
|
|
||||||
* actively trying to minimize #if blocks within the main source,
|
|
||||||
* since they obfuscate the code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_PLATFORM_H_INCLUDED
|
|
||||||
#define ARCHIVE_PLATFORM_H_INCLUDED
|
|
||||||
|
|
||||||
/* archive.h and archive_entry.h require this. */
|
|
||||||
#define __LIBARCHIVE_BUILD 1
|
|
||||||
|
|
||||||
#if defined(PLATFORM_CONFIG_H)
|
|
||||||
/* Use hand-built config.h in environments that need it. */
|
|
||||||
#include PLATFORM_CONFIG_H
|
|
||||||
#elif defined(HAVE_CONFIG_H)
|
|
||||||
/* Most POSIX platforms use the 'configure' script to build config.h */
|
|
||||||
#include "config.h"
|
|
||||||
#else
|
|
||||||
/* Warn if the library hasn't been (automatically or manually) configured. */
|
|
||||||
#error Oops: No config.h and no pre-built configuration in archive_platform.h.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* On macOS check for some symbols based on the deployment target version. */
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
# undef HAVE_FUTIMENS
|
|
||||||
# undef HAVE_UTIMENSAT
|
|
||||||
# include <AvailabilityMacros.h>
|
|
||||||
# if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
|
|
||||||
# define HAVE_FUTIMENS 1
|
|
||||||
# define HAVE_UTIMENSAT 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* It should be possible to get rid of this by extending the feature-test
|
|
||||||
* macros to cover Windows API functions, probably along with non-trivial
|
|
||||||
* refactoring of code to find structures that sit more cleanly on top of
|
|
||||||
* either Windows or Posix APIs. */
|
|
||||||
#if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
|
|
||||||
#include "archive_windows.h"
|
|
||||||
#else
|
|
||||||
#define la_stat(path,stref) stat(path,stref)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The config files define a lot of feature macros. The following
|
|
||||||
* uses those macros to select/define replacements and include key
|
|
||||||
* headers as required.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Get a real definition for __FBSDID or __RCSID if we can */
|
|
||||||
#if HAVE_SYS_CDEFS_H
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If not, define them so as to avoid dangling semicolons. */
|
|
||||||
#ifndef __FBSDID
|
|
||||||
#define __FBSDID(a) struct _undefined_hack
|
|
||||||
#endif
|
|
||||||
#ifndef __RCSID
|
|
||||||
#define __RCSID(a) struct _undefined_hack
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Try to get standard C99-style integer type definitions. */
|
|
||||||
#if HAVE_INTTYPES_H
|
|
||||||
#include <inttypes.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_STDINT_H
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Borland warns about its own constants! */
|
|
||||||
#if defined(__BORLANDC__)
|
|
||||||
# if HAVE_DECL_UINT64_MAX
|
|
||||||
# undef UINT64_MAX
|
|
||||||
# undef HAVE_DECL_UINT64_MAX
|
|
||||||
# endif
|
|
||||||
# if HAVE_DECL_UINT64_MIN
|
|
||||||
# undef UINT64_MIN
|
|
||||||
# undef HAVE_DECL_UINT64_MIN
|
|
||||||
# endif
|
|
||||||
# if HAVE_DECL_INT64_MAX
|
|
||||||
# undef INT64_MAX
|
|
||||||
# undef HAVE_DECL_INT64_MAX
|
|
||||||
# endif
|
|
||||||
# if HAVE_DECL_INT64_MIN
|
|
||||||
# undef INT64_MIN
|
|
||||||
# undef HAVE_DECL_INT64_MIN
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Some platforms lack the standard *_MAX definitions. */
|
|
||||||
#if !HAVE_DECL_SIZE_MAX
|
|
||||||
#define SIZE_MAX (~(size_t)0)
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_SSIZE_MAX
|
|
||||||
#define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1))
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_UINT32_MAX
|
|
||||||
#define UINT32_MAX (~(uint32_t)0)
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_INT32_MAX
|
|
||||||
#define INT32_MAX ((int32_t)(UINT32_MAX >> 1))
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_INT32_MIN
|
|
||||||
#define INT32_MIN ((int32_t)(~INT32_MAX))
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_UINT64_MAX
|
|
||||||
#define UINT64_MAX (~(uint64_t)0)
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_INT64_MAX
|
|
||||||
#define INT64_MAX ((int64_t)(UINT64_MAX >> 1))
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_INT64_MIN
|
|
||||||
#define INT64_MIN ((int64_t)(~INT64_MAX))
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_UINTMAX_MAX
|
|
||||||
#define UINTMAX_MAX (~(uintmax_t)0)
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_INTMAX_MAX
|
|
||||||
#define INTMAX_MAX ((intmax_t)(UINTMAX_MAX >> 1))
|
|
||||||
#endif
|
|
||||||
#if !HAVE_DECL_INTMAX_MIN
|
|
||||||
#define INTMAX_MIN ((intmax_t)(~INTMAX_MAX))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we can't restore metadata using a file descriptor, then
|
|
||||||
* for compatibility's sake, close files before trying to restore metadata.
|
|
||||||
*/
|
|
||||||
#if defined(HAVE_FCHMOD) || defined(HAVE_FUTIMES) || defined(HAVE_ACL_SET_FD) || defined(HAVE_ACL_SET_FD_NP) || defined(HAVE_FCHOWN)
|
|
||||||
#define CAN_RESTORE_METADATA_FD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* glibc 2.24 deprecates readdir_r
|
|
||||||
*/
|
|
||||||
#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
|
|
||||||
#define USE_READDIR_R 1
|
|
||||||
#else
|
|
||||||
#undef USE_READDIR_R
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set up defaults for internal error codes. */
|
|
||||||
#ifndef ARCHIVE_ERRNO_FILE_FORMAT
|
|
||||||
#if HAVE_EFTYPE
|
|
||||||
#define ARCHIVE_ERRNO_FILE_FORMAT EFTYPE
|
|
||||||
#else
|
|
||||||
#if HAVE_EILSEQ
|
|
||||||
#define ARCHIVE_ERRNO_FILE_FORMAT EILSEQ
|
|
||||||
#else
|
|
||||||
#define ARCHIVE_ERRNO_FILE_FORMAT EINVAL
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ERRNO_PROGRAMMER
|
|
||||||
#define ARCHIVE_ERRNO_PROGRAMMER EINVAL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_ERRNO_MISC
|
|
||||||
#define ARCHIVE_ERRNO_MISC (-1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ >= 7)
|
|
||||||
#define __LA_FALLTHROUGH __attribute__((fallthrough))
|
|
||||||
#else
|
|
||||||
#define __LA_FALLTHROUGH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* !ARCHIVE_PLATFORM_H_INCLUDED */
|
|
55
3rdparty/libarchive/c/archive_platform_acl.h
vendored
55
3rdparty/libarchive/c/archive_platform_acl.h
vendored
@ -1,55 +0,0 @@
|
|||||||
/*-
|
|
||||||
* Copyright (c) 2017 Martin Matuska
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
||||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
|
|
||||||
|
|
||||||
#ifndef ARCHIVE_PLATFORM_ACL_H_INCLUDED
|
|
||||||
#define ARCHIVE_PLATFORM_ACL_H_INCLUDED
|
|
||||||
|
|
||||||
#ifndef __LIBARCHIVE_BUILD
|
|
||||||
#ifndef __LIBARCHIVE_TEST_COMMON
|
|
||||||
#error This header is only to be used internally to libarchive.
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Determine what ACL types are supported
|
|
||||||
*/
|
|
||||||
#if ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_SUNOS || ARCHIVE_ACL_LIBACL
|
|
||||||
#define ARCHIVE_ACL_POSIX1E 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_SUNOS_NFS4 || \
|
|
||||||
ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBRICHACL
|
|
||||||
#define ARCHIVE_ACL_NFS4 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ARCHIVE_ACL_POSIX1E || ARCHIVE_ACL_NFS4
|
|
||||||
#define ARCHIVE_ACL_SUPPORT 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ARCHIVE_PLATFORM_ACL_H_INCLUDED */
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user