Subject: bin/2249: /bin/mt write filemarks in spite of read-only operation
To: None <gnats-bugs@NetBSD.ORG>
From: None <that@aquarius.bekkoame.or.jp>
List: netbsd-bugs
Date: 03/23/1996 10:39:23
>Number: 2249
>Category: bin
>Synopsis: /bin/mt write filemarks in spite of read-only operation.
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Mar 22 20:50:08 1996
>Last-Modified:
>Originator: Hitoshi Osada
>Organization:
None
>Release: NetBSD 1.1A Mar 17
>Environment:
System: NetBSD thatat.standalone.co.jp 1.1A NetBSD 1.1A (THATAT) #11: Wed Mar 20 01:22:44 JST 1996 that@thatat.standalone.co.jp:/usr/src/sys/arch/i386/compile/THATAT i386
>Description:
/bin/mt write filemarks in spite of read-only(space, eom) operation.
>How-To-Repeat:
% tar cvf /dev/rst0 /bin
% mt rew
% tar tvf /dev/rst0
>Fix:
*** mt.c Wed Mar 6 21:07:49 1996
--- mt.c.new Wed Mar 20 00:26:01 1996
***************
*** 103,108 ****
--- 103,109 ----
struct mtop mt_com;
int ch, len, mtfd;
char *p, *tape;
+ int openmode;
uid = getuid();
euid = geteuid();
***************
*** 143,150 ****
if (strncmp(p, comp->c_name, len) == 0)
break;
}
! if ((mtfd = host ? rmtopen(tape, 2) :
! open(tape, O_WRONLY|O_CREAT, 0666)) < 0)
err(2, "%s", tape);
if (comp->c_code != MTNOP) {
mt_com.mt_op = comp->c_code;
--- 144,152 ----
if (strncmp(p, comp->c_name, len) == 0)
break;
}
! openmode = comp->c_ronly ? O_RDONLY : O_WRONLY;
! if ((mtfd = host ? rmtopen(tape, openmode) :
! open(tape, openmode)) < 0)
err(2, "%s", tape);
if (comp->c_code != MTNOP) {
mt_com.mt_op = comp->c_code;
>Audit-Trail:
>Unformatted: