mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 23:10:58 +00:00
2630e70550
Each server process can log a couple of different warnings about the server keys found on disk: - If afsconf_GetLatestKey() returns success (indicating a single-DES key is present), we call LogDesWarning(). - If afsconf_CountKeys() returns 0 (indicating there are no keys at all on disk), we log a warning that all authenticated access will fail. Currently, the code to do these checks and log the relevant warning is duplicated across the startup code for nearly every server process. To avoid this duplication, and to make sure the checks aren't accidentally skipped for anyone, move these checks to afsconf_BuildServerSecurityObjects, which every server process calls. We must add an additional parameter to afsconf_BuildServerSecurityObjects to handle the different logging mechanism these servers use, but afsconf_BuildServerSecurityObjects is declared in a public header (cellconfig.h), and is exported in a public library (libafsauthent). So to avoid changing a public symbol, introduce a new variant of the function, called afsconf_BuildServerSecurityObjects_int. Declare this in a new internal header, authcon.h. We don't have easily-usable logging functions for upserver and butc, so just don't log the warnings for those. For ubik servers, don't update ubik_SetServerSecurityProcs to use the new function; the initial call to afsconf_BuildServerSecurityObjects_int in the server's startup code will cover logging the warning on startup. Change-Id: I5d5fceefdaf907f96db9f1c0d21ceb6957299a59 Reviewed-on: https://gerrit.openafs.org/10831 Tested-by: Andrew Deason <adeason@sinenomine.net> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
137 lines
3.0 KiB
C
137 lines
3.0 KiB
C
#include <afsconfig.h>
|
|
#include <afs/param.h>
|
|
|
|
#include <roken.h>
|
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
#include <sys/wait.h>
|
|
#endif
|
|
|
|
#include <rx/rx.h>
|
|
|
|
#include <afs/authcon.h>
|
|
#include <afs/cellconfig.h>
|
|
|
|
#include <tests/tap/basic.h>
|
|
|
|
#include "common.h"
|
|
|
|
/* Start up the VLserver, using the configuration in dirname, and putting our
|
|
* logs there too.
|
|
*/
|
|
|
|
int
|
|
afstest_StartVLServer(char *dirname, pid_t *serverPid)
|
|
{
|
|
pid_t pid;
|
|
int status;
|
|
|
|
pid = fork();
|
|
if (pid == -1) {
|
|
exit(1);
|
|
/* Argggggghhhhh */
|
|
} else if (pid == 0) {
|
|
char *binPath, *logPath, *dbPath, *build;
|
|
|
|
/* Child */
|
|
build = getenv("C_TAP_BUILD");
|
|
|
|
if (build == NULL)
|
|
build = "..";
|
|
|
|
if (asprintf(&binPath, "%s/../src/tvlserver/vlserver", build) < 0 ||
|
|
asprintf(&logPath, "%s/VLLog", dirname) < 0 ||
|
|
asprintf(&dbPath, "%s/vldb", dirname) < 0) {
|
|
fprintf(stderr, "Out of memory building vlserver arguments\n");
|
|
exit(1);
|
|
}
|
|
execl(binPath, "vlserver",
|
|
"-logfile", logPath, "-database", dbPath, "-config", dirname, NULL);
|
|
fprintf(stderr, "Running %s failed\n", binPath);
|
|
exit(1);
|
|
}
|
|
|
|
if (waitpid(pid, &status, WNOHANG) != 0) {
|
|
fprintf(stderr, "Error starting vlserver\n");
|
|
return -1;
|
|
}
|
|
|
|
diag("Sleeping for a few seconds to let the vlserver startup");
|
|
sleep(5);
|
|
|
|
if (waitpid(pid, &status, WNOHANG) != 0) {
|
|
fprintf(stderr, "vlserver died during startup\n");
|
|
return -1;
|
|
}
|
|
|
|
*serverPid = pid;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
afstest_StopServer(pid_t serverPid)
|
|
{
|
|
int status;
|
|
|
|
kill(serverPid, SIGTERM);
|
|
|
|
waitpid(serverPid, &status, 0);
|
|
|
|
if (WIFSIGNALED(status) && WTERMSIG(status) != SIGTERM) {
|
|
fprintf(stderr, "Server died exited on signal %d\n", WTERMSIG(status));
|
|
return -1;
|
|
}
|
|
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
|
|
fprintf(stderr, "Server exited with code %d\n", WEXITSTATUS(status));
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
afstest_StartTestRPCService(const char *configPath,
|
|
pid_t signal_pid,
|
|
u_short port,
|
|
u_short serviceId,
|
|
afs_int32 (*proc) (struct rx_call *))
|
|
{
|
|
struct afsconf_dir *dir;
|
|
struct rx_securityClass **classes;
|
|
afs_int32 numClasses;
|
|
int code;
|
|
struct rx_service *service;
|
|
struct afsconf_bsso_info bsso;
|
|
|
|
memset(&bsso, 0, sizeof(bsso));
|
|
|
|
dir = afsconf_Open(configPath);
|
|
if (dir == NULL) {
|
|
fprintf(stderr, "Server: Unable to open config directory\n");
|
|
return -1;
|
|
}
|
|
|
|
code = rx_Init(htons(port));
|
|
if (code != 0) {
|
|
fprintf(stderr, "Server: Unable to initialise RX\n");
|
|
return -1;
|
|
}
|
|
|
|
if (signal_pid != 0) {
|
|
kill(signal_pid, SIGUSR1);
|
|
}
|
|
|
|
bsso.dir = dir;
|
|
afsconf_BuildServerSecurityObjects_int(&bsso, &classes, &numClasses);
|
|
service = rx_NewService(0, serviceId, "test", classes, numClasses,
|
|
proc);
|
|
if (service == NULL) {
|
|
fprintf(stderr, "Server: Unable to start to test service\n");
|
|
return -1;
|
|
}
|
|
|
|
rx_StartServer(1);
|
|
|
|
return 0; /* Not reached, we donated ourselves to StartServer */
|
|
}
|