~mrooney/ecryptfs/nautilus-integration

« back to all changes in this revision

Viewing changes to src/libecryptfs/decision_graph.c

  • Committer: mhalcrow@us.ibm.com
  • Date: 2007-11-06 22:56:01 UTC
  • Revision ID: git-v1:f8357de9d554b274497b5cce9db4347254b7e7eb
Initial import of eCryptfs filesystem userspace utilities (mount helper, daemon component,
etc.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * 02111-1307, USA.
20
20
 */
21
21
 
22
 
#include "config.h"
23
22
#include <errno.h>
24
23
#include <stdint.h>
25
24
#ifndef S_SPLINT_S
29
28
#include <stdlib.h>
30
29
#include <string.h>
31
30
#include <unistd.h>
 
31
#include "config.h"
32
32
#include "../include/ecryptfs.h"
33
33
#include "../include/decision_graph.h"
34
34
 
78
78
        while (pair) {
79
79
                if (pair->value)
80
80
                        free(pair->value);
81
 
                if (pair->name)
82
 
                        free(pair->name);
83
81
                next = pair->next;
84
82
                free(pair);
85
83
                pair = next;
105
103
        return rc;
106
104
}
107
105
 
108
 
/**
109
 
 * set_exit_param_node_for_node
110
 
 *
111
 
 * Sets all NULL next_token's to exit_param_node
112
 
 */
113
106
int set_exit_param_node_for_node(struct param_node *param_node,
114
107
                                 struct param_node *exit_param_node,
115
108
                                 int recursive)
134
127
}
135
128
 
136
129
/**
137
 
 * Sets the exit param node for all NULL transitions throughout an
 
130
 * Sets the exist param node for all NULL transitions throughout an
138
131
 * entire graph.
139
132
 */
140
133
int ecryptfs_set_exit_param_on_graph(struct param_node *param_node,
143
136
        return set_exit_param_node_for_node(param_node, exit_param_node, 1);
144
137
}
145
138
 
146
 
/**
147
 
 * set_exit_param_node_for_arr
148
 
 *
149
 
 * Sets the exit param node for all NULL transitions contained in an
150
 
 * array of param nodes.
151
 
 */
152
139
int set_exit_param_node_for_arr(struct param_node param_node_arr[],
153
140
                                struct param_node *exit_param_node)
154
141
{
186
173
 
187
174
/**
188
175
 * do_transition
189
 
 * @ctx: The current eCryptfs library context
190
 
 * @next: Set to the param_node that the transition engine determines
191
 
 *        is the next node
192
 
 * @current: The current param_node from which we are transitioning
193
 
 * @nvp_head: The name-value pair list that contains name-value pairs
194
 
 *            specified on the command line or provided via the
195
 
 *            .ecryptfsrc file. Whenever a param node needs a value,
196
 
 *            the decision graph logic first scans this list for a
197
 
 *            corresponding name-value pair
198
 
 * @mnt_params: Head of mount option stack that the callback functions
199
 
 *              for the transition nodes in the param node populate
200
 
 * @foo: An arbitrary data structure that the transition node callback
201
 
 *       functions create, reference, and destroy
 
176
 * @ctx:
 
177
 * @next:
 
178
 * @current:
 
179
 * @nvp_head:
 
180
 * @mnt_params: Head of mount option stack
 
181
 * @foo:
202
182
 *
203
183
 * This function needs to compare transition nodes to options.
204
184
 * It is currently comparing them to values provided to options.
235
215
                                }
236
216
                                return rc;
237
217
                        }
238
 
                        else return EINVAL;
 
218
                        else return -EINVAL;
239
219
                }
240
220
                while (nvp) {
241
221
                        int trans_func_tok_id = NULL_TOK;
268
248
        for (i = 0; i < current->num_transitions; i++) {
269
249
                struct transition_node *tn = &current->tl[i];
270
250
 
271
 
                if (tn->val && strcmp("default", tn->val) == 0) {
 
251
                if (tn->val && strcmp("default", tn->val) == 0){
272
252
                        int trans_func_tok_id = NULL_TOK;
273
253
 
274
254
                        if (tn->trans_func)
275
255
                                trans_func_tok_id =
276
256
                                        tn->trans_func(ctx, current,
277
257
                                                       mnt_params, foo);
278
 
                        if (trans_func_tok_id == WRONG_VALUE && 
279
 
                            (ctx->verbosity || 
280
 
                             (current->flags & STDIN_REQUIRED))) {
281
 
                            *next = current;
282
 
                            return 0;
283
 
                        }
284
 
                        if (trans_func_tok_id == MOUNT_ERROR || 
285
 
                            trans_func_tok_id < 0)
 
258
                        if (trans_func_tok_id == MOUNT_ERROR)
286
259
                                return trans_func_tok_id;
287
260
                        if ((*next = tn->next_token))
288
261
                                return 0;
289
262
                        else return -EINVAL;
290
263
                }
291
264
        }
292
 
        return NULL_TOK;
 
265
        return MOUNT_ERROR;
293
266
}
294
267
 
295
268
/**
296
269
 * Try to find one of the aliases for this node in the list of
297
270
 * name-value pairs. If found, set the value from that element in the
298
271
 * list.
299
 
 *
300
 
 * Returns non-zero on error condition
301
272
 */
302
 
static int retrieve_val(int *value_retrieved,
303
 
                        struct ecryptfs_name_val_pair *nvp_head,
 
273
static int retrieve_val(struct ecryptfs_name_val_pair *nvp_head,
304
274
                        struct param_node *node)
305
275
{
306
276
        int i = node->num_mnt_opt_names;
307
 
        int rc = 0;
308
277
 
309
278
        if (ecryptfs_verbosity)
310
279
                syslog(LOG_INFO, "%s: Called on node [%s]\n", __FUNCTION__,
311
280
                       node->mnt_opt_names[0]);
312
 
        (*value_retrieved) = 0;
313
281
        while (i > 0) {
314
282
                struct ecryptfs_name_val_pair *temp = nvp_head->next;
315
283
 
331
299
                                if (temp->value
332
300
                                    && (strcmp(temp->value, "(null)") != 0)) {
333
301
                                        if (asprintf(&node->val, "%s",
334
 
                                                     temp->value) == -1) {
335
 
                                                rc = -ENOMEM;
336
 
                                                goto out;
337
 
                                        }
338
 
                                } else
 
302
                                                     temp->value) == -1)
 
303
                                                return -ENOMEM;
 
304
                                } else {
339
305
                                        node->flags |= PARAMETER_SET;
340
 
                                (*value_retrieved) = 1;
341
 
                                goto out;
 
306
                                        return -1;
 
307
                                }
 
308
                                return 0;
342
309
                        }
343
310
                        temp = temp->next;
344
311
                }
345
312
        }
346
 
        if (node->default_val && (strcmp(node->default_val, "NULL") != 0)) {
347
 
                if (asprintf(&node->val, "%s", node->default_val) == -1) {
348
 
                        rc = -ENOMEM;
349
 
                        goto out;
350
 
                }
351
 
                if (ecryptfs_verbosity)
352
 
                        syslog(LOG_INFO, "%s: Value retrieved from "
353
 
                               "node->default_val = [%s]\n", __FUNCTION__,
354
 
                               node->default_val);
355
 
                (*value_retrieved) = 1;
356
 
                goto out;
 
313
        if (node->default_val) {
 
314
                if (asprintf(&node->val, "%s", node->default_val) == -1)
 
315
                        return -ENOMEM;
 
316
                return 0;
357
317
        }
358
 
out:
359
 
        return rc;
 
318
        return -1;
360
319
}
361
320
 
362
321
/**
369
328
{
370
329
        char *verify_prompt;
371
330
        char *verify;
 
331
        int rc = 0;
372
332
        int val;
373
 
        int value_retrieved;
374
 
        int i;
375
 
        int rc = 0;
376
 
        int tries = 0;
377
333
 
378
 
        if (ecryptfs_verbosity)
379
 
                syslog(LOG_INFO, "%s: Called on node->mnt_opt_names[0] = [%s]",
380
 
                       __FUNCTION__, node->mnt_opt_names[0]);
381
 
        if (node->val) {
382
 
                if (ecryptfs_verbosity)
383
 
                        syslog(LOG_INFO, "%s: node->val already set to [%s]\n",
384
 
                               __FUNCTION__, node->val);
385
 
                goto out;
386
 
        }
387
 
        rc = retrieve_val(&value_retrieved, nvp_head, node);
388
 
        if (rc) {
389
 
                syslog(LOG_ERR, "%s: Error attempting to retrieve value; "
390
 
                       "rc = [%d]\n", __FUNCTION__, rc);
391
 
                goto out;
392
 
        }
393
 
        if (value_retrieved) {
394
 
                if (ecryptfs_verbosity)
395
 
                        syslog(LOG_INFO,
396
 
                               "%s: Value retrieved from default_val or from "
397
 
                               "parameter list; returning\n",
398
 
                               __FUNCTION__);
399
 
                if (!(node->flags & ECRYPTFS_ALLOW_IMPLICIT_TRANSITION
400
 
                      && node->flags & ECRYPTFS_IMPLICIT_OVERRIDE_DEFAULT))
401
 
                        goto out;
402
 
        }
403
 
        if (node->flags & ECRYPTFS_ALLOW_IMPLICIT_TRANSITION
404
 
            && !(node->flags & ECRYPTFS_NO_AUTO_TRANSITION)) {
405
 
                for (i = 0; i < node->num_transitions; i++) {
406
 
                        if (node->tl[i].next_token)
407
 
                                rc = retrieve_val(&value_retrieved, nvp_head,
408
 
                                                  node->tl[i].next_token);
409
 
                        if (rc) {
410
 
                                syslog(LOG_ERR, "%s: Error attempting to "
411
 
                                       "retrieve value; rc = [%d]\n",
412
 
                                       __FUNCTION__, rc);
413
 
                                goto out;
414
 
                        }
415
 
                        if (value_retrieved) {
416
 
                                if (ecryptfs_verbosity)
417
 
                                        syslog(LOG_INFO,
418
 
                                               "%s: Value retrieved from "
419
 
                                               "default_val or from parameter "
420
 
                                               "list for successive "
421
 
                                               "node at transition slot [%d]; "
422
 
                                               "returning\n", __FUNCTION__, i);
423
 
                                rc = asprintf(&node->val, "%s",
424
 
                                              node->tl[i].next_token->mnt_opt_names[0]);
425
 
                                if (rc == -1) {
426
 
                                        rc = -ENOMEM;
427
 
                                        goto out;
428
 
                                }
429
 
                                rc = 0;
430
 
                                goto out;
431
 
                        }
432
 
                }
433
 
        }
434
 
        if (node->flags & ECRYPTFS_PARAM_FLAG_NO_VALUE) {
435
 
                if (ecryptfs_verbosity)
436
 
                        syslog(LOG_INFO,
437
 
                               "%s: ECRYPTFS_PARAM_FLAG_NO_VALUE set\n",
438
 
                               __FUNCTION__);
439
 
                goto out;
440
 
        }
441
 
        if (ctx->verbosity == 0 && !(node->flags & STDIN_REQUIRED)) {
442
 
                if (ecryptfs_verbosity)
443
 
                        syslog(LOG_INFO, "%s: ctx->verbosity == 0 and "
444
 
                               "STDIN_REQUIRED not set\n", __FUNCTION__);
445
 
                goto out;
446
 
        }
447
 
        if ((node->flags & PARAMETER_SET) && !(node->flags & STDIN_REQUIRED)) {
448
 
                if (ecryptfs_verbosity)
449
 
                        syslog(LOG_INFO, "%s: PARAMETER_SET and "
450
 
                               "STDIN_REQUIRED not set\n", __FUNCTION__);
451
 
                goto out;
452
 
        }
 
334
        if (!retrieve_val(nvp_head, node))
 
335
                goto out;
 
336
        if (node->flags & ECRYPTFS_PARAM_FLAG_NO_VALUE)
 
337
                goto out;
 
338
        if (ctx->verbosity == 0 && !(node->flags & STDIN_REQUIRED))
 
339
                return 0;
 
340
        if ((node->flags & PARAMETER_SET) && !(node->flags & STDIN_REQUIRED))
 
341
                return 0;
453
342
        if (ctx->get_string) {
454
 
                if (ecryptfs_verbosity)
455
 
                        syslog(LOG_INFO, "%s: ctx->get_string defined\n",
456
 
                               __FUNCTION__);
457
343
                if (node->flags & DISPLAY_TRANSITION_NODE_VALS) {
458
 
                        struct prompt_elem pe_head;
459
 
                        struct prompt_elem *pe;
 
344
                        int i, strpos = 0;
 
345
                        int node_prompt_len = strlen(node->prompt);
 
346
                        int default_val_len = 0;
 
347
                        int len;
460
348
                        char *prompt;
461
 
                        uint32_t prompt_len;
462
 
                        int i;
463
349
 
464
 
                        if (ecryptfs_verbosity)
465
 
                                syslog(LOG_INFO, "%s: DISPLAY_TRANSITION_NODE_"
466
 
                                       "VALS set\n", __FUNCTION__);
467
 
                        memset(&pe_head, 0, sizeof(pe_head));
468
 
                        pe = &pe_head;
469
 
                        if ((node->num_transitions == 1)
 
350
                        if (node->default_val)
 
351
                                default_val_len = strlen(node->default_val);
 
352
                        len = node_prompt_len + default_val_len + 32;
 
353
                        if (node->num_transitions == 1
470
354
                            && !(node->flags
471
355
                                 & ECRYPTFS_PARAM_FORCE_DISPLAY_NODES)) {
472
356
                                if (asprintf(&(node->val), "%s",
473
 
                                             node->tl[0].val) == -1) {
474
 
                                        rc = -ENOMEM;
475
 
                                        goto out;
476
 
                                }
477
 
                                rc = 0;
478
 
                                goto out;
479
 
                        }
480
 
                        pe->next = malloc(sizeof(*pe));
481
 
                        if (!pe->next) {
482
 
                                rc = -ENOMEM;
483
 
                                goto out;
484
 
                        }
485
 
                        pe = pe->next;
486
 
                        memset(pe, 0, sizeof(*pe));
487
 
                        rc = asprintf(&pe->str, "%s: \n", node->prompt);
488
 
                        if (rc == -1) {
489
 
                                rc = -ENOMEM;
490
 
                                goto out;
491
 
                        }
492
 
                        rc = 0;
 
357
                                             node->tl[0].val) == -1)
 
358
                                        return MOUNT_ERROR;
 
359
                                return 0;
 
360
                        }
 
361
                        for (i = 0; i < node->num_transitions; i++)
 
362
                                len += (strlen(node->tl[i].val) + 5);
 
363
                        prompt = malloc(len);
 
364
                        if (!prompt)
 
365
                                return -ENOMEM;
 
366
                        memcpy(prompt, node->prompt, node_prompt_len);
 
367
                        prompt[node_prompt_len] = ':';
 
368
                        strpos = node_prompt_len + 1;
 
369
                        prompt[strpos++] = '\n';
493
370
                        for (i = 0; i < node->num_transitions; i++) {
494
 
                                pe->next = malloc(sizeof(*pe));
495
 
                                if (!pe->next) {
496
 
                                        rc = -ENOMEM;
497
 
                                        goto out;
498
 
                                }
499
 
                                pe = pe->next;
500
 
                                memset(pe, 0, sizeof(*pe));
501
 
                                if (node->flags & ECRYPTFS_DISPLAY_PRETTY_VALS)
502
 
                                        rc = asprintf(&pe->str, " %d) %s\n",
503
 
                                                      (i + 1),
504
 
                                                      node->tl[i].pretty_val);
505
 
                                else
506
 
                                        rc = asprintf(&pe->str, " %d) %s\n",
507
 
                                                      (i + 1),
508
 
                                                      node->tl[i].val);
509
 
                                if (rc == -1) {
510
 
                                        rc = -ENOMEM;
511
 
                                        goto out;
512
 
                                }
513
 
                                rc = 0;
514
 
                        }
515
 
                        pe->next = malloc(sizeof(*pe));
516
 
                        if (!pe->next) {
517
 
                                rc = -ENOMEM;
518
 
                                goto out;
519
 
                        }
520
 
                        pe = pe->next;
521
 
                        memset(pe, 0, sizeof(*pe));
522
 
                        if (node->suggested_val)
523
 
                                rc = asprintf(&pe->str, "Selection [%s]",
524
 
                                              node->suggested_val);
525
 
                        else if (node->default_val)
526
 
                                rc = asprintf(&pe->str, "Selection [%s]",
527
 
                                              node->default_val);
528
 
                        else
529
 
                                rc = asprintf(&pe->str, "Selection");
530
 
                        if (rc == -1) {
531
 
                                rc = -ENOMEM;
532
 
                                goto out;
533
 
                        }
534
 
                        rc = 0;
535
 
                        /* Convert prompt_elem linked list into
536
 
                         * single prompt string */
537
 
                        prompt_len = 0;
538
 
                        pe = pe_head.next;
539
 
                        while (pe) {
540
 
                                prompt_len += strlen(pe->str);
541
 
                                pe = pe->next;
542
 
                        }
543
 
                        prompt_len++;
544
 
                        i = 0;
545
 
                        prompt = malloc(prompt_len);
546
 
                        if (!prompt) {
547
 
                                rc = -ENOMEM;
548
 
                                goto out;
549
 
                        }
550
 
                        pe = pe_head.next;
551
 
                        while (pe) {
552
 
                                struct prompt_elem *pe_tmp;
553
 
 
554
 
                                memcpy(&prompt[i], pe->str, strlen(pe->str));
555
 
                                i += strlen(pe->str);
556
 
                                pe_tmp = pe;
557
 
                                pe = pe->next;
558
 
                                free(pe_tmp->str);
559
 
                                free(pe_tmp);
560
 
                        }
561
 
                        prompt[i] = '\0';
 
371
                                prompt[strpos++] = ' ';
 
372
                                prompt[strpos++] = '0' + (char)(i + 1);
 
373
                                prompt[strpos++] = ')';
 
374
                                prompt[strpos++] = ' ';
 
375
                                memcpy(&prompt[strpos], node->tl[i].val,
 
376
                                       strlen(node->tl[i].val));
 
377
                                strpos += strlen(node->tl[i].val);
 
378
                                prompt[strpos++] = '\n';
 
379
                        }
 
380
                        memcpy(&prompt[strpos], "Selection", 9);
 
381
                        strpos += 9;
 
382
                        if (node->suggested_val) {
 
383
                                memcpy(&prompt[strpos], " [", 2);
 
384
                                strpos += 2;
 
385
                                memcpy(&prompt[strpos], node->default_val,
 
386
                                       default_val_len);
 
387
                                strpos += default_val_len;
 
388
                                memcpy(&prompt[strpos], "]", 1);
 
389
                                strpos += 1;
 
390
                        } else if (node->default_val) {
 
391
                                memcpy(&prompt[strpos], " [", 2);
 
392
                                strpos += 2;
 
393
                                memcpy(&prompt[strpos], node->default_val,
 
394
                                       default_val_len);
 
395
                                strpos += default_val_len;
 
396
                                memcpy(&prompt[strpos], "]", 1);
 
397
                                strpos += 1;
 
398
                        }
 
399
                        prompt[strpos] = '\0';
562
400
get_value:
563
401
                        rc = (ctx->get_string)
564
402
                                (&(node->val), prompt,
567
405
                        val = atoi(node->val);
568
406
                        if (val > 0 && val <= node->num_transitions) {
569
407
                                free(node->val);
570
 
                                if (asprintf(&(node->val), "%s",
571
 
                                             node->tl[val - 1].val) == -1) {
572
 
                                        rc = -ENOMEM;
573
 
                                        goto out;
574
 
                                }
 
408
                                asprintf(&(node->val), "%s",
 
409
                                         node->tl[val - 1].val);
575
410
                        } else {
576
 
                                int valid_val;
577
 
 
578
 
                                if (node->val[0] == '\0') {
579
 
                                        if (!node->suggested_val)
580
 
                                                goto get_value;
581
 
                                        rc = asprintf(&node->val, "%s",
582
 
                                                      node->suggested_val);
583
 
                                        if (rc == -1) {
584
 
                                                rc = -ENOMEM;
585
 
                                                goto out;
586
 
                                        }
587
 
                                        rc = 0;
588
 
                                }
589
 
                                valid_val = 0;
590
 
                                for (i = 0; i < node->num_transitions; i++) {
591
 
                                        if (strcmp(node->val, node->tl[i].val)
592
 
                                            == 0) {
593
 
                                                valid_val = 1;
594
 
                                                break;
595
 
                                        }
596
 
                                }
597
 
                                if (!valid_val)
598
 
                                        goto get_value;
 
411
                                goto get_value;
599
412
                        }
600
413
                        free(prompt);
601
414
                        return rc;
602
415
                } else {
603
416
                        char *prompt;
604
417
 
605
 
                        if (ecryptfs_verbosity)
606
 
                                syslog(LOG_INFO, "%s: DISPLAY_TRANSITION_NODE_"
607
 
                                       "VALS not set\n", __FUNCTION__);
608
418
obtain_value:
609
 
                        if (++tries > 3) return EINVAL;
610
419
                        if (node->suggested_val)
611
 
                                rc = asprintf(&prompt, "%s [%s]", node->prompt,
 
420
                                asprintf(&prompt, "%s [%s]", node->prompt,
612
421
                                         node->suggested_val);
613
422
                        else
614
 
                                rc = asprintf(&prompt, "%s", node->prompt);
615
 
                        if (rc == -1) {
616
 
                                rc = -ENOMEM;
617
 
                                goto out;
618
 
                        }
619
 
                        rc = 0;
 
423
                                asprintf(&prompt, "%s", node->prompt);
620
424
                        if (ecryptfs_verbosity)
621
425
                                syslog(LOG_INFO,
622
 
                                       "%s: node->mnt_opt_names[0] = [%s]\n; "
 
426
                                       "node->mnt_opt_names[0] = [%s]\n; "
623
427
                                       "node->flags = [0x%.8x]\n",
624
 
                                       __FUNCTION__,
625
428
                                       node->mnt_opt_names[0], node->flags);
626
429
                        rc = (ctx->get_string)
627
430
                                (&(node->val), prompt,
628
431
                                 (node->flags
629
432
                                  & ECRYPTFS_PARAM_FLAG_ECHO_INPUT));
630
 
                        if (node->val[0] == '\0' && 
631
 
                            (node->flags & ECRYPTFS_NONEMPTY_VALUE_REQUIRED)) {
632
 
                                fprintf(stderr,"Wrong input, non-empty value "
633
 
                                        "required!\n");
634
 
                                goto obtain_value;
635
 
                        }
636
433
                        free(prompt);
637
434
                        if (node->flags & VERIFY_VALUE) {
638
435
                                rc = asprintf(&verify_prompt, "Verify %s",
654
451
                        }
655
452
                        return rc;
656
453
                }
657
 
        } else {
658
 
                if (ecryptfs_verbosity)
659
 
                        syslog(LOG_INFO, "%s: ctx->get_string not defined",
660
 
                               __FUNCTION__);
661
454
        }
662
 
        rc = MOUNT_ERROR;
 
455
        return MOUNT_ERROR;
663
456
out:
664
457
        return rc;
665
458
}
689
482
 
690
483
        get_verbosity(nvp_head, &(ctx->verbosity));
691
484
        do {
692
 
                if (ecryptfs_verbosity) {
693
 
                        int i;
694
 
 
 
485
                if (ecryptfs_verbosity)
695
486
                        syslog(LOG_INFO, "%s: Calling alloc_and_get_val() on "
696
487
                               "node = [%p]; node->mnt_opt_names[0] = [%s]\n",
697
488
                               __FUNCTION__, node, node->mnt_opt_names[0]);
698
 
                        for (i = 0; i < node->num_transitions; i++) {
699
 
                                syslog(LOG_INFO,
700
 
                                       "%s:  node->tl[%d].val = [%s]\n",
701
 
                                       __FUNCTION__, i, node->tl[i].val);
702
 
                        }
703
 
                }
704
489
                if ((rc = alloc_and_get_val(ctx, node, nvp_head)))
705
490
                        return rc;
706
491
        } while (!(rc = do_transition(ctx, &node, node, nvp_head,
716
501
 
717
502
        memset(*mnt_params, 0, sizeof(struct val_node));
718
503
        rc = eval_param_tree(ctx, root_node, nvp_head, mnt_params);
719
 
        if ((rc > 0) && (rc != MOUNT_ERROR))
720
 
                return 0;
 
504
        if (rc == MOUNT_ERROR)
 
505
                goto out;
 
506
        else
 
507
                rc = 0;
 
508
out:
721
509
        return rc;
722
510
}
723
511
 
832
620
                }
833
621
        }
834
622
out:
835
 
        return rc;
 
623
                return rc;
836
624
}
837
625
 
838
626
/**
849
637
 
850
638
        if (trans_node->next_token)
851
639
                rc = ecryptfs_insert_params(nvp, trans_node->next_token);
852
 
 
 
640
out:
853
641
        return rc;
854
642
}
855
643
 
961
749
                rc = -ENOMEM;
962
750
                goto out;
963
751
        }
964
 
        rc = 0;
965
752
        subgraph_ctx = (struct ecryptfs_subgraph_ctx *)(*foo);
966
753
        walker = &subgraph_ctx->head_val_node;
967
754
        while (walker->next)
1014
801
        curr = subgraph_ctx->head_val_node.next;
1015
802
        while (curr) {
1016
803
                if (curr->val) {
1017
 
                        if ((rc = asprintf(&param_vals[i].val, "%s",
1018
 
                                           (char *)curr->val)) == -1) {
 
804
                        if ((rc = asprintf(&param_vals[i].val, "%s", curr->val))
 
805
                            == -1) {
1019
806
                                rc = -ENOMEM;
1020
807
                                goto out_free_list_and_subgraph_ctx;
1021
808
                        }
1036
823
                rc = -ENOMEM;
1037
824
                goto out_free_list_and_subgraph_ctx;
1038
825
        }
1039
 
        rc = stack_push(mnt_params, sig_mnt_opt);
 
826
        rc = 0;
 
827
        stack_push(mnt_params, sig_mnt_opt);
1040
828
out_free_list_and_subgraph_ctx:
1041
829
        curr = subgraph_ctx->head_val_node.next;
1042
830
        while (curr) {
1050
838
        }
1051
839
out_free_subgraph_ctx:
1052
840
        free(subgraph_ctx);
1053
 
 
 
841
out:
1054
842
        return rc;
1055
843
}
1056
844
 
1139
927
                        goto out;
1140
928
                }
1141
929
                param_node->num_mnt_opt_names = 1;
1142
 
                if (params[i].description) {
 
930
                if (params[i].description)
1143
931
                        if ((rc = asprintf(&param_node->prompt, "%s",
1144
932
                                           params[i].description)) == -1) {
1145
933
                                rc = -ENOMEM;
1146
934
                                goto out;
1147
935
                        }
1148
 
                } else
 
936
                else
1149
937
                        if ((rc = asprintf(&param_node->prompt, "%s",
1150
938
                                           params[i].option)) == -1) {
1151
939
                                rc = -ENOMEM;