#include <afsconfig.h>
#include <afs/param.h>
+#include <afs/stds.h>
+#include <roken.h>
-#include <fcntl.h>
-#include <sys/stat.h>
#ifdef AFS_NT40_ENV
-#include <winsock2.h>
#include <WINNT/afsevent.h>
-#else
-#include <netinet/in.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <netdb.h>
#endif
-#include <string.h>
-#include <afs/stds.h>
-#include <sys/types.h>
-#include <time.h>
-#include <stdio.h>
#include <afs/cmd.h>
#include <lwp.h>
#include <ubik.h>
#include <afs/bubasics.h>
#include <afs/afsutil.h>
#include <afs/com_err.h>
-#include <errno.h>
-#ifdef AFS_AIX32_ENV
-#include <signal.h>
-#endif
+#include <afs/audit.h>
+
#include "budb_errs.h"
#include "database.h"
#include "error_macros.h"
#include "budb_internal.h"
#include "globals.h"
-#include "afs/audit.h"
struct ubik_dbase *BU_dbase;
struct afsconf_dir *BU_conf; /* for getting cell info */
#define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
afs_uint32 SHostAddrs[ADDRSPERSITE];
-#if defined(AFS_PTHREAD_ENV)
-static int
-threadNum(void)
-{
- return (intptr_t)pthread_getspecific(rx_thread_id_key);
-}
-#endif
-
/* check whether caller is authorized to manage RX statistics */
int
BU_rxstat_userok(struct rx_call *call)
return afsconf_SuperUser(BU_conf, call, NULL);
}
+/**
+ * Return true if this name is a member of the local realm.
+ */
+int
+BU_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
+{
+ struct afsconf_dir *dir = (struct afsconf_dir *)rock;
+ afs_int32 islocal = 0; /* default to no */
+ int code;
+
+ code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell);
+ if (code) {
+ LogError(code, "Failed local realm check; name=%s, inst=%s, cell=%s\n",
+ name, inst, cell);
+ }
+ return islocal;
+}
+
int
convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_uint32 *myHost,
afs_uint32 *serverList)
/* database directory */
if (as->parms[0].items != 0) {
- globalConfPtr->databaseDirectory =
- (char *)malloc(strlen(as->parms[0].items->data) + 1);
+ globalConfPtr->databaseDirectory = strdup(as->parms[0].items->data);
if (globalConfPtr->databaseDirectory == 0)
BUDB_EXIT(-1);
- strcpy(globalConfPtr->databaseDirectory, as->parms[0].items->data);
}
/* -cellservdb, cell configuration directory */
if (as->parms[1].items != 0) {
- globalConfPtr->cellConfigdir =
- (char *)malloc(strlen(as->parms[1].items->data) + 1);
+ globalConfPtr->cellConfigdir = strdup(as->parms[1].items->data);
if (globalConfPtr->cellConfigdir == 0)
BUDB_EXIT(-1);
- strcpy(globalConfPtr->cellConfigdir, as->parms[1].items->data);
-
globalConfPtr->debugFlags |= DF_RECHECKNOAUTH;
}
afs_int32 code = 0;
int fd;
- path =
- (char *)malloc(strlen(globalConfPtr->databaseDirectory) +
- strlen(globalConfPtr->databaseName) +
- strlen(globalConfPtr->databaseExtension) + 1);
- if (path == 0)
+ asprintf(&path, "%s%s%s",
+ globalConfPtr->databaseDirectory,
+ globalConfPtr->databaseName,
+ globalConfPtr->databaseExtension);
+ if (path == NULL)
ERROR(-1);
- /* construct the database name */
- strcpy(path, globalConfPtr->databaseDirectory);
- strcat(path, globalConfPtr->databaseName);
- strcat(path, globalConfPtr->databaseExtension);
-
fd = open(path, O_RDWR, 0755);
if (!fd) {
code = errno;
close(fd);
}
+ free(path);
+
error_exit:
return (code);
}
srandom(1);
#ifdef AFS_PTHREAD_ENV
- SetLogThreadNumProgram( threadNum );
+ SetLogThreadNumProgram( rx_GetThreadNum );
#endif
/* process the user supplied args */
ERROR(code);
}
- /* initialize ubik */
- ubik_CRXSecurityProc = afsconf_ClientAuth;
- ubik_CRXSecurityRock = BU_conf;
-
- ubik_SRXSecurityProc = afsconf_ServerAuth;
- ubik_SRXSecurityRock = BU_conf;
+ /* initialize audit user check */
+ osi_audit_set_user_check(BU_conf, BU_IsLocalRealmMatch);
- ubik_CheckRXSecurityProc = afsconf_CheckAuth;
- ubik_CheckRXSecurityRock = BU_conf;
+ /* initialize ubik */
+ ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, BU_conf);
+ ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
+ afsconf_CheckAuth, BU_conf);
if (ubik_nBuffers == 0)
ubik_nBuffers = 400;
LogError(0, "Will allocate %d ubik buffers\n", ubik_nBuffers);
- dbNamePtr =
- (char *)malloc(strlen(globalConfPtr->databaseDirectory) +
- strlen(globalConfPtr->databaseName) + 1);
+ asprintf(&dbNamePtr, "%s%s", globalConfPtr->databaseDirectory,
+ globalConfPtr->databaseName);
if (dbNamePtr == 0)
ERROR(-1);
- /* construct the database name */
- strcpy(dbNamePtr, globalConfPtr->databaseDirectory);
- strcat(dbNamePtr, globalConfPtr->databaseName); /* name prefix */
-
rx_SetRxDeadTime(60); /* 60 seconds inactive before timeout */
if (rxBind) {
}
}
+ /* Disable jumbograms */
+ rx_SetNoJumbo();
+
code = ubik_ServerInitByInfo (globalConfPtr->myHost,
htons(AFSCONF_BUDBPORT),
&cellinfo,
ERROR(code);
}
- afsconf_BuildServerSecurityObjects(BU_conf, 0,
- &securityClasses, &numClasses);
-
- /* Disable jumbograms */
- rx_SetNoJumbo();
+ afsconf_BuildServerSecurityObjects(BU_conf, &securityClasses, &numClasses);
tservice =
rx_NewServiceHost(host, 0, BUDB_SERVICE, "BackupDatabase",