mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-24 00:29:58 -05:00
Test, exit value.
git-svn-id: file:///svn/unbound/trunk@1236 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
3137c88a43
commit
757eff88f5
3 changed files with 14 additions and 7 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
15 September 2008: Wouter
|
15 September 2008: Wouter
|
||||||
- working start, stop, reload commands for unbound-control.
|
- working start, stop, reload commands for unbound-control.
|
||||||
|
- test for unbound-control working; better exit value for control.
|
||||||
|
|
||||||
12 September 2008: Wouter
|
12 September 2008: Wouter
|
||||||
- removed browser control mentions. Proto speccy.
|
- removed browser control mentions. Proto speccy.
|
||||||
|
|
|
||||||
|
|
@ -183,12 +183,13 @@ setup_ssl(SSL_CTX* ctx, int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** send command and display result */
|
/** send command and display result */
|
||||||
static void
|
static int
|
||||||
go_cmd(SSL* ssl, int argc, char* argv[])
|
go_cmd(SSL* ssl, int argc, char* argv[])
|
||||||
{
|
{
|
||||||
char* pre="UBCT";
|
char* pre="UBCT";
|
||||||
char* space=" ";
|
char* space=" ";
|
||||||
char* newline="\n";
|
char* newline="\n";
|
||||||
|
int was_error = 0, first_line = 1;
|
||||||
int r, i;
|
int r, i;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
if(SSL_write(ssl, pre, (int)strlen(pre)) <= 0)
|
if(SSL_write(ssl, pre, (int)strlen(pre)) <= 0)
|
||||||
|
|
@ -212,15 +213,19 @@ go_cmd(SSL* ssl, int argc, char* argv[])
|
||||||
}
|
}
|
||||||
buf[r] = 0;
|
buf[r] = 0;
|
||||||
printf("%s", buf);
|
printf("%s", buf);
|
||||||
|
if(first_line && strncmp(buf, "error", 5) == 0)
|
||||||
|
was_error = 1;
|
||||||
|
first_line = 0;
|
||||||
}
|
}
|
||||||
|
return was_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** go ahead and read config, contact server and perform command and display */
|
/** go ahead and read config, contact server and perform command and display */
|
||||||
static void
|
static int
|
||||||
go(char* cfgfile, char* svr, int argc, char* argv[])
|
go(char* cfgfile, char* svr, int argc, char* argv[])
|
||||||
{
|
{
|
||||||
struct config_file* cfg;
|
struct config_file* cfg;
|
||||||
int fd;
|
int fd, ret;
|
||||||
SSL_CTX* ctx;
|
SSL_CTX* ctx;
|
||||||
SSL* ssl;
|
SSL* ssl;
|
||||||
|
|
||||||
|
|
@ -238,12 +243,13 @@ go(char* cfgfile, char* svr, int argc, char* argv[])
|
||||||
ssl = setup_ssl(ctx, fd);
|
ssl = setup_ssl(ctx, fd);
|
||||||
|
|
||||||
/* send command */
|
/* send command */
|
||||||
go_cmd(ssl, argc, argv);
|
ret = go_cmd(ssl, argc, argv);
|
||||||
|
|
||||||
SSL_free(ssl);
|
SSL_free(ssl);
|
||||||
close(fd);
|
close(fd);
|
||||||
SSL_CTX_free(ctx);
|
SSL_CTX_free(ctx);
|
||||||
config_delete(cfg);
|
config_delete(cfg);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** getopt global, in case header files fail to declare it. */
|
/** getopt global, in case header files fail to declare it. */
|
||||||
|
|
@ -254,7 +260,7 @@ extern char* optarg;
|
||||||
/** Main routine for unbound-control */
|
/** Main routine for unbound-control */
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c, ret;
|
||||||
char* cfgfile = CONFIGFILE;
|
char* cfgfile = CONFIGFILE;
|
||||||
char* svr = NULL;
|
char* svr = NULL;
|
||||||
log_ident_set("unbound-control");
|
log_ident_set("unbound-control");
|
||||||
|
|
@ -310,11 +316,11 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go(cfgfile, svr, argc, argv);
|
ret = go(cfgfile, svr, argc, argv);
|
||||||
|
|
||||||
#ifdef USE_WINSOCK
|
#ifdef USE_WINSOCK
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
#endif
|
#endif
|
||||||
checklock_stop();
|
checklock_stop();
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
testdata/09-unbound-control.tpkg
vendored
Normal file
BIN
testdata/09-unbound-control.tpkg
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue