Tue Apr 17 12:52:35 2018 UTC ()
pkg_install: Update to 20180417.

Fix an issue in pkg_create where we may have been using corrupted owner and
group information.  Noticed on macOS where libarchive would complain about
the owner entry being too long.  Reviewed by joerg.

Also includes some manual page improvements committed recently.


(jperkin)
diff -r1.6 -r1.7 pkgsrc/pkgtools/pkg_install/files/create/util.c
diff -r1.174 -r1.175 pkgsrc/pkgtools/pkg_install/files/lib/version.h

cvs diff -r1.6 -r1.7 pkgsrc/pkgtools/pkg_install/files/create/util.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/create/util.c 2017/04/19 21:42:50 1.6
+++ pkgsrc/pkgtools/pkg_install/files/create/util.c 2018/04/17 12:52:35 1.7
@@ -55,79 +55,78 @@ @@ -55,79 +55,78 @@
55#include "lib.h" 55#include "lib.h"
56#include "create.h" 56#include "create.h"
57 57
58static void 58static void
59update_ids(struct memory_file *file) 59update_ids(struct memory_file *file)
60{ 60{
61 if (file->owner != NULL) { 61 if (file->owner != NULL) {
62 uid_t uid; 62 uid_t uid;
63 63
64 if (uid_from_user(file->owner, &uid) == -1) 64 if (uid_from_user(file->owner, &uid) == -1)
65 errx(2, "user %s unknown", file->owner); 65 errx(2, "user %s unknown", file->owner);
66 file->st.st_uid = uid; 66 file->st.st_uid = uid;
67 } else { 67 } else {
68 file->owner = user_from_uid(file->st.st_uid, 1); 68 file->owner = xstrdup(user_from_uid(file->st.st_uid, 1));
69 } 69 }
70 70
71 if (file->group != NULL) { 71 if (file->group != NULL) {
72 gid_t gid; 72 gid_t gid;
73 73
74 if (gid_from_group(file->group, &gid) == -1) 74 if (gid_from_group(file->group, &gid) == -1)
75 errx(2, "group %s unknown", file->group); 75 errx(2, "group %s unknown", file->group);
76 file->group = file->group; 
77 file->st.st_gid = gid; 76 file->st.st_gid = gid;
78 } else { 77 } else {
79 file->group = group_from_gid(file->st.st_gid, 1); 78 file->group = xstrdup(group_from_gid(file->st.st_gid, 1));
80 } 79 }
81} 80}
82 81
83struct memory_file * 82struct memory_file *
84make_memory_file(const char *archive_name, void *data, size_t len, 83make_memory_file(const char *archive_name, void *data, size_t len,
85 const char *owner, const char *group, mode_t mode) 84 const char *owner, const char *group, mode_t mode)
86{ 85{
87 struct memory_file *file; 86 struct memory_file *file;
88 87
89 file = xmalloc(sizeof(*file)); 88 file = xmalloc(sizeof(*file));
90 file->name = archive_name; 89 file->name = archive_name;
91 file->owner = owner; 90 file->owner = (owner != NULL) ? xstrdup(owner) : NULL;
92 file->group = group; 91 file->group = (group != NULL) ? xstrdup(group) : NULL;
93 file->data = data; 92 file->data = data;
94 file->len = len; 93 file->len = len;
95 94
96 memset(&file->st, 0, sizeof(file->st)); 95 memset(&file->st, 0, sizeof(file->st));
97 96
98 file->st.st_atime = file->st.st_ctime = file->st.st_mtime = time(NULL); 97 file->st.st_atime = file->st.st_ctime = file->st.st_mtime = time(NULL);
99 98
100 file->st.st_nlink = 1; 99 file->st.st_nlink = 1;
101 file->st.st_size = len; 100 file->st.st_size = len;
102 file->st.st_mode = mode | S_IFREG; 101 file->st.st_mode = mode | S_IFREG;
103 102
104 update_ids(file); 103 update_ids(file);
105 104
106 return file; 105 return file;
107} 106}
108 107
109struct memory_file * 108struct memory_file *
110load_memory_file(const char *disk_name, 109load_memory_file(const char *disk_name,
111 const char *archive_name, const char *owner, const char *group, 110 const char *archive_name, const char *owner, const char *group,
112 mode_t mode) 111 mode_t mode)
113{ 112{
114 struct memory_file *file; 113 struct memory_file *file;
115 int fd; 114 int fd;
116 115
117 file = xmalloc(sizeof(*file)); 116 file = xmalloc(sizeof(*file));
118 file->name = archive_name; 117 file->name = archive_name;
119 file->owner = owner; 118 file->owner = (owner != NULL) ? xstrdup(owner) : NULL;
120 file->group = group; 119 file->group = (group != NULL) ? xstrdup(group) : NULL;
121 file->mode = mode; 120 file->mode = mode;
122 121
123 fd = open(disk_name, O_RDONLY); 122 fd = open(disk_name, O_RDONLY);
124 if (fd == -1) 123 if (fd == -1)
125 err(2, "cannot open file %s", disk_name); 124 err(2, "cannot open file %s", disk_name);
126 if (fstat(fd, &file->st) == -1) 125 if (fstat(fd, &file->st) == -1)
127 err(2, "cannot stat file %s", disk_name); 126 err(2, "cannot stat file %s", disk_name);
128 127
129 update_ids(file); 128 update_ids(file);
130 129
131 if ((file->st.st_mode & S_IFMT) != S_IFREG) 130 if ((file->st.st_mode & S_IFMT) != S_IFREG)
132 errx(1, "meta data file %s is not regular file", disk_name); 131 errx(1, "meta data file %s is not regular file", disk_name);
133 if (file->st.st_size > SSIZE_MAX) 132 if (file->st.st_size > SSIZE_MAX)
@@ -138,17 +137,19 @@ load_memory_file(const char *disk_name, @@ -138,17 +137,19 @@ load_memory_file(const char *disk_name,
138 err(2, "cannot read file into memory %s", disk_name); 137 err(2, "cannot read file into memory %s", disk_name);
139 138
140 file->len = file->st.st_size; 139 file->len = file->st.st_size;
141 140
142 close(fd); 141 close(fd);
143 142
144 return file; 143 return file;
145} 144}
146 145
147void 146void
148free_memory_file(struct memory_file *file) 147free_memory_file(struct memory_file *file)
149{ 148{
150 if (file != NULL) { 149 if (file != NULL) {
 150 free((char *)file->owner);
 151 free((char *)file->group);
151 free(file->data); 152 free(file->data);
152 free(file); 153 free(file);
153 } 154 }
154} 155}

cvs diff -r1.174 -r1.175 pkgsrc/pkgtools/pkg_install/files/lib/version.h (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/version.h 2018/03/25 03:56:28 1.174
+++ pkgsrc/pkgtools/pkg_install/files/lib/version.h 2018/04/17 12:52:35 1.175
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: version.h,v 1.174 2018/03/25 03:56:28 sevan Exp $ */ 1/* $NetBSD: version.h,v 1.175 2018/04/17 12:52:35 jperkin 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 *
@@ -17,16 +17,16 @@ @@ -17,16 +17,16 @@
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 20180325 30#define PKGTOOLS_VERSION 20180417
31 31
32#endif /* _INST_LIB_VERSION_H_ */ 32#endif /* _INST_LIB_VERSION_H_ */