CVS: rdesktop channels.c, 1.16, 1.17 constants.h, 1.47, 1.48 proto.h, 1.101, 1.102 rdpdr.c, 1.46, 1.47 scard.c, 1.13, 1.14 secure.c, 1.62, 1.63 tcp.c, 1.33, 1.34

Michael Gernoth <[email protected]> Fri, 03 Nov 2006 15:51:38 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16350

Modified Files:
	channels.c constants.h proto.h rdpdr.c scard.c secure.c tcp.c 
Log Message:
more smartcard locking fixes


Index: channels.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/channels.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** channels.c	27 Mar 2006 08:17:33 -0000	1.16
--- channels.c	3 Nov 2006 23:51:35 -0000	1.17
***************
*** 84,87 ****
--- 84,91 ----
  	uint8 *data;
  
+ #ifdef WITH_SCARD
+ 	scard_lock(SCARD_LOCK_CHANNEL);
+ #endif
+ 
  	/* first fragment sent in-place */
  	s_pop_layer(s, channel_hdr);
***************
*** 126,129 ****
--- 130,137 ----
  		data += thislength;
  	}
+ 
+ #ifdef WITH_SCARD
+ 	scard_unlock(SCARD_LOCK_CHANNEL);
+ #endif
  }
  

Index: constants.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/constants.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** constants.h	14 Jun 2006 08:26:00 -0000	1.47
--- constants.h	3 Nov 2006 23:51:35 -0000	1.48
***************
*** 426,427 ****
--- 426,434 ----
  #define SEAMLESSRDP_HELLO_RECONNECT	0x0001
  #define SEAMLESSRDP_HELLO_HIDDEN	0x0002
+ 
+ /* Smartcard constants */
+ #define SCARD_LOCK_TCP		0
+ #define SCARD_LOCK_SEC		1
+ #define SCARD_LOCK_CHANNEL	2
+ #define SCARD_LOCK_RDPDR	3
+ #define SCARD_LOCK_LAST		4

Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.101
retrieving revision 1.102
diff -C2 -d -r1.101 -r1.102
*** proto.h	3 Nov 2006 19:56:42 -0000	1.101
--- proto.h	3 Nov 2006 23:51:35 -0000	1.102
***************
*** 308,315 ****
  void scardSetInfo(uint32 device, uint32 id, uint32 bytes_out);
  int scard_enum_devices(uint32 * id, char *optarg);
! void scard_tcp_lock(void);
! void scard_tcp_unlock(void);
! void scard_sec_lock(void);
! void scard_sec_unlock(void);
  STREAM scard_tcp_init(void);
  void scard_tcp_connect(void);
--- 308,313 ----
  void scardSetInfo(uint32 device, uint32 id, uint32 bytes_out);
  int scard_enum_devices(uint32 * id, char *optarg);
! void scard_lock(int lock);
! void scard_unlock(int lock);
  STREAM scard_tcp_init(void);
  void scard_tcp_connect(void);

Index: rdpdr.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpdr.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** rdpdr.c	3 Nov 2006 19:56:42 -0000	1.46
--- rdpdr.c	3 Nov 2006 23:51:35 -0000	1.47
***************
*** 67,75 ****
  extern BOOL g_notify_stamp;
  
- #ifdef WITH_SCARD
- VCHANNEL *rdpdr_channel;
- #else
  static VCHANNEL *rdpdr_channel;
- #endif
  
  /* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */
--- 67,71 ----
***************
*** 324,327 ****
--- 320,326 ----
  	STREAM s;
  
+ #ifdef WITH_SCARD
+ 	scard_lock(SCARD_LOCK_RDPDR);
+ #endif
  	s = channel_init(rdpdr_channel, 20 + length);
  	out_uint8a(s, magic, 4);
***************
*** 338,341 ****
--- 337,343 ----
  #endif
  	channel_send(s, rdpdr_channel);
+ #ifdef WITH_SCARD
+ 	scard_unlock(SCARD_LOCK_RDPDR);
+ #endif
  }
  

Index: scard.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/scard.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** scard.c	3 Nov 2006 19:56:42 -0000	1.13
--- scard.c	3 Nov 2006 23:51:35 -0000	1.14
***************
*** 45,50 ****
  static struct stream out[STREAM_COUNT];
  static int cur_stream_id = 0;
! static pthread_mutex_t *tcp_sendcontrol_mutex = NULL;
! static pthread_mutex_t *sec_channels_mutex = NULL;
  
  static uint32 curDevice = 0, curId = 0, curBytesOut = 0;
--- 45,49 ----
  static struct stream out[STREAM_COUNT];
  static int cur_stream_id = 0;
! static pthread_mutex_t **scard_mutex = NULL;
  
  static uint32 curDevice = 0, curId = 0, curBytesOut = 0;
***************
*** 2621,2657 ****
  
  void
! scard_tcp_lock(void)
  {
! 	if (!tcp_sendcontrol_mutex)
  	{
! 		tcp_sendcontrol_mutex = (pthread_mutex_t *) xmalloc(sizeof(pthread_mutex_t));
! 		pthread_mutex_init(tcp_sendcontrol_mutex, NULL);
  	}
  
! 	pthread_mutex_lock(tcp_sendcontrol_mutex);
! }
! 
! void
! scard_tcp_unlock(void)
! {
! 	pthread_mutex_unlock(tcp_sendcontrol_mutex);
! }
! 
! void
! scard_sec_lock(void)
! {
! 	if (!sec_channels_mutex)
  	{
! 		sec_channels_mutex = (pthread_mutex_t *) xmalloc(sizeof(pthread_mutex_t));
! 		pthread_mutex_init(sec_channels_mutex, NULL);
  	}
  
! 	pthread_mutex_lock(sec_channels_mutex);
  }
  
  void
! scard_sec_unlock(void)
  {
! 	pthread_mutex_unlock(sec_channels_mutex);
  }
  
--- 2620,2644 ----
  
  void
! scard_lock(int lock)
  {
! 	if (!scard_mutex)
  	{
! 		scard_mutex =
! 			(pthread_mutex_t **) xmalloc(sizeof(pthread_mutex_t *) * SCARD_LOCK_LAST);
  	}
  
! 	if (!scard_mutex[lock])
  	{
! 		scard_mutex[lock] = (pthread_mutex_t *) xmalloc(sizeof(pthread_mutex_t));
! 		pthread_mutex_init(scard_mutex[lock], NULL);
  	}
  
! 	pthread_mutex_lock(scard_mutex[lock]);
  }
  
  void
! scard_unlock(int lock)
  {
! 	pthread_mutex_unlock(scard_mutex[lock]);
  }
  

Index: secure.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/secure.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** secure.c	3 Nov 2006 19:56:42 -0000	1.62
--- secure.c	3 Nov 2006 23:51:35 -0000	1.63
***************
*** 364,368 ****
  
  #ifdef WITH_SCARD
! 	scard_sec_lock();
  #endif
  
--- 364,368 ----
  
  #ifdef WITH_SCARD
! 	scard_lock(SCARD_LOCK_SEC);
  #endif
  
***************
*** 388,392 ****
  
  #ifdef WITH_SCARD
! 	scard_sec_unlock();
  #endif
  }
--- 388,392 ----
  
  #ifdef WITH_SCARD
! 	scard_unlock(SCARD_LOCK_SEC);
  #endif
  }

Index: tcp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/tcp.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** tcp.c	1 Nov 2006 20:52:01 -0000	1.33
--- tcp.c	3 Nov 2006 23:51:35 -0000	1.34
***************
*** 47,51 ****
  
  #ifdef WITH_SCARD
! 	scard_tcp_lock();
  	result = scard_tcp_init();
  #else
--- 47,51 ----
  
  #ifdef WITH_SCARD
! 	scard_lock(SCARD_LOCK_TCP);
  	result = scard_tcp_init();
  #else
***************
*** 62,66 ****
  	result->end = result->data + result->size;
  #ifdef WITH_SCARD
! 	scard_tcp_unlock();
  #endif
  	return result;
--- 62,66 ----
  	result->end = result->data + result->size;
  #ifdef WITH_SCARD
! 	scard_unlock(SCARD_LOCK_TCP);
  #endif
  	return result;
***************
*** 75,79 ****
  
  #ifdef WITH_SCARD
! 	scard_tcp_lock();
  #endif
  	while (total < length)
--- 75,79 ----
  
  #ifdef WITH_SCARD
! 	scard_lock(SCARD_LOCK_TCP);
  #endif
  	while (total < length)
***************
*** 89,93 ****
  	}
  #ifdef WITH_SCARD
! 	scard_tcp_unlock();
  #endif
  }
--- 89,93 ----
  	}
  #ifdef WITH_SCARD
! 	scard_unlock(SCARD_LOCK_TCP);
  #endif
  }


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642