Skip to content

Commit

Permalink
Add first part of validating the user entered Priv Flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sai2791 committed Jul 17, 2021
1 parent 548080d commit 0a792e7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fs_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <hidden>]",
// loop and accept new connections
(int)(tail - backup), backup);
else
printf("[%s]", c->req->data);
Expand Down Expand Up @@ -313,13 +314,22 @@ 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);
if (c->client == NULL) {
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;
Expand Down

0 comments on commit 0a792e7

Please sign in to comment.