aboutsummaryrefslogtreecommitdiff
path: root/smallapp/unbound-control.c
diff options
context:
space:
mode:
Diffstat (limited to 'smallapp/unbound-control.c')
-rw-r--r--smallapp/unbound-control.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/smallapp/unbound-control.c b/smallapp/unbound-control.c
index 3ea6aa033c08..ed8bad1e9719 100644
--- a/smallapp/unbound-control.c
+++ b/smallapp/unbound-control.c
@@ -423,19 +423,19 @@ static void print_stats_shm(const char* cfgfile)
if(!config_read(cfg, cfgfile, NULL))
fatal_exit("could not read config file");
/* get shm segments */
- id_ctl = shmget(cfg->shm_key, sizeof(int), SHM_R|SHM_W);
+ id_ctl = shmget(cfg->shm_key, sizeof(int), SHM_R);
if(id_ctl == -1) {
fatal_exit("shmget(%d): %s", cfg->shm_key, strerror(errno));
}
- id_arr = shmget(cfg->shm_key+1, sizeof(int), SHM_R|SHM_W);
+ id_arr = shmget(cfg->shm_key+1, sizeof(int), SHM_R);
if(id_arr == -1) {
fatal_exit("shmget(%d): %s", cfg->shm_key+1, strerror(errno));
}
- shm_stat = (struct ub_shm_stat_info*)shmat(id_ctl, NULL, 0);
+ shm_stat = (struct ub_shm_stat_info*)shmat(id_ctl, NULL, SHM_RDONLY);
if(shm_stat == (void*)-1) {
fatal_exit("shmat(%d): %s", id_ctl, strerror(errno));
}
- stats = (struct ub_stats_info*)shmat(id_arr, NULL, 0);
+ stats = (struct ub_stats_info*)shmat(id_arr, NULL, SHM_RDONLY);
if(stats == (void*)-1) {
fatal_exit("shmat(%d): %s", id_arr, strerror(errno));
}
@@ -499,6 +499,12 @@ setup_ctx(struct config_file* cfg)
if((SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv3) & SSL_OP_NO_SSLv3)
!= SSL_OP_NO_SSLv3)
ssl_err("could not set SSL_OP_NO_SSLv3");
+#if defined(SSL_OP_NO_RENEGOTIATION)
+ /* disable client renegotiation */
+ if((SSL_CTX_set_options(ctx, SSL_OP_NO_RENEGOTIATION) &
+ SSL_OP_NO_RENEGOTIATION) != SSL_OP_NO_RENEGOTIATION)
+ ssl_err("could not set SSL_OP_NO_RENEGOTIATION");
+#endif
if(!SSL_CTX_use_certificate_chain_file(ctx,c_cert))
ssl_path_err("Error setting up SSL_CTX client cert", c_cert);
if (!SSL_CTX_use_PrivateKey_file(ctx,c_key,SSL_FILETYPE_PEM))
@@ -609,7 +615,7 @@ setup_ssl(SSL_CTX* ctx, int fd)
if(!ssl)
ssl_err("could not SSL_new");
SSL_set_connect_state(ssl);
- (void)SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
+ (void)SSL_set_mode(ssl, (long)SSL_MODE_AUTO_RETRY);
if(!SSL_set_fd(ssl, fd))
ssl_err("could not SSL_set_fd");
while(1) {
@@ -684,6 +690,27 @@ remote_write(SSL* ssl, int fd, const char* buf, size_t len)
}
}
+/** check args, to see if too many args. Because when a file is sent it
+ * would wait for the terminal, and we can check for too many arguments,
+ * eg. user put arguments on the commandline. */
+static void
+check_args_for_listcmd(int argc, char* argv[])
+{
+ if(argc >= 1 && (strcmp(argv[0], "local_zones") == 0 ||
+ strcmp(argv[0], "local_zones_remove") == 0 ||
+ strcmp(argv[0], "local_datas") == 0 ||
+ strcmp(argv[0], "local_datas_remove") == 0) &&
+ argc >= 2) {
+ fatal_exit("too many arguments for command '%s', "
+ "content is piped in from stdin", argv[0]);
+ }
+ if(argc >= 1 && strcmp(argv[0], "view_local_datas") == 0 &&
+ argc >= 3) {
+ fatal_exit("too many arguments for command '%s', "
+ "content is piped in from stdin", argv[0]);
+ }
+}
+
/** send stdin to server */
static void
send_file(SSL* ssl, int fd, FILE* in, char* buf, size_t sz)
@@ -847,6 +874,7 @@ int main(int argc, char* argv[])
print_stats_shm(cfgfile);
return 0;
}
+ check_args_for_listcmd(argc, argv);
#ifdef USE_WINSOCK
if((r = WSAStartup(MAKEWORD(2,2), &wsa_data)) != 0)
@@ -860,7 +888,9 @@ int main(int argc, char* argv[])
ERR_load_SSL_strings();
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000 || !defined(HAVE_OPENSSL_INIT_CRYPTO)
+# ifndef S_SPLINT_S
OpenSSL_add_all_algorithms();
+# endif
#else
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS
| OPENSSL_INIT_ADD_ALL_DIGESTS