@@ -94,7 +94,8 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
94
94
if (result != GFARM_ERR_NO_ERROR ) {
95
95
/* server cert is invalid? raise alert */
96
96
gflog_warning (GFARM_MSG_1005354 ,
97
- "%s: does not accept my certificate: %s" ,
97
+ "%s: does not accept my certificate: %s, "
98
+ "skip SASL authentication" ,
98
99
hostname , gfarm_error_string (result ));
99
100
gfp_xdr_tls_reset (conn ); /* XXX this is NOT graceful for now */
100
101
return (GFARM_ERR_AUTHENTICATION );
@@ -111,7 +112,9 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
111
112
112
113
if (r != SASL_OK ) {
113
114
sasl_conn = NULL ;
114
- gflog_notice (GFARM_MSG_UNFIXED , "%s: sasl_server_new(): %s" ,
115
+ gflog_notice (GFARM_MSG_UNFIXED ,
116
+ "%s: sasl_server_new() faild: %s, "
117
+ "skip SASL authentication" ,
115
118
hostname , sasl_errstring (r , NULL , NULL ));
116
119
data = "" ; /* mechanism_candidates == "" means error */
117
120
len = 0 ;
@@ -120,13 +123,15 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
120
123
len = strlen (data );
121
124
if (data [0 ] == '\0' )
122
125
gflog_notice (GFARM_MSG_UNFIXED ,
123
- "%s: no sasl mechanism candidate" , hostname );
126
+ "%s: no sasl mechanism candidate, "
127
+ "skip SASL authentication" , hostname );
124
128
} else {
125
129
r = sasl_listmech (sasl_conn , NULL , NULL , " " , NULL ,
126
130
& data , & len , & count );
127
131
if (r != SASL_OK ) {
128
- gflog_error (GFARM_MSG_UNFIXED ,
129
- "%s: sasl_listmech(): %s" ,
132
+ gflog_notice (GFARM_MSG_UNFIXED ,
133
+ "%s: sasl_listmech() failed: %s, "
134
+ "skip SASL authentication" ,
130
135
hostname , sasl_errstring (r , NULL , NULL ));
131
136
data = "" ; /* mechanism_candidates == "" means error */
132
137
len = 0 ;
@@ -145,13 +150,13 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
145
150
sasl_dispose (& sasl_conn );
146
151
gfp_xdr_tls_reset (conn );
147
152
if (data == NULL ) {
148
- gflog_error (GFARM_MSG_UNFIXED ,
153
+ gflog_notice (GFARM_MSG_UNFIXED ,
149
154
"%s: %s: sasl_listmech(): no memory?" ,
150
155
diag , hostname );
151
156
return (GFARM_ERR_NO_MEMORY );
152
157
}
153
158
/* a gflog message was already recorded in previous clause */
154
- return (GFARM_ERR_AUTHENTICATION );
159
+ return (e != GFARM_ERR_NO_ERROR ? e : GFARM_ERR_AUTHENTICATION );
155
160
}
156
161
gflog_auth_info (GFARM_MSG_UNFIXED ,
157
162
"SASL: %s: propose mechanisms <%s>" , hostname , data );
@@ -189,8 +194,9 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
189
194
"%s: %s: unexpected EOF" , diag , hostname );
190
195
} else {
191
196
e = GFARM_ERR_AUTHENTICATION ;
192
- gflog_auth_error (GFARM_MSG_UNFIXED ,
193
- "%s: SASL mechanism unmatch" , hostname );
197
+ gflog_auth_notice (GFARM_MSG_UNFIXED ,
198
+ "%s: SASL mechanism mismatch, "
199
+ "skip SASL authentication" , hostname );
194
200
}
195
201
sasl_dispose (& sasl_conn );
196
202
gfp_xdr_tls_reset (conn );
@@ -224,21 +230,24 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
224
230
225
231
if (gfarm_ctxp -> sasl_mechanisms != NULL &&
226
232
strcasecmp (chosen_mechanism , gfarm_ctxp -> sasl_mechanisms ) != 0 ) {
227
- gflog_error (GFARM_MSG_1005358 ,
228
- "%s: SASL mechanism does not match. \"%s\" vs \"%s\"" ,
233
+ gflog_info (GFARM_MSG_1005358 ,
234
+ "%s: SASL mechanism does not match. \"%s\" vs \"%s\""
235
+ "skip SASL authentication" ,
229
236
hostname , gfarm_ctxp -> sasl_mechanisms , chosen_mechanism );
230
237
/* XXX FIXME is this graceful? */
231
238
e = gfp_xdr_send (conn , "i" ,
232
239
(gfarm_int32_t )GFARM_AUTH_SASL_STEP_ERROR );
233
240
if (e == GFARM_ERR_NO_ERROR )
234
241
e = gfp_xdr_flush (conn );
235
- gflog_debug (GFARM_MSG_UNFIXED , "%s: %s: gfp_xdr_send: %s" ,
236
- diag , hostname , gfarm_error_string (e ));
242
+ if (e != GFARM_ERR_NO_ERROR )
243
+ gflog_debug (GFARM_MSG_UNFIXED ,
244
+ "%s: %s: gfp_xdr_send: %s" ,
245
+ diag , hostname , gfarm_error_string (e ));
237
246
free (response );
238
247
free (chosen_mechanism );
239
248
sasl_dispose (& sasl_conn );
240
249
gfp_xdr_tls_reset (conn ); /* is this case graceful? */
241
- return (GFARM_ERR_AUTHENTICATION );
250
+ return (e != GFARM_ERR_NO_ERROR ? e : GFARM_ERR_AUTHENTICATION );
242
251
}
243
252
244
253
data = NULL ;
@@ -250,18 +259,21 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
250
259
free (chosen_mechanism );
251
260
chosen_mechanism = response = NULL ;
252
261
if (r != SASL_OK && r != SASL_CONTINUE ) {
253
- gflog_error (GFARM_MSG_1005359 ,
254
- "%s: SASL negotiation: %s" , hostname ,
262
+ gflog_notice (GFARM_MSG_1005359 ,
263
+ "%s: SASL negotiation: %s, "
264
+ "skip SASL authentication" , hostname ,
255
265
sasl_errstring (r , NULL , NULL ));
256
266
e = gfp_xdr_send (conn , "i" ,
257
267
(gfarm_int32_t )GFARM_AUTH_SASL_STEP_ERROR );
258
268
if (e == GFARM_ERR_NO_ERROR )
259
269
e = gfp_xdr_flush (conn );
260
- gflog_debug (GFARM_MSG_UNFIXED , "%s: %s: gfp_xdr_send: %s" ,
261
- diag , hostname , gfarm_error_string (e ));
270
+ if (e != GFARM_ERR_NO_ERROR )
271
+ gflog_debug (GFARM_MSG_UNFIXED ,
272
+ "%s: %s: gfp_xdr_send: %s" ,
273
+ diag , hostname , gfarm_error_string (e ));
262
274
sasl_dispose (& sasl_conn );
263
275
gfp_xdr_tls_reset (conn ); /* is this case graceful? */
264
- return (GFARM_ERR_AUTHENTICATION );
276
+ return (e != GFARM_ERR_NO_ERROR ? e : GFARM_ERR_AUTHENTICATION );
265
277
}
266
278
267
279
while (r == SASL_CONTINUE ) {
@@ -302,71 +314,81 @@ gfarm_authorize_sasl_common(struct gfp_xdr *conn,
302
314
free (response );
303
315
response = NULL ;
304
316
if (r != SASL_OK && r != SASL_CONTINUE ) {
305
- gflog_error (GFARM_MSG_1005360 ,
306
- "%s: SASL negotiation: %s" , peer_hsbuf ,
317
+ gflog_notice (GFARM_MSG_1005360 ,
318
+ "%s: SASL negotiation: %s, "
319
+ "skip SASL authentication" , peer_hsbuf ,
307
320
sasl_errstring (r , NULL , NULL ));
308
321
e = gfp_xdr_send (conn , "i" ,
309
322
(gfarm_int32_t )GFARM_AUTH_SASL_STEP_ERROR );
310
323
if (e == GFARM_ERR_NO_ERROR )
311
324
e = gfp_xdr_flush (conn );
312
- gflog_debug (GFARM_MSG_UNFIXED ,
313
- "%s: %s: gfp_xdr_send: %s" ,
314
- diag , hostname , gfarm_error_string (e ));
325
+ if (e != GFARM_ERR_NO_ERROR )
326
+ gflog_debug (GFARM_MSG_UNFIXED ,
327
+ "%s: %s: gfp_xdr_send: %s" ,
328
+ diag , hostname , gfarm_error_string (e ));
315
329
sasl_dispose (& sasl_conn );
316
330
gfp_xdr_tls_reset (conn ); /* is this case graceful? */
317
- return (GFARM_ERR_AUTHENTICATION );
331
+ return (e != GFARM_ERR_NO_ERROR ? e
332
+ : GFARM_ERR_AUTHENTICATION );
318
333
}
319
334
}
320
335
321
336
if (r != SASL_OK ) {
322
- gflog_error (GFARM_MSG_1005361 ,
323
- "%s: SASL: incorrect authentication: %s" , hostname ,
337
+ gflog_notice (GFARM_MSG_1005361 ,
338
+ "%s: SASL: incorrect authentication: %s, "
339
+ "skip SASL authentication" , hostname ,
324
340
sasl_errstring (r , NULL , NULL ));
325
341
e = gfp_xdr_send (conn , "i" ,
326
342
(gfarm_int32_t )GFARM_AUTH_SASL_STEP_ERROR );
327
343
if (e == GFARM_ERR_NO_ERROR )
328
344
e = gfp_xdr_flush (conn );
329
- gflog_debug (GFARM_MSG_UNFIXED , "%s: %s: gfp_xdr_send: %s" ,
330
- diag , hostname , gfarm_error_string (e ));
345
+ if (e != GFARM_ERR_NO_ERROR )
346
+ gflog_debug (GFARM_MSG_UNFIXED ,
347
+ "%s: %s: gfp_xdr_send: %s" ,
348
+ diag , hostname , gfarm_error_string (e ));
331
349
sasl_dispose (& sasl_conn );
332
350
gfp_xdr_tls_reset (conn ); /* is this case graceful? */
333
- return (GFARM_ERR_AUTHENTICATION );
351
+ return (e != GFARM_ERR_NO_ERROR ? e : GFARM_ERR_AUTHENTICATION );
334
352
}
335
353
336
354
r = sasl_getprop (sasl_conn , SASL_USERNAME ,
337
355
(const void * * )& user_id );
338
356
339
357
if (r != SASL_OK ) {
340
- gflog_error (GFARM_MSG_1005362 ,
341
- "%s: SASL: SASL_USERNAME: %s" , hostname ,
358
+ gflog_notice (GFARM_MSG_1005362 ,
359
+ "%s: SASL: SASL_USERNAME: %s, "
360
+ "skip SASL authentication" , hostname ,
342
361
sasl_errstring (r , NULL , NULL ));
343
362
e = gfp_xdr_send (conn , "i" ,
344
363
(gfarm_int32_t )GFARM_AUTH_SASL_STEP_ERROR );
345
364
if (e == GFARM_ERR_NO_ERROR )
346
365
e = gfp_xdr_flush (conn );
347
- gflog_debug (GFARM_MSG_UNFIXED ,
348
- "%s: %s: gfp_xdr_send: %s" ,
349
- diag , hostname , gfarm_error_string (e ));
366
+ if (e != GFARM_ERR_NO_ERROR )
367
+ gflog_debug (GFARM_MSG_UNFIXED ,
368
+ "%s: %s: gfp_xdr_send: %s" ,
369
+ diag , hostname , gfarm_error_string (e ));
350
370
sasl_dispose (& sasl_conn );
351
371
gfp_xdr_tls_reset (conn ); /* is this case graceful? */
352
- return (GFARM_ERR_AUTHENTICATION );
372
+ return (e != GFARM_ERR_NO_ERROR ? e : GFARM_ERR_AUTHENTICATION );
353
373
}
354
374
355
375
e = (* auth_uid_to_global_user )(closure , auth_method ,
356
376
user_id , & peer_role , & global_username );
357
377
if (e != GFARM_ERR_NO_ERROR ) {
358
- gflog_error (GFARM_MSG_1005363 ,
359
- "%s@%s: unregistered user: %s" , user_id , hostname ,
360
- gfarm_error_string (e ));
378
+ gflog_notice (GFARM_MSG_1005363 ,
379
+ "%s@%s: unregistered user: %s, skip SASL authentication" ,
380
+ user_id , hostname , gfarm_error_string (e ));
361
381
e = gfp_xdr_send (conn , "i" ,
362
382
(gfarm_int32_t )GFARM_AUTH_SASL_STEP_ERROR );
363
383
if (e == GFARM_ERR_NO_ERROR )
364
384
e = gfp_xdr_flush (conn );
365
- gflog_debug (GFARM_MSG_UNFIXED , "%s: %s: gfp_xdr_send: %s" ,
366
- diag , hostname , gfarm_error_string (e ));
385
+ if (e != GFARM_ERR_NO_ERROR )
386
+ gflog_debug (GFARM_MSG_UNFIXED ,
387
+ "%s: %s: gfp_xdr_send: %s" ,
388
+ diag , hostname , gfarm_error_string (e ));
367
389
sasl_dispose (& sasl_conn );
368
390
gfp_xdr_tls_reset (conn ); /* is this case graceful? */
369
- return (GFARM_ERR_AUTHENTICATION );
391
+ return (e != GFARM_ERR_NO_ERROR ? e : GFARM_ERR_AUTHENTICATION );
370
392
}
371
393
372
394
sasl_dispose (& sasl_conn ); /* user_id is freed here */
0 commit comments