コード例 #1
0
ファイル: postinst.cpp プロジェクト: surfnzdotcom/cvsnt-fork
void MigrateCvsPass()
{
    std::string path = GetHomeDirectory();
    char line[1024],*key,*pw;

    if(!path.size())
        return; /* Nothing to migrate */

    path+="\\.cvspass";
    FILE *f = fopen(path.c_str(),"r");
    if(!f)
        return; /* No .cvspass file */

    while(fgets(line,1024,f)>0)
    {
        line[strlen(line)-1]='\0';
        key = strtok(line," ");
        if(key && key[0]=='/') /* This was added in 1.11.1.  Not sure why. */
            key=strtok(NULL," ");
        if(key)
            pw=key+strlen(key)+1;
        if(key && pw)
            WriteRegistryKey("cvspass",key,pw);
    }

    fclose(f);

    /* We might as well delete now.  cvsnt hasn't used this file for 3 years and
           the repeated migrations on upgrade will be confusing things. */
    DeleteFile(path.c_str());
}
コード例 #2
0
ファイル: persistent.cpp プロジェクト: prey/new-lock
bool PersistentSystemOptions::WriteToStorage() const
{
  char* sid = getSid();
  std::string options = "\\PersistentSystemOptions";
  std::string sep = "\\";
  std::string dest = sid + sep + REGISTRY_SETTINGS_LOCATION + options;
  bool allWorked = true;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasChangePassword"), hasChangePassword))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasLockComputer"), hasLockComputer))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasLogOff"), hasLogOff))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasSwitchUser"), hasSwitchUser))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasTaskManager"), hasTaskManager))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasPower"), hasPower))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasFilterKeysHotkey"), hasFilterKeysHotkey))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasMouseKeysHotkey"), hasMouseKeysHotkey))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasStickyKeysHotkey"), hasStickyKeysHotkey))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasToggleKeysHotkey"), hasToggleKeysHotkey))
    allWorked = false;

  if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasHighContrastHotkey"), hasHighContrastHotkey))
    allWorked = false;
    
   if(!WriteRegistryKey(HKEY_USERS, _T(dest), _T("hasFastBootHotkey"), !hasFastBootHotKey))
    allWorked = false;

  return allWorked;
}
コード例 #3
0
ファイル: persistent.cpp プロジェクト: prey/new-lock
bool PersistentSystemOptions::WriteSystemSettings() const
{
  bool allWorked = true;
  char* sid = getSid();
  std::string system = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
  std::string explorer = "\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer";
  std::string power = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power";

  //if(!sid = getSid()) {
  //  return false;
  //}

  if(!WriteRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableChangePassword"), !hasChangePassword)) {
    allWorked = false;
    Tcout << _T("Error DisableChangePassword") << std::endl;
  }

  if(!WriteRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableLockWorkstation"), !hasLockComputer)) {
    allWorked = false;
    Tcout << _T("Error DisableLockWorkstation") << std::endl;
  }

  if(!WriteRegistryKey(HKEY_USERS, _T(sid + explorer), _T("NoLogoff"), !hasLogOff)) {
    allWorked = false;
    Tcout << _T("Error NoLogoff") << std::endl;
  }

  if(!WriteRegistryKey(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"), _T("HideFastUserSwitching"), !hasSwitchUser)) {
    allWorked = false;
    Tcout << _T("Error HideFastUserSwitching") << std::endl;
  }

#ifndef DEBUG

  if(!WriteRegistryKey(HKEY_USERS, _T(sid + system), _T("DisableTaskMgr"), !hasTaskManager)) {
    allWorked = false;
    Tcout << _T("Error DisableTaskMgr") << std::endl;
  }

#endif // DEBUG

  if(!WriteRegistryKey(HKEY_USERS, _T(sid + explorer), _T("NoClose"), !hasPower)) {
    allWorked = false;
    Tcout << _T("Error NoClose") << std::endl;
  }

  if(!WriteFilterKeysHotkey(hasFilterKeysHotkey)) {
    allWorked = false;
    Tcout << _T("Error FilterKeysHotkey") << std::endl;
  }

  if(!WriteMouseKeysHotkey(hasMouseKeysHotkey)) {
    allWorked = false;
    Tcout << _T("Error MouseKeysHotkey") << std::endl;
  }

  if(!WriteStickyKeysHotkey(hasStickyKeysHotkey)) {
    allWorked = false;
    Tcout << _T("Error StickyKeysHotkey") << std::endl;
  }

  if(!WriteToggleKeysHotkey(hasToggleKeysHotkey)) {
    allWorked = false;
    Tcout << _T("Error ToggleKeysHotkey") << std::endl;
  }

  if(!WriteHighContrastHotkey(hasHighContrastHotkey)) {
    allWorked = false;
    Tcout << _T("Error HighContrastHotkey") << std::endl;
  }
  
 if(!WriteRegistryKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power"), _T("HiberbootEnabled"), hasFastBootHotKey)) {
    allWorked = false;
    Tcout << _T("Error FastBootHotKey") << std::endl;
  }

  return allWorked;
}