Commit f035b16d authored by Steven Murray's avatar Steven Murray
Browse files

tpconfig and tpstat now use the TapeServer:AdminPort configuration parameter

parent 556eea3e
......@@ -21,6 +21,10 @@
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <time.h>
namespace castor {
namespace tape {
namespace tapeserver {
......@@ -99,4 +103,3 @@ const int TAPESERVER_DB_TIMEOUT = 60 * 5; // 5 minutes
} // namespace tapeserver
} // namespace tape
} // namespace castor
......@@ -26,8 +26,14 @@ if (${COMPILE_SERVER} STREQUAL "1")
################################################################################
# Rules to build and install tpconfig
################################################################################
add_executable (tpconfig tpconfig.cpp Ctape_config.c send2tpd.c Ctape_errmsg.c
Ctape_status.c TpConfigCmdLine.cpp TpConfigException.cpp)
add_executable (tpconfig
tpconfig.cpp
Ctape_config.c
send2tpd.cpp
Ctape_errmsg.c
Ctape_status.c
TpConfigCmdLine.cpp
TpConfigException.cpp)
target_link_libraries (tpconfig castorcommon)
install (TARGETS tpconfig DESTINATION ${CASTOR_DEST_BIN_DIR})
CastorInstallExeManPage (tpconfig)
......@@ -35,7 +41,11 @@ if (${COMPILE_SERVER} STREQUAL "1")
################################################################################
# Rules to build and install tpstat
################################################################################
add_executable (tpstat tpstat.c Ctape_status.c send2tpd.c Ctape_errmsg.c)
add_executable (tpstat
tpstat.c
Ctape_status.c
send2tpd.cpp
Ctape_errmsg.c)
target_link_libraries (tpstat castorcommon)
install (TARGETS tpstat DESTINATION ${CASTOR_DEST_BIN_DIR})
CastorInstallExeManPage (tpstat)
......
......@@ -5,6 +5,15 @@
* All rights reserved
*/
#include "castor/tape/tapeserver/daemon/Constants.hpp"
#include "h/Cnetdb.h"
#include "h/Ctape.h"
#include "h/Ctape_api.h"
#include "h/getconfent.h"
#include "h/marshall.h"
#include "h/net.h"
#include "h/serrno.h"
#include <errno.h>
#include <sys/types.h>
#include <stdlib.h>
......@@ -12,16 +21,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include "Cnetdb.h"
#include <stddef.h>
#include "Ctape.h"
#include "marshall.h"
#include "net.h"
#include "serrno.h"
#ifdef TPCSEC
#include "Csec_api.h"
#endif
#include "Ctape_api.h"
/* send2tpd - send a request to the tape daemon and wait for the reply */
......@@ -34,8 +34,6 @@ int send2tpd(char *host,
int actual_replen = 0;
int c;
char func[16];
char *getconfent();
char *getenv();
struct hostent *hp;
int magic;
int n;
......@@ -45,43 +43,17 @@ int send2tpd(char *host,
char repbuf[REPBUFSZ];
int s;
struct sockaddr_in sin; /* internet socket */
struct servent *sp;
char tapehost[CA_MAXHOSTNAMELEN+1];
#ifdef TPCSEC
Csec_context_t ctx;
int secure_connection = 0;
#endif
strncpy (func, "send2tpd", 16);
#ifdef TPCSEC
if (getenv("SECURE_CASTOR") != NULL) secure_connection++;
#endif
sin.sin_family = AF_INET;
#ifdef TPCSEC
if (secure_connection) {
if ((p = getenv ("STAPE_PORT")) || (p = getconfent ("STAPE", "PORT", 0))) {
sin.sin_port = htons ((unsigned short)atoi (p));
} else if (sp = Cgetservbyname ("stape", "tcp")) {
sin.sin_port = sp->s_port;
serrno = 0;
} else {
sin.sin_port = htons ((unsigned short)STAPE_PORT);
serrno = 0;
}
if ((p = getconfent ("TapeServer", "AdminPort", 0))) {
sin.sin_port = htons ((unsigned short)atoi (p));
} else {
#endif
if ((p = getenv ("TAPE_PORT")) || (p = getconfent ("TAPE", "PORT", 0))) {
sin.sin_port = htons ((unsigned short)atoi (p));
} else if ((sp = Cgetservbyname ("tape", "tcp"))) {
sin.sin_port = sp->s_port;
serrno = 0;
} else {
sin.sin_port = htons ((unsigned short)TAPE_PORT);
serrno = 0;
}
#ifdef TPCSEC
using namespace castor::tape::tapeserver::daemon;
sin.sin_port = htons (TAPESERVER_ADMIN_PORT);
serrno = 0;
}
#endif
if (host == NULL) {
gethostname (tapehost, CA_MAXHOSTNAMELEN+1);
} else {
......@@ -113,29 +85,6 @@ int send2tpd(char *host,
return (-1);
}
}
#ifdef TPCSEC
if (secure_connection) {
if (Csec_client_initContext(&ctx, CSEC_SERVICE_TYPE_TAPE, NULL) <0) {
Ctape_errmsg (func, TP002, "send", "Could not init context");
(void) close (s);
serrno = ESEC_CTX_NOT_INITIALIZED;
return -1;
}
if(Csec_client_establishContext(&ctx, s)< 0) {
Ctape_errmsg (func, "%s: %s\n",
"send",
"Could not establish context");
(void) close (s);
serrno = ESEC_NO_CONTEXT;
return -1;
}
Csec_clearContext(&ctx);
}
#endif
/* send request to tape daemon */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment