xbps-rindex: fix -a/--add mode repodata archive permissions.

The repodata archive wasn't group writable, resulting in a new archive
created from scratch if the fd wasn't writable.

repodata archives are now created with 0664 mode, this way its main group
also can write to it.
This commit is contained in:
Juan RP 2014-09-15 12:15:42 +02:00
parent 3f7e98235c
commit dee7852af8
3 changed files with 11 additions and 4 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.39 (???):
* xbps-rindex: fix -a/--add mode to create repodata archives with 0664 permissions;
and do not create a new archive if the file cannot be open/locked, error out
instead... otherwise the file lock is ignored.
xbps-0.38 (2014-09-14):
* Disabled best pkg matching code for performance reasons. When installing

View File

@ -59,6 +59,12 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
repodir = dirname(tmprepodir);
repo = xbps_repo_open(xhp, repodir, true);
if (repo == NULL && errno != ENOENT) {
fprintf(stderr, "xbps-rindex: cannot open/lock repository "
"%s: %s\n", repodir, strerror(errno));
rv = -1;
goto out;
}
if (repo && repo->idx) {
xbps_repo_open_idxfiles(repo);
idx = xbps_dictionary_copy(repo->idx);

View File

@ -45,7 +45,6 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
struct archive *ar;
char *repofile, *tname, *buf;
int rv, repofd = -1;
mode_t myumask;
/* Create a tempfile for our repository archive */
repofile = xbps_repo_path(xhp, repodir);
@ -95,9 +94,7 @@ repodata_flush(struct xbps_handle *xhp, const char *repodir,
/* Write data to tempfile and rename */
archive_write_finish(ar);
fdatasync(repofd);
myumask = umask(0);
(void)umask(myumask);
assert(fchmod(repofd, 0666 & ~myumask) != -1);
assert(fchmod(repofd, 0664) != -1);
close(repofd);
rename(tname, repofile);
free(repofile);