From 0a792e7553dacc59ddbef90875e64ad53b2c5d72 Mon Sep 17 00:00:00 2001 From: Steve Inglis Date: Sat, 17 Jul 2021 21:25:42 +0100 Subject: [PATCH] Add first part of validating the user entered Priv Flag --- fs_cli.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs_cli.c b/fs_cli.c index 9d0d7b2..bb84e63 100755 --- a/fs_cli.c +++ b/fs_cli.c @@ -142,6 +142,7 @@ fs_cli(struct fs_context *c) if (cmd_tab[i].impl == fs_cmd_i_am || cmd_tab[i].impl == fs_cmd_pass) printf("[%.*s ]", + // loop and accept new connections (int)(tail - backup), backup); else printf("[%s]", c->req->data); @@ -313,6 +314,7 @@ fs_cmd_priv(struct fs_context *c, char *tail) { struct ec_fs_reply reply; char *user, *priv; + user = fs_cli_getarg(&tail); priv = fs_cli_getarg(&tail); if (debug) printf("cli: priv request %s to '%s'\n", user, priv); @@ -320,6 +322,14 @@ fs_cmd_priv(struct fs_context *c, char *tail) fs_err(c, EC_FS_E_WHOAREYOU); return; } + // Add Validation to the privilege level + if (strlen(priv) > 1) + { + // TODO: Write a procedure to check that the priv flag is valid + fs_err(c, EC_FS_E_NOPRIV); + return; + } + if (userfuncs->set_priv(c->client, user, priv)) { fs_err(c, EC_FS_E_NOPRIV); // Should be Priv?? return;