Commit Graph

601 Commits

Author SHA1 Message Date
Michael Friedrich 86108e6a1e Improve logging and code quality 2019-06-19 14:46:11 +02:00
Michael Friedrich a91bbe8acd Fix constant value for zone var override 2019-06-19 14:46:11 +02:00
Michael Friedrich e545884952 Improve logging for staged config sync 2019-06-19 14:46:11 +02:00
Michael Friedrich 1853254201 Pass the zonesVar override around 2019-06-19 14:46:11 +02:00
Michael Friedrich c2d7063ae7 Better signal for checking the cluster config sync stage (ignore production) 2019-06-19 14:46:11 +02:00
Michael Friedrich 65c8d43157 Add function docs for CA CLI commands 2019-06-07 10:33:55 +02:00
Michael Friedrich b32d818d1b CLI: Allow to list removed CSRs with 'ca list' 2019-06-07 10:33:55 +02:00
Michael Friedrich a35828a6ff CLI: Update ca remove/restore commands from my review 2019-06-07 10:33:55 +02:00
Andrew Jaffie d95feb4950 Log messages now use CN, file permissions fixed, ca remove now will not remove CSR's that have already been signed. 2019-06-07 10:33:55 +02:00
Andrew Jaffie 6aa2e0c36b Added ca restore command+docs to undo effects of ca remove 2019-06-07 10:33:55 +02:00
Andrew Jaffie 429f1ed317 Ignore repeated requests from client after using ca remove command 2019-06-07 10:33:55 +02:00
Andrew Jaffie a970f7dcf9 Implemented cli command + documentation. 2019-06-07 10:33:55 +02:00
Michael Friedrich 99bb7fa99c
Merge pull request #7196 from Icinga/feature/network-cleanup
Cleanup old code (HTTP, Cluster)
2019-05-29 14:50:40 +02:00
Michael Friedrich e72721b62f CLI: Remove broken troubleshoot command
It wasn't finished nor have we used it for support questions.

Issue templates, troubleshooting docs and external scripts
serve a better purpose here, especially with distributed systems.
2019-05-28 12:31:38 +02:00
Michael Friedrich c77d6eb869 Quality: Drop unused boost/tuple header include 2019-05-24 15:50:43 +02:00
Michael Friedrich f933aafd29 Quality: Purge old HTTP code in lib/remote 2019-05-24 15:50:43 +02:00
Michael Friedrich a0c8f41d58 Debug Console: Use our new I/O engine for HTTP requests
refs #7041
2019-05-22 12:51:23 +02:00
Michael Friedrich 6ba67487ea CLI: 'ca list' now lists pending CSRs by default, add '--all' parameter
https://puppet.com/docs/puppet/5.5/man/cert.html
2019-05-10 15:41:00 +02:00
Michael Friedrich aed88ca477 Revert "CLI: Return non-zero on unknown sub commands"
This reverts commit 00bc0b2303.
2019-05-10 15:16:05 +02:00
Michael Friedrich 6cce9c0fdd API: Automatically repair broken packages
This partially reverts #7150 and avoids exceptions
inside the flow. Each time an empty active stage
is detected, Icinga tries to repair it from the
the given directory tree.

Also, the code now takes into account that it should
create the package storage on startup, whether within
the API object, or if disabled, inside the application.

Caching the active stages for packages in memory
only is in effect with the API feature being enabled.
This is useful for other deployed config packages,
not only the internal one.

fixes #7173
refs #7150
refs #7119
fixes #6959
2019-05-10 12:48:34 +02:00
Michael Friedrich 00bc0b2303 CLI: Return non-zero on unknown sub commands
fixes #6585
2019-05-07 12:43:53 +02:00
Michael Friedrich 4197bc9bcd CLI: Fix updates for NodeName/ZoneName constants
fixes #7117
2019-05-06 10:19:56 +02:00
Michael Friedrich 759b090f81
Merge pull request #7150 from Icinga/bugfix/api-config-package-active-stage-name
Ensure that runtime created API objects survive a restart
2019-04-30 14:22:13 +02:00
Michael Friedrich 0d6d48fd59 Daemon: Deal with exceptions from broken _api package 2019-04-26 14:43:10 +02:00
Michael Friedrich 1078a0a824 Add --cn parameter to 'api setup' CLI command allowing hostname overrides
fixes #6649
2019-04-26 10:52:05 +02:00
Michael Friedrich 0438c866f8
Merge pull request #7102 from Icinga/feature/boost-fs-7101
Replace self-written filesystem ops with boost.filesystem
2019-04-25 15:53:55 +02:00
Alexander A. Klimov 5a17722c1f Replace _unlink() + rename() with boost::filesystem::rename()
refs #7101
2019-04-25 09:53:02 +02:00
Alexander A. Klimov ba842403ce Fix circular #include
refs #6985
2019-04-25 08:25:28 +02:00
Michael Friedrich 44d0c9013b Ignore synced config zones where no config item exists
The culprit is that we're in compiling configuration stage here,
we don't have access to `Zone::GetByName()` as objects have not
been activated yet.

Our best guess is from a config item loaded before (e.g. from zones.conf)
since no-one can sync zones via cluster config sync either.

It may not be 100% correct since the zone object itself may be invalid.
Still, if the zone object validator fails later, the config breaks either way.

The problem with removal of these directories is dealt by the cluster
config sync with stages.

refs #6727
refs #6716
2019-04-15 17:38:43 +02:00
Michael Friedrich 7ca8c3ec2f Impersonate as Icinga user, not root
This requires write permissions for

- etc/features-*
- etc/*.conf
- var/{lib,cache}/icinga2/*

Typically permissions are handled by prepare-dirs,
or the respective CLI commands are run as root either way.

fixes #4947
2019-04-02 17:05:48 +02:00
Michael Friedrich 804c00ece5
Merge pull request #6999 from Icinga/bugfix/compiler-warnings
Suppress or fix compiler warnings
2019-03-18 08:44:30 +01:00
Alexander A. Klimov bf92e32496 Suppress or fix compiler warnings 2019-03-08 14:07:29 +01:00
Michael Friedrich 37b715baf1 Replace a few more copyright strings 2019-02-25 16:30:40 +01:00
Michael Friedrich 458f997a18 Replace Copyright header with a short version, part II 2019-02-25 15:09:36 +01:00
Michael Friedrich d14a88235d Replace Copyright header with a short version, part I
CLion -> replace in path
2019-02-25 14:48:22 +01:00
Michael Friedrich b81f7a7415
Merge pull request #6577 from Icinga/fix/setup-api-including-users-file
Include api user configuration file during api setup
2019-02-11 16:41:46 +01:00
Michael Friedrich 4c1a54073c
Merge pull request #6748 from Icinga/bugfix/api-setup-fails-missing-confd
Fix api setup to automatically create the conf.d directory
2019-02-11 16:35:57 +01:00
Michael Insel 1352b15220 Fix string comparison on edge cases
This fixes a few edge cases where the string comparison failed before.
2018-12-05 20:12:06 +01:00
Michael Friedrich f3cd3eb870 DSL: Implement getenv()
This patch also restores Utility::GetFromEnvironment()
and replaces the hardcoded `getenv()` calls.
2018-11-19 18:11:16 +01:00
Michael Insel b785674ab2 Fix api setup to automatically create the conf.d directory
This patch creates the conf.d directory automatically when it is not present during api setup.
2018-11-01 19:16:26 +01:00
Michael Friedrich dea5ec614e icinga.com: Update CMakeLists.txt 2018-10-18 09:35:18 +02:00
Michael Friedrich dab53448bc icinga.com: Update *.{h,c}pp 2018-10-18 09:27:04 +02:00
Alexander A. Klimov 6d114b16e4 node setup: always respect --accept-config and --accept-commands 2018-10-01 16:33:50 +02:00
Michael Friedrich c8d4e785a1
Merge pull request #6519 from Icinga/fix/erroneous-console-exit
Reset terminal on erroneous console exit
2018-09-13 13:34:58 +02:00
Michael Insel cc417ca176 Fix CI builds 2018-09-04 18:56:54 +02:00
Michael Insel 46163700b4 Include api user configuration file during api setup
refs #6557
2018-09-04 18:38:38 +02:00
Michael Friedrich 1c2a59bf63
Merge pull request #6591 from Icinga/bugfix/lto-builds-static-initialize-namespaces
Fix static initializer priority for namespaces in LTO builds
2018-09-04 16:54:30 +02:00
Michael Friedrich 19993df380 Fix static initializer priority for namespaces in LTO builds
fixes #6575
2018-09-04 16:36:22 +02:00
Alan Jenkins a21166dcf8 Fix logging under systemd
icinga2.service used `-e ${ICINGA2_ERROR_LOG}`, but this is documented
as having no effect without `-d`.  Furthermore, icinga2 under systemd
unconditionally logged everything to the system log (but without setting
the log level etc), which contradicted the documentation.  (Issue #6339)

Stop icinga2 on systemd from logging to stdout - and hence the system log -
once it has finished starting up.  Just like when you start icinga2 from a
terminal using `-d`.  And just like -d, we stop logging fatal errors to
stderr, and instead write to the log file passed with `-e`.

As per docs, mainlog (icinga2.log) is already enabled by default.  And
pre-startup messages including config errors will still appear in the
system log.

This uses a new option --close-stdio, which has the same effect on logging as
--daemonize, but does not fork or call setsid().

For this purpose, I moved setsid() up and into Daemonize().

Consequence of that last point: if anyone is weird enough to specify a TTY
device file as the fatal error log (-e option), that will become icinga's
controlling terminal, which you generally don't want as a daemon.  This
makes it consistent with the existing behaviour for icinga mainlog.  For
this reason you're supposed to use O_NOCTTY in Linux daemons.  But I wasn't
sure where icinga would want to put the ugly `#ifdef _WIN32 ... #else ...`.
2018-08-25 10:21:06 +01:00
Alan Jenkins 50463a6a10 Daemonize(): use one error convention, not three
Standardize on exit() / _exit() (this depends whether we are considered
to be the "main" fork, which should run anything registered with atexit()).
Exclude `return false` and throwing exceptions.

This fixes the error path for fork().  Daemonize() would return false, but
the `return false` error convention was not tested in the caller.

It also fixes the error message for fork() to show the error code.
Everyone loves `strace`, but sysadmins should not have to rerun their
daemons under it just to see an error code.

Also in case an exception is thrown, show its diagnostic information
instead of dropping it on the floor.  In the log message, I mention why we
are uninitializing and then initializing the app at this point.

For the reader, it pushes all the weirdness into the error convention of
Daemonize().  This comes back to the exit() / _exit() distinction.  Once
we have forked, we technically don't want to allow the parent process to
exit(), so we don't want to return to the caller.
2018-08-25 10:07:02 +01:00