The 'D' is now capital to clarify pronunciation.
DBus service name is kept as '/Tuned' not to break
backward compatibility.
This will also need update of downstream tests
which rely on the specific output strings containing
the name.
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
The returned string was only pseudo random. It is only used for the
log_capture_start() mechanism at the moment. Therefore an attacker might
be able to guess the tokens of other users. Since this data it publicly
available anyways it should not be a big issue, however.
Currently the logrotation is not configurable. On system with large
amount of cpus a tuned start creates a lot of entries and older log
entries are lost.
Add two DBus calls:
log_capture_start(log_level, timeout)
* This will instruct Tuned to create a new log handler, which will
start writing log messages with level 'log_level' and higher to
a buffer. The log levels are standard Python log levels (e.g.
logging.INFO) or Tuned's custom log level LOG_LEVEL_CONSOLE which
is defined as 60. The handler will be destroyed after 'timeout' seconds
if contents of the buffer are not collected using log_capture_finish()
before the timeout. If 'timeout' <= 0, log messages will be collected
for as long as it takes before log_capture_finish() is called (use
with care, so that you don't fill up memory with Tuned logs). This
call returns a string ID of the log handler, a token, which should
be passed to log_capture_finish().
log_capture_finish(token)
* This will return (as a string) log messages collected by a log handler
associated with the 'token'. It will also destroy the log handler.
These calls are privileged. They can only be called by the root user or
by a user logged in on a local console (just like the change-profile DBus
calls). This restriction is meant to prevent ordinary users from forcing
Tuned to allocate an insane amount of memory for the log buffers and crash
it (or other processes). In the future we may wish to replace this
restriction with a configurable policy which determines how many (and how
big) log buffers can a user with a given UID create. We may also want to
destroy the log handler when the original caller disconnects from DBus.
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This level has the highest severity. It is meant for important messages
about situations which may require user intervention. These messages
will be shown to the user on the console when running tuned-adm (this is
implemented in a followup commit).
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
This fixes Pylint errors such as the following:
tuned/logs.py:39: [E1003(bad-super-call), TunedLogger.__init__] \
Bad first argument 'self.__class__' given to super()
This prevents infinite recursion errors, see
https://stackoverflow.com/a/18208725
This does introduce name duplication, but when we drop python2 support
in the future, we can use super() without arguments.
Drop TunedLogger.set_level(). It doesn't appear to be used anywhere
and it causes problems with Python3, because logging._levelNames
doesn't exist anymore.
Previously if you ran 'tuned -l log', it would crash with:
OSError: [Errno 2] No such file or directory: ''
This patch fixes the bug.
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
If used without argument as --pid or -P the tuned will write the PID file even
if running in foreground. The PID file is always written if running as daemon.
If used with argument as --pid FILE or -P FILE, the PID will be written to
FILE. This is also applicable for daemon.
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
If used without argument as --log or -l the tuned will log to file even if
running on foreground. It will not log to console. This is the default if
running as daemon.
If used with argument as --log FILE, -l FILE, the log will be stored to FILE.
This is also applicable for deamon.
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
GPL license does not require all files to have the copyright notice
and header. To save some space, I removed the headers from all files
except the executables and the main Python module.