Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/handle.c
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-03-04 09:08:54 +0000
committerAaron Griffin <aaron@archlinux.org>2007-03-04 09:08:54 +0000
commitcdb46ef3fa6d2bea95ae45b8b807497982b18fd5 (patch)
tree0f2340ed62be9f99f1e4bf0764c65aad1e701964 /lib/libalpm/handle.c
parenta7d7c963579176dfefe424931a57e86bc8b51924 (diff)
* Fixed a whole mess of extra '/' pathing issues when a different root is
specified * Use db->path when appropriate * Commented out the FAKEROOT checks in libalpm. This should never ever be done. TODO test this quite a bit, as this will never cause the transactions to fail if RW operations are requested... right now it is totally up to the front end to decide when to fail * Use realpath() to canonicalize the root path when specified, so _alpm_makepath() doesn't freak out * Fixed some output/indent of MDFile and SHAFile algorithms * More efficient sprintf() usage in MDFile/SHAFile * Added real error output to _alpm_makepath
Diffstat (limited to 'lib/libalpm/handle.c')
-rw-r--r--lib/libalpm/handle.c57
1 files changed, 34 insertions, 23 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 5ca8258e..c17d86a5 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -56,25 +56,25 @@ pmhandle_t *_alpm_handle_new()
#ifndef CYGWIN
/* see if we're root or not */
handle->uid = geteuid();
-#ifndef FAKEROOT
- if(!handle->uid && getenv("FAKEROOTKEY")) {
- /* fakeroot doesn't count, we're non-root */
- handle->uid = 99;
- }
-#endif
-
- /* see if we're root or not (fakeroot does not count) */
-#ifndef FAKEROOT
- if(handle->uid == 0 && !getenv("FAKEROOTKEY")) {
- /* } make vim indent work - stupid ifdef's */
-#else
- if(handle->uid == 0) {
-#endif
- handle->access = PM_ACCESS_RW;
- } else {
- handle->access = PM_ACCESS_RO;
- }
-#else
+//#ifndef FAKEROOT
+// if(!handle->uid && getenv("FAKEROOTKEY")) {
+// /* fakeroot doesn't count, we're non-root */
+// handle->uid = 99;
+// }
+//#endif
+//
+// /* see if we're root or not (fakeroot does not count) */
+//#ifndef FAKEROOT
+// if(handle->uid == 0 && !getenv("FAKEROOTKEY")) {
+// /* } make vim indent work - stupid ifdef's */
+//#else
+// if(handle->uid == 0) {
+//#endif
+// handle->access = PM_ACCESS_RW;
+// } else {
+// handle->access = PM_ACCESS_RO;
+// }
+//#else
handle->access = PM_ACCESS_RW;
#endif
@@ -152,16 +152,27 @@ void SYMEXPORT alpm_option_set_logmask(unsigned short mask) { handle->logmask =
void alpm_option_set_root(const char *root)
{
if(handle->root) FREE(handle->root);
- if(root) {
+ /* According to the man page, realpath is safe to use IFF the second arg is
+ * NULL. */
+ char *realroot = realpath(root, NULL);
+ if(!realroot) {
+ realroot = root;
+ _alpm_log(PM_LOG_ERROR, _("cannot canonicalize specified root path '%s'"), root);
+ }
+
+ /* check again, in case both are null */
+ if(realroot) {
/* verify root ends in a '/' */
- int rootlen = strlen(root);
- if(root[rootlen-1] != '/') {
+ int rootlen = strlen(realroot);
+ if(realroot[rootlen-1] != '/') {
rootlen += 1;
}
handle->root = calloc(rootlen+1, sizeof(char));
- strncpy(handle->root, root, rootlen);
+ strncpy(handle->root, realroot, rootlen);
handle->root[rootlen-1] = '/';
_alpm_log(PM_LOG_DEBUG, _("option 'root' = %s"), handle->root);
+
+ free(realroot);
}
}