auth-options.h revision 1.11 1 1.4 christos /* $NetBSD: auth-options.h,v 1.11 2018/08/26 07:46:36 christos Exp $ */
2 1.11 christos /* $OpenBSD: auth-options.h,v 1.27 2018/06/06 18:23:32 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.10 christos /*
27 1.10 christos * sshauthopt represents key options parsed from authorized_keys or
28 1.10 christos * from certificate extensions/options.
29 1.10 christos */
30 1.10 christos struct sshauthopt {
31 1.10 christos /* Feature flags */
32 1.10 christos int permit_port_forwarding_flag;
33 1.10 christos int permit_agent_forwarding_flag;
34 1.10 christos int permit_x11_forwarding_flag;
35 1.10 christos int permit_pty_flag;
36 1.10 christos int permit_user_rc;
37 1.10 christos
38 1.10 christos /* "restrict" keyword was invoked */
39 1.10 christos int restricted;
40 1.10 christos
41 1.10 christos /* key/principal expiry date */
42 1.10 christos uint64_t valid_before;
43 1.10 christos
44 1.10 christos /* Certificate-related options */
45 1.10 christos int cert_authority;
46 1.10 christos char *cert_principals;
47 1.10 christos
48 1.10 christos int force_tun_device;
49 1.10 christos char *force_command;
50 1.10 christos
51 1.10 christos /* Custom environment */
52 1.10 christos size_t nenv;
53 1.10 christos char **env;
54 1.10 christos
55 1.10 christos /* Permitted port forwardings */
56 1.10 christos size_t npermitopen;
57 1.10 christos char **permitopen;
58 1.10 christos
59 1.11 christos /* Permitted listens (remote forwarding) */
60 1.11 christos size_t npermitlisten;
61 1.11 christos char **permitlisten;
62 1.11 christos
63 1.10 christos /*
64 1.10 christos * Permitted host/addresses (comma-separated)
65 1.10 christos * Caller must check source address matches both lists (if present).
66 1.10 christos */
67 1.10 christos char *required_from_host_cert;
68 1.10 christos char *required_from_host_keys;
69 1.1 christos };
70 1.1 christos
71 1.10 christos struct sshauthopt *sshauthopt_new(void);
72 1.10 christos struct sshauthopt *sshauthopt_new_with_keys_defaults(void);
73 1.10 christos void sshauthopt_free(struct sshauthopt *opts);
74 1.10 christos struct sshauthopt *sshauthopt_copy(const struct sshauthopt *orig);
75 1.10 christos int sshauthopt_serialise(const struct sshauthopt *opts, struct sshbuf *m, int);
76 1.10 christos int sshauthopt_deserialise(struct sshbuf *m, struct sshauthopt **opts);
77 1.10 christos
78 1.10 christos /*
79 1.10 christos * Parse authorized_keys options. Returns an options structure on success
80 1.10 christos * or NULL on failure. Will set errstr on failure.
81 1.10 christos */
82 1.10 christos struct sshauthopt *sshauthopt_parse(const char *s, const char **errstr);
83 1.10 christos
84 1.10 christos /*
85 1.10 christos * Parse certification options to a struct sshauthopt.
86 1.10 christos * Returns options on success or NULL on failure.
87 1.10 christos */
88 1.10 christos struct sshauthopt *sshauthopt_from_cert(struct sshkey *k);
89 1.10 christos
90 1.10 christos /*
91 1.10 christos * Merge key options.
92 1.10 christos */
93 1.10 christos struct sshauthopt *sshauthopt_merge(const struct sshauthopt *primary,
94 1.10 christos const struct sshauthopt *additional, const char **errstrp);
95 1.1 christos
96 1.1 christos #endif
97