Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce --no-impersonate flag #10321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion icinga-app/icinga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ static int Main()
("include,I", po::value<std::vector<std::string> >(), "add include search directory")
("log-level,x", po::value<std::string>(), "specify the log level for the console log.\n"
"The valid value is either debug, notice, information (default), warning, or critical")
("script-debugger,X", "whether to enable the script debugger");
("script-debugger,X", "whether to enable the script debugger")
("no-impersonate", ("run as current user, never impersonate " +
Configuration::RunAsUser + ":" + Configuration::RunAsGroup).CStr());

po::options_description hiddenDesc("Hidden options");

Expand Down
5 changes: 0 additions & 5 deletions lib/cli/apisetupcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ String ApiSetupCommand::GetShortDescription() const
return "setup for API";
}

ImpersonationLevel ApiSetupCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

void ApiSetupCommand::InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const
{
Expand Down
1 change: 0 additions & 1 deletion lib/cli/apisetupcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class ApiSetupCommand final : public CLICommand
void InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
ImpersonationLevel GetImpersonationLevel() const override;
};

}
Expand Down
10 changes: 0 additions & 10 deletions lib/cli/caremovecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ int CARemoveCommand::GetMinArguments() const
return 1;
}

/**
* Impersonate as Icinga user.
*
* @return impersonate level
*/
ImpersonationLevel CARemoveCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

/**
* The entry point for the "ca remove" CLI command.
*
Expand Down
1 change: 0 additions & 1 deletion lib/cli/caremovecommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CARemoveCommand final : public CLICommand
String GetDescription() const override;
String GetShortDescription() const override;
int GetMinArguments() const override;
ImpersonationLevel GetImpersonationLevel() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
};

Expand Down
10 changes: 0 additions & 10 deletions lib/cli/carestorecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ int CARestoreCommand::GetMinArguments() const
return 1;
}

/**
* Impersonate as Icinga user.
*
* @return impersonate level
*/
ImpersonationLevel CARestoreCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

/**
* The entry point for the "ca restore" CLI command.
*
Expand Down
1 change: 0 additions & 1 deletion lib/cli/carestorecommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CARestoreCommand final : public CLICommand
String GetDescription() const override;
String GetShortDescription() const override;
int GetMinArguments() const override;
ImpersonationLevel GetImpersonationLevel() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
};

Expand Down
10 changes: 0 additions & 10 deletions lib/cli/casigncommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ int CASignCommand::GetMinArguments() const
return 1;
}

/**
* Impersonate as Icinga user.
*
* @return impersonate level
*/
ImpersonationLevel CASignCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

/**
* The entry point for the "ca sign" CLI command.
*
Expand Down
1 change: 0 additions & 1 deletion lib/cli/casigncommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CASignCommand final : public CLICommand
String GetDescription() const override;
String GetShortDescription() const override;
int GetMinArguments() const override;
ImpersonationLevel GetImpersonationLevel() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
};

Expand Down
6 changes: 5 additions & 1 deletion lib/cli/clicommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void CLICommand::InitParameters(boost::program_options::options_description& vis

ImpersonationLevel CLICommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
return m_ImpersonationLevel;
}

bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& visibleDesc,
Expand Down Expand Up @@ -216,6 +216,10 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
po::store(po::command_line_parser(argc - arg_end, argv + arg_end).options(adesc).positional(positionalDesc).run(), vm);
po::notify(vm);

if (vm.count("no-impersonate")) {
command->m_ImpersonationLevel = ImpersonateNone;
}

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/cli/clicommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class CLICommand : public Object
bool autocomplete = false, int autoindex = -1);

private:
ImpersonationLevel m_ImpersonationLevel = ImpersonateIcinga;

static std::mutex& GetRegistryMutex();
static std::map<std::vector<String>, CLICommand::Ptr>& GetRegistry();
};
Expand Down
5 changes: 0 additions & 5 deletions lib/cli/featuredisablecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ int FeatureDisableCommand::GetMaxArguments() const
return -1;
}

ImpersonationLevel FeatureDisableCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

/**
* The entry point for the "feature disable" CLI command.
*
Expand Down
1 change: 0 additions & 1 deletion lib/cli/featuredisablecommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class FeatureDisableCommand final : public CLICommand
int GetMinArguments() const override;
int GetMaxArguments() const override;
std::vector<String> GetPositionalSuggestions(const String& word) const override;
ImpersonationLevel GetImpersonationLevel() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;

};
Expand Down
5 changes: 0 additions & 5 deletions lib/cli/featureenablecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ int FeatureEnableCommand::GetMaxArguments() const
return -1;
}

ImpersonationLevel FeatureEnableCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

/**
* The entry point for the "feature enable" CLI command.
*
Expand Down
1 change: 0 additions & 1 deletion lib/cli/featureenablecommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class FeatureEnableCommand final : public CLICommand
int GetMinArguments() const override;
int GetMaxArguments() const override;
std::vector<String> GetPositionalSuggestions(const String& word) const override;
ImpersonationLevel GetImpersonationLevel() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
};

Expand Down
5 changes: 0 additions & 5 deletions lib/cli/internalsignalcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ String InternalSignalCommand::GetShortDescription() const
return "Send signal as Icinga user";
}

ImpersonationLevel InternalSignalCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

bool InternalSignalCommand::IsHidden() const
{
return true;
Expand Down
1 change: 0 additions & 1 deletion lib/cli/internalsignalcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class InternalSignalCommand final : public CLICommand

String GetDescription() const override;
String GetShortDescription() const override;
ImpersonationLevel GetImpersonationLevel() const override;
bool IsHidden() const override;
void InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const override;
Expand Down
5 changes: 0 additions & 5 deletions lib/cli/nodesetupcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ std::vector<String> NodeSetupCommand::GetArgumentSuggestions(const String& argum
return CLICommand::GetArgumentSuggestions(argument, word);
}

ImpersonationLevel NodeSetupCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

/**
* The entry point for the "node setup" CLI command.
*
Expand Down
1 change: 0 additions & 1 deletion lib/cli/nodesetupcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class NodeSetupCommand final : public CLICommand
void InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const override;
std::vector<String> GetArgumentSuggestions(const String& argument, const String& word) const override;
ImpersonationLevel GetImpersonationLevel() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;

private:
Expand Down
5 changes: 0 additions & 5 deletions lib/cli/nodewizardcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ String NodeWizardCommand::GetShortDescription() const
return "wizard for node setup";
}

ImpersonationLevel NodeWizardCommand::GetImpersonationLevel() const
{
return ImpersonateIcinga;
}

int NodeWizardCommand::GetMaxArguments() const
{
return -1;
Expand Down
1 change: 0 additions & 1 deletion lib/cli/nodewizardcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class NodeWizardCommand final : public CLICommand
String GetShortDescription() const override;
int GetMaxArguments() const override;
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
ImpersonationLevel GetImpersonationLevel() const override;
void InitParameters(boost::program_options::options_description& visibleDesc,
boost::program_options::options_description& hiddenDesc) const override;

Expand Down
Loading