RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 30-Jul-2007 14:40:30
Branch: rpm-4_5 Handle: 2007073013402801
Modified files: (Branch: rpm-4_5)
rpm CHANGES
rpm/rpmdb db_emu.h hdrinline.h header.c header.h
librpmdb.vers rpmdb.c rpmdb.h sqlite.c
Log:
- adjust signal polling for python exit purposes <pmatlai@redhat.com>.
- adopt rpm.org signal handling <pmatlai@redhat.com>.
- void * for headerRead and headerWrite.
Summary:
Revision Changes Path
1.1360.2.30 +4 -0 rpm/CHANGES
1.1.6.1 +7 -1 rpm/rpmdb/db_emu.h
1.7.2.2 +8 -8 rpm/rpmdb/hdrinline.h
1.48.2.3 +7 -5 rpm/rpmdb/header.c
1.13.2.2 +6 -6 rpm/rpmdb/header.h
1.3.2.1 +1 -0 rpm/rpmdb/librpmdb.vers
1.128.2.7 +23 -11 rpm/rpmdb/rpmdb.c
1.57.2.2 +15 -1 rpm/rpmdb/rpmdb.h
1.5.2.2 +64 -4 rpm/rpmdb/sqlite.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1360.2.29 -r1.1360.2.30 CHANGES
--- rpm/CHANGES 30 Jul 2007 03:07:58 -0000 1.1360.2.29
+++ rpm/CHANGES 30 Jul 2007 12:40:28 -0000 1.1360.2.30
@@ -3,6 +3,10 @@
- jbj: eliminate --rsegfault/--wsegfault.
- jbj: add RPMTAG_DBINSTANCE header extension.
- jbj: parameterize Depends index and dependency result caching.
+ - jbj: adjust signal polling for python exit purposes <pmatlai@redhat.com>.
+ - jbj: use _macro_BUFSIZ, not compiled in BUFSIZ, to size expansion targets.
+ - jbj: enable %{dirname:...} macro primitive.
+ - jbj: adopt rpm.org signal handling <pmatlai@redhat.com>.
- jbj: fix a --import memory leak.
- jbj: selinux: use matchpthcon() instead or rpmsx.
- jbj: insure that RPMFILE_EXISTS is set for %config files.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/db_emu.h
============================================================================
$ cvs diff -u -r1.1 -r1.1.6.1 db_emu.h
--- rpm/rpmdb/db_emu.h 28 Jan 2005 21:56:56 -0000 1.1
+++ rpm/rpmdb/db_emu.h 30 Jul 2007 12:40:29 -0000 1.1.6.1
@@ -22,7 +22,7 @@
u_int32_t size;
void *data;
- #define DB_DBT_MALLOC 0x01 /* We malloc the memory and hand off a copy. */
+#define DB_DBT_MALLOC 0x01 /* We malloc the memory and hand off a copy. */
u_int32_t flags;
};
@@ -48,5 +48,11 @@
#define DB_SET 32
#define DB_WRITECURSOR 39
#define DB_NOTFOUND (-30990)
+#define DB_PRIVATE 0x0200000
+#define DB_EXCL 0x0004000
+
+#define DB_VERSION_MAJOR 3
+#define DB_VERSION_MINOR 0
+#define DB_VERSION_PATCH 0
#endif
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/hdrinline.h
============================================================================
$ cvs diff -u -r1.7.2.1 -r1.7.2.2 hdrinline.h
--- rpm/rpmdb/hdrinline.h 9 Jun 2007 19:08:52 -0000 1.7.2.1
+++ rpm/rpmdb/hdrinline.h 30 Jul 2007 12:40:29 -0000 1.7.2.2
@@ -192,32 +192,32 @@
/** \ingroup header
* Read (and load) header from file handle.
- * @param fd file handle
+ * @param _fd file handle
* @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
/*@unused@*/ static inline
-/*@null@*/ Header headerRead(FD_t fd, enum hMagic magicp)
- /*@modifies fd @*/
+/*@null@*/ Header headerRead(void * _fd, enum hMagic magicp)
+ /*@modifies _fd @*/
{
- return hdrVec->hdrread(fd, magicp);
+ return hdrVec->hdrread(_fd, magicp);
}
/** \ingroup header
* Write (with unload) header to file handle.
- * @param fd file handle
+ * @param _fd file handle
* @param h header
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
/*@unused@*/ static inline
-int headerWrite(FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
- /*@modifies fd, h @*/
+int headerWrite(void * _fd, /*@null@*/ Header h, enum hMagic magicp)
+ /*@modifies _fd, h @*/
{
/*@-abstract@*/
if (h == NULL) return 0;
/*@=abstract@*/
- return (h2hv(h)->hdrwrite) (fd, h, magicp);
+ return (h2hv(h)->hdrwrite) (_fd, h, magicp);
}
/** \ingroup header
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.c
============================================================================
$ cvs diff -u -r1.48.2.2 -r1.48.2.3 header.c
--- rpm/rpmdb/header.c 17 Jun 2007 14:41:58 -0000 1.48.2.2
+++ rpm/rpmdb/header.c 30 Jul 2007 12:40:29 -0000 1.48.2.3
@@ -1335,14 +1335,15 @@
/** \ingroup header
* Read (and load) header from file handle.
- * @param fd file handle
+ * @param _fd file handle
* @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
static /*@null@*/
-Header headerRead(FD_t fd, enum hMagic magicp)
- /*@modifies fd @*/
+Header headerRead(void * _fd, enum hMagic magicp)
+ /*@modifies _fd @*/
{
+ FD_t fd = _fd;
int_32 block[4];
int_32 reserved;
int_32 * ei = NULL;
@@ -1420,16 +1421,17 @@
/** \ingroup header
* Write (with unload) header to file handle.
- * @param fd file handle
+ * @param _fd file handle
* @param h header
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
static
-int headerWrite(FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
+int headerWrite(void * _fd, /*@null@*/ Header h, enum hMagic magicp)
/*@globals fileSystem @*/
/*@modifies fd, h, fileSystem @*/
{
+ FD_t fd = _fd;
ssize_t nb;
int length;
const void * uh;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.h
============================================================================
$ cvs diff -u -r1.13.2.1 -r1.13.2.2 header.h
--- rpm/rpmdb/header.h 9 Jun 2007 19:08:52 -0000 1.13.2.1
+++ rpm/rpmdb/header.h 30 Jul 2007 12:40:29 -0000 1.13.2.2
@@ -455,25 +455,25 @@
/** \ingroup header
* Read (and load) header from file handle.
- * @param fd file handle
+ * @param _fd file handle
* @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
typedef
-/*@null@*/ Header (*HDRread) (FD_t fd, enum hMagic magicp)
- /*@modifies fd @*/;
+/*@null@*/ Header (*HDRread) (void * _fd, enum hMagic magicp)
+ /*@modifies _fd @*/;
/** \ingroup header
* Write (with unload) header to file handle.
- * @param fd file handle
+ * @param _fd file handle
* @param h header
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
typedef
-int (*HDRwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
+int (*HDRwrite) (void * _fd, /*@null@*/ Header h, enum hMagic magicp)
/*@globals fileSystem @*/
- /*@modifies fd, h, fileSystem @*/;
+ /*@modifies _fd, h, fileSystem @*/;
/** \ingroup header
* Check if tag is in header.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/librpmdb.vers
============================================================================
$ cvs diff -u -r1.3 -r1.3.2.1 librpmdb.vers
--- rpm/rpmdb/librpmdb.vers 25 May 2007 17:36:33 -0000 1.3
+++ rpm/rpmdb/librpmdb.vers 30 Jul 2007 12:40:29 -0000 1.3.2.1
@@ -44,6 +44,7 @@
rpmdbAppendIterator;
rpmDBArgs;
rpmdbCheckSignals;
+ rpmdbCheckTerminate;
rpmdbClose;
rpmdbBlockDBI;
rpmdbCloseDBI;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/rpmdb.c
============================================================================
$ cvs diff -u -r1.128.2.6 -r1.128.2.7 rpmdb.c
--- rpm/rpmdb/rpmdb.c 30 Jul 2007 03:03:32 -0000 1.128.2.6
+++ rpm/rpmdb/rpmdb.c 30 Jul 2007 12:40:29 -0000 1.128.2.7
@@ -677,14 +677,14 @@
/*@unchecked@*/ /*@exposed@*/ /*@null@*/
static rpmdbMatchIterator rpmmiRock;
-int rpmdbCheckSignals(void)
+int rpmdbCheckTerminate(int terminate)
/*@globals rpmdbRock, rpmmiRock @*/
/*@modifies rpmdbRock, rpmmiRock @*/
{
sigset_t newMask, oldMask;
- static int terminate = 0;
+ static int terminating = 0;
- if (terminate) return 0;
+ if (terminating) return 1;
(void) sigfillset(&newMask); /* block all signals */
(void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
@@ -693,17 +693,14 @@
|| sigismember(&rpmsqCaught, SIGQUIT)
|| sigismember(&rpmsqCaught, SIGHUP)
|| sigismember(&rpmsqCaught, SIGTERM)
- || sigismember(&rpmsqCaught, SIGPIPE))
- terminate = 1;
+ || sigismember(&rpmsqCaught, SIGPIPE)
+ || terminate)
+ terminating = 1;
- if (terminate) {
+ if (terminating) {
rpmdb db;
rpmdbMatchIterator mi;
-/*@-abstract@*/ /* sigset_t is abstract type */
- rpmMessage(RPMMESS_DEBUG, D_("Exiting on signal(0x%lx) ...\n"), *((unsigned long *)&rpmsqCaught));
-/*@=abstract@*/
-
/*@-branchstate@*/
while ((mi = rpmmiRock) != NULL) {
/*@i@*/ rpmmiRock = mi->mi_next;
@@ -719,9 +716,24 @@
(void) rpmdbClose(db);
}
/*@=newreftrans@*/
+ }
+ (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
+ return terminating;
+}
+
+int rpmdbCheckSignals(void)
+ /*@globals rpmdbRock, rpmmiRock @*/
+ /*@modifies rpmdbRock, rpmmiRock @*/
+{
+
+ if (rpmdbCheckTerminate(0)) {
+/*@-abstract@*/ /* sigset_t is abstract type */
+ rpmMessage(RPMMESS_DEBUG, D_("Exiting on signal(0x%lx) ...\n"), *((unsigned long *)&rpmsqCaught));
+/*@=abstract@*/
exit(EXIT_FAILURE);
}
- return sigprocmask(SIG_SETMASK, &oldMask, NULL);
+ return 0;
+
}
/**
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/rpmdb.h
============================================================================
$ cvs diff -u -r1.57.2.1 -r1.57.2.2 rpmdb.h
--- rpm/rpmdb/rpmdb.h 30 Jul 2007 03:03:32 -0000 1.57.2.1
+++ rpm/rpmdb/rpmdb.h 30 Jul 2007 12:40:29 -0000 1.57.2.2
@@ -1101,7 +1101,21 @@
/*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
- * Check rpmdb signal handler for trapped signal exit.
+ * Check rpmdb signal handler for trapped signal and/or requested exit.
+ * Clean up any open iterators and databases on termination condition.
+ * On non-zero exit any open references to rpmdb are invalid and cannot
+ * be accessed anymore, calling process should terminate immediately.
+ *
+ * @param terminate 0 to only check for signals, 1 to terminate anyway
+ * @return 0 to continue, 1 if termination cleanup was done.
+ */
+/*@mayexit@*/
+int rpmdbCheckTerminate(int terminate)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
+
+/** \ingroup rpmdb
+ * Check for and exit on termination signals.
*/
/*@mayexit@*/
int rpmdbCheckSignals(void)
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/sqlite.c
============================================================================
$ cvs diff -u -r1.5.2.1 -r1.5.2.2 sqlite.c
--- rpm/rpmdb/sqlite.c 9 Jun 2007 15:47:56 -0000 1.5.2.1
+++ rpm/rpmdb/sqlite.c 30 Jul 2007 12:40:29 -0000 1.5.2.2
@@ -38,6 +38,7 @@
#include "system.h"
#include <rpmlib.h>
+#include <rpmio.h>
#include <rpmmacro.h>
#include <rpmurl.h> /* XXX urlPath proto */
@@ -453,7 +454,7 @@
}
} else
if (!strcmp(vtype, "text")) {
- const char * v = sqlite3_column_text(scp->pStmt, i);
+ const char * v = (const char *)sqlite3_column_text(scp->pStmt, i);
nb = strlen(v) + 1;
if (_debug)
fprintf(stderr, "\t%d %s %s \"%s\"\n", i, cname, vtype, v);
@@ -686,6 +687,38 @@
char cmd[BUFSIZ];
int rc = 0;
+ if (dbi->dbi_tmpdir) {
+ const char *root;
+ const char *tmpdir;
+ root = (dbi->dbi_root ? dbi->dbi_root : dbi->dbi_rpmdb->db_root);
+ /*@-boundsread@*/
+ if ((root[0] == '/' && root[1] == '\0') || dbi->dbi_rpmdb->db_chrootDone)
+ root = NULL;
+ /*@=boundsread@*/
+ /*@-mods@*/
+ tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
+ /*@=mods@*/
+ int xx;
+ sprintf(cmd, "PRAGMA temp_store_directory = '%s';", tmpdir);
+ xx = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
+ tmpdir = _free(tmpdir);
+ }
+ if (dbi->dbi_eflags & DB_EXCL) {
+ int xx;
+ sprintf(cmd, "PRAGMA locking_mode = EXCLUSIVE;");
+ xx = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
+ }
+ if (dbi->dbi_pagesize > 0) {
+ int xx;
+ sprintf(cmd, "PRAGMA cache_size = %d;", dbi->dbi_cachesize);
+ xx = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
+ }
+ if (dbi->dbi_cachesize > 0) {
+ int xx;
+ sprintf(cmd, "PRAGMA page_size = %d;", dbi->dbi_pagesize);
+ xx = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
+ }
+
/* Check if the table exists... */
sprintf(cmd,
"SELECT name FROM 'sqlite_master' WHERE type='table' and name='%s';",
@@ -729,13 +762,15 @@
}
if (_debug)
fprintf(stderr, "\t%s(%d) type(%d) keytype %s\n", tagName(dbi->dbi_rpmtag), dbi->dbi_rpmtag, (tagType(dbi->dbi_rpmtag) & RPM_MASK_TYPE), keytype);
- sprintf(cmd, "CREATE TABLE '%s' (key %s, value %s)",
+ sprintf(cmd, "CREATE %sTABLE '%s' (key %s, value %s)",
+ dbi->dbi_temporary ? "TEMPORARY " : "",
dbi->dbi_subfile, keytype, valtype);
rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
if (rc)
goto exit;
- sprintf(cmd, "CREATE TABLE 'db_info' (endian TEXT)");
+ sprintf(cmd, "CREATE %sTABLE 'db_info' (endian TEXT)",
+ dbi->dbi_temporary ? "TEMPORARY " : "");
rc = sqlite3_exec(sqldb->db, cmd, NULL, NULL, (char **)&scp->pzErrmsg);
if (rc)
goto exit;
@@ -826,6 +861,17 @@
rpmMessage(RPMMESS_DEBUG, D_("closed sql db %s\n"),
dbi->dbi_subfile);
+#if defined(MAYBE) /* XXX should SQLite and BDB have different semantics? */
+ if (dbi->dbi_temporary && !(dbi->dbi_eflags & DB_PRIVATE)) {
+ const char * dbhome = NULL;
+ urltype ut = urlPath(dbi->dbi_home, &dbhome);
+ const char * dbfname = rpmGenPath(dbhome, dbi->dbi_file, NULL);
+ int xx = (dbfname ? Unlink(dbfname) : 0);
+ ut = ut; xx = xx; /* XXX tell gcc to be quiet. */
+ dbfname = _free(dbfname);
+ }
+#endif
+
dbi->dbi_stats = _free(dbi->dbi_stats);
dbi->dbi_file = _free(dbi->dbi_file);
dbi->dbi_db = _free(dbi->dbi_db);
@@ -859,6 +905,7 @@
const char * dbfile;
const char * dbfname;
const char * sql_errcode;
+ mode_t umask_safed = 0002;
dbiIndex dbi;
SQL_DB * sqldb;
size_t len;
@@ -922,7 +969,10 @@
*/
(void) rpmioMkpath(dbhome, 0755, getuid(), getgid());
- dbfname = rpmGenPath(dbhome, dbi->dbi_file, NULL);
+ if (dbi->dbi_eflags & DB_PRIVATE)
+ dbfname = strdup(":memory:");
+ else
+ dbfname = rpmGenPath(dbhome, dbi->dbi_file, NULL);
rpmMessage(RPMMESS_DEBUG, D_("opening sql db %s (%s) mode=0x%x\n"),
dbfname, dbi->dbi_subfile, dbi->dbi_mode);
@@ -931,7 +981,17 @@
sqldb = xcalloc(1, sizeof(*sqldb));
sql_errcode = NULL;
+ if (dbi->dbi_perms)
+ /* mask-out permission bits which are not requested (security) */
+ umask_safed = umask(~((mode_t)(dbi->dbi_perms)));
xx = sqlite3_open(dbfname, &sqldb->db);
+ if (dbi->dbi_perms) {
+ if ((0644 /* = SQLite hard-coded default */ & dbi->dbi_perms) != dbi->dbi_perms) {
+ /* add requested permission bits which are still missing (semantic) */
+ chmod(dbfname, dbi->dbi_perms);
+ }
+ umask(umask_safed);
+ }
if (xx != SQLITE_OK)
sql_errcode = sqlite3_errmsg(sqldb->db);
@@ .
Received on Mon Jul 30 14:40:30 2007