[or-cvs] bugfix for win32 with lots of users

Roger Dingledine arma at seul.org
Mon Oct 27 10:26:46 UTC 2003


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	fakepoll.c util.c 
Log Message:
bugfix for win32 with lots of users
plus general cleanup on switch_id()


Index: fakepoll.c
===================================================================
RCS file: /home/or/cvsroot/src/common/fakepoll.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- fakepoll.c	7 Oct 2003 21:16:04 -0000	1.11
+++ fakepoll.c	27 Oct 2003 10:26:44 -0000	1.12
@@ -24,6 +24,11 @@
 #include <winsock.h>
 #endif
 
+/* by default, windows handles only 64 fd's */
+#if defined(MS_WINDOWS) && !defined(FD_SETSIZE)
+#define FD_SETSIZE MAXCONNECTIONS
+#endif
+
 #include "util.h"
 
 int

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- util.c	23 Oct 2003 14:28:44 -0000	1.36
+++ util.c	27 Oct 2003 10:26:44 -0000	1.37
@@ -589,7 +589,6 @@
 
 int switch_id(char *user, char *group) {
 #ifndef MS_WINDOWS
-  int status;
   struct passwd *pw = NULL;
   struct group *gr = NULL;
 
@@ -609,24 +608,21 @@
       return -1;
     }
 
-    status = setgid(gr->gr_gid);
-    if (status != 0) {
+    if (setgid(gr->gr_gid) != 0) {
       log_fn(LOG_ERR,"Error setting GID: %s", strerror(errno));
       return -1;
     }
   } else if (user) {
-    status = setgid(pw->pw_gid);
-    if (status != 0) {
+    if (setgid(pw->pw_gid) != 0) {
       log_fn(LOG_ERR,"Error setting GID: %s", strerror(errno));
       return -1;
     }
   }
 
   /* now that the group is switched, we can switch users and lose
-     priviledges */
+     privileges */
   if (user) {
-    status = setuid(pw->pw_uid);
-    if (status != 0) {
+    if (setuid(pw->pw_uid) != 0) {
       log_fn(LOG_ERR,"Error setting UID: %s", strerror(errno));
       return -1;
     }



More information about the tor-commits mailing list