mike-jumper commented on a change in pull request #205:
URL: https://github.com/apache/guacamole-server/pull/205#discussion_r575723262
##########
File path: src/guacd/conf-file.c
##########
@@ -169,48 +192,40 @@ int guacd_conf_parse_file(guacd_config* conf, int fd) {
}
-guacd_config* guacd_conf_load() {
-
- guacd_config* conf = malloc(sizeof(guacd_config));
- if (conf == NULL)
- return NULL;
-
- /* Load defaults */
- conf->bind_host = NULL;
- conf->bind_port = strdup("4822");
- conf->pidfile = NULL;
- conf->foreground = 0;
- conf->print_version = 0;
- conf->max_log_level = GUAC_LOG_INFO;
-
-#ifdef ENABLE_SSL
- conf->cert_file = NULL;
- conf->key_file = NULL;
-#endif
+int guacd_conf_load(guacd_config* conf, const char* conf_file_path) {
/* Read configuration from file */
- int fd = open(GUACD_CONF_FILE, O_RDONLY);
+ int fd = open(conf_file_path, O_RDONLY);
if (fd > 0) {
int retval = guacd_conf_parse_file(conf, fd);
close(fd);
if (retval != 0) {
- fprintf(stderr, "Unable to parse \"" GUACD_CONF_FILE "\".\n");
- free(conf);
- return NULL;
+ fprintf(stderr, "Unable to parse \"%s\".\n", conf_file_path);
+ return 1;
}
}
/* Notify of errors preventing reading */
else if (errno != ENOENT) {
- fprintf(stderr, "Unable to open \"" GUACD_CONF_FILE "\": %s\n",
strerror(errno));
- free(conf);
- return NULL;
+ fprintf(stderr, "Unable to open \"%s\": %s\n", conf_file_path,
strerror(errno));
+ return 1;
}
- return conf;
+ /* Load successfully */
+ return 0;
}
+int guacd_conf_load_default(guacd_config* conf) {
+
+ /* Determine path to the default configuration file and load it */
+ char *path = getenv("GUACD_CONF_FILE");
Review comment:
I think, arguably, this accurately refers to the file as default in the
sense that it's where the default configuration values come from.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]