diff --git a/README.md b/README.md index 596d9a0..0178e48 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pam_e4crypt.c b/pam_e4crypt.c index c12f65c..f1f32e6 100644 --- a/pam_e4crypt.c +++ b/pam_e4crypt.c @@ -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);