chiark / gitweb /
gnupg2 (2.1.17-3) unstable; urgency=medium
[gnupg2.git] / g13 / g13-syshelp.h
1 /* g130syshelp.h - Global definitions for G13-SYSHELP.
2  * Copyright (C) 2015 Werner Koch
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GnuPG is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef G13_SYSHELP_H
21 #define G13_SYSHELP_H
22
23 #include "g13-common.h"
24 #include "g13tuple.h"
25
26 struct tab_item_s;
27 typedef struct tab_item_s *tab_item_t;
28
29 struct tab_item_s
30 {
31   tab_item_t next;
32   char *label;       /* Optional malloced label for that entry.  */
33   char *mountpoint;  /* NULL or a malloced mountpoint.  */
34   char blockdev[1];  /* String with the name of the block device.  If
35                         it starts with a slash is is a regular device
36                         name, otherwise it is a PARTUUID.  */
37 };
38
39
40
41 /* Forward declaration for an object defined in g13-sh-cmd.c.  */
42 struct server_local_s;
43
44 /* Session control object.  This object is passed down to most
45    functions.  The default values for it are set by
46    g13_syshelp_init_default_ctrl(). */
47 struct server_control_s
48 {
49   int no_server;      /* We are not running under server control */
50   int  status_fd;     /* Only for non-server mode */
51   struct server_local_s *server_local;
52
53   struct {
54     uid_t uid;     /* UID of the client calling use.  */
55     char *uname;
56     tab_item_t tab;/* Linked list with the g13tab items for this user.  */
57   } client;
58
59   /* Flag indicating that we should fail all commands.  */
60   int fail_all_cmds;
61
62   /* Type of the current container.  See the CONTTYPE_ constants.  */
63   int conttype;
64
65   /* A pointer into client.tab with the selected tab line or NULL. */
66   tab_item_t devti;
67 };
68
69
70 /*-- g13-syshelp.c --*/
71 void g13_syshelp_init_default_ctrl (struct server_control_s *ctrl);
72 void g13_syshelp_i_know_what_i_am_doing (void);
73
74 /*-- sh-cmd.c --*/
75 gpg_error_t syshelp_server (ctrl_t ctrl);
76 gpg_error_t sh_encrypt_keyblob (ctrl_t ctrl,
77                                 const void *keyblob, size_t keybloblen,
78                                 char **r_enckeyblob, size_t *r_enckeybloblen);
79
80 /*-- sh-blockdev.c --*/
81 gpg_error_t sh_blockdev_getsz (const char *name, unsigned long long *r_nblocks);
82 gpg_error_t sh_is_empty_partition (const char *name);
83
84 /*-- sh-dmcrypt.c --*/
85 gpg_error_t sh_dmcrypt_create_container (ctrl_t ctrl, const char *devname,
86                                          estream_t devfp);
87 gpg_error_t sh_dmcrypt_mount_container (ctrl_t ctrl, const char *devname,
88                                         tupledesc_t keyblob);
89 gpg_error_t sh_dmcrypt_umount_container (ctrl_t ctrl, const char *devname);
90 gpg_error_t sh_dmcrypt_suspend_container (ctrl_t ctrl, const char *devname);
91 gpg_error_t sh_dmcrypt_resume_container (ctrl_t ctrl, const char *devname,
92                                          tupledesc_t keyblob);
93
94
95
96 #endif /*G13_SYSHELP_H*/