diff -upr 1/ecryptfs-utils-53/src/utils/ecryptfs_add_passphrase.c 2/ecryptfs-utils-53/src/utils/ecryptfs_add_passphrase.c --- ecryptfs-utils-53/src/utils/ecryptfs_add_passphrase.c 2008-01-18 22:58:42.000000000 -0600 +++ ecryptfs-utils-53/src/utils/ecryptfs_add_passphrase.c 2008-10-22 18:55:21.503540303 -0500 @@ -38,13 +38,23 @@ int main(int argc, char *argv[]) char salt[ECRYPTFS_SALT_SIZE]; char salt_hex[ECRYPTFS_SALT_SIZE_HEX]; int rc = 0; + char *p; if (argc != 2) { usage(); goto out; } - memcpy(passphrase, argv[1], ECRYPTFS_MAX_PASSWORD_LENGTH); - passphrase[ECRYPTFS_MAX_PASSWORD_LENGTH] = '\0'; + if (strlen(argv[1]) == 1 && strncmp(argv[1], "-", 1) == 0) { + if (fgets(passphrase, ECRYPTFS_MAX_PASSWORD_LENGTH, stdin) == NULL) { + usage(); + goto out; + } + p = strrchr(passphrase, '\n'); + if (p) *p = '\0'; + } else { + memcpy(passphrase, argv[1], ECRYPTFS_MAX_PASSWORD_LENGTH); + passphrase[ECRYPTFS_MAX_PASSWORD_LENGTH] = '\0'; + } rc = ecryptfs_read_salt_hex_from_rc(salt_hex); if (rc) { printf("Unable to read salt value from user's " diff -upr 1/ecryptfs-utils-53/src/utils/ecryptfs-setup-private 2/ecryptfs-utils-53/src/utils/ecryptfs-setup-private --- ecryptfs-utils-53/src/utils/ecryptfs-setup-private 2008-10-22 15:59:19.895533209 -0500 +++ ecryptfs-utils-53/src/utils/ecryptfs-setup-private 2008-10-22 19:36:52.179587956 -0500 @@ -233,12 +229,12 @@ done # Setup wrapped-passphrase file u=`umask` umask 377 -ecryptfs-wrap-passphrase "$HOME/.ecryptfs/wrapped-passphrase" "$MOUNTPASS" "$LOGINPASS" || error "Could not wrap passphrase" +echo -e "$MOUNTPASS\n$LOGINPASS" | ecryptfs-wrap-passphrase "$HOME/.ecryptfs/wrapped-passphrase" - || error "Could not wrap passphrase" umask $u # Add the passphrase to current keyring # On subsequent logins, this should be handled by "pam_ecryptfs.so unwrap" -response=`ecryptfs-add-passphrase "$MOUNTPASS"` +response=`echo -e "$MOUNTPASS" | ecryptfs-add-passphrase -` if [ $? -ne 0 ]; then error "Could not add passphrase to the current keyring" fi diff -upr 1/ecryptfs-utils-53/src/utils/ecryptfs_wrap_passphrase.c 2/ecryptfs-utils-53/src/utils/ecryptfs_wrap_passphrase.c --- ecryptfs-utils-53/src/utils/ecryptfs_wrap_passphrase.c 2008-01-18 22:58:42.000000000 -0600 +++ ecryptfs-utils-53/src/utils/ecryptfs_wrap_passphrase.c 2008-10-22 18:59:14.523631473 -0500 @@ -20,6 +20,7 @@ #include #include +#include #include "config.h" void usage(void) @@ -39,14 +40,35 @@ int main(int argc, char *argv[]) char salt[ECRYPTFS_SALT_SIZE]; char salt_hex[ECRYPTFS_SALT_SIZE_HEX]; int rc = 0; + char *p; - if (argc != 4) { + if (argc == 3 && strlen(argv[2]) == 1 && strncmp(argv[2], "-", 1) == 0) { + if ((passphrase = (char *)malloc(ECRYPTFS_MAX_PASSWORD_LENGTH+1)) == NULL) { + perror("malloc"); + goto out; + } + if ((wrapping_passphrase = (char *)malloc(ECRYPTFS_MAX_PASSWORD_LENGTH+1)) == NULL) { + perror("malloc"); + goto out; + } + fgets(passphrase, ECRYPTFS_MAX_PASSWORD_LENGTH, stdin); + p = strrchr(passphrase, '\n'); + if (p) *p = '\0'; + fgets(wrapping_passphrase, ECRYPTFS_MAX_PASSWORD_LENGTH, stdin); + p = strrchr(wrapping_passphrase, '\n'); + if (p) *p = '\0'; + if (passphrase == NULL || wrapping_passphrase == NULL) { + usage(); + goto out; + } + } else if (argc == 4) { + passphrase = argv[2]; + wrapping_passphrase = argv[3]; + } else { usage(); goto out; } file = argv[1]; - passphrase = argv[2]; - wrapping_passphrase = argv[3]; rc = ecryptfs_read_salt_hex_from_rc(salt_hex); if (rc) { printf("Unable to read salt value from user's "