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