#endif
-#define MAXSETUP 6 /* How many setup questions to ask */
+#define MAXSETUP 11 /* How many setup questions to ask */
#define UI_TEXT 0 /* Default setup type -- text only */
#define UI_DIALOG 2 /* Use the 'dialog' program */
"Citadel User ID",
"Server IP address",
"Server port number",
- "Authentication mode"
+ "Authentication mode",
+ "LDAP host",
+ "LDAP port number",
+ "LDAP base DN",
+ "LDAP bind DN",
+ "LDAP bind password"
};
/**
-"How would you like to authenticate users on your Citadel system?\n"
+"Specify which authentication mode you wish to use.\n"
"\n"
-" 0. Self contained authentication - Citadel maintains its own user database\n"
-" (This mode is *strongly* recommended)\n"
+" 0. Self contained authentication\n"
+" 1. Host system integrated authentication\n"
+" 2. External LDAP - RFC 2307 compliant directory\n"
+" 3. External LDAP - nonstandard MS Active Directory\n"
"\n"
-" 1. Authenticate users against the host system (unix or linux accounts)\n"
+"For help: http://www.citadel.org/doku.php/faq:installation:authmodes\n"
"\n"
-" 2. Authenticate users against an external LDAP directory\n"
-"\n"
-"WARNING: do *not* change this setting once your system is installed.\n"
-"\n"
-"(Answer \"0\" unless you completely understand this option)\n"
-"Which authentication mode do you want to use?\n"
+"ANSWER \"0\" UNLESS YOU COMPLETELY UNDERSTAND THIS OPTION.\n",
+
+"Please enter the host name or IP address of your LDAP server.\n",
+
+"Please enter the port number of the LDAP service (usually 389).\n",
+
+"Please enter the Base DN to search for authentication\n"
+"(for example: dc=example,dc=com)\n",
+
+"Please enter the DN of an account to use for binding to the LDAP server\n"
+"for performing queries. The account does not require any other\n"
+"privileges. If your LDAP server allows anonymous queries, you can.\n"
+"leave this blank.\n",
+
+"If you entered a Bind DN in the previous question, you must now enter\n"
+"the password associated with that account. Otherwise, you can leave this\n"
+"blank.\n"
};
question,
( default_value ? "Yes" : "No" )
);
- fgets(buf, sizeof buf, stdin);
- answer = tolower(buf[0]);
- if ((buf[0]==0) || (buf[0]==13) || (buf[0]==10))
- answer = default_value;
- else if (answer == 'y')
- answer = 1;
- else if (answer == 'n')
- answer = 0;
+ if (fgets(buf, sizeof buf, stdin))
+ {
+ answer = tolower(buf[0]);
+ if ((buf[0]==0) || (buf[0]==13) || (buf[0]==10))
+ answer = default_value;
+ else if (answer == 'y')
+ answer = 1;
+ else if (answer == 'n')
+ answer = 0;
+ }
} while ((answer < 0) || (answer > 1));
break;
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf(" %s \n\n%s\n\n", title, msgtext);
printf("Press return to continue...");
- fgets(buf, sizeof buf, stdin);
+ if (fgets(buf, sizeof buf, stdin));
break;
case UI_DIALOG:
sizeof looking_for,
"%s/citserver",
ctdl_sbin_dir
- );
+ );
/* Now tweak /etc/inittab */
infp = fopen("/etc/inittab", "r");
fp = fopen(initfile, "r");
if (fp != NULL) {
if (yesno("Citadel already appears to be configured to start at boot.\n"
- "Would you like to keep your boot configuration as is?\n", 1) == 1) {
+ "Would you like to keep your boot configuration as is?\n", 1) == 1) {
return;
}
fclose(fp);
}
fprintf(fp, "#!/bin/sh\n"
- "#\n"
- "# Init file for Citadel\n"
- "#\n"
- "# chkconfig: - 79 30\n"
- "# description: Citadel service\n"
- "# processname: citserver\n"
- "# pidfile: %s/citadel.pid\n"
- "\n"
- "CITADEL_DIR=%s\n"
- ,
- setup_directory,
- setup_directory
- );
+ "#\n"
+ "# Init file for Citadel\n"
+ "#\n"
+ "# chkconfig: - 79 30\n"
+ "# description: Citadel service\n"
+ "# processname: citserver\n"
+ "# pidfile: %s/citadel.pid\n\n"
+ "# uncomment this to create coredumps as described in\n"
+ "# http://www.citadel.org/doku.php/faq:mastering_your_os:gdb#how.do.i.make.my.system.produce.core-files\n"
+ "# ulimit -c unlimited\n"
+ "\n"
+ "CITADEL_DIR=%s\n"
+ ,
+ setup_directory,
+ setup_directory
+ );
fprintf(fp, "\n"
- "test -d /var/run || exit 0\n"
- "\n"
- "case \"$1\" in\n"
- "\n"
- "start) echo -n \"Starting Citadel... \"\n"
- " if $CITADEL_DIR/citserver -d -h$CITADEL_DIR\n"
- " then\n"
- " echo \"ok\"\n"
- " else\n"
- " echo \"failed\"\n"
- " fi\n");
+ "test -d /var/run || exit 0\n"
+ "\n"
+ "case \"$1\" in\n"
+ "\n"
+ "start) echo -n \"Starting Citadel... \"\n"
+ " if $CITADEL_DIR/citserver -lmail -d -h$CITADEL_DIR\n"
+ " then\n"
+ " echo \"ok\"\n"
+ " else\n"
+ " echo \"failed\"\n"
+ " fi\n");
fprintf(fp, " ;;\n"
- "stop) echo -n \"Stopping Citadel... \"\n"
- " if $CITADEL_DIR/sendcommand DOWN >/dev/null 2>&1 ; then\n"
- " echo \"ok\"\n"
- " else\n"
- " echo \"failed\"\n"
- " fi\n"
- " rm -f %s/citadel.pid 2>/dev/null\n"
- ,
- setup_directory
- );
+ "stop) echo -n \"Stopping Citadel... \"\n"
+ " if $CITADEL_DIR/sendcommand DOWN >/dev/null 2>&1 ; then\n"
+ " echo \"ok\"\n"
+ " else\n"
+ " echo \"failed\"\n"
+ " fi\n"
+ " rm -f %s/citadel.pid 2>/dev/null\n"
+ ,
+ setup_directory
+ );
fprintf(fp, " ;;\n"
- "restart) if $CITADEL_DIR/sendcommand DOWN 1 >/dev/null 2>&1 ; then\n"
- " echo \"ok\"\n"
- " else\n"
- " echo \"failed\"\n"
- " fi\n"
- " ;;\n"
- "*) echo \"Usage: $0 {start|stop|restart}\"\n"
- " exit 1\n"
- " ;;\n"
- "esac\n"
- );
+ "restart) if $CITADEL_DIR/sendcommand DOWN 1 >/dev/null 2>&1 ; then\n"
+ " echo \"ok\"\n"
+ " else\n"
+ " echo \"failed\"\n"
+ " fi\n"
+ " ;;\n"
+ "*) echo \"Usage: $0 {start|stop|restart}\"\n"
+ " exit 1\n"
+ " ;;\n"
+ "esac\n"
+ );
fclose(fp);
chmod(initfile, 0755);
}
else {
snprintf(buf, sizeof buf,
- "Setup can configure the \"xinetd\" service to automatically\n"
- "connect incoming telnet sessions to Citadel, bypassing the\n"
- "host system login: prompt. Would you like to do this?\n"
- );
+ "Setup can configure the \"xinetd\" service to automatically\n"
+ "connect incoming telnet sessions to Citadel, bypassing the\n"
+ "host system login: prompt. Would you like to do this?\n"
+ );
if (yesno(buf, 1) == 0) {
return;
}
while (fgets(buf, sizeof buf, fp) != NULL) {
if ( (buf[0]=='2')
- && (strstr(buf, cookie) != NULL) ) {
+ && (strstr(buf, cookie) != NULL) ) {
++found_it;
}
}
void strprompt(char *prompt_title, char *prompt_text, char *str)
{
- char buf[SIZ];
+ char buf[SIZ] = "";
char setupmsg[SIZ];
char dialog_result[PATH_MAX];
FILE *fp = NULL;
printf("\n%s\n", prompt_text);
printf("This is currently set to:\n%s\n", str);
printf("Enter new value or press return to leave unchanged:\n");
- fgets(buf, sizeof buf, stdin);
- buf[strlen(buf) - 1] = 0;
+ if (fgets(buf, sizeof buf, stdin)){
+ buf[strlen(buf) - 1] = 0;
+ }
if (!IsEmptyStr(buf))
strcpy(str, buf);
break;
system(buf);
fp = fopen(dialog_result, "r");
if (fp != NULL) {
- fgets(str, sizeof buf, fp);
- if (str[strlen(str)-1] == 10) {
- str[strlen(str)-1] = 0;
+ if (fgets(str, sizeof buf, fp)) {
+ if (str[strlen(str)-1] == 10) {
+ str[strlen(str)-1] = 0;
+ }
}
fclose(fp);
unlink(dialog_result);
case 6:
if (setup_type == UI_SILENT)
{
- if (getenv("ENABLE_UNIX_AUTH")) {
- if (!strcasecmp(getenv("ENABLE_UNIX_AUTH"), "yes")) {
+ const char *auth;
+ config.c_auth_mode = AUTHMODE_NATIVE;
+ auth = getenv("ENABLE_UNIX_AUTH");
+ if (auth != NULL)
+ {
+ if ((strcasecmp(auth, "yes") == 0) ||
+ (strcasecmp(auth, "host") == 0))
+ {
config.c_auth_mode = AUTHMODE_HOST;
}
- else {
- config.c_auth_mode = AUTHMODE_NATIVE;
+ else if (strcasecmp(auth, "ldap") == 0){
+ config.c_auth_mode = AUTHMODE_LDAP;
+ }
+ else if ((strcasecmp(auth, "ldap_ad") == 0) ||
+ (strcasecmp(auth, "active directory") == 0)){
+ config.c_auth_mode = AUTHMODE_LDAP_AD;
}
}
}
}
break;
+ case 7:
+ if (setup_type == UI_SILENT)
+ {
+ if (getenv("LDAP_HOST")) {
+ strcpy(config.c_ldap_host, getenv("LDAP_HOST"));
+ }
+ }
+ else
+ {
+ set_str_val(curr, config.c_ldap_host);
+ }
+ break;
+
+ case 8:
+ if (setup_type == UI_SILENT)
+ {
+ if (getenv("LDAP_PORT")) {
+ config.c_ldap_port = atoi(getenv("LDAP_PORT"));
+ }
+ }
+ else
+ {
+ set_int_val(curr, &config.c_ldap_port);
+ }
+ break;
+
+ case 9:
+ if (setup_type == UI_SILENT)
+ {
+ if (getenv("LDAP_BASE_DN")) {
+ strcpy(config.c_ldap_base_dn, getenv("LDAP_BASE_DN"));
+ }
+ }
+ else
+ {
+ set_str_val(curr, config.c_ldap_base_dn);
+ }
+ break;
+
+ case 10:
+ if (setup_type == UI_SILENT)
+ {
+ if (getenv("LDAP_BIND_DN")) {
+ strcpy(config.c_ldap_bind_dn, getenv("LDAP_BIND_DN"));
+ }
+ }
+ else
+ {
+ set_str_val(curr, config.c_ldap_bind_dn);
+ }
+ break;
+
+ case 11:
+ if (setup_type == UI_SILENT)
+ {
+ if (getenv("LDAP_BIND_PW")) {
+ strcpy(config.c_ldap_bind_pw, getenv("LDAP_BIND_PW"));
+ }
+ }
+ else
+ {
+ set_str_val(curr, config.c_ldap_bind_pw);
+ }
+ break;
+
}
+
}
/*
int home=0;
char relhome[PATH_MAX]="";
char ctdldir[PATH_MAX]=CTDLDIR;
+ int rv;
/* set an invalid setup type */
setup_type = (-1);
}
else if (!strncmp(argv[a], "-h", 2)) {
relh=argv[a][2]!='/';
- if (!relh) safestrncpy(ctdl_home_directory, &argv[a][2],
- sizeof ctdl_home_directory);
- else
- safestrncpy(relhome, &argv[a][2],
- sizeof relhome);
+ if (!relh) {
+ safestrncpy(ctdl_home_directory, &argv[a][2], sizeof ctdl_home_directory);
+ } else {
+ safestrncpy(relhome, &argv[a][2], sizeof relhome);
+ }
home = 1;
}
/* Try to stop Citadel if we can */
if (!access("/etc/init.d/citadel", X_OK)) {
- system("/etc/init.d/citadel stop");
+ rv = system("/etc/init.d/citadel stop");
}
/* Make sure Citadel is not running. */
display_error("setup: cannot append citadel.config");
cleanup(errno);
}
- for (a = 0; a < sizeof(struct config); ++a)
+ for (a = 0; a < sizeof(struct config); ++a) {
putc(0, fp);
+ }
fclose(fp);
/* now we re-open it, and read the old or blank configuration */
display_error("setup: cannot open citadel.config");
cleanup(errno);
}
- fread((char *) &config, sizeof(struct config), 1, fp);
+ rv = fread((char *) &config, sizeof(struct config), 1, fp);
fclose(fp);
/* set some sample/default values in place of blanks... */
sizeof config.c_nodename);
strtok(config.c_nodename, ".");
if (IsEmptyStr(config.c_fqdn) ) {
- if ((he = gethostbyname(my_utsname.nodename)) != NULL)
- safestrncpy(config.c_fqdn, he->h_name,
- sizeof config.c_fqdn);
- else
- safestrncpy(config.c_fqdn, my_utsname.nodename,
- sizeof config.c_fqdn);
+ if ((he = gethostbyname(my_utsname.nodename)) != NULL) {
+ safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn);
+ } else {
+ safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn);
+ }
}
- if (IsEmptyStr(config.c_humannode))
+ if (IsEmptyStr(config.c_humannode)) {
strcpy(config.c_humannode, "My System");
- if (IsEmptyStr(config.c_phonenum))
+ }
+ if (IsEmptyStr(config.c_phonenum)) {
strcpy(config.c_phonenum, "US 800 555 1212");
+ }
if (config.c_initax == 0) {
config.c_initax = 4;
}
- if (IsEmptyStr(config.c_moreprompt))
- strcpy(config.c_moreprompt, "<more>");
- if (IsEmptyStr(config.c_twitroom))
- strcpy(config.c_twitroom, "Trashcan");
- if (IsEmptyStr(config.c_baseroom))
- strcpy(config.c_baseroom, BASEROOM);
- if (IsEmptyStr(config.c_aideroom))
- strcpy(config.c_aideroom, "Aide");
+ if (IsEmptyStr(config.c_moreprompt)) strcpy(config.c_moreprompt, "<more>");
+ if (IsEmptyStr(config.c_twitroom)) strcpy(config.c_twitroom, "Trashcan");
+ if (IsEmptyStr(config.c_baseroom)) strcpy(config.c_baseroom, BASEROOM);
+ if (IsEmptyStr(config.c_aideroom)) strcpy(config.c_aideroom, "Aide");
if (config.c_port_number == 0) {
config.c_port_number = 504;
}
}
if (config.c_ctdluid == 0) {
pw = getpwnam("citadel");
- if (pw != NULL)
+ if (pw != NULL) {
config.c_ctdluid = pw->pw_uid;
+ }
}
if (config.c_ctdluid == 0) {
pw = getpwnam("bbs");
- if (pw != NULL)
+ if (pw != NULL) {
config.c_ctdluid = pw->pw_uid;
+ }
}
if (config.c_ctdluid == 0) {
pw = getpwnam("guest");
- if (pw != NULL)
+ if (pw != NULL) {
config.c_ctdluid = pw->pw_uid;
+ }
}
if (config.c_createax == 0) {
config.c_createax = 3;
/* Go through a series of dialogs prompting for config info */
for (curr = 1; curr <= MAXSETUP; ++curr) {
edit_value(curr);
+ if ((curr == 6) && (config.c_auth_mode != AUTHMODE_LDAP) && (config.c_auth_mode != AUTHMODE_LDAP_AD)) {
+ curr += 5; /* skip LDAP questions if we're not authenticating against LDAP */
+ }
}
/***** begin version update section ***** */
write_config_to_disk();
- mkdir(ctdl_info_dir, 0700);
- chmod(ctdl_info_dir, 0700);
- chown(ctdl_info_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_info_dir, 0700);
+ rv = chmod(ctdl_info_dir, 0700);
+ rv = chown(ctdl_info_dir, config.c_ctdluid, -1);
- mkdir(ctdl_bio_dir, 0700);
- chmod(ctdl_bio_dir, 0700);
- chown(ctdl_bio_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_bio_dir, 0700);
+ rv = chmod(ctdl_bio_dir, 0700);
+ rv = chown(ctdl_bio_dir, config.c_ctdluid, -1);
- mkdir(ctdl_usrpic_dir, 0700);
- chmod(ctdl_usrpic_dir, 0700);
- chown(ctdl_usrpic_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_usrpic_dir, 0700);
+ rv = chmod(ctdl_usrpic_dir, 0700);
+ rv = chown(ctdl_usrpic_dir, config.c_ctdluid, -1);
- mkdir(ctdl_message_dir, 0700);
- chmod(ctdl_message_dir, 0700);
- chown(ctdl_message_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_message_dir, 0700);
+ rv = chmod(ctdl_message_dir, 0700);
+ rv = chown(ctdl_message_dir, config.c_ctdluid, -1);
- mkdir(ctdl_hlp_dir, 0700);
- chmod(ctdl_hlp_dir, 0700);
- chown(ctdl_hlp_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_hlp_dir, 0700);
+ rv = chmod(ctdl_hlp_dir, 0700);
+ rv = chown(ctdl_hlp_dir, config.c_ctdluid, -1);
- mkdir(ctdl_image_dir, 0700);
- chmod(ctdl_image_dir, 0700);
- chown(ctdl_image_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_image_dir, 0700);
+ rv = chmod(ctdl_image_dir, 0700);
+ rv = chown(ctdl_image_dir, config.c_ctdluid, -1);
- mkdir(ctdl_bb_dir, 0700);
- chmod(ctdl_bb_dir, 0700);
- chown(ctdl_bb_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_bb_dir, 0700);
+ rv = chmod(ctdl_bb_dir, 0700);
+ rv = chown(ctdl_bb_dir, config.c_ctdluid, -1);
- mkdir(ctdl_file_dir, 0700);
- chmod(ctdl_file_dir, 0700);
- chown(ctdl_file_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_file_dir, 0700);
+ rv = chmod(ctdl_file_dir, 0700);
+ rv = chown(ctdl_file_dir, config.c_ctdluid, -1);
- mkdir(ctdl_netcfg_dir, 0700);
- chmod(ctdl_netcfg_dir, 0700);
- chown(ctdl_netcfg_dir, config.c_ctdluid, -1);
+ rv = mkdir(ctdl_netcfg_dir, 0700);
+ rv = chmod(ctdl_netcfg_dir, 0700);
+ rv = chown(ctdl_netcfg_dir, config.c_ctdluid, -1);
/* Delete files and directories used by older Citadel versions */
- system("exec /bin/rm -fr ./rooms ./chatpipes ./expressmsgs ./sessions 2>/dev/null");
+ rv = system("exec /bin/rm -fr ./rooms ./chatpipes ./expressmsgs ./sessions 2>/dev/null");
unlink("citadel.log");
unlink("weekly");
/* Check for the 'db' nss and offer to disable it */
fixnss();
- if ((pw = getpwuid(config.c_ctdluid)) == NULL)
+ if ((pw = getpwuid(config.c_ctdluid)) == NULL) {
gid = getgid();
- else
+ } else {
gid = pw->pw_gid;
+ }
progress("Setting file permissions", 0, 3);
- chown(ctdl_run_dir, config.c_ctdluid, gid);
+ rv = chown(ctdl_run_dir, config.c_ctdluid, gid);
progress("Setting file permissions", 1, 3);
- chown(file_citadel_config, config.c_ctdluid, gid);
+ rv = chown(file_citadel_config, config.c_ctdluid, gid);
progress("Setting file permissions", 2, 3);
- chmod(file_citadel_config, S_IRUSR | S_IWUSR);
+ rv = chmod(file_citadel_config, S_IRUSR | S_IWUSR);
progress("Setting file permissions", 3, 3);
/*
}
if (!access("/etc/init.d/citadel", X_OK)) {
- system("/etc/init.d/citadel start");
+ rv = system("/etc/init.d/citadel start");
sleep(3);
}
char buf[SIZ];
int found_it = 0;
- snprintf (admin_cmd, sizeof(admin_cmd), "%s/sendcommand \"CREU %s|%s\" 2>&1",
- ctdl_sbin_dir, config.c_sysadm, admin_pass);
- fp = popen(admin_cmd, "r");
- if (fp != NULL) {
- while (fgets(buf, sizeof buf, fp) != NULL)
- {
- if ((atol(buf) == 574) || (atol(buf) == 200))
- ++found_it;
+ if (config.c_auth_mode == AUTHMODE_NATIVE) {
+ snprintf (admin_cmd, sizeof(admin_cmd), "%s/sendcommand \"CREU %s|%s\" 2>&1",
+ ctdl_sbin_dir, config.c_sysadm, admin_pass);
+ fp = popen(admin_cmd, "r");
+ if (fp != NULL) {
+ while (fgets(buf, sizeof buf, fp) != NULL)
+ {
+ if ((atol(buf) == 574) || (atol(buf) == 200))
+ ++found_it;
+ }
+ pclose(fp);
+ }
+
+ if (found_it == 0) {
+ important_message("Error","Setup failed to create your admin user");
}
- pclose(fp);
}
-
- if (found_it == 0)
- important_message("Error","Setup failed to create your admin user");
if (setup_type != UI_SILENT)
important_message("Setup finished",