~ubuntu-branches/debian/experimental/nfs-utils/experimental

« back to all changes in this revision

Viewing changes to support/export/keys.c

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2006-07-08 14:26:40 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060708142640-r171kjj2a13gy2kz
Tags: 1:1.0.9-1
* Updated co-mantainer mail address.
* New upstream release.
  - Added 'mount.nfs' utility which can be used as a mount helper
    to mount nfs filesystems. It does not yet support 'user' mounts.
  - Makefile/autoconf tidyups
  - No compiles with no warnings
  - deleted debian/* at request of debian maintainer
  - deleted assorted other unused files
  - mountd can be run multi-threaded for configurations with many hundreds
    of clients (mountd -t 20).  Default is single-threaded
  - Support for selection NFS version to be exported, and protocol to
    use.  This requires kernel patches that should be in linux 2.6.19.
  - Use 65534 rather than -2 for default anon.  This makes no difference in many
    cases, but is important in some.
  - New utility 'rpcdebug' for controlled kernel 'debug' options for nfs and nfsd.
  - nfsstat reports NFSv4 operation statistics that should be available in
    linux 2.6.18.
  - assorted other fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * keys.c               Key management for nfsd. Currently, keys
3
 
 *                      are kept in a single file only, but eventually,
4
 
 *                      support for a key server should be added.
5
 
 *
6
 
 * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
7
 
 */
8
 
 
9
 
#include "config.h"
10
 
 
11
 
#include <sys/stat.h>
12
 
#include "nfslib.h"
13
 
#include "exportfs.h"
14
 
#include "xmalloc.h"
15
 
 
16
 
struct keycache {
17
 
        struct keycache *       k_next;
18
 
        struct nfskeyent        k_data;
19
 
};
20
 
 
21
 
static struct keycache *        keycache = NULL;
22
 
static time_t                   lastmod = 0;
23
 
 
24
 
static void     key_reload(void);
25
 
 
26
 
 
27
 
struct nfskey *
28
 
key_lookup(char *hname)
29
 
{
30
 
        struct keycache *kc;
31
 
 
32
 
        key_reload();
33
 
 
34
 
        for (kc = keycache; kc; kc = kc->k_next) {
35
 
#if 0
36
 
                if (matchhostname(kc->k_data.k_hostname, hname))
37
 
#else
38
 
                if (!strcmp(kc->k_data.k_hostname, hname))
39
 
#endif
40
 
                        return &kc->k_data.k_key;
41
 
        }
42
 
 
43
 
        return NULL;
44
 
}
45
 
 
46
 
static void
47
 
key_reload(void)
48
 
{
49
 
        struct stat     stb;
50
 
        struct keycache *cp;
51
 
        struct nfskeyent *kp;
52
 
 
53
 
        if (stat(_PATH_NFSKEYS, &stb) >= 0 && stb.st_mtime == lastmod)
54
 
                return;
55
 
 
56
 
        while (keycache) {
57
 
                cp = keycache->k_next;
58
 
                xfree(keycache);
59
 
                keycache = cp;
60
 
        }
61
 
 
62
 
        setnfskeyent(_PATH_NFSKEYS);
63
 
        while ((kp = getnfskeyent()) != NULL) {
64
 
                cp = (struct keycache *) xmalloc(sizeof(*cp));
65
 
                cp->k_data = *kp;
66
 
                cp->k_next = keycache;
67
 
                keycache = cp;
68
 
        }
69
 
        endnfskeyent();
70
 
 
71
 
        lastmod = stb.st_mtime;
72
 
}