From 619e03fa692b53ac173fcae7b62d0a23509443b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Thu, 16 Mar 1995 15:10:11 +0000 Subject: [PATCH] Reading NCR registers is not secure at all times, so prevent an ordinary user from doing this. (Problem pointed out by Guido van Rooij). --- usr.sbin/ncrcontrol/ncrcontrol.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usr.sbin/ncrcontrol/ncrcontrol.c b/usr.sbin/ncrcontrol/ncrcontrol.c index 9aad16f66d61..296fb889d9c7 100644 --- a/usr.sbin/ncrcontrol/ncrcontrol.c +++ b/usr.sbin/ncrcontrol/ncrcontrol.c @@ -1,6 +1,6 @@ /************************************************************************** ** -** $Id: ncrcontrol.c,v 1.5 1995/02/03 20:49:10 bde Exp $ +** $Id: ncrcontrol.c,v 1.6 1995/03/14 21:12:26 se Exp $ ** ** Utility for NCR 53C810 device driver. ** @@ -1310,7 +1310,7 @@ static void dump_ncr (void) dump_link (" jump_tcb", &ncr.jump_tcb); printf (" register: @ %x (p=%x)\n", ncr.vaddr, ncr.paddr); - if (strchr (debug_opt, 'r')) { + if (wizard && strchr (debug_opt, 'r')) { struct ncr_reg reg; if (!KVM_READ ( @@ -1374,7 +1374,7 @@ static void dump_ncr (void) printf (" lasttime: %s", ctime ((time_t*)&ncr.lasttime)); printf ("\n"); - if (strchr (debug_opt, 'd') && ncr.regtime.tv_sec) { + if (wizard && strchr (debug_opt, 'd') && ncr.regtime.tv_sec) { printf (" regdump: %s", ctime (&ncr.regtime.tv_sec)); dump_reg (&ncr.regdump); }; @@ -1444,6 +1444,11 @@ do_debug(char * arg) ); if (strchr (debug_opt, 'n')) dump_ncr (); + + if (!wizard) { + fprintf (stderr, "%s: You are NOT a wizard!\n", prog); + exit (2); + }; if (strchr (debug_opt, 'r')) { struct ncr_reg reg; if (!KVM_READ ( @@ -1554,7 +1559,8 @@ void main(argc, argv) break; case 'w': - wizard=1; + if(geteuid()==0) + wizard=1; break; case 'v': verbose++;