=== modified file 'src/include/ecryptfs.h' --- src/include/ecryptfs.h 2009-07-21 23:11:16 +0000 +++ src/include/ecryptfs.h 2009-11-11 00:03:13 +0000 @@ -514,7 +514,8 @@ int get_string_stdin(char **val, char *prompt, int echo); int stack_pop(struct val_node **head); int stack_pop_val(struct val_node **head, void **val); -int ecryptfs_mount(char *source, char *target, unsigned long flags, char *opts); +int ecryptfs_mount(char *source, char *target, unsigned long flags, char *opts, + int fake); int ecryptfs_get_current_kernel_ciphers( struct ecryptfs_cipher_elem *cipher_list_head); int ecryptfs_default_cipher(struct ecryptfs_cipher_elem **default_cipher, === modified file 'src/libecryptfs/main.c' --- src/libecryptfs/main.c 2009-07-22 14:32:32 +0000 +++ src/libecryptfs/main.c 2009-11-11 00:50:45 +0000 @@ -380,7 +380,8 @@ return rc; } -int ecryptfs_mount(char *source, char *target, unsigned long flags, char *opts) +int ecryptfs_mount(char *source, char *target, unsigned long flags, char *opts, + int fake) { FILE *mtab_fd = NULL; struct mntent mountent; @@ -420,6 +421,10 @@ goto out; } + if (fake == 1) { + goto out; + } + if (mount(fullpath_source, fullpath_target, "ecryptfs", flags, opts)) { rc = -errno; syslog(LOG_ERR, "Failed to perform eCryptfs mount: [%m]\n"); === modified file 'src/utils/mount.ecryptfs.c' --- src/utils/mount.ecryptfs.c 2009-07-17 07:32:40 +0000 +++ src/utils/mount.ecryptfs.c 2009-11-11 00:50:23 +0000 @@ -60,7 +60,7 @@ * returns 0 on success */ static int parse_arguments(int argc, char **argv, char **src, char **target, - char **options) + char **options, int *fake) { int rc = 0; char *ptr; @@ -99,30 +99,36 @@ if ((*target)[len - 1] == '/') (*target)[len - 1] = '\0'; } - if ((options) && (argc >= NUM_REQUIRED_ARGS)) { + if ((options) && argc >= NUM_REQUIRED_ARGS) { int i; ptr = NULL; - for (i = 3; i < (argc-1); i++) - if (!strcmp("-o", argv[i])) { + for (i = 3; i < (argc-1); i++) { + if (strcmp("-o", argv[i]) == 0) { ptr = argv[i+1]; - break; - } - if (!ptr) { - fprintf(stderr, "Unable to find a list of options to " + if (ptr) { + len = strlen(ptr) + 1; /* + NULL */ + *options = malloc(len); + if (!*options){ + fprintf(stderr, + "Unable to allocate memory for options " + "buffer\n"); + rc = -ENOMEM; + goto out; + } + memcpy(*options, ptr, len); + } else { + fprintf(stderr, + "Unable to find a list of options to " "parse, defaulting to interactive " "mount\n"); - return 0; - } - len = strlen(ptr) + 1; /* + NULL-terminator */ - *options = malloc(len); - if (!*options){ - fprintf(stderr, "Unable to allocate memory for options " - "buffer\n"); - rc = -ENOMEM; - goto out; - } - memcpy(*options, ptr, len); + } + /* Skip past the options string */ + i++; + } else if (strcmp("-f", argv[i]) == 0) { + *fake = 1; + } + } } return 0; out: @@ -457,7 +463,7 @@ * -> trans_func(head). */ static int ecryptfs_do_mount(int argc, char **argv, struct val_node *mnt_params, - int sig_cache, struct passwd *pw) + int sig_cache, struct passwd *pw, int fake) { int rc; int flags = 0; @@ -465,7 +471,7 @@ char *src = NULL, *targ = NULL, *opts = NULL, *new_opts = NULL, *temp; char *val; - if ((rc = parse_arguments(argc, argv, &src, &targ, &opts))) { + if ((rc = parse_arguments(argc, argv, &src, &targ, &opts, &fake))) { fprintf(stderr, "Unable to understand the mount options\n"); goto out; } @@ -512,7 +518,7 @@ rc); goto out; } - rc = ecryptfs_mount(src, targ, flags, new_opts); + rc = ecryptfs_mount(src, targ, flags, new_opts, fake); out: free(src); free(targ); @@ -532,6 +538,7 @@ int sig_cache = 1; int rc; struct passwd *pw; + int fake = 0; /* Nasty hack; On some systems, this need to run before we mlock. * See: @@ -585,7 +592,7 @@ memset(mnt_params, 0, sizeof(struct val_node)); memset(&ctx, 0, sizeof(struct ecryptfs_ctx)); ctx.get_string = &get_string_stdin; - if ((rc = parse_arguments(argc, argv, NULL, NULL, &opts_str))) + if ((rc = parse_arguments(argc, argv, NULL, NULL, &opts_str, &fake))) goto out; if (opts_str_contains_option(opts_str, "verbose")) ecryptfs_verbosity = 1; @@ -623,7 +630,8 @@ rc, strerror(-rc)); goto out; } - rc = ecryptfs_do_mount(argc, argv, mnt_params, sig_cache, pw); + rc = ecryptfs_do_mount(argc, argv, mnt_params, sig_cache, pw, + fake); if (rc == ECANCELED) { rc = 0; goto out;