void MailboxReader::execute() { while ( q->hasResults() ) { Row * r = q->nextRow(); UString n = r->getUString( "name" ); uint id = r->getInt( "id" ); Mailbox * m = ::mailboxes->find( id ); if ( !m || m->name() != n ) { m = Mailbox::obtain( n ); if ( n != m->d->name ) m->d->name = n; m->setId( id ); ::mailboxes->insert( id, m ); } if ( r->getBoolean( "deleted" ) ) m->setType( Mailbox::Deleted ); else m->setType( Mailbox::Ordinary ); uint uidvalidity = r->getInt( "uidvalidity" ); if ( m->d->uidvalidity != uidvalidity ) { m->d->uidvalidity = uidvalidity; m->abortSessions(); } if ( !r->isNull( "owner" ) ) m->setOwner( r->getInt( "owner" ) ); m->setUidnextAndNextModSeq( r->getInt( "uidnext" ), r->getBigint( "nextmodseq" ), q->transaction() ); m->setFlag( r->getEString( "flag" ) ); } if ( !q->done() || done ) return; done = true; if ( q->transaction() ) q->transaction()->commit(); ::readers->remove( this ); ::wiped = false; if ( q->failed() && !EventLoop::global()->inShutdown() ) { List<Mailbox> * c = Mailbox::root()->children(); if ( c && !c->isEmpty() ) log( "Couldn't update mailbox tree: " + q->error() ); else log( "Couldn't create mailbox tree: " + q->error(), Log::Disaster ); } if ( owner ) owner->execute(); };
void execute() { if ( !q ) { q = new Query( "select not exists (select * from " "information_schema.table_privileges where " "privilege_type='DELETE' and table_name=" "'messages' and grantee=$1) and not exists " "(select u.usename from pg_catalog.pg_class c " "left join pg_catalog.pg_user u on " "(u.usesysid=c.relowner) where c.relname=" "'messages' and u.usename=$1) as allowed", this ); q->bind( 1, Configuration::text( Configuration::DbUser ) ); q->execute(); } if ( !q->done() ) return; Row * r = q->nextRow(); if ( q->failed() || !r || r->getBoolean( "allowed" ) == false ) { EString s( "Refusing to start because we have too many " "privileges on the messages table in secure " "mode." ); result->setError( s ); l->log( s, Log::Disaster ); if ( q->failed() ) { l->log( "Query: " + q->description(), Log::Disaster ); l->log( "Error: " + q->error(), Log::Disaster ); } } else { result->setState( Query::Completed ); } result->notify(); }