Exemple #1
0
int main(int argc, char *argv[])
{
    GenericAgentConfig *config = CheckOpts(argc, argv);

    THIS_AGENT_TYPE = AGENT_TYPE_KEYGEN;

    ReportContext *report_context = OpenReports("keygenerator");
    GenericInitialize("keygenerator", config, report_context);

    if (SHOWHOSTS)
    {
        ShowLastSeenHosts();
        return 0;
    }

    if (REMOVEKEYS)
    {
        return RemoveKeys(remove_keys_host);
    }

    if(LICENSE_INSTALL)
    {
        bool success = LicenseInstall(LICENSE_SOURCE);
        return success ? 0 : 1;
    }

    KeepKeyPromises();

    ReportContextDestroy(report_context);
    GenericAgentConfigDestroy(config);
    return 0;
}
Exemple #2
0
int main(int argc, char *argv[])
{
    EvalContext *ctx = EvalContextNew();

    GenericAgentConfig *config = CheckOpts(argc, argv);
    GenericAgentConfigApply(ctx, config);

    ReportContext *report_context = OpenReports(ctx, config->agent_type);
    GenericAgentDiscoverContext(ctx, config, report_context);

    if (SHOWHOSTS)
    {
        ShowLastSeenHosts();
        return 0;
    }

    if (print_digest_arg)
    {
        return PrintDigest(print_digest_arg);
    }

    if (REMOVEKEYS)
    {
        return RemoveKeys(remove_keys_host);
    }

    if(LICENSE_INSTALL)
    {
        bool success = LicenseInstall(LICENSE_SOURCE);
        return success ? 0 : 1;
    }

    if (trust_key_arg)
    {
        return TrustKey(trust_key_arg);
    }

    char *public_key_file, *private_key_file;

    if (KEY_PATH)
    {
        xasprintf(&public_key_file, "%s.pub", KEY_PATH);
        xasprintf(&private_key_file, "%s.priv", KEY_PATH);
    }
    else
    {
        public_key_file = xstrdup(PublicKeyFile());
        private_key_file = xstrdup(PrivateKeyFile());
    }

    KeepKeyPromises(public_key_file, private_key_file);

    free(public_key_file);
    free(private_key_file);

    ReportContextDestroy(report_context);
    GenericAgentConfigDestroy(config);
    EvalContextDestroy(ctx);
    return 0;
}
Exemple #3
0
int main(int argc,char *argv[])

{
CheckOpts(argc,argv);

THIS_AGENT_TYPE = cf_keygen;

GenericInitialize(argc,argv,"keygenerator");

if (SHOWHOSTS)
   {
   ShowLastSeenHosts();
   return 0; 	
   }

if (REMOVEKEYS)
   {
   return RemoveKeys(remove_keys_host);
   }

KeepKeyPromises();
return 0;
}
void GProperty::Clear() {

	RemoveKeys();
	DeleteProperties();
}
void ReduceKeysByWaypointList(void)
{
#define MAX_SEL_LIST_SIZE	60
char SelList[MAX_SEL_LIST_SIZE]={""};
unsigned int NumChar=0;
bool CharEqual = true;
char Charlist[MAX_SEL_LIST_SIZE]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.@-_ \xD6\xDC\xC4"};

unsigned int i,j,EqCnt=WayPointList.size();


WndProperty *wp;
TCHAR Found[NAME_SIZE + 1];
SelList[0] = '\0';
unsigned int NameLen=0;
 int Offset=0;
unsigned int k =0;
IdenticalOffset =999;
IdenticalIndex = -1;
  if(cursor < GC_SUB_STRING_THRESHOLD/*1*/)   /* enable all keys if no char entered */
  {
    RemoveKeys((char*)Charlist, sizeof(Charlist));
  }
  else
  {
    EqCnt=0; /* reset number of found waypoints */
    NumChar =0;
    for (i=NUMRESWP; i< WayPointList.size(); i++)
    {
      NameLen =  _tcslen(WayPointList[i].Name);
      Offset = 0;
      if(cursor > NameLen)
	CharEqual = false;
      else
      {
        do
        {
          k=0;
          CharEqual = true;
          while((k < (cursor)) && ((k+Offset) < NameLen) && CharEqual)
          {
            LKASSERT(k < MAX_TEXTENTRY);
            LKASSERT((k+Offset) < NameLen);
            char ac = (char)WayPointList[i].Name[k+Offset];
            char bc = (char)edittext[k];
            if(  ToUpper(ac) !=   ToUpper(bc) ) /* waypoint has string ?*/
            {
              CharEqual = false;
            }
            k++;
          }
          Offset++;
        }
        while(((Offset-1+cursor) < NameLen) && !CharEqual );
        Offset--;
      }


      if(CharEqual)
      {

	if(Offset < IdenticalOffset)
        {
          IdenticalIndex = i; /* remember first found equal name */
          IdenticalOffset = Offset; /* remember first found equal name */
		   // StartupStore(_T("Found Best Fit %i Idx %i %s\n"), i, IdenticalIndex, WayPointList[IdenticalIndex].Name);
        }
        EqCnt++;
        LKASSERT((cursor+Offset)<=NAME_SIZE);
        LKASSERT(i<=WayPointList.size());
        TCHAR newChar = ToUpper(WayPointList[i].Name[cursor+Offset]);
        bool existing = false;
        j=0;
        while(( j < NumChar) && (!existing))  /* new character already in list? */
        {
     //     StartupStore(_T(". j=%i  MAX_SEL_LIST_SIZE= %i\n"),j,MAX_SEL_LIST_SIZE);
          LKASSERT(j<MAX_SEL_LIST_SIZE);
          if(SelList[j] == (unsigned char)newChar)
		existing = true;
          j++;
        }

        if(!existing && (NumChar <MAX_SEL_LIST_SIZE))  /* add new character to key enable list */
        {
     //     StartupStore(_T(". j=%i  MAX_SEL_LIST_SIZE= %i\n"),j,MAX_SEL_LIST_SIZE);
          LKASSERT(NumChar<MAX_SEL_LIST_SIZE);
          SelList[NumChar++] = newChar;
        }
      }
    }

    SelList[NumChar++] = '\0';
    RemoveKeys((char*)SelList, NumChar);
    wp = (WndProperty*)wf->FindByName(TEXT("prpText"));

    if (wp)
    {
      if(EqCnt ==1)
      {
	LKASSERT(IdenticalIndex<= (int)WayPointList.size());
	    wp->SetText(WayPointList[IdenticalIndex].Name);
      }
      else
      {
        if((cursor >0) &&  (EqCnt >0))
        {
          LKASSERT(cursor < NAME_SIZE);
          LKASSERT(IdenticalIndex<=(int)WayPointList.size());
          _stprintf(Found,_T("%s"),WayPointList[IdenticalIndex].Name);
	  for( i = 0; i < cursor; i++)
	     Found[i+IdenticalOffset] = toupper(WayPointList[IdenticalIndex].Name[i+IdenticalOffset]);
          wp->SetText(Found);
        }
      }
    }
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpMatch"));
  if (wp)
  {
    _stprintf(Found,_T("%s:%i"),MsgToken(948),EqCnt); /* _@M948_ Found */
    wp->SetCaption(Found);
  }
}
Exemple #6
0
int main(int argc, char *argv[])
{
    SetupSignalsForCfKey(HandleSignalsForAgent);

    GenericAgentConfig *config = CheckOpts(argc, argv);
    EvalContext *ctx = EvalContextNew();
    GenericAgentConfigApply(ctx, config);

    GenericAgentDiscoverContext(ctx, config);

    if (SHOWHOSTS)
    {
        SetupSignalsForCfKey(handleShowKeysSignal);
        ShowLastSeenHosts();
        return 0;
    }

    if (print_digest_arg)
    {
        return PrintDigest(print_digest_arg);
    }

    GenericAgentPostLoadInit(ctx);

    if (REMOVEKEYS)
    {
        int status;
        if (FORCEREMOVAL)
        {
            if (!strncmp(remove_keys_host, "SHA=", 3) ||
                !strncmp(remove_keys_host, "MD5=", 3))
            {
                status = ForceKeyRemoval(remove_keys_host);
            }
            else
            {
                status = ForceIpAddressRemoval(remove_keys_host);
            }
        }
        else
        {
            status = RemoveKeys(remove_keys_host, true);
            if (status == 0 || status == 1)
            {
                Log (LOG_LEVEL_VERBOSE,
                    "Forced removal of entry '%s' was successful",
                    remove_keys_host);
                return 0;
            }
        }
        return status;
    }

    if(LICENSE_INSTALL)
    {
        bool success = LicenseInstall(LICENSE_SOURCE);
        return success ? 0 : 1;
    }

    if (trust_key_arg != NULL)
    {
        char *filename, *ipaddr, *username;
        /* We will modify the argument to --trust-key. */
        char *arg = xstrdup(trust_key_arg);

        ParseKeyArg(arg, &filename, &ipaddr, &username);

        /* Server IP address required to trust key on the client side. */
        if (ipaddr == NULL)
        {
            Log(LOG_LEVEL_NOTICE, "Establishing trust might be incomplete. "
                "For completeness, use --trust-key IPADDR:filename");
        }

        bool ret = TrustKey(filename, ipaddr, username);

        free(arg);
        return ret ? EXIT_SUCCESS : EXIT_FAILURE;
    }

    char *public_key_file, *private_key_file;

    if (KEY_PATH)
    {
        xasprintf(&public_key_file, "%s.pub", KEY_PATH);
        xasprintf(&private_key_file, "%s.priv", KEY_PATH);
    }
    else
    {
        public_key_file = PublicKeyFile(GetWorkDir());
        private_key_file = PrivateKeyFile(GetWorkDir());
    }

    bool ret = KeepKeyPromises(public_key_file, private_key_file, KEY_SIZE);

    free(public_key_file);
    free(private_key_file);

    GenericAgentFinalize(ctx, config);

    return ret ? EXIT_SUCCESS : EXIT_FAILURE;
}
static void test_RemoveKeys(void)
{
	assert_true(1);
    assert_int_equal(RemoveKeys("somehostname"), 255);
}