NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
gsasl2.h File Reference

GNU SASL authentication support. More...

#include <gsasl.h>
+ Include dependency graph for gsasl2.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void mutt_gsasl_client_finish (Gsasl_session **sctx)
 Free a GNU SASL client.
 
int mutt_gsasl_client_new (struct Connection *conn, const char *mech, Gsasl_session **sctx)
 Create a new GNU SASL client.
 
void mutt_gsasl_cleanup (Gsasl **ctx)
 Shutdown GNU SASL library.
 
const char * mutt_gsasl_get_mech (const char *requested_mech, const char *server_mechlist)
 Pick a connection mechanism.
 

Detailed Description

GNU SASL authentication support.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file gsasl2.h.

Function Documentation

◆ mutt_gsasl_client_finish()

void mutt_gsasl_client_finish ( Gsasl_session ** sctx)

Free a GNU SASL client.

Parameters
sctxGNU SASL Session

Definition at line 225 of file gsasl.c.

226{
227 gsasl_finish(*sctx);
228 *sctx = NULL;
229}
+ Here is the caller graph for this function:

◆ mutt_gsasl_client_new()

int mutt_gsasl_client_new ( struct Connection * conn,
const char * mech,
Gsasl_session ** sctx )

Create a new GNU SASL client.

Parameters
connConnection to a server
mechMechanisms to use
sctxGNU SASL Session
Return values
0Success
-1Error

Definition at line 203 of file gsasl.c.

204{
205 if (!mutt_gsasl_init())
206 return -1;
207
209 int rc = gsasl_client_start(mod_data->mutt_gsasl_ctx, mech, sctx);
210 if (rc != GSASL_OK)
211 {
212 *sctx = NULL;
213 mutt_debug(LL_DEBUG1, "gsasl_client_start failed (%d): %s\n", rc, gsasl_strerror(rc));
214 return -1;
215 }
216
217 gsasl_session_hook_set(*sctx, conn);
218 return 0;
219}
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
static bool mutt_gsasl_init(void)
Initialise GNU SASL library.
Definition gsasl.c:127
@ LL_DEBUG1
Log at debug level 1.
Definition logging2.h:45
@ MODULE_ID_CONN
ModuleConn, Network connections
Definition module_api.h:60
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:663
Conn private Module data.
Definition module_data.h:38
Container for Accounts, Notifications.
Definition neomutt.h:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_gsasl_cleanup()

void mutt_gsasl_cleanup ( Gsasl ** ctx)

Shutdown GNU SASL library.

Parameters
ctxGNU SASL context to clean up

Definition at line 151 of file gsasl.c.

152{
153 if (!ctx || !*ctx)
154 return;
155
156 gsasl_done(*ctx);
157 *ctx = NULL;
158}
+ Here is the caller graph for this function:

◆ mutt_gsasl_get_mech()

const char * mutt_gsasl_get_mech ( const char * requested_mech,
const char * server_mechlist )

Pick a connection mechanism.

Parameters
requested_mechRequested mechanism
server_mechlistServer's list of mechanisms
Return values
ptrSelected mechanism string

Definition at line 166 of file gsasl.c.

167{
168 if (!mutt_gsasl_init())
169 return NULL;
170
172
173 /* libgsasl does not do case-independent string comparisons,
174 * and stores its methods internally in uppercase. */
175 char *uc_server_mechlist = mutt_str_dup(server_mechlist);
176 if (uc_server_mechlist)
177 mutt_str_upper(uc_server_mechlist);
178
179 char *uc_requested_mech = mutt_str_dup(requested_mech);
180 if (uc_requested_mech)
181 mutt_str_upper(uc_requested_mech);
182
183 const char *sel_mech = NULL;
184 if (uc_requested_mech)
185 sel_mech = gsasl_client_suggest_mechanism(mod_data->mutt_gsasl_ctx, uc_requested_mech);
186 else
187 sel_mech = gsasl_client_suggest_mechanism(mod_data->mutt_gsasl_ctx, uc_server_mechlist);
188
189 FREE(&uc_requested_mech);
190 FREE(&uc_server_mechlist);
191
192 return sel_mech;
193}
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition string.c:257
char * mutt_str_upper(char *str)
Convert all characters in the string to uppercase.
Definition string.c:340
+ Here is the call graph for this function:
+ Here is the caller graph for this function: