From e47fc2d7c6eb99a7b09393c6938ea47416cb88bc Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Thu, 17 Mar 2011 05:14:06 -0500 Subject: Ensure we have a root partition when checking space Partially addresses the "why doesn't CheckSpace work in a chroot" issue. We can't make it work, but we can at least detect when it won't work by checking for a partition for our given installation root. If we can't determine the mountpoint for this, bail out with an error. Signed-off-by: Dan McGee --- lib/libalpm/diskspace.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 892b1aac..281173a2 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -61,7 +61,7 @@ static int mount_point_cmp(const void *p1, const void *p2) static alpm_list_t *mount_point_list(void) { - alpm_list_t *mount_points = NULL; + alpm_list_t *mount_points = NULL, *ptr; alpm_mountpoint_t *mp; #if defined HAVE_GETMNTENT @@ -124,6 +124,10 @@ static alpm_list_t *mount_point_list(void) mount_points = alpm_list_msort(mount_points, alpm_list_count(mount_points), mount_point_cmp); + for(ptr = mount_points; ptr != NULL; ptr = ptr->next) { + mp = ptr->data; + _alpm_log(PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir); + } return(mount_points); } @@ -256,6 +260,7 @@ cleanup: int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) { alpm_list_t *mount_points, *i; + alpm_mountpoint_t *root_mp; size_t replaces = 0, current = 0, numtargs; int abort = 0; alpm_list_t *targ; @@ -263,7 +268,13 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) numtargs = alpm_list_count(trans->add); mount_points = mount_point_list(); if(mount_points == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points")); + _alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points\n")); + return(-1); + } + root_mp = match_mount_point(mount_points, handle->root); + if(root_mp == NULL) { + _alpm_log(PM_LOG_ERROR, _("could not determine root mount point %s\n"), + handle->root); return(-1); } -- cgit v1.2.3-24-g4f1b From b48f71841712d1839f5e900f1ec0fdf5665354ba Mon Sep 17 00:00:00 2001 From: tuxce Date: Thu, 17 Mar 2011 10:51:44 -0500 Subject: Correctly parse %DELTAS% entries in sync DB We erroniously dropped the call to _alpm_delta_parse() when macro-izing, causing segfaults for repos that provide deltas. Addresses FS#23314. Signed-off-by: Dan McGee --- lib/libalpm/be_sync.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 6c0d2d67..ca76105f 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -429,7 +429,12 @@ static int sync_db_read(pmdb_t *db, struct archive *archive, } else if(strcmp(line, "%PROVIDES%") == 0) { READ_AND_STORE_ALL(pkg->provides); } else if(strcmp(line, "%DELTAS%") == 0) { - READ_AND_STORE_ALL(pkg->deltas); + /* Different than the rest because of the _alpm_delta_parse call. */ + while(1) { + READ_NEXT(line); + if(strlen(line) == 0) break; + pkg->deltas = alpm_list_add(pkg->deltas, _alpm_delta_parse(line)); + } } } } else if(strcmp(filename, "files") == 0) { -- cgit v1.2.3-24-g4f1b From f6716ae94a5f299569b35bebb4d0aae23cd9af97 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 19 Mar 2011 11:22:19 +1000 Subject: Use sane umask for repo db downloads Fixes FS#23343. Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- lib/libalpm/be_sync.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/libalpm') diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index ca76105f..98516fd8 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -84,6 +84,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) struct stat buf; size_t len; int ret; + mode_t oldmask; ALPM_LOG_FUNC; @@ -104,6 +105,9 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) MALLOC(syncpath, len, RET_ERR(PM_ERR_MEMORY, -1)); sprintf(syncpath, "%s%s", dbpath, "sync/"); + /* make sure we have a sane umask */ + oldmask = umask(0022); + if(stat(syncpath, &buf) != 0) { _alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it\n", syncpath); @@ -124,6 +128,7 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db) ret = _alpm_download_single_file(dbfile, db->servers, syncpath, force); free(dbfile); free(syncpath); + umask(oldmask); if(ret == 1) { /* files match, do nothing */ -- cgit v1.2.3-24-g4f1b From 67c0e9cab39a536f1ca2fbf2a35fe898e3b71ef4 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 20 Mar 2011 11:43:37 -0500 Subject: Add missing include for size_t Needed for things like our strndup() substitute function. Signed-off-by: Dan McGee --- lib/libalpm/util.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/libalpm') diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h index d65f7734..3232f004 100644 --- a/lib/libalpm/util.h +++ b/lib/libalpm/util.h @@ -32,6 +32,7 @@ #include #include #include +#include /* size_t */ #include #include /* struct stat */ #include /* struct archive */ -- cgit v1.2.3-24-g4f1b