Changeset 060d066 for irc_commands.c
- Timestamp:
- 2011-02-01T13:05:58Z (13 years ago)
- Branches:
- master
- Children:
- da60f28
- Parents:
- 00fd005
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_commands.c
r00fd005 r060d066 397 397 } 398 398 399 399 static void irc_cmd_oper_hack( irc_t *irc, char **cmd ); 400 400 401 401 static void irc_cmd_oper( irc_t *irc, char **cmd ) 402 402 { 403 account_t *a; 404 405 /* /OPER can now also be used to enter IM passwords without echoing. 406 It's a hack but the extra password security is worth it. */ 407 for( a = irc->b->accounts; a; a = a->next ) 408 if( strcmp( a->pass, PASSWORD_PENDING ) == 0 ) 409 { 410 set_setstr( &a->set, "password", cmd[2] ); 411 irc_usermsg( irc, "Password added to IM account " 412 "%s(%s)", a->prpl->name, a->user ); 413 /* The IRC client may expect this. Report failure since 414 we didn't hand out a +o. */ 415 irc_send_num( irc, 491, ":Password added to IM account " 416 "%s(%s)", a->prpl->name, a->user ); 417 return; 418 } 403 /* Very non-standard evil but useful/secure hack, see below. */ 404 if( irc->status & OPER_HACK_ANY ) 405 return irc_cmd_oper_hack( irc, cmd ); 419 406 420 407 if( global.conf->oper_pass && … … 430 417 irc_send_num( irc, 491, ":Incorrect password" ); 431 418 } 419 } 420 421 static void irc_cmd_oper_hack( irc_t *irc, char **cmd ) 422 { 423 char *password = g_strjoinv( " ", cmd + 2 ); 424 425 /* /OPER can now also be used to enter IM/identify passwords without 426 echoing. It's a hack but the extra password security is worth it. */ 427 if( irc->status & OPER_HACK_ACCOUNT_ADD ) 428 { 429 account_t *a; 430 431 for( a = irc->b->accounts; a; a = a->next ) 432 if( strcmp( a->pass, PASSWORD_PENDING ) == 0 ) 433 { 434 set_setstr( &a->set, "password", password ); 435 irc_usermsg( irc, "Password added to IM account " 436 "%s(%s)", a->prpl->name, a->user ); 437 /* The IRC client may expect this. 491 suggests the OPER 438 password was wrong, so the client won't expect a +o. 439 It may however repeat the password prompt. We'll see. */ 440 irc_send_num( irc, 491, ":Password added to IM account " 441 "%s(%s)", a->prpl->name, a->user ); 442 } 443 } 444 else if( irc->status & OPER_HACK_IDENTIFY ) 445 { 446 char *send_cmd[] = { "identify", password, NULL }; 447 irc_send_num( irc, 491, ":Trying to identify" ); 448 root_command( irc, send_cmd ); 449 } 450 else if( irc->status & OPER_HACK_REGISTER ) 451 { 452 char *send_cmd[] = { "register", password, NULL }; 453 irc_send_num( irc, 491, ":Trying to identify" ); 454 root_command( irc, send_cmd ); 455 } 456 457 irc->status &= ~OPER_HACK_ANY; 458 g_free( password ); 432 459 } 433 460 … … 756 783 } 757 784 758 if( irc->status >=USTATUS_LOGGED_IN )785 if( irc->status & USTATUS_LOGGED_IN ) 759 786 irc_send_num( irc, 421, "%s :Unknown command", cmd[0] ); 760 787 }
Note: See TracChangeset
for help on using the changeset viewer.