Skip to content

Commit

Permalink
Merge pull request #23 from jnvsor/saltpath
Browse files Browse the repository at this point in the history
Add saltpath argument for salts outside of $HOME
  • Loading branch information
neithernut authored Dec 3, 2017
2 parents 9dd3212 + d07b285 commit 1968245
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ You can generate this salt with one of the following commands :

``` echo -n s:`head -c 16 /dev/urandom | xxd -p` > ~/.ext4_encryption_salt ```

You can also store the salt outside your home directory in your pam config:

```
auth required pam_e4crypt.so saltpath=/home/.e4crypt
```

The module will then look for the salt in `/home/.e4crypt/$USER`

### Keyring

Expand Down
13 changes: 13 additions & 0 deletions pam_e4crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,19 @@ pam_sm_authenticate(
}
char path[PATH_MAX];
snprintf(path, PATH_MAX, "%s/%s", pw->pw_dir, ".ext4_encryption_salt");

for (int i = 0; i < argc; ++i) {
char const* option;

if (option = get_modarg_value("saltpath", argv[i])) {
// If a custom saltpath has been passed, use it instead
int spchars = snprintf(path, PATH_MAX, "%s/%s", option, pw->pw_name);
continue;
}

pam_log(LOG_WARNING, "Unknown option for authenticate: %s", argv[i]);
}

char* salt_data = read_salt_data(path);
if (salt_data) {
generate_key(flags, salt_data, auth_token, keys);
Expand Down

0 comments on commit 1968245

Please sign in to comment.