View | Details | Raw Unified | Return to bug 272845
Collapse All | Expand All

(-)b/contrib/libarchive/unzip/bsdunzip.h (+2 lines)
Lines 1-63 Link Here
1
/*-
1
/*-
2
 * Copyright (c) 2023, Martin Matuska
2
 * Copyright (c) 2023, Martin Matuska
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
12
 *    documentation and/or other materials provided with the distribution.
13
 *
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
17
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
24
 */
25
25
26
#ifndef BSDUNZIP_H_INCLUDED
26
#ifndef BSDUNZIP_H_INCLUDED
27
#define BSDUNZIP_H_INCLUDED
27
#define BSDUNZIP_H_INCLUDED
28
28
29
#if defined(PLATFORM_CONFIG_H)
29
#if defined(PLATFORM_CONFIG_H)
30
/* Use hand-built config.h in environments that need it. */
30
/* Use hand-built config.h in environments that need it. */
31
#include PLATFORM_CONFIG_H
31
#include PLATFORM_CONFIG_H
32
#else
32
#else
33
/* Not having a config.h of some sort is a serious problem. */
33
/* Not having a config.h of some sort is a serious problem. */
34
#include "config.h"
34
#include "config.h"
35
#endif
35
#endif
36
36
37
#include <archive.h>
37
#include <archive.h>
38
#include <archive_entry.h>
38
#include <archive_entry.h>
39
39
40
struct bsdunzip {
40
struct bsdunzip {
41
	/* Option parser state */
41
	/* Option parser state */
42
	int		  getopt_state;
42
	int		  getopt_state;
43
	char		 *getopt_word;
43
	char		 *getopt_word;
44
44
45
	/* Miscellaneous state information */
45
	/* Miscellaneous state information */
46
	int		  argc;
46
	int		  argc;
47
	char		**argv;
47
	char		**argv;
48
	const char	 *argument;
48
	const char	 *argument;
49
};
49
};
50
50
51
struct bsdunzip_getopt_ret {
51
struct bsdunzip_getopt_ret {
52
	int		index;
52
	int		index;
53
	int		opt;
53
	int		opt;
54
};
54
};
55
55
56
enum {
56
enum {
57
	OPTION_NONE,
57
	OPTION_NONE,
58
	OPTION_VERSION
58
	OPTION_VERSION
59
};
59
};
60
60
61
int bsdunzip_getopt(struct bsdunzip *);
61
int bsdunzip_getopt(struct bsdunzip *);
62
62
63
extern int bsdunzip_optind;
64
63
#endif
65
#endif
(-)b/contrib/libarchive/unzip/cmdline.c (-2 lines)
Lines 1-250 Link Here
1
/*-
1
/*-
2
 * Copyright (c) 2003-2008 Tim Kientzle
2
 * Copyright (c) 2003-2008 Tim Kientzle
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
12
 *    documentation and/or other materials provided with the distribution.
13
 *
13
 *
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
17
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
24
 */
25
25
26
/*
26
/*
27
 * Command line parser for bsdunzip.
27
 * Command line parser for bsdunzip.
28
 */
28
 */
29
29
30
#include "bsdunzip_platform.h"
30
#include "bsdunzip_platform.h"
31
__FBSDID("$FreeBSD$");
31
__FBSDID("$FreeBSD$");
32
32
33
#ifdef HAVE_ERRNO_H
33
#ifdef HAVE_ERRNO_H
34
#include <errno.h>
34
#include <errno.h>
35
#endif
35
#endif
36
#ifdef HAVE_STDLIB_H
36
#ifdef HAVE_STDLIB_H
37
#include <stdlib.h>
37
#include <stdlib.h>
38
#endif
38
#endif
39
#ifdef HAVE_STRING_H
39
#ifdef HAVE_STRING_H
40
#include <string.h>
40
#include <string.h>
41
#endif
41
#endif
42
42
43
#include "bsdunzip.h"
43
#include "bsdunzip.h"
44
#include "err.h"
44
#include "err.h"
45
45
46
extern int bsdunzip_optind;
47
48
/*
46
/*
49
 * Short options for bsdunzip.  Please keep this sorted.
47
 * Short options for bsdunzip.  Please keep this sorted.
50
 */
48
 */
51
static const char *short_options
49
static const char *short_options
52
	= "aCcd:fI:jLlnO:opP:qtuvx:yZ:";
50
	= "aCcd:fI:jLlnO:opP:qtuvx:yZ:";
53
51
54
/*
52
/*
55
 * Long options for bsdunzip.  Please keep this list sorted.
53
 * Long options for bsdunzip.  Please keep this list sorted.
56
 *
54
 *
57
 * The symbolic names for options that lack a short equivalent are
55
 * The symbolic names for options that lack a short equivalent are
58
 * defined in bsdunzip.h.  Also note that so far I've found no need
56
 * defined in bsdunzip.h.  Also note that so far I've found no need
59
 * to support optional arguments to long options.  That would be
57
 * to support optional arguments to long options.  That would be
60
 * a small change to the code below.
58
 * a small change to the code below.
61
 */
59
 */
62
60
63
static const struct bsdunzip_option {
61
static const struct bsdunzip_option {
64
	const char *name;
62
	const char *name;
65
	int required;      /* 1 if this option requires an argument. */
63
	int required;      /* 1 if this option requires an argument. */
66
	int equivalent;    /* Equivalent short option. */
64
	int equivalent;    /* Equivalent short option. */
67
} bsdunzip_longopts[] = {
65
} bsdunzip_longopts[] = {
68
	{ "version", 0, OPTION_VERSION },
66
	{ "version", 0, OPTION_VERSION },
69
	{ NULL, 0, 0 }
67
	{ NULL, 0, 0 }
70
};
68
};
71
69
72
/*
70
/*
73
 * This getopt implementation has two key features that common
71
 * This getopt implementation has two key features that common
74
 * getopt_long() implementations lack.  Apart from those, it's a
72
 * getopt_long() implementations lack.  Apart from those, it's a
75
 * straightforward option parser, considerably simplified by not
73
 * straightforward option parser, considerably simplified by not
76
 * needing to support the wealth of exotic getopt_long() features.  It
74
 * needing to support the wealth of exotic getopt_long() features.  It
77
 * has, of course, been shamelessly tailored for bsdunzip.  (If you're
75
 * has, of course, been shamelessly tailored for bsdunzip.  (If you're
78
 * looking for a generic getopt_long() implementation for your
76
 * looking for a generic getopt_long() implementation for your
79
 * project, I recommend Gregory Pietsch's public domain getopt_long()
77
 * project, I recommend Gregory Pietsch's public domain getopt_long()
80
 * implementation.)  The two additional features are:
78
 * implementation.)  The two additional features are:
81
 */
79
 */
82
80
83
int
81
int
84
bsdunzip_getopt(struct bsdunzip *bsdunzip)
82
bsdunzip_getopt(struct bsdunzip *bsdunzip)
85
{
83
{
86
	enum { state_start = 0, state_next_word, state_short, state_long };
84
	enum { state_start = 0, state_next_word, state_short, state_long };
87
85
88
	const struct bsdunzip_option *popt, *match = NULL, *match2 = NULL;
86
	const struct bsdunzip_option *popt, *match = NULL, *match2 = NULL;
89
	const char *p, *long_prefix = "--";
87
	const char *p, *long_prefix = "--";
90
	size_t optlength;
88
	size_t optlength;
91
	int opt = OPTION_NONE;
89
	int opt = OPTION_NONE;
92
	int required = 0;
90
	int required = 0;
93
91
94
	bsdunzip->argument = NULL;
92
	bsdunzip->argument = NULL;
95
93
96
	/* First time through, initialize everything. */
94
	/* First time through, initialize everything. */
97
	if (bsdunzip->getopt_state == state_start) {
95
	if (bsdunzip->getopt_state == state_start) {
98
		/* Skip program name. */
96
		/* Skip program name. */
99
		++bsdunzip->argv;
97
		++bsdunzip->argv;
100
		--bsdunzip->argc;
98
		--bsdunzip->argc;
101
		if (*bsdunzip->argv == NULL)
99
		if (*bsdunzip->argv == NULL)
102
			return (-1);
100
			return (-1);
103
		bsdunzip->getopt_state = state_next_word;
101
		bsdunzip->getopt_state = state_next_word;
104
	}
102
	}
105
103
106
	/*
104
	/*
107
	 * We're ready to look at the next word in argv.
105
	 * We're ready to look at the next word in argv.
108
	 */
106
	 */
109
	if (bsdunzip->getopt_state == state_next_word) {
107
	if (bsdunzip->getopt_state == state_next_word) {
110
		/* No more arguments, so no more options. */
108
		/* No more arguments, so no more options. */
111
		if (bsdunzip->argv[0] == NULL)
109
		if (bsdunzip->argv[0] == NULL)
112
			return (-1);
110
			return (-1);
113
		/* Doesn't start with '-', so no more options. */
111
		/* Doesn't start with '-', so no more options. */
114
		if (bsdunzip->argv[0][0] != '-')
112
		if (bsdunzip->argv[0][0] != '-')
115
			return (-1);
113
			return (-1);
116
		/* "--" marks end of options; consume it and return. */
114
		/* "--" marks end of options; consume it and return. */
117
		if (strcmp(bsdunzip->argv[0], "--") == 0) {
115
		if (strcmp(bsdunzip->argv[0], "--") == 0) {
118
			++bsdunzip->argv;
116
			++bsdunzip->argv;
119
			--bsdunzip->argc;
117
			--bsdunzip->argc;
120
			return (-1);
118
			return (-1);
121
		}
119
		}
122
		/* Get next word for parsing. */
120
		/* Get next word for parsing. */
123
		bsdunzip->getopt_word = *bsdunzip->argv++;
121
		bsdunzip->getopt_word = *bsdunzip->argv++;
124
		--bsdunzip->argc;
122
		--bsdunzip->argc;
125
		bsdunzip_optind++;
123
		bsdunzip_optind++;
126
		if (bsdunzip->getopt_word[1] == '-') {
124
		if (bsdunzip->getopt_word[1] == '-') {
127
			/* Set up long option parser. */
125
			/* Set up long option parser. */
128
			bsdunzip->getopt_state = state_long;
126
			bsdunzip->getopt_state = state_long;
129
			bsdunzip->getopt_word += 2; /* Skip leading '--' */
127
			bsdunzip->getopt_word += 2; /* Skip leading '--' */
130
		} else {
128
		} else {
131
			/* Set up short option parser. */
129
			/* Set up short option parser. */
132
			bsdunzip->getopt_state = state_short;
130
			bsdunzip->getopt_state = state_short;
133
			++bsdunzip->getopt_word;  /* Skip leading '-' */
131
			++bsdunzip->getopt_word;  /* Skip leading '-' */
134
		}
132
		}
135
	}
133
	}
136
134
137
	/*
135
	/*
138
	 * We're parsing a group of POSIX-style single-character options.
136
	 * We're parsing a group of POSIX-style single-character options.
139
	 */
137
	 */
140
	if (bsdunzip->getopt_state == state_short) {
138
	if (bsdunzip->getopt_state == state_short) {
141
		/* Peel next option off of a group of short options. */
139
		/* Peel next option off of a group of short options. */
142
		opt = *bsdunzip->getopt_word++;
140
		opt = *bsdunzip->getopt_word++;
143
		if (opt == '\0') {
141
		if (opt == '\0') {
144
			/* End of this group; recurse to get next option. */
142
			/* End of this group; recurse to get next option. */
145
			bsdunzip->getopt_state = state_next_word;
143
			bsdunzip->getopt_state = state_next_word;
146
			return bsdunzip_getopt(bsdunzip);
144
			return bsdunzip_getopt(bsdunzip);
147
		}
145
		}
148
146
149
		/* Does this option take an argument? */
147
		/* Does this option take an argument? */
150
		p = strchr(short_options, opt);
148
		p = strchr(short_options, opt);
151
		if (p == NULL)
149
		if (p == NULL)
152
			return ('?');
150
			return ('?');
153
		if (p[1] == ':')
151
		if (p[1] == ':')
154
			required = 1;
152
			required = 1;
155
153
156
		/* If it takes an argument, parse that. */
154
		/* If it takes an argument, parse that. */
157
		if (required) {
155
		if (required) {
158
			/* If arg is run-in, bsdunzip->getopt_word already points to it. */
156
			/* If arg is run-in, bsdunzip->getopt_word already points to it. */
159
			if (bsdunzip->getopt_word[0] == '\0') {
157
			if (bsdunzip->getopt_word[0] == '\0') {
160
				/* Otherwise, pick up the next word. */
158
				/* Otherwise, pick up the next word. */
161
				bsdunzip->getopt_word = *bsdunzip->argv;
159
				bsdunzip->getopt_word = *bsdunzip->argv;
162
				if (bsdunzip->getopt_word == NULL) {
160
				if (bsdunzip->getopt_word == NULL) {
163
					lafe_warnc(0,
161
					lafe_warnc(0,
164
					    "Option -%c requires an argument",
162
					    "Option -%c requires an argument",
165
					    opt);
163
					    opt);
166
					return ('?');
164
					return ('?');
167
				}
165
				}
168
				++bsdunzip->argv;
166
				++bsdunzip->argv;
169
				--bsdunzip->argc;
167
				--bsdunzip->argc;
170
				bsdunzip_optind++;
168
				bsdunzip_optind++;
171
			}
169
			}
172
			bsdunzip->getopt_state = state_next_word;
170
			bsdunzip->getopt_state = state_next_word;
173
			bsdunzip->argument = bsdunzip->getopt_word;
171
			bsdunzip->argument = bsdunzip->getopt_word;
174
		}
172
		}
175
	}
173
	}
176
174
177
	/* We're reading a long option */
175
	/* We're reading a long option */
178
	if (bsdunzip->getopt_state == state_long) {
176
	if (bsdunzip->getopt_state == state_long) {
179
		/* After this long option, we'll be starting a new word. */
177
		/* After this long option, we'll be starting a new word. */
180
		bsdunzip->getopt_state = state_next_word;
178
		bsdunzip->getopt_state = state_next_word;
181
179
182
		/* Option name ends at '=' if there is one. */
180
		/* Option name ends at '=' if there is one. */
183
		p = strchr(bsdunzip->getopt_word, '=');
181
		p = strchr(bsdunzip->getopt_word, '=');
184
		if (p != NULL) {
182
		if (p != NULL) {
185
			optlength = (size_t)(p - bsdunzip->getopt_word);
183
			optlength = (size_t)(p - bsdunzip->getopt_word);
186
			bsdunzip->argument = (char *)(uintptr_t)(p + 1);
184
			bsdunzip->argument = (char *)(uintptr_t)(p + 1);
187
		} else {
185
		} else {
188
			optlength = strlen(bsdunzip->getopt_word);
186
			optlength = strlen(bsdunzip->getopt_word);
189
		}
187
		}
190
188
191
		/* Search the table for an unambiguous match. */
189
		/* Search the table for an unambiguous match. */
192
		for (popt = bsdunzip_longopts; popt->name != NULL; popt++) {
190
		for (popt = bsdunzip_longopts; popt->name != NULL; popt++) {
193
			/* Short-circuit if first chars don't match. */
191
			/* Short-circuit if first chars don't match. */
194
			if (popt->name[0] != bsdunzip->getopt_word[0])
192
			if (popt->name[0] != bsdunzip->getopt_word[0])
195
				continue;
193
				continue;
196
			/* If option is a prefix of name in table, record it.*/
194
			/* If option is a prefix of name in table, record it.*/
197
			if (strncmp(bsdunzip->getopt_word, popt->name, optlength) == 0) {
195
			if (strncmp(bsdunzip->getopt_word, popt->name, optlength) == 0) {
198
				match2 = match; /* Record up to two matches. */
196
				match2 = match; /* Record up to two matches. */
199
				match = popt;
197
				match = popt;
200
				/* If it's an exact match, we're done. */
198
				/* If it's an exact match, we're done. */
201
				if (strlen(popt->name) == optlength) {
199
				if (strlen(popt->name) == optlength) {
202
					match2 = NULL; /* Forget the others. */
200
					match2 = NULL; /* Forget the others. */
203
					break;
201
					break;
204
				}
202
				}
205
			}
203
			}
206
		}
204
		}
207
205
208
		/* Fail if there wasn't a unique match. */
206
		/* Fail if there wasn't a unique match. */
209
		if (match == NULL) {
207
		if (match == NULL) {
210
			lafe_warnc(0,
208
			lafe_warnc(0,
211
			    "Option %s%s is not supported",
209
			    "Option %s%s is not supported",
212
			    long_prefix, bsdunzip->getopt_word);
210
			    long_prefix, bsdunzip->getopt_word);
213
			return ('?');
211
			return ('?');
214
		}
212
		}
215
		if (match2 != NULL) {
213
		if (match2 != NULL) {
216
			lafe_warnc(0,
214
			lafe_warnc(0,
217
			    "Ambiguous option %s%s (matches --%s and --%s)",
215
			    "Ambiguous option %s%s (matches --%s and --%s)",
218
			    long_prefix, bsdunzip->getopt_word, match->name, match2->name);
216
			    long_prefix, bsdunzip->getopt_word, match->name, match2->name);
219
			return ('?');
217
			return ('?');
220
		}
218
		}
221
219
222
		/* We've found a unique match; does it need an argument? */
220
		/* We've found a unique match; does it need an argument? */
223
		if (match->required) {
221
		if (match->required) {
224
			/* Argument required: get next word if necessary. */
222
			/* Argument required: get next word if necessary. */
225
			if (bsdunzip->argument == NULL) {
223
			if (bsdunzip->argument == NULL) {
226
				bsdunzip->argument = *bsdunzip->argv;
224
				bsdunzip->argument = *bsdunzip->argv;
227
				if (bsdunzip->argument == NULL) {
225
				if (bsdunzip->argument == NULL) {
228
					lafe_warnc(0,
226
					lafe_warnc(0,
229
					    "Option %s%s requires an argument",
227
					    "Option %s%s requires an argument",
230
					    long_prefix, match->name);
228
					    long_prefix, match->name);
231
					return ('?');
229
					return ('?');
232
				}
230
				}
233
				++bsdunzip->argv;
231
				++bsdunzip->argv;
234
				--bsdunzip->argc;
232
				--bsdunzip->argc;
235
				bsdunzip_optind++;
233
				bsdunzip_optind++;
236
			}
234
			}
237
		} else {
235
		} else {
238
			/* Argument forbidden: fail if there is one. */
236
			/* Argument forbidden: fail if there is one. */
239
			if (bsdunzip->argument != NULL) {
237
			if (bsdunzip->argument != NULL) {
240
				lafe_warnc(0,
238
				lafe_warnc(0,
241
				    "Option %s%s does not allow an argument",
239
				    "Option %s%s does not allow an argument",
242
				    long_prefix, match->name);
240
				    long_prefix, match->name);
243
				return ('?');
241
				return ('?');
244
			}
242
			}
245
		}
243
		}
246
		return (match->equivalent);
244
		return (match->equivalent);
247
	}
245
	}
248
246
249
	return (opt);
247
	return (opt);
250
}
248
}
(-)b/etc/mtree/BSD.tests.dist (+2 lines)
Lines 1-1184 Link Here
1
# $FreeBSD$
1
# $FreeBSD$
2
#
2
#
3
# Please see the file src/etc/mtree/README before making changes to this file.
3
# Please see the file src/etc/mtree/README before making changes to this file.
4
#
4
#
5
5
6
/set type=dir uname=root gname=wheel mode=0755 tags=package=tests
6
/set type=dir uname=root gname=wheel mode=0755 tags=package=tests
7
.
7
.
8
    bin
8
    bin
9
        cat
9
        cat
10
        ..
10
        ..
11
        chflags
11
        chflags
12
        ..
12
        ..
13
        chmod
13
        chmod
14
        ..
14
        ..
15
        cp
15
        cp
16
        ..
16
        ..
17
        date
17
        date
18
        ..
18
        ..
19
        dd
19
        dd
20
        ..
20
        ..
21
        echo
21
        echo
22
        ..
22
        ..
23
        expr
23
        expr
24
        ..
24
        ..
25
        ln
25
        ln
26
        ..
26
        ..
27
        ls
27
        ls
28
        ..
28
        ..
29
        mkdir
29
        mkdir
30
        ..
30
        ..
31
        mv
31
        mv
32
        ..
32
        ..
33
        pax
33
        pax
34
        ..
34
        ..
35
        pkill
35
        pkill
36
        ..
36
        ..
37
        pwait
37
        pwait
38
        ..
38
        ..
39
        rm
39
        rm
40
        ..
40
        ..
41
        rmdir
41
        rmdir
42
        ..
42
        ..
43
        sh
43
        sh
44
            builtins
44
            builtins
45
            ..
45
            ..
46
            errors
46
            errors
47
            ..
47
            ..
48
            execution
48
            execution
49
            ..
49
            ..
50
            expansion
50
            expansion
51
            ..
51
            ..
52
            invocation
52
            invocation
53
            ..
53
            ..
54
            parameters
54
            parameters
55
            ..
55
            ..
56
            parser
56
            parser
57
            ..
57
            ..
58
            set-e
58
            set-e
59
            ..
59
            ..
60
        ..
60
        ..
61
        sleep
61
        sleep
62
        ..
62
        ..
63
        test
63
        test
64
        ..
64
        ..
65
        timeout
65
        timeout
66
        ..
66
        ..
67
    ..
67
    ..
68
    cddl
68
    cddl
69
        lib
69
        lib
70
        ..
70
        ..
71
        sbin
71
        sbin
72
        ..
72
        ..
73
        usr.bin
73
        usr.bin
74
            ctfconvert
74
            ctfconvert
75
            ..
75
            ..
76
            ztest
76
            ztest
77
            ..
77
            ..
78
        ..
78
        ..
79
        usr.sbin
79
        usr.sbin
80
            dtrace
80
            dtrace
81
                common
81
                common
82
                    aggs
82
                    aggs
83
                    ..
83
                    ..
84
                    arithmetic
84
                    arithmetic
85
                    ..
85
                    ..
86
                    arrays
86
                    arrays
87
                    ..
87
                    ..
88
                    assocs
88
                    assocs
89
                    ..
89
                    ..
90
                    begin
90
                    begin
91
                    ..
91
                    ..
92
                    bitfields
92
                    bitfields
93
                    ..
93
                    ..
94
                    buffering
94
                    buffering
95
                    ..
95
                    ..
96
                    builtinvar
96
                    builtinvar
97
                    ..
97
                    ..
98
                    cg
98
                    cg
99
                    ..
99
                    ..
100
                    clauses
100
                    clauses
101
                    ..
101
                    ..
102
                    cpc
102
                    cpc
103
                    ..
103
                    ..
104
                    decls
104
                    decls
105
                    ..
105
                    ..
106
                    drops
106
                    drops
107
                    ..
107
                    ..
108
                    dtraceUtil
108
                    dtraceUtil
109
                    ..
109
                    ..
110
                    end
110
                    end
111
                    ..
111
                    ..
112
                    env
112
                    env
113
                    ..
113
                    ..
114
                    enum
114
                    enum
115
                    ..
115
                    ..
116
                    error
116
                    error
117
                    ..
117
                    ..
118
                    exit
118
                    exit
119
                    ..
119
                    ..
120
                    fbtprovider
120
                    fbtprovider
121
                    ..
121
                    ..
122
                    funcs
122
                    funcs
123
                    ..
123
                    ..
124
                    grammar
124
                    grammar
125
                    ..
125
                    ..
126
                    include
126
                    include
127
                    ..
127
                    ..
128
                    inline
128
                    inline
129
                    ..
129
                    ..
130
                    io
130
                    io
131
                    ..
131
                    ..
132
                    ip
132
                    ip
133
                    ..
133
                    ..
134
                    java_api
134
                    java_api
135
                    ..
135
                    ..
136
                    json
136
                    json
137
                    ..
137
                    ..
138
                    kinst
138
                    kinst
139
                    ..
139
                    ..
140
                    lexer
140
                    lexer
141
                    ..
141
                    ..
142
                    llquantize
142
                    llquantize
143
                    ..
143
                    ..
144
                    mdb
144
                    mdb
145
                    ..
145
                    ..
146
                    mib
146
                    mib
147
                    ..
147
                    ..
148
                    misc
148
                    misc
149
                    ..
149
                    ..
150
                    multiaggs
150
                    multiaggs
151
                    ..
151
                    ..
152
                    offsetof
152
                    offsetof
153
                    ..
153
                    ..
154
                    operators
154
                    operators
155
                    ..
155
                    ..
156
                    pid
156
                    pid
157
                    ..
157
                    ..
158
                    plockstat
158
                    plockstat
159
                    ..
159
                    ..
160
                    pointers
160
                    pointers
161
                    ..
161
                    ..
162
                    pragma
162
                    pragma
163
                    ..
163
                    ..
164
                    predicates
164
                    predicates
165
                    ..
165
                    ..
166
                    preprocessor
166
                    preprocessor
167
                    ..
167
                    ..
168
                    print
168
                    print
169
                    ..
169
                    ..
170
                    printa
170
                    printa
171
                    ..
171
                    ..
172
                    printf
172
                    printf
173
                    ..
173
                    ..
174
                    privs
174
                    privs
175
                    ..
175
                    ..
176
                    probes
176
                    probes
177
                    ..
177
                    ..
178
                    proc
178
                    proc
179
                    ..
179
                    ..
180
                    profile-n
180
                    profile-n
181
                    ..
181
                    ..
182
                    providers
182
                    providers
183
                    ..
183
                    ..
184
                    raise
184
                    raise
185
                    ..
185
                    ..
186
                    rates
186
                    rates
187
                    ..
187
                    ..
188
                    safety
188
                    safety
189
                    ..
189
                    ..
190
                    scalars
190
                    scalars
191
                    ..
191
                    ..
192
                    sched
192
                    sched
193
                    ..
193
                    ..
194
                    scripting
194
                    scripting
195
                    ..
195
                    ..
196
                    sdt
196
                    sdt
197
                    ..
197
                    ..
198
                    sizeof
198
                    sizeof
199
                    ..
199
                    ..
200
                    speculation
200
                    speculation
201
                    ..
201
                    ..
202
                    stability
202
                    stability
203
                    ..
203
                    ..
204
                    stack
204
                    stack
205
                    ..
205
                    ..
206
                    stackdepth
206
                    stackdepth
207
                    ..
207
                    ..
208
                    stop
208
                    stop
209
                    ..
209
                    ..
210
                    strlen
210
                    strlen
211
                    ..
211
                    ..
212
                    strtoll
212
                    strtoll
213
                    ..
213
                    ..
214
                    struct
214
                    struct
215
                    ..
215
                    ..
216
                    sugar
216
                    sugar
217
                    ..
217
                    ..
218
                    syscall
218
                    syscall
219
                    ..
219
                    ..
220
                    sysevent
220
                    sysevent
221
                    ..
221
                    ..
222
                    tick-n
222
                    tick-n
223
                    ..
223
                    ..
224
                    trace
224
                    trace
225
                    ..
225
                    ..
226
                    tracemem
226
                    tracemem
227
                    ..
227
                    ..
228
                    translators
228
                    translators
229
                    ..
229
                    ..
230
                    typedef
230
                    typedef
231
                    ..
231
                    ..
232
                    types
232
                    types
233
                    ..
233
                    ..
234
                    uctf
234
                    uctf
235
                    ..
235
                    ..
236
                    union
236
                    union
237
                    ..
237
                    ..
238
                    usdt
238
                    usdt
239
                    ..
239
                    ..
240
                    ustack
240
                    ustack
241
                    ..
241
                    ..
242
                    vars
242
                    vars
243
                    ..
243
                    ..
244
                    version
244
                    version
245
                    ..
245
                    ..
246
                ..
246
                ..
247
                i386
247
                i386
248
                    arrays
248
                    arrays
249
                    ..
249
                    ..
250
                    funcs
250
                    funcs
251
                    ..
251
                    ..
252
                    pid
252
                    pid
253
                    ..
253
                    ..
254
                    ustack
254
                    ustack
255
                    ..
255
                    ..
256
                ..
256
                ..
257
                amd64
257
                amd64
258
                    arrays
258
                    arrays
259
                    ..
259
                    ..
260
                ..
260
                ..
261
            ..
261
            ..
262
            zfsd
262
            zfsd
263
            ..
263
            ..
264
        ..
264
        ..
265
    ..
265
    ..
266
    etc
266
    etc
267
        rc.d
267
        rc.d
268
        ..
268
        ..
269
    ..
269
    ..
270
    examples
270
    examples
271
    ..
271
    ..
272
    games
272
    games
273
    ..
273
    ..
274
    gnu
274
    gnu
275
        lib
275
        lib
276
        ..
276
        ..
277
        usr.bin
277
        usr.bin
278
            diff
278
            diff
279
            ..
279
            ..
280
        ..
280
        ..
281
    ..
281
    ..
282
    lib
282
    lib
283
        atf
283
        atf
284
            libatf-c
284
            libatf-c
285
                detail
285
                detail
286
                ..
286
                ..
287
            ..
287
            ..
288
            libatf-c++
288
            libatf-c++
289
                detail
289
                detail
290
                ..
290
                ..
291
            ..
291
            ..
292
            test-programs
292
            test-programs
293
            ..
293
            ..
294
        ..
294
        ..
295
        csu
295
        csu
296
            dynamic
296
            dynamic
297
            ..
297
            ..
298
            dynamiclib
298
            dynamiclib
299
            ..
299
            ..
300
            static
300
            static
301
            ..
301
            ..
302
        ..
302
        ..
303
        googletest
303
        googletest
304
            gmock
304
            gmock
305
            ..
305
            ..
306
            gmock_main
306
            gmock_main
307
            ..
307
            ..
308
            gtest
308
            gtest
309
            ..
309
            ..
310
            gtest_main
310
            gtest_main
311
            ..
311
            ..
312
        ..
312
        ..
313
        libarchive
313
        libarchive
314
        ..
314
        ..
315
        libbe
315
        libbe
316
        ..
316
        ..
317
        libc
317
        libc
318
            c063
318
            c063
319
            ..
319
            ..
320
            db
320
            db
321
            ..
321
            ..
322
            gen
322
            gen
323
                execve
323
                execve
324
                ..
324
                ..
325
                posix_spawn
325
                posix_spawn
326
                ..
326
                ..
327
            ..
327
            ..
328
            hash
328
            hash
329
                data
329
                data
330
                ..
330
                ..
331
            ..
331
            ..
332
            iconv
332
            iconv
333
            ..
333
            ..
334
            inet
334
            inet
335
            ..
335
            ..
336
            locale
336
            locale
337
            ..
337
            ..
338
            net
338
            net
339
                getaddrinfo
339
                getaddrinfo
340
                    data
340
                    data
341
                    ..
341
                    ..
342
                ..
342
                ..
343
            ..
343
            ..
344
            nss
344
            nss
345
            ..
345
            ..
346
            regex
346
            regex
347
                data
347
                data
348
                ..
348
                ..
349
            ..
349
            ..
350
            resolv
350
            resolv
351
            ..
351
            ..
352
            rpc
352
            rpc
353
            ..
353
            ..
354
            ssp
354
            ssp
355
            ..
355
            ..
356
            setjmp
356
            setjmp
357
            ..
357
            ..
358
            stdio
358
            stdio
359
            ..
359
            ..
360
            stdlib
360
            stdlib
361
            ..
361
            ..
362
            string
362
            string
363
            ..
363
            ..
364
            sys
364
            sys
365
            ..
365
            ..
366
            time
366
            time
367
            ..
367
            ..
368
            tls
368
            tls
369
                dso
369
                dso
370
                ..
370
                ..
371
            ..
371
            ..
372
            termios
372
            termios
373
            ..
373
            ..
374
            ttyio
374
            ttyio
375
            ..
375
            ..
376
        ..
376
        ..
377
        libcam
377
        libcam
378
        ..
378
        ..
379
        libcasper
379
        libcasper
380
            services
380
            services
381
                cap_dns
381
                cap_dns
382
                ..
382
                ..
383
                cap_grp
383
                cap_grp
384
                ..
384
                ..
385
                cap_pwd
385
                cap_pwd
386
                ..
386
                ..
387
                cap_sysctl
387
                cap_sysctl
388
                ..
388
                ..
389
            ..
389
            ..
390
        ..
390
        ..
391
        libcrypt
391
        libcrypt
392
        ..
392
        ..
393
        libdevdctl
393
        libdevdctl
394
        ..
394
        ..
395
        libexecinfo
395
        libexecinfo
396
        ..
396
        ..
397
        libkvm
397
        libkvm
398
        ..
398
        ..
399
        libmp
399
        libmp
400
        ..
400
        ..
401
        libnv
401
        libnv
402
        ..
402
        ..
403
        libproc
403
        libproc
404
        ..
404
        ..
405
        libregex
405
        libregex
406
            data
406
            data
407
            ..
407
            ..
408
        ..
408
        ..
409
        librt
409
        librt
410
        ..
410
        ..
411
        libsbuf
411
        libsbuf
412
        ..
412
        ..
413
        libsysdecode
413
        libsysdecode
414
        ..
414
        ..
415
        libthr
415
        libthr
416
            dlopen
416
            dlopen
417
            ..
417
            ..
418
        ..
418
        ..
419
        libutil
419
        libutil
420
        ..
420
        ..
421
        libxo
421
        libxo
422
        ..
422
        ..
423
        msun
423
        msun
424
        ..
424
        ..
425
    ..
425
    ..
426
    libexec
426
    libexec
427
        atf
427
        atf
428
            atf-check
428
            atf-check
429
            ..
429
            ..
430
            atf-pytest-wrapper
430
            atf-pytest-wrapper
431
            ..
431
            ..
432
            atf-sh
432
            atf-sh
433
            ..
433
            ..
434
        ..
434
        ..
435
        rc
435
        rc
436
        ..
436
        ..
437
        rtld-elf
437
        rtld-elf
438
        ..
438
        ..
439
        tftpd
439
        tftpd
440
        ..
440
        ..
441
    ..
441
    ..
442
    sbin
442
    sbin
443
        bectl
443
        bectl
444
        ..
444
        ..
445
        dhclient
445
        dhclient
446
        ..
446
        ..
447
        devd
447
        devd
448
        ..
448
        ..
449
        growfs
449
        growfs
450
        ..
450
        ..
451
        ifconfig
451
        ifconfig
452
        ..
452
        ..
453
        ipfw
453
        ipfw
454
        ..
454
        ..
455
        md5
455
        md5
456
        ..
456
        ..
457
        mdconfig
457
        mdconfig
458
        ..
458
        ..
459
        newfs_msdos
459
        newfs_msdos
460
        ..
460
        ..
461
        nvmecontrol
461
        nvmecontrol
462
        ..
462
        ..
463
        pfctl
463
        pfctl
464
            files
464
            files
465
            ..
465
            ..
466
        ..
466
        ..
467
        ping
467
        ping
468
        ..
468
        ..
469
        route
469
        route
470
        ..
470
        ..
471
        sysctl
471
        sysctl
472
        ..
472
        ..
473
    ..
473
    ..
474
    secure
474
    secure
475
        lib
475
        lib
476
        ..
476
        ..
477
        libexec
477
        libexec
478
        ..
478
        ..
479
        usr.bin
479
        usr.bin
480
        ..
480
        ..
481
        usr.sbin
481
        usr.sbin
482
        ..
482
        ..
483
    ..
483
    ..
484
    share
484
    share
485
        examples
485
        examples
486
            tests
486
            tests
487
                atf
487
                atf
488
                ..
488
                ..
489
                googletest
489
                googletest
490
                ..
490
                ..
491
                plain
491
                plain
492
                ..
492
                ..
493
                tap
493
                tap
494
                ..
494
                ..
495
            ..
495
            ..
496
        ..
496
        ..
497
        zoneinfo
497
        zoneinfo
498
        ..
498
        ..
499
    ..
499
    ..
500
    sys
500
    sys
501
        acl
501
        acl
502
        ..
502
        ..
503
        aio
503
        aio
504
        ..
504
        ..
505
        audit
505
        audit
506
        ..
506
        ..
507
        auditpipe
507
        auditpipe
508
        ..
508
        ..
509
        capsicum
509
        capsicum
510
        ..
510
        ..
511
        cddl
511
        cddl
512
            zfs
512
            zfs
513
                bin
513
                bin
514
                ..
514
                ..
515
                include
515
                include
516
                ..
516
                ..
517
                tests
517
                tests
518
                    acl
518
                    acl
519
                        cifs
519
                        cifs
520
                        ..
520
                        ..
521
                        nontrivial
521
                        nontrivial
522
                        ..
522
                        ..
523
                        trivial
523
                        trivial
524
                        ..
524
                        ..
525
                    ..
525
                    ..
526
                    atime
526
                    atime
527
                    ..
527
                    ..
528
                    bootfs
528
                    bootfs
529
                    ..
529
                    ..
530
                    cache
530
                    cache
531
                    ..
531
                    ..
532
                    cachefile
532
                    cachefile
533
                    ..
533
                    ..
534
                    clean_mirror
534
                    clean_mirror
535
                    ..
535
                    ..
536
                    cli_root
536
                    cli_root
537
                        zfs_upgrade
537
                        zfs_upgrade
538
                        ..
538
                        ..
539
                        zfs_promote
539
                        zfs_promote
540
                        ..
540
                        ..
541
                        zfs_clone
541
                        zfs_clone
542
                        ..
542
                        ..
543
                        zfs_property
543
                        zfs_property
544
                        ..
544
                        ..
545
                        zfs_destroy
545
                        zfs_destroy
546
                        ..
546
                        ..
547
                        zpool_create
547
                        zpool_create
548
                        ..
548
                        ..
549
                        zpool_history
549
                        zpool_history
550
                        ..
550
                        ..
551
                        zpool_expand
551
                        zpool_expand
552
                        ..
552
                        ..
553
                        zpool_remove
553
                        zpool_remove
554
                        ..
554
                        ..
555
                        zfs_mount
555
                        zfs_mount
556
                        ..
556
                        ..
557
                        zfs_unshare
557
                        zfs_unshare
558
                        ..
558
                        ..
559
                        zdb
559
                        zdb
560
                        ..
560
                        ..
561
                        zpool_online
561
                        zpool_online
562
                        ..
562
                        ..
563
                        zpool_get
563
                        zpool_get
564
                        ..
564
                        ..
565
                        zpool_export
565
                        zpool_export
566
                        ..
566
                        ..
567
                        zfs_copies
567
                        zfs_copies
568
                        ..
568
                        ..
569
                        zfs_get
569
                        zfs_get
570
                        ..
570
                        ..
571
                        zfs
571
                        zfs
572
                        ..
572
                        ..
573
                        zpool_clear
573
                        zpool_clear
574
                        ..
574
                        ..
575
                        zpool_import
575
                        zpool_import
576
                            blockfiles
576
                            blockfiles
577
                            ..
577
                            ..
578
                        ..
578
                        ..
579
                        zpool
579
                        zpool
580
                        ..
580
                        ..
581
                        zpool_offline
581
                        zpool_offline
582
                        ..
582
                        ..
583
                        zpool_replace
583
                        zpool_replace
584
                        ..
584
                        ..
585
                        zfs_rollback
585
                        zfs_rollback
586
                        ..
586
                        ..
587
                        zpool_set
587
                        zpool_set
588
                        ..
588
                        ..
589
                        zfs_send
589
                        zfs_send
590
                        ..
590
                        ..
591
                        zfs_set
591
                        zfs_set
592
                        ..
592
                        ..
593
                        zpool_detach
593
                        zpool_detach
594
                        ..
594
                        ..
595
                        zfs_diff
595
                        zfs_diff
596
                        ..
596
                        ..
597
                        zpool_scrub
597
                        zpool_scrub
598
                        ..
598
                        ..
599
                        zfs_inherit
599
                        zfs_inherit
600
                        ..
600
                        ..
601
                        zfs_snapshot
601
                        zfs_snapshot
602
                        ..
602
                        ..
603
                        zfs_share
603
                        zfs_share
604
                        ..
604
                        ..
605
                        zpool_destroy
605
                        zpool_destroy
606
                        ..
606
                        ..
607
                        zpool_status
607
                        zpool_status
608
                        ..
608
                        ..
609
                        zfs_unmount
609
                        zfs_unmount
610
                        ..
610
                        ..
611
                        zfs_receive
611
                        zfs_receive
612
                        ..
612
                        ..
613
                        zfs_create
613
                        zfs_create
614
                        ..
614
                        ..
615
                        zpool_upgrade
615
                        zpool_upgrade
616
                            blockfiles
616
                            blockfiles
617
                            ..
617
                            ..
618
                        ..
618
                        ..
619
                        zpool_add
619
                        zpool_add
620
                        ..
620
                        ..
621
                        zfs_rename
621
                        zfs_rename
622
                        ..
622
                        ..
623
                        zpool_attach
623
                        zpool_attach
624
                        ..
624
                        ..
625
                        zfs_reservation
625
                        zfs_reservation
626
                        ..
626
                        ..
627
                    ..
627
                    ..
628
                    cli_user
628
                    cli_user
629
                        misc
629
                        misc
630
                        ..
630
                        ..
631
                        zfs_list
631
                        zfs_list
632
                        ..
632
                        ..
633
                        zpool_iostat
633
                        zpool_iostat
634
                        ..
634
                        ..
635
                        zpool_list
635
                        zpool_list
636
                        ..
636
                        ..
637
                    ..
637
                    ..
638
                    compression
638
                    compression
639
                    ..
639
                    ..
640
                    ctime
640
                    ctime
641
                    ..
641
                    ..
642
                    delegate
642
                    delegate
643
                    ..
643
                    ..
644
                    devices
644
                    devices
645
                    ..
645
                    ..
646
                    exec
646
                    exec
647
                    ..
647
                    ..
648
                    grow_pool
648
                    grow_pool
649
                    ..
649
                    ..
650
                    grow_replicas
650
                    grow_replicas
651
                    ..
651
                    ..
652
                    history
652
                    history
653
                    ..
653
                    ..
654
                    hotplug
654
                    hotplug
655
                    ..
655
                    ..
656
                    hotspare
656
                    hotspare
657
                    ..
657
                    ..
658
                    inheritance
658
                    inheritance
659
                    ..
659
                    ..
660
                    interop
660
                    interop
661
                    ..
661
                    ..
662
                    inuse
662
                    inuse
663
                    ..
663
                    ..
664
                    iscsi
664
                    iscsi
665
                    ..
665
                    ..
666
                    large_files
666
                    large_files
667
                    ..
667
                    ..
668
                    largest_pool
668
                    largest_pool
669
                    ..
669
                    ..
670
                    link_count
670
                    link_count
671
                    ..
671
                    ..
672
                    migration
672
                    migration
673
                    ..
673
                    ..
674
                    mmap
674
                    mmap
675
                    ..
675
                    ..
676
                    mount
676
                    mount
677
                    ..
677
                    ..
678
                    mv_files
678
                    mv_files
679
                    ..
679
                    ..
680
                    nestedfs
680
                    nestedfs
681
                    ..
681
                    ..
682
                    no_space
682
                    no_space
683
                    ..
683
                    ..
684
                    online_offline
684
                    online_offline
685
                    ..
685
                    ..
686
                    pool_names
686
                    pool_names
687
                    ..
687
                    ..
688
                    poolversion
688
                    poolversion
689
                    ..
689
                    ..
690
                    quota
690
                    quota
691
                    ..
691
                    ..
692
                    redundancy
692
                    redundancy
693
                    ..
693
                    ..
694
                    refquota
694
                    refquota
695
                    ..
695
                    ..
696
                    refreserv
696
                    refreserv
697
                    ..
697
                    ..
698
                    rename_dirs
698
                    rename_dirs
699
                    ..
699
                    ..
700
                    replacement
700
                    replacement
701
                    ..
701
                    ..
702
                    reservation
702
                    reservation
703
                    ..
703
                    ..
704
                    rootpool
704
                    rootpool
705
                    ..
705
                    ..
706
                    rsend
706
                    rsend
707
                    ..
707
                    ..
708
                    scrub_mirror
708
                    scrub_mirror
709
                    ..
709
                    ..
710
                    slog
710
                    slog
711
                    ..
711
                    ..
712
                    snapshot
712
                    snapshot
713
                    ..
713
                    ..
714
                    snapused
714
                    snapused
715
                    ..
715
                    ..
716
                    sparse
716
                    sparse
717
                    ..
717
                    ..
718
                    threadsappend
718
                    threadsappend
719
                    ..
719
                    ..
720
                    truncate
720
                    truncate
721
                    ..
721
                    ..
722
                    txg_integrity
722
                    txg_integrity
723
                    ..
723
                    ..
724
                    userquota
724
                    userquota
725
                    ..
725
                    ..
726
                    utils_test
726
                    utils_test
727
                    ..
727
                    ..
728
                    write_dirs
728
                    write_dirs
729
                    ..
729
                    ..
730
                    xattr
730
                    xattr
731
                    ..
731
                    ..
732
                    zfsd
732
                    zfsd
733
                    ..
733
                    ..
734
                    zil
734
                    zil
735
                    ..
735
                    ..
736
                    zinject
736
                    zinject
737
                    ..
737
                    ..
738
                    zones
738
                    zones
739
                    ..
739
                    ..
740
                    zvol
740
                    zvol
741
                        zvol_ENOSPC
741
                        zvol_ENOSPC
742
                        ..
742
                        ..
743
                        zvol_cli
743
                        zvol_cli
744
                        ..
744
                        ..
745
                        zvol_misc
745
                        zvol_misc
746
                        ..
746
                        ..
747
                        zvol_swap
747
                        zvol_swap
748
                        ..
748
                        ..
749
                    ..
749
                    ..
750
                    zvol_thrash
750
                    zvol_thrash
751
                    ..
751
                    ..
752
                ..
752
                ..
753
            ..
753
            ..
754
        ..
754
        ..
755
        compat32
755
        compat32
756
        ..
756
        ..
757
        devrandom
757
        devrandom
758
        ..
758
        ..
759
        dtrace
759
        dtrace
760
        ..
760
        ..
761
        fifo
761
        fifo
762
        ..
762
        ..
763
        file
763
        file
764
        ..
764
        ..
765
        fs
765
        fs
766
            fusefs
766
            fusefs
767
            ..
767
            ..
768
            tarfs
768
            tarfs
769
            ..
769
            ..
770
            tmpfs
770
            tmpfs
771
            ..
771
            ..
772
        ..
772
        ..
773
        geom
773
        geom
774
            class
774
            class
775
                concat
775
                concat
776
                ..
776
                ..
777
                eli
777
                eli
778
                ..
778
                ..
779
                gate
779
                gate
780
                ..
780
                ..
781
                gpt
781
                gpt
782
                ..
782
                ..
783
                mirror
783
                mirror
784
                ..
784
                ..
785
                multipath
785
                multipath
786
                ..
786
                ..
787
                nop
787
                nop
788
                ..
788
                ..
789
                part
789
                part
790
                ..
790
                ..
791
                raid3
791
                raid3
792
                ..
792
                ..
793
                shsec
793
                shsec
794
                ..
794
                ..
795
                stripe
795
                stripe
796
                ..
796
                ..
797
                uzip
797
                uzip
798
                    etalon
798
                    etalon
799
                    ..
799
                    ..
800
                ..
800
                ..
801
            ..
801
            ..
802
        ..
802
        ..
803
        kern
803
        kern
804
            acct
804
            acct
805
            ..
805
            ..
806
            execve
806
            execve
807
            ..
807
            ..
808
            pipe
808
            pipe
809
            ..
809
            ..
810
        ..
810
        ..
811
        kqueue
811
        kqueue
812
            libkqueue
812
            libkqueue
813
            ..
813
            ..
814
        ..
814
        ..
815
        mac
815
        mac
816
            bsdextended
816
            bsdextended
817
            ..
817
            ..
818
            ipacl
818
            ipacl
819
            ..
819
            ..
820
            portacl
820
            portacl
821
            ..
821
            ..
822
        ..
822
        ..
823
        mqueue
823
        mqueue
824
        ..
824
        ..
825
        net
825
        net
826
            if_ovpn
826
            if_ovpn
827
            ..
827
            ..
828
            routing
828
            routing
829
            ..
829
            ..
830
        ..
830
        ..
831
        netgraph
831
        netgraph
832
        ..
832
        ..
833
        netinet
833
        netinet
834
        ..
834
        ..
835
        netinet6
835
        netinet6
836
            frag6
836
            frag6
837
            ..
837
            ..
838
        ..
838
        ..
839
        netipsec
839
        netipsec
840
            tunnel
840
            tunnel
841
            ..
841
            ..
842
        ..
842
        ..
843
        netlink
843
        netlink
844
        ..
844
        ..
845
        netmap
845
        netmap
846
        ..
846
        ..
847
        netpfil
847
        netpfil
848
            common
848
            common
849
            ..
849
            ..
850
            ipfw
850
            ipfw
851
            ..
851
            ..
852
            pf
852
            pf
853
                ioctl
853
                ioctl
854
                ..
854
                ..
855
            ..
855
            ..
856
        ..
856
        ..
857
        opencrypto
857
        opencrypto
858
        ..
858
        ..
859
        pjdfstest
859
        pjdfstest
860
            chflags
860
            chflags
861
            ..
861
            ..
862
            chmod
862
            chmod
863
            ..
863
            ..
864
            chown
864
            chown
865
            ..
865
            ..
866
            ftruncate
866
            ftruncate
867
            ..
867
            ..
868
            granular
868
            granular
869
            ..
869
            ..
870
            link
870
            link
871
            ..
871
            ..
872
            mkdir
872
            mkdir
873
            ..
873
            ..
874
            mkfifo
874
            mkfifo
875
            ..
875
            ..
876
            mknod
876
            mknod
877
            ..
877
            ..
878
            open
878
            open
879
            ..
879
            ..
880
            rename
880
            rename
881
            ..
881
            ..
882
            rmdir
882
            rmdir
883
            ..
883
            ..
884
            symlink
884
            symlink
885
            ..
885
            ..
886
            truncate
886
            truncate
887
            ..
887
            ..
888
            unlink
888
            unlink
889
            ..
889
            ..
890
            utimensat
890
            utimensat
891
            ..
891
            ..
892
        ..
892
        ..
893
        posixshm
893
        posixshm
894
        ..
894
        ..
895
        sys
895
        sys
896
        ..
896
        ..
897
        vfs
897
        vfs
898
        ..
898
        ..
899
        vm
899
        vm
900
        ..
900
        ..
901
        vmm
901
        vmm
902
        ..
902
        ..
903
    ..
903
    ..
904
    usr.bin
904
    usr.bin
905
        apply
905
        apply
906
        ..
906
        ..
907
        asa
907
        asa
908
        ..
908
        ..
909
        awk
909
        awk
910
            bugs-fixed
910
            bugs-fixed
911
            ..
911
            ..
912
            netbsd
912
            netbsd
913
            ..
913
            ..
914
        ..
914
        ..
915
        basename
915
        basename
916
        ..
916
        ..
917
        bintrans
917
        bintrans
918
        ..
918
        ..
919
        bmake
919
        bmake
920
            archives
920
            archives
921
                fmt_44bsd
921
                fmt_44bsd
922
                ..
922
                ..
923
                fmt_44bsd_mod
923
                fmt_44bsd_mod
924
                ..
924
                ..
925
                fmt_oldbsd
925
                fmt_oldbsd
926
                ..
926
                ..
927
            ..
927
            ..
928
            basic
928
            basic
929
                t0
929
                t0
930
                ..
930
                ..
931
                t1
931
                t1
932
                ..
932
                ..
933
                t2
933
                t2
934
                ..
934
                ..
935
                t3
935
                t3
936
                ..
936
                ..
937
            ..
937
            ..
938
            execution
938
            execution
939
                ellipsis
939
                ellipsis
940
                ..
940
                ..
941
                empty
941
                empty
942
                ..
942
                ..
943
                joberr
943
                joberr
944
                ..
944
                ..
945
                plus
945
                plus
946
                ..
946
                ..
947
            ..
947
            ..
948
            shell
948
            shell
949
                builtin
949
                builtin
950
                ..
950
                ..
951
                meta
951
                meta
952
                ..
952
                ..
953
                path
953
                path
954
                ..
954
                ..
955
                path_select
955
                path_select
956
                ..
956
                ..
957
                replace
957
                replace
958
                ..
958
                ..
959
                select
959
                select
960
                ..
960
                ..
961
            ..
961
            ..
962
            suffixes
962
            suffixes
963
                basic
963
                basic
964
                ..
964
                ..
965
                src_wild1
965
                src_wild1
966
                ..
966
                ..
967
                src_wild2
967
                src_wild2
968
                ..
968
                ..
969
            ..
969
            ..
970
            syntax
970
            syntax
971
                directive-t0
971
                directive-t0
972
                ..
972
                ..
973
                enl
973
                enl
974
                ..
974
                ..
975
                funny-targets
975
                funny-targets
976
                ..
976
                ..
977
                semi
977
                semi
978
                ..
978
                ..
979
            ..
979
            ..
980
            sysmk
980
            sysmk
981
                t0
981
                t0
982
                    2
982
                    2
983
                        1
983
                        1
984
                        ..
984
                        ..
985
                    ..
985
                    ..
986
                    mk
986
                    mk
987
                    ..
987
                    ..
988
                ..
988
                ..
989
                t1
989
                t1
990
                    2
990
                    2
991
                        1
991
                        1
992
                        ..
992
                        ..
993
                    ..
993
                    ..
994
                    mk
994
                    mk
995
                    ..
995
                    ..
996
                ..
996
                ..
997
                t2
997
                t2
998
                    2
998
                    2
999
                        1
999
                        1
1000
                        ..
1000
                        ..
1001
                    ..
1001
                    ..
1002
                    mk
1002
                    mk
1003
                    ..
1003
                    ..
1004
                ..
1004
                ..
1005
            ..
1005
            ..
1006
            variables
1006
            variables
1007
                modifier_M
1007
                modifier_M
1008
                ..
1008
                ..
1009
                modifier_t
1009
                modifier_t
1010
                ..
1010
                ..
1011
                opt_V
1011
                opt_V
1012
                ..
1012
                ..
1013
                t0
1013
                t0
1014
                ..
1014
                ..
1015
            ..
1015
            ..
1016
        ..
1016
        ..
1017
        bsdcat
1017
        bsdcat
1018
        ..
1018
        ..
1019
        calendar
1019
        calendar
1020
        ..
1020
        ..
1021
        cmp
1021
        cmp
1022
        ..
1022
        ..
1023
        compress
1023
        compress
1024
        ..
1024
        ..
1025
        cpio
1025
        cpio
1026
        ..
1026
        ..
1027
        col
1027
        col
1028
        ..
1028
        ..
1029
        comm
1029
        comm
1030
        ..
1030
        ..
1031
        csplit
1031
        csplit
1032
        ..
1032
        ..
1033
        cut
1033
        cut
1034
        ..
1034
        ..
1035
        dc
1035
        dc
1036
        ..
1036
        ..
1037
        diff
1037
        diff
1038
        ..
1038
        ..
1039
        diff3
1039
        diff3
1040
        ..
1040
        ..
1041
        dirname
1041
        dirname
1042
        ..
1042
        ..
1043
        du
1043
        du
1044
        ..
1044
        ..
1045
        factor
1045
        factor
1046
        ..
1046
        ..
1047
        file2c
1047
        file2c
1048
        ..
1048
        ..
1049
        file
1049
        file
1050
        ..
1050
        ..
1051
        find
1051
        find
1052
        ..
1052
        ..
1053
        fold
1053
        fold
1054
        ..
1054
        ..
1055
        getconf
1055
        getconf
1056
        ..
1056
        ..
1057
        gh-bc
1057
        gh-bc
1058
        ..
1058
        ..
1059
        grep
1059
        grep
1060
        ..
1060
        ..
1061
        gzip
1061
        gzip
1062
        ..
1062
        ..
1063
        head
1063
        head
1064
        ..
1064
        ..
1065
        hexdump
1065
        hexdump
1066
        ..
1066
        ..
1067
        ident
1067
        ident
1068
        ..
1068
        ..
1069
        indent
1069
        indent
1070
        ..
1070
        ..
1071
        join
1071
        join
1072
        ..
1072
        ..
1073
        jot
1073
        jot
1074
        ..
1074
        ..
1075
        lastcomm
1075
        lastcomm
1076
        ..
1076
        ..
1077
        limits
1077
        limits
1078
        ..
1078
        ..
1079
        locale
1079
        locale
1080
        ..
1080
        ..
1081
        m4
1081
        m4
1082
        ..
1082
        ..
1083
        mkimg
1083
        mkimg
1084
        ..
1084
        ..
1085
        mktemp
1085
        mktemp
1086
        ..
1086
        ..
1087
        ncal
1087
        ncal
1088
        ..
1088
        ..
1089
        opensm
1089
        opensm
1090
        ..
1090
        ..
1091
        patch
1091
        patch
1092
        ..
1092
        ..
1093
        pr
1093
        pr
1094
        ..
1094
        ..
1095
        printf
1095
        printf
1096
        ..
1096
        ..
1097
        procstat
1097
        procstat
1098
        ..
1098
        ..
1099
        renice
1099
        renice
1100
        ..
1100
        ..
1101
        rs
1101
        rs
1102
        ..
1102
        ..
1103
        sdiff
1103
        sdiff
1104
        ..
1104
        ..
1105
        sed
1105
        sed
1106
            regress.multitest.out
1106
            regress.multitest.out
1107
            ..
1107
            ..
1108
        ..
1108
        ..
1109
        seq
1109
        seq
1110
        ..
1110
        ..
1111
        soelim
1111
        soelim
1112
        ..
1112
        ..
1113
        sort
1113
        sort
1114
        ..
1114
        ..
1115
        split
1115
        split
1116
        ..
1116
        ..
1117
        stat
1117
        stat
1118
        ..
1118
        ..
1119
        tail
1119
        tail
1120
        ..
1120
        ..
1121
        tar
1121
        tar
1122
        ..
1122
        ..
1123
        tftp
1123
        tftp
1124
        ..
1124
        ..
1125
        tr
1125
        tr
1126
        ..
1126
        ..
1127
        truncate
1127
        truncate
1128
        ..
1128
        ..
1129
        tsort
1129
        tsort
1130
        ..
1130
        ..
1131
        units
1131
        units
1132
        ..
1132
        ..
1133
        unifdef
1133
        unifdef
1134
        ..
1134
        ..
1135
        uniq
1135
        uniq
1136
        ..
1136
        ..
1137
        unzip
1138
        ..
1137
        vmstat
1139
        vmstat
1138
        ..
1140
        ..
1139
        wc
1141
        wc
1140
        ..
1142
        ..
1141
        xargs
1143
        xargs
1142
        ..
1144
        ..
1143
        xinstall
1145
        xinstall
1144
        ..
1146
        ..
1145
        xo
1147
        xo
1146
        ..
1148
        ..
1147
        yacc
1149
        yacc
1148
            yacc
1150
            yacc
1149
            ..
1151
            ..
1150
        ..
1152
        ..
1151
    ..
1153
    ..
1152
    usr.sbin
1154
    usr.sbin
1153
        chown
1155
        chown
1154
        ..
1156
        ..
1155
        daemon
1157
        daemon
1156
        ..
1158
        ..
1157
        etcupdate
1159
        etcupdate
1158
        ..
1160
        ..
1159
        extattr
1161
        extattr
1160
        ..
1162
        ..
1161
        fstyp
1163
        fstyp
1162
        ..
1164
        ..
1163
        jail
1165
        jail
1164
        ..
1166
        ..
1165
        makefs
1167
        makefs
1166
        ..
1168
        ..
1167
        mixer
1169
        mixer
1168
        ..
1170
        ..
1169
        newsyslog
1171
        newsyslog
1170
        ..
1172
        ..
1171
        nmtree
1173
        nmtree
1172
        ..
1174
        ..
1173
        praudit
1175
        praudit
1174
        ..
1176
        ..
1175
        pw
1177
        pw
1176
        ..
1178
        ..
1177
        rpcbind
1179
        rpcbind
1178
        ..
1180
        ..
1179
        sa
1181
        sa
1180
        ..
1182
        ..
1181
    ..
1183
    ..
1182
..
1184
..
1183
1185
1184
# vim: set expandtab ts=4 sw=4:
1186
# vim: set expandtab ts=4 sw=4:
(-)b/lib/libarchive/config_freebsd.h (+5 lines)
Lines 1-267 Link Here
1
/*-
1
/*-
2
 * SPDX-License-Identifier: BSD-2-Clause
2
 * SPDX-License-Identifier: BSD-2-Clause
3
 *
3
 *
4
 * Copyright (c) 2003-2007 Tim Kientzle
4
 * Copyright (c) 2003-2007 Tim Kientzle
5
 * All rights reserved.
5
 * All rights reserved.
6
 *
6
 *
7
 * Redistribution and use in source and binary forms, with or without
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
8
 * modification, are permitted provided that the following conditions
9
 * are met:
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
14
 *    documentation and/or other materials provided with the distribution.
15
 *
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 *
26
 *
27
 * $FreeBSD$
27
 * $FreeBSD$
28
 */
28
 */
29
#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
29
#define __LIBARCHIVE_CONFIG_H_INCLUDED 1
30
30
31
#include <osreldate.h>
31
#include <osreldate.h>
32
32
33
/* FreeBSD 5.0 and later has ACL and extattr support. */
33
/* FreeBSD 5.0 and later has ACL and extattr support. */
34
#if __FreeBSD__ > 4
34
#if __FreeBSD__ > 4
35
#define ARCHIVE_ACL_FREEBSD 1
35
#define ARCHIVE_ACL_FREEBSD 1
36
#define ARCHIVE_XATTR_FREEBSD 1
36
#define ARCHIVE_XATTR_FREEBSD 1
37
#define HAVE_ACL_GET_PERM_NP 1
37
#define HAVE_ACL_GET_PERM_NP 1
38
#define HAVE_ARC4RANDOM_BUF 1
38
#define HAVE_ARC4RANDOM_BUF 1
39
#define HAVE_STRUCT_XVFSCONF 1
39
#define HAVE_STRUCT_XVFSCONF 1
40
#define HAVE_SYS_ACL_H 1
40
#define HAVE_SYS_ACL_H 1
41
#define HAVE_SYS_EXTATTR_H 1
41
#define HAVE_SYS_EXTATTR_H 1
42
#if __FreeBSD__ > 7
42
#if __FreeBSD__ > 7
43
/* FreeBSD 8.0 and later has NFSv4 ACL support */
43
/* FreeBSD 8.0 and later has NFSv4 ACL support */
44
#define ARCHIVE_ACL_FREEBSD_NFS4 1
44
#define ARCHIVE_ACL_FREEBSD_NFS4 1
45
#define HAVE_ACL_GET_LINK_NP 1
45
#define HAVE_ACL_GET_LINK_NP 1
46
#define HAVE_ACL_IS_TRIVIAL_NP 1
46
#define HAVE_ACL_IS_TRIVIAL_NP 1
47
#define HAVE_ACL_SET_LINK_NP 1
47
#define HAVE_ACL_SET_LINK_NP 1
48
#endif /* __FreeBSD__ > 7 */
48
#endif /* __FreeBSD__ > 7 */
49
#endif /* __FreeBSD__ > 4 */
49
#endif /* __FreeBSD__ > 4 */
50
50
51
#ifdef WITH_OPENSSL
51
#ifdef WITH_OPENSSL
52
#define HAVE_LIBCRYPTO 1
52
#define HAVE_LIBCRYPTO 1
53
#define HAVE_OPENSSL_EVP_H 1
53
#define HAVE_OPENSSL_EVP_H 1
54
#define HAVE_OPENSSL_MD5_H 1
54
#define HAVE_OPENSSL_MD5_H 1
55
#define HAVE_OPENSSL_RIPEMD_H 1
55
#define HAVE_OPENSSL_RIPEMD_H 1
56
#define HAVE_OPENSSL_SHA_H 1
56
#define HAVE_OPENSSL_SHA_H 1
57
#define HAVE_OPENSSL_SHA256_INIT 1
57
#define HAVE_OPENSSL_SHA256_INIT 1
58
#define HAVE_OPENSSL_SHA384_INIT 1
58
#define HAVE_OPENSSL_SHA384_INIT 1
59
#define HAVE_OPENSSL_SHA512_INIT 1
59
#define HAVE_OPENSSL_SHA512_INIT 1
60
#define HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
60
#define HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
61
#define HAVE_SHA256 1
61
#define HAVE_SHA256 1
62
#define HAVE_SHA384 1
62
#define HAVE_SHA384 1
63
#define HAVE_SHA512 1
63
#define HAVE_SHA512 1
64
#else
64
#else
65
#define HAVE_LIBMD 1
65
#define HAVE_LIBMD 1
66
#define HAVE_MD5_H 1
66
#define HAVE_MD5_H 1
67
#define HAVE_MD5INIT 1
67
#define HAVE_MD5INIT 1
68
#define HAVE_RIPEMD_H 1
68
#define HAVE_RIPEMD_H 1
69
#define HAVE_SHA_H 1
69
#define HAVE_SHA_H 1
70
#define HAVE_SHA1 1
70
#define HAVE_SHA1 1
71
#define HAVE_SHA1_INIT 1
71
#define HAVE_SHA1_INIT 1
72
#define HAVE_SHA256 1
72
#define HAVE_SHA256 1
73
#define HAVE_SHA256_H 1
73
#define HAVE_SHA256_H 1
74
#define HAVE_SHA256_INIT 1
74
#define HAVE_SHA256_INIT 1
75
#define HAVE_SHA512 1
75
#define HAVE_SHA512 1
76
#define HAVE_SHA512_H 1
76
#define HAVE_SHA512_H 1
77
#define HAVE_SHA512_INIT 1
77
#define HAVE_SHA512_INIT 1
78
#endif
78
#endif
79
79
80
#define HAVE_BSDXML_H 1
80
#define HAVE_BSDXML_H 1
81
#define HAVE_BZLIB_H 1
81
#define HAVE_BZLIB_H 1
82
#define HAVE_CHFLAGS 1
82
#define HAVE_CHFLAGS 1
83
#define HAVE_CHOWN 1
83
#define HAVE_CHOWN 1
84
#define HAVE_CHROOT 1
84
#define HAVE_CHROOT 1
85
#define HAVE_CTIME_R 1
85
#define HAVE_CTIME_R 1
86
#define HAVE_CTYPE_H 1
86
#define HAVE_CTYPE_H 1
87
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 1
87
#define HAVE_DECL_EXTATTR_NAMESPACE_USER 1
88
#define HAVE_DECL_INT32_MAX 1
88
#define HAVE_DECL_INT32_MAX 1
89
#define HAVE_DECL_INT32_MIN 1
89
#define HAVE_DECL_INT32_MIN 1
90
#define HAVE_DECL_INT64_MAX 1
90
#define HAVE_DECL_INT64_MAX 1
91
#define HAVE_DECL_INT64_MIN 1
91
#define HAVE_DECL_INT64_MIN 1
92
#define HAVE_DECL_INTMAX_MAX 1
92
#define HAVE_DECL_INTMAX_MAX 1
93
#define HAVE_DECL_INTMAX_MIN 1
93
#define HAVE_DECL_INTMAX_MIN 1
94
#define HAVE_DECL_SIZE_MAX 1
94
#define HAVE_DECL_SIZE_MAX 1
95
#define HAVE_DECL_SSIZE_MAX 1
95
#define HAVE_DECL_SSIZE_MAX 1
96
#define HAVE_DECL_STRERROR_R 1
96
#define HAVE_DECL_STRERROR_R 1
97
#define HAVE_DECL_UINT32_MAX 1
97
#define HAVE_DECL_UINT32_MAX 1
98
#define HAVE_DECL_UINT64_MAX 1
98
#define HAVE_DECL_UINT64_MAX 1
99
#define HAVE_DECL_UINTMAX_MAX 1
99
#define HAVE_DECL_UINTMAX_MAX 1
100
#define HAVE_DIRENT_H 1
100
#define HAVE_DIRENT_H 1
101
#define HAVE_DIRFD 1
101
#define HAVE_DIRFD 1
102
#define HAVE_DLFCN_H 1
102
#define HAVE_DLFCN_H 1
103
#ifndef __linux__
103
#ifndef __linux__
104
#define HAVE_D_MD_ORDER 1
104
#define HAVE_D_MD_ORDER 1
105
#endif
105
#endif
106
#define HAVE_EFTYPE 1
106
#define HAVE_EFTYPE 1
107
#define HAVE_EILSEQ 1
107
#define HAVE_EILSEQ 1
108
#define HAVE_ERRNO_H 1
108
#define HAVE_ERRNO_H 1
109
#define HAVE_FCHDIR 1
109
#define HAVE_FCHDIR 1
110
#define HAVE_FCHFLAGS 1
110
#define HAVE_FCHFLAGS 1
111
#define HAVE_FCHMOD 1
111
#define HAVE_FCHMOD 1
112
#define HAVE_FCHOWN 1
112
#define HAVE_FCHOWN 1
113
#define HAVE_FCNTL 1
113
#define HAVE_FCNTL 1
114
#define HAVE_FCNTL_H 1
114
#define HAVE_FCNTL_H 1
115
#define HAVE_FDOPENDIR 1
115
#define HAVE_FDOPENDIR 1
116
#define HAVE_FNMATCH 1
117
#define HAVE_FNMATCH_H 1
116
#define HAVE_FORK 1
118
#define HAVE_FORK 1
117
#define HAVE_FSEEKO 1
119
#define HAVE_FSEEKO 1
118
#define HAVE_FSTAT 1
120
#define HAVE_FSTAT 1
119
#define HAVE_FSTATAT 1
121
#define HAVE_FSTATAT 1
120
#define HAVE_FSTATFS 1
122
#define HAVE_FSTATFS 1
121
#define HAVE_FSTATVFS 1
123
#define HAVE_FSTATVFS 1
122
#define HAVE_FTRUNCATE 1
124
#define HAVE_FTRUNCATE 1
123
#define HAVE_FUTIMES 1
125
#define HAVE_FUTIMES 1
124
#define HAVE_FUTIMESAT 1
126
#define HAVE_FUTIMESAT 1
125
#define HAVE_GETEUID 1
127
#define HAVE_GETEUID 1
126
#define HAVE_GETGRGID_R 1
128
#define HAVE_GETGRGID_R 1
127
#define HAVE_GETGRNAM_R 1
129
#define HAVE_GETGRNAM_R 1
130
#define HAVE_GETLINE 1
131
#define HAVE_GETOPT_OPTRESET 1
128
#define HAVE_GETPID 1
132
#define HAVE_GETPID 1
129
#define HAVE_GETPWNAM_R 1
133
#define HAVE_GETPWNAM_R 1
130
#define HAVE_GETPWUID_R 1
134
#define HAVE_GETPWUID_R 1
131
#define HAVE_GETVFSBYNAME 1
135
#define HAVE_GETVFSBYNAME 1
132
#define HAVE_GMTIME_R 1
136
#define HAVE_GMTIME_R 1
133
#define HAVE_GRP_H 1
137
#define HAVE_GRP_H 1
134
#define HAVE_INTMAX_T 1
138
#define HAVE_INTMAX_T 1
135
#define HAVE_INTTYPES_H 1
139
#define HAVE_INTTYPES_H 1
136
#define HAVE_LANGINFO_H 1
140
#define HAVE_LANGINFO_H 1
137
#define HAVE_LCHFLAGS 1
141
#define HAVE_LCHFLAGS 1
138
#define HAVE_LCHMOD 1
142
#define HAVE_LCHMOD 1
139
#define HAVE_LCHOWN 1
143
#define HAVE_LCHOWN 1
140
#define HAVE_LIBZ 1
144
#define HAVE_LIBZ 1
141
#define HAVE_LIMITS_H 1
145
#define HAVE_LIMITS_H 1
142
#define HAVE_LINK 1
146
#define HAVE_LINK 1
143
#define HAVE_LINKAT 1
147
#define HAVE_LINKAT 1
144
#define HAVE_LOCALE_H 1
148
#define HAVE_LOCALE_H 1
145
#define HAVE_LOCALTIME_R 1
149
#define HAVE_LOCALTIME_R 1
146
#define HAVE_LONG_LONG_INT 1
150
#define HAVE_LONG_LONG_INT 1
147
#define HAVE_LSTAT 1
151
#define HAVE_LSTAT 1
148
#define HAVE_LUTIMES 1
152
#define HAVE_LUTIMES 1
149
#define HAVE_MBRTOWC 1
153
#define HAVE_MBRTOWC 1
150
#define HAVE_MEMMOVE 1
154
#define HAVE_MEMMOVE 1
151
#define HAVE_MEMORY_H 1
155
#define HAVE_MEMORY_H 1
152
#define HAVE_MEMSET 1
156
#define HAVE_MEMSET 1
153
#define HAVE_MKDIR 1
157
#define HAVE_MKDIR 1
154
#define HAVE_MKFIFO 1
158
#define HAVE_MKFIFO 1
155
#define HAVE_MKNOD 1
159
#define HAVE_MKNOD 1
156
#define HAVE_MKSTEMP 1
160
#define HAVE_MKSTEMP 1
157
#define HAVE_NL_LANGINFO 1
161
#define HAVE_NL_LANGINFO 1
158
#define HAVE_OPENAT 1
162
#define HAVE_OPENAT 1
159
#define HAVE_PATHS_H 1
163
#define HAVE_PATHS_H 1
160
#define HAVE_PIPE 1
164
#define HAVE_PIPE 1
161
#define HAVE_POLL 1
165
#define HAVE_POLL 1
162
#define HAVE_POLL_H 1
166
#define HAVE_POLL_H 1
163
#define HAVE_POSIX_SPAWNP 1
167
#define HAVE_POSIX_SPAWNP 1
164
#define HAVE_PTHREAD_H 1
168
#define HAVE_PTHREAD_H 1
165
#define HAVE_PWD_H 1
169
#define HAVE_PWD_H 1
166
#define HAVE_READDIR_R 1
170
#define HAVE_READDIR_R 1
167
#define HAVE_READLINK 1
171
#define HAVE_READLINK 1
168
#define HAVE_READLINKAT 1
172
#define HAVE_READLINKAT 1
169
#ifndef __linux__
173
#ifndef __linux__
170
#define HAVE_READPASSPHRASE 1
174
#define HAVE_READPASSPHRASE 1
171
#define HAVE_READPASSPHRASE_H 1
175
#define HAVE_READPASSPHRASE_H 1
172
#endif
176
#endif
173
#define HAVE_REGEX_H 1
177
#define HAVE_REGEX_H 1
174
#define HAVE_SELECT 1
178
#define HAVE_SELECT 1
175
#define HAVE_SETENV 1
179
#define HAVE_SETENV 1
176
#define HAVE_SETLOCALE 1
180
#define HAVE_SETLOCALE 1
177
#define HAVE_SIGACTION 1
181
#define HAVE_SIGACTION 1
178
#define HAVE_SIGNAL_H 1
182
#define HAVE_SIGNAL_H 1
179
#define HAVE_SPAWN_H 1
183
#define HAVE_SPAWN_H 1
180
#define HAVE_STATFS 1
184
#define HAVE_STATFS 1
181
#define HAVE_STATVFS 1
185
#define HAVE_STATVFS 1
182
#define HAVE_STDARG_H 1
186
#define HAVE_STDARG_H 1
183
#define HAVE_STDINT_H 1
187
#define HAVE_STDINT_H 1
184
#define HAVE_STDLIB_H 1
188
#define HAVE_STDLIB_H 1
185
#define HAVE_STRCHR 1
189
#define HAVE_STRCHR 1
186
#define HAVE_STRDUP 1
190
#define HAVE_STRDUP 1
187
#define HAVE_STRERROR 1
191
#define HAVE_STRERROR 1
188
#define HAVE_STRERROR_R 1
192
#define HAVE_STRERROR_R 1
189
#define HAVE_STRFTIME 1
193
#define HAVE_STRFTIME 1
190
#define HAVE_STRINGS_H 1
194
#define HAVE_STRINGS_H 1
191
#define HAVE_STRING_H 1
195
#define HAVE_STRING_H 1
192
#define HAVE_STRNLEN 1
196
#define HAVE_STRNLEN 1
193
#define HAVE_STRRCHR 1
197
#define HAVE_STRRCHR 1
194
#define HAVE_STRUCT_STATFS_F_NAMEMAX 1
198
#define HAVE_STRUCT_STATFS_F_NAMEMAX 1
195
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
199
#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
196
#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
200
#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
197
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
201
#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
198
#define HAVE_STRUCT_STAT_ST_FLAGS 1
202
#define HAVE_STRUCT_STAT_ST_FLAGS 1
199
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
203
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
200
#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
204
#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
201
#define HAVE_STRUCT_TM_TM_GMTOFF 1
205
#define HAVE_STRUCT_TM_TM_GMTOFF 1
202
#define HAVE_SYMLINK 1
206
#define HAVE_SYMLINK 1
203
#define HAVE_SYS_CDEFS_H 1
207
#define HAVE_SYS_CDEFS_H 1
204
#define HAVE_SYS_IOCTL_H 1
208
#define HAVE_SYS_IOCTL_H 1
205
#define HAVE_SYS_MOUNT_H 1
209
#define HAVE_SYS_MOUNT_H 1
206
#define HAVE_SYS_PARAM_H 1
210
#define HAVE_SYS_PARAM_H 1
207
#define HAVE_SYS_POLL_H 1
211
#define HAVE_SYS_POLL_H 1
212
#define HAVE_SYS_QUEUE_H 1
208
#define HAVE_SYS_SELECT_H 1
213
#define HAVE_SYS_SELECT_H 1
209
#define HAVE_SYS_STATVFS_H 1
214
#define HAVE_SYS_STATVFS_H 1
210
#define HAVE_SYS_STAT_H 1
215
#define HAVE_SYS_STAT_H 1
211
#define HAVE_SYS_TIME_H 1
216
#define HAVE_SYS_TIME_H 1
212
#define HAVE_SYS_TYPES_H 1
217
#define HAVE_SYS_TYPES_H 1
213
#define HAVE_SYS_UTSNAME_H 1
218
#define HAVE_SYS_UTSNAME_H 1
214
#define HAVE_SYS_WAIT_H 1
219
#define HAVE_SYS_WAIT_H 1
215
#define HAVE_TIMEGM 1
220
#define HAVE_TIMEGM 1
216
#define HAVE_TIME_H 1
221
#define HAVE_TIME_H 1
217
#define HAVE_TZSET 1
222
#define HAVE_TZSET 1
218
#define HAVE_UINTMAX_T 1
223
#define HAVE_UINTMAX_T 1
219
#define HAVE_UNISTD_H 1
224
#define HAVE_UNISTD_H 1
220
#define HAVE_UNLINKAT 1
225
#define HAVE_UNLINKAT 1
221
#define HAVE_UNSETENV 1
226
#define HAVE_UNSETENV 1
222
#define HAVE_UNSIGNED_LONG_LONG 1
227
#define HAVE_UNSIGNED_LONG_LONG 1
223
#define HAVE_UNSIGNED_LONG_LONG_INT 1
228
#define HAVE_UNSIGNED_LONG_LONG_INT 1
224
#define HAVE_UTIME 1
229
#define HAVE_UTIME 1
225
#define HAVE_UTIMES 1
230
#define HAVE_UTIMES 1
226
#define HAVE_UTIME_H 1
231
#define HAVE_UTIME_H 1
227
#define HAVE_VFORK 1
232
#define HAVE_VFORK 1
228
#define HAVE_VPRINTF 1
233
#define HAVE_VPRINTF 1
229
#define HAVE_WCHAR_H 1
234
#define HAVE_WCHAR_H 1
230
#define HAVE_WCHAR_T 1
235
#define HAVE_WCHAR_T 1
231
#define HAVE_WCRTOMB 1
236
#define HAVE_WCRTOMB 1
232
#define HAVE_WCSCMP 1
237
#define HAVE_WCSCMP 1
233
#define HAVE_WCSCPY 1
238
#define HAVE_WCSCPY 1
234
#define HAVE_WCSLEN 1
239
#define HAVE_WCSLEN 1
235
#define HAVE_WCTOMB 1
240
#define HAVE_WCTOMB 1
236
#define HAVE_WCTYPE_H 1
241
#define HAVE_WCTYPE_H 1
237
#define HAVE_WMEMCMP 1
242
#define HAVE_WMEMCMP 1
238
#define HAVE_WMEMCPY 1
243
#define HAVE_WMEMCPY 1
239
#define HAVE_WMEMMOVE 1
244
#define HAVE_WMEMMOVE 1
240
#define HAVE_ZLIB_H 1
245
#define HAVE_ZLIB_H 1
241
#define TIME_WITH_SYS_TIME 1
246
#define TIME_WITH_SYS_TIME 1
242
247
243
#if __FreeBSD_version >= 1100056
248
#if __FreeBSD_version >= 1100056
244
#define HAVE_FUTIMENS 1
249
#define HAVE_FUTIMENS 1
245
#define HAVE_UTIMENSAT 1
250
#define HAVE_UTIMENSAT 1
246
#endif
251
#endif
247
252
248
/* FreeBSD 4 and earlier lack intmax_t/uintmax_t */
253
/* FreeBSD 4 and earlier lack intmax_t/uintmax_t */
249
#if __FreeBSD__ < 5
254
#if __FreeBSD__ < 5
250
#define intmax_t int64_t
255
#define intmax_t int64_t
251
#define uintmax_t uint64_t
256
#define uintmax_t uint64_t
252
#endif
257
#endif
253
258
254
/* FreeBSD defines for archive_hash.h */
259
/* FreeBSD defines for archive_hash.h */
255
#ifdef WITH_OPENSSL
260
#ifdef WITH_OPENSSL
256
#define ARCHIVE_CRYPTO_MD5_OPENSSL 1
261
#define ARCHIVE_CRYPTO_MD5_OPENSSL 1
257
#define ARCHIVE_CRYPTO_RMD160_OPENSSL 1
262
#define ARCHIVE_CRYPTO_RMD160_OPENSSL 1
258
#define ARCHIVE_CRYPTO_SHA1_OPENSSL
263
#define ARCHIVE_CRYPTO_SHA1_OPENSSL
259
#define ARCHIVE_CRYPTO_SHA256_OPENSSL 1
264
#define ARCHIVE_CRYPTO_SHA256_OPENSSL 1
260
#define ARCHIVE_CRYPTO_SHA384_OPENSSL 1
265
#define ARCHIVE_CRYPTO_SHA384_OPENSSL 1
261
#define ARCHIVE_CRYPTO_SHA512_OPENSSL 1
266
#define ARCHIVE_CRYPTO_SHA512_OPENSSL 1
262
#else
267
#else
263
#define ARCHIVE_CRYPTO_MD5_LIBMD 1
268
#define ARCHIVE_CRYPTO_MD5_LIBMD 1
264
#define ARCHIVE_CRYPTO_SHA1_LIBMD 1
269
#define ARCHIVE_CRYPTO_SHA1_LIBMD 1
265
#define ARCHIVE_CRYPTO_SHA256_LIBMD 1
270
#define ARCHIVE_CRYPTO_SHA256_LIBMD 1
266
#define ARCHIVE_CRYPTO_SHA512_LIBMD 1
271
#define ARCHIVE_CRYPTO_SHA512_LIBMD 1
267
#endif
272
#endif
(-)b/usr.bin/unzip/Makefile (-1 / +27 lines)
Lines 1-6 Link Here
1
# $FreeBSD$
1
# $FreeBSD$
2
2
3
PROG = unzip
3
.include <src.opts.mk>
4
5
_LIBARCHIVEDIR=	${SRCTOP}/contrib/libarchive
6
_LIBARCHIVECONFDIR=	${SRCTOP}/lib/libarchive
7
8
PROG=	bsdunzip
9
10
BSDUNZIP_VERSION_STRING!= sed -n '/define.*ARCHIVE_VERSION_ONLY_STRING/{s,[^0-9.],,gp;q;}' \
11
			${_LIBARCHIVEDIR}/libarchive/archive.h
12
13
.PATH:	${_LIBARCHIVEDIR}/unzip
14
SRCS=	bsdunzip.c
15
16
.PATH:	${_LIBARCHIVEDIR}/libarchive_fe
17
SRCS+=	cmdline.c err.c passphrase.c
18
19
CFLAGS+= -DBSDUNZIP_VERSION_STRING=\"${BSDUNZIP_VERSION_STRING}\"
20
CFLAGS+= -DPLATFORM_CONFIG_H=\"${_LIBARCHIVECONFDIR}/config_freebsd.h\"
21
CFLAGS+= -I${_LIBARCHIVEDIR}/unzip -I${_LIBARCHIVEDIR}/libarchive_fe
22
4
LIBADD=	archive
23
LIBADD=	archive
5
24
25
SYMLINKS=bsdunzip ${BINDIR}/unzip
26
MLINKS= bsdunzip.1 unzip.1
27
28
HAS_TESTS=
29
SUBDIR.${MK_TESTS}+= tests
30
6
.include <bsd.prog.mk>
31
.include <bsd.prog.mk>
32
# DO NOT DELETE
(-)b/usr.bin/unzip/tests/Makefile (+74 lines)
Added Link Here
1
# $FreeBSD$
2
3
PACKAGE=	tests
4
5
_LIBARCHIVEDIR=	${SRCTOP}/contrib/libarchive
6
7
ATF_TESTS_SH+=	functional_test
8
9
BINDIR=		${TESTSDIR}
10
11
PROGS+=		bsdunzip_test
12
13
CFLAGS+=	-DPLATFORM_CONFIG_H=\"${SRCTOP}/lib/libarchive/config_freebsd.h\"
14
CFLAGS+=	-I${SRCTOP}/lib/libarchive -I${.OBJDIR}
15
16
CFLAGS+=	-I${.OBJDIR}
17
CFLAGS+=	-I${_LIBARCHIVEDIR}/unzip -I${_LIBARCHIVEDIR}/unzip/test
18
CFLAGS+=	-I${_LIBARCHIVEDIR}/libarchive
19
CFLAGS+=	-I${_LIBARCHIVEDIR}/libarchive_fe -I${_LIBARCHIVEDIR}/test_utils
20
21
# Uncomment to link against dmalloc
22
#LDADD+= -L/usr/local/lib -ldmalloc
23
#CFLAGS+= -I/usr/local/include -DUSE_DMALLOC
24
25
CFLAGS.test_utils.c+=	-Wno-cast-align
26
27
.PATH:	${_LIBARCHIVEDIR}/libarchive_fe
28
UNZIP_SRCS+= err.c
29
30
.PATH:	${_LIBARCHIVEDIR}/unzip/test
31
TESTS_SRCS=	\
32
	test_0.c 				\
33
	test_C.c				\
34
	test_L.c				\
35
	test_P_encryption.c			\
36
	test_Z1.c				\
37
	test_basic.c				\
38
	test_d.c				\
39
	test_glob.c				\
40
	test_j.c				\
41
	test_n.c				\
42
	test_not_exist.c			\
43
	test_o.c				\
44
	test_p.c				\
45
	test_q.c				\
46
	test_singlefile.c 			\
47
	test_t.c				\
48
	test_t_bad.c				\
49
	test_version.c				\
50
	test_x.c
51
52
SRCS.bsdunzip_test= list.h			\
53
	${UNZIP_SRCS}				\
54
	${TESTS_SRCS}
55
56
.PATH:	${_LIBARCHIVEDIR}/test_utils
57
SRCS.bsdunzip_test+=	test_main.c		\
58
			test_utils.c
59
60
LIBADD.bsdunzip_test=	archive
61
62
list.h: ${TESTS_SRCS} Makefile
63
	@(cd ${_LIBARCHIVEDIR}/unzip/test && \
64
	grep -h DEFINE_TEST ${.ALLSRC:N*Makefile}) > ${.TARGET}.tmp
65
	@mv ${.TARGET}.tmp ${.TARGET}
66
67
CLEANFILES+=	list.h list.h.tmp
68
69
${PACKAGE}FILES+= test_basic.zip.uu
70
${PACKAGE}FILES+= test_encrypted.zip.uu
71
${PACKAGE}FILES+= test_singlefile.zip.uu
72
${PACKAGE}FILES+= test_t_bad.zip.uu
73
74
.include <bsd.test.mk>
(-)b/usr.bin/unzip/tests/Makefile.depend (+24 lines)
Added Link Here
1
# $FreeBSD$
2
# Autogenerated - do NOT edit!
3
4
DIRDEPS = \
5
	gnu/lib/csu \
6
	include \
7
	include/xlocale \
8
	lib/${CSU_DIR} \
9
	lib/libarchive \
10
	lib/libbz2 \
11
	lib/libc \
12
	lib/libcompiler_rt \
13
	lib/libexpat \
14
	lib/liblzma \
15
	lib/libthr \
16
	lib/libz \
17
	secure/lib/libcrypto \
18
19
20
.include <dirdeps.mk>
21
22
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
23
# local dependencies - needed for -jN in clean tree
24
.endif
(-)b/usr.bin/unzip/tests/functional_test.sh (+56 lines)
Added Link Here
1
#
2
# Copyright 2015 EMC Corp.
3
# All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions are
7
# met:
8
#
9
# * Redistributions of source code must retain the above copyright
10
#   notice, this list of conditions and the following disclaimer.
11
# * Redistributions in binary form must reproduce the above copyright
12
#   notice, this list of conditions and the following disclaimer in the
13
#   documentation and/or other materials provided with the distribution.
14
#
15
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
#
27
# $FreeBSD$
28
29
SRCDIR=$(atf_get_srcdir)
30
TESTER="${SRCDIR}/bsdunzip_test"
31
export BSDUNZIP=$(which bsdunzip)
32
33
check()
34
{
35
	local testcase=${1}; shift
36
37
	# For some odd reason /bin/sh spuriously writes
38
	# "write error on stdout" with some of the testcases
39
	#
40
	# Probably an issue with how they're written as it calls system(3) to
41
	# clean up directories..
42
	atf_check -e ignore -o ignore -s exit:0 ${TESTER} -d -r "${SRCDIR}" -v "${testcase}"
43
}
44
45
atf_init_test_cases()
46
{
47
	# Redirect stderr to stdout for the usage message because if you don't
48
	# kyua list/kyua test will break:
49
	# https://github.com/jmmv/kyua/issues/149
50
	testcases=$(${TESTER} -h 2>&1 | awk 'p != 0 && $1 ~ /^[0-9]+:/ { print $NF } /Available tests:/ { p=1 }')
51
	for testcase in ${testcases}; do
52
		atf_test_case ${testcase}
53
		eval "${testcase}_body() { check ${testcase}; }"
54
		atf_add_test_case ${testcase}
55
	done
56
}
(-)a/usr.bin/unzip/unzip.1 (-207 lines)
Removed Link Here
1
.\"-
2
.\" Copyright (c) 2007-2008 Dag-Erling Smørgrav
3
.\" All rights reserved.
4
.\"
5
.\" Redistribution and use in source and binary forms, with or without
6
.\" modification, are permitted provided that the following conditions
7
.\" are met:
8
.\" 1. Redistributions of source code must retain the above copyright
9
.\"    notice, this list of conditions and the following disclaimer.
10
.\" 2. Redistributions in binary form must reproduce the above copyright
11
.\"    notice, this list of conditions and the following disclaimer in the
12
.\"    documentation and/or other materials provided with the distribution.
13
.\"
14
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24
.\" SUCH DAMAGE.
25
.\"
26
.\" $FreeBSD$
27
.\"
28
.Dd June 27, 2023
29
.Dt UNZIP 1
30
.Os
31
.Sh NAME
32
.Nm unzip
33
.Nd extract files from a ZIP archive
34
.Sh SYNOPSIS
35
.Nm
36
.Op Fl aCcfjLlnopqtuvy
37
.Op { Fl O | Fl I No } Ar encoding
38
.Op Fl d Ar dir
39
.Op Fl x Ar pattern
40
.Op Fl P Ar password
41
.Ar zipfile
42
.Op Ar member ...
43
.Sh DESCRIPTION
44
.\" ...
45
The following options are available:
46
.Bl -tag -width Fl
47
.It Fl a
48
When extracting a text file, convert DOS-style line endings to
49
Unix-style line endings.
50
.It Fl C
51
Match file names case-insensitively.
52
.It Fl c
53
Extract to stdout/screen.
54
When extracting files from the zipfile, they are written to stdout.
55
This is similar to
56
.Fl p ,
57
but does not suppress normal output.
58
.It Fl d Ar dir
59
Extract files into the specified directory rather than the current
60
directory.
61
.It Fl f
62
Update existing.
63
Extract only files from the zipfile if a file with the same name
64
already exists on disk and is older than the former.
65
Otherwise, the file is silently skipped.
66
.It Fl I Ar encoding
67
.It Fl O Ar encoding
68
Convert filenames from the specified encoding.
69
.It Fl j
70
Ignore directories stored in the zipfile; instead, extract all files
71
directly into the extraction directory.
72
.It Fl L
73
Convert the names of the extracted files and directories to lowercase.
74
.It Fl l
75
List, rather than extract, the contents of the zipfile.
76
.It Fl n
77
No overwrite.
78
When extracting a file from the zipfile, if a file with the same name
79
already exists on disk, the file is silently skipped.
80
.It Fl o
81
Overwrite.
82
When extracting a file from the zipfile, if a file with the same name
83
already exists on disk, the existing file is replaced with the file
84
from the zipfile.
85
.It Fl p
86
Extract to stdout.
87
When extracting files from the zipfile, they are written to stdout.
88
The normal output is suppressed as if
89
.Fl q
90
was specified.
91
.It Fl P Ar password
92
Extract encrypted files using a password.
93
Putting a password on the command line using this option can be
94
insecure.
95
.It Fl q
96
Quiet: print less information while extracting.
97
.It Fl t
98
Test: do not extract anything, but verify the checksum of every file
99
in the archive.
100
.It Fl u
101
Update.
102
When extracting a file from the zipfile, if a file with the same name
103
already exists on disk, the existing file is replaced with the file
104
from the zipfile if and only if the latter is newer than the former.
105
Otherwise, the file is silently skipped.
106
.It Fl v
107
List verbosely, rather than extract, the contents of the zipfile.
108
This differs from
109
.Fl l
110
by using the long listing.
111
Note that most of the data is currently fake and does not reflect the
112
content of the archive.
113
.It Fl x Ar pattern
114
Exclude files matching the pattern
115
.Ar pattern .
116
.It Fl y
117
Print four digit years in listings instead of two.
118
.It Fl Z Ar mode
119
Emulate
120
.Xr zipinfo 1L
121
mode.
122
Enabling
123
.Xr zipinfo 1L
124
mode changes the way in which additional arguments are parsed.
125
Currently only
126
.Xr zipinfo 1L
127
mode 1 is supported, which lists the file names one per line.
128
.It Ar [member ...]
129
Optional list of members to extract from the zipfile.
130
Can include patterns, e.g.,
131
.Ar 'memberdir/*'
132
will extract all files and dirs below memberdir.
133
.El
134
.Pp
135
Note that only one of
136
.Fl n ,
137
.Fl o ,
138
and
139
.Fl u
140
may be specified.
141
If specified filename is
142
.Qq - ,
143
then data is read from
144
.Va stdin .
145
.Sh ENVIRONMENT
146
If the
147
.Ev UNZIP_DEBUG
148
environment variable is defined, the
149
.Fl q
150
command-line option has no effect, and additional debugging
151
information will be printed to
152
.Va stderr .
153
.Sh COMPATIBILITY
154
The
155
.Nm
156
utility aims to be sufficiently compatible with other implementations
157
to serve as a drop-in replacement in the context of the
158
.Xr ports 7
159
system.
160
No attempt has been made to replicate functionality which is not
161
required for that purpose.
162
.Pp
163
For compatibility reasons, command-line options will be recognized if
164
they are listed not only before but also after the name of the
165
zipfile.
166
.Pp
167
Normally, the
168
.Fl a
169
option should only affect files which are marked as text files in the
170
zipfile's central directory.
171
Since the
172
.Xr archive 3
173
library does not provide access to that information, it is not available
174
to the
175
.Nm
176
utility.
177
Instead, the
178
.Nm
179
utility will assume that a file is a text file if no non-ASCII
180
characters are present within the first block of data decompressed for
181
that file.
182
If non-ASCII characters appear in subsequent blocks of data, a warning
183
will be issued.
184
.Pp
185
The
186
.Nm
187
utility is only able to process ZIP archives handled by
188
.Xr libarchive 3 .
189
Depending on the installed version of
190
.Xr libarchive 3 ,
191
this may or may not include self-extracting or ZIPX archives.
192
.Sh SEE ALSO
193
.Xr libarchive 3
194
.Sh HISTORY
195
The
196
.Nm
197
utility appeared in
198
.Fx 8.0 .
199
.Sh AUTHORS
200
The
201
.Nm
202
utility and this manual page were written by
203
.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
204
It uses the
205
.Xr archive 3
206
library developed by
207
.An Tim Kientzle Aq Mt kientzle@FreeBSD.org .
(-)a/usr.bin/unzip/unzip.c (-1141 lines)
Removed Link Here
1
/*-
2
 * SPDX-License-Identifier: BSD-2-Clause
3
 *
4
 * Copyright (c) 2009, 2010 Joerg Sonnenberger <joerg@NetBSD.org>
5
 * Copyright (c) 2007-2008 Dag-Erling Smørgrav
6
 * All rights reserved.
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer
13
 *    in this position and unchanged.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
 * SUCH DAMAGE.
29
 *
30
 * $FreeBSD$
31
 *
32
 * This file would be much shorter if we didn't care about command-line
33
 * compatibility with Info-ZIP's UnZip, which requires us to duplicate
34
 * parts of libarchive in order to gain more detailed control of its
35
 * behaviour for the purpose of implementing the -n, -o, -L and -a
36
 * options.
37
 */
38
39
#include <sys/queue.h>
40
#include <sys/stat.h>
41
42
#include <ctype.h>
43
#include <errno.h>
44
#include <fcntl.h>
45
#include <fnmatch.h>
46
#include <stdarg.h>
47
#include <stdio.h>
48
#include <stdlib.h>
49
#include <string.h>
50
#include <unistd.h>
51
52
#include <archive.h>
53
#include <archive_entry.h>
54
#include <readpassphrase.h>
55
56
/* command-line options */
57
static int		 a_opt;		/* convert EOL */
58
static int		 C_opt;		/* match case-insensitively */
59
static int		 c_opt;		/* extract to stdout */
60
static const char	*d_arg;		/* directory */
61
static int		 f_opt;		/* update existing files only */
62
static char		*O_arg;		/* encoding */
63
static int		 j_opt;		/* junk directories */
64
static int		 L_opt;		/* lowercase names */
65
static int		 n_opt;		/* never overwrite */
66
static int		 o_opt;		/* always overwrite */
67
static int		 p_opt;		/* extract to stdout, quiet */
68
static char		*P_arg;		/* passphrase */
69
static int		 q_opt;		/* quiet */
70
static int		 t_opt;		/* test */
71
static int		 u_opt;		/* update */
72
static int		 v_opt;		/* verbose/list */
73
static const char	*y_str = "";	/* 4 digit year */
74
static int		 Z1_opt;	/* zipinfo mode list files only */
75
76
/* debug flag */
77
static int		 unzip_debug;
78
79
/* zipinfo mode */
80
static int		 zipinfo_mode;
81
82
/* running on tty? */
83
static int		 tty;
84
85
/* convenience macro */
86
/* XXX should differentiate between ARCHIVE_{WARN,FAIL,RETRY} */
87
#define ac(call)						\
88
	do {							\
89
		int acret = (call);				\
90
		if (acret != ARCHIVE_OK)			\
91
			errorx("%s", archive_error_string(a));	\
92
	} while (0)
93
94
/*
95
 * Indicates that last info() did not end with EOL.  This helps error() et
96
 * al. avoid printing an error message on the same line as an incomplete
97
 * informational message.
98
 */
99
static int noeol;
100
101
/* for an interactive passphrase input */
102
static char *passphrase_buf;
103
104
/* fatal error message + errno */
105
static void
106
error(const char *fmt, ...)
107
{
108
	va_list ap;
109
110
	if (noeol)
111
		fprintf(stdout, "\n");
112
	fflush(stdout);
113
	fprintf(stderr, "unzip: ");
114
	va_start(ap, fmt);
115
	vfprintf(stderr, fmt, ap);
116
	va_end(ap);
117
	fprintf(stderr, ": %s\n", strerror(errno));
118
	exit(EXIT_FAILURE);
119
}
120
121
/* fatal error message, no errno */
122
static void
123
errorx(const char *fmt, ...)
124
{
125
	va_list ap;
126
127
	if (noeol)
128
		fprintf(stdout, "\n");
129
	fflush(stdout);
130
	fprintf(stderr, "unzip: ");
131
	va_start(ap, fmt);
132
	vfprintf(stderr, fmt, ap);
133
	va_end(ap);
134
	fprintf(stderr, "\n");
135
	exit(EXIT_FAILURE);
136
}
137
138
/* non-fatal error message + errno */
139
static void
140
warning(const char *fmt, ...)
141
{
142
	va_list ap;
143
144
	if (noeol)
145
		fprintf(stdout, "\n");
146
	fflush(stdout);
147
	fprintf(stderr, "unzip: ");
148
	va_start(ap, fmt);
149
	vfprintf(stderr, fmt, ap);
150
	va_end(ap);
151
	fprintf(stderr, ": %s\n", strerror(errno));
152
}
153
154
/* non-fatal error message, no errno */
155
static void
156
warningx(const char *fmt, ...)
157
{
158
	va_list ap;
159
160
	if (noeol)
161
		fprintf(stdout, "\n");
162
	fflush(stdout);
163
	fprintf(stderr, "unzip: ");
164
	va_start(ap, fmt);
165
	vfprintf(stderr, fmt, ap);
166
	va_end(ap);
167
	fprintf(stderr, "\n");
168
}
169
170
/* informational message (if not -q) */
171
static void
172
info(const char *fmt, ...)
173
{
174
	va_list ap;
175
176
	if (q_opt && !unzip_debug)
177
		return;
178
	va_start(ap, fmt);
179
	vfprintf(stdout, fmt, ap);
180
	va_end(ap);
181
	fflush(stdout);
182
183
	if (*fmt == '\0')
184
		noeol = 1;
185
	else
186
		noeol = fmt[strlen(fmt) - 1] != '\n';
187
}
188
189
/* debug message (if unzip_debug) */
190
static void
191
debug(const char *fmt, ...)
192
{
193
	va_list ap;
194
195
	if (!unzip_debug)
196
		return;
197
	va_start(ap, fmt);
198
	vfprintf(stderr, fmt, ap);
199
	va_end(ap);
200
	fflush(stderr);
201
202
	if (*fmt == '\0')
203
		noeol = 1;
204
	else
205
		noeol = fmt[strlen(fmt) - 1] != '\n';
206
}
207
208
/* duplicate a path name, possibly converting to lower case */
209
static char *
210
pathdup(const char *path)
211
{
212
	char *str;
213
	size_t i, len;
214
215
	if (path == NULL || path[0] == '\0')
216
		return (NULL);
217
218
	len = strlen(path);
219
	while (len && path[len - 1] == '/')
220
		len--;
221
	if ((str = malloc(len + 1)) == NULL) {
222
		errno = ENOMEM;
223
		error("malloc()");
224
	}
225
	if (L_opt) {
226
		for (i = 0; i < len; ++i)
227
			str[i] = tolower((unsigned char)path[i]);
228
	} else {
229
		memcpy(str, path, len);
230
	}
231
	str[len] = '\0';
232
233
	return (str);
234
}
235
236
/* concatenate two path names */
237
static char *
238
pathcat(const char *prefix, const char *path)
239
{
240
	char *str;
241
	size_t prelen, len;
242
243
	prelen = prefix ? strlen(prefix) + 1 : 0;
244
	len = strlen(path) + 1;
245
	if ((str = malloc(prelen + len)) == NULL) {
246
		errno = ENOMEM;
247
		error("malloc()");
248
	}
249
	if (prefix) {
250
		memcpy(str, prefix, prelen);	/* includes zero */
251
		str[prelen - 1] = '/';		/* splat zero */
252
	}
253
	memcpy(str + prelen, path, len);	/* includes zero */
254
255
	return (str);
256
}
257
258
/*
259
 * Pattern lists for include / exclude processing
260
 */
261
struct pattern {
262
	STAILQ_ENTRY(pattern) link;
263
	char pattern[];
264
};
265
266
STAILQ_HEAD(pattern_list, pattern);
267
static struct pattern_list include = STAILQ_HEAD_INITIALIZER(include);
268
static struct pattern_list exclude = STAILQ_HEAD_INITIALIZER(exclude);
269
270
/*
271
 * Add an entry to a pattern list
272
 */
273
static void
274
add_pattern(struct pattern_list *list, const char *pattern)
275
{
276
	struct pattern *entry;
277
	size_t len;
278
279
	debug("adding pattern '%s'\n", pattern);
280
	len = strlen(pattern);
281
	if ((entry = malloc(sizeof *entry + len + 1)) == NULL) {
282
		errno = ENOMEM;
283
		error("malloc()");
284
	}
285
	memcpy(entry->pattern, pattern, len + 1);
286
	STAILQ_INSERT_TAIL(list, entry, link);
287
}
288
289
/*
290
 * Match a string against a list of patterns
291
 */
292
static int
293
match_pattern(struct pattern_list *list, const char *str)
294
{
295
	struct pattern *entry;
296
297
	STAILQ_FOREACH(entry, list, link) {
298
		if (fnmatch(entry->pattern, str, C_opt ? FNM_CASEFOLD : 0) == 0)
299
			return (1);
300
	}
301
	return (0);
302
}
303
304
/*
305
 * Verify that a given pathname is in the include list and not in the
306
 * exclude list.
307
 */
308
static int
309
accept_pathname(const char *pathname)
310
{
311
312
	if (!STAILQ_EMPTY(&include) && !match_pattern(&include, pathname))
313
		return (0);
314
	if (!STAILQ_EMPTY(&exclude) && match_pattern(&exclude, pathname))
315
		return (0);
316
	return (1);
317
}
318
319
/*
320
 * Create the specified directory with the specified mode, taking certain
321
 * precautions on they way.
322
 */
323
static void
324
make_dir(const char *path, int mode)
325
{
326
	struct stat sb;
327
328
	if (lstat(path, &sb) == 0) {
329
		if (S_ISDIR(sb.st_mode))
330
			return;
331
		/*
332
		 * Normally, we should either ask the user about removing
333
		 * the non-directory of the same name as a directory we
334
		 * wish to create, or respect the -n or -o command-line
335
		 * options.  However, this may lead to a later failure or
336
		 * even compromise (if this non-directory happens to be a
337
		 * symlink to somewhere unsafe), so we don't.
338
		 */
339
340
		/*
341
		 * Don't check unlink() result; failure will cause mkdir()
342
		 * to fail later, which we will catch.
343
		 */
344
		(void)unlink(path);
345
	}
346
	if (mkdir(path, mode) != 0 && errno != EEXIST)
347
		error("mkdir('%s')", path);
348
}
349
350
/*
351
 * Ensure that all directories leading up to (but not including) the
352
 * specified path exist.
353
 *
354
 * XXX inefficient + modifies the file in-place
355
 */
356
static void
357
make_parent(char *path)
358
{
359
	struct stat sb;
360
	char *sep;
361
362
	sep = strrchr(path, '/');
363
	if (sep == NULL || sep == path)
364
		return;
365
	*sep = '\0';
366
	if (lstat(path, &sb) == 0) {
367
		if (S_ISDIR(sb.st_mode)) {
368
			*sep = '/';
369
			return;
370
		}
371
		unlink(path);
372
	}
373
	make_parent(path);
374
	mkdir(path, 0755);
375
	*sep = '/';
376
377
#if 0
378
	for (sep = path; (sep = strchr(sep, '/')) != NULL; sep++) {
379
		/* root in case of absolute d_arg */
380
		if (sep == path)
381
			continue;
382
		*sep = '\0';
383
		make_dir(path, 0755);
384
		*sep = '/';
385
	}
386
#endif
387
}
388
389
/*
390
 * Extract a directory.
391
 */
392
static void
393
extract_dir(struct archive *a, struct archive_entry *e, const char *path)
394
{
395
	int mode;
396
397
	/*
398
	 * Dropbox likes to create '/' directory entries, just ignore
399
	 * such junk.
400
	 */
401
	if (*path == '\0')
402
		return;
403
404
	mode = archive_entry_mode(e) & 0777;
405
	if (mode == 0)
406
		mode = 0755;
407
408
	/*
409
	 * Some zipfiles contain directories with weird permissions such
410
	 * as 0644 or 0444.  This can cause strange issues such as being
411
	 * unable to extract files into the directory we just created, or
412
	 * the user being unable to remove the directory later without
413
	 * first manually changing its permissions.  Therefore, we whack
414
	 * the permissions into shape, assuming that the user wants full
415
	 * access and that anyone who gets read access also gets execute
416
	 * access.
417
	 */
418
	mode |= 0700;
419
	if (mode & 0040)
420
		mode |= 0010;
421
	if (mode & 0004)
422
		mode |= 0001;
423
424
	info("   creating: %s/\n", path);
425
	make_dir(path, mode);
426
	ac(archive_read_data_skip(a));
427
}
428
429
static unsigned char buffer[8192];
430
static char spinner[] = { '|', '/', '-', '\\' };
431
432
static int
433
handle_existing_file(char **path)
434
{
435
	size_t alen;
436
	ssize_t len;
437
	char buf[4];
438
439
	for (;;) {
440
		fprintf(stderr,
441
		    "replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
442
		    *path);
443
		if (fgets(buf, sizeof(buf), stdin) == NULL) {
444
			clearerr(stdin);
445
			printf("NULL\n(EOF or read error, "
446
			    "treating as \"[N]one\"...)\n");
447
			n_opt = 1;
448
			return -1;
449
		}
450
		switch (*buf) {
451
		case 'A':
452
			o_opt = 1;
453
			/* FALLTHROUGH */
454
		case 'y':
455
		case 'Y':
456
			(void)unlink(*path);
457
			return 1;
458
		case 'N':
459
			n_opt = 1;
460
			/* FALLTHROUGH */
461
		case 'n':
462
			return -1;
463
		case 'r':
464
		case 'R':
465
			printf("New name: ");
466
			fflush(stdout);
467
			free(*path);
468
			*path = NULL;
469
			alen = 0;
470
			len = getline(path, &alen, stdin);
471
			if ((*path)[len - 1] == '\n')
472
				(*path)[len - 1] = '\0';
473
			return 0;
474
		default:
475
			break;
476
		}
477
	}
478
}
479
480
/*
481
 * Detect binary files by a combination of character white list and
482
 * black list. NUL bytes and other control codes without use in text files
483
 * result directly in switching the file to binary mode. Otherwise, at least
484
 * one white-listed byte has to be found.
485
 *
486
 * Black-listed: 0..6, 14..25, 28..31
487
 * 0xf3ffc07f = 11110011111111111100000001111111b
488
 * White-listed: 9..10, 13, >= 32
489
 * 0x00002600 = 00000000000000000010011000000000b
490
 *
491
 * See the proginfo/txtvsbin.txt in the zip sources for a detailed discussion.
492
 */
493
#define BYTE_IS_BINARY(x)	((x) < 32 && (0xf3ffc07fU & (1U << (x))))
494
#define	BYTE_IS_TEXT(x)		((x) >= 32 || (0x00002600U & (1U << (x))))
495
496
static int
497
check_binary(const unsigned char *buf, size_t len)
498
{
499
	int rv;
500
	for (rv = 1; len--; ++buf) {
501
		if (BYTE_IS_BINARY(*buf))
502
			return 1;
503
		if (BYTE_IS_TEXT(*buf))
504
			rv = 0;
505
	}
506
507
	return rv;
508
}
509
510
/*
511
 * Extract to a file descriptor
512
 */
513
static int
514
extract2fd(struct archive *a, char *pathname, int fd)
515
{
516
	int cr, text, warn;
517
	ssize_t len;
518
	unsigned char *p, *q, *end;
519
520
	text = a_opt;
521
	warn = 0;
522
	cr = 0;
523
524
	/* loop over file contents and write to fd */
525
	for (int n = 0; ; n++) {
526
		if (fd != STDOUT_FILENO)
527
			if (tty && (n % 4) == 0)
528
				info(" %c\b\b", spinner[(n / 4) % sizeof spinner]);
529
530
		len = archive_read_data(a, buffer, sizeof buffer);
531
532
		if (len < 0)
533
			ac(len);
534
535
		/* left over CR from previous buffer */
536
		if (a_opt && cr) {
537
			if (len == 0 || buffer[0] != '\n')
538
				if (write(fd, "\r", 1) != 1)
539
					error("write('%s')", pathname);
540
			cr = 0;
541
		}
542
543
		/* EOF */
544
		if (len == 0)
545
			break;
546
		end = buffer + len;
547
548
		/*
549
		 * Detect whether this is a text file.  The correct way to
550
		 * do this is to check the least significant bit of the
551
		 * "internal file attributes" field of the corresponding
552
		 * file header in the central directory, but libarchive
553
		 * does not provide access to this field, so we have to
554
		 * guess by looking for non-ASCII characters in the
555
		 * buffer.  Hopefully we won't guess wrong.  If we do
556
		 * guess wrong, we print a warning message later.
557
		 */
558
		if (a_opt && n == 0) {
559
			if (check_binary(buffer, len))
560
				text = 0;
561
		}
562
563
		/* simple case */
564
		if (!a_opt || !text) {
565
			if (write(fd, buffer, len) != len)
566
				error("write('%s')", pathname);
567
			continue;
568
		}
569
570
		/* hard case: convert \r\n to \n (sigh...) */
571
		for (p = buffer; p < end; p = q + 1) {
572
			for (q = p; q < end; q++) {
573
				if (!warn && BYTE_IS_BINARY(*q)) {
574
					warningx("%s may be corrupted due"
575
					    " to weak text file detection"
576
					    " heuristic", pathname);
577
					warn = 1;
578
				}
579
				if (q[0] != '\r')
580
					continue;
581
				if (&q[1] == end) {
582
					cr = 1;
583
					break;
584
				}
585
				if (q[1] == '\n')
586
					break;
587
			}
588
			if (write(fd, p, q - p) != q - p)
589
				error("write('%s')", pathname);
590
		}
591
	}
592
593
	return text;
594
}
595
596
/*
597
 * Extract a regular file.
598
 */
599
static void
600
extract_file(struct archive *a, struct archive_entry *e, char **path)
601
{
602
	int mode;
603
	struct timespec mtime;
604
	struct stat sb;
605
	struct timespec ts[2];
606
	int fd, check, text;
607
	const char *linkname;
608
609
	mode = archive_entry_mode(e) & 0777;
610
	if (mode == 0)
611
		mode = 0644;
612
	mtime.tv_sec = archive_entry_mtime(e);
613
	mtime.tv_nsec = archive_entry_mtime_nsec(e);
614
615
	/* look for existing file of same name */
616
recheck:
617
	if (lstat(*path, &sb) == 0) {
618
		if (u_opt || f_opt) {
619
			/* check if up-to-date */
620
			if (S_ISREG(sb.st_mode) &&
621
			    (sb.st_mtim.tv_sec > mtime.tv_sec ||
622
			    (sb.st_mtim.tv_sec == mtime.tv_sec &&
623
			    sb.st_mtim.tv_nsec >= mtime.tv_nsec)))
624
				return;
625
			(void)unlink(*path);
626
		} else if (o_opt) {
627
			/* overwrite */
628
			(void)unlink(*path);
629
		} else if (n_opt) {
630
			/* do not overwrite */
631
			return;
632
		} else {
633
			check = handle_existing_file(path);
634
			if (check == 0)
635
				goto recheck;
636
			if (check == -1)
637
				return; /* do not overwrite */
638
		}
639
	} else {
640
		if (f_opt)
641
			return;
642
	}
643
644
	ts[0].tv_sec = 0;
645
	ts[0].tv_nsec = UTIME_NOW;
646
	ts[1] = mtime;
647
648
	/* process symlinks */
649
	linkname = archive_entry_symlink(e);
650
	if (linkname != NULL) {
651
		if (symlink(linkname, *path) != 0)
652
			error("symlink('%s')", *path);
653
		info(" extracting: %s -> %s\n", *path, linkname);
654
		if (lchmod(*path, mode) != 0)
655
			warning("Cannot set mode for '%s'", *path);
656
		/* set access and modification time */
657
		if (utimensat(AT_FDCWD, *path, ts, AT_SYMLINK_NOFOLLOW) != 0)
658
			warning("utimensat('%s')", *path);
659
		return;
660
	}
661
662
	if ((fd = open(*path, O_RDWR|O_CREAT|O_TRUNC, mode)) < 0)
663
		error("open('%s')", *path);
664
665
	info(" extracting: %s", *path);
666
667
	text = extract2fd(a, *path, fd);
668
669
	if (tty)
670
		info("  \b\b");
671
	if (text)
672
		info(" (text)");
673
	info("\n");
674
675
	/* set access and modification time */
676
	if (futimens(fd, ts) != 0)
677
		error("futimens('%s')", *path);
678
	if (close(fd) != 0)
679
		error("close('%s')", *path);
680
}
681
682
/*
683
 * Extract a zipfile entry: first perform some sanity checks to ensure
684
 * that it is either a directory or a regular file and that the path is
685
 * not absolute and does not try to break out of the current directory;
686
 * then call either extract_dir() or extract_file() as appropriate.
687
 *
688
 * This is complicated a bit by the various ways in which we need to
689
 * manipulate the path name.  Case conversion (if requested by the -L
690
 * option) happens first, but the include / exclude patterns are applied
691
 * to the full converted path name, before the directory part of the path
692
 * is removed in accordance with the -j option.  Sanity checks are
693
 * intentionally done earlier than they need to be, so the user will get a
694
 * warning about insecure paths even for files or directories which
695
 * wouldn't be extracted anyway.
696
 */
697
static void
698
extract(struct archive *a, struct archive_entry *e)
699
{
700
	char *pathname, *realpathname;
701
	mode_t filetype;
702
	char *p, *q;
703
704
	if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) {
705
		warningx("skipping empty or unreadable filename entry");
706
		ac(archive_read_data_skip(a));
707
		return;
708
	}
709
	filetype = archive_entry_filetype(e);
710
711
	/* sanity checks */
712
	if (pathname[0] == '/' ||
713
	    strncmp(pathname, "../", 3) == 0 ||
714
	    strstr(pathname, "/../") != NULL) {
715
		warningx("skipping insecure entry '%s'", pathname);
716
		ac(archive_read_data_skip(a));
717
		free(pathname);
718
		return;
719
	}
720
721
	/* I don't think this can happen in a zipfile.. */
722
	if (!S_ISDIR(filetype) && !S_ISREG(filetype) && !S_ISLNK(filetype)) {
723
		warningx("skipping non-regular entry '%s'", pathname);
724
		ac(archive_read_data_skip(a));
725
		free(pathname);
726
		return;
727
	}
728
729
	/* skip directories in -j case */
730
	if (S_ISDIR(filetype) && j_opt) {
731
		ac(archive_read_data_skip(a));
732
		free(pathname);
733
		return;
734
	}
735
736
	/* apply include / exclude patterns */
737
	if (!accept_pathname(pathname)) {
738
		ac(archive_read_data_skip(a));
739
		free(pathname);
740
		return;
741
	}
742
743
	/* apply -j and -d */
744
	if (j_opt) {
745
		for (p = q = pathname; *p; ++p)
746
			if (*p == '/')
747
				q = p + 1;
748
		realpathname = pathcat(d_arg, q);
749
	} else {
750
		realpathname = pathcat(d_arg, pathname);
751
	}
752
753
	/* ensure that parent directory exists */
754
	make_parent(realpathname);
755
756
	if (S_ISDIR(filetype))
757
		extract_dir(a, e, realpathname);
758
	else
759
		extract_file(a, e, &realpathname);
760
761
	free(realpathname);
762
	free(pathname);
763
}
764
765
static void
766
extract_stdout(struct archive *a, struct archive_entry *e)
767
{
768
	char *pathname;
769
	mode_t filetype;
770
771
	if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) {
772
		warningx("skipping empty or unreadable filename entry");
773
		ac(archive_read_data_skip(a));
774
		return;
775
	}
776
	filetype = archive_entry_filetype(e);
777
778
	/* I don't think this can happen in a zipfile.. */
779
	if (!S_ISDIR(filetype) && !S_ISREG(filetype) && !S_ISLNK(filetype)) {
780
		warningx("skipping non-regular entry '%s'", pathname);
781
		ac(archive_read_data_skip(a));
782
		free(pathname);
783
		return;
784
	}
785
786
	/* skip directories in -j case */
787
	if (S_ISDIR(filetype)) {
788
		ac(archive_read_data_skip(a));
789
		free(pathname);
790
		return;
791
	}
792
793
	/* apply include / exclude patterns */
794
	if (!accept_pathname(pathname)) {
795
		ac(archive_read_data_skip(a));
796
		free(pathname);
797
		return;
798
	}
799
800
	if (c_opt)
801
		info("x %s\n", pathname);
802
803
	(void)extract2fd(a, pathname, STDOUT_FILENO);
804
805
	free(pathname);
806
}
807
808
/*
809
 * Print the name of an entry to stdout.
810
 */
811
static void
812
list(struct archive *a, struct archive_entry *e)
813
{
814
	char buf[20];
815
	time_t mtime;
816
	struct tm *tm;
817
818
	mtime = archive_entry_mtime(e);
819
	tm = localtime(&mtime);
820
	if (*y_str)
821
		strftime(buf, sizeof(buf), "%m-%d-%G %R", tm);
822
	else
823
		strftime(buf, sizeof(buf), "%m-%d-%g %R", tm);
824
825
	if (!zipinfo_mode) {
826
		if (v_opt == 1) {
827
			printf(" %8ju  %s   %s\n",
828
			    (uintmax_t)archive_entry_size(e),
829
			    buf, archive_entry_pathname(e));
830
		} else if (v_opt == 2) {
831
			printf("%8ju  Stored  %7ju   0%%  %s  %08x  %s\n",
832
			    (uintmax_t)archive_entry_size(e),
833
			    (uintmax_t)archive_entry_size(e),
834
			    buf,
835
			    0U,
836
			    archive_entry_pathname(e));
837
		}
838
	} else {
839
		if (Z1_opt)
840
			printf("%s\n",archive_entry_pathname(e));
841
	}
842
	ac(archive_read_data_skip(a));
843
}
844
845
/*
846
 * Extract to memory to check CRC
847
 */
848
static int
849
test(struct archive *a, struct archive_entry *e)
850
{
851
	ssize_t len;
852
	int error_count;
853
854
	error_count = 0;
855
	if (S_ISDIR(archive_entry_filetype(e)))
856
		return 0;
857
858
	info("    testing: %s\t", archive_entry_pathname(e));
859
	while ((len = archive_read_data(a, buffer, sizeof buffer)) > 0)
860
		/* nothing */;
861
	if (len < 0) {
862
		info(" %s\n", archive_error_string(a));
863
		++error_count;
864
	} else {
865
		info(" OK\n");
866
	}
867
868
	/* shouldn't be necessary, but it doesn't hurt */
869
	ac(archive_read_data_skip(a));
870
871
	return error_count;
872
}
873
874
/*
875
 * Callback function for reading passphrase.
876
 * Originally from cpio.c and passphrase.c, libarchive.
877
 */
878
#define PPBUFF_SIZE 1024
879
static const char *
880
passphrase_callback(struct archive *a, void *_client_data)
881
{
882
	char *p;
883
884
	(void)a; /* UNUSED */
885
	(void)_client_data; /* UNUSED */
886
887
	if (passphrase_buf == NULL) {
888
		passphrase_buf = malloc(PPBUFF_SIZE);
889
		if (passphrase_buf == NULL) {
890
			errno = ENOMEM;
891
			error("malloc()");
892
		}
893
	}
894
895
	p = readpassphrase("\nEnter password: ", passphrase_buf,
896
		PPBUFF_SIZE, RPP_ECHO_OFF);
897
898
	if (p == NULL && errno != EINTR)
899
		error("Error reading password");
900
901
	return p;
902
}
903
904
/*
905
 * Main loop: open the zipfile, iterate over its contents and decide what
906
 * to do with each entry.
907
 */
908
static void
909
unzip(const char *fn)
910
{
911
	struct archive *a;
912
	struct archive_entry *e;
913
	int ret;
914
	uintmax_t total_size, file_count, error_count;
915
916
	if ((a = archive_read_new()) == NULL)
917
		error("archive_read_new failed");
918
919
	ac(archive_read_support_format_zip(a));
920
921
	if (O_arg)
922
		ac(archive_read_set_format_option(a, "zip", "hdrcharset", O_arg));
923
924
	if (P_arg)
925
		archive_read_add_passphrase(a, P_arg);
926
	else
927
		archive_read_set_passphrase_callback(a, NULL,
928
			&passphrase_callback);
929
930
	ac(archive_read_open_filename(a, fn, 8192));
931
932
	if (!zipinfo_mode) {
933
		if (!p_opt && !q_opt)
934
			printf("Archive:  %s\n", fn);
935
		if (v_opt == 1) {
936
			printf("  Length     %sDate   Time    Name\n", y_str);
937
			printf(" --------    %s----   ----    ----\n", y_str);
938
		} else if (v_opt == 2) {
939
			printf(" Length   Method    Size  Ratio   %sDate   Time   CRC-32    Name\n", y_str);
940
			printf("--------  ------  ------- -----   %s----   ----   ------    ----\n", y_str);
941
		}
942
	}
943
944
	total_size = 0;
945
	file_count = 0;
946
	error_count = 0;
947
	for (;;) {
948
		ret = archive_read_next_header(a, &e);
949
		if (ret == ARCHIVE_EOF)
950
			break;
951
		ac(ret);
952
		if (!zipinfo_mode) {
953
			if (t_opt)
954
				error_count += test(a, e);
955
			else if (v_opt)
956
				list(a, e);
957
			else if (p_opt || c_opt)
958
				extract_stdout(a, e);
959
			else
960
				extract(a, e);
961
		} else {
962
			if (Z1_opt)
963
				list(a, e);
964
		}
965
966
		total_size += archive_entry_size(e);
967
		++file_count;
968
	}
969
970
	if (zipinfo_mode) {
971
		if (v_opt == 1) {
972
			printf(" --------                   %s-------\n", y_str);
973
			printf(" %8ju                   %s%ju file%s\n",
974
			    total_size, y_str, file_count, file_count != 1 ? "s" : "");
975
		} else if (v_opt == 2) {
976
			printf("--------          -------  ---                            %s-------\n", y_str);
977
			printf("%8ju          %7ju   0%%                            %s%ju file%s\n",
978
			    total_size, total_size, y_str, file_count,
979
			    file_count != 1 ? "s" : "");
980
		}
981
	}
982
983
	ac(archive_read_free(a));
984
985
	if (passphrase_buf != NULL) {
986
		memset_s(passphrase_buf, PPBUFF_SIZE, 0, PPBUFF_SIZE);
987
		free(passphrase_buf);
988
	}
989
990
	if (t_opt) {
991
		if (error_count > 0) {
992
			errorx("%ju checksum error(s) found.", error_count);
993
		}
994
		else {
995
			printf("No errors detected in compressed data of %s.\n",
996
			       fn);
997
		}
998
	}
999
}
1000
1001
static void
1002
usage(void)
1003
{
1004
1005
	fprintf(stderr,
1006
"Usage: unzip [-aCcfjLlnopqtuvyZ1] [{-O|-I} encoding] [-d dir] [-x pattern] [-P password] zipfile\n"
1007
"             [member ...]\n");
1008
	exit(EXIT_FAILURE);
1009
}
1010
1011
static int
1012
getopts(int argc, char *argv[])
1013
{
1014
	int opt;
1015
1016
	optreset = optind = 1;
1017
	while ((opt = getopt(argc, argv, "aCcd:fI:jLlnO:opP:qtuvx:yZ1")) != -1)
1018
		switch (opt) {
1019
		case '1':
1020
			Z1_opt = 1;
1021
			break;
1022
		case 'a':
1023
			a_opt = 1;
1024
			break;
1025
		case 'C':
1026
			C_opt = 1;
1027
			break;
1028
		case 'c':
1029
			c_opt = 1;
1030
			break;
1031
		case 'd':
1032
			d_arg = optarg;
1033
			break;
1034
		case 'f':
1035
			f_opt = 1;
1036
			break;
1037
		case 'I':
1038
		case 'O':
1039
			O_arg = optarg;
1040
		case 'j':
1041
			j_opt = 1;
1042
			break;
1043
		case 'L':
1044
			L_opt = 1;
1045
			break;
1046
		case 'l':
1047
			if (v_opt == 0)
1048
				v_opt = 1;
1049
			break;
1050
		case 'n':
1051
			n_opt = 1;
1052
			break;
1053
		case 'o':
1054
			o_opt = 1;
1055
			q_opt = 1;
1056
			break;
1057
		case 'p':
1058
			p_opt = 1;
1059
			break;
1060
		case 'P':
1061
			P_arg = optarg;
1062
			break;
1063
		case 'q':
1064
			q_opt = 1;
1065
			break;
1066
		case 't':
1067
			t_opt = 1;
1068
			break;
1069
		case 'u':
1070
			u_opt = 1;
1071
			break;
1072
		case 'v':
1073
			v_opt = 2;
1074
			break;
1075
		case 'x':
1076
			add_pattern(&exclude, optarg);
1077
			break;
1078
		case 'y':
1079
			y_str = "  ";
1080
			break;
1081
		case 'Z':
1082
			zipinfo_mode = 1;
1083
			break;
1084
		default:
1085
			usage();
1086
		}
1087
1088
	return (optind);
1089
}
1090
1091
int
1092
main(int argc, char *argv[])
1093
{
1094
	const char *zipfile;
1095
	int nopts;
1096
1097
	if (isatty(STDOUT_FILENO))
1098
		tty = 1;
1099
1100
	if (getenv("UNZIP_DEBUG") != NULL)
1101
		unzip_debug = 1;
1102
	for (int i = 0; i < argc; ++i)
1103
		debug("%s%c", argv[i], (i < argc - 1) ? ' ' : '\n');
1104
1105
	/*
1106
	 * Info-ZIP's unzip(1) expects certain options to come before the
1107
	 * zipfile name, and others to come after - though it does not
1108
	 * enforce this.  For simplicity, we accept *all* options both
1109
	 * before and after the zipfile name.
1110
	 */
1111
	nopts = getopts(argc, argv);
1112
1113
	/*
1114
	 * When more of the zipinfo mode options are implemented, this
1115
	 * will need to change.
1116
	 */
1117
	if (zipinfo_mode && !Z1_opt) {
1118
		printf("Zipinfo mode needs additional options\n");
1119
		exit(EXIT_FAILURE);
1120
	}
1121
1122
	if (argc <= nopts)
1123
		usage();
1124
	zipfile = argv[nopts++];
1125
1126
	if (strcmp(zipfile, "-") == 0)
1127
		zipfile = NULL; /* STDIN */
1128
1129
	while (nopts < argc && *argv[nopts] != '-')
1130
		add_pattern(&include, argv[nopts++]);
1131
1132
	nopts--; /* fake argv[0] */
1133
	nopts += getopts(argc - nopts, argv + nopts);
1134
1135
	if (n_opt + o_opt + u_opt > 1)
1136
		errorx("-n, -o and -u are contradictory");
1137
1138
	unzip(zipfile);
1139
1140
	exit(EXIT_SUCCESS);
1141
}

Return to bug 272845