xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.sbin/in.ftpd/gssutil.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*0Sstevel@tonic-gate  * Use is subject to license terms.
4*0Sstevel@tonic-gate  */
5*0Sstevel@tonic-gate 
6*0Sstevel@tonic-gate #ifndef _GSSUTIL_H
7*0Sstevel@tonic-gate #define	_GSSUTIL_H
8*0Sstevel@tonic-gate 
9*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
10*0Sstevel@tonic-gate 
11*0Sstevel@tonic-gate #ifdef __cplusplus
12*0Sstevel@tonic-gate extern "C" {
13*0Sstevel@tonic-gate #endif
14*0Sstevel@tonic-gate 
15*0Sstevel@tonic-gate #include <gssapi/gssapi.h>
16*0Sstevel@tonic-gate #ifdef SOLARIS_2
17*0Sstevel@tonic-gate #include <gssapi/gssapi_ext.h>
18*0Sstevel@tonic-gate #else
19*0Sstevel@tonic-gate #include <gssapi/gssapi_generic.h>
20*0Sstevel@tonic-gate #endif
21*0Sstevel@tonic-gate 
22*0Sstevel@tonic-gate #ifndef SOLARIS_2
23*0Sstevel@tonic-gate #define	GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
24*0Sstevel@tonic-gate #endif
25*0Sstevel@tonic-gate 
26*0Sstevel@tonic-gate #ifndef g_OID_equal
27*0Sstevel@tonic-gate #define	g_OID_equal(o1, o2) \
28*0Sstevel@tonic-gate 	(((o1)->length == (o2)->length) && \
29*0Sstevel@tonic-gate 	(memcmp((o1)->elements, (o2)->elements, (int)(o1)->length) == 0))
30*0Sstevel@tonic-gate #endif /* g_OID_equal */
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #define	GSS_AUTH_NONE 0x00
33*0Sstevel@tonic-gate #define	GSS_ADAT_DONE 0x01
34*0Sstevel@tonic-gate #define	GSS_USER_DONE 0x02
35*0Sstevel@tonic-gate #define	GSS_PWD_DONE  0x04
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate typedef struct gss_inforec {
38*0Sstevel@tonic-gate 	gss_ctx_id_t	context;
39*0Sstevel@tonic-gate 	gss_OID		mechoid;
40*0Sstevel@tonic-gate 	gss_name_t	client;
41*0Sstevel@tonic-gate 	char		*display_name;
42*0Sstevel@tonic-gate 	unsigned char	data_prot;
43*0Sstevel@tonic-gate 	unsigned char	ctrl_prot;
44*0Sstevel@tonic-gate 	unsigned char	authstate;
45*0Sstevel@tonic-gate 	unsigned char	want_creds;
46*0Sstevel@tonic-gate 	unsigned char	have_creds;
47*0Sstevel@tonic-gate 	unsigned char	must_gss_auth;
48*0Sstevel@tonic-gate } gss_info_t;
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate #define	GSSUSERAUTH_OK(x) (((x).authstate & (GSS_ADAT_DONE|GSS_USER_DONE)) \
51*0Sstevel@tonic-gate == (GSS_ADAT_DONE|GSS_USER_DONE))
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate #define	IS_GSSAUTH(s) ((s) != NULL && (strcmp((s), "GSSAPI") == 0))
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate int gss_user(struct passwd *);
56*0Sstevel@tonic-gate int gss_adat(char *adatstr);
57*0Sstevel@tonic-gate unsigned int gss_setpbsz(char *pbszstr);
58*0Sstevel@tonic-gate int sec_write(int fd, char *buf, int len);
59*0Sstevel@tonic-gate void ccc(void);
60*0Sstevel@tonic-gate int sec_putc(int c, FILE *stream);
61*0Sstevel@tonic-gate int sec_getc(FILE *stream);
62*0Sstevel@tonic-gate int sec_fprintf(FILE *stream, char *fmt, ...);
63*0Sstevel@tonic-gate int sec_fflush(FILE *stream);
64*0Sstevel@tonic-gate int sec_read(int fd, char *buf, int maxlen);
65*0Sstevel@tonic-gate int sec_reply(char *buf, int bufsiz, int n);
66*0Sstevel@tonic-gate char *sec_decode_command(char *cmd);
67*0Sstevel@tonic-gate size_t gss_getinbufsz(void);
68*0Sstevel@tonic-gate void gss_adjust_buflen(void);
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate #ifdef __cplusplus
71*0Sstevel@tonic-gate }
72*0Sstevel@tonic-gate #endif
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate #endif /* _GSSUTIL_H */
75