OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
SMB_COM_RENAME semantics

From: Allen, Michael B (RSCH) (Michael_B_AllenML.COM)
Date: Mon Mar 24 2003 - 23:09:21 CST


Are wildcards really supported by SMB_COM_RENAME? What happends if
multiple files match the wildcard pattern? Are new filenames generated based
on the portion of the source filename that matched the wildcard pattern? For
example if the source and destination patterns where:

  *._xe --> *.exe

would this rename the file foo._exe to foo.exe?

On my home drive I had two files 'test0.doc' and test1.doc'. In a cmd prompt I did:

H:\> rename test*.doc foo*.doc

The resulted in files named 'foot0.doc' and foot1.doc' being created. Here's an
ethereal packet summary:

Transaction2 Request FIND_FIRST2, Pattern: \test<.doc
Transaction2 Response FIND_FIRST2, Files: test0.doc test1.doc
NT Create AndX Request, Path: \test0.doc
NT Create AndX Response, FID: 0x8006
Query Information Request, Path: \foot0.doc
Query Information Response, Error: STATUS_OBJECT_NAME_NOT_FOUND
Close Request, FID: 0x8006
Close Response
Rename Request, Old Name: \test0.doc, New Name: \foot0.doc
Rename Response
NT Create AndX Request, Path: \test1.doc
NT Create AndX Response, FID: 0x8007
Query Information Request, Path: \foot1.doc
Query Information Response, Error: STATUS_OBJECT_NAME_NOT_FOUND
Close Request, FID: 0x8007
Close Response
Rename Request, Old Name: \test1.doc, New Name: \foot1.doc
Rename Response
Find Close2 Request
Find Close2 Response

So it didn't use the wildcard functionality of SMB_COM_RENAME. It emulated
the behavior using TRANS2_FIND_FIRST2/NEXT2 to rename each matching file
individually. I think I'm glad. But this begs the question what happends if a file
exists halfway through the rename operation?

So now I created a file test1.doc and renamed the files back with:

H:\> rename foot*.doc test*.doc
A duplicate file name exists, or the file
cannot be found.

Transaction2 Request FIND_FIRST2, Pattern: \foot<.doc
Transaction2 Response FIND_FIRST2, Files: foot0.doc foot1.doc
NT Create AndX Request, Path: \foot0.doc
NT Create AndX Response, FID: 0x000d
Query Information Request, Path: \test0.doc
Query Information Response, Error: STATUS_OBJECT_NAME_NOT_FOUND
Close Request, FID: 0x000d
Close Response
Rename Request, Old Name: \foot0.doc, New Name: \test0.doc
Rename Response
NT Create AndX Request, Path: \foot1.doc
NT Create AndX Response, FID: 0x8009
Query Information Request, Path: \test1.doc
Query Information Response
Close Request, FID: 0x8009
Close Response
Rename Request, Old Name: \foot1.doc, New Name: \test1.doc
Rename Response, Error: STATUS_OBJECT_NAME_COLLISION
Find Close2 Request
Find Close2 Response

Humph.

Mike

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info including how to unsubscribe. Save time, search
the archives at http://discuss.microsoft.com/archives/index.html