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