Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4315040pxu; Mon, 21 Dec 2020 09:18:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrrPCWyPlWD2JkLuzTaQfl4urGTRYOddZP3lX7oIJu4TnwV3xu6Xp9EfCLsZKBzeok9C26 X-Received: by 2002:a17:907:2111:: with SMTP id qn17mr15781401ejb.525.1608571125620; Mon, 21 Dec 2020 09:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608571125; cv=none; d=google.com; s=arc-20160816; b=h6MKxt408dPPnPl3uqMVTsFE1KfVejRUz5ixR/NgUNRMNqMbTGoyTAIRh0L4DU+Fj2 lF9WnZddivbmwN3tx52ssEnF2qzvDuJd+3hNeaEeMIEVLKg/CV9q+NkzaY1w2ahWDpi9 P+RTEZXK9iH9jXFboIHCRNgzpqSpROlHiu7jslOIdLQRTlFEkfBJRHuxW6WVzeHip/Am AZ1qJAPUQ4qUCXK5PF/iROijPC/84T/7Du8oo+kgxqsSXfmhlBNs5rv8tD/ImoEiZCOr nxb4yRp87BvJ8gT3oY0PIRfrd6wID21doSvdzi0n4VRoVpNIMF0D1CjwjLuKip4zbrV3 nsTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=BrlwuJ7Wsdax0BBfkanmGMtk6GKetW4Dz1RxeSTSf6U=; b=VNwBJkM3ZoKMC4R3V5v+CLkeVMvsOM2h0Rtrzu3PBqb6DT2ccXJ9FMxYGYpsICp3ds 0Os/sFw3dr/vZtCL8SJFPlVUwGqpdlZFyfek2RQQXrytbZYFh6980BMFAZSX+a+DyQ5S lGJHY5NUDyoVTmO1ZHsyicjdL3+3HRKn11vLxEIMC9srsfu8ywyFxvsmiKTl5OSZ63LG YsQky0swyyW0d/ysh9jPtaVKa7VJQ+G6QHuCjZQBGCrBnjjLQ3tCyO5LmJo+NM14yKbs EkiFhMmw5HflePH0+OTR2iZQSlCjmCQ4NeXKSuKINYZ2XFrpEpH9Q38q9jNfIiU+BLKG tExg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UNuS+nbS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn4si1262487ejc.274.2020.12.21.09.18.22; Mon, 21 Dec 2020 09:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UNuS+nbS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726111AbgLURPq (ORCPT + 99 others); Mon, 21 Dec 2020 12:15:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45279 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgLURPq (ORCPT ); Mon, 21 Dec 2020 12:15:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608570859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=BrlwuJ7Wsdax0BBfkanmGMtk6GKetW4Dz1RxeSTSf6U=; b=UNuS+nbSJ3TNPmTYGVKgLzi/i7WVhq5GXxNE2hEvDFNp83xAWqQxgRyVQ2m9BmMlxiw4tX ahgQJmE7AmAtwZhbFGHZldka/DzTst4K4VLa8P+bYd0sdUJgdQnsOepMhmP/bxuy7jWnfx TSnZyQUybQH3hETeGZsJXA7AitDPeaE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-ozhqscUFOcChKRkRG-yYlA-1; Mon, 21 Dec 2020 12:14:15 -0500 X-MC-Unique: ozhqscUFOcChKRkRG-yYlA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C391107B46E; Mon, 21 Dec 2020 17:14:13 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.10.110.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9DC45D9CA; Mon, 21 Dec 2020 17:14:02 +0000 (UTC) From: Richard Guy Briggs To: Linux Containers List , Linux-Audit Mailing List , LKML Cc: Neil Horman , Eric Paris , mpatel@redhat.com, Richard Guy Briggs Subject: [PATCH ghau51/ghau40 v10 07/11] signal_info: only print context if it is available. Date: Mon, 21 Dec 2020 12:12:47 -0500 Message-Id: <20201221171251.2610890-8-rgb@redhat.com> In-Reply-To: <20201221171251.2610890-1-rgb@redhat.com> References: <20201221171251.2610890-1-rgb@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Richard Guy Briggs --- src/auditd-event.c | 20 +++++++++++++++----- src/auditd-reconfig.c | 2 -- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/auditd-event.c b/src/auditd-event.c index e6b2a961f02b..800f4d83bc83 100644 --- a/src/auditd-event.c +++ b/src/auditd-event.c @@ -1323,13 +1323,16 @@ static void reconfigure(struct auditd_event *e) const char *ctx = nconf->sender_ctx; struct timeval tv; char txt[MAX_AUDIT_MESSAGE_LENGTH]; + int txt_len; char date[40]; unsigned int seq_num; int need_size_check = 0, need_reopen = 0, need_space_check = 0; - snprintf(txt, sizeof(txt), - "config change requested by pid=%d auid=%u subj=%s", - pid, uid, ctx); + txt_len = snprintf(txt, sizeof(txt), + "config change requested by pid=%d auid=%u", pid, uid); + if (ctx) + snprintf(txt + txt_len, sizeof(txt) - txt_len, + " subj=%s", ctx); audit_msg(LOG_NOTICE, "%s", txt); /* Do the reconfiguring. These are done in a specific @@ -1578,8 +1581,15 @@ static void reconfigure(struct auditd_event *e) e->reply.type = AUDIT_DAEMON_CONFIG; e->reply.len = snprintf(e->reply.msg.data, MAX_AUDIT_MESSAGE_LENGTH-2, - "%s: op=reconfigure state=changed auid=%u pid=%d subj=%s res=success", - date, uid, pid, ctx ); + "%s: op=reconfigure state=changed auid=%u pid=%d", + date, uid, pid); + if (ctx) + e->reply.len += snprintf(e->reply.msg.data + e->reply.len, + MAX_AUDIT_MESSAGE_LENGTH-2 - e->reply.len, + " subj=%s", ctx); + e->reply.len += snprintf(e->reply.msg.data + e->reply.len, + MAX_AUDIT_MESSAGE_LENGTH-2 - e->reply.len, + " res=success"); e->reply.message = e->reply.msg.data; free((char *)ctx); } diff --git a/src/auditd-reconfig.c b/src/auditd-reconfig.c index f5b00e6d1dc7..1af402526c4e 100644 --- a/src/auditd-reconfig.c +++ b/src/auditd-reconfig.c @@ -106,8 +106,6 @@ static void *config_thread_main(void *arg) if (e->reply.len > 24) new_config.sender_ctx = strdup(e->reply.signal_info->ctx); - else - new_config.sender_ctx = strdup("?"); memcpy(e->reply.msg.data, &new_config, sizeof(new_config)); e->reply.conf = (struct daemon_conf *)e->reply.msg.data; e->reply.type = AUDIT_DAEMON_RECONFIG; -- 2.18.4