Home | History | Annotate | Line # | Download | only in dist
auth-options.h revision 1.10
      1   1.4  christos /*	$NetBSD: auth-options.h,v 1.10 2018/04/06 18:58:59 christos Exp $	*/
      2  1.10  christos /* $OpenBSD: auth-options.h,v 1.26 2018/03/12 00:52:01 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.10  christos 	/*
     60  1.10  christos 	 * Permitted host/addresses (comma-separated)
     61  1.10  christos 	 * Caller must check source address matches both lists (if present).
     62  1.10  christos 	 */
     63  1.10  christos 	char *required_from_host_cert;
     64  1.10  christos 	char *required_from_host_keys;
     65   1.1  christos };
     66   1.1  christos 
     67  1.10  christos struct sshauthopt *sshauthopt_new(void);
     68  1.10  christos struct sshauthopt *sshauthopt_new_with_keys_defaults(void);
     69  1.10  christos void sshauthopt_free(struct sshauthopt *opts);
     70  1.10  christos struct sshauthopt *sshauthopt_copy(const struct sshauthopt *orig);
     71  1.10  christos int sshauthopt_serialise(const struct sshauthopt *opts, struct sshbuf *m, int);
     72  1.10  christos int sshauthopt_deserialise(struct sshbuf *m, struct sshauthopt **opts);
     73  1.10  christos 
     74  1.10  christos /*
     75  1.10  christos  * Parse authorized_keys options. Returns an options structure on success
     76  1.10  christos  * or NULL on failure. Will set errstr on failure.
     77  1.10  christos  */
     78  1.10  christos struct sshauthopt *sshauthopt_parse(const char *s, const char **errstr);
     79  1.10  christos 
     80  1.10  christos /*
     81  1.10  christos  * Parse certification options to a struct sshauthopt.
     82  1.10  christos  * Returns options on success or NULL on failure.
     83  1.10  christos  */
     84  1.10  christos struct sshauthopt *sshauthopt_from_cert(struct sshkey *k);
     85  1.10  christos 
     86  1.10  christos /*
     87  1.10  christos  * Merge key options.
     88  1.10  christos  */
     89  1.10  christos struct sshauthopt *sshauthopt_merge(const struct sshauthopt *primary,
     90  1.10  christos     const struct sshauthopt *additional, const char **errstrp);
     91   1.1  christos 
     92   1.1  christos #endif
     93