~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/utils/ecryptfs_add_key.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:
 
1
#include <stdio.h>
 
2
#include <ecryptfs.h>
 
3
 
 
4
void usage(void)
 
5
{
 
6
        printf("Usage:\n"
 
7
               "\n"
 
8
               "ecryptfs-add-key [module alias] [module params]\n"
 
9
               "\n");
 
10
}
 
11
 
 
12
int main(int argc, char *argv[])
 
13
{
 
14
        struct ecryptfs_pki_elem *selected_pki = NULL;
 
15
        char auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX + 1];
 
16
        int rc = 0;
 
17
 
 
18
        if (argc != 2) {
 
19
                usage();
 
20
                goto out;
 
21
        }
 
22
        if ((rc = ecryptfs_add_key_module_key_to_keyring(auth_tok_sig_hex,
 
23
                                                         selected_pki))) {
 
24
                printf("Error attempting to insert key "
 
25
                       "into the user session keyring; rc = [%d]. "
 
26
                       "Check the system log for more information from "
 
27
                       "libecryptfs.\n", rc);
 
28
                rc = 1;
 
29
                goto out;
 
30
        }
 
31
        auth_tok_sig_hex[ECRYPTFS_SIG_SIZE_HEX] = '\0';
 
32
        printf("Inserted auth tok with sig [%s] into the user session "
 
33
               "keyring\n", auth_tok_sig_hex);
 
34
out:
 
35
        return rc;
 
36
}