// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::FetchLeafObjectSizeL // Fetches leaf object size. // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& /* aType */, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: Start" ); LOGSTRING3( "\tFetchLeafObjectSizeL \tURI: %S, \tLUID: %S,", &aURI, &aLUID ); CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( ETrue, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetSizeCmd, LastURISeg( aURI ), KNullDesC8); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); // if executed get status if ( cmd->Executed() ) { Callback().SetStatusL( aStatusRef, cmd->Status() ); // if successful get results if ( cmd->Status() == CSmlDmAdapter::EOk ) { LOGSTRING2( "\tCmd executed with result: %S ", cmd->Data() ); CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() ); CleanupStack::PushL( result ); result->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *result, KNullDesC8 ); CleanupStack::PopAndDestroy( result ); } } else { // failed to execute command Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); } CleanupStack::PopAndDestroy( cmd ); LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: End" ); }
// ------------------------------------------------------------------------ // CNSmlDmAOAdapter::ChildURIListL // Fetches child nodes of a node. these may be either all VENDORCONFIG // nodes or leaf nodes under a VENDORCONFIG node. // ------------------------------------------------------------------------ void CNSmlDmAOAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: Start" ); LOGSTRING3( "\tChildURIListL URI: %S, LUID: %S ", &aURI, &aLUID ); CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen ); CleanupStack::PushL( resultList ); // get all leaf nodes below VENDORCONFIG node if ( !aURI.Compare( KNSmlDmAOAdapterAO ) ) { CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( EFalse, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetCmd, KNullDesC8, KNullDesC8 ); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); Callback().SetStatusL( aStatusRef, cmd->Status() ); if( cmd->Status() == CSmlDmAdapter::EOk ) { resultList->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *resultList, KNullDesC8 ); } CleanupStack::PopAndDestroy( cmd ); } CleanupStack::PopAndDestroy( resultList ); LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: End" ); }
// ------------------------------------------------------------------------- // CNSmlDmAOAdapter::UpdateLeafObjectL // Adds or updates leaf node value. // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& /*aType*/, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: Start" ); LOGSTRING4( "\tUpdateLeafObjectL \tURI: %S, \n\tLUID: %S,\ \tobject: %S ", &aURI, &aLUID, &aObject ); // execute command and return status CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( ETrue, aStatusRef, KNSmlDmAOInvalidRef, CNSmlDmAOAdapter::EAddCmd, LastURISeg( aURI ), aObject); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d", cmd->Status() ); Callback().SetStatusL( aStatusRef, cmd->Status() ); CleanupStack::PopAndDestroy( cmd ); LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: End" ); }
void auth_user(nfs_mount * mp, struct svc_req *rqstp) { uid_t cuid; gid_t cgid; GETGROUPS_T cgids[NGRPS]; int squash = mp->o.all_squash; int cred_set, i, clen; cred_set = 0; if (rqstp->rq_cred.oa_flavor == AUTH_UNIX) { struct authunix_parms *unix_cred; unix_cred = (struct authunix_parms *) rqstp->rq_clntcred; cred_uid = (uid_t) unix_cred->aup_uid; cred_gid = (gid_t) unix_cred->aup_gid; cred_len = ((unix_cred->aup_len >= 0) ? (int) unix_cred->aup_len : 0); cred_gids = (gid_t *) unix_cred->aup_gids; cred_set = 1; #ifdef HAVE_AUTHDES_GETUCRED } else if (rqstp->rq_cred.oa_flavor == AUTH_DES) { static GETGROUPS_T des_gids[NGRPS]; struct authdes_cred *cred; short grplen = NGRPS; int i; cred = (struct authdes_cred *) rqstp->rq_clntcred; i = authdes_getucred(cred, &cred_uid, &cred_gid, &grplen, des_gids); if (i != 0 && grplen >= 0) { cred_set = 1; cred_len = grplen; cred_gids = des_gids; if (cred_len > NGRPS) cred_len = NGRPS; } #endif } /* We will want to support AUTH_DES/AUTH_KRB one day, * but for now we treat all other authentication flavor * as AUTH_NULL. */ if (!cred_set) squash = 1; if (!squash) { /* Do the uid/gid mapping here. * Note that we check cred_uid (which is the native uid_t), * not unix_cred->aup_uid to avoid the uid masking bug. */ if (cred_len < 0) cred_len = 0; else if (cred_len > NGRPS) cred_len = NGRPS; cuid = luid(cred_uid, mp, rqstp); cgid = lgid(cred_gid, mp, rqstp); clen = cred_len; for (i = 0; i < cred_len; i++) cgids[i] = lgid(cred_gids[i], mp, rqstp); } else { /* On systems that have 32bit uid_t in user space but * 16bit in the kernel, we need to truncate the * nobody ID (default -2). */ #if !defined(HAVE_BROKEN_SETFSUID) cuid = mp->o.nobody_uid; cgid = mp->o.nobody_gid; #else cuid = (unsigned short) mp->o.nobody_uid; cgid = (unsigned short) mp->o.nobody_gid; #endif /* Construct a list of one gid. */ cgids[0] = cgid; clen = 1; } /* This code is a little awkward because setfsuid has been present * in the Linux kernel for quite some time but not in libc. * The startup code tests for the setfsuid syscall and sets * have_setfsuid accordingly. * * The code becomes even more awkward as of glibc 2.1 because * we now have 32bit user-land uid_t, 16bit kernel uid_t, and * a setfsuid function that rejects any uids that have the * upper 16 bits set (including our default nobody uid -2). */ #if defined(HAVE_SETFSUID) setfsids(cuid, cgid, cgids, clen); #else #if defined(MAYBE_HAVE_SETFSUID) if (have_setfsuid) setfsids(cuid, cgid, cgids, clen); else #endif seteids(cuid, cgid, cgids, clen); #endif }
void ActiveSyncSource::beginSync(const std::string &lastToken, const std::string &resumeToken) { // erase content which might have been set in a previous call reset(); // claim item node for ids, if not done yet if (m_itemNode && !m_ids) { m_ids.swap(m_itemNode); } // incremental sync (non-empty token) or start from scratch m_startSyncKey = lastToken; if (lastToken.empty()) { // slow sync: wipe out cached list of IDs, will be filled anew below SE_LOG_DEBUG(this, NULL, "sync key empty, starting slow sync"); m_ids->clear(); } else { SE_LOG_DEBUG(this, NULL, "sync key %s for account '%s' folder '%s', starting incremental sync", lastToken.c_str(), m_account.c_str(), m_folder.c_str()); } gboolean moreAvailable = TRUE; m_currentSyncKey = m_startSyncKey; // same logic as in ActiveSyncCalendarSource::beginSync() bool slowSync = false; for (bool firstIteration = true; moreAvailable; firstIteration = false) { gchar *buffer = NULL; GErrorCXX gerror; EASItemsCXX created, updated; EASIdsCXX deleted; bool wasSlowSync = m_currentSyncKey.empty(); if (!eas_sync_handler_get_items(m_handler, m_currentSyncKey.c_str(), &buffer, getEasType(), m_folder.c_str(), created, updated, deleted, &moreAvailable, gerror)) { if (gerror.m_gerror && /* gerror.m_gerror->domain == EAS_TYPE_CONNECTION_ERROR && gerror.m_gerror->code == EAS_CONNECTION_SYNC_ERROR_INVALIDSYNCKEY && */ gerror.m_gerror->message && strstr(gerror.m_gerror->message, "Sync error: Invalid synchronization key") && firstIteration) { // fall back to slow sync slowSync = true; m_currentSyncKey = ""; m_ids->clear(); continue; } gerror.throwError("reading ActiveSync changes"); } GStringPtr bufferOwner(buffer, "reading changes: empty sync key returned"); // TODO: Test that we really get an empty token here for an unexpected slow // sync. If not, we'll start an incremental sync here and later the engine // will ask us for older, unmodified item content which we won't have. // populate ID lists and content cache BOOST_FOREACH(EasItemInfo *item, created) { if (!item->server_id) { throwError("no server ID for new eas item"); } string luid(item->server_id); if (luid.empty()) { throwError("empty server ID for new eas item"); } SE_LOG_DEBUG(this, NULL, "new item %s", luid.c_str()); addItem(luid, NEW); m_ids->setProperty(luid, "1"); if (!item->data) { throwError(StringPrintf("no body returned for new eas item %s", luid.c_str())); } m_items[luid] = item->data; } BOOST_FOREACH(EasItemInfo *item, updated) { if (!item->server_id) { throwError("no server ID for updated eas item"); } string luid(item->server_id); if (luid.empty()) { throwError("empty server ID for updated eas item"); } SE_LOG_DEBUG(this, NULL, "updated item %s", luid.c_str()); addItem(luid, UPDATED); // m_ids.setProperty(luid, "1"); not necessary, should already exist (TODO: check?!) if (!item->data) { throwError(StringPrintf("no body returned for updated eas item %s", luid.c_str())); } m_items[luid] = item->data; } BOOST_FOREACH(const char *serverID, deleted) { if (!serverID) { throwError("no server ID for deleted eas item"); } string luid(serverID); if (luid.empty()) { throwError("empty server ID for deleted eas item"); } SE_LOG_DEBUG(this, NULL, "deleted item %s", luid.c_str()); addItem(luid, DELETED); m_ids->removeProperty(luid); } // update key m_currentSyncKey = buffer; // Google hack: if we started with an empty sync key (= slow sync) // and got no results (= existing items), then try one more time, // because Google only seems to report results when asked with // a valid sync key. As an additional sanity check make sure that // we have a valid sync key now. if (wasSlowSync && created.empty() && !m_currentSyncKey.empty()) { moreAvailable = true; } } // now also generate full list of all current items: // old items + new (added to m_ids above) - deleted (removed above) ConfigProps props; m_ids->readProperties(props); BOOST_FOREACH(const StringPair &entry, props) { const std::string &luid = entry.first; SE_LOG_DEBUG(this, NULL, "existing item %s", luid.c_str()); addItem(luid, ANY); } if (slowSync) { // tell engine that we need a slow sync, if it didn't know already SE_THROW_EXCEPTION_STATUS(StatusException, "ActiveSync error: Invalid synchronization key", STATUS_SLOW_SYNC_508); } }