From a71d6b2c787d0e80c058afcf2be8bd0d31984c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Fri, 24 Jan 2025 14:28:00 -0500 Subject: [PATCH] Allow "reserving" names The SyncTERM cache uses the BBS name as the directory name, so any system-level caching needs to either be in the cache root directory or in a directory whose name is guaranteed to not collide with an entry name. This leaves two options... either prevent a list of suffixes from being used on BBS names, or have a separate system cache whose name cannot be used as a BBS name. I've taken the second route here... SyncTERM will not load a BBS entry with the (case insensitive) name "syncterm-system-cache" and will not allow creating one. This is the directory where "global" cache files will be stored (ie: scripts, internet dialing directories, etc.) --- src/syncterm/bbslist.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/syncterm/bbslist.c b/src/syncterm/bbslist.c index 6c64f2c509..ce6e49a755 100644 --- a/src/syncterm/bbslist.c +++ b/src/syncterm/bbslist.c @@ -839,6 +839,14 @@ read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int strListFree(§ion); } +bool +is_reserved_bbs_name(const char *name) +{ + if (stricmp(name, "syncterm-system-cache") == 0) + return true; + return false; +} + /* * Checks if bbsname already is listed in list * setting *pos to the position if not NULL. @@ -894,7 +902,7 @@ read_list(char *listpath, struct bbslist **list, struct bbslist *defaults, int * read_item(inilines, defaults, NULL, -1, type); bbses = iniGetSectionList(inilines, NULL); while ((bbsname = strListRemove(&bbses, 0)) != NULL) { - if (!list_name_check(list, bbsname, NULL, false)) { + if ((!list_name_check(list, bbsname, NULL, false)) && (!is_reserved_bbs_name(bbsname))) { if ((list[*i] = (struct bbslist *)malloc(sizeof(struct bbslist))) == NULL) { free(bbsname); break; @@ -1102,6 +1110,12 @@ edit_name(char *itemname, struct bbslist **list, str_list_t inifile, bool edit_t uifc.msg("Entry Name Already Exists!"); check_exit(false); } + else if(is_reserved_bbs_name(tmp)) { + uifc.helpbuf = "`Reserved Name`\n\n" + "The name you entered is reserved for internal use\n"; + uifc.msg("Reserved Name!"); + check_exit(false); + } else { if (tmp[0] == 0) { uifc.helpbuf = "`Can Not Use an Empty Name`\n\n" @@ -3266,6 +3280,13 @@ show_bbslist(char *current, int connected) check_exit(false); break; } + if(is_reserved_bbs_name(tmp)) { + uifc.helpbuf = "`Reserved Name`\n\n" + "The name you entered is reserved for internal use\n"; + uifc.msg("Reserved Name!"); + check_exit(false); + break; + } listcount++; list[listcount] = list[listcount - 1]; list[listcount -- GitLab