summaryrefslogtreecommitdiffstats
path: root/sbin/dmesg
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2001-02-24 10:16:54 +0000
committerru <ru@FreeBSD.org>2001-02-24 10:16:54 +0000
commitf4bc17fe3e727273d3cc8c2c11d1963385c616d0 (patch)
tree757d2cfd3f2819b6074b6b0af265ce8386e53d3d /sbin/dmesg
parenta97d568931024effb29c978a06d054867d92dc88 (diff)
downloadFreeBSD-src-f4bc17fe3e727273d3cc8c2c11d1963385c616d0.zip
FreeBSD-src-f4bc17fe3e727273d3cc8c2c11d1963385c616d0.tar.gz
Restrict -a to root only.
PR: bin/25337
Diffstat (limited to 'sbin/dmesg')
-rw-r--r--sbin/dmesg/dmesg.81
-rw-r--r--sbin/dmesg/dmesg.c7
2 files changed, 7 insertions, 1 deletions
diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8
index 196b4dc..8d59634 100644
--- a/sbin/dmesg/dmesg.8
+++ b/sbin/dmesg/dmesg.8
@@ -54,6 +54,7 @@ Show all data in the message buffer.
This includes any syslog records and
.Pa /dev/console
output.
+Only root is allowed to use this option.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c
index 541e9df..3883688 100644
--- a/sbin/dmesg/dmesg.c
+++ b/sbin/dmesg/dmesg.c
@@ -45,6 +45,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
+#include <sys/types.h>
#include <sys/msgbuf.h>
#include <err.h>
@@ -53,9 +54,10 @@ static const char rcsid[] =
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sysexits.h>
+#include <syslog.h>
#include <unistd.h>
#include <vis.h>
-#include <sys/syslog.h>
struct nlist nl[] = {
#define X_MSGBUF 0
@@ -109,6 +111,9 @@ main(argc, argv)
if (memf != NULL || nlistf != NULL)
setgid(getgid());
+ if (all && getuid())
+ errx(EX_NOPERM, "must be root to use -a");
+
/* Read in kernel message buffer, do sanity checks. */
if ((kd = kvm_open(nlistf, memf, NULL, O_RDONLY, "dmesg")) == NULL)
exit (1);
OpenPOWER on IntegriCloud