Greenbone Vulnerability Management Libraries 22.32.0
pwpolicy.h File Reference

Protos and data structures for pwpolicy checking. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * gvm_validate_password (const char *, const char *)
 Validate a password against the pattern file.
void gvm_disable_password_policy (void)
 Disable all password policy checking.

Detailed Description

Protos and data structures for pwpolicy checking.

This file contains the protos for pwpolicy.c

Definition in file pwpolicy.h.

Function Documentation

◆ gvm_disable_password_policy()

void gvm_disable_password_policy ( void )

Disable all password policy checking.

Definition at line 406 of file pwpolicy.c.

407{
409 g_warning ("Password policy checking has been disabled.");
410}
static gboolean disable_password_policy
Flag indicating that passwords are not checked.
Definition pwpolicy.c:99

References disable_password_policy.

◆ gvm_validate_password()

char * gvm_validate_password ( const char * password,
const char * username )

Validate a password against the pattern file.

Parameters
[in]passwordThe password to check
[in]usernameThe user name or NULL. This is used to check the passphrase against the user name.
Returns
NULL on success or a malloced string with an error description.

Definition at line 350 of file pwpolicy.c.

351{
352 const char *patternfile = PWPOLICY_FILE_NAME;
353 char *ret;
354 FILE *fp;
355 int lineno;
356 char line[256];
357 char *desc = NULL;
358
360 return NULL;
361
362 if (!password || !*password)
363 return g_strdup ("Empty password");
364
365 fp = fopen (patternfile, "r");
366 if (!fp)
367 {
368 g_warning ("error opening '%s': %s", patternfile, g_strerror (errno));
369 return policy_checking_failed ();
370 }
371 lineno = 0;
372 ret = NULL;
373 while (fgets (line, DIM (line) - 1, fp))
374 {
375 size_t len;
376
377 lineno++;
378 len = strlen (line);
379 if (!len || line[len - 1] != '\n')
380 {
381 g_warning ("error reading '%s', line %d: %s", patternfile, lineno,
382 len ? "line too long" : "line without a LF");
383 ret = policy_checking_failed ();
384 break;
385 }
386 line[--len] = 0; /* Chop the LF. */
387 if (len && line[len - 1] == '\r')
388 line[--len] = 0; /* Chop an optional CR. */
389 ret = parse_pattern_line (line, patternfile, lineno, &desc, password,
390 username);
391 if (ret)
392 break;
393
394 bzero (line, sizeof (line));
395 }
396
397 fclose (fp);
398 g_free (desc);
399 return ret;
400}
#define DIM(v)
Definition pwpolicy.c:23
static char * policy_checking_failed(void)
Definition pwpolicy.c:106
#define PWPOLICY_FILE_NAME
The name of the pattern file.
Definition pwpolicy.c:94
static char * parse_pattern_line(char *line, const char *fname, int lineno, char **descp, const char *password, const char *username)
Parse one line of a pettern file.
Definition pwpolicy.c:226

References DIM, disable_password_policy, parse_pattern_line(), policy_checking_failed(), and PWPOLICY_FILE_NAME.

Here is the call graph for this function: