Thu Jan 8 00:01:31 2009 UTC ()
pkg_install-20090108:
pkg_add optionally checks for vulnerable packages and bails out.


(joerg)
diff -r1.70.4.19 -r1.70.4.20 pkgsrc/pkgtools/pkg_install/files/add/perform.c
diff -r1.42.2.16 -r1.42.2.17 pkgsrc/pkgtools/pkg_install/files/lib/lib.h
diff -r1.1.2.5 -r1.1.2.6 pkgsrc/pkgtools/pkg_install/files/lib/parse-config.c
diff -r1.1.2.3 -r1.1.2.4 pkgsrc/pkgtools/pkg_install/files/lib/pkg_install.conf.5
diff -r1.1.2.3 -r1.1.2.4 pkgsrc/pkgtools/pkg_install/files/lib/pkg_install.conf.cat5
diff -r1.102.2.19 -r1.102.2.20 pkgsrc/pkgtools/pkg_install/files/lib/version.h

cvs diff -r1.70.4.19 -r1.70.4.20 pkgsrc/pkgtools/pkg_install/files/add/perform.c (switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/add/perform.c 2008/08/25 19:15:11 1.70.4.19
+++ pkgsrc/pkgtools/pkg_install/files/add/perform.c 2009/01/08 00:01:30 1.70.4.20
@@ -1,1386 +1,1436 @@ @@ -1,1386 +1,1436 @@
1/* $NetBSD: perform.c,v 1.70.4.19 2008/08/25 19:15:11 joerg Exp $ */ 1/* $NetBSD: perform.c,v 1.70.4.20 2009/01/08 00:01:30 joerg Exp $ */
2#if HAVE_CONFIG_H 2#if HAVE_CONFIG_H
3#include "config.h" 3#include "config.h"
4#endif 4#endif
5#include <nbcompat.h> 5#include <nbcompat.h>
6#if HAVE_SYS_CDEFS_H 6#if HAVE_SYS_CDEFS_H
7#include <sys/cdefs.h> 7#include <sys/cdefs.h>
8#endif 8#endif
9__RCSID("$NetBSD: perform.c,v 1.70.4.19 2008/08/25 19:15:11 joerg Exp $"); 9__RCSID("$NetBSD: perform.c,v 1.70.4.20 2009/01/08 00:01:30 joerg Exp $");
10 10
11/*- 11/*-
12 * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org> 12 * Copyright (c) 2003 Grant Beattie <grant@NetBSD.org>
13 * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org> 13 * Copyright (c) 2005 Dieter Baron <dillo@NetBSD.org>
14 * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org> 14 * Copyright (c) 2007 Roland Illig <rillig@NetBSD.org>
15 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> 15 * Copyright (c) 2008, 2009 Joerg Sonnenberger <joerg@NetBSD.org>
16 * All rights reserved. 16 * All rights reserved.
17 * 17 *
18 * Redistribution and use in source and binary forms, with or without 18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions 19 * modification, are permitted provided that the following conditions
20 * are met: 20 * are met:
21 * 21 *
22 * 1. Redistributions of source code must retain the above copyright 22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer. 23 * notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright 24 * 2. Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in 25 * notice, this list of conditions and the following disclaimer in
26 * the documentation and/or other materials provided with the 26 * the documentation and/or other materials provided with the
27 * distribution. 27 * distribution.
28 * 28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 32 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 33 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 34 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
37 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE. 40 * SUCH DAMAGE.
41 */ 41 */
42 42
43#include <sys/utsname.h> 43#include <sys/utsname.h>
44#if HAVE_ERR_H 44#if HAVE_ERR_H
45#include <err.h> 45#include <err.h>
46#endif 46#endif
47#include <errno.h> 47#include <errno.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <string.h> 49#include <string.h>
50#include <unistd.h> 50#include <unistd.h>
51 51
52#include <archive.h> 52#include <archive.h>
53#include <archive_entry.h> 53#include <archive_entry.h>
54 54
55#include "lib.h" 55#include "lib.h"
56#include "add.h" 56#include "add.h"
57 57
58struct pkg_meta { 58struct pkg_meta {
59 char *meta_contents; 59 char *meta_contents;
60 char *meta_comment; 60 char *meta_comment;
61 char *meta_desc; 61 char *meta_desc;
62 char *meta_mtree; 62 char *meta_mtree;
63 char *meta_build_version; 63 char *meta_build_version;
64 char *meta_build_info; 64 char *meta_build_info;
65 char *meta_size_pkg; 65 char *meta_size_pkg;
66 char *meta_size_all; 66 char *meta_size_all;
67 char *meta_required_by; 67 char *meta_required_by;
68 char *meta_display; 68 char *meta_display;
69 char *meta_install; 69 char *meta_install;
70 char *meta_deinstall; 70 char *meta_deinstall;
71 char *meta_preserve; 71 char *meta_preserve;
72 char *meta_views; 72 char *meta_views;
73 char *meta_installed_info; 73 char *meta_installed_info;
74}; 74};
75 75
76struct pkg_task { 76struct pkg_task {
77 char *pkgname; 77 char *pkgname;
78 78
79 const char *prefix; 79 const char *prefix;
80 char *install_prefix; 80 char *install_prefix;
81 81
82 char *logdir; 82 char *logdir;
83 char *install_logdir; 83 char *install_logdir;
84 char *other_version; 84 char *other_version;
85 85
86 package_t plist; 86 package_t plist;
87 87
88 struct pkg_meta meta_data; 88 struct pkg_meta meta_data;
89 89
90 struct archive *archive; 90 struct archive *archive;
91 struct archive_entry *entry; 91 struct archive_entry *entry;
92 92
93 char *buildinfo[BI_ENUM_COUNT]; 93 char *buildinfo[BI_ENUM_COUNT];
94 94
95 size_t dep_length, dep_allocated; 95 size_t dep_length, dep_allocated;
96 char **dependencies; 96 char **dependencies;
97}; 97};
98 98
99static const struct pkg_meta_desc { 99static const struct pkg_meta_desc {
100 size_t entry_offset; 100 size_t entry_offset;
101 const char *entry_filename; 101 const char *entry_filename;
102 int required_file; 102 int required_file;
103 mode_t perm; 103 mode_t perm;
104} pkg_meta_descriptors[] = { 104} pkg_meta_descriptors[] = {
105 { offsetof(struct pkg_meta, meta_contents), CONTENTS_FNAME, 1, 0644 }, 105 { offsetof(struct pkg_meta, meta_contents), CONTENTS_FNAME, 1, 0644 },
106 { offsetof(struct pkg_meta, meta_comment), COMMENT_FNAME, 1, 0444}, 106 { offsetof(struct pkg_meta, meta_comment), COMMENT_FNAME, 1, 0444},
107 { offsetof(struct pkg_meta, meta_desc), DESC_FNAME, 1, 0444}, 107 { offsetof(struct pkg_meta, meta_desc), DESC_FNAME, 1, 0444},
108 { offsetof(struct pkg_meta, meta_install), INSTALL_FNAME, 0, 0555 }, 108 { offsetof(struct pkg_meta, meta_install), INSTALL_FNAME, 0, 0555 },
109 { offsetof(struct pkg_meta, meta_deinstall), DEINSTALL_FNAME, 0, 0555 }, 109 { offsetof(struct pkg_meta, meta_deinstall), DEINSTALL_FNAME, 0, 0555 },
110 { offsetof(struct pkg_meta, meta_display), DISPLAY_FNAME, 0, 0444 }, 110 { offsetof(struct pkg_meta, meta_display), DISPLAY_FNAME, 0, 0444 },
111 { offsetof(struct pkg_meta, meta_mtree), MTREE_FNAME, 0, 0444 }, 111 { offsetof(struct pkg_meta, meta_mtree), MTREE_FNAME, 0, 0444 },
112 { offsetof(struct pkg_meta, meta_build_version), BUILD_VERSION_FNAME, 0, 0444 }, 112 { offsetof(struct pkg_meta, meta_build_version), BUILD_VERSION_FNAME, 0, 0444 },
113 { offsetof(struct pkg_meta, meta_build_info), BUILD_INFO_FNAME, 0, 0444 }, 113 { offsetof(struct pkg_meta, meta_build_info), BUILD_INFO_FNAME, 0, 0444 },
114 { offsetof(struct pkg_meta, meta_size_pkg), SIZE_PKG_FNAME, 0, 0444 }, 114 { offsetof(struct pkg_meta, meta_size_pkg), SIZE_PKG_FNAME, 0, 0444 },
115 { offsetof(struct pkg_meta, meta_size_all), SIZE_ALL_FNAME, 0, 0444 }, 115 { offsetof(struct pkg_meta, meta_size_all), SIZE_ALL_FNAME, 0, 0444 },
116 { offsetof(struct pkg_meta, meta_preserve), PRESERVE_FNAME, 0, 0444 }, 116 { offsetof(struct pkg_meta, meta_preserve), PRESERVE_FNAME, 0, 0444 },
117 { offsetof(struct pkg_meta, meta_views), VIEWS_FNAME, 0, 0444 }, 117 { offsetof(struct pkg_meta, meta_views), VIEWS_FNAME, 0, 0444 },
118 { offsetof(struct pkg_meta, meta_required_by), REQUIRED_BY_FNAME, 0, 0644 }, 118 { offsetof(struct pkg_meta, meta_required_by), REQUIRED_BY_FNAME, 0, 0644 },
119 { offsetof(struct pkg_meta, meta_installed_info), INSTALLED_INFO_FNAME, 0, 0644 }, 119 { offsetof(struct pkg_meta, meta_installed_info), INSTALLED_INFO_FNAME, 0, 0644 },
120 { 0, NULL, 0 }, 120 { 0, NULL, 0 },
121}; 121};
122 122
123static int pkg_do(const char *, int); 123static int pkg_do(const char *, int);
124 124
125static int 125static int
126mkdir_p(const char *path) 126mkdir_p(const char *path)
127{ 127{
128 char *p, *cur_end; 128 char *p, *cur_end;
129 int done; 129 int done;
130 130
131 /* 131 /*
132 * Handle the easy case of direct success or 132 * Handle the easy case of direct success or
133 * pre-existing directory first. 133 * pre-existing directory first.
134 */ 134 */
135 if (mkdir(path, 0777) == 0 || errno == EEXIST) 135 if (mkdir(path, 0777) == 0 || errno == EEXIST)
136 return 0; 136 return 0;
137 if (errno != ENOENT) 137 if (errno != ENOENT)
138 return -1; 138 return -1;
139 139
140 cur_end = p = xstrdup(path); 140 cur_end = p = xstrdup(path);
141 141
142 for (;;) { 142 for (;;) {
143 /* 143 /*
144 * First skip leading slashes either from / or 144 * First skip leading slashes either from / or
145 * from the last iteration. 145 * from the last iteration.
146 */ 146 */
147 cur_end += strspn(cur_end, "/"); 147 cur_end += strspn(cur_end, "/");
148 /* Find end of actual directory name. */ 148 /* Find end of actual directory name. */
149 cur_end += strcspn(cur_end, "/"); 149 cur_end += strcspn(cur_end, "/");
150 150
151 /* 151 /*
152 * Remember if this is the last component and 152 * Remember if this is the last component and
153 * overwrite / if needed. 153 * overwrite / if needed.
154 */ 154 */
155 done = (*cur_end == '\0'); 155 done = (*cur_end == '\0');
156 *cur_end = '\0'; 156 *cur_end = '\0';
157 157
158 /* 158 /*
159 * ENOENT can only happen if something else races us, 159 * ENOENT can only happen if something else races us,
160 * in which case we should better give up. 160 * in which case we should better give up.
161 */ 161 */
162 if (mkdir(p, 0777) == -1 && errno != EEXIST) { 162 if (mkdir(p, 0777) == -1 && errno != EEXIST) {
163 free(p); 163 free(p);
164 return -1; 164 return -1;
165 } 165 }
166 if (done) 166 if (done)
167 break; 167 break;
168 *cur_end = '/'; 168 *cur_end = '/';
169 } 169 }
170 170
171 free(p); 171 free(p);
172 return 0;  172 return 0;
173} 173}
174 174
175/* 175/*
176 * Read meta data from archive. 176 * Read meta data from archive.
177 * Bail out if a required entry is missing or entries are in the wrong order. 177 * Bail out if a required entry is missing or entries are in the wrong order.
178 */ 178 */
179static int 179static int
180read_meta_data(struct pkg_task *pkg) 180read_meta_data(struct pkg_task *pkg)
181{ 181{
182 const struct pkg_meta_desc *descr, *last_descr; 182 const struct pkg_meta_desc *descr, *last_descr;
183 const char *fname; 183 const char *fname;
184 char **target; 184 char **target;
185 int64_t size; 185 int64_t size;
186 int r, found_required; 186 int r, found_required;
187 187
188 found_required = 0; 188 found_required = 0;
189 189
190 r = ARCHIVE_OK; 190 r = ARCHIVE_OK;
191 last_descr = 0; 191 last_descr = 0;
192 192
193 if (pkg->entry != NULL) 193 if (pkg->entry != NULL)
194 goto skip_header; 194 goto skip_header;
195 195
196 for (;;) { 196 for (;;) {
197 r = archive_read_next_header(pkg->archive, &pkg->entry); 197 r = archive_read_next_header(pkg->archive, &pkg->entry);
198 if (r != ARCHIVE_OK) 198 if (r != ARCHIVE_OK)
199 break; 199 break;
200skip_header: 200skip_header:
201 fname = archive_entry_pathname(pkg->entry); 201 fname = archive_entry_pathname(pkg->entry);
202 202
203 for (descr = pkg_meta_descriptors; descr->entry_filename; 203 for (descr = pkg_meta_descriptors; descr->entry_filename;
204 ++descr) { 204 ++descr) {
205 if (strcmp(descr->entry_filename, fname) == 0) 205 if (strcmp(descr->entry_filename, fname) == 0)
206 break; 206 break;
207 } 207 }
208 if (descr->entry_filename == NULL) 208 if (descr->entry_filename == NULL)
209 break; 209 break;
210 210
211 if (descr->required_file) 211 if (descr->required_file)
212 ++found_required; 212 ++found_required;
213 213
214 target = (char **)((char *)&pkg->meta_data + 214 target = (char **)((char *)&pkg->meta_data +
215 descr->entry_offset); 215 descr->entry_offset);
216 if (*target) { 216 if (*target) {
217 warnx("duplicate entry, package corrupt"); 217 warnx("duplicate entry, package corrupt");
218 return -1; 218 return -1;
219 } 219 }
220 if (descr < last_descr) { 220 if (descr < last_descr) {
221 warnx("misordered package"); 221 warnx("misordered package");
222 return -1; 222 return -1;
223 } 223 }
224 last_descr = descr; 224 last_descr = descr;
225 225
226 size = archive_entry_size(pkg->entry); 226 size = archive_entry_size(pkg->entry);
227 if (size > SSIZE_MAX - 1) { 227 if (size > SSIZE_MAX - 1) {
228 warnx("package meta data too large to process"); 228 warnx("package meta data too large to process");
229 return -1; 229 return -1;
230 } 230 }
231 *target = xmalloc(size + 1); 231 *target = xmalloc(size + 1);
232 if (archive_read_data(pkg->archive, *target, size) != size) { 232 if (archive_read_data(pkg->archive, *target, size) != size) {
233 warnx("cannot read package meta data"); 233 warnx("cannot read package meta data");
234 return -1; 234 return -1;
235 } 235 }
236 (*target)[size] = '\0'; 236 (*target)[size] = '\0';
237 } 237 }
238 238
239 if (r != ARCHIVE_OK) 239 if (r != ARCHIVE_OK)
240 pkg->entry = NULL; 240 pkg->entry = NULL;
241 if (r == ARCHIVE_EOF) 241 if (r == ARCHIVE_EOF)
242 r = ARCHIVE_OK; 242 r = ARCHIVE_OK;
243 243
244 for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) { 244 for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) {
245 if (descr->required_file) 245 if (descr->required_file)
246 --found_required; 246 --found_required;
247 } 247 }
248 248
249 return !found_required && r == ARCHIVE_OK ? 0 : -1; 249 return !found_required && r == ARCHIVE_OK ? 0 : -1;
250} 250}
251 251
252/* 252/*
253 * Free meta data. 253 * Free meta data.
254 */ 254 */
255static void 255static void
256free_meta_data(struct pkg_task *pkg) 256free_meta_data(struct pkg_task *pkg)
257{ 257{
258 const struct pkg_meta_desc *descr; 258 const struct pkg_meta_desc *descr;
259 char **target; 259 char **target;
260 260
261 for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) { 261 for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) {
262 target = (char **)((char *)&pkg->meta_data + 262 target = (char **)((char *)&pkg->meta_data +
263 descr->entry_offset); 263 descr->entry_offset);
264 free(*target); 264 free(*target);
265 *target = NULL; 265 *target = NULL;
266 } 266 }
267} 267}
268 268
269/* 269/*
270 * Parse PLIST and populate pkg. 270 * Parse PLIST and populate pkg.
271 */ 271 */
272static int 272static int
273pkg_parse_plist(struct pkg_task *pkg) 273pkg_parse_plist(struct pkg_task *pkg)
274{ 274{
275 plist_t *p; 275 plist_t *p;
276 276
277 parse_plist(&pkg->plist, pkg->meta_data.meta_contents); 277 parse_plist(&pkg->plist, pkg->meta_data.meta_contents);
278 if ((p = find_plist(&pkg->plist, PLIST_NAME)) == NULL) { 278 if ((p = find_plist(&pkg->plist, PLIST_NAME)) == NULL) {
279 warnx("Invalid PLIST: missing @name"); 279 warnx("Invalid PLIST: missing @name");
280 return -1; 280 return -1;
281 } 281 }
282 if (pkg->pkgname == NULL) 282 if (pkg->pkgname == NULL)
283 pkg->pkgname = xstrdup(p->name); 283 pkg->pkgname = xstrdup(p->name);
284 else if (strcmp(pkg->pkgname, p->name) != 0) { 284 else if (strcmp(pkg->pkgname, p->name) != 0) {
285 warnx("Signature and PLIST differ on package name"); 285 warnx("Signature and PLIST differ on package name");
286 return -1; 286 return -1;
287 } 287 }
288 if ((p = find_plist(&pkg->plist, PLIST_CWD)) == NULL) { 288 if ((p = find_plist(&pkg->plist, PLIST_CWD)) == NULL) {
289 warnx("Invalid PLIST: missing @cwd"); 289 warnx("Invalid PLIST: missing @cwd");
290 return -1; 290 return -1;
291 } 291 }
292 292
293 if (Prefix != NULL && 293 if (Prefix != NULL &&
294 strcmp(p->name, Prefix) != 0) { 294 strcmp(p->name, Prefix) != 0) {
295 size_t len; 295 size_t len;
296 296
297 delete_plist(&pkg->plist, FALSE, PLIST_CWD, NULL); 297 delete_plist(&pkg->plist, FALSE, PLIST_CWD, NULL);
298 add_plist_top(&pkg->plist, PLIST_CWD, Prefix); 298 add_plist_top(&pkg->plist, PLIST_CWD, Prefix);
299 free(pkg->meta_data.meta_contents); 299 free(pkg->meta_data.meta_contents);
300 stringify_plist(&pkg->plist, &pkg->meta_data.meta_contents, &len, 300 stringify_plist(&pkg->plist, &pkg->meta_data.meta_contents, &len,
301 Prefix); 301 Prefix);
302 pkg->prefix = Prefix; 302 pkg->prefix = Prefix;
303 } else 303 } else
304 pkg->prefix = p->name; 304 pkg->prefix = p->name;
305 305
306 if (Destdir != NULL) 306 if (Destdir != NULL)
307 pkg->install_prefix = xasprintf("%s/%s", Destdir, pkg->prefix); 307 pkg->install_prefix = xasprintf("%s/%s", Destdir, pkg->prefix);
308 else 308 else
309 pkg->install_prefix = xstrdup(pkg->prefix); 309 pkg->install_prefix = xstrdup(pkg->prefix);
310 310
311 return 0; 311 return 0;
312} 312}
313 313
314/* 314/*
315 * Helper function to extract value from a string of the 315 * Helper function to extract value from a string of the
316 * form key=value ending at eol. 316 * form key=value ending at eol.
317 */ 317 */
318static char * 318static char *
319dup_value(const char *line, const char *eol) 319dup_value(const char *line, const char *eol)
320{ 320{
321 const char *key; 321 const char *key;
322 char *val; 322 char *val;
323 323
324 key = strchr(line, '='); 324 key = strchr(line, '=');
325 val = xmalloc(eol - key); 325 val = xmalloc(eol - key);
326 memcpy(val, key + 1, eol - key - 1); 326 memcpy(val, key + 1, eol - key - 1);
327 val[eol - key - 1] = '\0'; 327 val[eol - key - 1] = '\0';
328 return val; 328 return val;
329} 329}
330 330
331static int 331static int
332check_already_installed(struct pkg_task *pkg) 332check_already_installed(struct pkg_task *pkg)
333{ 333{
334 char *filename; 334 char *filename;
335 int fd; 335 int fd;
336 336
337 if (Force) 337 if (Force)
338 return -1; 338 return -1;
339 339
340 filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME); 340 filename = pkgdb_pkg_file(pkg->pkgname, CONTENTS_FNAME);
341 fd = open(filename, O_RDONLY); 341 fd = open(filename, O_RDONLY);
342 free(filename); 342 free(filename);
343 if (fd == -1) 343 if (fd == -1)
344 return -1; 344 return -1;
345 345
346 /* We can only arrive here for explicitly requested packages. */ 346 /* We can only arrive here for explicitly requested packages. */
347 if (!Automatic && is_automatic_installed(pkg->pkgname)) { 347 if (!Automatic && is_automatic_installed(pkg->pkgname)) {
348 if (Fake || 348 if (Fake ||
349 mark_as_automatic_installed(pkg->pkgname, 0) == 0) 349 mark_as_automatic_installed(pkg->pkgname, 0) == 0)
350 warnx("package `%s' was already installed as " 350 warnx("package `%s' was already installed as "
351 "dependency, now marked as installed " 351 "dependency, now marked as installed "
352 "manually", pkg->pkgname); 352 "manually", pkg->pkgname);
353 } else { 353 } else {
354 warnx("package `%s' already recorded as installed", 354 warnx("package `%s' already recorded as installed",
355 pkg->pkgname); 355 pkg->pkgname);
356 } 356 }
357 return 0; 357 return 0;
358 358
359} 359}
360 360
361static int 361static int
362check_other_installed(struct pkg_task *pkg) 362check_other_installed(struct pkg_task *pkg)
363{ 363{
364 FILE *f, *f_pkg; 364 FILE *f, *f_pkg;
365 size_t len; 365 size_t len;
366 char *pkgbase, *iter, *filename; 366 char *pkgbase, *iter, *filename;
367 package_t plist; 367 package_t plist;
368 plist_t *p; 368 plist_t *p;
369 int status; 369 int status;
370 370
371 pkgbase = xstrdup(pkg->pkgname); 371 pkgbase = xstrdup(pkg->pkgname);
372 372
373 if ((iter = strrchr(pkgbase, '-')) == NULL) { 373 if ((iter = strrchr(pkgbase, '-')) == NULL) {
374 free(pkgbase); 374 free(pkgbase);
375 warnx("Invalid package name %s", pkg->pkgname); 375 warnx("Invalid package name %s", pkg->pkgname);
376 return -1; 376 return -1;
377 } 377 }
378 *iter = '\0'; 378 *iter = '\0';
379 pkg->other_version = find_best_matching_installed_pkg(pkgbase); 379 pkg->other_version = find_best_matching_installed_pkg(pkgbase);
380 free(pkgbase); 380 free(pkgbase);
381 if (pkg->other_version == NULL) 381 if (pkg->other_version == NULL)
382 return 0; 382 return 0;
383 383
384 if (!Replace) { 384 if (!Replace) {
385 /* XXX This is redundant to the implicit conflict check. */ 385 /* XXX This is redundant to the implicit conflict check. */
386 warnx("A different version of %s is already installed: %s", 386 warnx("A different version of %s is already installed: %s",
387 pkg->pkgname, pkg->other_version); 387 pkg->pkgname, pkg->other_version);
388 return -1; 388 return -1;
389 } 389 }
390 390
391 filename = pkgdb_pkg_file(pkg->other_version, REQUIRED_BY_FNAME); 391 filename = pkgdb_pkg_file(pkg->other_version, REQUIRED_BY_FNAME);
392 errno = 0; 392 errno = 0;
393 f = fopen(filename, "r"); 393 f = fopen(filename, "r");
394 free(filename); 394 free(filename);
395 if (f == NULL) { 395 if (f == NULL) {
396 if (errno == ENOENT) { 396 if (errno == ENOENT) {
397 /* No packages depend on this, so everything is well. */ 397 /* No packages depend on this, so everything is well. */
398 return 0;  398 return 0;
399 } 399 }
400 warnx("Can't open +REQUIRED_BY of %s", pkg->other_version); 400 warnx("Can't open +REQUIRED_BY of %s", pkg->other_version);
401 return -1; 401 return -1;
402 } 402 }
403 403
404 status = 0; 404 status = 0;
405 405
406 while ((iter = fgetln(f, &len)) != NULL) { 406 while ((iter = fgetln(f, &len)) != NULL) {
407 if (iter[len - 1] == '\n') 407 if (iter[len - 1] == '\n')
408 iter[len - 1] = '\0'; 408 iter[len - 1] = '\0';
409 filename = pkgdb_pkg_file(iter, CONTENTS_FNAME); 409 filename = pkgdb_pkg_file(iter, CONTENTS_FNAME);
410 if ((f_pkg = fopen(filename, "r")) == NULL) { 410 if ((f_pkg = fopen(filename, "r")) == NULL) {
411 warnx("Can't open +CONTENTS of depending package %s", 411 warnx("Can't open +CONTENTS of depending package %s",
412 iter); 412 iter);
413 fclose(f); 413 fclose(f);
414 return -1; 414 return -1;
415 } 415 }
416 read_plist(&plist, f_pkg); 416 read_plist(&plist, f_pkg);
417 fclose(f_pkg); 417 fclose(f_pkg);
418 for (p = plist.head; p != NULL; p = p->next) { 418 for (p = plist.head; p != NULL; p = p->next) {
419 if (p->type == PLIST_IGNORE) { 419 if (p->type == PLIST_IGNORE) {
420 p = p->next; 420 p = p->next;
421 continue; 421 continue;
422 } else if (p->type != PLIST_PKGDEP) 422 } else if (p->type != PLIST_PKGDEP)
423 continue; 423 continue;
424 /* 424 /*
425 * XXX This is stricter than necessary. 425 * XXX This is stricter than necessary.
426 * XXX One pattern might be fulfilled by 426 * XXX One pattern might be fulfilled by
427 * XXX a different package and still need this 427 * XXX a different package and still need this
428 * XXX one for a different pattern. 428 * XXX one for a different pattern.
429 */ 429 */
430 if (pkg_match(p->name, pkg->other_version) == 0) 430 if (pkg_match(p->name, pkg->other_version) == 0)
431 continue; 431 continue;
432 if (pkg_match(p->name, pkg->pkgname) == 1) 432 if (pkg_match(p->name, pkg->pkgname) == 1)
433 continue; /* Both match, ok. */ 433 continue; /* Both match, ok. */
434 warnx("Dependency of %s fulfilled by %s, but not by %s", 434 warnx("Dependency of %s fulfilled by %s, but not by %s",
435 iter, pkg->other_version, pkg->pkgname); 435 iter, pkg->other_version, pkg->pkgname);
436 if (!Force) 436 if (!Force)
437 status = -1; 437 status = -1;
438 break; 438 break;
439 } 439 }
440 free_plist(&plist);  440 free_plist(&plist);
441 } 441 }
442 442
443 fclose(f); 443 fclose(f);
444 444
445 return status; 445 return status;
446} 446}
447 447
448/* 448/*
449 * Read package build information from meta data. 449 * Read package build information from meta data.
450 */ 450 */
451static int 451static int
452read_buildinfo(struct pkg_task *pkg) 452read_buildinfo(struct pkg_task *pkg)
453{ 453{
454 const char *data, *eol, *next_line; 454 const char *data, *eol, *next_line;
455 455
456 data = pkg->meta_data.meta_build_info; 456 data = pkg->meta_data.meta_build_info;
457 457
458 for (; *data != '\0'; data = next_line) { 458 for (; *data != '\0'; data = next_line) {
459 if ((eol = strchr(data, '\n')) == NULL) { 459 if ((eol = strchr(data, '\n')) == NULL) {
460 eol = data + strlen(data); 460 eol = data + strlen(data);
461 next_line = eol; 461 next_line = eol;
462 } else 462 } else
463 next_line = eol + 1; 463 next_line = eol + 1;
464 464
465 if (strncmp(data, "OPSYS=", 6) == 0) 465 if (strncmp(data, "OPSYS=", 6) == 0)
466 pkg->buildinfo[BI_OPSYS] = dup_value(data, eol); 466 pkg->buildinfo[BI_OPSYS] = dup_value(data, eol);
467 else if (strncmp(data, "OS_VERSION=", 11) == 0) 467 else if (strncmp(data, "OS_VERSION=", 11) == 0)
468 pkg->buildinfo[BI_OS_VERSION] = dup_value(data, eol); 468 pkg->buildinfo[BI_OS_VERSION] = dup_value(data, eol);
469 else if (strncmp(data, "MACHINE_ARCH=", 13) == 0) 469 else if (strncmp(data, "MACHINE_ARCH=", 13) == 0)
470 pkg->buildinfo[BI_MACHINE_ARCH] = dup_value(data, eol); 470 pkg->buildinfo[BI_MACHINE_ARCH] = dup_value(data, eol);
471 else if (strncmp(data, "IGNORE_RECOMMENDED=", 19) == 0) 471 else if (strncmp(data, "IGNORE_RECOMMENDED=", 19) == 0)
472 pkg->buildinfo[BI_IGNORE_RECOMMENDED] = dup_value(data, 472 pkg->buildinfo[BI_IGNORE_RECOMMENDED] = dup_value(data,
473 eol); 473 eol);
474 else if (strncmp(data, "USE_ABI_DEPENDS=", 16) == 0) 474 else if (strncmp(data, "USE_ABI_DEPENDS=", 16) == 0)
475 pkg->buildinfo[BI_USE_ABI_DEPENDS] = dup_value(data, 475 pkg->buildinfo[BI_USE_ABI_DEPENDS] = dup_value(data,
476 eol); 476 eol);
477 } 477 }
478 if (pkg->buildinfo[BI_OPSYS] == NULL || 478 if (pkg->buildinfo[BI_OPSYS] == NULL ||
479 pkg->buildinfo[BI_OS_VERSION] == NULL || 479 pkg->buildinfo[BI_OS_VERSION] == NULL ||
480 pkg->buildinfo[BI_MACHINE_ARCH] == NULL) { 480 pkg->buildinfo[BI_MACHINE_ARCH] == NULL) {
481 warnx("Not all required build information are present."); 481 warnx("Not all required build information are present.");
482 return -1; 482 return -1;
483 } 483 }
484 484
485 if ((pkg->buildinfo[BI_USE_ABI_DEPENDS] != NULL && 485 if ((pkg->buildinfo[BI_USE_ABI_DEPENDS] != NULL &&
486 strcasecmp(pkg->buildinfo[BI_USE_ABI_DEPENDS], "YES") != 0) || 486 strcasecmp(pkg->buildinfo[BI_USE_ABI_DEPENDS], "YES") != 0) ||
487 (pkg->buildinfo[BI_IGNORE_RECOMMENDED] != NULL && 487 (pkg->buildinfo[BI_IGNORE_RECOMMENDED] != NULL &&
488 strcasecmp(pkg->buildinfo[BI_IGNORE_RECOMMENDED], "NO") != 0)) { 488 strcasecmp(pkg->buildinfo[BI_IGNORE_RECOMMENDED], "NO") != 0)) {
489 warnx("%s was built to ignore ABI dependencies", pkg->pkgname); 489 warnx("%s was built to ignore ABI dependencies", pkg->pkgname);
490 } 490 }
491 491
492 return 0; 492 return 0;
493} 493}
494 494
495/* 495/*
496 * Free buildinfo. 496 * Free buildinfo.
497 */ 497 */
498static void 498static void
499free_buildinfo(struct pkg_task *pkg) 499free_buildinfo(struct pkg_task *pkg)
500{ 500{
501 size_t i; 501 size_t i;
502 502
503 for (i = 0; i < BI_ENUM_COUNT; ++i) { 503 for (i = 0; i < BI_ENUM_COUNT; ++i) {
504 free(pkg->buildinfo[i]); 504 free(pkg->buildinfo[i]);
505 pkg->buildinfo[i] = NULL; 505 pkg->buildinfo[i] = NULL;
506 } 506 }
507} 507}
508 508
509/* 509/*
510 * Write meta data files to pkgdb after creating the directory. 510 * Write meta data files to pkgdb after creating the directory.
511 */ 511 */
512static int 512static int
513write_meta_data(struct pkg_task *pkg) 513write_meta_data(struct pkg_task *pkg)
514{ 514{
515 const struct pkg_meta_desc *descr; 515 const struct pkg_meta_desc *descr;
516 char *filename, **target; 516 char *filename, **target;
517 size_t len; 517 size_t len;
518 ssize_t ret; 518 ssize_t ret;
519 int fd; 519 int fd;
520 520
521 if (Fake) 521 if (Fake)
522 return 0; 522 return 0;
523 523
524 if (mkdir_p(pkg->install_logdir)) { 524 if (mkdir_p(pkg->install_logdir)) {
525 warn("Can't create pkgdb entry: %s", pkg->install_logdir); 525 warn("Can't create pkgdb entry: %s", pkg->install_logdir);
526 return -1; 526 return -1;
527 } 527 }
528 528
529 for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) { 529 for (descr = pkg_meta_descriptors; descr->entry_filename; ++descr) {
530 target = (char **)((char *)&pkg->meta_data + 530 target = (char **)((char *)&pkg->meta_data +
531 descr->entry_offset); 531 descr->entry_offset);
532 if (*target == NULL) 532 if (*target == NULL)
533 continue; 533 continue;
534 filename = xasprintf("%s/%s", pkg->install_logdir, 534 filename = xasprintf("%s/%s", pkg->install_logdir,
535 descr->entry_filename); 535 descr->entry_filename);
536 (void)unlink(filename); 536 (void)unlink(filename);
537 fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, descr->perm); 537 fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, descr->perm);
538 if (fd == -1) { 538 if (fd == -1) {
539 warn("Can't open meta data file: %s", filename); 539 warn("Can't open meta data file: %s", filename);
540 return -1; 540 return -1;
541 } 541 }
542 len = strlen(*target); 542 len = strlen(*target);
543 do { 543 do {
544 ret = write(fd, *target, len); 544 ret = write(fd, *target, len);
545 if (ret == -1) { 545 if (ret == -1) {
546 warn("Can't write meta data file: %s", 546 warn("Can't write meta data file: %s",
547 filename); 547 filename);
548 free(filename); 548 free(filename);
549 return -1; 549 return -1;
550 } 550 }
551 len -= ret; 551 len -= ret;
552 } while (ret > 0); 552 } while (ret > 0);
553 if (close(fd) == -1) { 553 if (close(fd) == -1) {
554 warn("Can't close meta data file: %s", filename); 554 warn("Can't close meta data file: %s", filename);
555 free(filename); 555 free(filename);
556 return -1; 556 return -1;
557 } 557 }
558 free(filename); 558 free(filename);
559 } 559 }
560 560
561 return 0; 561 return 0;
562} 562}
563 563
564/* 564/*
565 * Helper function for extract_files. 565 * Helper function for extract_files.
566 */ 566 */
567static int 567static int
568copy_data_to_disk(struct archive *reader, struct archive *writer, 568copy_data_to_disk(struct archive *reader, struct archive *writer,
569 const char *filename) 569 const char *filename)
570{ 570{
571 int r; 571 int r;
572 const void *buff; 572 const void *buff;
573 size_t size; 573 size_t size;
574 off_t offset; 574 off_t offset;
575 575
576 for (;;) { 576 for (;;) {
577 r = archive_read_data_block(reader, &buff, &size, &offset); 577 r = archive_read_data_block(reader, &buff, &size, &offset);
578 if (r == ARCHIVE_EOF) 578 if (r == ARCHIVE_EOF)
579 return 0; 579 return 0;
580 if (r != ARCHIVE_OK) { 580 if (r != ARCHIVE_OK) {
581 warnx("Read error for %s: %s", filename, 581 warnx("Read error for %s: %s", filename,
582 archive_error_string(reader)); 582 archive_error_string(reader));
583 return -1; 583 return -1;
584 } 584 }
585 r = archive_write_data_block(writer, buff, size, offset); 585 r = archive_write_data_block(writer, buff, size, offset);
586 if (r != ARCHIVE_OK) { 586 if (r != ARCHIVE_OK) {
587 warnx("Write error for %s: %s", filename, 587 warnx("Write error for %s: %s", filename,
588 archive_error_string(writer)); 588 archive_error_string(writer));
589 return -1; 589 return -1;
590 } 590 }
591 } 591 }
592} 592}
593 593
594/* 594/*
595 * Extract package. 595 * Extract package.
596 * Any misordered, missing or unlisted file in the package is an error. 596 * Any misordered, missing or unlisted file in the package is an error.
597 */ 597 */
598 598
599static const int extract_flags = /* ARCHIVE_EXTRACT_OWNER | */ 599static const int extract_flags = /* ARCHIVE_EXTRACT_OWNER | */
600 ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK | 600 ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_UNLINK |
601 ARCHIVE_EXTRACT_ACL | ARCHIVE_EXTRACT_FFLAGS | ARCHIVE_EXTRACT_XATTR; 601 ARCHIVE_EXTRACT_ACL | ARCHIVE_EXTRACT_FFLAGS | ARCHIVE_EXTRACT_XATTR;
602 602
603static int 603static int
604extract_files(struct pkg_task *pkg) 604extract_files(struct pkg_task *pkg)
605{ 605{
606 char cmd[MaxPathSize]; 606 char cmd[MaxPathSize];
607 const char *owner, *group, *permissions; 607 const char *owner, *group, *permissions;
608 struct archive *writer; 608 struct archive *writer;
609 int r; 609 int r;
610 plist_t *p; 610 plist_t *p;
611 const char *last_file; 611 const char *last_file;
612 char *fullpath; 612 char *fullpath;
613 613
614 if (Fake) 614 if (Fake)
615 return 0; 615 return 0;
616 616
617 if (mkdir_p(pkg->install_prefix)) { 617 if (mkdir_p(pkg->install_prefix)) {
618 warn("Can't create prefix: %s", pkg->install_prefix); 618 warn("Can't create prefix: %s", pkg->install_prefix);
619 return -1; 619 return -1;
620 } 620 }
621 621
622 if (!NoRecord && !pkgdb_open(ReadWrite)) { 622 if (!NoRecord && !pkgdb_open(ReadWrite)) {
623 warn("Can't open pkgdb for writing"); 623 warn("Can't open pkgdb for writing");
624 return -1; 624 return -1;
625 } 625 }
626 626
627 if (chdir(pkg->install_prefix) == -1) { 627 if (chdir(pkg->install_prefix) == -1) {
628 warn("Can't change into prefix: %s", pkg->install_prefix); 628 warn("Can't change into prefix: %s", pkg->install_prefix);
629 return -1; 629 return -1;
630 } 630 }
631 631
632 writer = archive_write_disk_new(); 632 writer = archive_write_disk_new();
633 archive_write_disk_set_options(writer, extract_flags); 633 archive_write_disk_set_options(writer, extract_flags);
634 archive_write_disk_set_standard_lookup(writer); 634 archive_write_disk_set_standard_lookup(writer);
635 635
636 owner = NULL; 636 owner = NULL;
637 group = NULL; 637 group = NULL;
638 permissions = NULL; 638 permissions = NULL;
639 last_file = NULL; 639 last_file = NULL;
640 640
641 r = -1; 641 r = -1;
642 642
643 for (p = pkg->plist.head; p != NULL; p = p->next) { 643 for (p = pkg->plist.head; p != NULL; p = p->next) {
644 switch (p->type) { 644 switch (p->type) {
645 case PLIST_FILE: 645 case PLIST_FILE:
646 last_file = p->name; 646 last_file = p->name;
647 if (pkg->entry == NULL) { 647 if (pkg->entry == NULL) {
648 warnx("PLIST entry not in package (%s)", 648 warnx("PLIST entry not in package (%s)",
649 archive_entry_pathname(pkg->entry)); 649 archive_entry_pathname(pkg->entry));
650 goto out; 650 goto out;
651 } 651 }
652 if (strcmp(p->name, archive_entry_pathname(pkg->entry))) { 652 if (strcmp(p->name, archive_entry_pathname(pkg->entry))) {
653 warnx("PLIST entry and package don't match (%s vs %s)", 653 warnx("PLIST entry and package don't match (%s vs %s)",
654 p->name, archive_entry_pathname(pkg->entry)); 654 p->name, archive_entry_pathname(pkg->entry));
655 goto out; 655 goto out;
656 } 656 }
657 fullpath = xasprintf("%s/%s", pkg->prefix, p->name); 657 fullpath = xasprintf("%s/%s", pkg->prefix, p->name);
658 pkgdb_store(fullpath, pkg->pkgname); 658 pkgdb_store(fullpath, pkg->pkgname);
659 free(fullpath); 659 free(fullpath);
660 if (Verbose) 660 if (Verbose)
661 printf("%s", p->name); 661 printf("%s", p->name);
662 break; 662 break;
663 663
664 case PLIST_CMD: 664 case PLIST_CMD:
665 if (format_cmd(cmd, sizeof(cmd), p->name, pkg->prefix, last_file)) 665 if (format_cmd(cmd, sizeof(cmd), p->name, pkg->prefix, last_file))
666 return -1; 666 return -1;
667 printf("Executing '%s'\n", cmd); 667 printf("Executing '%s'\n", cmd);
668 if (!Fake && system(cmd)) 668 if (!Fake && system(cmd))
669 warnx("command '%s' failed", cmd); /* XXX bail out? */ 669 warnx("command '%s' failed", cmd); /* XXX bail out? */
670 continue; 670 continue;
671 671
672 case PLIST_CHMOD: 672 case PLIST_CHMOD:
673 permissions = p->name; 673 permissions = p->name;
674 continue; 674 continue;
675 675
676 case PLIST_CHOWN: 676 case PLIST_CHOWN:
677 owner = p->name; 677 owner = p->name;
678 continue; 678 continue;
679 679
680 case PLIST_CHGRP: 680 case PLIST_CHGRP:
681 group = p->name; 681 group = p->name;
682 continue; 682 continue;
683 683
684 case PLIST_IGNORE: 684 case PLIST_IGNORE:
685 p = p->next; 685 p = p->next;
686 continue; 686 continue;
687 687
688 default: 688 default:
689 continue; 689 continue;
690 } 690 }
691 691
692 r = archive_write_header(writer, pkg->entry); 692 r = archive_write_header(writer, pkg->entry);
693 if (r != ARCHIVE_OK) { 693 if (r != ARCHIVE_OK) {
694 warnx("Failed to write %s: %s", 694 warnx("Failed to write %s: %s",
695 archive_entry_pathname(pkg->entry), 695 archive_entry_pathname(pkg->entry),
696 archive_error_string(writer)); 696 archive_error_string(writer));
697 goto out; 697 goto out;
698 } 698 }
699 699
700 if (owner != NULL) 700 if (owner != NULL)
701 archive_entry_set_uname(pkg->entry, owner); 701 archive_entry_set_uname(pkg->entry, owner);
702 if (group != NULL) 702 if (group != NULL)
703 archive_entry_set_uname(pkg->entry, group); 703 archive_entry_set_uname(pkg->entry, group);
704 if (permissions != NULL) { 704 if (permissions != NULL) {
705 mode_t mode; 705 mode_t mode;
706 706
707 mode = archive_entry_mode(pkg->entry); 707 mode = archive_entry_mode(pkg->entry);
708 mode = getmode(setmode(permissions), mode); 708 mode = getmode(setmode(permissions), mode);
709 archive_entry_set_mode(pkg->entry, mode); 709 archive_entry_set_mode(pkg->entry, mode);
710 } 710 }
711 711
712 r = copy_data_to_disk(pkg->archive, writer, 712 r = copy_data_to_disk(pkg->archive, writer,
713 archive_entry_pathname(pkg->entry)); 713 archive_entry_pathname(pkg->entry));
714 if (r) 714 if (r)
715 goto out; 715 goto out;
716 if (Verbose) 716 if (Verbose)
717 printf("\n"); 717 printf("\n");
718 718
719 r = archive_read_next_header(pkg->archive, &pkg->entry); 719 r = archive_read_next_header(pkg->archive, &pkg->entry);
720 if (r == ARCHIVE_EOF) { 720 if (r == ARCHIVE_EOF) {
721 pkg->entry = NULL; 721 pkg->entry = NULL;
722 continue; 722 continue;
723 } 723 }
724 if (r != ARCHIVE_OK) { 724 if (r != ARCHIVE_OK) {
725 warnx("Failed to read from archive: %s", 725 warnx("Failed to read from archive: %s",
726 archive_error_string(pkg->archive)); 726 archive_error_string(pkg->archive));
727 goto out; 727 goto out;
728 } 728 }
729 } 729 }
730 730
731 if (pkg->entry != NULL) { 731 if (pkg->entry != NULL) {
732 warnx("Package contains entries not in PLIST: %s", 732 warnx("Package contains entries not in PLIST: %s",
733 archive_entry_pathname(pkg->entry)); 733 archive_entry_pathname(pkg->entry));
734 goto out; 734 goto out;
735 } 735 }
736 736
737 r = 0; 737 r = 0;
738 738
739out: 739out:
740 if (!NoRecord) 740 if (!NoRecord)
741 pkgdb_close(); 741 pkgdb_close();
742 archive_write_close(writer); 742 archive_write_close(writer);
743 archive_write_finish(writer); 743 archive_write_finish(writer);
744 744
745 return r; 745 return r;
746} 746}
747 747
748/* 748/*
749 * Register dependencies after sucessfully installing the package. 749 * Register dependencies after sucessfully installing the package.
750 */ 750 */
751static void 751static void
752pkg_register_depends(struct pkg_task *pkg) 752pkg_register_depends(struct pkg_task *pkg)
753{ 753{
754 int fd; 754 int fd;
755 size_t text_len, i; 755 size_t text_len, i;
756 char *required_by, *text; 756 char *required_by, *text;
757 757
758 if (Fake) 758 if (Fake)
759 return; 759 return;
760 760
761 if (pkg->other_version != NULL) 761 if (pkg->other_version != NULL)
762 return; /* XXX It's using the old dependencies. */ 762 return; /* XXX It's using the old dependencies. */
763 763
764 text = xasprintf("%s\n", pkg->pkgname); 764 text = xasprintf("%s\n", pkg->pkgname);
765 text_len = strlen(text); 765 text_len = strlen(text);
766 766
767 for (i = 0; i < pkg->dep_length; ++i) { 767 for (i = 0; i < pkg->dep_length; ++i) {
768 required_by = pkgdb_pkg_file(pkg->dependencies[i], REQUIRED_BY_FNAME); 768 required_by = pkgdb_pkg_file(pkg->dependencies[i], REQUIRED_BY_FNAME);
769 769
770 fd = open(required_by, O_WRONLY | O_APPEND | O_CREAT, 0644); 770 fd = open(required_by, O_WRONLY | O_APPEND | O_CREAT, 0644);
771 if (fd == -1) 771 if (fd == -1)
772 warn("can't open dependency file '%s'," 772 warn("can't open dependency file '%s',"
773 "registration is incomplete!", required_by); 773 "registration is incomplete!", required_by);
774 else if (write(fd, text, text_len) != text_len) 774 else if (write(fd, text, text_len) != text_len)
775 warn("can't write to dependency file `%s'", required_by); 775 warn("can't write to dependency file `%s'", required_by);
776 else if (close(fd) == -1) 776 else if (close(fd) == -1)
777 warn("cannot close file %s", required_by); 777 warn("cannot close file %s", required_by);
778 778
779 free(required_by); 779 free(required_by);
780 } 780 }
781 781
782 free(text); 782 free(text);
783} 783}
784 784
785/* 785/*
786 * Reduce the result from uname(3) to a canonical form. 786 * Reduce the result from uname(3) to a canonical form.
787 */ 787 */
788static void 788static void
789normalise_platform(struct utsname *host_name) 789normalise_platform(struct utsname *host_name)
790{ 790{
791#ifdef NUMERIC_VERSION_ONLY 791#ifdef NUMERIC_VERSION_ONLY
792 size_t span; 792 size_t span;
793 793
794 span = strspn(host_name->release, "0123456789."); 794 span = strspn(host_name->release, "0123456789.");
795 host_name->release[span] = '\0'; 795 host_name->release[span] = '\0';
796#endif 796#endif
797} 797}
798 798
799/* 799/*
800 * Check build platform of the package against local host. 800 * Check build platform of the package against local host.
801 */ 801 */
802static int 802static int
803check_platform(struct pkg_task *pkg) 803check_platform(struct pkg_task *pkg)
804{ 804{
805 struct utsname host_uname; 805 struct utsname host_uname;
806 const char *effective_arch; 806 const char *effective_arch;
807 int fatal; 807 int fatal;
808 808
809 if (uname(&host_uname) < 0) { 809 if (uname(&host_uname) < 0) {
810 if (Force) { 810 if (Force) {
811 warnx("uname() failed, continuing."); 811 warnx("uname() failed, continuing.");
812 return 0; 812 return 0;
813 } else { 813 } else {
814 warnx("uname() failed, aborting."); 814 warnx("uname() failed, aborting.");
815 return -1; 815 return -1;
816 } 816 }
817 } 817 }
818 818
819 normalise_platform(&host_uname); 819 normalise_platform(&host_uname);
820 820
821 if (OverrideMachine != NULL) 821 if (OverrideMachine != NULL)
822 effective_arch = OverrideMachine; 822 effective_arch = OverrideMachine;
823 else 823 else
824 effective_arch = MACHINE_ARCH; 824 effective_arch = MACHINE_ARCH;
825 825
826 /* If either the OS or arch are different, bomb */ 826 /* If either the OS or arch are different, bomb */
827 if (strcmp(OPSYS_NAME, pkg->buildinfo[BI_OPSYS]) || 827 if (strcmp(OPSYS_NAME, pkg->buildinfo[BI_OPSYS]) ||
828 strcmp(effective_arch, pkg->buildinfo[BI_MACHINE_ARCH]) != 0) 828 strcmp(effective_arch, pkg->buildinfo[BI_MACHINE_ARCH]) != 0)
829 fatal = 1; 829 fatal = 1;
830 else 830 else
831 fatal = 0; 831 fatal = 0;
832 832
833 if (fatal || 833 if (fatal ||
834 strcmp(host_uname.release, pkg->buildinfo[BI_OS_VERSION]) != 0) { 834 strcmp(host_uname.release, pkg->buildinfo[BI_OS_VERSION]) != 0) {
835 warnx("Warning: package `%s' was built for a platform:", 835 warnx("Warning: package `%s' was built for a platform:",
836 pkg->pkgname); 836 pkg->pkgname);
837 warnx("%s/%s %s (pkg) vs. %s/%s %s (this host)", 837 warnx("%s/%s %s (pkg) vs. %s/%s %s (this host)",
838 pkg->buildinfo[BI_OPSYS], 838 pkg->buildinfo[BI_OPSYS],
839 pkg->buildinfo[BI_MACHINE_ARCH], 839 pkg->buildinfo[BI_MACHINE_ARCH],
840 pkg->buildinfo[BI_OS_VERSION], 840 pkg->buildinfo[BI_OS_VERSION],
841 OPSYS_NAME, 841 OPSYS_NAME,
842 effective_arch, 842 effective_arch,
843 host_uname.release); 843 host_uname.release);
844 if (!Force && fatal) 844 if (!Force && fatal)
845 return -1; 845 return -1;
846 } 846 }
847 return 0; 847 return 0;
848} 848}
849 849
850/* 850/*
851 * Run the install script. 851 * Run the install script.
852 */ 852 */
853static int 853static int
854run_install_script(struct pkg_task *pkg, const char *argument) 854run_install_script(struct pkg_task *pkg, const char *argument)
855{ 855{
856 int ret; 856 int ret;
857 char *filename; 857 char *filename;
858 858
859 if (pkg->meta_data.meta_install == NULL || NoInstall) 859 if (pkg->meta_data.meta_install == NULL || NoInstall)
860 return 0; 860 return 0;
861 861
862 if (Destdir != NULL) 862 if (Destdir != NULL)
863 setenv(PKG_DESTDIR_VNAME, Destdir, 1); 863 setenv(PKG_DESTDIR_VNAME, Destdir, 1);
864 setenv(PKG_PREFIX_VNAME, pkg->prefix, 1); 864 setenv(PKG_PREFIX_VNAME, pkg->prefix, 1);
865 setenv(PKG_METADATA_DIR_VNAME, pkg->logdir, 1); 865 setenv(PKG_METADATA_DIR_VNAME, pkg->logdir, 1);
866 setenv(PKG_REFCOUNT_DBDIR_VNAME, pkgdb_refcount_dir(), 1); 866 setenv(PKG_REFCOUNT_DBDIR_VNAME, pkgdb_refcount_dir(), 1);
867 867
868 if (Verbose) 868 if (Verbose)
869 printf("Running install with PRE-INSTALL for %s.\n", pkg->pkgname); 869 printf("Running install with PRE-INSTALL for %s.\n", pkg->pkgname);
870 if (Fake) 870 if (Fake)
871 return 0; 871 return 0;
872 872
873 filename = pkgdb_pkg_file(pkg->pkgname, INSTALL_FNAME); 873 filename = pkgdb_pkg_file(pkg->pkgname, INSTALL_FNAME);
874 874
875 ret = 0; 875 ret = 0;
876 errno = 0; 876 errno = 0;
877 if (fcexec(pkg->install_logdir, filename, pkg->pkgname, argument, 877 if (fcexec(pkg->install_logdir, filename, pkg->pkgname, argument,
878 (void *)NULL)) { 878 (void *)NULL)) {
879 if (errno != 0) 879 if (errno != 0)
880 warn("exec of install script failed"); 880 warn("exec of install script failed");
881 else 881 else
882 warnx("install script returned error status"); 882 warnx("install script returned error status");
883 ret = -1; 883 ret = -1;
884 } 884 }
885 free(filename); 885 free(filename);
886 886
887 return ret; 887 return ret;
888} 888}
889 889
890static int 890static int
891check_explicit_conflict(struct pkg_task *pkg) 891check_explicit_conflict(struct pkg_task *pkg)
892{ 892{
893 char *installed, *installed_pattern; 893 char *installed, *installed_pattern;
894 plist_t *p; 894 plist_t *p;
895 int status; 895 int status;
896 896
897 status = 0; 897 status = 0;
898 898
899 for (p = pkg->plist.head; p != NULL; p = p->next) { 899 for (p = pkg->plist.head; p != NULL; p = p->next) {
900 if (p->type == PLIST_IGNORE) { 900 if (p->type == PLIST_IGNORE) {
901 p = p->next; 901 p = p->next;
902 continue; 902 continue;
903 } else if (p->type != PLIST_PKGCFL) 903 } else if (p->type != PLIST_PKGCFL)
904 continue; 904 continue;
905 installed = find_best_matching_installed_pkg(p->name); 905 installed = find_best_matching_installed_pkg(p->name);
906 if (installed) { 906 if (installed) {
907 warnx("Package `%s' conflicts with `%s', and `%s' is installed.", 907 warnx("Package `%s' conflicts with `%s', and `%s' is installed.",
908 pkg->pkgname, p->name, installed); 908 pkg->pkgname, p->name, installed);
909 free(installed); 909 free(installed);
910 status = -1; 910 status = -1;
911 } 911 }
912 } 912 }
913 913
914 if (some_installed_package_conflicts_with(pkg->pkgname, 914 if (some_installed_package_conflicts_with(pkg->pkgname,
915 pkg->other_version, &installed, &installed_pattern)) { 915 pkg->other_version, &installed, &installed_pattern)) {
916 warnx("Installed package `%s' conflicts with `%s' when trying to install `%s'.", 916 warnx("Installed package `%s' conflicts with `%s' when trying to install `%s'.",
917 installed, installed_pattern, pkg->pkgname); 917 installed, installed_pattern, pkg->pkgname);
918 free(installed); 918 free(installed);
919 free(installed_pattern); 919 free(installed_pattern);
920 status = -1; 920 status = -1;
921 } 921 }
922 922
923 return status; 923 return status;
924} 924}
925 925
926static int 926static int
927check_implicit_conflict(struct pkg_task *pkg) 927check_implicit_conflict(struct pkg_task *pkg)
928{ 928{
929 plist_t *p; 929 plist_t *p;
930 char *fullpath, *existing; 930 char *fullpath, *existing;
931 int status; 931 int status;
932 932
933 if (!pkgdb_open(ReadOnly)) { 933 if (!pkgdb_open(ReadOnly)) {
934#if notyet /* XXX empty pkgdb without database? */ 934#if notyet /* XXX empty pkgdb without database? */
935 warn("Can't open pkgdb for reading"); 935 warn("Can't open pkgdb for reading");
936 return -1; 936 return -1;
937#else 937#else
938 return 0; 938 return 0;
939#endif 939#endif
940 } 940 }
941 941
942 status = 0; 942 status = 0;
943 943
944 for (p = pkg->plist.head; p != NULL; p = p->next) { 944 for (p = pkg->plist.head; p != NULL; p = p->next) {
945 if (p->type == PLIST_IGNORE) { 945 if (p->type == PLIST_IGNORE) {
946 p = p->next; 946 p = p->next;
947 continue; 947 continue;
948 } else if (p->type != PLIST_FILE) 948 } else if (p->type != PLIST_FILE)
949 continue; 949 continue;
950 950
951 fullpath = xasprintf("%s/%s", pkg->prefix, p->name); 951 fullpath = xasprintf("%s/%s", pkg->prefix, p->name);
952 existing = pkgdb_retrieve(fullpath); 952 existing = pkgdb_retrieve(fullpath);
953 free(fullpath); 953 free(fullpath);
954 if (existing == NULL) 954 if (existing == NULL)
955 continue; 955 continue;
956 if (pkg->other_version != NULL && 956 if (pkg->other_version != NULL &&
957 strcmp(pkg->other_version, existing) == 0) 957 strcmp(pkg->other_version, existing) == 0)
958 continue; 958 continue;
959 959
960 warnx("Conflicting PLIST with %s: %s", existing, p->name); 960 warnx("Conflicting PLIST with %s: %s", existing, p->name);
961 if (!Force) { 961 if (!Force) {
962 status = -1; 962 status = -1;
963 if (!Verbose) 963 if (!Verbose)
964 break; 964 break;
965 } 965 }
966 } 966 }
967 967
968 pkgdb_close(); 968 pkgdb_close();
969 return status; 969 return status;
970} 970}
971 971
972static int 972static int
973check_dependencies(struct pkg_task *pkg) 973check_dependencies(struct pkg_task *pkg)
974{ 974{
975 plist_t *p; 975 plist_t *p;
976 char *best_installed; 976 char *best_installed;
977 int status; 977 int status;
978 size_t i; 978 size_t i;
979 979
980 status = 0; 980 status = 0;
981 981
982 for (p = pkg->plist.head; p != NULL; p = p->next) { 982 for (p = pkg->plist.head; p != NULL; p = p->next) {
983 if (p->type == PLIST_IGNORE) { 983 if (p->type == PLIST_IGNORE) {
984 p = p->next; 984 p = p->next;
985 continue; 985 continue;
986 } else if (p->type != PLIST_PKGDEP) 986 } else if (p->type != PLIST_PKGDEP)
987 continue; 987 continue;
988 988
989 best_installed = find_best_matching_installed_pkg(p->name); 989 best_installed = find_best_matching_installed_pkg(p->name);
990 990
991 if (best_installed == NULL) { 991 if (best_installed == NULL) {
992 /* XXX check cyclic dependencies? */ 992 /* XXX check cyclic dependencies? */
993 if (Fake || NoRecord) { 993 if (Fake || NoRecord) {
994 if (!Force) { 994 if (!Force) {
995 warnx("Missing dependency %s\n", 995 warnx("Missing dependency %s\n",
996 p->name); 996 p->name);
997 status = -1; 997 status = -1;
998 break; 998 break;
999 } 999 }
1000 warnx("Missing dependency %s, continuing", 1000 warnx("Missing dependency %s, continuing",
1001 p->name); 1001 p->name);
1002 continue; 1002 continue;
1003 } 1003 }
1004 if (pkg_do(p->name, 1)) { 1004 if (pkg_do(p->name, 1)) {
1005 warnx("Can't install dependency %s", p->name); 1005 warnx("Can't install dependency %s", p->name);
1006 status = -1; 1006 status = -1;
1007 break; 1007 break;
1008 } 1008 }
1009 best_installed = find_best_matching_installed_pkg(p->name); 1009 best_installed = find_best_matching_installed_pkg(p->name);
1010 if (best_installed == NULL && Force) { 1010 if (best_installed == NULL && Force) {
1011 warnx("Missing dependency %s ignored", p->name); 1011 warnx("Missing dependency %s ignored", p->name);
1012 continue; 1012 continue;
1013 } else if (best_installed == NULL) { 1013 } else if (best_installed == NULL) {
1014 warnx("Just installed dependency %s disappeared", p->name); 1014 warnx("Just installed dependency %s disappeared", p->name);
1015 status = -1; 1015 status = -1;
1016 break; 1016 break;
1017 } 1017 }
1018 } 1018 }
1019 for (i = 0; i < pkg->dep_length; ++i) { 1019 for (i = 0; i < pkg->dep_length; ++i) {
1020 if (strcmp(best_installed, pkg->dependencies[i]) == 0) 1020 if (strcmp(best_installed, pkg->dependencies[i]) == 0)
1021 break; 1021 break;
1022 } 1022 }
1023 if (i < pkg->dep_length) { 1023 if (i < pkg->dep_length) {
1024 /* Already used as dependency, so skip it. */ 1024 /* Already used as dependency, so skip it. */
1025 free(best_installed); 1025 free(best_installed);
1026 continue; 1026 continue;
1027 } 1027 }
1028 if (pkg->dep_length + 1 >= pkg->dep_allocated) { 1028 if (pkg->dep_length + 1 >= pkg->dep_allocated) {
1029 char **tmp; 1029 char **tmp;
1030 pkg->dep_allocated = 2 * pkg->dep_allocated + 1; 1030 pkg->dep_allocated = 2 * pkg->dep_allocated + 1;
1031 pkg->dependencies = xrealloc(pkg->dependencies, 1031 pkg->dependencies = xrealloc(pkg->dependencies,
1032 pkg->dep_allocated * sizeof(*tmp)); 1032 pkg->dep_allocated * sizeof(*tmp));
1033 } 1033 }
1034 pkg->dependencies[pkg->dep_length++] = best_installed; 1034 pkg->dependencies[pkg->dep_length++] = best_installed;
1035 } 1035 }
1036 1036
1037 return status; 1037 return status;
1038} 1038}
1039 1039
1040/* 1040/*
1041 * If this package uses pkg_views, register it in the default view. 1041 * If this package uses pkg_views, register it in the default view.
1042 */ 1042 */
1043static void 1043static void
1044pkg_register_views(struct pkg_task *pkg) 1044pkg_register_views(struct pkg_task *pkg)
1045{ 1045{
1046 if (Fake || NoView || pkg->meta_data.meta_views == NULL) 1046 if (Fake || NoView || pkg->meta_data.meta_views == NULL)
1047 return; 1047 return;
1048 1048
1049 if (Verbose) { 1049 if (Verbose) {
1050 printf("%s/pkg_view -d %s %s%s %s%s %sadd %s\n", 1050 printf("%s/pkg_view -d %s %s%s %s%s %sadd %s\n",
1051 BINDIR, _pkgdb_getPKGDB_DIR(), 1051 BINDIR, _pkgdb_getPKGDB_DIR(),
1052 View ? "-w " : "", View ? View : "", 1052 View ? "-w " : "", View ? View : "",
1053 Viewbase ? "-W " : "", Viewbase ? Viewbase : "", 1053 Viewbase ? "-W " : "", Viewbase ? Viewbase : "",
1054 Verbose ? "-v " : "", pkg->pkgname); 1054 Verbose ? "-v " : "", pkg->pkgname);
1055 } 1055 }
1056 1056
1057 fexec_skipempty(BINDIR "/pkg_view", "-d", _pkgdb_getPKGDB_DIR(), 1057 fexec_skipempty(BINDIR "/pkg_view", "-d", _pkgdb_getPKGDB_DIR(),
1058 View ? "-w " : "", View ? View : "", 1058 View ? "-w " : "", View ? View : "",
1059 Viewbase ? "-W " : "", Viewbase ? Viewbase : "", 1059 Viewbase ? "-W " : "", Viewbase ? Viewbase : "",
1060 Verbose ? "-v " : "", "add", pkg->pkgname, 1060 Verbose ? "-v " : "", "add", pkg->pkgname,
1061 (void *)NULL); 1061 (void *)NULL);
1062} 1062}
1063 1063
1064static int 1064static int
1065preserve_meta_data_file(struct pkg_task *pkg, const char *name) 1065preserve_meta_data_file(struct pkg_task *pkg, const char *name)
1066{ 1066{
1067 char *old_file, *new_file; 1067 char *old_file, *new_file;
1068 int rv; 1068 int rv;
1069 1069
1070 if (Fake) 1070 if (Fake)
1071 return 0; 1071 return 0;
1072 1072
1073 old_file = pkgdb_pkg_file(pkg->other_version, name); 1073 old_file = pkgdb_pkg_file(pkg->other_version, name);
1074 new_file = pkgdb_pkg_file(pkg->pkgname, name); 1074 new_file = pkgdb_pkg_file(pkg->pkgname, name);
1075 rv = 0; 1075 rv = 0;
1076 if (rename(old_file, new_file) == -1 && errno != ENOENT) { 1076 if (rename(old_file, new_file) == -1 && errno != ENOENT) {
1077 warn("Can't move %s from %s to %s", name, old_file, new_file); 1077 warn("Can't move %s from %s to %s", name, old_file, new_file);
1078 rv = -1;  1078 rv = -1;
1079 } 1079 }
1080 free(old_file); 1080 free(old_file);
1081 free(new_file); 1081 free(new_file);
1082 return rv; 1082 return rv;
1083} 1083}
1084 1084
1085static int 1085static int
1086start_replacing(struct pkg_task *pkg) 1086start_replacing(struct pkg_task *pkg)
1087{ 1087{
1088 if (preserve_meta_data_file(pkg, REQUIRED_BY_FNAME)) 1088 if (preserve_meta_data_file(pkg, REQUIRED_BY_FNAME))
1089 return -1; 1089 return -1;
1090 1090
1091 if (pkg->meta_data.meta_preserve == NULL && 1091 if (pkg->meta_data.meta_preserve == NULL &&
1092 preserve_meta_data_file(pkg, PRESERVE_FNAME)) 1092 preserve_meta_data_file(pkg, PRESERVE_FNAME))
1093 return -1; 1093 return -1;
1094 1094
1095 if (pkg->meta_data.meta_installed_info == NULL && 1095 if (pkg->meta_data.meta_installed_info == NULL &&
1096 preserve_meta_data_file(pkg, INSTALLED_INFO_FNAME)) 1096 preserve_meta_data_file(pkg, INSTALLED_INFO_FNAME))
1097 return -1; 1097 return -1;
1098 1098
1099 if (Verbose || Fake) { 1099 if (Verbose || Fake) {
1100 printf("%s/pkg_delete -K %s -p %s%s%s '%s'\n", 1100 printf("%s/pkg_delete -K %s -p %s%s%s '%s'\n",
1101 BINDIR, _pkgdb_getPKGDB_DIR(), pkg->prefix, 1101 BINDIR, _pkgdb_getPKGDB_DIR(), pkg->prefix,
1102 Destdir ? " -P ": "", Destdir ? Destdir : "", 1102 Destdir ? " -P ": "", Destdir ? Destdir : "",
1103 pkg->other_version); 1103 pkg->other_version);
1104 } 1104 }
1105 if (!Fake) 1105 if (!Fake)
1106 fexec_skipempty(BINDIR "/pkg_delete", "-K", _pkgdb_getPKGDB_DIR(), 1106 fexec_skipempty(BINDIR "/pkg_delete", "-K", _pkgdb_getPKGDB_DIR(),
1107 "-p", pkg->prefix, 1107 "-p", pkg->prefix,
1108 Destdir ? "-P": "", Destdir ? Destdir : "", 1108 Destdir ? "-P": "", Destdir ? Destdir : "",
1109 pkg->other_version, NULL); 1109 pkg->other_version, NULL);
1110 1110
1111 /* XXX Check return value and do what? */ 1111 /* XXX Check return value and do what? */
1112 return 0; 1112 return 0;
1113} 1113}
1114 1114
1115static int check_input(const char *line, size_t len) 1115static int check_input(const char *line, size_t len)
1116{ 1116{
1117 if (line == NULL || len == 0) 1117 if (line == NULL || len == 0)
1118 return 1; 1118 return 1;
1119 switch (*line) { 1119 switch (*line) {
1120 case 'Y': 1120 case 'Y':
1121 case 'y': 1121 case 'y':
1122 case 'T': 1122 case 'T':
1123 case 't': 1123 case 't':
1124 case '1': 1124 case '1':
1125 return 0; 1125 return 0;
1126 default: 1126 default:
1127 return 1; 1127 return 1;
1128 } 1128 }
1129} 1129}
1130 1130
1131static int 1131static int
1132check_signature(struct pkg_task *pkg, void *signature_cookie, int invalid_sig) 1132check_signature(struct pkg_task *pkg, void *signature_cookie, int invalid_sig)
1133{ 1133{
1134 char *line; 1134 char *line;
1135 size_t len; 1135 size_t len;
1136 1136
1137 if (strcasecmp(verified_installation, "never") == 0) 1137 if (strcasecmp(verified_installation, "never") == 0)
1138 return 0; 1138 return 0;
1139 if (strcasecmp(verified_installation, "always") == 0) { 1139 if (strcasecmp(verified_installation, "always") == 0) {
1140 if (invalid_sig) 1140 if (invalid_sig)
1141 warnx("No valid signature found, rejected"); 1141 warnx("No valid signature found, rejected");
1142 return invalid_sig; 1142 return invalid_sig;
1143 } 1143 }
1144 if (strcasecmp(verified_installation, "trusted") == 0) { 1144 if (strcasecmp(verified_installation, "trusted") == 0) {
1145 if (!invalid_sig) 1145 if (!invalid_sig)
1146 return 0; 1146 return 0;
1147 fprintf(stderr, "No valid signature found for %s.\n", 1147 fprintf(stderr, "No valid signature found for %s.\n",
1148 pkg->pkgname); 1148 pkg->pkgname);
1149 fprintf(stderr, 1149 fprintf(stderr,
1150 "Do you want to proceed with the installation [y/n]?\n"); 1150 "Do you want to proceed with the installation [y/n]?\n");
1151 line = fgetln(stdin, &len); 1151 line = fgetln(stdin, &len);
1152 if (check_input(line, len)) { 1152 if (check_input(line, len)) {
1153 fprintf(stderr, "Cancelling installation\n"); 1153 fprintf(stderr, "Cancelling installation\n");
1154 return 1; 1154 return 1;
1155 } 1155 }
1156 return 0; 1156 return 0;
1157 } 1157 }
1158 if (strcasecmp(verified_installation, "interactive") == 0) { 1158 if (strcasecmp(verified_installation, "interactive") == 0) {
1159 fprintf(stderr, "Do you want to proceed with " 1159 fprintf(stderr, "Do you want to proceed with "
1160 "the installation of %s [y/n]?\n", pkg->pkgname); 1160 "the installation of %s [y/n]?\n", pkg->pkgname);
1161 line = fgetln(stdin, &len); 1161 line = fgetln(stdin, &len);
1162 if (check_input(line, len)) { 1162 if (check_input(line, len)) {
1163 fprintf(stderr, "Cancelling installation\n"); 1163 fprintf(stderr, "Cancelling installation\n");
1164 return 1; 1164 return 1;
1165 } 1165 }
1166 return 0; 1166 return 0;
1167 } 1167 }
1168 warnx("Unknown value of configuration variable VERIFIED_INSTALLATION"); 1168 warnx("Unknown value of configuration variable VERIFIED_INSTALLATION");
1169 return 1; 1169 return 1;
1170} 1170}
1171 1171
 1172static int
 1173check_vulnerable(struct pkg_task *pkg)
 1174{
 1175 static struct pkg_vulnerabilities *pv;
 1176 size_t i;
 1177 int require_check;
 1178 char *line;
 1179 size_t len;
 1180
 1181 if (strcasecmp(check_vulnerabilities, "never") == 0)
 1182 return 0;
 1183 else if (strcasecmp(check_vulnerabilities, "always"))
 1184 require_check = 1;
 1185 else if (strcasecmp(check_vulnerabilities, "interactive"))
 1186 require_check = 0;
 1187 else {
 1188 warnx("Unknown value of the configuration variable"
 1189 "CHECK_VULNERABILITIES");
 1190 return 1;
 1191 }
 1192
 1193 if (pv == NULL) {
 1194 pv = read_pkg_vulnerabilities(pkg_vulnerabilities_file,
 1195 require_check, 0);
 1196 if (pv == NULL)
 1197 return require_check;
 1198 }
 1199
 1200 for (i = 0; i < pv->entries; ++i) {
 1201 if (!pkg_match(pv->vulnerability[i], pkg->pkgname))
 1202 continue;
 1203 if (strcmp("eol", pv->classification[i]) == 0)
 1204 continue;
 1205 warnx("Package %s has a %s vulnerability, see %s",
 1206 pkg->pkgname, pv->classification[i], pv->advisory[i]);
 1207 fprintf(stderr, "Do you want to proceed with "
 1208 "the installation of %s [y/n]?\n", pkg->pkgname);
 1209 line = fgetln(stdin, &len);
 1210 if (check_input(line, len)) {
 1211 fprintf(stderr, "Cancelling installation\n");
 1212 return 1;
 1213 }
 1214 return 0;
 1215 }
 1216 return 0;
 1217}
 1218
1172/* 1219/*
1173 * Install a single package. 1220 * Install a single package.
1174 */ 1221 */
1175static int 1222static int
1176pkg_do(const char *pkgpath, int mark_automatic) 1223pkg_do(const char *pkgpath, int mark_automatic)
1177{ 1224{
1178 int status, invalid_sig; 1225 int status, invalid_sig;
1179 void *archive_cookie; 1226 void *archive_cookie;
1180 void *signature_cookie; 1227 void *signature_cookie;
1181 struct pkg_task *pkg; 1228 struct pkg_task *pkg;
1182 1229
1183 pkg = xcalloc(1, sizeof(*pkg)); 1230 pkg = xcalloc(1, sizeof(*pkg));
1184 1231
1185 status = -1; 1232 status = -1;
1186 1233
1187 if ((pkg->archive = find_archive(pkgpath, &archive_cookie)) == NULL) { 1234 if ((pkg->archive = find_archive(pkgpath, &archive_cookie)) == NULL) {
1188 warnx("no pkg found for '%s', sorry.", pkgpath); 1235 warnx("no pkg found for '%s', sorry.", pkgpath);
1189 goto clean_find_archive; 1236 goto clean_find_archive;
1190 } 1237 }
1191 1238
1192#ifdef HAVE_SSL 1239#ifdef HAVE_SSL
1193 invalid_sig = pkg_verify_signature(&pkg->archive, &pkg->entry, 1240 invalid_sig = pkg_verify_signature(&pkg->archive, &pkg->entry,
1194 &pkg->pkgname, &signature_cookie); 1241 &pkg->pkgname, &signature_cookie);
1195#else 1242#else
1196 invalid_sig = 1; 1243 invalid_sig = 1;
1197 signature_cookie = NULL; 1244 signature_cookie = NULL;
1198#endif 1245#endif
1199 1246
1200 if (read_meta_data(pkg)) 1247 if (read_meta_data(pkg))
1201 goto clean_memory; 1248 goto clean_memory;
1202 1249
1203 /* Parse PLIST early, so that messages can use real package name. */ 1250 /* Parse PLIST early, so that messages can use real package name. */
1204 if (pkg_parse_plist(pkg)) 1251 if (pkg_parse_plist(pkg))
1205 goto clean_memory; 1252 goto clean_memory;
1206 1253
1207 if (check_signature(pkg, &signature_cookie, invalid_sig)) 1254 if (check_signature(pkg, &signature_cookie, invalid_sig))
1208 goto clean_memory; 1255 goto clean_memory;
1209 1256
 1257 if (check_vulnerable(pkg))
 1258 goto clean_memory;
 1259
1210 if (pkg->meta_data.meta_mtree != NULL) 1260 if (pkg->meta_data.meta_mtree != NULL)
1211 warnx("mtree specification in pkg `%s' ignored", pkg->pkgname); 1261 warnx("mtree specification in pkg `%s' ignored", pkg->pkgname);
1212 1262
1213 if (pkg->meta_data.meta_views != NULL) { 1263 if (pkg->meta_data.meta_views != NULL) {
1214 pkg->logdir = xstrdup(pkg->prefix); 1264 pkg->logdir = xstrdup(pkg->prefix);
1215 _pkgdb_setPKGDB_DIR(dirname_of(pkg->logdir)); 1265 _pkgdb_setPKGDB_DIR(dirname_of(pkg->logdir));
1216 } else { 1266 } else {
1217 pkg->logdir = xasprintf("%s/%s", _pkgdb_getPKGDB_DIR(), 1267 pkg->logdir = xasprintf("%s/%s", _pkgdb_getPKGDB_DIR(),
1218 pkg->pkgname); 1268 pkg->pkgname);
1219 } 1269 }
1220 1270
1221 if (Destdir != NULL) { 1271 if (Destdir != NULL) {
1222 pkg->install_logdir = xasprintf("%s/%s", Destdir, pkg->logdir); 1272 pkg->install_logdir = xasprintf("%s/%s", Destdir, pkg->logdir);
1223 _pkgdb_setPKGDB_DIR(dirname_of(pkg->install_logdir)); 1273 _pkgdb_setPKGDB_DIR(dirname_of(pkg->install_logdir));
1224 } else 1274 } else
1225 pkg->install_logdir = xstrdup(pkg->logdir); 1275 pkg->install_logdir = xstrdup(pkg->logdir);
1226 1276
1227 if (NoRecord && !Fake) { 1277 if (NoRecord && !Fake) {
1228 const char *tmpdir; 1278 const char *tmpdir;
1229 1279
1230 tmpdir = getenv("TMPDIR"); 1280 tmpdir = getenv("TMPDIR");
1231 if (tmpdir == NULL) 1281 if (tmpdir == NULL)
1232 tmpdir = "/tmp"; 1282 tmpdir = "/tmp";
1233 1283
1234 free(pkg->install_logdir); 1284 free(pkg->install_logdir);
1235 pkg->install_logdir = xasprintf("%s/pkg_install.XXXXXX", tmpdir); 1285 pkg->install_logdir = xasprintf("%s/pkg_install.XXXXXX", tmpdir);
1236 /* XXX pkg_add -u... */ 1286 /* XXX pkg_add -u... */
1237 if (mkdtemp(pkg->install_logdir) == NULL) { 1287 if (mkdtemp(pkg->install_logdir) == NULL) {
1238 warn("mkdtemp failed"); 1288 warn("mkdtemp failed");
1239 goto clean_memory; 1289 goto clean_memory;
1240 } 1290 }
1241 } 1291 }
1242 1292
1243 if (check_already_installed(pkg) == 0) { 1293 if (check_already_installed(pkg) == 0) {
1244 status = 0; 1294 status = 0;
1245 goto clean_memory; 1295 goto clean_memory;
1246 } 1296 }
1247 1297
1248 if (read_buildinfo(pkg)) 1298 if (read_buildinfo(pkg))
1249 goto clean_memory; 1299 goto clean_memory;
1250 1300
1251 if (check_platform(pkg)) 1301 if (check_platform(pkg))
1252 goto clean_memory; 1302 goto clean_memory;
1253 1303
1254 if (check_other_installed(pkg)) 1304 if (check_other_installed(pkg))
1255 goto clean_memory;  1305 goto clean_memory;
1256 1306
1257 if (check_explicit_conflict(pkg)) 1307 if (check_explicit_conflict(pkg))
1258 goto clean_memory; 1308 goto clean_memory;
1259 1309
1260 if (check_implicit_conflict(pkg)) 1310 if (check_implicit_conflict(pkg))
1261 goto clean_memory; 1311 goto clean_memory;
1262 1312
1263 if (pkg->other_version != NULL) { 1313 if (pkg->other_version != NULL) {
1264 /* 1314 /*
1265 * Replacing an existing package. 1315 * Replacing an existing package.
1266 * Write meta-data, get rid of the old version, 1316 * Write meta-data, get rid of the old version,
1267 * install/update dependencies and finally extract. 1317 * install/update dependencies and finally extract.
1268 */ 1318 */
1269 if (write_meta_data(pkg)) 1319 if (write_meta_data(pkg))
1270 goto nuke_pkgdb; 1320 goto nuke_pkgdb;
1271 1321
1272 if (start_replacing(pkg)) 1322 if (start_replacing(pkg))
1273 goto nuke_pkgdb; 1323 goto nuke_pkgdb;
1274 1324
1275 if (check_dependencies(pkg)) 1325 if (check_dependencies(pkg))
1276 goto nuke_pkgdb; 1326 goto nuke_pkgdb;
1277 } else { 1327 } else {
1278 /* 1328 /*
1279 * Normal installation. 1329 * Normal installation.
1280 * Install/update dependencies first and 1330 * Install/update dependencies first and
1281 * write the current package to disk afterwards. 1331 * write the current package to disk afterwards.
1282 */  1332 */
1283 if (check_dependencies(pkg)) 1333 if (check_dependencies(pkg))
1284 goto clean_memory; 1334 goto clean_memory;
1285 1335
1286 if (write_meta_data(pkg)) 1336 if (write_meta_data(pkg))
1287 goto nuke_pkgdb; 1337 goto nuke_pkgdb;
1288 } 1338 }
1289 1339
1290 if (run_install_script(pkg, "PRE-INSTALL")) 1340 if (run_install_script(pkg, "PRE-INSTALL"))
1291 goto nuke_pkgdb; 1341 goto nuke_pkgdb;
1292 1342
1293 if (extract_files(pkg)) 1343 if (extract_files(pkg))
1294 goto nuke_pkg; 1344 goto nuke_pkg;
1295 1345
1296 if (run_install_script(pkg, "POST-INSTALL")) 1346 if (run_install_script(pkg, "POST-INSTALL"))
1297 goto nuke_pkgdb; 1347 goto nuke_pkgdb;
1298 1348
1299 /* XXX keep +INSTALL_INFO for updates? */ 1349 /* XXX keep +INSTALL_INFO for updates? */
1300 /* XXX keep +PRESERVE for updates? */ 1350 /* XXX keep +PRESERVE for updates? */
1301 if (mark_automatic) 1351 if (mark_automatic)
1302 mark_as_automatic_installed(pkg->pkgname, 1); 1352 mark_as_automatic_installed(pkg->pkgname, 1);
1303 1353
1304 pkg_register_depends(pkg); 1354 pkg_register_depends(pkg);
1305 1355
1306 if (Verbose) 1356 if (Verbose)
1307 printf("Package %s registered in %s\n", pkg->pkgname, pkg->install_logdir); 1357 printf("Package %s registered in %s\n", pkg->pkgname, pkg->install_logdir);
1308 1358
1309 if (pkg->meta_data.meta_display != NULL) 1359 if (pkg->meta_data.meta_display != NULL)
1310 fputs(pkg->meta_data.meta_display, stdout); 1360 fputs(pkg->meta_data.meta_display, stdout);
1311 1361
1312 pkg_register_views(pkg); 1362 pkg_register_views(pkg);
1313 1363
1314 status = 0; 1364 status = 0;
1315 goto clean_memory; 1365 goto clean_memory;
1316 1366
1317nuke_pkg: 1367nuke_pkg:
1318 if (!Fake) { 1368 if (!Fake) {
1319 if (pkg->other_version) { 1369 if (pkg->other_version) {
1320 warnx("Updating of %s to %s failed.", 1370 warnx("Updating of %s to %s failed.",
1321 pkg->other_version, pkg->pkgname); 1371 pkg->other_version, pkg->pkgname);
1322 warnx("Remember to run pkg_admin rebuild-tree after fixing this."); 1372 warnx("Remember to run pkg_admin rebuild-tree after fixing this.");
1323 } 1373 }
1324 delete_package(FALSE, FALSE, &pkg->plist, FALSE, Destdir); 1374 delete_package(FALSE, FALSE, &pkg->plist, FALSE, Destdir);
1325 } 1375 }
1326 1376
1327nuke_pkgdb: 1377nuke_pkgdb:
1328 if (!Fake) { 1378 if (!Fake) {
1329 if (recursive_remove(pkg->install_logdir, 1)) 1379 if (recursive_remove(pkg->install_logdir, 1))
1330 warn("Couldn't remove %s", pkg->install_logdir); 1380 warn("Couldn't remove %s", pkg->install_logdir);
1331 free(pkg->install_logdir); 1381 free(pkg->install_logdir);
1332 free(pkg->logdir); 1382 free(pkg->logdir);
1333 pkg->install_logdir = NULL; 1383 pkg->install_logdir = NULL;
1334 pkg->logdir = NULL; 1384 pkg->logdir = NULL;
1335 } 1385 }
1336 1386
1337clean_memory: 1387clean_memory:
1338 if (pkg->logdir != NULL && NoRecord && !Fake) { 1388 if (pkg->logdir != NULL && NoRecord && !Fake) {
1339 if (recursive_remove(pkg->install_logdir, 1)) 1389 if (recursive_remove(pkg->install_logdir, 1))
1340 warn("Couldn't remove %s", pkg->install_logdir); 1390 warn("Couldn't remove %s", pkg->install_logdir);
1341 } 1391 }
1342 free(pkg->install_prefix); 1392 free(pkg->install_prefix);
1343 free(pkg->install_logdir); 1393 free(pkg->install_logdir);
1344 free(pkg->logdir); 1394 free(pkg->logdir);
1345 free_buildinfo(pkg); 1395 free_buildinfo(pkg);
1346 free_plist(&pkg->plist); 1396 free_plist(&pkg->plist);
1347 free_meta_data(pkg); 1397 free_meta_data(pkg);
1348 if (pkg->archive) { 1398 if (pkg->archive) {
1349 archive_read_close(pkg->archive); 1399 archive_read_close(pkg->archive);
1350 close_archive(archive_cookie); 1400 close_archive(archive_cookie);
1351 } 1401 }
1352 free(pkg->other_version); 1402 free(pkg->other_version);
1353 free(pkg->pkgname); 1403 free(pkg->pkgname);
1354#ifdef HAVE_SSL 1404#ifdef HAVE_SSL
1355 pkg_free_signature(signature_cookie); 1405 pkg_free_signature(signature_cookie);
1356#endif 1406#endif
1357clean_find_archive: 1407clean_find_archive:
1358 free(pkg); 1408 free(pkg);
1359 return status; 1409 return status;
1360} 1410}
1361 1411
1362int 1412int
1363pkg_perform(lpkg_head_t *pkgs) 1413pkg_perform(lpkg_head_t *pkgs)
1364{ 1414{
1365 int oldcwd, errors = 0; 1415 int oldcwd, errors = 0;
1366 lpkg_t *lpp; 1416 lpkg_t *lpp;
1367 1417
1368 if ((oldcwd = open(".", O_RDONLY, 0)) == -1) 1418 if ((oldcwd = open(".", O_RDONLY, 0)) == -1)
1369 err(EXIT_FAILURE, "unable to open cwd"); 1419 err(EXIT_FAILURE, "unable to open cwd");
1370 1420
1371 while ((lpp = TAILQ_FIRST(pkgs)) != NULL) { 1421 while ((lpp = TAILQ_FIRST(pkgs)) != NULL) {
1372 path_prepend_from_pkgname(lpp->lp_name); 1422 path_prepend_from_pkgname(lpp->lp_name);
1373 if (pkg_do(lpp->lp_name, Automatic)) 1423 if (pkg_do(lpp->lp_name, Automatic))
1374 ++errors; 1424 ++errors;
1375 path_prepend_clear(); 1425 path_prepend_clear();
1376 TAILQ_REMOVE(pkgs, lpp, lp_link); 1426 TAILQ_REMOVE(pkgs, lpp, lp_link);
1377 free_lpkg(lpp); 1427 free_lpkg(lpp);
1378 1428
1379 if (fchdir(oldcwd) == -1) 1429 if (fchdir(oldcwd) == -1)
1380 err(EXIT_FAILURE, "unable to restore cwd"); 1430 err(EXIT_FAILURE, "unable to restore cwd");
1381 } 1431 }
1382 1432
1383 close(oldcwd); 1433 close(oldcwd);
1384 1434
1385 return errors; 1435 return errors;
1386} 1436}

cvs diff -r1.42.2.16 -r1.42.2.17 pkgsrc/pkgtools/pkg_install/files/lib/lib.h (switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/lib.h 2008/12/30 15:55:57 1.42.2.16
+++ pkgsrc/pkgtools/pkg_install/files/lib/lib.h 2009/01/08 00:01:31 1.42.2.17
@@ -1,426 +1,427 @@ @@ -1,426 +1,427 @@
1/* $NetBSD: lib.h,v 1.42.2.16 2008/12/30 15:55:57 joerg Exp $ */ 1/* $NetBSD: lib.h,v 1.42.2.17 2009/01/08 00:01:31 joerg Exp $ */
2 2
3/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ 3/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
4 4
5/* 5/*
6 * FreeBSD install - a package for the installation and maintainance 6 * FreeBSD install - a package for the installation and maintainance
7 * of non-core utilities. 7 * of non-core utilities.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 17 *
18 * Jordan K. Hubbard 18 * Jordan K. Hubbard
19 * 18 July 1993 19 * 18 July 1993
20 * 20 *
21 * Include and define various things wanted by the library routines. 21 * Include and define various things wanted by the library routines.
22 * 22 *
23 */ 23 */
24 24
25#ifndef _INST_LIB_LIB_H_ 25#ifndef _INST_LIB_LIB_H_
26#define _INST_LIB_LIB_H_ 26#define _INST_LIB_LIB_H_
27 27
28#if HAVE_CONFIG_H 28#if HAVE_CONFIG_H
29#include "config.h" 29#include "config.h"
30#endif 30#endif
31#include <nbcompat.h> 31#include <nbcompat.h>
32#if HAVE_SYS_PARAM_H 32#if HAVE_SYS_PARAM_H
33#include <sys/param.h> 33#include <sys/param.h>
34#endif 34#endif
35#if HAVE_SYS_STAT_H 35#if HAVE_SYS_STAT_H
36#include <sys/stat.h> 36#include <sys/stat.h>
37#endif 37#endif
38#if HAVE_SYS_FILE_H 38#if HAVE_SYS_FILE_H
39#include <sys/file.h> 39#include <sys/file.h>
40#endif 40#endif
41#if HAVE_SYS_QUEUE_H 41#if HAVE_SYS_QUEUE_H
42#include <sys/queue.h> 42#include <sys/queue.h>
43#endif 43#endif
44 44
45#if HAVE_CTYPE_H 45#if HAVE_CTYPE_H
46#include <ctype.h> 46#include <ctype.h>
47#endif 47#endif
48#if HAVE_DIRENT_H 48#if HAVE_DIRENT_H
49#include <dirent.h> 49#include <dirent.h>
50#endif 50#endif
51#if HAVE_STDIO_H 51#if HAVE_STDIO_H
52#include <stdio.h> 52#include <stdio.h>
53#endif 53#endif
54#if HAVE_STDLIB_H 54#if HAVE_STDLIB_H
55#include <stdlib.h> 55#include <stdlib.h>
56#endif 56#endif
57#if HAVE_STDARG_H 57#if HAVE_STDARG_H
58#include <stdarg.h> 58#include <stdarg.h>
59#endif 59#endif
60#if HAVE_STRING_H 60#if HAVE_STRING_H
61#include <string.h> 61#include <string.h>
62#endif 62#endif
63#if HAVE_UNISTD_H 63#if HAVE_UNISTD_H
64#include <unistd.h> 64#include <unistd.h>
65#endif 65#endif
66 66
67#include "path.h" 67#include "path.h"
68 68
69/* Macros */ 69/* Macros */
70#define SUCCESS (0) 70#define SUCCESS (0)
71#define FAIL (-1) 71#define FAIL (-1)
72 72
73#ifndef TRUE 73#ifndef TRUE
74#define TRUE (1) 74#define TRUE (1)
75#endif 75#endif
76 76
77#ifndef FALSE 77#ifndef FALSE
78#define FALSE (0) 78#define FALSE (0)
79#endif 79#endif
80 80
81#ifndef OPSYS_NAME 81#ifndef OPSYS_NAME
82#define OPSYS_NAME "NetBSD" 82#define OPSYS_NAME "NetBSD"
83#endif 83#endif
84 84
85#ifndef DEF_UMASK 85#ifndef DEF_UMASK
86#define DEF_UMASK 022 86#define DEF_UMASK 022
87#endif 87#endif
88 88
89#ifndef PATH_MAX 89#ifndef PATH_MAX
90# ifdef MAXPATHLEN 90# ifdef MAXPATHLEN
91# define PATH_MAX MAXPATHLEN 91# define PATH_MAX MAXPATHLEN
92# else 92# else
93# define PATH_MAX 1024 93# define PATH_MAX 1024
94# endif 94# endif
95#endif 95#endif
96 96
97enum { 97enum {
98 MaxPathSize = PATH_MAX 98 MaxPathSize = PATH_MAX
99}; 99};
100 100
101/* The names of our "special" files */ 101/* The names of our "special" files */
102#define CONTENTS_FNAME "+CONTENTS" 102#define CONTENTS_FNAME "+CONTENTS"
103#define COMMENT_FNAME "+COMMENT" 103#define COMMENT_FNAME "+COMMENT"
104#define DESC_FNAME "+DESC" 104#define DESC_FNAME "+DESC"
105#define INSTALL_FNAME "+INSTALL" 105#define INSTALL_FNAME "+INSTALL"
106#define DEINSTALL_FNAME "+DEINSTALL" 106#define DEINSTALL_FNAME "+DEINSTALL"
107#define REQUIRED_BY_FNAME "+REQUIRED_BY" 107#define REQUIRED_BY_FNAME "+REQUIRED_BY"
108#define REQUIRED_BY_FNAME_TMP "+REQUIRED_BY.tmp" 108#define REQUIRED_BY_FNAME_TMP "+REQUIRED_BY.tmp"
109#define DISPLAY_FNAME "+DISPLAY" 109#define DISPLAY_FNAME "+DISPLAY"
110#define MTREE_FNAME "+MTREE_DIRS" 110#define MTREE_FNAME "+MTREE_DIRS"
111#define BUILD_VERSION_FNAME "+BUILD_VERSION" 111#define BUILD_VERSION_FNAME "+BUILD_VERSION"
112#define BUILD_INFO_FNAME "+BUILD_INFO" 112#define BUILD_INFO_FNAME "+BUILD_INFO"
113#define INSTALLED_INFO_FNAME "+INSTALLED_INFO" 113#define INSTALLED_INFO_FNAME "+INSTALLED_INFO"
114#define SIZE_PKG_FNAME "+SIZE_PKG" 114#define SIZE_PKG_FNAME "+SIZE_PKG"
115#define SIZE_ALL_FNAME "+SIZE_ALL" 115#define SIZE_ALL_FNAME "+SIZE_ALL"
116#define PRESERVE_FNAME "+PRESERVE" 116#define PRESERVE_FNAME "+PRESERVE"
117#define VIEWS_FNAME "+VIEWS" 117#define VIEWS_FNAME "+VIEWS"
118#define VIEWS_FNAME_TMP "+VIEWS.tmp" 118#define VIEWS_FNAME_TMP "+VIEWS.tmp"
119#define DEPOT_FNAME "+DEPOT" 119#define DEPOT_FNAME "+DEPOT"
120 120
121/* The names of special variables */ 121/* The names of special variables */
122#define AUTOMATIC_VARNAME "automatic" 122#define AUTOMATIC_VARNAME "automatic"
123 123
124/* Prefix for extended PLIST cmd */ 124/* Prefix for extended PLIST cmd */
125#define CMD_CHAR '@'  125#define CMD_CHAR '@'
126 126
127/* The name of the "prefix" environment variable given to scripts */ 127/* The name of the "prefix" environment variable given to scripts */
128#define PKG_PREFIX_VNAME "PKG_PREFIX" 128#define PKG_PREFIX_VNAME "PKG_PREFIX"
129 129
130/* The name of the "destdir" environment variable given to scripts */ 130/* The name of the "destdir" environment variable given to scripts */
131#define PKG_DESTDIR_VNAME "PKG_DESTDIR" 131#define PKG_DESTDIR_VNAME "PKG_DESTDIR"
132 132
133/* 133/*
134 * The name of the "metadatadir" environment variable given to scripts. 134 * The name of the "metadatadir" environment variable given to scripts.
135 * This variable holds the location of the +-files for this package. 135 * This variable holds the location of the +-files for this package.
136 */ 136 */
137#define PKG_METADATA_DIR_VNAME "PKG_METADATA_DIR" 137#define PKG_METADATA_DIR_VNAME "PKG_METADATA_DIR"
138 138
139/* 139/*
140 * The name of the environment variable holding the location to the 140 * The name of the environment variable holding the location to the
141 * reference-counts database directory. 141 * reference-counts database directory.
142 */ 142 */
143#define PKG_REFCOUNT_DBDIR_VNAME "PKG_REFCOUNT_DBDIR" 143#define PKG_REFCOUNT_DBDIR_VNAME "PKG_REFCOUNT_DBDIR"
144 144
145#define PKG_PATTERN_MAX MaxPathSize /* max length of pattern, including nul */ 145#define PKG_PATTERN_MAX MaxPathSize /* max length of pattern, including nul */
146#define PKG_SUFFIX_MAX 10 /* max length of suffix, including nul */ 146#define PKG_SUFFIX_MAX 10 /* max length of suffix, including nul */
147 147
148enum { 148enum {
149 ReadWrite, 149 ReadWrite,
150 ReadOnly 150 ReadOnly
151}; 151};
152 152
153 153
154/* Enumerated constants for plist entry types */ 154/* Enumerated constants for plist entry types */
155typedef enum pl_ent_t { 155typedef enum pl_ent_t {
156 PLIST_SHOW_ALL = -1, 156 PLIST_SHOW_ALL = -1,
157 PLIST_FILE, /* 0 */ 157 PLIST_FILE, /* 0 */
158 PLIST_CWD, /* 1 */ 158 PLIST_CWD, /* 1 */
159 PLIST_CMD, /* 2 */ 159 PLIST_CMD, /* 2 */
160 PLIST_CHMOD, /* 3 */ 160 PLIST_CHMOD, /* 3 */
161 PLIST_CHOWN, /* 4 */ 161 PLIST_CHOWN, /* 4 */
162 PLIST_CHGRP, /* 5 */ 162 PLIST_CHGRP, /* 5 */
163 PLIST_COMMENT, /* 6 */ 163 PLIST_COMMENT, /* 6 */
164 PLIST_IGNORE, /* 7 */ 164 PLIST_IGNORE, /* 7 */
165 PLIST_NAME, /* 8 */ 165 PLIST_NAME, /* 8 */
166 PLIST_UNEXEC, /* 9 */ 166 PLIST_UNEXEC, /* 9 */
167 PLIST_SRC, /* 10 */ 167 PLIST_SRC, /* 10 */
168 PLIST_DISPLAY, /* 11 */ 168 PLIST_DISPLAY, /* 11 */
169 PLIST_PKGDEP, /* 12 */ 169 PLIST_PKGDEP, /* 12 */
170 PLIST_MTREE, /* 13 */ 170 PLIST_MTREE, /* 13 */
171 PLIST_DIR_RM, /* 14 */ 171 PLIST_DIR_RM, /* 14 */
172 PLIST_IGNORE_INST, /* 15 */ 172 PLIST_IGNORE_INST, /* 15 */
173 PLIST_OPTION, /* 16 */ 173 PLIST_OPTION, /* 16 */
174 PLIST_PKGCFL, /* 17 */ 174 PLIST_PKGCFL, /* 17 */
175 PLIST_BLDDEP /* 18 */ 175 PLIST_BLDDEP /* 18 */
176} pl_ent_t; 176} pl_ent_t;
177 177
178/* Enumerated constants for build info */ 178/* Enumerated constants for build info */
179typedef enum bi_ent_t { 179typedef enum bi_ent_t {
180 BI_OPSYS, /* 0 */ 180 BI_OPSYS, /* 0 */
181 BI_OS_VERSION, /* 1 */ 181 BI_OS_VERSION, /* 1 */
182 BI_MACHINE_ARCH, /* 2 */ 182 BI_MACHINE_ARCH, /* 2 */
183 BI_IGNORE_RECOMMENDED, /* 3 */ 183 BI_IGNORE_RECOMMENDED, /* 3 */
184 BI_USE_ABI_DEPENDS, /* 4 */ 184 BI_USE_ABI_DEPENDS, /* 4 */
185 BI_ENUM_COUNT /* 5 */ 185 BI_ENUM_COUNT /* 5 */
186} bi_ent_t; 186} bi_ent_t;
187 187
188/* Types */ 188/* Types */
189typedef unsigned int Boolean; 189typedef unsigned int Boolean;
190 190
191/* This structure describes a packing list entry */ 191/* This structure describes a packing list entry */
192typedef struct plist_t { 192typedef struct plist_t {
193 struct plist_t *prev; /* previous entry */ 193 struct plist_t *prev; /* previous entry */
194 struct plist_t *next; /* next entry */ 194 struct plist_t *next; /* next entry */
195 char *name; /* name of entry */ 195 char *name; /* name of entry */
196 Boolean marked; /* whether entry has been marked */ 196 Boolean marked; /* whether entry has been marked */
197 pl_ent_t type; /* type of entry */ 197 pl_ent_t type; /* type of entry */
198} plist_t; 198} plist_t;
199 199
200/* This structure describes a package's complete packing list */ 200/* This structure describes a package's complete packing list */
201typedef struct package_t { 201typedef struct package_t {
202 plist_t *head; /* head of list */ 202 plist_t *head; /* head of list */
203 plist_t *tail; /* tail of list */ 203 plist_t *tail; /* tail of list */
204} package_t; 204} package_t;
205 205
206#define SYMLINK_HEADER "Symlink:" 206#define SYMLINK_HEADER "Symlink:"
207#define CHECKSUM_HEADER "MD5:" 207#define CHECKSUM_HEADER "MD5:"
208 208
209enum { 209enum {
210 ChecksumHeaderLen = 4, /* strlen(CHECKSUM_HEADER) */ 210 ChecksumHeaderLen = 4, /* strlen(CHECKSUM_HEADER) */
211 SymlinkHeaderLen = 8, /* strlen(SYMLINK_HEADER) */ 211 SymlinkHeaderLen = 8, /* strlen(SYMLINK_HEADER) */
212 ChecksumLen = 16, 212 ChecksumLen = 16,
213 LegibleChecksumLen = 33 213 LegibleChecksumLen = 33
214}; 214};
215 215
216/* List of files */ 216/* List of files */
217typedef struct _lfile_t { 217typedef struct _lfile_t {
218 TAILQ_ENTRY(_lfile_t) lf_link; 218 TAILQ_ENTRY(_lfile_t) lf_link;
219 char *lf_name; 219 char *lf_name;
220} lfile_t; 220} lfile_t;
221TAILQ_HEAD(_lfile_head_t, _lfile_t); 221TAILQ_HEAD(_lfile_head_t, _lfile_t);
222typedef struct _lfile_head_t lfile_head_t; 222typedef struct _lfile_head_t lfile_head_t;
223#define LFILE_ADD(lfhead,lfp,str) do { \ 223#define LFILE_ADD(lfhead,lfp,str) do { \
224 lfp = xmalloc(sizeof(lfile_t)); \ 224 lfp = xmalloc(sizeof(lfile_t)); \
225 lfp->lf_name = str; \ 225 lfp->lf_name = str; \
226 TAILQ_INSERT_TAIL(lfhead,lfp,lf_link); \ 226 TAILQ_INSERT_TAIL(lfhead,lfp,lf_link); \
227 } while(0) 227 } while(0)
228 228
229/* List of packages */ 229/* List of packages */
230typedef struct _lpkg_t { 230typedef struct _lpkg_t {
231 TAILQ_ENTRY(_lpkg_t) lp_link; 231 TAILQ_ENTRY(_lpkg_t) lp_link;
232 char *lp_name; 232 char *lp_name;
233} lpkg_t; 233} lpkg_t;
234TAILQ_HEAD(_lpkg_head_t, _lpkg_t); 234TAILQ_HEAD(_lpkg_head_t, _lpkg_t);
235typedef struct _lpkg_head_t lpkg_head_t; 235typedef struct _lpkg_head_t lpkg_head_t;
236 236
237struct pkg_vulnerabilities { 237struct pkg_vulnerabilities {
238 size_t entries; 238 size_t entries;
239 char **vulnerability; 239 char **vulnerability;
240 char **classification; 240 char **classification;
241 char **advisory; 241 char **advisory;
242}; 242};
243 243
244/* If URLlength()>0, then there is a ftp:// or http:// in the string, 244/* If URLlength()>0, then there is a ftp:// or http:// in the string,
245 * and this must be an URL. Hide this behind a more obvious name. */ 245 * and this must be an URL. Hide this behind a more obvious name. */
246#define IS_URL(str) (URLlength(str) > 0) 246#define IS_URL(str) (URLlength(str) > 0)
247 247
248#define IS_STDIN(str) ((str) != NULL && !strcmp((str), "-")) 248#define IS_STDIN(str) ((str) != NULL && !strcmp((str), "-"))
249#define IS_FULLPATH(str) ((str) != NULL && (str)[0] == '/') 249#define IS_FULLPATH(str) ((str) != NULL && (str)[0] == '/')
250 250
251/* Conflict handling (conflicts.c) */ 251/* Conflict handling (conflicts.c) */
252int some_installed_package_conflicts_with(const char *, const char *, char **, char **); 252int some_installed_package_conflicts_with(const char *, const char *, char **, char **);
253 253
254 254
255/* Prototypes */ 255/* Prototypes */
256/* Misc */ 256/* Misc */
257void cleanup(int); 257void cleanup(int);
258void show_version(void); 258void show_version(void);
259int fexec(const char *, ...); 259int fexec(const char *, ...);
260int fexec_skipempty(const char *, ...); 260int fexec_skipempty(const char *, ...);
261int fcexec(const char *, const char *, ...); 261int fcexec(const char *, const char *, ...);
262int pfcexec(const char *, const char *, const char **); 262int pfcexec(const char *, const char *, const char **);
263 263
264/* variables file handling */ 264/* variables file handling */
265 265
266char *var_get(const char *, const char *); 266char *var_get(const char *, const char *);
267char *var_get_memory(const char *, const char *); 267char *var_get_memory(const char *, const char *);
268int var_set(const char *, const char *, const char *); 268int var_set(const char *, const char *, const char *);
269int var_copy_list(const char *, const char **); 269int var_copy_list(const char *, const char **);
270 270
271/* automatically installed as dependency */ 271/* automatically installed as dependency */
272 272
273Boolean is_automatic_installed(const char *); 273Boolean is_automatic_installed(const char *);
274int mark_as_automatic_installed(const char *, int); 274int mark_as_automatic_installed(const char *, int);
275 275
276/* String */ 276/* String */
277const char *basename_of(const char *); 277const char *basename_of(const char *);
278const char *dirname_of(const char *); 278const char *dirname_of(const char *);
279const char *suffix_of(const char *); 279const char *suffix_of(const char *);
280int pkg_match(const char *, const char *); 280int pkg_match(const char *, const char *);
281int pkg_order(const char *, const char *, const char *); 281int pkg_order(const char *, const char *, const char *);
282int ispkgpattern(const char *); 282int ispkgpattern(const char *);
283int quick_pkg_match(const char *, const char *); 283int quick_pkg_match(const char *, const char *);
284 284
285/* Iterator functions */ 285/* Iterator functions */
286int iterate_pkg_generic_src(int (*)(const char *, void *), void *, 286int iterate_pkg_generic_src(int (*)(const char *, void *), void *,
287 const char *(*)(void *),void *); 287 const char *(*)(void *),void *);
288int iterate_local_pkg_dir(const char *, int, int, int (*)(const char *, void *), 288int iterate_local_pkg_dir(const char *, int, int, int (*)(const char *, void *),
289 void *); 289 void *);
290int iterate_pkg_db(int (*)(const char *, void *), void *); 290int iterate_pkg_db(int (*)(const char *, void *), void *);
291 291
292int add_installed_pkgs_by_basename(const char *, lpkg_head_t *); 292int add_installed_pkgs_by_basename(const char *, lpkg_head_t *);
293int add_installed_pkgs_by_pattern(const char *, lpkg_head_t *); 293int add_installed_pkgs_by_pattern(const char *, lpkg_head_t *);
294char *find_best_matching_installed_pkg(const char *); 294char *find_best_matching_installed_pkg(const char *);
295char *find_best_matching_file(const char *, const char *, int, int); 295char *find_best_matching_file(const char *, const char *, int, int);
296int match_installed_pkgs(const char *, int (*)(const char *, void *), void *); 296int match_installed_pkgs(const char *, int (*)(const char *, void *), void *);
297int match_local_files(const char *, int, int, const char *, int (*cb)(const char *, void *), void *); 297int match_local_files(const char *, int, int, const char *, int (*cb)(const char *, void *), void *);
298 298
299/* File */ 299/* File */
300Boolean fexists(const char *); 300Boolean fexists(const char *);
301Boolean isdir(const char *); 301Boolean isdir(const char *);
302Boolean islinktodir(const char *); 302Boolean islinktodir(const char *);
303Boolean isemptydir(const char *); 303Boolean isemptydir(const char *);
304Boolean isemptyfile(const char *); 304Boolean isemptyfile(const char *);
305Boolean isfile(const char *); 305Boolean isfile(const char *);
306Boolean isbrokenlink(const char *); 306Boolean isbrokenlink(const char *);
307Boolean isempty(const char *); 307Boolean isempty(const char *);
308int URLlength(const char *); 308int URLlength(const char *);
309Boolean make_preserve_name(char *, size_t, char *, char *); 309Boolean make_preserve_name(char *, size_t, char *, char *);
310void remove_files(const char *, const char *); 310void remove_files(const char *, const char *);
311int delete_hierarchy(char *, Boolean, Boolean); 311int delete_hierarchy(char *, Boolean, Boolean);
312int format_cmd(char *, size_t, const char *, const char *, const char *); 312int format_cmd(char *, size_t, const char *, const char *, const char *);
313 313
314int recursive_remove(const char *, int); 314int recursive_remove(const char *, int);
315 315
316/* pkg_io.c: Local and remote archive handling */ 316/* pkg_io.c: Local and remote archive handling */
317struct archive; 317struct archive;
318struct archive_entry; 318struct archive_entry;
319 319
320struct archive *open_archive(const char *, void **); 320struct archive *open_archive(const char *, void **);
321void close_archive(void *); 321void close_archive(void *);
322struct archive *find_archive(const char *, void **); 322struct archive *find_archive(const char *, void **);
323 323
324/* Packing list */ 324/* Packing list */
325plist_t *new_plist_entry(void); 325plist_t *new_plist_entry(void);
326plist_t *last_plist(package_t *); 326plist_t *last_plist(package_t *);
327plist_t *find_plist(package_t *, pl_ent_t); 327plist_t *find_plist(package_t *, pl_ent_t);
328char *find_plist_option(package_t *, char *); 328char *find_plist_option(package_t *, char *);
329void plist_delete(package_t *, Boolean, pl_ent_t, char *); 329void plist_delete(package_t *, Boolean, pl_ent_t, char *);
330void free_plist(package_t *); 330void free_plist(package_t *);
331void mark_plist(package_t *); 331void mark_plist(package_t *);
332void csum_plist_entry(char *, plist_t *); 332void csum_plist_entry(char *, plist_t *);
333void add_plist(package_t *, pl_ent_t, const char *); 333void add_plist(package_t *, pl_ent_t, const char *);
334void add_plist_top(package_t *, pl_ent_t, const char *); 334void add_plist_top(package_t *, pl_ent_t, const char *);
335void delete_plist(package_t *, Boolean, pl_ent_t, char *); 335void delete_plist(package_t *, Boolean, pl_ent_t, char *);
336void write_plist(package_t *, FILE *, char *); 336void write_plist(package_t *, FILE *, char *);
337void stringify_plist(package_t *, char **, size_t *, const char *); 337void stringify_plist(package_t *, char **, size_t *, const char *);
338void parse_plist(package_t *, const char *); 338void parse_plist(package_t *, const char *);
339void read_plist(package_t *, FILE *); 339void read_plist(package_t *, FILE *);
340void append_plist(package_t *, FILE *); 340void append_plist(package_t *, FILE *);
341int delete_package(Boolean, Boolean, package_t *, Boolean, const char *); 341int delete_package(Boolean, Boolean, package_t *, Boolean, const char *);
342 342
343/* Package Database */ 343/* Package Database */
344int pkgdb_open(int); 344int pkgdb_open(int);
345void pkgdb_close(void); 345void pkgdb_close(void);
346int pkgdb_store(const char *, const char *); 346int pkgdb_store(const char *, const char *);
347char *pkgdb_retrieve(const char *); 347char *pkgdb_retrieve(const char *);
348int pkgdb_dump(void); 348int pkgdb_dump(void);
349int pkgdb_remove(const char *); 349int pkgdb_remove(const char *);
350int pkgdb_remove_pkg(const char *); 350int pkgdb_remove_pkg(const char *);
351char *pkgdb_refcount_dir(void); 351char *pkgdb_refcount_dir(void);
352char *_pkgdb_getPKGDB_FILE(char *, unsigned); 352char *_pkgdb_getPKGDB_FILE(char *, unsigned);
353const char *_pkgdb_getPKGDB_DIR(void); 353const char *_pkgdb_getPKGDB_DIR(void);
354void _pkgdb_setPKGDB_DIR(const char *); 354void _pkgdb_setPKGDB_DIR(const char *);
355 355
356char *pkgdb_pkg_file(const char *, const char *); 356char *pkgdb_pkg_file(const char *, const char *);
357 357
358/* List of packages functions */ 358/* List of packages functions */
359lpkg_t *alloc_lpkg(const char *); 359lpkg_t *alloc_lpkg(const char *);
360lpkg_t *find_on_queue(lpkg_head_t *, const char *); 360lpkg_t *find_on_queue(lpkg_head_t *, const char *);
361void free_lpkg(lpkg_t *); 361void free_lpkg(lpkg_t *);
362 362
363/* Extract input if compressed to NUL terminated buffer (not counted) */ 363/* Extract input if compressed to NUL terminated buffer (not counted) */
364int decompress_buffer(const char *, size_t, char **, size_t *); 364int decompress_buffer(const char *, size_t, char **, size_t *);
365 365
366/* Parse NUL terminated inputed, argument is strlen of the input */ 366/* Parse NUL terminated inputed, argument is strlen of the input */
367struct pkg_vulnerabilities *parse_pkg_vulnerabilities(const char *, size_t, int); 367struct pkg_vulnerabilities *parse_pkg_vulnerabilities(const char *, size_t, int);
368/* Read pkg_vulnerabilities from file */ 368/* Read pkg_vulnerabilities from file */
369struct pkg_vulnerabilities *read_pkg_vulnerabilities(const char *, int, int); 369struct pkg_vulnerabilities *read_pkg_vulnerabilities(const char *, int, int);
370void free_pkg_vulnerabilities(struct pkg_vulnerabilities *); 370void free_pkg_vulnerabilities(struct pkg_vulnerabilities *);
371 371
372/* Parse configuration file */ 372/* Parse configuration file */
373void pkg_install_config(void); 373void pkg_install_config(void);
374/* Print configuration variable */ 374/* Print configuration variable */
375void pkg_install_show_variable(const char *); 375void pkg_install_show_variable(const char *);
376 376
377#ifdef HAVE_SSL 377#ifdef HAVE_SSL
378/* Package signature creation and validation */ 378/* Package signature creation and validation */
379int pkg_verify_signature(struct archive **, struct archive_entry **, char **, 379int pkg_verify_signature(struct archive **, struct archive_entry **, char **,
380 void **); 380 void **);
381int pkg_full_signature_check(struct archive *); 381int pkg_full_signature_check(struct archive *);
382void pkg_free_signature(void *); 382void pkg_free_signature(void *);
383void pkg_sign_x509(const char *, const char *, const char *, const char *); 383void pkg_sign_x509(const char *, const char *, const char *, const char *);
384#endif 384#endif
385 385
386void pkg_sign_gpg(const char *, const char *); 386void pkg_sign_gpg(const char *, const char *);
387 387
388#ifdef HAVE_SSL 388#ifdef HAVE_SSL
389/* PKCS7 signing/verification */ 389/* PKCS7 signing/verification */
390int easy_pkcs7_verify(const char *, size_t, const char *, size_t, 390int easy_pkcs7_verify(const char *, size_t, const char *, size_t,
391 const char *, int); 391 const char *, int);
392int easy_pkcs7_sign(const char *, size_t, char **, size_t *, const char *, 392int easy_pkcs7_sign(const char *, size_t, char **, size_t *, const char *,
393 const char *); 393 const char *);
394#endif 394#endif
395 395
396int inline_gpg_verify(const char *, size_t); 396int inline_gpg_verify(const char *, size_t);
397int detached_gpg_verify(const char *, size_t, const char *, size_t, 397int detached_gpg_verify(const char *, size_t, const char *, size_t,
398 const char *); 398 const char *);
399int detached_gpg_sign(const char *, size_t, char **, size_t *, const char *, 399int detached_gpg_sign(const char *, size_t, char **, size_t *, const char *,
400 const char *); 400 const char *);
401 401
402char *xstrdup(const char *); 402char *xstrdup(const char *);
403void *xrealloc(void *, size_t); 403void *xrealloc(void *, size_t);
404void *xcalloc(size_t, size_t); 404void *xcalloc(size_t, size_t);
405void *xmalloc(size_t); 405void *xmalloc(size_t);
406char *xasprintf(const char *, ...); 406char *xasprintf(const char *, ...);
407 407
408/* Externs */ 408/* Externs */
409extern Boolean Verbose; 409extern Boolean Verbose;
410extern Boolean Fake; 410extern Boolean Fake;
411extern Boolean Force; 411extern Boolean Force;
412extern const char *cert_chain_file; 412extern const char *cert_chain_file;
413extern const char *certs_packages; 413extern const char *certs_packages;
414extern const char *certs_pkg_vulnerabilities; 414extern const char *certs_pkg_vulnerabilities;
 415extern const char *check_vulnerabilities;
415extern const char *config_file; 416extern const char *config_file;
416extern const char *verified_installation; 417extern const char *verified_installation;
417extern const char *gpg_cmd; 418extern const char *gpg_cmd;
418extern char fetch_flags[]; 419extern char fetch_flags[];
419 420
420extern const char *pkg_vulnerabilities_dir; 421extern const char *pkg_vulnerabilities_dir;
421extern const char *pkg_vulnerabilities_file; 422extern const char *pkg_vulnerabilities_file;
422extern const char *pkg_vulnerabilities_url; 423extern const char *pkg_vulnerabilities_url;
423extern const char *ignore_advisories; 424extern const char *ignore_advisories;
424extern const char tnf_vulnerability_base[]; 425extern const char tnf_vulnerability_base[];
425 426
426#endif /* _INST_LIB_LIB_H_ */ 427#endif /* _INST_LIB_LIB_H_ */

cvs diff -r1.1.2.5 -r1.1.2.6 pkgsrc/pkgtools/pkg_install/files/lib/parse-config.c (switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/parse-config.c 2008/08/21 16:04:39 1.1.2.5
+++ pkgsrc/pkgtools/pkg_install/files/lib/parse-config.c 2009/01/08 00:01:31 1.1.2.6
@@ -1,128 +1,133 @@ @@ -1,128 +1,133 @@
1/* $NetBSD: parse-config.c,v 1.1.2.5 2008/08/21 16:04:39 joerg Exp $ */ 1/* $NetBSD: parse-config.c,v 1.1.2.6 2009/01/08 00:01:31 joerg Exp $ */
2 2
3#if HAVE_CONFIG_H 3#if HAVE_CONFIG_H
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6#include <nbcompat.h> 6#include <nbcompat.h>
7#if HAVE_SYS_CDEFS_H 7#if HAVE_SYS_CDEFS_H
8#include <sys/cdefs.h> 8#include <sys/cdefs.h>
9#endif 9#endif
10#ifndef lint 10#ifndef lint
11__RCSID("$NetBSD: parse-config.c,v 1.1.2.5 2008/08/21 16:04:39 joerg Exp $"); 11__RCSID("$NetBSD: parse-config.c,v 1.1.2.6 2009/01/08 00:01:31 joerg Exp $");
12#endif 12#endif
13 13
14/*- 14/*-
15 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>. 15 * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>.
16 * All rights reserved. 16 * All rights reserved.
17 * 17 *
18 * Redistribution and use in source and binary forms, with or without 18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions 19 * modification, are permitted provided that the following conditions
20 * are met: 20 * are met:
21 * 21 *
22 * 1. Redistributions of source code must retain the above copyright 22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer. 23 * notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright 24 * 2. Redistributions in binary form must reproduce the above copyright
25 * notice, this list of conditions and the following disclaimer in 25 * notice, this list of conditions and the following disclaimer in
26 * the documentation and/or other materials provided with the 26 * the documentation and/or other materials provided with the
27 * distribution. 27 * distribution.
28 * 28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 32 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 33 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 34 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 36 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
37 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 37 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE. 40 * SUCH DAMAGE.
41 */ 41 */
42 42
43#if HAVE_ERR_H 43#if HAVE_ERR_H
44#include <err.h> 44#include <err.h>
45#endif 45#endif
46#if HAVE_STRING_H 46#if HAVE_STRING_H
47#include <string.h> 47#include <string.h>
48#endif 48#endif
49 49
50#include "lib.h" 50#include "lib.h"
51 51
52const char *config_file = SYSCONFDIR"/pkg_install.conf"; 52const char *config_file = SYSCONFDIR"/pkg_install.conf";
53 53
54char fetch_flags[10]; 54char fetch_flags[10];
55static const char *active_ftp; 55static const char *active_ftp;
56static const char *verbose_netio; 56static const char *verbose_netio;
57static const char *ignore_proxy; 57static const char *ignore_proxy;
58const char *cert_chain_file; 58const char *cert_chain_file;
59const char *certs_packages; 59const char *certs_packages;
60const char *certs_pkg_vulnerabilities; 60const char *certs_pkg_vulnerabilities;
 61const char *check_vulnerabilities;
61const char *verified_installation; 62const char *verified_installation;
62const char *gpg_cmd; 63const char *gpg_cmd;
63const char *pkg_vulnerabilities_dir; 64const char *pkg_vulnerabilities_dir;
64const char *pkg_vulnerabilities_file; 65const char *pkg_vulnerabilities_file;
65const char *pkg_vulnerabilities_url; 66const char *pkg_vulnerabilities_url;
66const char *ignore_advisories = NULL; 67const char *ignore_advisories = NULL;
67 68
68const char tnf_vulnerability_base[] = "ftp://ftp.NetBSD.org/pub/NetBSD/packages/vulns"; 69const char tnf_vulnerability_base[] = "ftp://ftp.NetBSD.org/pub/NetBSD/packages/vulns";
69 70
70static struct config_variable { 71static struct config_variable {
71 const char *name; 72 const char *name;
72 const char **var; 73 const char **var;
73} config_variables[] = { 74} config_variables[] = {
74 { "ACTIVE_FTP", &active_ftp }, 75 { "ACTIVE_FTP", &active_ftp },
75 { "CERTIFICATE_ANCHOR_PKGS", &certs_packages }, 76 { "CERTIFICATE_ANCHOR_PKGS", &certs_packages },
76 { "CERTIFICATE_ANCHOR_PKGVULN", &certs_pkg_vulnerabilities }, 77 { "CERTIFICATE_ANCHOR_PKGVULN", &certs_pkg_vulnerabilities },
77 { "CERTIFICATE_CHAIN", &cert_chain_file }, 78 { "CERTIFICATE_CHAIN", &cert_chain_file },
 79 { "CHECK_VULNERABILITIES", &check_vulnerabilities },
78 { "GPG", &gpg_cmd }, 80 { "GPG", &gpg_cmd },
79 { "IGNORE_PROXY", &ignore_proxy }, 81 { "IGNORE_PROXY", &ignore_proxy },
80 { "IGNORE_URL", &ignore_advisories }, 82 { "IGNORE_URL", &ignore_advisories },
81 { "PKGVULNDIR", &pkg_vulnerabilities_dir }, 83 { "PKGVULNDIR", &pkg_vulnerabilities_dir },
82 { "PKGVULNURL", &pkg_vulnerabilities_url }, 84 { "PKGVULNURL", &pkg_vulnerabilities_url },
83 { "VERBOSE_NETIO", &verbose_netio }, 85 { "VERBOSE_NETIO", &verbose_netio },
84 { "VERIFIED_INSTALLATION", &verified_installation }, 86 { "VERIFIED_INSTALLATION", &verified_installation },
85 { NULL, NULL } 87 { NULL, NULL }
86}; 88};
87 89
88void 90void
89pkg_install_config(void) 91pkg_install_config(void)
90{ 92{
91 char *value; 93 char *value;
92 struct config_variable *var; 94 struct config_variable *var;
93 95
94 for (var = config_variables; var->name != NULL; ++var) { 96 for (var = config_variables; var->name != NULL; ++var) {
95 value = var_get(config_file, var->name); 97 value = var_get(config_file, var->name);
96 if (value != NULL) 98 if (value != NULL)
97 *var->var = value; 99 *var->var = value;
98 } 100 }
99 101
100 if (pkg_vulnerabilities_dir == NULL) 102 if (pkg_vulnerabilities_dir == NULL)
101 pkg_vulnerabilities_dir = _pkgdb_getPKGDB_DIR(); 103 pkg_vulnerabilities_dir = _pkgdb_getPKGDB_DIR();
102 pkg_vulnerabilities_file = xasprintf("%s/pkg-vulnerabilities", 104 pkg_vulnerabilities_file = xasprintf("%s/pkg-vulnerabilities",
103 pkg_vulnerabilities_dir); 105 pkg_vulnerabilities_dir);
104 if (pkg_vulnerabilities_url == NULL) { 106 if (pkg_vulnerabilities_url == NULL) {
105 pkg_vulnerabilities_url = xasprintf("%s/pkg-vulnerabilities.gz", 107 pkg_vulnerabilities_url = xasprintf("%s/pkg-vulnerabilities.gz",
106 tnf_vulnerability_base); 108 tnf_vulnerability_base);
107 } 109 }
108 if (verified_installation == NULL) 110 if (verified_installation == NULL)
109 verified_installation = "never"; 111 verified_installation = "never";
110 112
 113 if (check_vulnerabilities == NULL)
 114 check_vulnerabilities = "never";
 115
111 snprintf(fetch_flags, sizeof(fetch_flags), "%s%s%s", 116 snprintf(fetch_flags, sizeof(fetch_flags), "%s%s%s",
112 (verbose_netio && *verbose_netio) ? "v" : "", 117 (verbose_netio && *verbose_netio) ? "v" : "",
113 (active_ftp && *active_ftp) ? "" : "p", 118 (active_ftp && *active_ftp) ? "" : "p",
114 (ignore_proxy && *ignore_proxy) ? "d" : ""); 119 (ignore_proxy && *ignore_proxy) ? "d" : "");
115} 120}
116 121
117void 122void
118pkg_install_show_variable(const char *var_name) 123pkg_install_show_variable(const char *var_name)
119{ 124{
120 struct config_variable *var; 125 struct config_variable *var;
121 126
122 for (var = config_variables; var->name != NULL; ++var) { 127 for (var = config_variables; var->name != NULL; ++var) {
123 if (strcmp(var->name, var_name) != 0) 128 if (strcmp(var->name, var_name) != 0)
124 continue; 129 continue;
125 if (*var->var != NULL) 130 if (*var->var != NULL)
126 puts(*var->var); 131 puts(*var->var);
127 } 132 }
128} 133}

cvs diff -r1.1.2.3 -r1.1.2.4 pkgsrc/pkgtools/pkg_install/files/lib/Attic/pkg_install.conf.5 (switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/Attic/pkg_install.conf.5 2008/08/21 16:10:01 1.1.2.3
+++ pkgsrc/pkgtools/pkg_install/files/lib/Attic/pkg_install.conf.5 2009/01/08 00:01:31 1.1.2.4
@@ -1,137 +1,149 @@ @@ -1,137 +1,149 @@
1.\" $NetBSD: pkg_install.conf.5,v 1.1.2.3 2008/08/21 16:10:01 joerg Exp $ 1.\" $NetBSD: pkg_install.conf.5,v 1.1.2.4 2009/01/08 00:01:31 joerg Exp $
2.\" 2.\"
3.\" Copyright (c) 2008 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation 6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Thomas Klausner. 7.\" by Thomas Klausner.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the 15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution. 16.\" documentation and/or other materials provided with the distribution.
17.\" 17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE. 28.\" POSSIBILITY OF SUCH DAMAGE.
29.\" 29.\"
30.Dd August 21, 2008 30.Dd January 8, 2009
31.Dt PKG_INSTALL.CONF 5 31.Dt PKG_INSTALL.CONF 5
32.Os 32.Os
33.Sh NAME 33.Sh NAME
34.Nm pkg_install.conf 34.Nm pkg_install.conf
35.Nd configuration file for package installation tools 35.Nd configuration file for package installation tools
36.Sh DESCRIPTION 36.Sh DESCRIPTION
37The file 37The file
38.Nm 38.Nm
39contains system defaults for the package installation tools 39contains system defaults for the package installation tools
40as a list of variable-value pairs. 40as a list of variable-value pairs.
41Each line has the format 41Each line has the format
42.Ev VARIABLE=VALUE . 42.Ev VARIABLE=VALUE .
43If the value consists of more than one line, each line is prefixed with 43If the value consists of more than one line, each line is prefixed with
44.Ev VARIABLE= . 44.Ev VARIABLE= .
45.Pp 45.Pp
46The current value of a variable can be checked by running 46The current value of a variable can be checked by running
47.Dl Ic pkg_admin config-var VARIABLE 47.Dl Ic pkg_admin config-var VARIABLE
48.Pp 48.Pp
49The following variables are supported: 49The following variables are supported:
50.Bl -tag -width indent 50.Bl -tag -width indent
51.It Dv ACTIVE_FTP 51.It Dv ACTIVE_FTP
52Force the use of active FTP. 52Force the use of active FTP.
53.It Dv CERTIFICATE_ANCHOR_PKGS 53.It Dv CERTIFICATE_ANCHOR_PKGS
54Path to the file containing the certificates used for validating 54Path to the file containing the certificates used for validating
55binary packages. 55binary packages.
56A package is trusted when a certificate chain ends in one of the 56A package is trusted when a certificate chain ends in one of the
57certificates contained in this file. 57certificates contained in this file.
58The certificates must be PEM-encoded. 58The certificates must be PEM-encoded.
59.It Dv CERTIFICATE_ANCHOR_PKGVULN 59.It Dv CERTIFICATE_ANCHOR_PKGVULN
60Analogous to 60Analogous to
61.Dv CERTIFICATE_ANCHOR_PKGS . 61.Dv CERTIFICATE_ANCHOR_PKGS .
62The 62The
63.Pa pkg-vulnerabilities 63.Pa pkg-vulnerabilities
64is trusted when a certificate chain ends in one of the certificates 64is trusted when a certificate chain ends in one of the certificates
65contained in this file. 65contained in this file.
66.It Dv CERTIFICATE_CHAIN 66.It Dv CERTIFICATE_CHAIN
67Path to a file containing additional certificates that can be used 67Path to a file containing additional certificates that can be used
68for completing certicate chains when validating binary packages or 68for completing certicate chains when validating binary packages or
69pkg-vulnerabilities files. 69pkg-vulnerabilities files.
 70.Dv CHECK_VULNERABILITIES
 71Check for vulnerabilities when installating packages.
 72Supported values are:
 73.Bl -tag -width interactiveXX
 74.It Dv never
 75No check is performed.
 76.It Dv always
 77Passing the vulnerability check is required.
 78A missing pkg-vulnerabilities file is considered an error.
 79.It Dv interactive
 80The user is always asked to confirm installation of vulnerable packages.
 81.El
70.It Dv GPG 82.It Dv GPG
71Deprecated. 83Deprecated.
72Path to 84Path to
73.Xr gpg 1 , 85.Xr gpg 1 ,
74which can be used to verify the signature in the 86which can be used to verify the signature in the
75.Pa pkg-vulnerabilities 87.Pa pkg-vulnerabilities
76file when running 88file when running
77.Dl Ic pkg_admin check-pkg-vulnerabilities -s 89.Dl Ic pkg_admin check-pkg-vulnerabilities -s
78or 90or
79.Dl Ic pkg_admin fetch-pkg-vulnerabilities -s 91.Dl Ic pkg_admin fetch-pkg-vulnerabilities -s
80.It Dv IGNORE_PROXY 92.It Dv IGNORE_PROXY
81Use direct connections and ignore 93Use direct connections and ignore
82.Ev FTP_PROXY 94.Ev FTP_PROXY
83and  95and
84.Ev HTTP_PROXY . 96.Ev HTTP_PROXY .
85.It Dv IGNORE_URL 97.It Dv IGNORE_URL
86One line per advisory which should be ignored when running 98One line per advisory which should be ignored when running
87.Dl Ic pkg_admin audit 99.Dl Ic pkg_admin audit
88The URL from the 100The URL from the
89.Pa pkg-vulnerabilities 101.Pa pkg-vulnerabilities
90file should be used as value. 102file should be used as value.
91.It Dv PKGVULNDIR 103.It Dv PKGVULNDIR
92Directory name in which the 104Directory name in which the
93.Pa pkg-vulnerabilities 105.Pa pkg-vulnerabilities
94file resides. 106file resides.
95Default is 107Default is
96.Pa ${PKG_DBDIR} . 108.Pa ${PKG_DBDIR} .
97.It Dv PKGVULNURL 109.It Dv PKGVULNURL
98URL which is used for updating the local 110URL which is used for updating the local
99.Pa pkg-vulnerabilities 111.Pa pkg-vulnerabilities
100file when running 112file when running
101.Dl Ic pkg_admin fetch-pkg-vulnerabilities 113.Dl Ic pkg_admin fetch-pkg-vulnerabilities
102The default is 114The default is
103.Pa ftp://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities.gz 115.Pa ftp://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities.gz
104.Em Note : 116.Em Note :
105Usually, only the compression type should be changed. 117Usually, only the compression type should be changed.
106Currently supported are uncompressed files and files compressed by 118Currently supported are uncompressed files and files compressed by
107.Xr bzip2 1 119.Xr bzip2 1
108.Pq Pa .bz2 120.Pq Pa .bz2
109or 121or
110.Xr gzip 1 122.Xr gzip 1
111.Pq Pa .gz . 123.Pq Pa .gz .
112.It Dv VERBOSE_NETIO 124.It Dv VERBOSE_NETIO
113Log details of network IO to stderr. 125Log details of network IO to stderr.
114.It Dv VERIFIED_INSTALLATION 126.It Dv VERIFIED_INSTALLATION
115Set trust level used when installation. 127Set trust level used when installation.
116Supported values are: 128Supported values are:
117.Bl -tag -width interactiveXX 129.Bl -tag -width interactiveXX
118.It Dv never 130.It Dv never
119No signature checks are performed. 131No signature checks are performed.
120.It Dv always 132.It Dv always
121A valid signature is required. 133A valid signature is required.
122If the binary package can not be verified, the installation is terminated 134If the binary package can not be verified, the installation is terminated
123.It Dv trusted 135.It Dv trusted
124A valid signature is required. 136A valid signature is required.
125If the binary package can not be verified, the user is asked interactively. 137If the binary package can not be verified, the user is asked interactively.
126.It Dv interactive 138.It Dv interactive
127The user is always asked interactively when installing a package. 139The user is always asked interactively when installing a package.
128.El 140.El
129.El 141.El
130.Sh FILES 142.Sh FILES
131.Bl -tag 143.Bl -tag
132.It Pa @SYSCONFDIR@/pkg_install.conf 144.It Pa @SYSCONFDIR@/pkg_install.conf
133Default location for the file described in this manual page. 145Default location for the file described in this manual page.
134.El 146.El
135.Sh SEE ALSO 147.Sh SEE ALSO
136.Xr pkg_add 1 , 148.Xr pkg_add 1 ,
137.Xr pkg_admin 1 149.Xr pkg_admin 1

cvs diff -r1.1.2.3 -r1.1.2.4 pkgsrc/pkgtools/pkg_install/files/lib/Attic/pkg_install.conf.cat5 (switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/Attic/pkg_install.conf.cat5 2008/08/21 16:10:01 1.1.2.3
+++ pkgsrc/pkgtools/pkg_install/files/lib/Attic/pkg_install.conf.cat5 2009/01/08 00:01:31 1.1.2.4
@@ -1,91 +1,102 @@ @@ -1,91 +1,102 @@
1PKG_INSTALL.CONF(5) NetBSD File Formats Manual PKG_INSTALL.CONF(5) 1PKG_INSTALL.CONF(5) NetBSD File Formats Manual PKG_INSTALL.CONF(5)
2 2
3NNAAMMEE 3NNAAMMEE
4 ppkkgg__iinnssttaallll..ccoonnff -- configuration file for package installation tools 4 ppkkgg__iinnssttaallll..ccoonnff -- configuration file for package installation tools
5 5
6DDEESSCCRRIIPPTTIIOONN 6DDEESSCCRRIIPPTTIIOONN
7 The file ppkkgg__iinnssttaallll..ccoonnff contains system defaults for the package 7 The file ppkkgg__iinnssttaallll..ccoonnff contains system defaults for the package
8 installation tools as a list of variable-value pairs. Each line has the 8 installation tools as a list of variable-value pairs. Each line has the
9 format VARIABLE=VALUE. If the value consists of more than one line, each 9 format VARIABLE=VALUE. If the value consists of more than one line, each
10 line is prefixed with VARIABLE=. 10 line is prefixed with VARIABLE=.
11 11
12 The current value of a variable can be checked by running 12 The current value of a variable can be checked by running
13 ppkkgg__aaddmmiinn ccoonnffiigg--vvaarr VVAARRIIAABBLLEE 13 ppkkgg__aaddmmiinn ccoonnffiigg--vvaarr VVAARRIIAABBLLEE
14 14
15 The following variables are supported: 15 The following variables are supported:
16 16
17 ACTIVE_FTP 17 ACTIVE_FTP
18 Force the use of active FTP. 18 Force the use of active FTP.
19 19
20 CERTIFICATE_ANCHOR_PKGS 20 CERTIFICATE_ANCHOR_PKGS
21 Path to the file containing the certificates used for validating 21 Path to the file containing the certificates used for validating
22 binary packages. A package is trusted when a certificate chain 22 binary packages. A package is trusted when a certificate chain
23 ends in one of the certificates contained in this file. The cer- 23 ends in one of the certificates contained in this file. The cer-
24 tificates must be PEM-encoded. 24 tificates must be PEM-encoded.
25 25
26 CERTIFICATE_ANCHOR_PKGVULN 26 CERTIFICATE_ANCHOR_PKGVULN
27 Analogous to CERTIFICATE_ANCHOR_PKGS. The _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s is 27 Analogous to CERTIFICATE_ANCHOR_PKGS. The _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s is
28 trusted when a certificate chain ends in one of the certificates 28 trusted when a certificate chain ends in one of the certificates
29 contained in this file. 29 contained in this file.
30 30
31 CERTIFICATE_CHAIN 31 CERTIFICATE_CHAIN
32 Path to a file containing additional certificates that can be 32 Path to a file containing additional certificates that can be
33 used for completing certicate chains when validating binary pack- 33 used for completing certicate chains when validating binary pack-
34 ages or pkg-vulnerabilities files. 34 ages or pkg-vulnerabilities files. CHECK_VULNERABILITIES Check
 35 for vulnerabilities when installating packages. Supported values
 36 are:
 37
 38 never No check is performed.
 39
 40 always Passing the vulnerability check is required. A
 41 missing pkg-vulnerabilities file is considered an
 42 error.
 43
 44 interactive The user is always asked to confirm installation
 45 of vulnerable packages.
35 46
36 GPG Deprecated. Path to gpg(1), which can be used to verify the sig- 47 GPG Deprecated. Path to gpg(1), which can be used to verify the sig-
37 nature in the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file when running 48 nature in the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file when running
38 ppkkgg__aaddmmiinn cchheecckk--ppkkgg--vvuullnneerraabbiilliittiieess --ss 49 ppkkgg__aaddmmiinn cchheecckk--ppkkgg--vvuullnneerraabbiilliittiieess --ss
39 or 50 or
40 ppkkgg__aaddmmiinn ffeettcchh--ppkkgg--vvuullnneerraabbiilliittiieess --ss 51 ppkkgg__aaddmmiinn ffeettcchh--ppkkgg--vvuullnneerraabbiilliittiieess --ss
41 52
42 IGNORE_PROXY 53 IGNORE_PROXY
43 Use direct connections and ignore FTP_PROXY and HTTP_PROXY. 54 Use direct connections and ignore FTP_PROXY and HTTP_PROXY.
44 55
45 IGNORE_URL 56 IGNORE_URL
46 One line per advisory which should be ignored when running 57 One line per advisory which should be ignored when running
47 ppkkgg__aaddmmiinn aauuddiitt 58 ppkkgg__aaddmmiinn aauuddiitt
48 The URL from the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file should be used as 59 The URL from the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file should be used as
49 value. 60 value.
50 61
51 PKGVULNDIR 62 PKGVULNDIR
52 Directory name in which the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file resides. 63 Directory name in which the _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file resides.
53 Default is _$_{_P_K_G___D_B_D_I_R_}. 64 Default is _$_{_P_K_G___D_B_D_I_R_}.
54 65
55 PKGVULNURL 66 PKGVULNURL
56 URL which is used for updating the local _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file 67 URL which is used for updating the local _p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s file
57 when running 68 when running
58 ppkkgg__aaddmmiinn ffeettcchh--ppkkgg--vvuullnneerraabbiilliittiieess 69 ppkkgg__aaddmmiinn ffeettcchh--ppkkgg--vvuullnneerraabbiilliittiieess
59 The default is 70 The default is
60 _f_t_p_:_/_/_f_t_p_._N_e_t_B_S_D_._o_r_g_/_p_u_b_/_N_e_t_B_S_D_/_p_a_c_k_a_g_e_s_/_v_u_l_n_s_/_p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s_._g_z 71 _f_t_p_:_/_/_f_t_p_._N_e_t_B_S_D_._o_r_g_/_p_u_b_/_N_e_t_B_S_D_/_p_a_c_k_a_g_e_s_/_v_u_l_n_s_/_p_k_g_-_v_u_l_n_e_r_a_b_i_l_i_t_i_e_s_._g_z
61 _N_o_t_e: Usually, only the compression type should be changed. Cur- 72 _N_o_t_e: Usually, only the compression type should be changed. Cur-
62 rently supported are uncompressed files and files compressed by 73 rently supported are uncompressed files and files compressed by
63 bzip2(1) (_._b_z_2) or gzip(1) (_._g_z). 74 bzip2(1) (_._b_z_2) or gzip(1) (_._g_z).
64 75
65 VERBOSE_NETIO 76 VERBOSE_NETIO
66 Log details of network IO to stderr. 77 Log details of network IO to stderr.
67 78
68 VERIFIED_INSTALLATION 79 VERIFIED_INSTALLATION
69 Set trust level used when installation. Supported values are: 80 Set trust level used when installation. Supported values are:
70 81
71 never No signature checks are performed. 82 never No signature checks are performed.
72 83
73 always A valid signature is required. If the binary 84 always A valid signature is required. If the binary
74 package can not be verified, the installation is 85 package can not be verified, the installation is
75 terminated 86 terminated
76 87
77 trusted A valid signature is required. If the binary 88 trusted A valid signature is required. If the binary
78 package can not be verified, the user is asked 89 package can not be verified, the user is asked
79 interactively. 90 interactively.
80 91
81 interactive The user is always asked interactively when 92 interactive The user is always asked interactively when
82 installing a package. 93 installing a package.
83 94
84FFIILLEESS 95FFIILLEESS
85 @SYSCONFDIR@/pkg_install.conf Default location for the file described 96 @SYSCONFDIR@/pkg_install.conf Default location for the file described
86 in this manual page. 97 in this manual page.
87 98
88SSEEEE AALLSSOO 99SSEEEE AALLSSOO
89 pkg_add(1), pkg_admin(1) 100 pkg_add(1), pkg_admin(1)
90 101
91NetBSD 4.0 August 21, 2008 NetBSD 4.0 102NetBSD 5.0 January 8, 2009 NetBSD 5.0

cvs diff -r1.102.2.19 -r1.102.2.20 pkgsrc/pkgtools/pkg_install/files/lib/version.h (switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/version.h 2008/12/30 15:55:57 1.102.2.19
+++ pkgsrc/pkgtools/pkg_install/files/lib/version.h 2009/01/08 00:01:31 1.102.2.20
@@ -1,32 +1,32 @@ @@ -1,32 +1,32 @@
1/* $NetBSD: version.h,v 1.102.2.19 2008/12/30 15:55:57 joerg Exp $ */ 1/* $NetBSD: version.h,v 1.102.2.20 2009/01/08 00:01:31 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Thomas Klausner. All rights reserved. 4 * Copyright (c) 2001 Thomas Klausner. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27#ifndef _INST_LIB_VERSION_H_ 27#ifndef _INST_LIB_VERSION_H_
28#define _INST_LIB_VERSION_H_ 28#define _INST_LIB_VERSION_H_
29 29
30#define PKGTOOLS_VERSION "20081230" 30#define PKGTOOLS_VERSION "20090108"
31 31
32#endif /* _INST_LIB_VERSION_H_ */ 32#endif /* _INST_LIB_VERSION_H_ */