mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 09:58:54 +00:00
service: add full path for service binary (#4316)
This commit is contained in:
parent
f5abb45919
commit
6eb695bf9b
@ -37,6 +37,8 @@
|
||||
#include "osquery/main/main.h"
|
||||
#include "osquery/sql/sqlite_util.h"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
namespace osquery {
|
||||
|
||||
SHELL_FLAG(int32,
|
||||
@ -150,7 +152,8 @@ int startOsquery(int argc, char* argv[], std::function<void()> shutdown) {
|
||||
|
||||
// Options for installing or uninstalling the osqueryd as a service
|
||||
if (FLAGS_install) {
|
||||
if (!installService(argv[0])) {
|
||||
auto binPath = fs::system_complete(fs::path(argv[0]));
|
||||
if (!installService(binPath.string())) {
|
||||
LOG(ERROR) << "Unable to install the osqueryd service";
|
||||
}
|
||||
return 1;
|
||||
|
@ -26,7 +26,7 @@ namespace osquery {
|
||||
* This disconnect of install flows is a limitation. The POSIX install flows
|
||||
* should be refactored into install/uninstall service methods.
|
||||
*/
|
||||
Status installService(const char* const path);
|
||||
Status installService(const std::string& path);
|
||||
|
||||
/// See installService.
|
||||
Status uninstallService();
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace osquery {
|
||||
|
||||
Status installService(const char* const /*path*/) {
|
||||
Status installService(const std::string& /*path*/) {
|
||||
LOG(INFO) << "The --install service flag only applies to Windows platforms";
|
||||
return Status(1);
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class ServiceArgumentParser {
|
||||
};
|
||||
|
||||
/// Install osqueryd as a service given the path to the binary
|
||||
Status installService(const char* const binPath) {
|
||||
Status installService(const std::string& binPath) {
|
||||
SC_HANDLE schSCManager = OpenSCManager(
|
||||
nullptr, nullptr, SC_MANAGER_CONNECT | SC_MANAGER_CREATE_SERVICE);
|
||||
|
||||
@ -225,9 +225,8 @@ Status installService(const char* const binPath) {
|
||||
}
|
||||
|
||||
HANDLE flagsFilePtr = nullptr;
|
||||
std::string binPathWithFlagFile = std::string(binPath) + " --flagfile=";
|
||||
std::string flagsFile =
|
||||
FLAGS_flagfile.empty() ? kDefaultFlagsFile : FLAGS_flagfile;
|
||||
auto binPathWithFlagFile = binPath + " --flagfile=";
|
||||
auto flagsFile = FLAGS_flagfile.empty() ? kDefaultFlagsFile : FLAGS_flagfile;
|
||||
binPathWithFlagFile += flagsFile;
|
||||
flagsFilePtr = CreateFile(flagsFile.c_str(),
|
||||
GENERIC_READ,
|
||||
|
Loading…
Reference in New Issue
Block a user