~ubuntu-branches/ubuntu/trusty/libpam-mount/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/mnt_fallback/src/pam_mount.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Kleineidam
  • Date: 2010-12-03 20:27:54 UTC
  • mfrom: (1.4.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101203202754-ki2m85culrxwklox
Tags: 2.7-1
* New upstream release.
  + Remove mnt_fallback patch since squeeze will have 2.5 and upgrading
    from 0.4x versions is not needed anymore.
  + Readd copy of ofl and fd0ssh to avoid installing a complete new
    package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef PMT_PAM_MOUNT_H
2
 
#define PMT_PAM_MOUNT_H 1
3
 
 
4
 
#include <sys/types.h>
5
 
#include <limits.h>
6
 
#include <stdbool.h>
7
 
#include <libHX/list.h>
8
 
#include <libHX/option.h>
9
 
#include <libHX/string.h>
10
 
#include "config.h"
11
 
 
12
 
#ifdef HAVE_VISIBILITY_HIDDEN
13
 
#       define EXPORT_SYMBOL __attribute__((visibility("default")))
14
 
#else
15
 
#       define EXPORT_SYMBOL
16
 
#endif
17
 
 
18
 
#ifndef S_IRXG
19
 
#       define S_IRXG (S_IRGRP | S_IXGRP)
20
 
#endif
21
 
#ifndef S_IRXO
22
 
#       define S_IRXO (S_IROTH | S_IXOTH)
23
 
#endif
24
 
#define sizeof_z(x) (sizeof(x) - 1)
25
 
 
26
 
/*
27
 
 * So many programs trash a useful $PATH (including mount(8)),
28
 
 * so just provide our own.
29
 
 */
30
 
#define PMT_DFL_PATH \
31
 
        "/usr/local/libexec/hxtools:/usr/local/lib/hxtools:" \
32
 
        "/usr/local/sbin:/usr/local/bin:" \
33
 
        "/usr/libexec/hxtools:/usr/lib/hxtools:" \
34
 
        "/usr/sbin:/usr/bin:/sbin:/bin"
35
 
#define PMT_DFL_DMCRYPT_CIPHER "aes-cbc-essiv:sha256"
36
 
#define PMT_DFL_FSK_CIPHER     "aes-256-cbc"
37
 
#define PMT_DFL_FSK_HASH       "sha1"
38
 
 
39
 
/* Note that you will also need to change PMPREFIX in pmvarrun.c then! */
40
 
#define l0g(fmt, ...) \
41
 
        misc_log(("%s(%s:%u): " fmt), pmtlog_prefix, HX_basename(__FILE__), \
42
 
        __LINE__, ## __VA_ARGS__)
43
 
#define w4rn(fmt, ...) \
44
 
        misc_warn(("%s(%s:%u): " fmt), pmtlog_prefix, HX_basename(__FILE__), \
45
 
        __LINE__, ## __VA_ARGS__)
46
 
 
47
 
struct HXdeque;
48
 
struct HXformatmap;
49
 
struct HXproc;
50
 
struct loop_info64;
51
 
 
52
 
enum auth_type {
53
 
        GET_PASS,
54
 
        USE_FIRST_PASS,
55
 
        TRY_FIRST_PASS,
56
 
        SOFT_TRY_PASS,
57
 
};
58
 
 
59
 
enum command_type {
60
 
        CMD_SMBMOUNT,
61
 
        CMD_SMBUMOUNT,
62
 
        CMD_CIFSMOUNT,
63
 
        CMD_NCPMOUNT,
64
 
        CMD_NCPUMOUNT,
65
 
        CMD_FUSEMOUNT,
66
 
        CMD_FUSEUMOUNT,
67
 
        CMD_LCLMOUNT,
68
 
        CMD_CRYPTMOUNT,
69
 
        CMD_CRYPTUMOUNT,
70
 
        CMD_NFSMOUNT,
71
 
        CMD_UMOUNT,
72
 
        CMD_PMHELPER,
73
 
        CMD_FSCK,
74
 
        CMD_PMVARRUN,
75
 
        CMD_FD0SSH,
76
 
        CMD_OFL,
77
 
        _CMD_MAX,
78
 
        CMD_NONE,
79
 
};
80
 
 
81
 
enum {
82
 
        /* src */
83
 
        PMTLOG_ERR = 0,
84
 
        PMTLOG_DBG,
85
 
        PMTLOG_SRCMAX,
86
 
 
87
 
        /* dst */
88
 
        PMTLOG_SYSLOG = 0,
89
 
        PMTLOG_STDERR,
90
 
        PMTLOG_DSTMAX,
91
 
};
92
 
 
93
 
struct vol {
94
 
        struct HXlist_head list;
95
 
        enum command_type type;
96
 
        /* true if configuration from global config, false if luserconf */
97
 
        bool globalconf;
98
 
        /* set, so that umount can rmdir it */
99
 
        bool created_mntpt;
100
 
        /* expansion already took place */
101
 
        bool is_expanded;
102
 
        /* was handed off to mount_op() */
103
 
        bool mnt_processed;
104
 
        const char *user;
105
 
        char *fstype, *server, *volume, *mountpoint, *cipher;
106
 
        char *fs_key_cipher, *fs_key_hash, *fs_key_path;
107
 
        /* May be NULL if no options */
108
 
        struct HXclist_head options;
109
 
        bool use_fstab;
110
 
        bool uses_ssh;
111
 
        bool noroot;
112
 
};
113
 
 
114
 
/**
115
 
 * @sig_hup:    send SIGHUP to processes keeping mountpoint open
116
 
 * @sig_term:   send SIGTERM - " -
117
 
 * @sig_kill:   send SIGKILL - " -
118
 
 * @sig_wait:   wait this many seconds between sending signals,
119
 
 *              in microseconds
120
 
 */
121
 
struct config {
122
 
        /* user logging in */
123
 
        char *user;
124
 
        unsigned int debug;
125
 
        bool mkmntpoint, rmdir_mntpt;
126
 
        bool seen_mntoptions_require, seen_mntoptions_allow;
127
 
        hxmc_t *luserconf;
128
 
        struct HXdeque *command[_CMD_MAX];
129
 
        struct HXmap *options_require, *options_allow, *options_deny;
130
 
        struct HXclist_head volume_list;
131
 
        int level;
132
 
        char *msg_authpw, *msg_sessionpw, *path;
133
 
 
134
 
        bool sig_hup, sig_term, sig_kill;
135
 
        unsigned int sig_wait;
136
 
};
137
 
 
138
 
struct kvp {
139
 
        char *key, *value;
140
 
        struct HXlist_head list;
141
 
};
142
 
 
143
 
/**
144
 
 * struct ehd_request - mapping and mount request for EHD
145
 
 * @mountpoint: where to mount EHD
146
 
 * @fs_cipher:  cipher used for filesystem (cryptsetup name)
147
 
 * @fs_hash:    hash used for filesystem (cryptsetup name)
148
 
 * @container:  path to disk image
149
 
 * @key_data:   key material
150
 
 * @key_size:   size of key data, in bytes
151
 
 * @trunc_keysize:      extra cryptsetup instruction for truncation (in bytes)
152
 
 * @readonly:   create readonly mount?
153
 
 */
154
 
struct ehd_mtreq {
155
 
        const char *mountpoint;
156
 
        const char *fs_cipher, *fs_hash, *container;
157
 
        const void *key_data;
158
 
        unsigned int key_size, trunc_keysize;
159
 
        bool readonly;
160
 
};
161
 
 
162
 
/**
163
 
 * struct ehd_mount - EHD mount info
164
 
 * @container:          path to disk image
165
 
 * @lower_device:       link to either @container if a block device,
166
 
 *                      otherwise points to @loop_device.
167
 
 * @loop_device:        loop device that was created, if any
168
 
 * @crypto_name:        crypto device that was created (basename only)
169
 
 * @crypto_device:      full path to the crypto device
170
 
 */
171
 
struct ehd_mount {
172
 
        char *container;
173
 
        const char *lower_device;
174
 
        char *loop_device;
175
 
        hxmc_t *crypto_name;
176
 
        hxmc_t *crypto_device;
177
 
};
178
 
 
179
 
struct ehd_crypto_ops {
180
 
        int (*load)(const struct ehd_mtreq *, struct ehd_mount *);
181
 
        int (*unload)(const struct ehd_mount *);
182
 
};
183
 
 
184
 
typedef int (mount_op_fn_t)(const struct config *, struct vol *,
185
 
        struct HXformat_map *, const char *);
186
 
 
187
 
/*
188
 
 *
189
 
 */
190
 
static inline void format_add(struct HXformat_map *table, const char *key,
191
 
    const char *value)
192
 
{
193
 
        if (value == NULL)
194
 
                HXformat_add(table, key, "", HXTYPE_STRING);
195
 
        else
196
 
                HXformat_add(table, key, value, HXTYPE_STRING | HXFORMAT_IMMED);
197
 
}
198
 
 
199
 
static inline const char *znul(const char *s)
200
 
{
201
 
        return (s == NULL) ? "(null)" : s;
202
 
}
203
 
 
204
 
/*
205
 
 *      CRYPTO.C
206
 
 */
207
 
extern int ehd_load(const struct ehd_mtreq *, struct ehd_mount *);
208
 
extern int ehd_unload(const struct ehd_mount *);
209
 
extern void ehd_mtfree(struct ehd_mount *);
210
 
extern hxmc_t *ehd_decrypt_key(const char *, const char *, const char *,
211
 
        hxmc_t *);
212
 
extern unsigned int cipher_digest_security(const char *);
213
 
extern hxmc_t *pmt_get_password(const char *);
214
 
 
215
 
/*
216
 
 *      CRYPTO-*.C
217
 
 */
218
 
extern const struct ehd_crypto_ops ehd_cgd_ops;
219
 
extern const struct ehd_crypto_ops ehd_dmcrypt_ops;
220
 
 
221
 
extern int dmc_is_luks(const char *, bool);
222
 
 
223
 
/*
224
 
 *      LOOP.C
225
 
 */
226
 
extern size_t pmt_block_getsize64(const char *);
227
 
extern int pmt_loop_setup(const char *, char **, bool);
228
 
extern int pmt_loop_release(const char *);
229
 
 
230
 
/*
231
 
 *      LOG.C
232
 
 */
233
 
extern const char *pmtlog_prefix;
234
 
extern bool pmtlog_path[PMTLOG_SRCMAX][PMTLOG_DSTMAX];
235
 
 
236
 
extern int misc_log(const char *, ...);
237
 
extern int misc_warn(const char *, ...);
238
 
 
239
 
/*
240
 
 *      MISC.C
241
 
 */
242
 
extern void arglist_add(struct HXdeque *, const char *,
243
 
        const struct HXformat_map *);
244
 
extern struct HXdeque *arglist_build(const struct HXdeque *,
245
 
        const struct HXformat_map *);
246
 
extern void arglist_log(const struct HXdeque *);
247
 
extern void arglist_llog(const char *const *);
248
 
extern bool kvplist_contains(const struct HXclist_head *, const char *);
249
 
extern char *kvplist_get(const struct HXclist_head *, const char *);
250
 
extern void kvplist_genocide(struct HXclist_head *);
251
 
extern hxmc_t *kvplist_to_str(const struct HXclist_head *);
252
 
extern void misc_add_ntdom(struct HXformat_map *, const char *);
253
 
extern void misc_dump_id(const char *);
254
 
extern int pmt_fileop_exists(const char *);
255
 
extern int pmt_fileop_owns(const char *, const char *);
256
 
extern char *relookup_user(const char *);
257
 
extern long str_to_long(const char *);
258
 
extern void *xmalloc(size_t);
259
 
extern void *xrealloc(void *, size_t);
260
 
extern char *xstrdup(const char *);
261
 
 
262
 
/*
263
 
 *      MTAB.C
264
 
 */
265
 
/* Enum constants must match order of /etc/mtab and /etc/cmtab, respectively. */
266
 
enum smtab_field {
267
 
        SMTABF_CONTAINER = 0,
268
 
        SMTABF_MOUNTPOINT,
269
 
        __SMTABF_MAX,
270
 
};
271
 
 
272
 
enum cmtab_field {
273
 
        CMTABF_MOUNTPOINT = 0,
274
 
        CMTABF_CONTAINER,
275
 
        CMTABF_LOOP_DEV,
276
 
        CMTABF_CRYPTO_DEV,
277
 
        __CMTABF_MAX,
278
 
};
279
 
 
280
 
extern int pmt_smtab_add(const char *, const char *,
281
 
        const char *, const char *);
282
 
extern int pmt_smtab_remove(const char *, enum smtab_field);
283
 
extern int pmt_smtab_mounted(const char *, const char *,
284
 
        int (*)(const char *, const char *));
285
 
extern int pmt_cmtab_add(const char *, const char *,
286
 
        const char *, const char *);
287
 
extern int pmt_cmtab_get(const char *, enum cmtab_field,
288
 
        char **, char **, char **, char **);
289
 
extern int pmt_cmtab_remove(const char *, enum cmtab_field);
290
 
extern int pmt_cmtab_mounted(const char *, const char *);
291
 
 
292
 
/*
293
 
 *      MOUNT.C
294
 
 */
295
 
extern mount_op_fn_t do_mount, do_unmount;
296
 
extern int fstype_nodev(const char *);
297
 
extern int mount_op(mount_op_fn_t *, const struct config *, struct vol *,
298
 
        const char *);
299
 
extern void umount_final(struct config *);
300
 
extern int pmt_already_mounted(const struct config *,
301
 
        const struct vol *, struct HXformat_map *);
302
 
extern hxmc_t *pmt_vol_to_dev(const struct vol *);
303
 
extern bool fstype_icase(const char *);
304
 
extern bool fstype2_icase(enum command_type);
305
 
 
306
 
/*
307
 
 *      OFL-LIB.C
308
 
 */
309
 
extern int (*ofl_printf)(const char *, ...);
310
 
extern bool ofl(const char *, unsigned int);
311
 
 
312
 
/*
313
 
 *      PAM_MOUNT.C
314
 
 */
315
 
#ifndef HAVE_VISIBILITY_HIDDEN
316
 
        /* Workaround Xserver issue */
317
 
#       define Debug pmt_debug
318
 
#endif
319
 
extern unsigned int Debug;
320
 
extern struct config Config;
321
 
 
322
 
/*
323
 
 *      RDCONF1.C
324
 
 */
325
 
extern bool expandconfig(const struct config *);
326
 
extern void initconfig(struct config *);
327
 
extern bool readconfig(const char *, bool, struct config *);
328
 
extern void freeconfig(struct config *);
329
 
 
330
 
/*
331
 
 *      RDCONF2.C
332
 
 */
333
 
extern bool luserconf_volume_record_sane(const struct config *, const struct vol *);
334
 
extern bool volume_record_sane(const struct config *, const struct vol *);
335
 
 
336
 
/*
337
 
 *      SPAWN.C
338
 
 */
339
 
extern const struct HXproc_ops pmt_spawn_ops, pmt_dropprivs_ops;
340
 
 
341
 
extern int pmt_spawn_dq(struct HXdeque *, struct HXproc *);
342
 
 
343
 
#endif /* PMT_PAM_MOUNT_H */