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