1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

Restrict -a to root only.

PR:		bin/25337
This commit is contained in:
Ruslan Ermilov 2001-02-24 10:16:54 +00:00
parent 130c1f25a4
commit b52c326cfc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72973
2 changed files with 7 additions and 1 deletions

View File

@ -54,6 +54,7 @@ Show all data in the message buffer.
This includes any syslog records and This includes any syslog records and
.Pa /dev/console .Pa /dev/console
output. output.
Only root is allowed to use this option.
.It Fl M .It Fl M
Extract values associated with the name list from the specified core Extract values associated with the name list from the specified core
instead of the default instead of the default

View File

@ -45,6 +45,7 @@ static const char rcsid[] =
"$FreeBSD$"; "$FreeBSD$";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h>
#include <sys/msgbuf.h> #include <sys/msgbuf.h>
#include <err.h> #include <err.h>
@ -53,9 +54,10 @@ static const char rcsid[] =
#include <locale.h> #include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sysexits.h>
#include <syslog.h>
#include <unistd.h> #include <unistd.h>
#include <vis.h> #include <vis.h>
#include <sys/syslog.h>
struct nlist nl[] = { struct nlist nl[] = {
#define X_MSGBUF 0 #define X_MSGBUF 0
@ -109,6 +111,9 @@ main(argc, argv)
if (memf != NULL || nlistf != NULL) if (memf != NULL || nlistf != NULL)
setgid(getgid()); setgid(getgid());
if (all && getuid())
errx(EX_NOPERM, "must be root to use -a");
/* Read in kernel message buffer, do sanity checks. */ /* Read in kernel message buffer, do sanity checks. */
if ((kd = kvm_open(nlistf, memf, NULL, O_RDONLY, "dmesg")) == NULL) if ((kd = kvm_open(nlistf, memf, NULL, O_RDONLY, "dmesg")) == NULL)
exit (1); exit (1);