auth-options.h revision 1.14 1 1.12 christos /* $NetBSD: auth-options.h,v 1.14 2020/12/04 18:42:49 christos Exp $ */
2 1.14 christos /* $OpenBSD: auth-options.h,v 1.30 2020/08/27 01:07:09 djm Exp $ */
3 1.1 christos
4 1.1 christos /*
5 1.10 christos * Copyright (c) 2018 Damien Miller <djm (at) mindrot.org>
6 1.1 christos *
7 1.10 christos * Permission to use, copy, modify, and distribute this software for any
8 1.10 christos * purpose with or without fee is hereby granted, provided that the above
9 1.10 christos * copyright notice and this permission notice appear in all copies.
10 1.10 christos *
11 1.10 christos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 1.10 christos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 1.10 christos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 1.10 christos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 1.10 christos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 1.10 christos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 1.10 christos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 1.1 christos */
19 1.1 christos
20 1.1 christos #ifndef AUTH_OPTIONS_H
21 1.1 christos #define AUTH_OPTIONS_H
22 1.1 christos
23 1.10 christos struct passwd;
24 1.10 christos struct sshkey;
25 1.10 christos
26 1.12 christos /* Maximum number of permitopen/permitlisten directives to accept */
27 1.12 christos #define SSH_AUTHOPT_PERMIT_MAX 4096
28 1.12 christos
29 1.10 christos /*
30 1.10 christos * sshauthopt represents key options parsed from authorized_keys or
31 1.10 christos * from certificate extensions/options.
32 1.10 christos */
33 1.10 christos struct sshauthopt {
34 1.10 christos /* Feature flags */
35 1.10 christos int permit_port_forwarding_flag;
36 1.10 christos int permit_agent_forwarding_flag;
37 1.10 christos int permit_x11_forwarding_flag;
38 1.10 christos int permit_pty_flag;
39 1.10 christos int permit_user_rc;
40 1.10 christos
41 1.10 christos /* "restrict" keyword was invoked */
42 1.10 christos int restricted;
43 1.10 christos
44 1.10 christos /* key/principal expiry date */
45 1.10 christos uint64_t valid_before;
46 1.10 christos
47 1.10 christos /* Certificate-related options */
48 1.10 christos int cert_authority;
49 1.10 christos char *cert_principals;
50 1.10 christos
51 1.10 christos int force_tun_device;
52 1.10 christos char *force_command;
53 1.10 christos
54 1.10 christos /* Custom environment */
55 1.10 christos size_t nenv;
56 1.10 christos char **env;
57 1.10 christos
58 1.10 christos /* Permitted port forwardings */
59 1.10 christos size_t npermitopen;
60 1.10 christos char **permitopen;
61 1.10 christos
62 1.11 christos /* Permitted listens (remote forwarding) */
63 1.11 christos size_t npermitlisten;
64 1.11 christos char **permitlisten;
65 1.11 christos
66 1.10 christos /*
67 1.10 christos * Permitted host/addresses (comma-separated)
68 1.10 christos * Caller must check source address matches both lists (if present).
69 1.10 christos */
70 1.10 christos char *required_from_host_cert;
71 1.10 christos char *required_from_host_keys;
72 1.13 christos
73 1.13 christos /* Key requires user presence asserted */
74 1.13 christos int no_require_user_presence;
75 1.14 christos /* Key requires user verification (e.g. PIN) */
76 1.14 christos int require_verify;
77 1.1 christos };
78 1.1 christos
79 1.10 christos struct sshauthopt *sshauthopt_new(void);
80 1.10 christos struct sshauthopt *sshauthopt_new_with_keys_defaults(void);
81 1.10 christos void sshauthopt_free(struct sshauthopt *opts);
82 1.10 christos struct sshauthopt *sshauthopt_copy(const struct sshauthopt *orig);
83 1.10 christos int sshauthopt_serialise(const struct sshauthopt *opts, struct sshbuf *m, int);
84 1.10 christos int sshauthopt_deserialise(struct sshbuf *m, struct sshauthopt **opts);
85 1.10 christos
86 1.10 christos /*
87 1.10 christos * Parse authorized_keys options. Returns an options structure on success
88 1.10 christos * or NULL on failure. Will set errstr on failure.
89 1.10 christos */
90 1.10 christos struct sshauthopt *sshauthopt_parse(const char *s, const char **errstr);
91 1.10 christos
92 1.10 christos /*
93 1.10 christos * Parse certification options to a struct sshauthopt.
94 1.10 christos * Returns options on success or NULL on failure.
95 1.10 christos */
96 1.10 christos struct sshauthopt *sshauthopt_from_cert(struct sshkey *k);
97 1.10 christos
98 1.10 christos /*
99 1.10 christos * Merge key options.
100 1.10 christos */
101 1.10 christos struct sshauthopt *sshauthopt_merge(const struct sshauthopt *primary,
102 1.10 christos const struct sshauthopt *additional, const char **errstrp);
103 1.1 christos
104 1.1 christos #endif
105