gvm-libs  11.0.1
About: GVM Libraries for the Greenbone Vulnerability Management (GVM-10) framework (derived from the former openvas-libraries).
  Fossies Dox: gvm-libs-11.0.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

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. More...
 
void gvm_disable_password_policy (void)
 Disable all password policy checking. More...
 

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 411 of file pwpolicy.c.

412 {
414  g_warning ("Password policy checking has been disabled.");
415 }

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 355 of file pwpolicy.c.

356 {
357  const char *patternfile = PWPOLICY_FILE_NAME;
358  char *ret;
359  FILE *fp;
360  int lineno;
361  char line[256];
362  char *desc = NULL;
363 
365  return NULL;
366 
367  if (!password || !*password)
368  return g_strdup ("Empty password");
369 
370  fp = fopen (patternfile, "r");
371  if (!fp)
372  {
373  g_warning ("error opening '%s': %s", patternfile, g_strerror (errno));
374  return policy_checking_failed ();
375  }
376  lineno = 0;
377  ret = NULL;
378  while (fgets (line, DIM (line) - 1, fp))
379  {
380  size_t len;
381 
382  lineno++;
383  len = strlen (line);
384  if (!len || line[len - 1] != '\n')
385  {
386  g_warning ("error reading '%s', line %d: %s", patternfile, lineno,
387  len ? "line too long" : "line without a LF");
388  ret = policy_checking_failed ();
389  break;
390  }
391  line[--len] = 0; /* Chop the LF. */
392  if (len && line[len - 1] == '\r')
393  line[--len] = 0; /* Chop an optional CR. */
394  ret = parse_pattern_line (line, patternfile, lineno, &desc, password,
395  username);
396  if (ret)
397  break;
398 
399  bzero (line, sizeof (line));
400  }
401 
402  fclose (fp);
403  g_free (desc);
404  return ret;
405 }

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

Here is the call graph for this function:
parse_pattern_line
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:232
PWPOLICY_FILE_NAME
#define PWPOLICY_FILE_NAME
The name of the pattern file.
Definition: pwpolicy.c:108
DIM
#define DIM(v)
Definition: pwpolicy.c:37
policy_checking_failed
static char * policy_checking_failed(void)
Definition: pwpolicy.c:120
disable_password_policy
static gboolean disable_password_policy
Flag indicating that passwords are not checked.
Definition: pwpolicy.c:113