~mrooney/ecryptfs/nautilus-integration

« back to all changes in this revision

Viewing changes to src/libecryptfs/decision_graph.c

  • Committer: Dustin Kirkland
  • Date: 2009-01-26 18:08:13 UTC
  • Revision ID: git-v1:1abdd21606f764382f2abc8a73abda091ace76fd
clear relevant keys on helper unmount

If the user calls the ecryptfs-umount-private helper, clear the kernel
keyring of the keys used by that private helper.

This should help assuage bug:
https://bugs.launchpad.net/ecryptfs/+bug/313812

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

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;
235
233
                                }
236
234
                                return rc;
237
235
                        }
238
 
                        else return EINVAL;
 
236
                        else return -EINVAL;
239
237
                }
240
238
                while (nvp) {
241
239
                        int trans_func_tok_id = NULL_TOK;
275
273
                                trans_func_tok_id =
276
274
                                        tn->trans_func(ctx, current,
277
275
                                                       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)
 
276
                        if (trans_func_tok_id == MOUNT_ERROR)
286
277
                                return trans_func_tok_id;
287
278
                        if ((*next = tn->next_token))
288
279
                                return 0;
289
280
                        else return -EINVAL;
290
281
                }
291
282
        }
292
 
        return NULL_TOK;
 
283
        return MOUNT_ERROR;
293
284
}
294
285
 
295
286
/**
372
363
        int val;
373
364
        int value_retrieved;
374
365
        int i;
375
 
        int rc = 0;
376
 
        int tries = 0;
 
366
        int rc;
377
367
 
378
368
        if (ecryptfs_verbosity)
379
369
                syslog(LOG_INFO, "%s: Called on node->mnt_opt_names[0] = [%s]",
567
557
                        val = atoi(node->val);
568
558
                        if (val > 0 && val <= node->num_transitions) {
569
559
                                free(node->val);
570
 
                                if (asprintf(&(node->val), "%s",
571
 
                                             node->tl[val - 1].val) == -1) {
572
 
                                        rc = -ENOMEM;
573
 
                                        goto out;
574
 
                                }
 
560
                                asprintf(&(node->val), "%s",
 
561
                                         node->tl[val - 1].val);
575
562
                        } else {
576
563
                                int valid_val;
577
564
 
606
593
                                syslog(LOG_INFO, "%s: DISPLAY_TRANSITION_NODE_"
607
594
                                       "VALS not set\n", __FUNCTION__);
608
595
obtain_value:
609
 
                        if (++tries > 3) return EINVAL;
610
596
                        if (node->suggested_val)
611
 
                                rc = asprintf(&prompt, "%s [%s]", node->prompt,
 
597
                                asprintf(&prompt, "%s [%s]", node->prompt,
612
598
                                         node->suggested_val);
613
599
                        else
614
 
                                rc = asprintf(&prompt, "%s", node->prompt);
615
 
                        if (rc == -1) {
616
 
                                rc = -ENOMEM;
617
 
                                goto out;
618
 
                        }
619
 
                        rc = 0;
 
600
                                asprintf(&prompt, "%s", node->prompt);
620
601
                        if (ecryptfs_verbosity)
621
602
                                syslog(LOG_INFO,
622
603
                                       "%s: node->mnt_opt_names[0] = [%s]\n; "
627
608
                                (&(node->val), prompt,
628
609
                                 (node->flags
629
610
                                  & 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
611
                        free(prompt);
637
612
                        if (node->flags & VERIFY_VALUE) {
638
613
                                rc = asprintf(&verify_prompt, "Verify %s",
716
691
 
717
692
        memset(*mnt_params, 0, sizeof(struct val_node));
718
693
        rc = eval_param_tree(ctx, root_node, nvp_head, mnt_params);
719
 
        if ((rc > 0) && (rc != MOUNT_ERROR))
720
 
                return 0;
 
694
        if (rc == MOUNT_ERROR)
 
695
                goto out;
 
696
        else
 
697
                rc = 0;
 
698
out:
721
699
        return rc;
722
700
}
723
701
 
849
827
 
850
828
        if (trans_node->next_token)
851
829
                rc = ecryptfs_insert_params(nvp, trans_node->next_token);
852
 
 
 
830
out:
853
831
        return rc;
854
832
}
855
833
 
961
939
                rc = -ENOMEM;
962
940
                goto out;
963
941
        }
964
 
        rc = 0;
965
942
        subgraph_ctx = (struct ecryptfs_subgraph_ctx *)(*foo);
966
943
        walker = &subgraph_ctx->head_val_node;
967
944
        while (walker->next)
1014
991
        curr = subgraph_ctx->head_val_node.next;
1015
992
        while (curr) {
1016
993
                if (curr->val) {
1017
 
                        if ((rc = asprintf(&param_vals[i].val, "%s",
1018
 
                                           (char *)curr->val)) == -1) {
 
994
                        if ((rc = asprintf(&param_vals[i].val, "%s", curr->val))
 
995
                            == -1) {
1019
996
                                rc = -ENOMEM;
1020
997
                                goto out_free_list_and_subgraph_ctx;
1021
998
                        }
1036
1013
                rc = -ENOMEM;
1037
1014
                goto out_free_list_and_subgraph_ctx;
1038
1015
        }
1039
 
        rc = stack_push(mnt_params, sig_mnt_opt);
 
1016
        rc = 0;
 
1017
        stack_push(mnt_params, sig_mnt_opt);
1040
1018
out_free_list_and_subgraph_ctx:
1041
1019
        curr = subgraph_ctx->head_val_node.next;
1042
1020
        while (curr) {
1050
1028
        }
1051
1029
out_free_subgraph_ctx:
1052
1030
        free(subgraph_ctx);
1053
 
 
 
1031
out:
1054
1032
        return rc;
1055
1033
}
1056
1034
 
1139
1117
                        goto out;
1140
1118
                }
1141
1119
                param_node->num_mnt_opt_names = 1;
1142
 
                if (params[i].description) {
 
1120
                if (params[i].description)
1143
1121
                        if ((rc = asprintf(&param_node->prompt, "%s",
1144
1122
                                           params[i].description)) == -1) {
1145
1123
                                rc = -ENOMEM;
1146
1124
                                goto out;
1147
1125
                        }
1148
 
                } else
 
1126
                else
1149
1127
                        if ((rc = asprintf(&param_node->prompt, "%s",
1150
1128
                                           params[i].option)) == -1) {
1151
1129
                                rc = -ENOMEM;