From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Buchanan Subject: Re: Problem with watching power commands - key is not logged Date: Mon, 30 Jan 2017 16:32:43 +0000 Message-ID: References: <00bd01d27960$5598e330$00caa990$@gmail.com> <20170129214036.GD7067@madcap2.tricolour.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6810385342998314168==" Return-path: Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6DC0DB8F44 for ; Mon, 30 Jan 2017 16:32:58 +0000 (UTC) Received: from mail-wj0-f180.google.com (mail-wj0-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D8B47E9DC for ; Mon, 30 Jan 2017 16:32:57 +0000 (UTC) Received: by mail-wj0-f180.google.com with SMTP id n2so8094844wjq.3 for ; Mon, 30 Jan 2017 08:32:55 -0800 (PST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: =?UTF-8?Q?Damian_Tyka=C5=82owski?= Cc: linux-audit@redhat.com List-Id: linux-audit@redhat.com --===============6810385342998314168== Content-Type: multipart/alternative; boundary=94eb2c0d0d360ac1070547525e0a --94eb2c0d0d360ac1070547525e0a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Glad to hear that it's working for you now. Typically, the '-w ' syntax is to watch system files for modification, not so much to audit the execution of the command (like for power events, as you're doing). The way I audit reboot commands (among others) is: -a always,exit -F arch=3Db32 -S acct -S reboot -S sched_setparam -S sched_setscheduler -S setrlimit -S swapon -k reboot_sched_swap -a always,exit -F arch=3Db64 -S acct -S reboot -S sched_setparam -S sched_setscheduler -S setrlimit -S swapon -k reboot_sched_swap and -w /var/run/utmp -p wa -k session This might not be sufficient for your needs, but hopefully it's helpful. Stephen On Mon, Jan 30, 2017 at 5:21 AM Damian Tyka=C5=82owski w= rote: > I found it out > auditctl -l did not list rule as loaded, I checked logs of auditd deeper > and found it stopped loading rules at some point due to duplicated rule, > after sorting that out, it loaded all rules correctly, sorry for trouble > > On Sun, Jan 29, 2017 at 10:40 PM, Richard Guy Briggs > wrote: > > On 2017-01-28 13:16, Damian Tyka=C5=82owski wrote: > > Hi > > Hi Damian, > > > I'm struggling to get proper auditing of usage of power commands, here'= s > > what I've got in rules > > > > [root@host01 ~]# cat /etc/audit/audit.rules | grep power > > -w /sbin/shutdown -p rwx -k power > > -w /sbin/poweroff -p rwx -k power > > -w /sbin/reboot -p rwx -k power > > -w /sbin/halt -p rwx -k power > > -w shutdown -p rwx -k power > > -w poweroff -p rwx -k power > > -w reboot -p rwx -k power > > -w halt -p rwx -k power > > > > However despite full host reboot/refreshing rules I'm not getting event= s > > with proper key "power" > > > > [root@host01 ~]# cat /var/log/audit/audit.log | grep power > > > > > > Events are logged though but without key > > > > type=3DUSER_CMD msg=3Daudit(1485604576.755:679): pid=3D3490 uid=3D5004 = auid=3D5004 > > ses=3D1 subj=3Dunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 > > msg=3D'cwd=3D"/home/user01" cmd=3D"reboot" terminal=3Dpts/0 res=3Dsucce= ss' > > > > type=3DUSER_CMD msg=3Daudit(1485604729.923:658): pid=3D3428 uid=3D5004 = auid=3D5004 > > ses=3D1 subj=3Dunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 > > msg=3D'cwd=3D"/home/user01" cmd=3D"reboot" terminal=3Dpts/0 res=3Dsucce= ss' > > > > Any idea what is wrong? Rules with other keys seems to work. > > I suspect you have another rule that is catching it first? > > > - RGB > > -- > Richard Guy Briggs > Kernel Security Engineering, Base Operating Systems, Red Hat > Remote, Ottawa, Canada > Voice: +1.647.777.2635, Internal: (81) 32635 > > > -- > Linux-audit mailing list > Linux-audit@redhat.com > https://www.redhat.com/mailman/listinfo/linux-audit --94eb2c0d0d360ac1070547525e0a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Glad to hear that it's working for you now.=C2=A0
=
Typically, the '-w <path/filename>' syntax is = to watch system files for modification, not so much to audit the execution = of the command (like for power events, as you're doing). The way I audi= t reboot commands (among others) is:

-a always,exit -F arch= =3Db32 -S acct -S reboot -S sched_setparam -S sched_setscheduler -S setrlim= it -S swapon -k reboot_sched_swap
-a always,exit -F arch=3Db64 -S acct -= S reboot -S sched_setparam -S sched_setscheduler -S setrlimit -S swapon -k = reboot_sched_swap
and
-w /var/run/utmp -p wa -k session=

This might not be sufficient for your needs, but hopefully it's= helpful.=C2=A0

Stephen

On Mon, Jan 30, 2017 at 5:21 AM Damian Ty= ka=C5=82owski <d47zm3@gmail.com&= gt; wrote:
I found it out
auditctl -l did not list rule as loaded, I checked logs of auditd = deeper and found it stopped loading rules at some point due to duplicated r= ule, after sorting that out, it loaded all rules correctly, sorry for troub= le

On Sun, Jan 29, 2017= at 10:40 PM, Richard Guy Briggs <= rgb= @redhat.com> wrote:
On 2017-01-28 13:16, Damian Tyka=C5=82owski wrote:<= br class=3D"gmail_msg"> > Hi

Hi Damian,

> I'm struggling to get proper auditing of usage of power commands, = here's
> what I've got in rules
>
> [root@host01 ~]# cat /etc/audit/audit.rules | grep power
> -w /sbin/shutdown -p rwx -k power
> -w /sbin/poweroff -p rwx -k power
> -w /sbin/reboot -p rwx -k power
> -w /sbin/halt -p rwx -k power
> -w shutdown -p rwx -k power
> -w poweroff -p rwx -k power
> -w reboot -p rwx -k power
> -w halt -p rwx -k power
>
> However despite full host reboot/refreshing rules I'm not getting = events
> with proper key "power"
>
> [root@host01 ~]# cat /var/log/audit/audit.log | grep power
> <empty>
>
> Events are logged though but without key
>
> type=3DUSER_CMD msg=3Daudit(1485604576.755:679): pid=3D3490 uid=3D5004= auid=3D5004
> ses=3D1 subj=3Dunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 > msg=3D'cwd=3D"/home/user01" cmd=3D"reboot" ter= minal=3Dpts/0 res=3Dsuccess'
>
> type=3DUSER_CMD msg=3Daudit(1485604729.923:658): pid=3D3428 uid=3D5004= auid=3D5004
> ses=3D1 subj=3Dunconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 > msg=3D'cwd=3D"/home/user01" cmd=3D"reboot" ter= minal=3Dpts/0 res=3Dsuccess'
>
> Any idea what is wrong? Rules with other keys seems to work.
I suspect you have another rule that is catching it first?


- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Kernel Security Engineering, Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635

--
Linux-audit mailing list
Linux-audit@redhat.com
https://www.redhat.com/mailma= n/listinfo/linux-audit
--94eb2c0d0d360ac1070547525e0a-- --===============6810385342998314168== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============6810385342998314168==--