From 8bb6fd14439df87a2a324f432b6ff605da233414 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce <sponcec3@cern.ch> Date: Wed, 5 Sep 2012 15:39:34 +0000 Subject: [PATCH] Almost dropped site.def. Only security related flags remain there (7 lines) --- mediachanger/castorrmc/common/remote.c | 35 ++++++++------------------ mediachanger/castorrmc/common/serror.c | 22 ---------------- mediachanger/castorrmc/h/serrno.h | 15 ----------- mediachanger/castorrmc/rmc/Imakefile | 5 +--- mediachanger/castorrmc/rmc/rmclogit.c | 2 +- 5 files changed, 12 insertions(+), 67 deletions(-) diff --git a/mediachanger/castorrmc/common/remote.c b/mediachanger/castorrmc/common/remote.c index 6f7e85fa1c..247bcd9589 100644 --- a/mediachanger/castorrmc/common/remote.c +++ b/mediachanger/castorrmc/common/remote.c @@ -23,15 +23,6 @@ #include <serrno.h> #include <Cnetdb.h> -#define strtok(X,Y) strtok_r(X,Y,&last) - -#ifndef LOCALHOSTSFILE -#define LOCALHOSTSFILE "/etc/shift.localhosts" -#endif -#ifndef RTHOSTSFILE -#define RTHOSTSFILE "/etc/shift.rthosts" -#endif - extern char *getconfent(); /* @@ -59,16 +50,16 @@ int isremote(struct in_addr from_host, struct sockaddr_in addr; char *last = NULL; - char lhfile[CA_MAXPATHLEN+1] = LOCALHOSTSFILE; - char rthfile[CA_MAXPATHLEN+1] = RTHOSTSFILE; + char lhfile[CA_MAXPATHLEN+1] = "/etc/castor/castor.localhosts"; + char rthfile[CA_MAXPATHLEN+1] = "/etc/castor/castor.remhosts"; if ( (p=getconfent("SIMULATION","REMOTE",1))!=NULL && - (p=(char *)strtok(p," \t"))!=NULL && !strcmp(p,"YES")) { + (p=(char *)strtok_r(p," \t",&last))!=NULL && !strcmp(p,"YES")) { log(LOG_DEBUG,"isremote(): Client simulates remote behaviour\n"); return 1 ; } if ( (p=getconfent("ISREMOTE","CALLS",1))!=NULL && - (p=(char *)strtok(p," \t") )!=NULL && !strcmp(p,"NO") ) { + (p=(char *)strtok_r(p," \t",&last) )!=NULL && !strcmp(p,"NO") ) { log(LOG_DEBUG,"isremote(): Any connection assumed from local site\n"); return 0 ; } @@ -96,7 +87,7 @@ int isremote(struct in_addr from_host, log(LOG_DEBUG,"isremote(): searching <%s> in %s\n",host_name, rthfile); if ( (fs = fopen( rthfile, "r")) != NULL ) { while ( fgets(s,CA_MAXHOSTNAMELEN+1,fs) != NULL ) { - if ( (cp= strtok(s," \n\t"))!=NULL ) { + if ( (cp= strtok_r(s," \n\t",&last))!=NULL ) { if ( !isdigit(cp[0]) && (cp[0]!='#') && !strcmp(cp,host_name) ) { log(LOG_DEBUG,"isremote(): %s is in list of external hosts\n",cp); fclose(fs); @@ -104,8 +95,8 @@ int isremote(struct in_addr from_host, } if ( isdigit(cp[0]) ) { strcpy(ent,cp) ; - if ( strtok(cp,".") == NULL || - strtok(NULL,".") == NULL ) + if ( strtok_r(cp,".",&last) == NULL || + strtok_r(NULL,".",&last) == NULL ) log(LOG_DEBUG,"%s ignored: IP specification too short\n", ent); else { if ( !strncmp( ent, inet_ntoa( from_host ), strlen(ent))) { @@ -128,7 +119,7 @@ int isremote(struct in_addr from_host, log(LOG_DEBUG,"isremote(): searching <%s> in %s\n",host_name, lhfile); if ( (fs = fopen( lhfile, "r")) != NULL ) { while ( fgets(s,CA_MAXHOSTNAMELEN+1,fs) != NULL ) { - if ( (cp= strtok(s," \n\t")) != NULL ) { + if ( (cp= strtok_r(s," \n\t",&last)) != NULL ) { if ( !isdigit(cp[0]) && (cp[0]!='#') && !strcmp(cp,host_name) ) { log(LOG_DEBUG,"isremote(): %s is in list of local hosts\n",cp); fclose(fs); @@ -136,8 +127,8 @@ int isremote(struct in_addr from_host, } if ( isdigit(cp[0]) ) { strcpy(ent,cp) ; - if ( strtok(cp,".") == NULL || - strtok(NULL,".") == NULL ) + if ( strtok_r(cp,".",&last) == NULL || + strtok_r(NULL,".",&last) == NULL ) log(LOG_DEBUG,"%s ignored: IP specification too short \n", ent); else { if ( !strncmp( ent, inet_ntoa( from_host ), strlen(ent) )) { @@ -247,9 +238,6 @@ int CDoubleDnsLookup(int s, char *host) { int isadminhost(int s, char *peerhost) { int i, rc; -#if defined(ADMIN_HOSTS) - char *defined_admin_hosts = ADMIN_HOSTS; -#endif /* ADMIN_HOSTS */ char *admin_hosts, *admin_host; rc = CDoubleDnsLookup(s,peerhost); @@ -258,9 +246,6 @@ int isadminhost(int s, char *peerhost) { admin_host = admin_hosts = NULL; if ( admin_hosts == NULL ) admin_hosts = getenv("ADMIN_HOSTS"); if ( admin_hosts == NULL ) admin_hosts = getconfent("ADMIN","HOSTS",1); -#if defined(ADMIN_HOSTS) - if ( admin_hosts == NULL ) admin_hosts = defined_admin_hosts; -#endif /* ADMIN_HOSTS */ if ( (admin_hosts != NULL) && ((admin_host = strstr(admin_hosts,peerhost)) != NULL) ) { diff --git a/mediachanger/castorrmc/common/serror.c b/mediachanger/castorrmc/common/serror.c index eb54174649..8542e1096a 100644 --- a/mediachanger/castorrmc/common/serror.c +++ b/mediachanger/castorrmc/common/serror.c @@ -359,23 +359,6 @@ char *sys_uperrlist[EUPMAXERR-EUPBASEOFF+2] = }; -/* - *------------------------------------------------------------------------ - * Expert service specific error messages - *------------------------------------------------------------------------ - */ -char *sys_experrlist[EEXPMAXERR-EEXPBASEOFF+2] = - {"Error 0", - "Expert service not active", - "Illegal request", - "Can't open the configuration file", - "Request wasn't found in the configuration file", - "Configuration file format error", - "Can't launch execv()", - "Can't change to working directory", - "BAD ERROR NUMBER" - }; - /* *------------------------------------------------------------------------ * DNS specific error messages @@ -550,11 +533,6 @@ char * sstrerror_r(n,buf,buflen) * UPV specific error messages */ tmpstr = sys_uperrlist[n-EUPBASEOFF]; - } else if ((n>EEXPBASEOFF) && (n<=EEXPMAXERR)) { - /* - * Expert service specific error messages - */ - tmpstr = sys_experrlist[n-EEXPBASEOFF]; } else if ((n>EDNSBASEOFF) && (n<=EDNSMAXERR)) { /* * DNS specific error messages diff --git a/mediachanger/castorrmc/h/serrno.h b/mediachanger/castorrmc/h/serrno.h index 02d5cead7f..c8174de6dd 100644 --- a/mediachanger/castorrmc/h/serrno.h +++ b/mediachanger/castorrmc/h/serrno.h @@ -33,7 +33,6 @@ #define EMONBASEOFF 2300 /* Monitoring Error base offset */ #define EUPBASEOFF 2400 /* UPV error base offset */ #define ESECBASEOFF 2700 /* Security error base offset */ -#define EEXPBASEOFF 2900 /* Expert system error base offset */ #define EDNSBASEOFF 3000 /* DNS error base offset */ #define SENOERR SEBASEOFF /* No error */ @@ -357,20 +356,6 @@ #define ECUPVNACT EUPBASEOFF+1 /* User Privilege Validator not active or service being drained */ #define EUPMAXERR EUPBASEOFF+1 -/* - *------------------------------------------------------------------------ - * Expert service errors - *------------------------------------------------------------------------ - */ -#define EEXPNACT EEXPBASEOFF+1 /* Service not active */ -#define EEXPILLREQ EEXPBASEOFF+2 /* Illegal request */ -#define EEXPNOCONFIG EEXPBASEOFF+3 /* Can't open the configuration file */ -#define EEXPRQNOTFOUND EEXPBASEOFF+4 /* Request wasn't found in the configuration file */ -#define EEXPCONFERR EEXPBASEOFF+5 /* Configuration file format error */ -#define EEXPEXECV EEXPBASEOFF+6 /* Can't launch execv() */ -#define EEXPCDWDIR EEXPBASEOFF+7 /* Can't change to working directory */ -#define EEXPMAXERR EEXPBASEOFF+7 - /* *------------------------------------------------------------------------ * DNS errors - See netdb.h for details diff --git a/mediachanger/castorrmc/rmc/Imakefile b/mediachanger/castorrmc/rmc/Imakefile index 58cec6cfb8..1f2daa300e 100644 --- a/mediachanger/castorrmc/rmc/Imakefile +++ b/mediachanger/castorrmc/rmc/Imakefile @@ -6,18 +6,15 @@ COMM @(#)$RCSfile: Imakefile,v $ $Revision: 1.8 $ $Date: 2009/08/18 09:43: COMM Make SCSI media changer server programs. -CPPFLAGS += -DRMCLOGFILE=RmcLogFile - TapeDependsOnLibrary(common,castorcommon) TapeDependsOnLibrary(upv,castorupv) TapeDependsOnLibrary(dlf,castordlf) TapeDependsOnLibrary(tape,castortape) RMCD_OBJS = rmc_serv.o rmc_procreq.o rmclogit.o sendrep.o usrmsg.o -OPSGRP = OperatorGid TapeProgramTarget(rmcd,$(RMCD_OBJS),,,755) ADMMANPAGE(rmcd) -TapeMakeDir(LogPath,0755) +TapeMakeDir($(LOGPATH),0755) LOGROTATE(castor-rmc-server,installtape) SYSCONFIG(rmcd,installtape) INITSCRIPT(rmcd,installtape) diff --git a/mediachanger/castorrmc/rmc/rmclogit.c b/mediachanger/castorrmc/rmc/rmclogit.c index 2145cd54e6..dd93368c7f 100644 --- a/mediachanger/castorrmc/rmc/rmclogit.c +++ b/mediachanger/castorrmc/rmc/rmclogit.c @@ -31,7 +31,7 @@ int rmclogit(char *func, char *msg, ...) tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, jid, func); vsprintf (prtbuf+strlen(prtbuf), msg, args); va_end (args); - fd_log = open (RMCLOGFILE, O_WRONLY | O_CREAT | O_APPEND, 0664); + fd_log = open("/var/log/castor/rmcd_legacy.log", O_WRONLY | O_CREAT | O_APPEND, 0664); if (fd_log < 0) return -1; write (fd_log, prtbuf, strlen(prtbuf)); close (fd_log); -- GitLab