svn commit: samba r16397 - in branches/SAMBA_3_0/source/smbd: .
Gerald (Jerry) Carter
jerry at samba.org
Tue Jun 20 13:01:46 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
jra at samba.org wrote:
> Author: jra
> Date: 2006-06-20 02:38:28 +0000 (Tue, 20 Jun 2006)
> New Revision: 16397
>
> WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16397
>
> Log:
> Fix Klocwork #11767 and drasticly simplify the
> logic in smbd/process.c. All interested (Volker,
> Jerry, James etc). PLEASE REVIEW THIS CHANGE.
> The logic should be identical but *much* easier
> to follow and change (and shouldn't confuse Klockwork :-).
Jeremy, You know we good friends, but from this point forward
I *refuse* to review patches with gratuitous reformatting.
It used to be funny, but we're all adults here....
Your patch:
$ svn diff -r16396:16397 \
file:///misc/src/repo.svn/samba/branches/SAMBA_3_0 | wc -l
573
After removing reformatting changes:
$ diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes \
samba3-r16396/source samba3-r16397/source | wc -l
283
cheers, jerry
=====================================================================
Samba ------- http://www.samba.org
Centeris ----------- http://www.centeris.com
"What man is a man who does not make the world better?" --Balian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFEl/G6IR7qMdg1EfYRAlykAKDd9/GddxXUGa2IIhjHuQO/Ffg6DgCfWUM0
iziLgpOUceX63o6agvg4l2w=
=S7Ee
-----END PGP SIGNATURE-----
-------------- next part --------------
diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes samba3-r16396/source/smbd/message.c samba3-r16397/source/smbd/message.c
--- samba3-r16396/source/smbd/message.c 2006-06-20 07:53:49.000000000 -0500
+++ samba3-r16397/source/smbd/message.c 2006-06-20 07:54:51.000000000 -0500
@@ -34,8 +34,9 @@
static fstring msgto;
/****************************************************************************
-deliver the message
+ Deliver the message.
****************************************************************************/
+
static void
msg_deliver (void)
{
@@ -134,14 +134,14 @@
msgpos = 0;
}
-
-
/****************************************************************************
- reply to a sends
+ Reply to a sends.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
+
int
-reply_sends (connection_struct * conn,
- char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
+reply_sends (connection_struct * conn, char *inbuf, char *outbuf,
+ int dum_size, int dum_buffsize)
{
int len;
char *msg;
@@ -184,13 +184,14 @@
return (outsize);
}
-
/****************************************************************************
- reply to a sendstrt
+ Reply to a sendstrt.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
+
int
-reply_sendstrt (connection_struct * conn,
- char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
+reply_sendstrt (connection_struct * conn, char *inbuf, char *outbuf,
+ int dum_size, int dum_buffsize)
{
int outsize = 0;
char *p;
@@ -222,13 +223,14 @@
return (outsize);
}
-
/****************************************************************************
- reply to a sendtxt
+ Reply to a sendtxt.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
+
int
-reply_sendtxt (connection_struct * conn,
- char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
+reply_sendtxt (connection_struct * conn, char *inbuf, char *outbuf,
+ int dum_size, int dum_buffsize)
{
int len;
int outsize = 0;
@@ -257,13 +259,14 @@
return (outsize);
}
-
/****************************************************************************
- reply to a sendend
+ Reply to a sendend.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
+
int
-reply_sendend (connection_struct * conn,
- char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
+reply_sendend (connection_struct * conn, char *inbuf, char *outbuf,
+ int dum_size, int dum_buffsize)
{
int outsize = 0;
START_PROFILE (SMBsendend);
diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes samba3-r16396/source/smbd/negprot.c samba3-r16397/source/smbd/negprot.c
--- samba3-r16396/source/smbd/negprot.c 2006-06-20 07:54:03.000000000 -0500
+++ samba3-r16397/source/smbd/negprot.c 2006-06-20 07:54:46.000000000 -0500
@@ -509,6 +509,7 @@
/****************************************************************************
Reply to a negprot.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes samba3-r16396/source/smbd/nttrans.c samba3-r16397/source/smbd/nttrans.c
--- samba3-r16396/source/smbd/nttrans.c 2006-06-20 07:54:03.000000000 -0500
+++ samba3-r16397/source/smbd/nttrans.c 2006-06-20 07:54:46.000000000 -0500
@@ -1767,6 +1767,7 @@
/****************************************************************************
Reply to a NT CANCEL request.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes samba3-r16396/source/smbd/process.c samba3-r16397/source/smbd/process.c
--- samba3-r16396/source/smbd/process.c 2006-06-20 07:54:03.000000000 -0500
+++ samba3-r16397/source/smbd/process.c 2006-06-20 07:54:46.000000000 -0500
@@ -624,10 +624,10 @@
force write permissions on print services.
*/
#define AS_USER (1<<0)
-#define NEED_WRITE (1<<1)
+#define NEED_WRITE (1<<1) /* Must be paired with AS_USER */
#define TIME_INIT (1<<2)
-#define CAN_IPC (1<<3)
-#define AS_GUEST (1<<5)
+#define CAN_IPC (1<<3) /* Must be paired with AS_USER */
+#define AS_GUEST (1<<5) /* Must *NOT* be paired with AS_USER */
#define DO_CHDIR (1<<6)
/*
@@ -1523,17 +1523,21 @@
last_session_tag = session_tag;
if (session_tag != UID_FIELD_INVALID)
+ {
vuser = get_valid_user_struct (session_tag);
- if (vuser != NULL)
+ if (vuser)
+ {
set_current_user_info (&vuser->user);
}
+ }
+ }
- /* does this protocol need to be run as root? */
- if (!(flags & AS_USER))
- change_to_root_user ();
+ /* Does this call need to be run as the connected user? */
+ if (flags & AS_USER)
+ {
- /* does this protocol need a valid tree connection? */
- if ((flags & AS_USER) && !conn)
+ /* Does this call need a valid tree connection? */
+ if (!conn)
{
/* Amazingly, the error code depends on the command (from Samba4). */
if (type == SMBntcreateX)
@@ -1546,29 +1550,30 @@
}
}
-
- /* does this protocol need to be run as the connected user? */
- if ((flags & AS_USER) && !change_to_user (conn, session_tag))
+ if (!change_to_user (conn, session_tag))
{
- if (flags & AS_GUEST)
- flags &= ~AS_USER;
- else
return (ERROR_FORCE_DOS (ERRSRV, ERRbaduid));
}
- /* this code is to work around a bug is MS client 3 without
- introducing a security hole - it needs to be able to do
- print queue checks as guest if it isn't logged in properly */
- if (flags & AS_USER)
- flags &= ~AS_GUEST;
+ /* All NEED_WRITE and CAN_IPC flags must also have AS_USER. */
- /* does it need write permission? */
+ /* Does it need write permission? */
if ((flags & NEED_WRITE) && !CAN_WRITE (conn))
+ {
return (ERROR_DOS (ERRSRV, ERRaccess));
+ }
- /* ipc services are limited */
- if (IS_IPC (conn) && (flags & AS_USER) && !(flags & CAN_IPC))
+ /* IPC services are limited */
+ if (IS_IPC (conn) && !(flags & CAN_IPC))
+ {
return (ERROR_DOS (ERRSRV, ERRaccess));
+ }
+ }
+ else
+ {
+ /* This call needs to be run as root */
+ change_to_root_user ();
+ }
/* load service specific parameters */
if (conn)
@@ -1587,7 +1592,9 @@
!check_access (smbd_server_fd (),
lp_hostsallow (-1),
lp_hostsdeny (-1))))
+ {
return (ERROR_DOS (ERRSRV, ERRaccess));
+ }
current_inbuf = inbuf; /* In case we need to defer this message in open... */
outsize = smb_messages[type].fn (conn, inbuf, outbuf, size, bufsize);
diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes samba3-r16396/source/smbd/reply.c samba3-r16397/source/smbd/reply.c
--- samba3-r16396/source/smbd/reply.c 2006-06-20 07:54:03.000000000 -0500
+++ samba3-r16397/source/smbd/reply.c 2006-06-20 07:54:46.000000000 -0500
@@ -636,6 +636,7 @@
/****************************************************************************
Reply to a tcon.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
@@ -702,6 +703,7 @@
/****************************************************************************
Reply to a tcon and X.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
@@ -852,6 +854,7 @@
/****************************************************************************
Reply to an ioctl.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
@@ -1852,6 +1855,7 @@
/****************************************************************************
Reply to a SMBulogoffX.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
@@ -3744,6 +3748,7 @@
/****************************************************************************
Reply to a exit.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
@@ -4038,6 +4043,7 @@
/****************************************************************************
Reply to a tdis.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
@@ -4067,6 +4073,7 @@
/****************************************************************************
Reply to a echo.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
int
diff -ruBb --exclude-from=/home/jerry/tmp/diff.excludes samba3-r16396/source/smbd/sesssetup.c samba3-r16397/source/smbd/sesssetup.c
--- samba3-r16396/source/smbd/sesssetup.c 2006-06-20 07:54:03.000000000 -0500
+++ samba3-r16397/source/smbd/sesssetup.c 2006-06-20 07:54:46.000000000 -0500
@@ -716,6 +716,7 @@
/****************************************************************************
Reply to a session setup command.
+ conn POINTER CAN BE NULL HERE !
****************************************************************************/
static int
More information about the samba-technical
mailing list