chiark
/
gitweb
/
~mdw
/
fwd
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a8ceabf
)
Handle select errors more robustly.
author
mdw
<mdw>
Sat, 20 Jan 2001 11:55:17 +0000
(11:55 +0000)
committer
mdw
<mdw>
Sat, 20 Jan 2001 11:55:17 +0000
(11:55 +0000)
fw.c
patch
|
blob
|
blame
|
history
diff --git
a/fw.c
b/fw.c
index 8665b437e5e06df0a909f2dedecff609da619bda..6b8f16d82a1dc93245bb4bee4b6fe9da59e322a2 100644
(file)
--- a/
fw.c
+++ b/
fw.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: fw.c,v 1.
8 2000/03/23 23:19:19
mdw Exp $
+ * $Id: fw.c,v 1.
9 2001/01/20 11:55:17
mdw Exp $
*
* Port forwarding thingy
*
*
* Port forwarding thingy
*
@@
-29,6
+29,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: fw.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: fw.c,v $
+ * Revision 1.9 2001/01/20 11:55:17 mdw
+ * Handle select errors more robustly.
+ *
* Revision 1.8 2000/03/23 23:19:19 mdw
* Fix changed options in parser table.
*
* Revision 1.8 2000/03/23 23:19:19 mdw
* Fix changed options in parser table.
*
@@
-532,11
+535,13
@@
int main(int argc, char *argv[])
#ifdef HAVE_SETGROUPS
if ((dropg != -1 && (setgid(dropg) || setgroups(1, &dropg))) ||
#ifdef HAVE_SETGROUPS
if ((dropg != -1 && (setgid(dropg) || setgroups(1, &dropg))) ||
+ (drop != -1 && setuid(drop)))
+ die(1, "couldn't drop privileges: %s", strerror(errno));
#else
if ((dropg != -1 && setgid(dropg)) ||
#else
if ((dropg != -1 && setgid(dropg)) ||
-#endif
(drop != -1 && setuid(drop)))
die(1, "couldn't drop privileges: %s", strerror(errno));
(drop != -1 && setuid(drop)))
die(1, "couldn't drop privileges: %s", strerror(errno));
+#endif
/* --- Fork into the background --- */
/* --- Fork into the background --- */
@@
-568,8
+573,23
@@
int main(int argc, char *argv[])
if (!(flags & FW_SET))
moan("nothing to do!");
signal(SIGPIPE, SIG_IGN);
if (!(flags & FW_SET))
moan("nothing to do!");
signal(SIGPIPE, SIG_IGN);
- while (active)
- sel_select(sel);
+
+ {
+ int selerr = 0;
+ while (active) {
+ if (!sel_select(sel))
+ selerr = 0;
+ else {
+ fw_log(-1, "error from select: %s", strerror(errno));
+ selerr++;
+ if (selerr > 8) {
+ fw_log(-1, "too many consecutive select errors: bailing out");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+ }
+
return (0);
}
return (0);
}