]> git.armaanb.net Git - opendoas.git/commitdiff
Add nolog option to avoid syslog(3)
authorkn <kn>
Fri, 9 Oct 2020 07:43:38 +0000 (07:43 +0000)
committerDuncan Overbruck <mail@duncano.de>
Thu, 5 Nov 2020 19:51:47 +0000 (20:51 +0100)
doas(1) unconditionally logs all executions but syslog.conf(5) provides no
means to filter messages by user, target or command.

Add the "nolog" option to doas.conf(5) such that syslog becomes an opt-out
feature;  this keeps configuration simple enough yet powerful since rule
definition is the best place to decide whether to log commands or not on a
per rule basis - this also aoids duplicating information or logic in any
other log processing tool.

OK tedu martijn

doas.c
doas.conf.5
doas.h
parse.y

diff --git a/doas.c b/doas.c
index 8275fe180b70ed80e99a8ee05affcca54b610e38..dea68f823181e1595e940a2666457dbb1a2fd799 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -391,8 +391,11 @@ main(int argc, char **argv)
        else
                cwd = cwdpath;
 
-       syslog(LOG_AUTHPRIV | LOG_INFO, "%s ran command %s as %s from %s",
-           mypw->pw_name, cmdline, targpw->pw_name, cwd);
+       if (!(rule->options & NOLOG)) {
+               syslog(LOG_AUTHPRIV | LOG_INFO,
+                   "%s ran command %s as %s from %s",
+                   mypw->pw_name, cmdline, targpw->pw_name, cwd);
+       }
 
        envp = prepenv(rule, mypw, targpw);
 
index a14e778291352a12e31492e0c6534cc1dbe5773b..ce6656507d98816401c5cbdd0e30010a233bf5c9 100644 (file)
@@ -45,6 +45,9 @@ Options are:
 .Bl -tag -width keepenv
 .It Ic nopass
 The user is not required to enter a password.
+.It Ic nolog
+Do not log successful command execution to
+.Xr syslogd 8 .
 .It Ic persist
 After the user successfully authenticates, do not ask for a password
 again for some time.
@@ -140,6 +143,7 @@ permit nopass keepenv setenv { PATH } root as root
 .Ed
 .Sh SEE ALSO
 .Xr doas 1
+.Xr syslogd 8
 .Sh HISTORY
 The
 .Nm
diff --git a/doas.h b/doas.h
index 4a117be1e256656c5e30658a72bcadd06f53df2c..de8dbe1c18495cd5fab1d3fe1eeddce8ac16d0aa 100644 (file)
--- a/doas.h
+++ b/doas.h
@@ -42,3 +42,4 @@ char **prepenv(const struct rule *, const struct passwd *,
 #define NOPASS         0x1
 #define KEEPENV                0x2
 #define PERSIST                0x4
+#define NOLOG          0x8
diff --git a/parse.y b/parse.y
index e4a041a374164133761a77c8f3f1e27f09c7556a..15c00c128ce11a1a9b9a5e693b358cc7b73393d6 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -73,7 +73,7 @@ arraylen(const char **arr)
 %}
 
 %token TPERMIT TDENY TAS TCMD TARGS
-%token TNOPASS TPERSIST TKEEPENV TSETENV
+%token TNOPASS TNOLOG TPERSIST TKEEPENV TSETENV
 %token TSTRING
 
 %%
@@ -139,6 +139,9 @@ options:    /* none */ {
 option:                TNOPASS {
                        $$.options = NOPASS;
                        $$.envlist = NULL;
+               } | TNOLOG {
+                       $$.options = NOLOG;
+                       $$.envlist = NULL;
                } | TPERSIST {
                        $$.options = PERSIST;
                        $$.envlist = NULL;
@@ -212,6 +215,7 @@ static struct keyword {
        { "cmd", TCMD },
        { "args", TARGS },
        { "nopass", TNOPASS },
+       { "nolog", TNOLOG },
        { "persist", TPERSIST },
        { "keepenv", TKEEPENV },
        { "setenv", TSETENV },