bool SftpClient::Connect(const string& server, const string& login, const string& passwd) { bool rc = false; BString cmd("sftp "); BString host(server.c_str()); BString port; if (host.FindFirst(':')) host.MoveInto(port, host.FindFirst(':'), host.Length()); port.RemoveAll(":"); if (port.Length()) cmd << "-oPort=" << port << " "; cmd << login.c_str(); cmd << "@" << host.String(); printf("COMMAND: '%s'\n", cmd.String()); SetCommandLine(cmd.String()); rc = SpawningUploadClient::Connect(server, login, passwd); BString reply; ssize_t len; if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; } fprintf(stderr, _GetReplyText(), reply.String()); if (reply.FindFirst("Connecting to ") != 0) return false; if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; } fprintf(stderr, _GetReplyText(), reply.String()); if (reply.FindFirst(/*[pP]*/"assword:") < 0) return false; write(OutputPipe(), passwd.c_str(), strlen(passwd.c_str())); write(OutputPipe(), "\n", 1); if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; } fprintf(stderr, _GetReplyText(), reply.String()); if (reply != "\n") return false; if ((len = ReadReply(&reply)) < 0) { fprintf(stderr, _GetLongReadText(), len); return false; } fprintf(stderr, _GetReplyText(), reply.String()); if (reply.FindFirst("sftp>") < 0) return false; return rc; }
/* construct system_manifest object and initialize it from manifest */ void SystemManifestCtor(struct NaClApp *nap) { struct SystemManifest *policy; /* check for design errors */ assert(nap != NULL); assert(nap->system_manifest != NULL); policy = nap->system_manifest; policy->syscallback = 0; /* get zerovm settings from manifest */ policy->version = GetValueByKey("Version"); policy->nexe_etag = GetValueByKey("NexeEtag"); /* check mandatory manifest keys */ ZLOGFAIL(nap->system_manifest->version == NULL, EFAULT, "the manifest version is not provided"); ZLOGFAIL(STRCMP(nap->system_manifest->version, MANIFEST_VERSION), EFAULT, "manifest version not supported"); SetTimeout(policy); /* user data (environment, command line) */ policy->envp = NULL; SetCustomAttributes(policy); /* prepare command line arguments for nexe */ policy->cmd_line = NULL; policy->cmd_line_size = 0; SetCommandLine(policy); /* get node name and id */ SetNodeName(nap); /* construct and initialize all channels */ ChannelsCtor(nap); /* * allocate "whole memory chunk" if specified. should be the last allocation * in raw because after chunk allocated there will be no free user memory * note: will set "heap_ptr" */ GET_INT_BY_KEY(nap->heap_end, "MemMax"); PreallocateUserMemory(nap); /* zerovm return code */ nap->system_manifest->ret_code = OK_CODE; }
void ezCommandLineUtils::SetCommandLine() { int argc = 0; LPWSTR* argvw = CommandLineToArgvW(GetCommandLineW(), &argc); EZ_ASSERT_RELEASE(argvw != nullptr, "CommandLineToArgvW failed"); ezArrayPtr<ezStringUtf8> ArgvUtf8 = EZ_DEFAULT_NEW_ARRAY(ezStringUtf8, argc); ezArrayPtr<const char*> argv = EZ_DEFAULT_NEW_ARRAY(const char*, argc); for (ezInt32 i = 0; i < argc; ++i) { ArgvUtf8[i] = argvw[i]; argv[i] = ArgvUtf8[i].GetData(); } SetCommandLine(argc, argv.GetPtr()); EZ_DEFAULT_DELETE_ARRAY(ArgvUtf8); EZ_DEFAULT_DELETE_ARRAY(argv); LocalFree(argvw); }
void CommandLineExe::Analize(int argc, const char *argv[]) { Arguments = GetCommandLine(argc, argv); ExtractKeyData(); SetCommandLine(ArgumentsExtra, Argc, Argv); }