Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/handle.c39
-rw-r--r--lib/libalpm/handle.h55
-rw-r--r--lib/libalpm/log.c2
-rw-r--r--lib/libalpm/trans.c6
4 files changed, 36 insertions, 66 deletions
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 7cee5020..b1fd45f2 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -53,31 +53,10 @@ pmhandle_t *_alpm_handle_new()
memset(handle, 0, sizeof(pmhandle_t));
handle->lckfd = -1;
+ handle->logstream = NULL;
-#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
- handle->access = PM_ACCESS_RW;
-#endif
handle->root = NULL;
handle->dbpath = NULL;
handle->cachedirs = NULL;
@@ -95,10 +74,10 @@ void _alpm_handle_free(pmhandle_t *handle)
return;
}
- /* close logfiles */
- if(handle->logfd) {
- fclose(handle->logfd);
- handle->logfd = NULL;
+ /* close logfile */
+ if(handle->logstream) {
+ fclose(handle->logstream);
+ handle->logstream= NULL;
}
if(handle->usesyslog) {
handle->usesyslog = 0;
@@ -231,14 +210,14 @@ void SYMEXPORT alpm_option_set_logfile(const char *logfile)
if(handle->logfile) {
FREE(handle->logfile);
- if(handle->logfd) {
- fclose(handle->logfd);
- handle->logfd = NULL;
+ if(handle->logstream) {
+ fclose(handle->logstream);
+ handle->logstream = NULL;
}
}
if(logfile) {
handle->logfile = strdup(logfile);
- handle->logfd = fopen(logfile, "a");
+ handle->logstream = fopen(logfile, "a");
}
}
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index b0e80338..cf2e9d5c 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -30,40 +30,37 @@
#include "alpm.h"
#include "trans.h"
-typedef enum _pmaccess_t {
- PM_ACCESS_RO,
- PM_ACCESS_RW
-} pmaccess_t;
-
typedef struct _pmhandle_t {
- /* Internal */
- pmaccess_t access;
- uid_t uid;
- pmdb_t *db_local;
- alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
- FILE *logfd;
- int lckfd;
+ /* internal usage */
+ uid_t uid; /* current UID */ /* TODO is this used? */
+ pmdb_t *db_local; /* local db pointer */
+ alpm_list_t *dbs_sync; /* List of (pmdb_t *) */
+ FILE *logstream; /* log file stream pointer */
+ int lckfd; /* lock file descriptor if one exists */
pmtrans_t *trans;
- /* options */
- alpm_cb_log logcb; /* Log callback function */
- alpm_cb_download dlcb; /* Download callback function */
- char *root; /* Root path, default '/' */
- char *dbpath; /* Base path to pacman's DBs */
- alpm_list_t *cachedirs; /* Paths to pacman cache directories */
- char *logfile; /* Name of the file to log to */ /*TODO is this used?*/
- char *lockfile; /* Name of the lock file */
- unsigned short usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
-
- alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
- alpm_list_t *noextract; /* List of packages NOT to extract */ /*TODO is this used?*/
- alpm_list_t *ignorepkg; /* List of packages to ignore */
- alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */
+ /* callback functions */
+ alpm_cb_log logcb; /* Log callback function */
+ alpm_cb_download dlcb; /* Download callback function */
- time_t upgradedelay; /* Amount of time to wait before upgrading a package */
- /* servers */
- char *xfercommand; /* External download command */
+ /* filesystem paths */
+ char *root; /* Root path, default '/' */
+ char *dbpath; /* Base path to pacman's DBs */
+ char *logfile; /* Name of the log file */
+ char *lockfile; /* Name of the lock file */
+ alpm_list_t *cachedirs; /* Paths to pacman cache directories */
+
+ /* package lists */
+ alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
+ alpm_list_t *noextract; /* List of packages NOT to extract */ /*TODO is this used?*/
+ alpm_list_t *ignorepkg; /* List of packages to ignore */
+ alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */
+
+ /* options */
+ unsigned short usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
unsigned short nopassiveftp; /* Don't use PASV ftp connections */
+ time_t upgradedelay; /* Time to wait before upgrading a package */
+ char *xfercommand; /* External download command */
} pmhandle_t;
extern pmhandle_t *handle;
diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index 19f41283..f4564fc9 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -52,7 +52,7 @@ int SYMEXPORT alpm_logaction(char *fmt, ...)
ASSERT(handle != NULL, RET_ERR(PM_ERR_HANDLE_NULL, -1));
va_start(args, fmt);
- ret = _alpm_logaction(handle->usesyslog, handle->logfd, fmt, args);
+ ret = _alpm_logaction(handle->usesyslog, handle->logstream, fmt, args);
va_end(args);
/* TODO We should add a prefix to log strings depending on who called us.
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 82f11f3d..5d62e8e8 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -165,12 +165,6 @@ int SYMEXPORT alpm_trans_commit(alpm_list_t **data)
ASSERT(handle->trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(handle->trans->state == STATE_PREPARED, RET_ERR(PM_ERR_TRANS_NOT_PREPARED, -1));
- /* Check for database R/W permission */
- if(!(handle->trans->flags & PM_TRANS_FLAG_PRINTURIS)) {
- /* The print-uris operation is a bit odd. So we explicitly check for it */
- ASSERT(handle->access == PM_ACCESS_RW, RET_ERR(PM_ERR_BADPERMS, -1));
- }
-
return(_alpm_trans_commit(handle->trans, data));
}