#define CTDLEXIT_SHUTDOWN 0 // Normal shutdown; do NOT auto-restart
-// Exit codes 101 through 109 are used for conditions in which
-// we deliberately do NOT want the service to automatically
-// restart.
+// Exit codes 101-109 are used for conditions in which we
+// deliberately do NOT want the service to automatically restart.
#define CTDLEXIT_CONFIG 101 // Could not read system configuration
+#define CTDLEXIT_SANITY 102 // Internal sanity check failed
#define CTDLEXIT_HOME 103 // Citadel home directory not found
#define CTDLEXIT_DB 105 // Unable to initialize database
#define CTDLEXIT_LIBCITADEL 106 // Incorrect version of libcitadel
#define CTDL_EXIT_UNSUP_AUTH 107 // Unsupported auth mode configured
#define CTDLEXIT_UNUSER 108 // Could not determine uid to run as
#define CTDLEXIT_CRYPTO 109 // Problem initializing SSL or TLS
-// Any other exit is likely to be from an unexpected abort (segfault etc)
-// and we want to try restarting.
+
+// Other exit codes are probably ok to try starting the server again.
+#define CTDLEXIT_REDIRECT 110 // Redirect buffer failure
+#define CTDLEXIT_CHKPWD 111 // chkpwd daemon failed
+#define CTDLEXIT_THREAD 112 // Problem setting up multithreading
+#define CTDLEXIT_BAD_MAGIC 113 // internet_addressing() magic number is wrong
+
+// Any other exit is likely to be from an unexpected abort (segfault etc) and we want to try restarting.
// Reasons why a session would be terminated (set CC->kill_me to these values)
if (sanity_diag_mode == 1) {
syslog(LOG_INFO, "control: sanity check diagnostic mode is active - exiting now");
- abort();
+ exit(CTDLEXIT_SANITY);
}
}
// This file contains functions which handle the mapping of Internet addresses
// to users on the Citadel system.
//
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
if (valid->recptypes_magic != RECPTYPES_MAGIC) {
syslog(LOG_ERR, "internet_addressing: attempt to call free_recipients() on some other data type!");
- abort();
+ exit(CTDLEXIT_BAD_MAGIC);
}
if (valid->errormsg != NULL) free(valid->errormsg);
*/
if (CC->redirect_buffer != NULL) {
syslog(LOG_ALERT, "msgbase: CC->redirect_buffer is not NULL during message submission!");
- abort();
+ exit(CTDLEXIT_REDIRECT);
}
CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
CtdlOutputPreLoadedMsg(msg, MT_RFC822, HEADERS_ALL, 0, 1, QP_EADDR);
// Here's where we (hopefully) have most parts of the Citadel server that
// might need tweaking when run on different operating system variants.
//
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
//
// This program is open source software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, version 3.
if (pthread_key_create(&ThreadKey, NULL) != 0) { // TSD for threads
syslog(LOG_ERR, "pthread_key_create() : %m");
- abort();
+ exit(CTDLEXIT_THREAD);
}
if (pthread_key_create(&MyConKey, NULL) != 0) { // TSD for sessions
syslog(LOG_CRIT, "sysdep: can't create TSD key: %m");
- abort();
+ exit(CTDLEXIT_THREAD);
}
// Interript, hangup, and terminate signals should cause the server to shut down.
// Server functions which perform operations on user objects.
//
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
//
// This program is open source software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License, version 3.
if ((stat(file_chkpwd, &filestats)==-1) || (filestats.st_size==0)) {
syslog(LOG_ERR, "user_ops: %s: %m", file_chkpwd);
- abort();
+ exit(CTDLEXIT_CHKPWD);
}
if (pipe(chkpwd_write_pipe) != 0) {
syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %m");
- abort();
+ exit(CTDLEXIT_CHKPWD);
}
if (pipe(chkpwd_read_pipe) != 0) {
syslog(LOG_ERR, "user_ops: unable to create pipe for chkpwd daemon: %m");
- abort();
+ exit(CTDLEXIT_CHKPWD);
}
chkpwd_pid = fork();
if (chkpwd_pid < 0) {
syslog(LOG_ERR, "user_ops: unable to fork chkpwd daemon: %m");
- abort();
+ exit(CTDLEXIT_CHKPWD);
}
if (chkpwd_pid == 0) {
dup2(chkpwd_write_pipe[0], 0);
for (i=2; i<256; ++i) close(i);
execl(file_chkpwd, file_chkpwd, NULL);
syslog(LOG_ERR, "user_ops: unable to exec chkpwd daemon: %m");
- abort();
exit(errno);
}
}
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
if ((stat(file_chkpwd, &filestats)==-1) || (filestats.st_size==0)){
printf("didn't find chkpwd daemon in %s: %s\n", file_chkpwd, strerror(errno));
- abort();
+ exit(1);
}
if (pipe(chkpwd_write_pipe) != 0) {
printf("Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
- abort();
+ exit(2);
}
if (pipe(chkpwd_read_pipe) != 0) {
printf("Unable to create pipe for chkpwd daemon: %s\n", strerror(errno));
- abort();
+ exit(3);
}
chkpwd_pid = fork();
if (chkpwd_pid < 0) {
printf("Unable to fork chkpwd daemon: %s\n", strerror(errno));
- abort();
+ exit(4);
}
if (chkpwd_pid == 0) {
dup2(chkpwd_write_pipe[0], 0);
for (i=2; i<256; ++i) close(i);
execl(file_chkpwd, file_chkpwd, NULL);
printf("Unable to exec chkpwd daemon: %s\n", strerror(errno));
- abort();
exit(errno);
}
}