mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Separate local db directory creation and db write
Changelogs and install files were getting extracted into the local db folder before it was manually created. This created issues for uses with 0077 umasks and was highlighted with the new sudo handling of umasks (FS#12263). This moves the local db creation to its own function which is called before the start of package archive extraction. Also, added a check that the folder is actually created. Signed-off-by: Allan McRae <allan@archlinux.org> [Dan: rename to _alpm_db_prepare()] Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
b3169a5687
commit
a73ad4f0e3
@ -696,6 +696,16 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
|
||||
}
|
||||
}
|
||||
|
||||
/* prepare directory for database entries so permission are correct after
|
||||
changelog/install script installation (FS#12263) */
|
||||
if(_alpm_db_prepare(db, newpkg)) {
|
||||
alpm_logaction("error: could not create database entry %s-%s\n",
|
||||
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
|
||||
pm_errno = PM_ERR_DB_WRITE;
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
|
||||
struct archive *archive;
|
||||
struct archive_entry *entry;
|
||||
|
@ -652,6 +652,26 @@ error:
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int _alpm_db_prepare(pmdb_t *db, pmpkg_t *info)
|
||||
{
|
||||
mode_t oldmask;
|
||||
int retval = 0;
|
||||
char *pkgpath = NULL;
|
||||
|
||||
oldmask = umask(0000);
|
||||
|
||||
pkgpath = get_pkgpath(db, info);
|
||||
|
||||
if((retval = mkdir(pkgpath, 0755)) != 0) {
|
||||
_alpm_log(PM_LOG_ERROR, _("could not create directory %s: %s\n"), pkgpath, strerror(errno));
|
||||
}
|
||||
|
||||
free(pkgpath);
|
||||
umask(oldmask);
|
||||
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
@ -670,10 +690,8 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
|
||||
|
||||
pkgpath = get_pkgpath(db, info);
|
||||
|
||||
oldmask = umask(0000);
|
||||
mkdir(pkgpath, 0755);
|
||||
/* make sure we have a sane umask */
|
||||
umask(0022);
|
||||
oldmask = umask(0022);
|
||||
|
||||
if(strcmp(db->treename, "local") == 0) {
|
||||
local = 1;
|
||||
|
@ -60,6 +60,7 @@ int _alpm_db_open(pmdb_t *db);
|
||||
void _alpm_db_close(pmdb_t *db);
|
||||
int _alpm_db_populate(pmdb_t *db);
|
||||
int _alpm_db_read(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
|
||||
int _alpm_db_prepare(pmdb_t *db, pmpkg_t *info);
|
||||
int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq);
|
||||
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user