~ecryptfs/ecryptfs/trunk

« back to all changes in this revision

Viewing changes to src/utils/dump_auth_tok_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
/**
 
2
 * Copyright (C) 2004-2006 International Business Machines
 
3
 * Written by Michael A. Halcrow <mhalcrow@us.ibm.com>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License as
 
7
 * published by the Free Software Foundation; either version 2 of the
 
8
 * License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful, but
 
11
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
18
 * 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include <stdio.h>
 
22
#include <stddef.h>
 
23
#include <sys/types.h>
 
24
#include <keyutil.h>
 
25
#include "ecryptfs.h"
 
26
 
 
27
void dump_auth_tok(struct ecryptfs_auth_tok *auth_tok);
 
28
 
 
29
int main( int argc, char **argv )
 
30
{
 
31
        int rc;
 
32
        int key_id;
 
33
        struct ecryptfs_auth_tok auth_tok;
 
34
        if (argc != 2) {
 
35
                printf( "Usage: %s <key id>\n", argv[0]);
 
36
                exit(1);
 
37
        }
 
38
        key_id = atoi(argv[1]);
 
39
        /* Read the key */
 
40
        rc = keyctl(KEYCTL_READ, key_id, (char*)&auth_tok,
 
41
                                sizeof(struct ecryptfs_auth_tok));
 
42
        if (rc < 0) {
 
43
                printf("Error reading key with id [%d]\n", key_id);
 
44
                exit(1);
 
45
        }
 
46
        printf("Successful read of key id [%d]\n",key_id);
 
47
        dump_auth_tok(&auth_tok);
 
48
        exit(0);
 
49
}