fence_virt: Rename challenge functions

Rename the challenge/response functions to be more accurate. They need
not be opeating on TCP sockets.

Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
This commit is contained in:
Ryan McCabe 2017-07-27 14:38:05 -04:00
parent 30baac19ab
commit c0dacabadf
7 changed files with 19 additions and 12 deletions

View File

@ -129,7 +129,7 @@ tcp_exchange(int fd, fence_auth_type_t auth, void *key,
/* Ok, we're connected */
dbg_printf(3, "Issuing TCP challenge\n");
if (tcp_challenge(fd, auth, key, key_len, timeout) <= 0) {
if (sock_challenge(fd, auth, key, key_len, timeout) <= 0) {
/* Challenge failed */
printf("Invalid response to challenge\n");
return 1;
@ -137,7 +137,7 @@ tcp_exchange(int fd, fence_auth_type_t auth, void *key,
/* Now they'll send us one, so we need to respond here */
dbg_printf(3, "Responding to TCP challenge\n");
if (tcp_response(fd, auth, key, key_len, timeout) <= 0) {
if (sock_response(fd, auth, key, key_len, timeout) <= 0) {
printf("Invalid response to challenge\n");
return 1;
}

View File

@ -49,7 +49,7 @@ tcp_exchange(int fd, fence_auth_type_t auth, void *key,
/* Ok, we're connected */
dbg_printf(3, "Issuing TCP challenge\n");
if (tcp_challenge(fd, auth, key, key_len, timeout) <= 0) {
if (sock_challenge(fd, auth, key, key_len, timeout) <= 0) {
/* Challenge failed */
printf("Invalid response to challenge\n");
return 1;
@ -57,7 +57,7 @@ tcp_exchange(int fd, fence_auth_type_t auth, void *key,
/* Now they'll send us one, so we need to respond here */
dbg_printf(3, "Responding to TCP challenge\n");
if (tcp_response(fd, auth, key, key_len, timeout) <= 0) {
if (sock_response(fd, auth, key, key_len, timeout) <= 0) {
printf("Invalid response to challenge\n");
return 1;
}

View File

@ -380,7 +380,7 @@ sha_response(int fd, fence_auth_type_t auth, void *key,
int
tcp_challenge(int fd, fence_auth_type_t auth, void *key, size_t key_len,
sock_challenge(int fd, fence_auth_type_t auth, void *key, size_t key_len,
int timeout)
{
switch(auth) {
@ -399,7 +399,7 @@ tcp_challenge(int fd, fence_auth_type_t auth, void *key, size_t key_len,
int
tcp_response(int fd, fence_auth_type_t auth, void *key, size_t key_len,
sock_response(int fd, fence_auth_type_t auth, void *key, size_t key_len,
int timeout)
{
switch(auth) {

View File

@ -25,8 +25,8 @@
#define DEFAULT_KEY_FILE "/etc/cluster/fence_xvm.key"
int read_key_file(char *, char *, size_t);
int tcp_challenge(int, fence_auth_type_t, void *, size_t, int);
int tcp_response(int, fence_auth_type_t, void *, size_t, int);
int sock_challenge(int, fence_auth_type_t, void *, size_t, int);
int sock_response(int, fence_auth_type_t, void *, size_t, int);
int sign_request(fence_req_t *, void *, size_t);
int verify_request(fence_req_t *, fence_hash_t, void *, size_t);

View File

@ -49,6 +49,7 @@ pm_fence_so_SOURCES = pm-fence.c
cpg_so_SOURCES = cpg-virt.c cpg.c virt.c history.c uuid-test.c
multicast_so_SOURCES = mcast.c history.c
tcp_so_SOURCES = tcp.c history.c
vsock_so_SOURCES = vsock.c history.c
serial_so_SOURCES = virt-serial.c virt-sockets.c serial.c history.c
@ -64,6 +65,7 @@ mod_cpg=@mod_cpg@
mod_multicast=@mod_multicast@
mod_serial=@mod_serial@
mod_tcp=@mod_tcp@
mod_vsock=@mod_vsock@
################################
ifeq ($(with_modules),yes)
@ -95,6 +97,9 @@ endif
ifneq ($(mod_tcp),no)
MODULES+=tcp.so
endif
ifneq ($(mod_vsock),no)
MODULES+=vsock.so
endif
ifneq ($(mod_null),no)
MODULES+=null.so
endif

View File

@ -165,13 +165,13 @@ connect_tcp(fence_req_t *req, fence_auth_type_t auth,
}
/* Noops if auth == AUTH_NONE */
if (tcp_response(fd, auth, key, key_len, 10) <= 0) {
if (sock_response(fd, auth, key, key_len, 10) <= 0) {
printf("Failed to respond to challenge\n");
close(fd);
return -1;
}
if (tcp_challenge(fd, auth, key, key_len, 10) <= 0) {
if (sock_challenge(fd, auth, key, key_len, 10) <= 0) {
printf("Remote failed challenge\n");
close(fd);
return -1;

View File

@ -167,15 +167,17 @@ do_fence_request_tcp(int fd, fence_req_t *req, tcp_info *info)
char ip_addr_src[1024];
char response = 1;
struct tcp_hostlist_arg arg;
int ret;
/* Noops if auth == AUTH_NONE */
if (tcp_response(fd, info->args.auth, info->key, info->key_len, 10) <= 0) {
if (sock_response(fd, info->args.auth, info->key, info->key_len, 10) <= 0) {
printf("Failed to respond to challenge\n");
close(fd);
return -1;
}
if (tcp_challenge(fd, info->args.auth, info->key, info->key_len, 10) <= 0) {
ret = sock_challenge(fd, info->args.auth, info->key, info->key_len, 10);
if (ret <= 0) {
printf("Remote failed challenge\n");
close(fd);
return -1;