Bug 15937

Summary: vi recover script in /etc/rc still remains unsolved.
Product: Base System Reporter: y-koga <y-koga>
Component: confAssignee: Peter Wemm <peter>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 2.2.8-STABLE   
Hardware: Any   
OS: Any   

Description y-koga 2000-01-06 10:50:02 UTC
About vi recover script in /etc/rc, this problem has been submitted by Mr. Kojima
and Peter has committed already, but it still remains unsolved.

Quoting filename(s) does not make sence, because it is splitted by space before then.

Fix: 

a) Change the working directory to /var/tmp/vi.recover or use full path, and
it can't remove a file "/foo". However, it is no more than a temporary step.

b) Use "ls" and replace white spaces with some charcters.
   e.g.)
	SPACE => /s
	TAB => /t
then restore as before and quote word(s) in "for" block.


Probably there are better solutions than above.
How-To-Repeat: case a) /foo is executable and user root can rm -f /foo: 
% echo a > '/var/tmp/vi.recover/vi. foo'

case b) user root can rm -f /foo: 
% touch /var/tmp/vi.recover/recover. foo'
Comment 1 peter 2000-01-06 11:14:38 UTC
y-koga@jp.FreeBSD.org wrote:

> >Description:
> About vi recover script in /etc/rc, this problem has been submitted by Mr. Ko
    jima
> and Peter has committed already, but it still remains unsolved.
> 
> Quoting filename(s) does not make sence, because it is splitted by space befo
    re then.

Can you please check a patch along these lines?  This stops the split in the
first place.

Index: rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.207
diff -u -r1.207 rc
--- rc	2000/01/05 09:19:27	1.207
+++ rc	2000/01/06 11:13:26
@@ -433,7 +433,7 @@
 vibackup=`echo /var/tmp/vi.recover/vi.*`
 if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
 	echo 'Recovering vi editor sessions'
-	for i in ${vibackup}; do
+	for i in /var/tmp/vi.recover/vi.*; do
 		# Only test files that are readable.
 		if [ ! -r "${i}" ]; then
 			continue
@@ -450,7 +450,7 @@
 	# crashes at the right time.
 	virecovery=`echo /var/tmp/vi.recover/recover.*`
 	if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
-		for i in ${virecovery}; do
+		for i in /var/tmp/vi.recover/recover.*; do
 			# Only test files that are readable.
 			if [ ! -r "${i}" ]; then
 				continue



Cheers,
-Peter
Comment 2 y-koga 2000-01-06 11:21:10 UTC
Peter Wemm <peter@netplex.com.au>:
> Can you please check a patch along these lines?  This stops the split in the
> first place.

It seems to work successfully.

-- Koga, Youichirou
Comment 3 Alexey Zelkin freebsd_committer freebsd_triage 2000-01-10 13:11:45 UTC
Responsible Changed
From-To: freebsd-bugs->peter

Peter proposed patch and he will close PR. 
Comment 4 nrahlstr freebsd_committer freebsd_triage 2000-06-04 23:10:19 UTC
State Changed
From-To: open->closed

Peter fixed this in revision 1.208 of etc/rc.