IPC Identification

Esh, Andrew Andrew_Esh at adaptec.com
Wed Feb 11 15:16:51 GMT 2004

Hi all!

I was testing some share mode code in smbd/service.c from a Windows NT client. The mode settings I am doing should not be applied to the IPC service, but I was still seeing problems with operations being attempted on IPC. My code tried to avoid affecting IPC by testing the macro "IS_IPC(conn), which tests conn->ipc.

I narrowed the problem down to this line in "smbd/service.c:make_connection_snum".

	conn->ipc = ((strncmp(dev,"IPC",3) == 0) || strequal(dev,"ADMIN$"));

During testing, I noticed this message in the log:

[2004/02/09 15:54:04, 5, pid=22631, effective(0, 0), real(0, 0)] smbd/service.c:make_connection(976)
  making a connection to 'normal' service ipc$

... which is a printout of the value of "dev". The name is not upper case, like the strncmp assumes.

In order to get the conn->ipc flag set right, I had to change the code to:

	conn->ipc = ((strncmp(dev,"IPC",3) == 0) || (strncmp(dev,"ipc",3) == 0) ||  strequal(dev,"ADMIN$"));

I noticed a number of other places in the code where the device string is tested against "IPC". I also wonder if testing the first three characters of the device string is the right thing to do. Why not test 'strequal(dev,"IPC$")'?

I think the setting of conn->ipc needs to be done right, and I think all tests for the IPC service should use "IS_IPC", instead of testing the device name against various strings. I think the same rules should apply for conn->printer, and IS_PRINT(conn).

What do you think?

Andrew C. Esh                mail:Andrew_Esh[at]adaptec.com
Adaptec, Inc.
2905 Northwest Blvd., Suite 20        763-557-9005 (main)
Plymouth, MN 55441-2644 USA      763-551-6418 (direct)

More information about the samba-technical mailing list