Merge the store-sqlite branch back onto trunk

This commit is contained in:
alexhudson
2008-09-04 15:22:34 +00:00
parent 38f62420e8
commit 29f4eeec4e
75 changed files with 6148 additions and 8645 deletions
+3 -3
View File
@@ -18,6 +18,7 @@
#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <config.h>
#include "config.h"
#include <libintl.h>
@@ -270,12 +271,11 @@ LoadDefaultStoreConfiguration(void)
} else {
XplConsolePrintf(_("Complete.\n"));
}
SetStoreConfigurationModifications(client);
SetStoreConfigurationModifications(client);
nmapcleanup:
NMAPQuit(client->conn);
ConnFree(client->conn);
storecleanup:
storecleanup:
if (kill(store_pid, SIGTERM) != 0) {
XplConsolePrintf(_("ERROR: Couldn't shut down store\n"));
}
+3 -9
View File
@@ -101,17 +101,11 @@ ImportSystemBackupFile(StoreClient *client, const char *path)
BOOL
SetAdminRights(StoreClient *client, char *document) {
CCode ccode;
char *rights = "grant user:admin all;";
ccode = NMAPRunCommandF(client->conn, client->buffer, sizeof(client->buffer),
"PROPSET %s nmap.access-control %d\r\n", document, strlen(rights));
if (ccode == 2002) {
NMAPSendCommandF(client->conn, rights);
ccode = NMAPReadAnswer(client->conn, client->buffer,
sizeof(client->buffer), TRUE);
if (ccode == 1000)
return TRUE;
}
"ACL GRANT %s Pall Tuser Wadmin\r\n", document);
if (ccode == 1000)
return TRUE;
return FALSE;
}
+1 -1
View File
@@ -309,7 +309,7 @@ LoadAgentConfiguration()
BongoArray *agentlist;
unsigned int i;
if (! NMAPReadConfigFile("manager", &config)) {
if (! NMAPReadConfigFile("manager", &config) || (config == NULL)) {
printf(_("bongo-manager: couldn't read config from store\n"));
return FALSE;
}
@@ -61,7 +61,7 @@ class StoreBackupCommand(Command):
usage="%prog %cmd [<output>]")
def GetStoreConnection(self):
return StoreClient(self.user, self.store)
return StoreClient(self.user, self.store, host=self.host, port=int(self.port), authPassword=self.password)
def BackupStore(self):
# create a backup file which contains all the contents of the given store
@@ -102,6 +102,10 @@ class StoreBackupCommand(Command):
if document.type == DocTypes.Conversation or document.type == DocTypes.Calendar:
# DB-only file type, don't attempt to back this up
continue
if collection == '/conversations':
# this is a hack; Bongo 0.3 doesn't seem to mark all conversations
# as such correctly :(
continue
filename = "%s/%s" % (collection, document.filename)
try:
content = docstore.Read(filename)
@@ -117,8 +121,12 @@ class StoreBackupCommand(Command):
headerx.SetKey("BONGO.flags", "%d" % document.flags)
props = docstore.PropGet(document.uid)
for key in props.keys():
headerx.SetKey("BONGO.%s" % key, props[key])
backup_file.write(headerx.ToString().encode("utf-8"))
value = props[key]
if value != None:
headerx.SetKey("BONGO.%s" % key, value.encode("utf-8"))
header_content = headerx.ToString()
backup_file.write(header_content)
# tar files have a 512 byte header (tar_info.tobuf()), and then the content
# content is padded to a multiple of 512 bytes
@@ -131,7 +139,6 @@ class StoreBackupCommand(Command):
space = len(content) % 512
if space != 0:
backup_file.write("\0" * (512 - space))
store.Quit()
docstore.Quit()
@@ -144,7 +151,10 @@ class StoreBackupCommand(Command):
self.print_help()
self.exit()
self.host = options.host
self.port = options.port
self.user = options.user
self.password = options.password
self.store = options.store
self.BackupStore()
@@ -210,8 +220,16 @@ class StoreRestoreCommand(Command):
del metadata["BONGO.nmap.flags"]
del metadata["BONGO.nmap.collection"]
del metadata["BONGO.nmap.index"]
if "BONGO.uid" in metadata:
del metadata["BONGO.uid"]
if "BONGO.type" in metadata:
del metadata["BONGO.type"]
if "BONGO.flags" in metadata:
del metadata["BONGO.flags"]
if "BONGO.imapuid" in metadata:
del metadata["BONGO.imapuid"]
for key, value in metadata.items():
if key[0:10] == "BONGO.nmap":
if key[0:6] == "BONGO.":
prop = key[6:]
try:
store.PropSet(guid, prop, value)
@@ -236,7 +254,7 @@ class StoreRestoreCommand(Command):
del metadata["BONGO.type"]
try:
new_guid = store.Write(collection, file_type, content, filename=filename, guid=file_guid)
new_guid = store.Write(collection, file_type, content, filename=filename, guid=file_guid, noProcess=True)
except:
print "Failed to restore %s/%s" % (collection, filename)
return
@@ -253,6 +271,7 @@ class StoreRestoreCommand(Command):
try:
if "BONGO.uid" in metadata:
store.Create(collection, guid=metadata["BONGO.uid"])
del metadata["BONGO.uid"]
else:
store.Create(collection)
except: