From 68ab7e062ced1b3d335ab6432840a393b6627a27 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 19 Apr 1995 13:19:08 +0000 Subject: [PATCH] New command: account - for authentication. --- kernel/kernel.h | 6 +++++- kernel/main.c | 20 ++++++++++++++------ kernel/persist.c | 13 +++++++++++-- kernel/urp.c | 26 +++++++++++++++++++++++--- 4 files changed, 53 insertions(+), 12 deletions(-) diff --git a/kernel/kernel.h b/kernel/kernel.h index ef5d82f..40bafaf 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: kernel.h,v $ - * Revision 1.14 1995/04/19 10:46:18 adam + * Revision 1.15 1995/04/19 13:19:08 adam + * New command: account - for authentication. + * + * Revision 1.14 1995/04/19 10:46:18 adam * Persistency works much better now. New command: status - history-like * * Revision 1.13 1995/04/19 07:31:04 adam @@ -82,6 +85,7 @@ struct gw_kernel_info { const char *override_res; char target[128]; char hostname[128]; + char account[128]; int port; const char *lang; const char *override_portno; diff --git a/kernel/main.c b/kernel/main.c index a8fadfb..7926912 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: main.c,v $ - * Revision 1.17 1995/04/19 10:46:18 adam + * Revision 1.18 1995/04/19 13:19:09 adam + * New command: account - for authentication. + * + * Revision 1.17 1995/04/19 10:46:18 adam * Persistency works much better now. New command: status - history-like * * Revision 1.16 1995/04/19 07:31:07 adam @@ -175,6 +178,7 @@ int main (int argc, char **argv) info.default_res = "default.res"; info.override_res = NULL; *info.target = 0; + *info.account = 0; info.lang = NULL; info.bibset = NULL; info.zass = NULL; @@ -487,16 +491,20 @@ void read_kernel_res (void) if (*info.target && ! gw_res_get (info.kernel_res, resource_name, NULL)) { /* target is there, and there is no sub-resource for it... */ - char *split; + const char *split; if ((split = strchr (info.target, ':'))) - *split++ = '\0'; - strncpy (info.hostname, info.target, sizeof(info.hostname)-1); - if (split) - info.port = atoi (split); + { + memcpy (info.hostname, info.target, split-info.target); + info.hostname[split-info.target] = '\0'; + info.port = atoi (split+1); + } else + { + strcpy (info.hostname, info.target); info.port = atoi (gw_res_get (info.kernel_res, "gw.portno", "210")); + } } else { diff --git a/kernel/persist.c b/kernel/persist.c index 219024f..34263b1 100644 --- a/kernel/persist.c +++ b/kernel/persist.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: persist.c,v $ - * Revision 1.2 1995/04/19 10:46:19 adam + * Revision 1.3 1995/04/19 13:19:09 adam + * New command: account - for authentication. + * + * Revision 1.2 1995/04/19 10:46:19 adam * Persistency works much better now. New command: status - history-like * * Revision 1.1 1995/04/19 07:31:10 adam @@ -224,6 +227,11 @@ int load_p_state (int userid) if (!fgetsx (fline, 1024, inf)) return -1; + if (sscanf (fline, "%s", info.account) != 1) + *info.account = '\0'; + + if (!fgetsx (fline, 1024, inf)) + return -1; free (info.database); info.database = gw_strdup (fline); @@ -319,7 +327,8 @@ int save_p_state (int userid) return -1; } gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Writing persistence file %s", fname); - fprintf (of, "%s\n%s\n%d\n", info.target, info.database, info.setno); + fprintf (of, "%s\n%s\n%s\n%d\n", info.target, info.account, + info.database, info.setno); save_sets (of, info.sets); fclose (of); return 0; diff --git a/kernel/urp.c b/kernel/urp.c index 0c6c333..a8956da 100644 --- a/kernel/urp.c +++ b/kernel/urp.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: urp.c,v $ - * Revision 1.27 1995/04/19 10:46:19 adam + * Revision 1.28 1995/04/19 13:19:09 adam + * New command: account - for authentication. + * + * Revision 1.27 1995/04/19 10:46:19 adam * Persistency works much better now. New command: status - history-like * * Revision 1.26 1995/04/19 07:31:12 adam @@ -141,7 +144,8 @@ int reopen_target (void) if (info.zass) gw_log (GW_LOG_WARN, KERNEL_LOG, "Zass free..."); gw_log (GW_LOG_DEBUG, KERNEL_LOG, "reopen_target"); - info.zass = zass_open (info.hostname, info.port); + info.zass = zass_open (info.hostname, info.port, *info.account ? + info.account : NULL); if (!info.zass) { gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Cannot connect to target %s:%d", @@ -195,6 +199,7 @@ static struct command_word { { "cancel", "cancel" }, { "target", "target" }, { "stop", "stop" }, +{ "account", "account" }, { NULL, NULL } }; @@ -398,6 +403,19 @@ static int exec_find (struct ccl_token *list, const char *search_str) return 0; } +static int exec_account (struct ccl_token *list) +{ + if (list->kind != CCL_TOK_EOL) + { + int len = list->len; + memcpy (info.account, list->name, len); + info.target[len] = '\0'; + } + else + *info.account = '\0'; + return 0; +} + static int exec_target (struct ccl_token *list) { int len; @@ -737,7 +755,7 @@ static int exec_command (const char *str) if (cmd->kind != CCL_TOK_EOL && (no = command_search (command_tab, cmd, "ccl.command."))) { - if (!info.zass && no != 9 && no != 4) + if (!info.zass && no != 9 && no != 4 && no != 11 && no != 7) reopen_target (); fprintf (reply_fd, "\n> %s\n", str); if (!info.zass && (no == 1 || no == 2 || no == 3)) @@ -768,6 +786,8 @@ static int exec_command (const char *str) return exec_status (cmd->next); case 9: return exec_target (cmd->next); + case 11: + return exec_account (cmd->next); default: fprintf (reply_fd, "%s\n", gw_res_get (info.kernel_res, "gw.err.unimplemented", -- 1.7.10.4