fix misleading error messages and command line arguments
Valeriy committed
Mar 29, 2016 at 18:37 UTC
f7e35af6cdd5a820833bae3db41f340c175c4565
3 files changed
+5
-5
src/appconfig.c
+1
-1
@@ -188,7 +188,7 @@ int load_config(char *filename, int overwrite_used)
188
if(!filename) filename = CONFIG_DIR "/" CONFIG_FILENAME;
189
FILE *fp = fopen(filename, "r");
190
if(!fp) {
191
- error("Cannot open file '%s'", CONFIG_DIR "/" CONFIG_FILENAME);
191
+ error("Cannot open file '%s'", filename);
192
return 0;
193
}
194
src/main.c
+2
-2
@@ -215,7 +215,7 @@ int main(int argc, char **argv)
215
else if(strcmp(argv[i], "-l") == 0 && (i+1) < argc) { config_set("global", "history", argv[i+1]); i++; }
216
else if(strcmp(argv[i], "-t") == 0 && (i+1) < argc) { config_set("global", "update every", argv[i+1]); i++; }
217
else if(strcmp(argv[i], "-ch") == 0 && (i+1) < argc) { config_set("global", "host access prefix", argv[i+1]); i++; }
218
- else if(strcmp(argv[i], "-nodeamon") == 0 || strcmp(argv[i], "-nd") == 0) dont_fork = 1;
218
+ else if(strcmp(argv[i], "-nodaemon") == 0 || strcmp(argv[i], "-nd") == 0) dont_fork = 1;
219
else if(strcmp(argv[i], "--unittest") == 0) {
220
rrd_update_every = 1;
221
if(run_all_mockup_tests()) exit(1);
@@ -225,7 +225,7 @@ int main(int argc, char **argv)
225
}
226
else {
227
fprintf(stderr, "Cannot understand option '%s'.\n", argv[i]);
228
- fprintf(stderr, "\nUSAGE: %s [-d] [-l LINES_TO_SAVE] [-u UPDATE_TIMER] [-p LISTEN_PORT] [-dl debug log file] [-df debug flags].\n\n", argv[0]);
228
+ fprintf(stderr, "\nUSAGE: %s [-d] [-l LINES_TO_SAVE] [-u UPDATE_TIMER] [-p LISTEN_PORT] [-df debug flags].\n\n", argv[0]);
229
fprintf(stderr, " -c CONFIG FILE the configuration file to load. Default: %s.\n", CONFIG_DIR "/" CONFIG_FILENAME);
230
fprintf(stderr, " -l LINES_TO_SAVE can be from 5 to %d lines in JSON data. Default: %d.\n", RRD_HISTORY_ENTRIES_MAX, RRD_DEFAULT_HISTORY_ENTRIES);
231
fprintf(stderr, " -t UPDATE_TIMER can be from 1 to %d seconds. Default: %d.\n", UPDATE_EVERY_MAX, UPDATE_EVERY);
src/web_client.c
+2
-2
@@ -292,9 +292,9 @@ int mysendfile(struct web_client *w, char *filename)
292
return 404;
293
}
294
295
- // check if the file is owned by us
295
+ // check if the file is owned by expected user
296
if(stat.st_uid != web_files_uid()) {
297
- error("%llu: File '%s' is owned by user %d (I run as user %d). Access Denied.", w->id, webfilename, stat.st_uid, getuid());
297
+ error("%llu: File '%s' is owned by user %d (expected user %d). Access Denied.", w->id, webfilename, stat.st_uid, web_files_uid());
298
buffer_sprintf(w->response.data, "Access to file '%s' is not permitted.", filename);
299
return 403;
300
}