Thread: [srvx-commits] CVS: services/src hash.h,1.86,1.87 helpserv.c,1.23,1.24 nickserv.c,1.194,1.195 proto-
Brought to you by:
entrope
|
From: Adrian D. <sai...@us...> - 2002-08-13 03:04:13
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv32127
Modified Files:
hash.h helpserv.c nickserv.c proto-bahamut.c proto-p10.c
proto.h
Log Message:
Remove now-invalid IsNickName from hash.h
Have HelpServ check bots nicks against the per-proto is_valid_nick()
Have HelpServ check the result of creating its user
Rename nickserv.c:is_valid_nick to is_registerable_nick, and have it check the per-proto is_valid_nick()
Make per-proto is_valid_nick() an exported function
Index: hash.h
===================================================================
RCS file: /cvsroot/srvx/services/src/hash.h,v
retrieving revision 1.86
retrieving revision 1.87
diff -C2 -r1.86 -r1.87
*** hash.h 11 Aug 2002 03:26:16 -0000 1.86
--- hash.h 13 Aug 2002 03:04:07 -0000 1.87
***************
*** 186,194 ****
void reg_server_link_func(server_link_func_t handler);
- #define IsNickName(x) ( \
- (isalpha(*(x)) || \
- ((*(x) >= 0x5B) && (*(x) <= 0x60)) || \
- ((*(x) >= 0x7B) && (*(x) <= 0x7D))) && \
- !strcspn((x)+1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789[]\\`_^{|}"))
typedef int (*new_user_func_t) (struct userNode *user);
void reg_new_user_func(new_user_func_t handler);
--- 186,189 ----
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** helpserv.c 11 Aug 2002 03:26:16 -0000 1.23
--- helpserv.c 13 Aug 2002 03:04:07 -0000 1.24
***************
*** 142,145 ****
--- 142,146 ----
#define HSMSG_REG_SUCCESS "%s now has ownership of bot %s."
#define HSMSG_NEED_UNREG_CONFIRM "To unregister this bot, you must /msg $S unregister CONFIRM"
+ #define HSMSG_ERROR_ADDING_SERVICE "Error creating new user $b%s$b"
/* Rename */
***************
*** 1754,1758 ****
REQUIRE_PARMS(2);
! if (IsNickName(argv[1])) {
char *newnick = argv[1], *oldnick, *reason;
--- 1755,1759 ----
REQUIRE_PARMS(2);
! if (is_valid_nick(argv[1])) {
char *newnick = argv[1], *oldnick, *reason;
***************
*** 2109,2113 ****
hs = calloc(1, sizeof(struct helpserv_bot));
! hs->helpserv = AddService(nick, helpserv_conf.description);
reg_privmsg_func(hs->helpserv, helpserv_botmsg);
--- 2110,2118 ----
hs = calloc(1, sizeof(struct helpserv_bot));
! if (!(hs->helpserv = AddService(nick, helpserv_conf.description))) {
! free(hs);
! return NULL;
! }
!
reg_privmsg_func(hs->helpserv, helpserv_botmsg);
***************
*** 2151,2155 ****
REQUIRE_PARMS(4);
nick = argv[1];
! if (!IsNickName(nick)) {
helpserv_notice(user, HSMSG_ILLEGAL_NICK, nick);
return 0;
--- 2156,2160 ----
REQUIRE_PARMS(4);
nick = argv[1];
! if (!is_valid_nick(nick)) {
helpserv_notice(user, HSMSG_ILLEGAL_NICK, nick);
return 0;
***************
*** 2171,2175 ****
if (!(handle = helpserv_get_handle_info(user, argv[3]))) return 0;
! hs = register_helpserv(nick, helpchan, user->handle_info->handle);
hs->registered = now;
helpserv_add_user(hs, handle, HlOwner);
--- 2176,2184 ----
if (!(handle = helpserv_get_handle_info(user, argv[3]))) return 0;
! if (!(hs = register_helpserv(nick, helpchan, user->handle_info->handle))) {
! helpserv_notice(user, HSMSG_ERROR_ADDING_SERVICE, nick);
! return 0;
! }
!
hs->registered = now;
helpserv_add_user(hs, handle, HlOwner);
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -C2 -r1.194 -r1.195
*** nickserv.c 11 Aug 2002 03:26:16 -0000 1.194
--- nickserv.c 13 Aug 2002 03:04:07 -0000 1.195
***************
*** 531,537 ****
static int
! is_valid_nick(const char *nick)
{
struct userNode *user;
/* cant register a juped nick/service nick.. client could kill it. */
user = GetUserH(nick);
--- 531,539 ----
static int
! is_registerable_nick(const char *nick)
{
struct userNode *user;
+ /* first, check that the nick is acceptible by the server */
+ if (!is_valid_nick(nick)) return 0;
/* cant register a juped nick/service nick.. client could kill it. */
user = GetUserH(nick);
***************
*** 1553,1557 ****
if (is_valid_oper(user, 0, 1)) {
nick = (argc < 2) ? user->nick : (char*)argv[1];
! if (!is_valid_nick(nick)) {
nickserv_notice(user, NSMSG_BAD_NICK, nick);
return 0;
--- 1555,1559 ----
if (is_valid_oper(user, 0, 1)) {
nick = (argc < 2) ? user->nick : (char*)argv[1];
! if (!is_registerable_nick(nick)) {
nickserv_notice(user, NSMSG_BAD_NICK, nick);
return 0;
***************
*** 1568,1572 ****
} else {
nick = user->nick;
! if (!is_valid_nick(nick)) {
nickserv_notice(user, NSMSG_BAD_NICK, nick);
return 0;
--- 1570,1574 ----
} else {
nick = user->nick;
! if (!is_registerable_nick(nick)) {
nickserv_notice(user, NSMSG_BAD_NICK, nick);
return 0;
Index: proto-bahamut.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-bahamut.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** proto-bahamut.c 8 Aug 2002 02:15:58 -0000 1.13
--- proto-bahamut.c 13 Aug 2002 03:04:07 -0000 1.14
***************
*** 94,98 ****
}
! static int
is_valid_nick(const unsigned char *nick) {
/* IRC has some of The Most Fucked-Up ideas about character sets
--- 94,98 ----
}
! int
is_valid_nick(const unsigned char *nick) {
/* IRC has some of The Most Fucked-Up ideas about character sets
Index: proto-p10.c
===================================================================
RCS file: /cvsroot/srvx/services/src/proto-p10.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** proto-p10.c 10 Aug 2002 00:49:04 -0000 1.15
--- proto-p10.c 13 Aug 2002 03:04:07 -0000 1.16
***************
*** 1544,1548 ****
}
! static int
is_valid_nick(const unsigned char *nick) {
/* IRC has some of The Most Fucked-Up ideas about character sets
--- 1544,1548 ----
}
! int
is_valid_nick(const unsigned char *nick) {
/* IRC has some of The Most Fucked-Up ideas about character sets
Index: proto.h
===================================================================
RCS file: /cvsroot/srvx/services/src/proto.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -r1.59 -r1.60
*** proto.h 8 Aug 2002 02:15:58 -0000 1.59
--- proto.h 13 Aug 2002 03:04:07 -0000 1.60
***************
*** 164,167 ****
--- 164,168 ----
/* stuff originally from other headers that is really protocol-specific */
+ int is_valid_nick(const unsigned char *nick);
struct userNode *AddService(const char *nick, const char *desc);
struct userNode *AddClone(const char *nick, const char *ident, const char *hostname, const char *desc);
|