pkgng

Check-in [28f1fb4a2b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make pass mode respect properly @owner/@group In pass mode we need to resolv the uid/gid and enforce them.
Timelines: family | ancestors | descendants | both | trunk | multi-repos | stash
Files: files | file ages | folders
SHA1:28f1fb4a2bc3a259ca7c467139a1f295e051cf1e
User & Date: bapt@FreeBSD.org 2013-10-05 17:43:15
Context
2013-10-05
17:56
Remove paking_append_file function Leaf check-in: 2a8d78975e user: bapt@FreeBSD.org tags: trunk, multi-repos, stash
17:43
Make pass mode respect properly @owner/@group In pass mode we need to resolv the uid/gid and enforce them. check-in: 28f1fb4a2b user: bapt@FreeBSD.org tags: trunk, multi-repos, stash
2013-09-30
16:01
Fix deinstallation message to say it will free space Reported by: mva check-in: 4c1ecfcbbd user: bryan@shatow.net tags: trunk, multi-repos, stash
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to libpkg/packing.c.

32
33
34
35
36
37
38


39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
..
63
64
65
66
67
68
69

70
71
72
73
74
75
76
..
87
88
89
90
91
92
93

94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
...
177
178
179
180
181
182
183
184




185
186

187




188

189
190
191
192
193
194
195
#include <archive_entry.h>
#include <assert.h>
#include <fcntl.h>
#include <fts.h>
#include <string.h>
#include <sys/mman.h>
#include <limits.h>



#include "pkg.h"
#include "private/event.h"
#include "private/pkg.h"

static const char *packing_set_format(struct archive *a, pkg_formats format);

struct packing {

	struct archive *aread;
	struct archive *awrite;
	struct archive_entry_linkresolver *resolver;
};

int
packing_init(struct packing **pack, const char *path, pkg_formats format)
................................................................................
	}

	(*pack)->aread = archive_read_disk_new();
	archive_read_disk_set_standard_lookup((*pack)->aread);
	archive_read_disk_set_symlink_physical((*pack)->aread);

	if (!is_dir(path)) {

		(*pack)->awrite = archive_write_new();
		archive_write_set_format_pax_restricted((*pack)->awrite);
		ext = packing_set_format((*pack)->awrite, format);
		if (ext == NULL) {
			archive_read_free((*pack)->aread);
			archive_write_free((*pack)->awrite);
			*pack = NULL;
................................................................................
			archive_read_free((*pack)->aread);
			archive_write_free((*pack)->awrite);
			*pack = NULL;
			return EPKG_FATAL;
		}
	} else { /* pass mode directly write to the disk */
		pkg_debug(1, "Packing to directory '%s' (pass mode)", path);

		(*pack)->awrite = archive_write_disk_new();
		archive_write_disk_set_options((*pack)->awrite,
		    EXTRACT_ARCHIVE_FLAGS);
	}

	(*pack)->resolver = archive_entry_linkresolver_new();
	archive_entry_linkresolver_set_strategy((*pack)->resolver,
	    ARCHIVE_FORMAT_TAR_PAX_RESTRICTED);

	return (EPKG_OK);
}

int
packing_append_buffer(struct packing *pack, const char *buffer,
    const char *path, int size)
{
................................................................................
	if (newpath != NULL)
		archive_entry_set_pathname(entry, newpath);

	if (archive_entry_filetype(entry) != AE_IFREG) {
		archive_entry_set_size(entry, 0);
	}

	if (uname != NULL && uname[0] != '\0')




		archive_entry_set_uname(entry, uname);


	if (gname != NULL && gname[0] != '\0')




		archive_entry_set_gname(entry, gname);


	if (perm != 0)
		archive_entry_set_perm(entry, perm);

	pkg_config_bool(PKG_CONFIG_UNSET_TIMESTAMP, &unset_timestamp);

	if (unset_timestamp) {







>
>








>







 







>







 







>








>







 







|
>
>
>
>

|
>
|
>
>
>
>

>







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
..
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include <archive_entry.h>
#include <assert.h>
#include <fcntl.h>
#include <fts.h>
#include <string.h>
#include <sys/mman.h>
#include <limits.h>
#include <pwd.h>
#include <grp.h>

#include "pkg.h"
#include "private/event.h"
#include "private/pkg.h"

static const char *packing_set_format(struct archive *a, pkg_formats format);

struct packing {
	bool pass;
	struct archive *aread;
	struct archive *awrite;
	struct archive_entry_linkresolver *resolver;
};

int
packing_init(struct packing **pack, const char *path, pkg_formats format)
................................................................................
	}

	(*pack)->aread = archive_read_disk_new();
	archive_read_disk_set_standard_lookup((*pack)->aread);
	archive_read_disk_set_symlink_physical((*pack)->aread);

	if (!is_dir(path)) {
		(*pack)->pass = false;
		(*pack)->awrite = archive_write_new();
		archive_write_set_format_pax_restricted((*pack)->awrite);
		ext = packing_set_format((*pack)->awrite, format);
		if (ext == NULL) {
			archive_read_free((*pack)->aread);
			archive_write_free((*pack)->awrite);
			*pack = NULL;
................................................................................
			archive_read_free((*pack)->aread);
			archive_write_free((*pack)->awrite);
			*pack = NULL;
			return EPKG_FATAL;
		}
	} else { /* pass mode directly write to the disk */
		pkg_debug(1, "Packing to directory '%s' (pass mode)", path);
		(*pack)->pass = true;
		(*pack)->awrite = archive_write_disk_new();
		archive_write_disk_set_options((*pack)->awrite,
		    EXTRACT_ARCHIVE_FLAGS);
	}

	(*pack)->resolver = archive_entry_linkresolver_new();
	archive_entry_linkresolver_set_strategy((*pack)->resolver,
	    ARCHIVE_FORMAT_TAR_PAX_RESTRICTED);

	return (EPKG_OK);
}

int
packing_append_buffer(struct packing *pack, const char *buffer,
    const char *path, int size)
{
................................................................................
	if (newpath != NULL)
		archive_entry_set_pathname(entry, newpath);

	if (archive_entry_filetype(entry) != AE_IFREG) {
		archive_entry_set_size(entry, 0);
	}

	if (uname != NULL && uname[0] != '\0') {
		if (pack->pass) {
			struct passwd* pw = getpwnam(uname);
			archive_entry_set_uid(entry, pw->pw_uid);
		}
		archive_entry_set_uname(entry, uname);
	}

	if (gname != NULL && gname[0] != '\0') {
		if (pack->pass) {
			struct group *gr = (getgrnam(gname));
			archive_entry_set_gid(entry, gr->gr_gid);
		}
		archive_entry_set_gname(entry, gname);
	}

	if (perm != 0)
		archive_entry_set_perm(entry, perm);

	pkg_config_bool(PKG_CONFIG_UNSET_TIMESTAMP, &unset_timestamp);

	if (unset_timestamp) {

Changes to libpkg/pkg.c.

1273
1274
1275
1276
1277
1278
1279
1280

1281
1282
1283
1284
1285
1286

1287
1288
1289
1290
1291
1292
1293
		/* TODO */
		return EPKG_FATAL;
	}

	while (pkg_dirs(pkg, &dir) == EPKG_OK) {
		snprintf(spath, sizeof(spath), "%s%s", src, pkg_dir_path(dir));
		snprintf(dpath, sizeof(dpath), "%s%s", dest, pkg_dir_path(dir));
		packing_append_file(pack, spath, dpath);

	}

	while (pkg_files(pkg, &file) == EPKG_OK) {
		snprintf(spath, sizeof(spath), "%s%s", src, pkg_file_path(file));
		snprintf(dpath, sizeof(dpath), "%s%s", dest, pkg_file_path(file));
		packing_append_file(pack, spath, dpath);

	}

	/* Execute post-install scripts */
	pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL);

	return (packing_finish(pack));
}







|
>





|
>







1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
		/* TODO */
		return EPKG_FATAL;
	}

	while (pkg_dirs(pkg, &dir) == EPKG_OK) {
		snprintf(spath, sizeof(spath), "%s%s", src, pkg_dir_path(dir));
		snprintf(dpath, sizeof(dpath), "%s%s", dest, pkg_dir_path(dir));
		packing_append_file_attr(pack, spath, dpath,
		    dir->uname, dir->gname, dir->perm);
	}

	while (pkg_files(pkg, &file) == EPKG_OK) {
		snprintf(spath, sizeof(spath), "%s%s", src, pkg_file_path(file));
		snprintf(dpath, sizeof(dpath), "%s%s", dest, pkg_file_path(file));
		packing_append_file_attr(pack, spath, dpath,
		    file->uname, file->gname, file->perm);
	}

	/* Execute post-install scripts */
	pkg_script_run(pkg, PKG_SCRIPT_POST_INSTALL);

	return (packing_finish(pack));
}