コード例 #1
0
ファイル: chown.cpp プロジェクト: arrrrrrr/ebftpd
util::Error LookupOwner(const std::string& user, const std::string& group, fs::Owner& owner)
{
  auto dbConfig = config->Database();  
  try
  {
    mongo::DBClientConnection conn;
    conn.connect(dbConfig.Host());
    if (!dbConfig.Login().empty())
    {
      std::string errmsg;
      if (!conn.auth(dbConfig.Name(), dbConfig.Login(), dbConfig.Password(), errmsg))
        throw mongo::DBException("Authentication failed", 0);
    }
    
    owner = fs::Owner(user.empty() ? -1 : LookupUID(conn, user),
                      group.empty() ? -1 : LookupGID(conn, group));
  }
  catch (const mongo::DBException& e)
  {
    return util::Error::Failure(e.what());
  }
  catch (const util::RuntimeError& e)
  {
    return util::Error::Failure(e.Message());
  }
  
  return util::Error::Success();
}
コード例 #2
0
ファイル: FileSystem.c プロジェクト: ColumPaget/Movgrab
int FileChOwner(const char *FileName, const char *Owner)
{
int uid, result;

uid=LookupUID(Owner);
if (uid > -1) 
{
	result=chown(FileName, uid, -1);
	if (result==0) return(TRUE);
}
RaiseError(ERRFLAG_ERRNO, "FileChOwner", "failed to change owner to user=%s uid=%d",Owner,uid);
return(FALSE);
}
コード例 #3
0
static LRESULT CALLBACK myspace_links_watcherwndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch (msg) {
        case WM_COPYDATA:
        {
            char *szData, *s;
            COPYDATASTRUCT *cds = (COPYDATASTRUCT *) lParam;

            //LOG(LOG_DEBUG, "Links: WM_COPYDATA");
            // Check to see if link support is enabled
            // We shouldn't need this check since the class instance shouldn't be running
            // but lets be safe
            if (!DBGetContactSettingByte(NULL, MODULE, "EnableLinkHandling", 0))
                break;
            if (!(char *) cds->lpData)
                break;
            s = szData = strdup((char *) cds->lpData);

            s += 5;
			if (!_strnicmp(s, "addContact?", 11)) {
				s =strstr(s, "cID=");
				if(s) {
					s += 4;
					char *t = strchr(s, '&');
					if(t) *t = 0;
					
					HANDLE hContact;
					int uid;
					for(t = strtok(s, ","); t ;t = strtok(0, ",")) {
						uid = atoi(t);
						hContact = FindContact(uid);
						if(!hContact) {
							hContact = CreateContact(uid, 0, 0, true);
							LookupUID(uid);
						}
					}
				}
			}
            else if (_strnicmp(s, "sendIM?", 7) == 0 && ServiceExists(MS_MSG_SENDMESSAGE))
			{
				s=strrchr(s, '=');
				if(s) {
					s++;
					int uid = atoi(s);

					HANDLE hContact = FindContact(uid);
					if(!hContact) {
						hContact = CreateContact(uid, 0, 0, false);
						DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1);
						DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
						LookupUID(uid);
					}
					CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
				}
			}

			free(szData);
        }
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}