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