---
name: "peks_edit_passwd_file"
section: "3"
platform: "linux"
package: "libnessus-dev"
version: "1.0.10-2"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/peks-passwd"
---

# peks\_edit\_passwd\_file(3)

handling user passwords

Part of [peks-passwd(3)](/peks-passwd/3.md).

## NAME

peks\_edit\_passwd\_file - handling user passwords

## SYNOPSIS

```
#include <peks.h>

char *peks_edit_passwd_file
       (const peks_key *prv_key, const char *usr_at_host,
        int count, const char *passwd,
        const char *pwd_file);
```

## DESCRIPTION

**Peks\_edit\_passwd\_file ()** manipulates passwords which can be stored together with any kind of user, or host keys. Passwords are tagged as user keys, so the same selection algorithm applies as in [**peks-keys**(3)](/peks-keys/3.md).

If the first argument *prv\_key* and the forth argument *passwd* are non NULL, the password line selected by the second argument *usr\_at\_host* is appended, or replaced respectively with an prv\_key-encrypted version of the text

```
<count> <usr> <passwd>
```

where count is the letter '0' + *count* modulo 32 (*count* is the third argument,) \<usr\> is the user name part of *usr\_at\_host* (looking like "usr@host"), and \<passwd\> is the text given as the forth argument *passwd*.

If the first argument *prv\_key* is non NULL but the forth argument *passwd* is  NULL, the passwd line is decoded and returned. With a non-negative third argument *count*, the three fields

```
<count> <usr> <passwd>
```

are returned which is the literal contents of the encrypted password text, stored in the data base. If the argument *count* is negative, a fourth field is possibly appended as in

```
<count> <usr> <passwd> <netspecs>
```

This forth field is a copy of the access specification. Is is the optional host or network part in the user@host:, or user@network: tag stored in the data base (see [**peks-keyfile**(5)](/peks-keyfile/5.md) for derails on the syntax.)

If the first argument *prv\_key* is NULL, the password line is deleted.

## RETURN VALUE

If there was no error, a character string is returned, an NULL otherwise (while the global variable *errno* is set - see [**errno**(3)](/errno/3.md) for details).

In case that a password line is appended/replaced or deleted, this return value is the empty string "".

Otherwise the password line is returned as a string with the three text fields as indicated above, separated by exactly one space.

## ENVIRONMENT VARIABLES

- **HOME**

  Used for the key file name expansion when there is a leading tilde-slash as in "~/\<pwd\_file\>".

## SEE ALSO

[**peks-keys**(3)](/peks-keys/3.md). [**peks-keyfile**(5)](/peks-keyfile/5.md), **tagsresolve**(3),  [**errno**(3)](/errno/3.md).

## AUTHOR

The **peks** package where these functions belong to was written by Jordan Hrycaj \<jordan@teddy-net.com\>, originally to support the **nessus** security scanner.
