~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/libecryptfs/key_management.c

  • Committer: Dustin Kirkland
  • Date: 2009-04-30 23:09:07 UTC
  • Revision ID: kirkland@canonical.com-20090430230907-siej46f5lbwg5uca
try the default ~/.ecryptfs/wrapped-passphrase before bailing out

  * include/ecryptfs.h, libecryptfs/key_management.c,
    utils/ecryptfs_insert_wrapped_passphrase_into_keyring.c,
    utils/ecryptfs_unwrap_passphrase.c: if the file to unwrap is
    unspecified, try to use the default ~/.ecryptfs/wrapped-passphrase
    before bailing out, LP: #359997


Signed-off-by: Dustin Kirkland <kirkland@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <sys/mman.h>
39
39
#include <sys/types.h>
40
40
#include <sys/stat.h>
 
41
#include <pwd.h>
41
42
#include "config.h"
42
43
#include "../include/ecryptfs.h"
43
44
 
925
926
        }
926
927
        return passphrase;
927
928
}
 
929
 
 
930
char *ecryptfs_get_wrapped_passphrase_filename() {
 
931
        struct passwd *pwd = NULL;
 
932
        struct stat s;
 
933
        char *filename = NULL;
 
934
        if ((pwd = getpwuid(getuid())) == NULL) {
 
935
                perror("getpwuid");
 
936
                return NULL;
 
937
        }
 
938
        if ((asprintf(&filename,
 
939
            "%s/.ecryptfs/wrapped-passphrase", pwd->pw_dir) < 0)) {
 
940
                perror("asprintf");
 
941
                return NULL;
 
942
        }
 
943
        if (stat(filename, &s) != 0) {
 
944
                perror("stat");
 
945
                return NULL;
 
946
        }
 
947
        return filename;
 
948
}