Store server cred on disk so we don't need to access MDB to get it
This commit is contained in:
@@ -74,6 +74,24 @@ StoreAgentReadConfiguration(BOOL *recover)
|
||||
if (!MsgGetServerCredential(StoreAgent.server.hash))
|
||||
// can't proceed without the server hash..
|
||||
return(FALSE);
|
||||
{
|
||||
char buffer[10000];
|
||||
int i;
|
||||
memset(&buffer, 0, 100);
|
||||
MsgAlex(&buffer);
|
||||
XplConsolePrintf("Mine: ", buffer);
|
||||
for(i = 0; i < 20; i++) {
|
||||
XplConsolePrintf("%x", buffer[i]);
|
||||
}
|
||||
XplConsolePrintf("\n");
|
||||
memset(&buffer, 0, 100);
|
||||
MsgGetServerCredential(&buffer);
|
||||
XplConsolePrintf("Orig: ", buffer);
|
||||
for(i = 0; i < 20; i++) {
|
||||
XplConsolePrintf("%x", buffer[i]);
|
||||
}
|
||||
XplConsolePrintf("\n");
|
||||
}
|
||||
|
||||
if (recover && MsgGetRecoveryFlag()) {
|
||||
*recover = TRUE;
|
||||
|
||||
@@ -115,13 +115,16 @@ class SetupCredentialCommand(Command):
|
||||
mdb = MdbUtil.GetSetupMdb(options)
|
||||
|
||||
passwd = Util.GeneratePassword(32)
|
||||
credential = Util.GeneratePassword(4096)
|
||||
|
||||
omask = os.umask(0077)
|
||||
|
||||
eclients = os.path.join(Xpl.DEFAULT_DBF_DIR, "eclients.dat")
|
||||
credfile = os.path.join(Xpl.DEFAULT_DBF_DIR, "credential.dat")
|
||||
|
||||
try:
|
||||
os.remove(eclients)
|
||||
os.remove(credfile)
|
||||
except os.error:
|
||||
pass
|
||||
|
||||
@@ -129,14 +132,18 @@ class SetupCredentialCommand(Command):
|
||||
fd.write(passwd)
|
||||
fd.write("\0")
|
||||
fd.close()
|
||||
|
||||
fd = open(credfile, "w")
|
||||
fd.write(credential)
|
||||
fd.write("\0")
|
||||
fd.close()
|
||||
|
||||
os.umask(omask)
|
||||
|
||||
mdb.SetPassword(msgapi.GetConfigProperty(msgapi.MESSAGING_SERVER),
|
||||
passwd)
|
||||
passwd = Util.GeneratePassword(4096)
|
||||
mdb.SetAttribute(msgapi.GetConfigProperty(msgapi.BONGO_SERVICES),
|
||||
msgapi.A_ACL, [passwd])
|
||||
msgapi.A_ACL, [credential])
|
||||
|
||||
class SetupSslCommand(Command):
|
||||
log = logging.getLogger("bongo.admintool")
|
||||
|
||||
@@ -40,6 +40,26 @@ usage(void) {
|
||||
"";
|
||||
|
||||
XplConsolePrintf("%s", text);
|
||||
|
||||
{
|
||||
char buffer[10000];
|
||||
int i;
|
||||
MsgInit();
|
||||
memset(&buffer, 0, 100);
|
||||
MsgAlex(&buffer);
|
||||
XplConsolePrintf("Mine: ", buffer);
|
||||
for(i = 0; i < 20; i++) {
|
||||
XplConsolePrintf("%x", buffer[i]);
|
||||
}
|
||||
XplConsolePrintf("\n");
|
||||
memset(&buffer, 0, 100);
|
||||
MsgGetServerCredential(&buffer);
|
||||
XplConsolePrintf("Orig: ", buffer);
|
||||
for(i = 0; i < 20; i++) {
|
||||
XplConsolePrintf("%x", buffer[i]);
|
||||
}
|
||||
XplConsolePrintf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+16
-29
@@ -165,19 +165,7 @@ MsgNmapChallenge(const unsigned char *response, unsigned char *reply, size_t len
|
||||
MDBValueStruct *v;
|
||||
xpl_hash_context ctx;
|
||||
|
||||
if (access[0] == '\0') {
|
||||
if (MsgGlobal.directoryHandle) {
|
||||
v = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
if (v) {
|
||||
MDBRead(MSGSRV_ROOT, MSGSRV_A_ACL, v);
|
||||
if (v->Used) {
|
||||
HashCredential(MsgGlobal.server.dn, v->Value[0], access);
|
||||
}
|
||||
|
||||
MDBDestroyValueStruct(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgGetServerCredential(&access);
|
||||
|
||||
if (access[0] && reply && (length > 32) && ((ptr = strchr(response, '<')) != NULL)) {
|
||||
salt = ++ptr;
|
||||
@@ -855,12 +843,11 @@ MsgLibraryStart(void)
|
||||
MDBFreeValues(MsgGlobal.vs.server.names);
|
||||
MsgGlobal.address.local = inet_addr(MsgGlobal.address.string);
|
||||
|
||||
MDBFreeValues(config);
|
||||
// MDBFreeValues(config);
|
||||
|
||||
LoadContextList(config);
|
||||
|
||||
MDBDestroyValueStruct(config);
|
||||
//LoadContextList(config);
|
||||
|
||||
// MDBDestroyValueStruct(config);
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
@@ -1175,18 +1162,18 @@ MsgGetRecoveryFlag(void)
|
||||
EXPORT BOOL
|
||||
MsgGetServerCredential(char *buffer)
|
||||
{
|
||||
MDBValueStruct *v;
|
||||
unsigned char credential[4097];
|
||||
unsigned char file[120];
|
||||
FILE *credfile;
|
||||
|
||||
if (MsgGlobal.directoryHandle) {
|
||||
v = MDBCreateValueStruct(MsgGlobal.directoryHandle, NULL);
|
||||
if (v) {
|
||||
MDBRead(MSGSRV_ROOT, MSGSRV_A_ACL, v);
|
||||
if (v->Used) {
|
||||
HashCredential(MsgGlobal.server.dn, v->Value[0], buffer);
|
||||
}
|
||||
MDBDestroyValueStruct(v);
|
||||
return TRUE;
|
||||
}
|
||||
memset(credential, 0, sizeof(credential));
|
||||
|
||||
sprintf(file, "%s/credential.dat", XPL_DEFAULT_DBF_DIR);
|
||||
credfile = fopen(file, "rb");
|
||||
if (credfile) {
|
||||
fread(credential, sizeof(unsigned char), sizeof(credential), credfile);
|
||||
fclose(credfile);
|
||||
credfile = NULL;
|
||||
HashCredential(MsgGlobal.server.dn, credential, buffer);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user