mirror of
https://github.com/systemd/systemd
synced 2026-04-07 07:34:50 +02:00
Compare commits
3 Commits
21d00e52db
...
1285252823
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1285252823 | ||
|
|
9c41618008 | ||
|
|
86bd939d7f |
@ -358,7 +358,7 @@ void log_forget_fds(void) {
|
||||
}
|
||||
|
||||
void log_set_max_level(int level) {
|
||||
assert((level & LOG_PRIMASK) == level);
|
||||
assert(level == LOG_NULL || (level & LOG_PRIMASK) == level);
|
||||
|
||||
log_max_level = level;
|
||||
}
|
||||
|
||||
@ -27,6 +27,10 @@ typedef enum LogTarget{
|
||||
_LOG_TARGET_INVALID = -EINVAL,
|
||||
} LogTarget;
|
||||
|
||||
/* This log level disables logging completely. It can only be passed to log_set_max_level() and cannot be
|
||||
* used a regular log level. */
|
||||
#define LOG_NULL (LOG_EMERG - 1)
|
||||
|
||||
/* Note to readers: << and >> have lower precedence than & and | */
|
||||
#define SYNTHETIC_ERRNO(num) (1 << 30 | (num))
|
||||
#define IS_SYNTHETIC_ERRNO(val) ((val) >> 30 & 1)
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "journald-kmsg.h"
|
||||
#include "journald-server.h"
|
||||
#include "journald-syslog.h"
|
||||
#include "log.h"
|
||||
#include "parse-util.h"
|
||||
#include "process-util.h"
|
||||
#include "stdio-util.h"
|
||||
@ -106,6 +107,8 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
|
||||
char *e, *f, *k;
|
||||
uint64_t serial;
|
||||
size_t pl;
|
||||
int saved_log_max_level = INT_MAX;
|
||||
ClientContext *c = NULL;
|
||||
|
||||
assert(s);
|
||||
assert(p);
|
||||
@ -266,10 +269,16 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
|
||||
else {
|
||||
pl -= syslog_parse_identifier((const char**) &p, &identifier, &pid);
|
||||
|
||||
/* Avoid any messages we generated ourselves via
|
||||
* log_info() and friends. */
|
||||
if (is_us(identifier, pid))
|
||||
goto finish;
|
||||
/* Avoid logging any new messages when we're processing messages generated by ourselves via
|
||||
* log_info() and friends to avoid infinite loops. */
|
||||
if (is_us(identifier, pid)) {
|
||||
if (!ratelimit_below(&s->kmsg_own_ratelimit))
|
||||
return;
|
||||
|
||||
saved_log_max_level = log_get_max_level();
|
||||
c = s->my_context;
|
||||
log_set_max_level(LOG_NULL);
|
||||
}
|
||||
|
||||
if (identifier) {
|
||||
syslog_identifier = strjoin("SYSLOG_IDENTIFIER=", identifier);
|
||||
@ -287,7 +296,11 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
|
||||
if (cunescape_length_with_prefix(p, pl, "MESSAGE=", UNESCAPE_RELAX, &message) >= 0)
|
||||
iovec[n++] = IOVEC_MAKE_STRING(message);
|
||||
|
||||
server_dispatch_message(s, iovec, n, ELEMENTSOF(iovec), NULL, NULL, priority, 0);
|
||||
|
||||
server_dispatch_message(s, iovec, n, ELEMENTSOF(iovec), c, NULL, priority, 0);
|
||||
|
||||
if (saved_log_max_level != INT_MAX)
|
||||
log_set_max_level(saved_log_max_level);
|
||||
|
||||
finish:
|
||||
for (j = 0; j < z; j++)
|
||||
|
||||
@ -65,6 +65,9 @@
|
||||
#define DEFAULT_RATE_LIMIT_BURST 10000
|
||||
#define DEFAULT_MAX_FILE_USEC USEC_PER_MONTH
|
||||
|
||||
#define DEFAULT_KMSG_OWN_INTERVAL (5 * USEC_PER_SEC)
|
||||
#define DEFAULT_KMSG_OWN_BURST 50
|
||||
|
||||
#define RECHECK_SPACE_USEC (30*USEC_PER_SEC)
|
||||
|
||||
#define NOTIFY_SNDBUF_SIZE (8*1024*1024)
|
||||
@ -2212,6 +2215,11 @@ int server_init(Server *s, const char *namespace) {
|
||||
|
||||
.runtime_storage.name = "Runtime Journal",
|
||||
.system_storage.name = "System Journal",
|
||||
|
||||
.kmsg_own_ratelimit = {
|
||||
.interval = DEFAULT_KMSG_OWN_INTERVAL,
|
||||
.burst = DEFAULT_KMSG_OWN_BURST,
|
||||
},
|
||||
};
|
||||
|
||||
r = set_namespace(s, namespace);
|
||||
|
||||
@ -16,6 +16,7 @@ typedef struct Server Server;
|
||||
#include "journald-stream.h"
|
||||
#include "list.h"
|
||||
#include "prioq.h"
|
||||
#include "ratelimit.h"
|
||||
#include "time-util.h"
|
||||
#include "varlink.h"
|
||||
|
||||
@ -142,6 +143,7 @@ struct Server {
|
||||
|
||||
uint64_t *kernel_seqnum;
|
||||
bool dev_kmsg_readable:1;
|
||||
RateLimit kmsg_own_ratelimit;
|
||||
|
||||
bool send_watchdog:1;
|
||||
bool sent_notify_ready:1;
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
echo "g adm - - -" | systemd-sysusers -
|
||||
|
||||
U=/run/systemd/system/test12.socket
|
||||
cat >$U <<EOF
|
||||
[Unit]
|
||||
|
||||
@ -19,7 +19,8 @@ inspect() {
|
||||
homectl inspect "$USERNAME" | tee /tmp/a
|
||||
userdbctl user "$USERNAME" | tee /tmp/b
|
||||
|
||||
diff -I '/^\s*Disk (Size|Free|Floor|Ceiling):/' /tmp/{a,b}
|
||||
# diff uses the grep BREs for pattern matching
|
||||
diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' /tmp/{a,b}
|
||||
rm /tmp/{a,b}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user