#include <rx/xdr.h>
#include <afs/afsint.h>
-#include <afs/afs_assert.h>
#include <afs/prs_fs.h>
#include <afs/nfs.h>
#include <afs/vlserver.h>
#define XBSA_TCMAIN
#include "butc_xbsa.h"
#include "butc_prototypes.h"
+#include "butc_internal.h"
#define N_SECURITY_OBJECTS 3
#define ERRCODE_RANGE 8 /* from error_table.h */
#define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
afs_uint32 SHostAddrs[ADDRSPERSITE];
-/* dummy routine for the audit work. It should do nothing since audits */
-/* occur at the server level and bos is not a server. */
-int
-osi_audit(void)
-{
- return 0;
-}
-
static afs_int32
SafeATOL(char *anum)
{
*pos = '_';
strcat(logFile, deviceName);
/* now put back deviceName to the way it was */
- if (mvFlag) {
- mvFlag = 0;
+ if (mvFlag)
deviceName -= devPrefLen;
- }
+
strcpy(deviceName, storeDevice);
return (0);
continue;
}
- opencallout = (char *)malloc(strlen(value) + 1);
- strcpy(opencallout, value);
+ opencallout = strdup(value);
printf("Tape mount callout routine is %s\n", opencallout);
}
continue;
}
- closecallout = (char *)malloc(strlen(value) + 1);
- strcpy(closecallout, value);
+ closecallout = strdup(value);
printf("Tape unmount callout routine is %s\n", closecallout);
}
cmd);
continue;
}
- xbsaObjectOwner = malloc(strlen(value) + 1);
- strcpy(xbsaObjectOwner, value);
+ xbsaObjectOwner = strdup(value);
printf("XBSA node is %s\n", xbsaObjectOwner);
}
cmd);
continue;
}
- adsmServerName = malloc(strlen(value) + 1);
- strcpy(adsmServerName, value);
+ adsmServerName = strdup(value);
printf("XBSA server is %s\n", adsmServerName);
}
continue;
}
- xbsaSecToken = malloc(strlen(value) + 1);
- strcpy(xbsaSecToken, value);
+ xbsaSecToken = strdup(value);
printf("XBSA Password has been read\n");
}
cmd);
continue;
}
- xbsalGName = malloc(strlen(value) + 1);
- strcpy(xbsalGName, value);
+ xbsalGName = strdup(value);
printf("XBSA management class is %s\n", xbsalGName);
}
#endif
}
else if (!strcmp(cmd, "CENTRALLOG")) {
- centralLogFile = malloc(strlen(value) + 1);
- strcpy(centralLogFile, value);
+ centralLogFile = strdup(value);
printf("Central log file is %s\n", centralLogFile);
}
return (code);
}
+#ifdef xbsa
+static void
+xbsa_shutdown(int x)
+{
+ xbsa_Finalize(&butxInfo);
+ exit(0);
+}
+#endif
+
static int
WorkerBee(struct cmd_syndesc *as, void *arock)
{
afs_int32 code;
- struct rx_securityClass *(securityObjects[3]);
+ struct rx_securityClass *(securityObjects[1]);
struct rx_service *service;
time_t tokenExpires;
char cellName[64];
}
if (as->parms[6].items) { /* -restoretofile */
- int s = strlen(as->parms[6].items->data);
- restoretofile = malloc(s + 1);
- strncpy(restoretofile, as->parms[6].items->data, s + 1);
+ restoretofile = strdup(as->parms[6].items->data);
printf("Restore to file '%s'\n", restoretofile);
}
struct stat sbuf;
afs_int32 statcode;
#ifndef AFS_NT40_ENV
- char path[AFSDIR_PATH_MAX];
+ char *path;
#endif
statcode = stat(centralLogFile, &sbuf);
}
#ifndef AFS_NT40_ENV
/* Make sure it is not in AFS, has to have been created first */
- if (!realpath(centralLogFile, path)) {
+ path = malloc(AFSDIR_PATH_MAX);
+ if (path == NULL || !realpath(centralLogFile, path)) {
fprintf(stderr,
"Warning: can't determine real path of '%s' (%d)\n",
centralLogFile, errno);
exit(1);
}
}
+ free(path);
#endif
/* Write header if created it */
rc = InitToServer(0 /*taskid */ , &butxInfo, adsmServerName);
if (rc != XBSA_SUCCESS)
return (1);
+ (void)signal(SIGINT, xbsa_shutdown);
+ (void)signal(SIGHUP, xbsa_shutdown);
}
#endif /*xbsa */
if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
AFSDIR_SERVER_NETINFO_FILEPATH) {
char reason[1024];
- ccode = parseNetFiles(SHostAddrs, NULL, NULL,
- ADDRSPERSITE, reason,
- AFSDIR_SERVER_NETINFO_FILEPATH,
- AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+ ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+ ADDRSPERSITE, reason,
+ AFSDIR_SERVER_NETINFO_FILEPATH,
+ AFSDIR_SERVER_NETRESTRICT_FILEPATH);
} else
{
ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
/*initialize the dumpNode list */
InitNodeList(portOffset);
- deviceLatch =
- (struct deviceSyncNode *)(malloc(sizeof(struct deviceSyncNode)));
+ deviceLatch = malloc(sizeof(struct deviceSyncNode));
Lock_Init(&(deviceLatch->lock));
deviceLatch->flags = 0;
* security on connections made to this server
*/
- securityObjects[0] = rxnull_NewServerSecurityObject();
- securityObjects[1] = (struct rx_securityClass *)0; /* don't bother with rxvab */
- if (!securityObjects[0]) {
+ securityObjects[RX_SECIDX_NULL] = rxnull_NewServerSecurityObject();
+ if (!securityObjects[RX_SECIDX_NULL]) {
TLog(0, "rxnull_NewServerSecurityObject");
exit(1);
}
service =
- rx_NewServiceHost(host, 0, 1, "BUTC", securityObjects, 3, TC_ExecuteRequest);
+ rx_NewServiceHost(host, 0, 1, "BUTC", securityObjects, 1, TC_ExecuteRequest);
if (!service) {
TLog(0, "rx_NewService");
exit(1);
setlinebuf(stdout);
- ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, "tape coordinator");
+ ts = cmd_CreateSyntax(NULL, WorkerBee, NULL, 0, "tape coordinator");
cmd_AddParm(ts, "-port", CMD_SINGLE, CMD_OPTIONAL, "port offset");
cmd_AddParm(ts, "-debuglevel", CMD_SINGLE, CMD_OPTIONAL, "0 | 1 | 2");
cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
/* setup the file paths */
strcompose(eFile, AFSDIR_PATH_MAX, AFSDIR_SERVER_BACKUP_DIRPATH, "/",
- TE_PREFIX, NULL);
+ TE_PREFIX, (char *)NULL);
strcompose(lFile, AFSDIR_PATH_MAX, AFSDIR_SERVER_BACKUP_DIRPATH, "/",
- TL_PREFIX, NULL);
+ TL_PREFIX, (char *)NULL);
strcompose(pFile, AFSDIR_PATH_MAX, AFSDIR_SERVER_BACKUP_DIRPATH, "/",
- CFG_PREFIX, NULL);
+ CFG_PREFIX, (char *)NULL);
strcpy(tapeConfigFile, AFSDIR_SERVER_TAPECONFIG_FILEPATH);
/* special case "no args" case since cmd_dispatch gives help message
* instead
*/
if (argc == 1) {
- ts = (struct cmd_syndesc *)malloc(sizeof(struct cmd_syndesc));
- memset(ts, 0, sizeof(*ts));
+ ts = calloc(1, sizeof(struct cmd_syndesc));
- ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
+ ti = malloc(sizeof(struct cmd_item));
ti->next = 0;
ti->data = "0";
ts->parms[0].items = ti;
- ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
+ ti = malloc(sizeof(struct cmd_item));
ti->next = 0;
ti->data = "0";
ts->parms[1].items = ti;
- ts->parms[2].items = (struct cmd_item *)NULL;
- ts->parms[3].items = (struct cmd_item *)NULL;
- ts->parms[4].items = (struct cmd_item *)NULL;
- ts->parms[5].items = (struct cmd_item *)NULL;
+ ts->parms[2].items = NULL;
+ ts->parms[3].items = NULL;
+ ts->parms[4].items = NULL;
+ ts->parms[5].items = NULL;
return WorkerBee(ts, NULL);
} else
return cmd_Dispatch(argc, argv);