chiark
/
gitweb
/
~mdw
/
tripe
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow binding to a chosen address.
[tripe]
/
tripe.c
diff --git
a/tripe.c
b/tripe.c
index 9e2256596609f3218aa9774566f4c011abd2de27..e0985966f1692fff61d337840f4e933128b0aef8 100644
(file)
--- a/
tripe.c
+++ b/
tripe.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: tripe.c,v 1.
9 2003/04/15 14:11:09
mdw Exp $
+ * $Id: tripe.c,v 1.
10 2003/05/16 12:09:03
mdw Exp $
*
* Main program
*
*
* Main program
*
@@
-29,6
+29,9
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: tripe.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: tripe.c,v $
+ * Revision 1.10 2003/05/16 12:09:03 mdw
+ * Allow binding to a chosen address.
+ *
* Revision 1.9 2003/04/15 14:11:09 mdw
* Rationalize the behaviour of the `-G' and `-U' options.
*
* Revision 1.9 2003/04/15 14:11:09 mdw
* Rationalize the behaviour of the `-G' and `-U' options.
*
@@
-151,6
+154,7
@@
int main(int argc, char *argv[])
const char *dir = "/var/lib/tripe";
const char *p;
unsigned port = 0;
const char *dir = "/var/lib/tripe";
const char *p;
unsigned port = 0;
+ struct in_addr baddr = { INADDR_ANY };
unsigned f = 0;
uid_t u = -1;
gid_t g = -1;
unsigned f = 0;
uid_t u = -1;
gid_t g = -1;
@@
-175,6
+179,7
@@
int main(int argc, char *argv[])
{ "setuid", OPTF_ARGREQ, 0, 'U' },
{ "gid", OPTF_ARGREQ, 0, 'G' },
{ "setgid", OPTF_ARGREQ, 0, 'G' },
{ "setuid", OPTF_ARGREQ, 0, 'U' },
{ "gid", OPTF_ARGREQ, 0, 'G' },
{ "setgid", OPTF_ARGREQ, 0, 'G' },
+ { "bind-address", OPTF_ARGREQ, 0, 'b' },
{ "port", OPTF_ARGREQ, 0, 'p' },
{ "directory", OPTF_ARGREQ, 0, 'd' },
{ "priv-keyring", OPTF_ARGREQ, 0, 'k' },
{ "port", OPTF_ARGREQ, 0, 'p' },
{ "directory", OPTF_ARGREQ, 0, 'd' },
{ "priv-keyring", OPTF_ARGREQ, 0, 'k' },
@@
-188,7
+193,7
@@
int main(int argc, char *argv[])
{ 0, 0, 0, 0 }
};
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "hvu DU:G: p:d:k:K:t:a:" T("T:"),
+ int i = mdwopt(argc, argv, "hvu DU:G:
b:
p:d:k:K:t:a:" T("T:"),
opts, 0, 0, 0);
if (i < 0)
break;
opts, 0, 0, 0);
if (i < 0)
break;
@@
-232,7
+237,13
@@
int main(int argc, char *argv[])
die(EXIT_FAILURE, "group `%s' not found", optarg);
g = gr->gr_gid;
} break;
die(EXIT_FAILURE, "group `%s' not found", optarg);
g = gr->gr_gid;
} break;
-
+
+ case 'b': {
+ struct hostent *h = gethostbyname(optarg);
+ if (!h)
+ die(EXIT_FAILURE, "unknown host name `%s'", optarg);
+ memcpy(&baddr, h->h_addr, sizeof(struct in_addr));
+ } break;
case 'p': {
char *p;
unsigned long i = strtoul(optarg, &p, 0);
case 'p': {
char *p;
unsigned long i = strtoul(optarg, &p, 0);
@@
-289,7
+300,7
@@
int main(int argc, char *argv[])
rand_seed(RAND_GLOBAL, RMD160_HASHSZ);
signal(SIGPIPE, SIG_IGN);
tun_init();
rand_seed(RAND_GLOBAL, RMD160_HASHSZ);
signal(SIGPIPE, SIG_IGN);
tun_init();
- p_init(port);
+ p_init(
baddr,
port);
if (!(f & f_daemon))
a_create(STDIN_FILENO, STDOUT_FILENO);
if (g != (gid_t)-1) {
if (!(f & f_daemon))
a_create(STDIN_FILENO, STDOUT_FILENO);
if (g != (gid_t)-1) {