auth-options.h revision 1.15 1 1.12 christos /* $NetBSD: auth-options.h,v 1.15 2021/09/02 11:26:17 christos Exp $ */
2 1.15 christos /* $OpenBSD: auth-options.h,v 1.31 2021/07/23 03:57:20 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.15 christos #define SSH_AUTHOPT_PERMIT_MAX 4096
28 1.15 christos
29 1.15 christos /* Maximum number of environment directives to accept */
30 1.15 christos #define SSH_AUTHOPT_ENV_MAX 1024
31 1.12 christos
32 1.10 christos /*
33 1.10 christos * sshauthopt represents key options parsed from authorized_keys or
34 1.10 christos * from certificate extensions/options.
35 1.10 christos */
36 1.10 christos struct sshauthopt {
37 1.10 christos /* Feature flags */
38 1.10 christos int permit_port_forwarding_flag;
39 1.10 christos int permit_agent_forwarding_flag;
40 1.10 christos int permit_x11_forwarding_flag;
41 1.10 christos int permit_pty_flag;
42 1.10 christos int permit_user_rc;
43 1.10 christos
44 1.10 christos /* "restrict" keyword was invoked */
45 1.10 christos int restricted;
46 1.10 christos
47 1.10 christos /* key/principal expiry date */
48 1.10 christos uint64_t valid_before;
49 1.10 christos
50 1.10 christos /* Certificate-related options */
51 1.10 christos int cert_authority;
52 1.10 christos char *cert_principals;
53 1.10 christos
54 1.10 christos int force_tun_device;
55 1.10 christos char *force_command;
56 1.10 christos
57 1.10 christos /* Custom environment */
58 1.10 christos size_t nenv;
59 1.10 christos char **env;
60 1.10 christos
61 1.10 christos /* Permitted port forwardings */
62 1.10 christos size_t npermitopen;
63 1.10 christos char **permitopen;
64 1.10 christos
65 1.11 christos /* Permitted listens (remote forwarding) */
66 1.11 christos size_t npermitlisten;
67 1.11 christos char **permitlisten;
68 1.11 christos
69 1.10 christos /*
70 1.10 christos * Permitted host/addresses (comma-separated)
71 1.10 christos * Caller must check source address matches both lists (if present).
72 1.10 christos */
73 1.10 christos char *required_from_host_cert;
74 1.10 christos char *required_from_host_keys;
75 1.13 christos
76 1.13 christos /* Key requires user presence asserted */
77 1.13 christos int no_require_user_presence;
78 1.14 christos /* Key requires user verification (e.g. PIN) */
79 1.14 christos int require_verify;
80 1.1 christos };
81 1.1 christos
82 1.10 christos struct sshauthopt *sshauthopt_new(void);
83 1.10 christos struct sshauthopt *sshauthopt_new_with_keys_defaults(void);
84 1.10 christos void sshauthopt_free(struct sshauthopt *opts);
85 1.10 christos struct sshauthopt *sshauthopt_copy(const struct sshauthopt *orig);
86 1.10 christos int sshauthopt_serialise(const struct sshauthopt *opts, struct sshbuf *m, int);
87 1.10 christos int sshauthopt_deserialise(struct sshbuf *m, struct sshauthopt **opts);
88 1.10 christos
89 1.10 christos /*
90 1.10 christos * Parse authorized_keys options. Returns an options structure on success
91 1.10 christos * or NULL on failure. Will set errstr on failure.
92 1.10 christos */
93 1.10 christos struct sshauthopt *sshauthopt_parse(const char *s, const char **errstr);
94 1.10 christos
95 1.10 christos /*
96 1.10 christos * Parse certification options to a struct sshauthopt.
97 1.10 christos * Returns options on success or NULL on failure.
98 1.10 christos */
99 1.10 christos struct sshauthopt *sshauthopt_from_cert(struct sshkey *k);
100 1.10 christos
101 1.10 christos /*
102 1.10 christos * Merge key options.
103 1.10 christos */
104 1.10 christos struct sshauthopt *sshauthopt_merge(const struct sshauthopt *primary,
105 1.10 christos const struct sshauthopt *additional, const char **errstrp);
106 1.1 christos
107 1.1 christos #endif
108