1*ebfedea0SLionel Sambuc.\" $NetBSD: libsaslc.3,v 1.15 2013/05/14 15:33:21 elric Exp $ 2*ebfedea0SLionel Sambuc.\" 3*ebfedea0SLionel Sambuc.\" Copyright (c) 2010 The NetBSD Foundation, Inc. 4*ebfedea0SLionel Sambuc.\" All rights reserved. 5*ebfedea0SLionel Sambuc.\" 6*ebfedea0SLionel Sambuc.\" This code is derived from software contributed to The NetBSD Foundation 7*ebfedea0SLionel Sambuc.\" by Mateusz Kocielski. 8*ebfedea0SLionel Sambuc.\" 9*ebfedea0SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without 10*ebfedea0SLionel Sambuc.\" modification, are permitted provided that the following conditions 11*ebfedea0SLionel Sambuc.\" are met: 12*ebfedea0SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright 13*ebfedea0SLionel Sambuc.\" notice, this list of conditions and the following disclaimer. 14*ebfedea0SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright 15*ebfedea0SLionel Sambuc.\" notice, this list of conditions and the following disclaimer in the 16*ebfedea0SLionel Sambuc.\" documentation and/or other materials provided with the distribution. 17*ebfedea0SLionel Sambuc.\" 3. All advertising materials mentioning features or use of this software 18*ebfedea0SLionel Sambuc.\" must display the following acknowledgement: 19*ebfedea0SLionel Sambuc.\" This product includes software developed by the NetBSD 20*ebfedea0SLionel Sambuc.\" Foundation, Inc. and its contributors. 21*ebfedea0SLionel Sambuc.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22*ebfedea0SLionel Sambuc.\" contributors may be used to endorse or promote products derived 23*ebfedea0SLionel Sambuc.\" from this software without specific prior written permission. 24*ebfedea0SLionel Sambuc.\" 25*ebfedea0SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26*ebfedea0SLionel Sambuc.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27*ebfedea0SLionel Sambuc.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28*ebfedea0SLionel Sambuc.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29*ebfedea0SLionel Sambuc.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30*ebfedea0SLionel Sambuc.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31*ebfedea0SLionel Sambuc.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32*ebfedea0SLionel Sambuc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33*ebfedea0SLionel Sambuc.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34*ebfedea0SLionel Sambuc.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35*ebfedea0SLionel Sambuc.\" POSSIBILITY OF SUCH DAMAGE. 36*ebfedea0SLionel Sambuc.\" 37*ebfedea0SLionel Sambuc.Dd September 23, 2011 38*ebfedea0SLionel Sambuc.Dt LIBSASLC 3 39*ebfedea0SLionel Sambuc.Os 40*ebfedea0SLionel Sambuc.Sh NAME 41*ebfedea0SLionel Sambuc.Nm libsaslc , 42*ebfedea0SLionel Sambuc.Nm saslc.d , 43*ebfedea0SLionel Sambuc.Nm saslc_alloc , 44*ebfedea0SLionel Sambuc.Nm saslc_end , 45*ebfedea0SLionel Sambuc.Nm saslc_init , 46*ebfedea0SLionel Sambuc.Nm saslc_sess_init , 47*ebfedea0SLionel Sambuc.Nm saslc_sess_end , 48*ebfedea0SLionel Sambuc.Nm saslc_sess_getprop , 49*ebfedea0SLionel Sambuc.Nm saslc_sess_setprop , 50*ebfedea0SLionel Sambuc.Nm saslc_sess_cont , 51*ebfedea0SLionel Sambuc.Nm saslc_sess_decode , 52*ebfedea0SLionel Sambuc.Nm saslc_sess_encode , 53*ebfedea0SLionel Sambuc.Nm saslc_sess_getmech , 54*ebfedea0SLionel Sambuc.Nm saslc_sess_strerror , 55*ebfedea0SLionel Sambuc.Nm saslc_strerror 56*ebfedea0SLionel Sambuc.Nd Simple Authentication and Security Layer client library 57*ebfedea0SLionel Sambuc.Sh LIBRARY 58*ebfedea0SLionel Sambuc.Lb libsaslc 59*ebfedea0SLionel Sambuc.Sh SYNOPSIS 60*ebfedea0SLionel Sambuc.In saslc.h 61*ebfedea0SLionel Sambuc.Ft saslc_t * 62*ebfedea0SLionel Sambuc.Fn saslc_alloc "void" 63*ebfedea0SLionel Sambuc.Ft int 64*ebfedea0SLionel Sambuc.Fn saslc_end "saslc_t *ctx" 65*ebfedea0SLionel Sambuc.Ft int 66*ebfedea0SLionel Sambuc.Fn saslc_init "saslc_t *ctx" "const char *appname" "const char *cfgpath" 67*ebfedea0SLionel Sambuc.Ft saslc_sess_t * 68*ebfedea0SLionel Sambuc.Fn saslc_sess_init "saslc_t *ctx" "const char *mechs" "const char *secopts" 69*ebfedea0SLionel Sambuc.Ft void 70*ebfedea0SLionel Sambuc.Fn saslc_sess_end "saslc_sess_t *sess" 71*ebfedea0SLionel Sambuc.Ft const char * 72*ebfedea0SLionel Sambuc.Fn saslc_sess_getprop "saslc_sess_t *sess" "const char *key" 73*ebfedea0SLionel Sambuc.Ft int 74*ebfedea0SLionel Sambuc.Fn saslc_sess_setprop "saslc_sess_t *sess" "const char *key" \ 75*ebfedea0SLionel Sambuc"const char *value" 76*ebfedea0SLionel Sambuc.Ft int 77*ebfedea0SLionel Sambuc.Fn saslc_sess_cont "saslc_sess_t *sess" "const void *in" "size_t inlen" \ 78*ebfedea0SLionel Sambuc"void* *out" "size_t *outlen" 79*ebfedea0SLionel Sambuc.Ft ssize_t 80*ebfedea0SLionel Sambuc.Fn saslc_sess_decode "saslc_sess_t *sess" "const void *in" "size_t inlen" \ 81*ebfedea0SLionel Sambuc"void* *out" "size_t *outlen" 82*ebfedea0SLionel Sambuc.Ft ssize_t 83*ebfedea0SLionel Sambuc.Fn saslc_sess_encode "saslc_sess_t *sess" "const void *in" "size_t inlen" \ 84*ebfedea0SLionel Sambuc"void* *out" "size_t *outlen" 85*ebfedea0SLionel Sambuc.Ft const char * 86*ebfedea0SLionel Sambuc.Fn saslc_sess_getmech "saslc_sess_t *sess" 87*ebfedea0SLionel Sambuc.Ft const char * 88*ebfedea0SLionel Sambuc.Fn saslc_sess_strerror "saslc_sess_t *sess" 89*ebfedea0SLionel Sambuc.Ft const char * 90*ebfedea0SLionel Sambuc.Fn saslc_strerror "saslc_t *ctx" 91*ebfedea0SLionel Sambuc.Sh DESCRIPTION 92*ebfedea0SLionel SambucThe 93*ebfedea0SLionel Sambuc.Nm libsaslc 94*ebfedea0SLionel Sambuclibrary offers a client interface for the 95*ebfedea0SLionel SambucSimple Authentication and Security Layer 96*ebfedea0SLionel Sambuc.Pq Tn SASL . 97*ebfedea0SLionel SambucThe library is heavily influenced by its use with 98*ebfedea0SLionel Sambuc.Xr postfix 1 . 99*ebfedea0SLionel Sambuc.Sh FUNCTIONS 100*ebfedea0SLionel SambucThe following functions are available in the library. 101*ebfedea0SLionel Sambuc.Bl -tag -width compact 102*ebfedea0SLionel Sambuc.It Fn saslc_alloc "" 103*ebfedea0SLionel SambucThe 104*ebfedea0SLionel Sambuc.Fn saslc_alloc 105*ebfedea0SLionel Sambucfunction allocates and returns a new saslc context. 106*ebfedea0SLionel SambucThe context is uninitialized: see 107*ebfedea0SLionel Sambuc.Fn saslc_init . 108*ebfedea0SLionel SambucReturns 109*ebfedea0SLionel Sambuc.Dv NULL 110*ebfedea0SLionel Sambucon error. 111*ebfedea0SLionel Sambuc.It Fn saslc_end "ctx" 112*ebfedea0SLionel SambucThe 113*ebfedea0SLionel Sambuc.Fn saslc_end 114*ebfedea0SLionel Sambucfunction destroys and deallocate resources used by the context 115*ebfedea0SLionel Sambuc.Ar ctx . 116*ebfedea0SLionel SambucThe context shouldn't have any sessions assigned to it. 117*ebfedea0SLionel SambucReturns 0 on success and \-1 if the context has active sessions and 118*ebfedea0SLionel Sambuccannot be deallocated. 119*ebfedea0SLionel Sambuc.It Fn saslc_init "ctx" "appname" "cfgpath" 120*ebfedea0SLionel SambucThe 121*ebfedea0SLionel Sambuc.Fn saslc_init 122*ebfedea0SLionel Sambucfunction initializes the saslc context 123*ebfedea0SLionel Sambuc.Ar ctx . 124*ebfedea0SLionel SambucBased on the application name 125*ebfedea0SLionel Sambuc.Ar appname , 126*ebfedea0SLionel Sambucit also parses the configuration files as indicated by 127*ebfedea0SLionel Sambuc.Ar cfgpath , 128*ebfedea0SLionel Sambucsets up the context and mechanism dictionaries, and creates mechanism 129*ebfedea0SLionel Sambuclist for the context. 130*ebfedea0SLionel SambucIf 131*ebfedea0SLionel Sambuc.Ar cfgpath 132*ebfedea0SLionel Sambucis 133*ebfedea0SLionel Sambuc.Dv NULL , 134*ebfedea0SLionel Sambucit checks the environment variable 135*ebfedea0SLionel Sambuc.Ev SASLC_CONFIG 136*ebfedea0SLionel Sambucfor a location and if that is not found it uses the default path 137*ebfedea0SLionel Sambuc.Pa /etc/saslc.d . 138*ebfedea0SLionel SambucReturns 0 on success and \-1 on failure. 139*ebfedea0SLionel Sambuc.It Fn saslc_sess_init "ctx" "mechs" "secopts" 140*ebfedea0SLionel SambucThe 141*ebfedea0SLionel Sambuc.Fn saslc_sess_init 142*ebfedea0SLionel Sambucfunction creates new session assigned to the 143*ebfedea0SLionel Sambuc.Ar ctx 144*ebfedea0SLionel Sambuccontext. 145*ebfedea0SLionel SambucThe function chooses the mechanism to use for authentication from the 146*ebfedea0SLionel Sambuc.Ar mechs 147*ebfedea0SLionel Sambuclist taking into account the requirements from the 148*ebfedea0SLionel Sambuc.Ar secopts 149*ebfedea0SLionel Sambuclist. 150*ebfedea0SLionel SambucBoth lists may be space or comma delimited. 151*ebfedea0SLionel SambucThe first matching mechanism from the 152*ebfedea0SLionel Sambuc.Ar mechs 153*ebfedea0SLionel Sambuclist is used. 154*ebfedea0SLionel SambucSee 155*ebfedea0SLionel Sambuc.Sx CONFIGURATION 156*ebfedea0SLionel Sambucbelow for the supported mechanisms. 157*ebfedea0SLionel SambucThe valid security options are 158*ebfedea0SLionel Sambuc.Pp 159*ebfedea0SLionel Sambuc.Bl -tag -width "nodictionaryxxx" -offset indent -compact 160*ebfedea0SLionel Sambuc.It Qo noanonymous Qc 161*ebfedea0SLionel Sambucreject anonymous mechanisms 162*ebfedea0SLionel Sambuc.It Qo noplaintext Qc 163*ebfedea0SLionel Sambucreject plaintext mechanisms 164*ebfedea0SLionel Sambuc.It Qo nodictionary Qc 165*ebfedea0SLionel Sambucreject mechanisms prone to dictionary attack 166*ebfedea0SLionel Sambuc.It Qo noactive Qc 167*ebfedea0SLionel Sambucreject mechanisms prone to active non-dictionary attacks 168*ebfedea0SLionel Sambuc.It Qo mutual Qc 169*ebfedea0SLionel Sambucrequire mutual authentication mechanisms 170*ebfedea0SLionel Sambuc.El 171*ebfedea0SLionel Sambuc.Pp 172*ebfedea0SLionel SambucUnknown security options are ignored. 173*ebfedea0SLionel SambucReturns a session handle or 174*ebfedea0SLionel Sambuc.Dv NULL 175*ebfedea0SLionel Sambucon error or no match. 176*ebfedea0SLionel Sambuc.It Fn saslc_sess_end "sess" 177*ebfedea0SLionel SambucThe 178*ebfedea0SLionel Sambuc.Fn saslc_sess_end 179*ebfedea0SLionel Sambucfunction ends the sasl session 180*ebfedea0SLionel Sambuc.Ar sess . 181*ebfedea0SLionel SambucIt destroys and deallocates all internal resources. 182*ebfedea0SLionel SambucThis does not fail. 183*ebfedea0SLionel Sambuc.It Fn saslc_sess_getprop "sess" "key" 184*ebfedea0SLionel SambucThe 185*ebfedea0SLionel Sambuc.Fn saslc_sess_getprop 186*ebfedea0SLionel Sambucfunction gets the property indicated by the 187*ebfedea0SLionel Sambuc.Ar key 188*ebfedea0SLionel Sambucfrom the saslc dictionaries. 189*ebfedea0SLionel SambucDictionaries are searched in following order: session 190*ebfedea0SLionel Sambuc.Ar sess 191*ebfedea0SLionel Sambucdictionary, 192*ebfedea0SLionel Sambuccontext dictionary (global configuration), and mechanism dictionary. 193*ebfedea0SLionel SambucReturns the property value or 194*ebfedea0SLionel Sambuc.Dv NULL 195*ebfedea0SLionel Sambucif the property is not found. 196*ebfedea0SLionel Sambuc.It Fn saslc_sess_setprop "sess" "key" "value" 197*ebfedea0SLionel SambucThe 198*ebfedea0SLionel Sambuc.Fn saslc_sess_setprop 199*ebfedea0SLionel Sambucfunction sets the property indexed by 200*ebfedea0SLionel Sambuc.Ar key 201*ebfedea0SLionel Sambucto the value 202*ebfedea0SLionel Sambuc.Ar value 203*ebfedea0SLionel Sambucin the session 204*ebfedea0SLionel Sambuc.Ar sess 205*ebfedea0SLionel Sambucdictionary. 206*ebfedea0SLionel SambucIf the property already exists in the session dictionary, then the 207*ebfedea0SLionel Sambucprevious value is replaced by the new value. 208*ebfedea0SLionel SambucIf 209*ebfedea0SLionel Sambuc.Ar value 210*ebfedea0SLionel Sambucis 211*ebfedea0SLionel Sambuc.Dv NULL , 212*ebfedea0SLionel Sambucthen any previous value in the session dictionary is removed. 213*ebfedea0SLionel SambucReturns 0 on success or \-1 on failure. 214*ebfedea0SLionel Sambuc.It Fn saslc_sess_cont "sess" "in" "inlen" "out" "outlen" 215*ebfedea0SLionel SambucThe 216*ebfedea0SLionel Sambuc.Fn saslc_sess_cont 217*ebfedea0SLionel Sambucfunction performs one step of the sasl authentication. 218*ebfedea0SLionel SambucIt reads 219*ebfedea0SLionel Sambuc.Ar inlen 220*ebfedea0SLionel Sambucbytes of input data 221*ebfedea0SLionel Sambuc.Pq from the server 222*ebfedea0SLionel Sambucfrom the 223*ebfedea0SLionel Sambuc.Ar in 224*ebfedea0SLionel Sambucbuffer and stores 225*ebfedea0SLionel Sambuc.Ar outlen 226*ebfedea0SLionel Sambucbytes of output data in 227*ebfedea0SLionel Sambuc.Ar out 228*ebfedea0SLionel Sambuc.Pq for the server . 229*ebfedea0SLionel SambucThe user is responsible for freeing memory allocated for 230*ebfedea0SLionel Sambuc.Ar out . 231*ebfedea0SLionel SambucIt returns 0 if the authentication process is completed, 1 if another 232*ebfedea0SLionel Sambucstep is required, and \-1 on error. 233*ebfedea0SLionel SambucNote that the completion of authentication process does not mean the 234*ebfedea0SLionel Sambucclient is authenticated; that is determined by the server. 235*ebfedea0SLionel Sambuc.It Fn saslc_sess_decode "sess" "in" "inlen" "out" "outlen" 236*ebfedea0SLionel SambucThe 237*ebfedea0SLionel Sambuc.Fn saslc_sess_encode 238*ebfedea0SLionel Sambucand 239*ebfedea0SLionel Sambuc.Fn saslc_sess_decode 240*ebfedea0SLionel Sambucfunctions are used to provide the integrity 241*ebfedea0SLionel Sambuc.Pq Qq auth-int 242*ebfedea0SLionel Sambucand confidentiality 243*ebfedea0SLionel Sambuc.Pq Qq auth-int 244*ebfedea0SLionel Sambuclayers for mechanisms that provide them. 245*ebfedea0SLionel SambucThey encode and, respectively, decode 246*ebfedea0SLionel Sambuc.Ar inlen 247*ebfedea0SLionel Sambucbytes of data from the 248*ebfedea0SLionel Sambuc.Ar in 249*ebfedea0SLionel Sambucbuffer using the method negotiated during authentication. 250*ebfedea0SLionel SambucOn error they return \-1. 251*ebfedea0SLionel SambucOtherwise, they return the number of bytes consumed from 252*ebfedea0SLionel Sambuc.Ar in 253*ebfedea0SLionel Sambucand output 254*ebfedea0SLionel Sambuc.Ar outlen 255*ebfedea0SLionel Sambucbytes of data in the 256*ebfedea0SLionel Sambuc.Ar out 257*ebfedea0SLionel Sambucbuffer. 258*ebfedea0SLionel SambucThe user is responsible for freeing memory allocated for 259*ebfedea0SLionel Sambuc.Ar out . 260*ebfedea0SLionel SambucIf 261*ebfedea0SLionel Sambuc.Ar outlen 262*ebfedea0SLionel Sambucis 0, more data is needed before anything can be output. 263*ebfedea0SLionel SambucUnused input data is stored internally for use in subsequent calls. 264*ebfedea0SLionel Sambuc.Pp 265*ebfedea0SLionel SambucWhen decoding, the internal buffers can only be flushed by providing 266*ebfedea0SLionel Sambucthe missing packet data and it is an error to call 267*ebfedea0SLionel Sambuc.Fn ssalc_sess_decode 268*ebfedea0SLionel Sambucwith 269*ebfedea0SLionel Sambuc.Ar inlen 270*ebfedea0SLionel Sambuc= 0. 271*ebfedea0SLionel SambucThe first call of 272*ebfedea0SLionel Sambuc.Fn saslc_sess_decode 273*ebfedea0SLionel Sambucin a session must begin at the start of a packet. 274*ebfedea0SLionel SambucSubsequent calls need not be aligned on packet boundaries. 275*ebfedea0SLionel Sambuc.It Fn saslc_sess_encode "sess" "in" "inlen" "out" "outlen" 276*ebfedea0SLionel SambucAs described above, 277*ebfedea0SLionel Sambuc.Fn saslc_sess_encode 278*ebfedea0SLionel Sambucencodes 279*ebfedea0SLionel Sambuc.Ar inlen 280*ebfedea0SLionel Sambucbytes of data from the 281*ebfedea0SLionel Sambuc.Ar in 282*ebfedea0SLionel Sambucbuffer. 283*ebfedea0SLionel SambucNote that unlike when decoding, 284*ebfedea0SLionel Sambucthe internal buffer may be flushed through the encoder 285*ebfedea0SLionel Sambucby calling 286*ebfedea0SLionel Sambuc.Fn saslc_sess_encode 287*ebfedea0SLionel Sambucwith 288*ebfedea0SLionel Sambuc.Ar inlen 289*ebfedea0SLionel Sambuc= 0. 290*ebfedea0SLionel SambucIn this case, 291*ebfedea0SLionel Sambuc.Fn saslc_sess_encode 292*ebfedea0SLionel Sambucreturns the number of bytes that were flushed from the internal buffer. 293*ebfedea0SLionel Sambuc.It Fn saslc_sess_getmech "sess" 294*ebfedea0SLionel SambucThe 295*ebfedea0SLionel Sambuc.Fn saslc_sess_getmech 296*ebfedea0SLionel Sambucfunction returns the name of the mechanism used in the session 297*ebfedea0SLionel Sambuc.Fa sess . 298*ebfedea0SLionel SambucThe function does not fail. 299*ebfedea0SLionel Sambuc.It Fn saslc_sess_strerror "sess" 300*ebfedea0SLionel SambucThe 301*ebfedea0SLionel Sambuc.Fn saslc_sess_strerror 302*ebfedea0SLionel Sambucreturns the error message associated with the session 303*ebfedea0SLionel Sambuc.Fa sess . 304*ebfedea0SLionel Sambuc.It Fn saslc_strerror "ctx" 305*ebfedea0SLionel SambucThe 306*ebfedea0SLionel Sambuc.Fn saslc_strerror 307*ebfedea0SLionel Sambucfunction operates as 308*ebfedea0SLionel Sambuc.Fn saslc_sess_strerror , 309*ebfedea0SLionel Sambucbut instead returns the error message string for the last error in the context 310*ebfedea0SLionel Sambuc.Fa ctx . 311*ebfedea0SLionel SambucNeither function will ever return 312*ebfedea0SLionel Sambuc.Dv NULL . 313*ebfedea0SLionel Sambuc.El 314*ebfedea0SLionel Sambuc.Sh CONFIGURATION 315*ebfedea0SLionel SambucThe library uses three types of dictionaries: context (or global), 316*ebfedea0SLionel Sambucsession, and mechanism, and they are searched in that order by 317*ebfedea0SLionel Sambuc.Fn saslc_getprop 318*ebfedea0SLionel Sambucand the first matching entry is taken. 319*ebfedea0SLionel SambucThe context and mechanism dictionaries are loaded from configuration 320*ebfedea0SLionel Sambucfiles, while the session dictionary is loaded by the caller via 321*ebfedea0SLionel Sambuc.Fn saslc_setprop . 322*ebfedea0SLionel Sambuc.Pp 323*ebfedea0SLionel SambucThe configuration file 324*ebfedea0SLionel Sambuc.Pa <cfgpath>/<appname>/saslc.conf 325*ebfedea0SLionel Sambucis used for the configuration context. 326*ebfedea0SLionel SambucThe 327*ebfedea0SLionel Sambuc.Pa <cfgpath>/<appname>/mech/<mechanism>.conf 328*ebfedea0SLionel Sambucfile is used for the mechanism configuration. 329*ebfedea0SLionel SambucThe 330*ebfedea0SLionel Sambuc.Pa <cfgpath> 331*ebfedea0SLionel Sambucis 332*ebfedea0SLionel Sambuc.Pa /etc/saslc.d 333*ebfedea0SLionel Sambucby default, but this may be overridden by the environment variable 334*ebfedea0SLionel Sambuc.Ev SASLC_CONFIG , 335*ebfedea0SLionel Sambucwhich in turn may be overridden by 336*ebfedea0SLionel Sambuc.Fn saslc_init . 337*ebfedea0SLionel SambucThe 338*ebfedea0SLionel Sambuc.Pa <appname> 339*ebfedea0SLionel Sambucis 340*ebfedea0SLionel Sambuc.Pa saslc 341*ebfedea0SLionel Sambucby default, but may also be overridden by 342*ebfedea0SLionel Sambuc.Fn saslc_init . 343*ebfedea0SLionel SambucFinally, the 344*ebfedea0SLionel Sambuc.Pa <mechanism> 345*ebfedea0SLionel Sambucis the mechanism in use by the session as returned by 346*ebfedea0SLionel Sambuc.Fn saslc_sess_getmech . 347*ebfedea0SLionel SambucNote that this name is case sensitive. 348*ebfedea0SLionel SambucThe currently supported mechanisms are 349*ebfedea0SLionel Sambuc.Bl -tag -width DIGEST-MD5 -offset indent 350*ebfedea0SLionel Sambuc.It ANONYMOUS 351*ebfedea0SLionel SambucSee RFC 2245 and RFC 4505. 352*ebfedea0SLionel Sambuc.It CRAM-MD5 353*ebfedea0SLionel SambucSee RFC 2195. 354*ebfedea0SLionel Sambuc.It DIGEST-MD5 355*ebfedea0SLionel SambucSee RFC 2831. 356*ebfedea0SLionel Sambuc.It EXTERNAL 357*ebfedea0SLionel SambucSee RFC 2222 section 7.4 and RFC 4422 appendix A. 358*ebfedea0SLionel Sambuc.It GSSAPI 359*ebfedea0SLionel SambucSee RFC 2222 section 7.2 and RFC 4752. 360*ebfedea0SLionel SambucThis requires GSS, Heimdal, or MIT Kerberos. 361*ebfedea0SLionel Sambuc.It LOGIN 362*ebfedea0SLionel SambucNon-standard, but common. 363*ebfedea0SLionel Sambuc.It PLAIN 364*ebfedea0SLionel SambucSee RFC 2595 and RFC 4616. 365*ebfedea0SLionel Sambuc.El 366*ebfedea0SLionel Sambuc.Pp 367*ebfedea0SLionel SambucIf any of the mechanism files are missing they are silently ignored, 368*ebfedea0SLionel Sambucunless debugging is enabled. 369*ebfedea0SLionel Sambuc.Pp 370*ebfedea0SLionel SambucThe configuration files consists of lines of the form: 371*ebfedea0SLionel Sambuc.Bd -literal -offset indent 372*ebfedea0SLionel Sambuc\fB#\fP comment line 373*ebfedea0SLionel Sambuc.Ao key Ac \~\~ Ao value Ac \~\~ Bo \fB#\fP comment Bc 374*ebfedea0SLionel Sambuc.Ed 375*ebfedea0SLionel Sambuc.Pp 376*ebfedea0SLionel SambucThe 377*ebfedea0SLionel Sambuc.Aq key 378*ebfedea0SLionel Sambucis a string beginning with an alpha character 379*ebfedea0SLionel Sambuc.Pq Xr isalpha 3 380*ebfedea0SLionel Sambucfollowed by any number of alpha numeric 381*ebfedea0SLionel Sambuc.Pq Xr isalnum 3 382*ebfedea0SLionel Sambucor underscore 383*ebfedea0SLionel Sambuc.Sq _ 384*ebfedea0SLionel Sambuccharacters; this is case sensitive. 385*ebfedea0SLionel SambucThe 386*ebfedea0SLionel Sambuc.Aq value 387*ebfedea0SLionel Sambucis a number or a quoted string. 388*ebfedea0SLionel SambucMore than one 389*ebfedea0SLionel Sambuc.Aq key 390*ebfedea0SLionel Sambucand 391*ebfedea0SLionel Sambuc.Aq value 392*ebfedea0SLionel Sambucpair may occur on a single line, but they may not be broken across 393*ebfedea0SLionel Sambuclines. 394*ebfedea0SLionel SambucA 395*ebfedea0SLionel Sambuc.Sq \fB#\fP 396*ebfedea0SLionel Sambuccharacter 397*ebfedea0SLionel Sambuc.Pq outside a quoted string 398*ebfedea0SLionel Sambucindicates that the rest of the line is a comment. 399*ebfedea0SLionel Sambuc.Pp 400*ebfedea0SLionel SambucNOTE: Currently, no escaping is supported in strings, so they may not 401*ebfedea0SLionel Sambuccontain quotes. 402*ebfedea0SLionel SambucNumbers must be between 0 and 403*ebfedea0SLionel Sambuc.Dv LLONG_MAX , 404*ebfedea0SLionel Sambucinclusive. 405*ebfedea0SLionel SambucAny base supported by 406*ebfedea0SLionel Sambuc.Xr strtoll 3 407*ebfedea0SLionel Sambucis allowed. 408*ebfedea0SLionel Sambuc.Sh PROPERTIES 409*ebfedea0SLionel SambucMost of the control of the library 410*ebfedea0SLionel Sambucbehavior is done via setting various properties in the context or 411*ebfedea0SLionel Sambucmechanism dictionaries via the configuration files or in the session 412*ebfedea0SLionel Sambucdictionary with 413*ebfedea0SLionel Sambuc.Fn saslc_setprop . 414*ebfedea0SLionel SambucThe following properties are currently used, as defined in 415*ebfedea0SLionel Sambuc.Pa saslc.h : 416*ebfedea0SLionel Sambuc.Bl -tag -width indent 417*ebfedea0SLionel Sambuc.It SASLC_PROP_AUTHCID Po Qo AUTHCID Qc Pc 418*ebfedea0SLionel SambucThe authentication name 419*ebfedea0SLionel Sambuc.Pq or username 420*ebfedea0SLionel Sambucto authenticate with. 421*ebfedea0SLionel SambucUsed by all mechanisms except EXTERNAL. 422*ebfedea0SLionel Sambuc.It SASLC_PROP_AUTHZID Po Qo AUTHZID Qc Pc 423*ebfedea0SLionel SambucThe authorization string to use. 424*ebfedea0SLionel SambucBy default, this string is empty. 425*ebfedea0SLionel SambucUsed by the DIGEST-MD5, EXTERNAL, and PLAIN mechanisms. 426*ebfedea0SLionel Sambuc.It SASLC_PROP_BASE64IO Po Qo BASE64IO Qc Pc 427*ebfedea0SLionel SambucIf true ("true", "yes", or nonzero), then input and output strings are 428*ebfedea0SLionel Sambucbase64 encoded. 429*ebfedea0SLionel SambucAny other value is false and the input and output strings are not 430*ebfedea0SLionel Sambucbase64 encoded. 431*ebfedea0SLionel SambucBy default, this is assumed true. 432*ebfedea0SLionel SambucUsed by all mechanisms. 433*ebfedea0SLionel Sambuc.It SASLC_PROP_CIPHERMASK Po Qo CIPHERMASK Qc Pc 434*ebfedea0SLionel SambucThe mask of ciphers to use with the DIGEST-MD5 mechanism when using 435*ebfedea0SLionel Sambucthe 436*ebfedea0SLionel Sambuc.Qq auth-conf 437*ebfedea0SLionel SambucQOP. 438*ebfedea0SLionel SambucBy default all supported ciphers are used, but they may be limited by 439*ebfedea0SLionel Sambuca comma delimited list of cipher names. 440*ebfedea0SLionel SambucThe recognized cipher names for DIGEST-MD5 are: 441*ebfedea0SLionel Sambuc.Pp 442*ebfedea0SLionel Sambuc.Bl -tag -offset indent -compact 443*ebfedea0SLionel Sambuc.It Li "3des" 444*ebfedea0SLionel SambucTriple-DES Cipher in CBC "two keys" mode with 112 bit key 445*ebfedea0SLionel Sambuc.It Li "aes" 446*ebfedea0SLionel SambucAES Cipher in CBC mode with 128 bit key 447*ebfedea0SLionel Sambuc.It Li "des" 448*ebfedea0SLionel SambucDES Cipher in CBC mode with 56 bit key 449*ebfedea0SLionel Sambuc.It Li "rc4" 450*ebfedea0SLionel SambucRC4 Cipher with 128 bit key 451*ebfedea0SLionel Sambuc.It Li "rc4-40" 452*ebfedea0SLionel SambucRC4 Cipher with 40 bit key 453*ebfedea0SLionel Sambuc.It Li "rc4-56" 454*ebfedea0SLionel SambucRC4 Cipher with 56 bit key 455*ebfedea0SLionel Sambuc.El 456*ebfedea0SLionel Sambuc.Pp 457*ebfedea0SLionel SambucThe default value is 458*ebfedea0SLionel Sambuc.Qq des,3des,rc4,rc4_40,rc4_56,aes . 459*ebfedea0SLionel Sambuc.Po 460*ebfedea0SLionel SambucNote that 461*ebfedea0SLionel Sambuc.Qq aes 462*ebfedea0SLionel Sambucis not part of the official standard. 463*ebfedea0SLionel Sambuc.Pc 464*ebfedea0SLionel SambucUsed by the DIGEST-MD5 mechanism. 465*ebfedea0SLionel Sambuc.It SASLC_PROP_DEBUG Po Qo DEBUG Qc Pc 466*ebfedea0SLionel SambucIf true, then enable debug messages. 467*ebfedea0SLionel SambucThis is implemented as a global variable so it will affect all 468*ebfedea0SLionel Sambucsessions. 469*ebfedea0SLionel SambucIf set via 470*ebfedea0SLionel Sambuc.Fn saslc_sess_setprop , 471*ebfedea0SLionel Sambucit should be set before the first call to 472*ebfedea0SLionel Sambuc.Fn saslc_sess_cont . 473*ebfedea0SLionel Sambuc.Po 474*ebfedea0SLionel SambucAlso see the environment variable 475*ebfedea0SLionel Sambuc.Ev SASLC_ENV_DEBUG 476*ebfedea0SLionel Sambucin the 477*ebfedea0SLionel Sambuc.Sx ENVIRONMENT 478*ebfedea0SLionel Sambucsection below. 479*ebfedea0SLionel Sambuc.Pc 480*ebfedea0SLionel Sambuc.It SASLC_PROP_HOSTNAME Po Qo HOSTNAME Qc Pc 481*ebfedea0SLionel SambucThe fully qualified domain name of the server host. 482*ebfedea0SLionel SambucUsed by the DIGEST-MD5 and GSSAPI mechanisms. 483*ebfedea0SLionel Sambuc.It SASLC_PROP_MAXBUF Po Qo MAXBUF Qc Pc 484*ebfedea0SLionel SambucThe size of the decode buffer. 485*ebfedea0SLionel SambucThis info is sent to the server so that it doesn't send packets that 486*ebfedea0SLionel Sambucwon't fit in the decode buffer when decoded. 487*ebfedea0SLionel SambucUsed by the DIGEST-MD5 and GSSAPI mechanisms. 488*ebfedea0SLionel Sambuc.It SASLC_PROP_PASSWD Po Qo PASSWD Qc Pc 489*ebfedea0SLionel SambucThe password to authenticate with. 490*ebfedea0SLionel SambucUsed by the CRAM-MD5, DIGEST-MD5, LOGIN, and PLAIN mechanisms. 491*ebfedea0SLionel Sambuc.It SASLC_PROP_QOPMASK Po Qo QOPMASK Qc Pc 492*ebfedea0SLionel SambucThe mask of QOP (quality of protection) to use with the DIGEST-MD5 493*ebfedea0SLionel Sambucand GSSAPI mechanisms. 494*ebfedea0SLionel SambucBy default all supported QOP values are allowed, but they may be 495*ebfedea0SLionel Sambuclimited by a comma delimited list of QOP values. 496*ebfedea0SLionel SambucThe recognized QOP values are: 497*ebfedea0SLionel Sambuc.Pp 498*ebfedea0SLionel Sambuc.Bl -tag -offset indent -compact 499*ebfedea0SLionel Sambuc.It Li "auth" 500*ebfedea0SLionel Sambucauthentication only 501*ebfedea0SLionel Sambuc.It Li "auth-int" 502*ebfedea0SLionel Sambucauthentication with integrity 503*ebfedea0SLionel Sambuc.It Li "auth-conf" 504*ebfedea0SLionel Sambucauthentication with confidentiality 505*ebfedea0SLionel Sambuc.El 506*ebfedea0SLionel Sambuc.Pp 507*ebfedea0SLionel Sambucso the default value of the mask is 508*ebfedea0SLionel Sambuc.Qq auth,auth-int,auth-conf . 509*ebfedea0SLionel SambucUsed by the DIGEST-MD5 and GSSAPI mechanisms. 510*ebfedea0SLionel Sambuc.It SASLC_PROP_REALM Po Qo REALM Qc Pc 511*ebfedea0SLionel SambucA comma delimited list of possible realms to use for authentication. 512*ebfedea0SLionel SambucThe format of each element in the list is 513*ebfedea0SLionel Sambuc.Qq Oo Ao hostname Ac : Oc Ns Ao realm Ac . 514*ebfedea0SLionel SambucThe user specified realm is the first realm in the list with a 515*ebfedea0SLionel Sambucmatching hostname or, if none is found, the first realm in the list 516*ebfedea0SLionel Sambucwith no hostname. 517*ebfedea0SLionel SambucIf the server provides a list of realms, the one matching the user 518*ebfedea0SLionel Sambucspecified realm is selected. 519*ebfedea0SLionel SambucIf no match is found or if the user didn't provide a realm, the first 520*ebfedea0SLionel Sambucrealm provided by the server is selected. 521*ebfedea0SLionel SambucIf the server doesn't provide any realms, use the user specified realm 522*ebfedea0SLionel Sambucif there is one, or the hostname if not. 523*ebfedea0SLionel SambucThis is useful when the server provides multiple realms or no realm. 524*ebfedea0SLionel SambucUsed by the DIGEST-MD5 mechanism. 525*ebfedea0SLionel Sambuc.It SASLC_PROP_SECURITY Po Qo SECURITY Qc Pc 526*ebfedea0SLionel SambucA comma delimited list of extra security option flags that will be 527*ebfedea0SLionel Sambuc.Qo or Qc Ns -ed 528*ebfedea0SLionel Sambuctogether with those passed to 529*ebfedea0SLionel Sambuc.Fn saslc_sess_init . 530*ebfedea0SLionel SambucSince these flags are used to choose the session mechanism, they are 531*ebfedea0SLionel Sambuconly effective if they are in the context configuration file. 532*ebfedea0SLionel Sambuc.Po 533*ebfedea0SLionel SambucSee the 534*ebfedea0SLionel Sambuc.Sx CONFIGURATION 535*ebfedea0SLionel Sambucsection and the 536*ebfedea0SLionel Sambuc.Fn saslc_sess_init 537*ebfedea0SLionel Sambucfunction. 538*ebfedea0SLionel Sambuc.Pc 539*ebfedea0SLionel Sambuc.It SASLC_PROP_SERVICE Po Qo SERVICE Qc Pc 540*ebfedea0SLionel SambucThe service being used, e.g., smtp, imap, etc. 541*ebfedea0SLionel SambucUsed by the DIGEST-MD5 and GSSAPI mechanisms. 542*ebfedea0SLionel Sambuc.It SASLC_PROP_SERVNAME Po Qo SERVNAME Qc Pc 543*ebfedea0SLionel SambucA comma delimited list of possible service names with elements of the 544*ebfedea0SLionel Sambucform 545*ebfedea0SLionel Sambuc.Qq Oo Ao hostname Ac : Oc Ns Ao serv-name Ac 546*ebfedea0SLionel Sambucand with the same rules as for the SASLC_PROP_REALM list. 547*ebfedea0SLionel SambucThis should only be used if the client uses a DNS name for the service 548*ebfedea0SLionel Sambucthat is different from the FQDN of the server. 549*ebfedea0SLionel SambucFor example, the service name 550*ebfedea0SLionel Sambuc.Em example.com 551*ebfedea0SLionel Sambucmight resolve 552*ebfedea0SLionel Sambuc.Pq via SRV or MX records 553*ebfedea0SLionel Sambucinto a set of other DNS names, one of which, 554*ebfedea0SLionel Sambuc.Em mail3.example.com , 555*ebfedea0SLionel Sambucis the FQDN of the server. 556*ebfedea0SLionel Sambuc.Po 557*ebfedea0SLionel SambucSee RFC 2831 section 2.1.2 558*ebfedea0SLionel Sambuc.Qq serv-name . 559*ebfedea0SLionel Sambuc.Pc 560*ebfedea0SLionel SambucUsed by the DIGEST-MD5 mechanism. 561*ebfedea0SLionel Sambuc.El 562*ebfedea0SLionel Sambuc.Pp 563*ebfedea0SLionel SambucThe defines in 564*ebfedea0SLionel Sambuc.Pa saslc.h 565*ebfedea0SLionel Sambucshould be used in code, but their values need to be used in the config 566*ebfedea0SLionel Sambucfiles. 567*ebfedea0SLionel Sambuc.Sh ENVIRONMENT 568*ebfedea0SLionel SambucThe following environment variables 569*ebfedea0SLionel Sambuc.Pq defined in Pa saslc.h 570*ebfedea0SLionel Sambucaffect the behavior of the library: 571*ebfedea0SLionel Sambuc.Bl -tag -width indent 572*ebfedea0SLionel Sambuc.It Ev SASLC_ENV_CONFIG Po Qo SASLC_CONFIG Qc Pc 573*ebfedea0SLionel SambucIf the environment variable 574*ebfedea0SLionel Sambuc.Ev SASLC_CONFIG 575*ebfedea0SLionel Sambucis set it overrides the default configuration file location of 576*ebfedea0SLionel Sambuc.Pa /etc/saslc.d . 577*ebfedea0SLionel SambucThis may be overridden by 578*ebfedea0SLionel Sambuc.Fn saslc_init . 579*ebfedea0SLionel Sambuc.It Ev SASLC_ENV_DEBUG Po Qo SASLC_DEBUG Qc Pc 580*ebfedea0SLionel SambucIf set, turn on debugging messages. 581*ebfedea0SLionel SambucThis turns on debugging as early as possible and is a global setting. 582*ebfedea0SLionel Sambuc.El 583*ebfedea0SLionel Sambuc.Sh GSSAPI AND KERBEROS 584*ebfedea0SLionel SambucThe following is a minimal 585*ebfedea0SLionel Sambuc.Pq Heimdal 586*ebfedea0SLionel SambucKerberos 5 setup for use with an smtp server that has been configured 587*ebfedea0SLionel Sambucto support 588*ebfedea0SLionel Sambuc.Em SASL 589*ebfedea0SLionel Sambucwith the 590*ebfedea0SLionel Sambuc.Em GSSAPI 591*ebfedea0SLionel Sambucmechanism. 592*ebfedea0SLionel SambucIt assumes that Kerberos and the smtp server will both run on 593*ebfedea0SLionel Sambuc.Em server.my.domain 594*ebfedea0SLionel Sambucand that the client is on 595*ebfedea0SLionel Sambuc.Em client.my.domain . 596*ebfedea0SLionel SambucIt also assumes that the smtp server runs as user 597*ebfedea0SLionel Sambuc.Em postfix 598*ebfedea0SLionel Sambucand group 599*ebfedea0SLionel Sambuc.Em mail , 600*ebfedea0SLionel Sambucand that it is not chrooted. 601*ebfedea0SLionel Sambuc.Pp 602*ebfedea0SLionel SambucOn 603*ebfedea0SLionel Sambuc.Em server.my.domain 604*ebfedea0SLionel Sambucrun the following script as 605*ebfedea0SLionel Sambuc.Em root 606*ebfedea0SLionel Sambucand then start the Kerberos server 607*ebfedea0SLionel Sambuc.Xr kdc 8 . 608*ebfedea0SLionel SambucYou will be prompted for a master password for Kerberos and a password 609*ebfedea0SLionel Sambucfor the 610*ebfedea0SLionel Sambuc.Em postfix 611*ebfedea0SLionel Sambucprincipal. 612*ebfedea0SLionel Sambuc.Bd -literal -offset indent 613*ebfedea0SLionel Sambuc#/bin/sh 614*ebfedea0SLionel Sambuc.Pp 615*ebfedea0SLionel Sambuccat <<- EOF >> /etc/krb5.conf 616*ebfedea0SLionel Sambuc[libdefaults] 617*ebfedea0SLionel Sambuc default_realm = MY.DOMAIN 618*ebfedea0SLionel Sambuc[realms] 619*ebfedea0SLionel Sambuc MY.DOMAIN = { 620*ebfedea0SLionel Sambuc kdc = server.my.domain 621*ebfedea0SLionel Sambuc admin_servers = server.my.domain 622*ebfedea0SLionel Sambuc } 623*ebfedea0SLionel Sambuc[domain_realm] 624*ebfedea0SLionel Sambuc .my.domain = MY.DOMAIN 625*ebfedea0SLionel SambucEOF 626*ebfedea0SLionel Sambuc.Pp 627*ebfedea0SLionel Sambucmkdir /var/heimdal 628*ebfedea0SLionel Sambucchown root:wheel /var/heimdal 629*ebfedea0SLionel Sambucchmod 755 /var/heimdal 630*ebfedea0SLionel Sambuc.Pp 631*ebfedea0SLionel Sambuckstash 632*ebfedea0SLionel Sambuckadmin -l init --realm-max-ticket-life=unlimited \\ 633*ebfedea0SLionel Sambuc --realm-max-renewable-life=unlimited \\ 634*ebfedea0SLionel Sambuc MY.DOMAIN 635*ebfedea0SLionel Sambuckadmin -l add --max-ticket-life="1 day" \\ 636*ebfedea0SLionel Sambuc --max-renewable-life="1 week" \\ 637*ebfedea0SLionel Sambuc --expiration-time=never \\ 638*ebfedea0SLionel Sambuc --pw-expiration-time=never \\ 639*ebfedea0SLionel Sambuc --attributes="" \\ 640*ebfedea0SLionel Sambuc postfix 641*ebfedea0SLionel Sambuckadmin -l add --random-key \\ 642*ebfedea0SLionel Sambuc --max-ticket-life="1 day" \\ 643*ebfedea0SLionel Sambuc --max-renewable-life="1 week" \\ 644*ebfedea0SLionel Sambuc --expiration-time=never \\ 645*ebfedea0SLionel Sambuc --pw-expiration-time=never \\ 646*ebfedea0SLionel Sambuc --attributes="" \\ 647*ebfedea0SLionel Sambuc smtp/server.my.domain 648*ebfedea0SLionel Sambuckadmin -l ext -k /etc/krb5.keytab smtp/server.my.domain 649*ebfedea0SLionel Sambucchown root:mail /etc/krb5.keytab 650*ebfedea0SLionel Sambucchmod 640 /etc/krb5.keytab 651*ebfedea0SLionel Sambuc.Ed 652*ebfedea0SLionel Sambuc.Pp 653*ebfedea0SLionel SambucNote that the keytab 654*ebfedea0SLionel Sambuc.Pa /etc/krb5.keytab 655*ebfedea0SLionel Sambucmust be readable by the smtp server or authentication will fail. 656*ebfedea0SLionel SambucThe location of this keytab file may be changed with the environment 657*ebfedea0SLionel Sambucvariable 658*ebfedea0SLionel Sambuc.Ev KRB5_KTNAME . 659*ebfedea0SLionel SambucIf postfix is the smtp server, note the 660*ebfedea0SLionel Sambuc.Em import_environment 661*ebfedea0SLionel Sambucparameter 662*ebfedea0SLionel Sambuc.Pq see Xr postconf 5 . 663*ebfedea0SLionel Sambuc.Pp 664*ebfedea0SLionel SambucOn 665*ebfedea0SLionel Sambuc.Em client.my.domain 666*ebfedea0SLionel Sambuccopy the keytab file from 667*ebfedea0SLionel Sambuc.Pa server.my.domain:/etc/krb5.keytab 668*ebfedea0SLionel Sambucto 669*ebfedea0SLionel Sambuc.Pa /etc/krb5.keytab . 670*ebfedea0SLionel SambucSetup the 671*ebfedea0SLionel Sambuc.Pa /etc/saslc.d 672*ebfedea0SLionel Sambucconfiguration directory 673*ebfedea0SLionel Sambuc.Po see Sx CONFIGURATION 674*ebfedea0SLionel Sambucabove 675*ebfedea0SLionel Sambuc.Pc . 676*ebfedea0SLionel SambucAdd the line 677*ebfedea0SLionel Sambuc.Bd -literal -offset indent 678*ebfedea0SLionel SambucAUTHCID "postfix" 679*ebfedea0SLionel Sambuc.Ed 680*ebfedea0SLionel Sambuc.Pp 681*ebfedea0SLionel Sambucto the file 682*ebfedea0SLionel Sambuc.Pa /etc/saslc.d/postfix/mech/GSSAPI.conf 683*ebfedea0SLionel Sambucso that the 684*ebfedea0SLionel Sambuc.Em postfix 685*ebfedea0SLionel Sambucprincipal will be used for authentication. 686*ebfedea0SLionel SambucEnable 687*ebfedea0SLionel Sambuc.Em SASL 688*ebfedea0SLionel Sambucin the smtp client. 689*ebfedea0SLionel SambucAssuming the smtp client is postfix, you will need to add the 690*ebfedea0SLionel Sambucfollowing to the 691*ebfedea0SLionel Sambuc.Pa /etc/postfix/main.cf 692*ebfedea0SLionel Sambucfile to do this: 693*ebfedea0SLionel Sambuc.Bd -literal -offset indent 694*ebfedea0SLionel Sambucsmtp_sasl_auth_enable = yes 695*ebfedea0SLionel Sambucsmtp_sasl_type = saslc 696*ebfedea0SLionel Sambucsmtp_sasl_mechanism_filter = GSSAPI 697*ebfedea0SLionel Sambucrelayhost = [server.my.domain]:submission 698*ebfedea0SLionel Sambuc.Ed 699*ebfedea0SLionel Sambuc.Pp 700*ebfedea0SLionel SambucHere we have assumed the 701*ebfedea0SLionel Sambuc.Em submission 702*ebfedea0SLionel Sambucport is the port the server is listening to. 703*ebfedea0SLionel SambucFinally, as 704*ebfedea0SLionel Sambuc.Em root , 705*ebfedea0SLionel Sambucrun the command 706*ebfedea0SLionel Sambuc.Bd -literal -offset indent 707*ebfedea0SLionel Sambucsu -m postfix -c kinit 708*ebfedea0SLionel Sambuc.Ed 709*ebfedea0SLionel Sambuc.Pp 710*ebfedea0SLionel Sambucto obtain a ticket for the postfix user with the postfix credential 711*ebfedea0SLionel Sambucand you should be good to go! 712*ebfedea0SLionel Sambuc.Sh FILES 713*ebfedea0SLionel Sambuc.Bl -tag -width /etc/saslc.d 714*ebfedea0SLionel Sambuc.It Pa /etc/saslc.d 715*ebfedea0SLionel Sambuc.El 716*ebfedea0SLionel Sambuc.Sh EXAMPLES 717*ebfedea0SLionel SambucThe following code fragments illustrate the possible use of the 718*ebfedea0SLionel Sambucfunctions described above. 719*ebfedea0SLionel Sambuc.Bd -literal 720*ebfedea0SLionel Sambucint 721*ebfedea0SLionel Sambucdecode_stream(saslc_sess_t *sess, int fdin, int fdout) 722*ebfedea0SLionel Sambuc{ 723*ebfedea0SLionel Sambuc uint8_t buf[BUFSIZE]; 724*ebfedea0SLionel Sambuc uint8_t *in; 725*ebfedea0SLionel Sambuc void *out; 726*ebfedea0SLionel Sambuc size_t inlen, outlen; 727*ebfedea0SLionel Sambuc ssize_t n, rval; 728*ebfedea0SLionel Sambuc.Pp 729*ebfedea0SLionel Sambuc for (;;) { 730*ebfedea0SLionel Sambuc if ((rval = read(fdin, buf, sizeof(buf))) == \-1) 731*ebfedea0SLionel Sambuc return \-1; 732*ebfedea0SLionel Sambuc if (rval == 0) 733*ebfedea0SLionel Sambuc break; 734*ebfedea0SLionel Sambuc in = buf; 735*ebfedea0SLionel Sambuc inlen = rval; 736*ebfedea0SLionel Sambuc while (inlen > 0) { 737*ebfedea0SLionel Sambuc rval = saslc_sess_decode(sess, in, inlen, &out, 738*ebfedea0SLionel Sambuc &outlen); 739*ebfedea0SLionel Sambuc if (rval == \-1) 740*ebfedea0SLionel Sambuc return \-1; 741*ebfedea0SLionel Sambuc if (outlen > 0) { 742*ebfedea0SLionel Sambuc n = write(fdout, out, outlen); 743*ebfedea0SLionel Sambuc free(out); 744*ebfedea0SLionel Sambuc if (n == \-1) 745*ebfedea0SLionel Sambuc return \-1; 746*ebfedea0SLionel Sambuc } 747*ebfedea0SLionel Sambuc in += rval; 748*ebfedea0SLionel Sambuc inlen -= rval; 749*ebfedea0SLionel Sambuc } 750*ebfedea0SLionel Sambuc } 751*ebfedea0SLionel Sambuc return 0; 752*ebfedea0SLionel Sambuc} 753*ebfedea0SLionel Sambuc.Pp 754*ebfedea0SLionel Sambucint 755*ebfedea0SLionel Sambucencode_stream(saslc_sess_t *sess, int fdin, int fdout) 756*ebfedea0SLionel Sambuc{ 757*ebfedea0SLionel Sambuc uint8_t buf[BUFSIZE]; 758*ebfedea0SLionel Sambuc uint8_t *in; 759*ebfedea0SLionel Sambuc void *out; 760*ebfedea0SLionel Sambuc size_t inlen, outlen; 761*ebfedea0SLionel Sambuc ssize_t n, rval; 762*ebfedea0SLionel Sambuc.Pp 763*ebfedea0SLionel Sambuc for (;;) { 764*ebfedea0SLionel Sambuc if ((rval = read(fdin, buf, sizeof(buf))) == \-1) 765*ebfedea0SLionel Sambuc return \-1; 766*ebfedea0SLionel Sambuc if (rval == 0) 767*ebfedea0SLionel Sambuc break; 768*ebfedea0SLionel Sambuc in = buf; 769*ebfedea0SLionel Sambuc inlen = rval; 770*ebfedea0SLionel Sambuc while (inlen > 0) { 771*ebfedea0SLionel Sambuc rval = saslc_sess_encode(sess, in, inlen, &out, 772*ebfedea0SLionel Sambuc &outlen); 773*ebfedea0SLionel Sambuc if (rval == \-1) 774*ebfedea0SLionel Sambuc return \-1; 775*ebfedea0SLionel Sambuc if (outlen > 0) { 776*ebfedea0SLionel Sambuc n = write(fdout, out, outlen); 777*ebfedea0SLionel Sambuc free(out); 778*ebfedea0SLionel Sambuc if (n == \-1) 779*ebfedea0SLionel Sambuc return \-1; 780*ebfedea0SLionel Sambuc } 781*ebfedea0SLionel Sambuc in += rval; 782*ebfedea0SLionel Sambuc inlen -= rval; 783*ebfedea0SLionel Sambuc } 784*ebfedea0SLionel Sambuc } 785*ebfedea0SLionel Sambuc /* flush internal encoder buffer */ 786*ebfedea0SLionel Sambuc if (saslc_sess_encode(sess, NULL, 0, &out, &outlen) == \-1) 787*ebfedea0SLionel Sambuc return \-1; 788*ebfedea0SLionel Sambuc if (outlen > 0) 789*ebfedea0SLionel Sambuc if (write(fdout, out, outlen) == \-1) 790*ebfedea0SLionel Sambuc return \-1; 791*ebfedea0SLionel Sambuc return 0; 792*ebfedea0SLionel Sambuc} 793*ebfedea0SLionel Sambuc.Ed 794*ebfedea0SLionel Sambuc.Sh COMPATIBILITY 795*ebfedea0SLionel SambucThere exist other SASL client library implementations including Cyrus SASL 796*ebfedea0SLionel Sambuc(http://asg.web.cmu.edu/sasl/sasl-library.html) and GNU SASL 797*ebfedea0SLionel Sambuc(http://www.gnu.org/software/gsasl/). 798*ebfedea0SLionel Sambuc.Sh STANDARDS 799*ebfedea0SLionel SambucRFC 2195, RFC 2222, RFC 2245, RFC 2595, RFC 2831, RFC 4422, RFC 4505, 800*ebfedea0SLionel SambucRFC 4616, RFC 4752. 801*ebfedea0SLionel Sambuc.Sh HISTORY 802*ebfedea0SLionel SambucThe 803*ebfedea0SLionel Sambuc.Nm 804*ebfedea0SLionel Sambuclibrary appeared in 805*ebfedea0SLionel Sambuc.Nx 6.0 . 806*ebfedea0SLionel Sambuc.Sh CAVEATS 807*ebfedea0SLionel SambucThe API was heavily influenced by its use with 808*ebfedea0SLionel Sambuc.Xr postfix 1 . 809*ebfedea0SLionel Sambuc.Pp 810*ebfedea0SLionel SambucCurrently the ANONYMOUS, LOGIN, PLAIN, CRAM-MD5, DIGEST-MD5, and 811*ebfedea0SLionel SambucGSSAPI mechanisms have been tested and shown to work for 812*ebfedea0SLionel Sambucauthentication with a 813*ebfedea0SLionel Sambuc.Xr postfix 1 814*ebfedea0SLionel SambucSMTP server using the cyrus-sasl library. 815*ebfedea0SLionel SambucLOGIN, PLAIN, CRAM-MD5, and DIGEST-MD5 have also been tested and shown 816*ebfedea0SLionel Sambucto work with a 817*ebfedea0SLionel Sambuc.Xr postfix 1 818*ebfedea0SLionel SambucSMTP server using a dovecot backend for authentication. 819*ebfedea0SLionel SambucThe DIGEST-MD5 and GSSAPI specs also provide for integrity and 820*ebfedea0SLionel Sambucconfidentiality layers via the 821*ebfedea0SLionel Sambuc.Fn saslc_sess_encode 822*ebfedea0SLionel Sambucand 823*ebfedea0SLionel Sambuc.Fn saslc_sess_decode 824*ebfedea0SLionel Sambucroutines, but these have not yet been tested against any servers. 825