Permalink
Browse files

Synchronize documentation/function for passwdok command. Fixes #560

Found by: maimizuno
Patch by: michaelortmann
Fixes: #560
  • Loading branch information...
michaelortmann authored and vanosg committed Sep 14, 2018
1 parent 27cfce6 commit a5a62049046ea5e0c504c6886e2a76b8d629cf48
Showing with 31 additions and 16 deletions.
  1. +2 −2 doc/sphinx_source/mainDocs/tcl-commands.rst
  2. +29 −14 src/userrec.c
@@ -193,9 +193,9 @@ userlist [flags]
passwdok <handle> <pass>
^^^^^^^^^^^^^^^^^^^^^^^^
Description: checks the password given against the user's password. Check against the password "" (a blank string) or "-" to find out if a user has no password set.
Description: checks the password given against the user's password. Check against the password "-" to find out if a user has no password set.
Returns: 1 if the password matches for that user; 0 otherwise
Returns: 1 if the password matches for that user; 0 otherwise. Or if we are checking against the password "-": 1 if the user has no password set; 0 otherwise.
Module: core
View
@@ -340,27 +340,42 @@ struct userrec *get_user_by_host(char *host)
return ret;
}
/* Try: pass_match_by_host("-",host)
* If a '-' is sent as the password, it denotes the intent
* to merely check if a password is set for that user.
* Returns 0 if password is set and does not match
* Returns 1 if password matches, or if we are
* checking if a password is set and it is not
* (via the '-' char).
/* use fixfrom() or dont? (drummer)
*/
struct userrec *get_user_by_equal_host(char *host)
{
struct userrec *u;
struct list_type *q;
for (u = userlist; u; u = u->next)
for (q = get_user(&USERENTRY_HOSTS, u); q; q = q->next)
if (!rfc_casecmp(q->extra, host))
return u;
return NULL;
}
/* Description: checks the password given against the user's password.
* Check against the password "-" to find out if a user has no password set.
*
* Returns: 1 if the password matches for that user; 0 otherwise. Or if we are
* checking against the password "-": 1 if the user has no password set; 0
* otherwise.
*/
int u_pass_match(struct userrec *u, char *pass)
{
char *cmp, new[32];
if (!u)
if (!u || !pass)
return 0;
cmp = get_user(&USERENTRY_PASS, u);
if (!cmp && (pass[0] == '-'))
return 1;
/* If password is not set in userrecord, or password
* is not sent, or '-' is sent
*/
if (!cmp || !pass || !pass[0] || (pass[0] == '-'))
if (pass[0] == '-') {
if (!cmp)
return 1;
else
return 0;
}
/* If password is not set in userrecord, or password is not sent */
if (!cmp || !pass[0])
return 0;
if (u->flags & USER_BOT) {
if (!strcmp(cmp, pass))

1 comment on commit a5a6204

@michaelortmann

This comment has been minimized.

Show comment
Hide comment
@michaelortmann

michaelortmann Sep 14, 2018

Contributor

pls. remove get_user_by_equal_host() again as it was removed by commit 81f37a3.

Contributor

michaelortmann commented on a5a6204 Sep 14, 2018

pls. remove get_user_by_equal_host() again as it was removed by commit 81f37a3.

Please sign in to comment.