miscellaneous bugfixes and indentation fixes
authorMichael Poole <mdpoole@troilus.org>
Thu, 1 Jul 2004 02:23:21 +0000 (02:23 +0000)
committerMichael Poole <mdpoole@troilus.org>
Thu, 1 Jul 2004 02:23:21 +0000 (02:23 +0000)
* srvx.conf.example: Clarify comment about "default_hostmask" setting.

* patches/sethost13.diff: Forward port of sethost patch, from Reed Loden.

* src/opserv.c (cmd_kickbanall): Free mod_chanmode_change after use.

* src/proto-p10.c (cmd_whois): Fix indentation and show real server to opers.

* src/tools.c (string_buffer_append_vprintf): Avoid a possible buffer overrun.
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-70

ChangeLog
patches/sethost13.diff [new file with mode: 0644]
src/opserv.c
src/proto-common.c
src/proto-p10.c
src/tools.c
srvx.conf.example

index fc973e8b39521e03ca9d0a851a7533d135c30ad0..5e8a78e6a8cb8de0ad851a8711d650d6fbac59f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,71 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3
 #
 
+2004-07-01 02:23:21 GMT        Michael Poole <mdpoole@troilus.org>     patch-70
+
+    Summary:
+      miscellaneous bugfixes and indentation fixes
+    Revision:
+      srvx--devo--1.3--patch-70
+
+    * srvx.conf.example: Clarify comment about "default_hostmask" setting.
+    
+    * patches/sethost13.diff: Forward port of sethost patch, from Reed Loden.
+    
+    * src/opserv.c (cmd_kickbanall): Free mod_chanmode_change after use.
+    
+    * src/proto-p10.c (cmd_whois): Fix indentation and show real server to opers.
+    
+    * src/tools.c (string_buffer_append_vprintf): Avoid a possible buffer overrun.
+
+    new files:
+     patches/.arch-ids/sethost13.diff.id patches/sethost13.diff
+
+    modified files:
+     ChangeLog INSTALL Makefile.am NEWS README compile configure.in
+     depcomp docs/access-levels.txt docs/coding-style.txt
+     docs/cookies.txt docs/helpserv.txt docs/ircd-modes.txt
+     docs/malloc-compare.txt languages/.arch-inventory
+     languages/de/README languages/de/chanserv.help
+     languages/de/global.help languages/de/modcmd.help
+     languages/de/nickserv.help languages/de/strings.db
+     languages/en/README languages/en_UK/README
+     languages/en_UK/chanserv.help languages/en_UK/opserv.help
+     languages/en_UK/strings.db languages/validate.pl
+     patches/helpserv-pgsql.diff sockcheck.conf.example
+     src/Makefile.am src/chanserv.c src/chanserv.h
+     src/chanserv.help src/common.h src/conf.c src/conf.h
+     src/dict-splay.c src/gline.c src/gline.h src/global.c
+     src/global.h src/global.help src/hash.c src/hash.h src/heap.c
+     src/heap.h src/helpfile.c src/helpfile.h src/ioset.c
+     src/ioset.h src/log.h src/main.c src/mod-helpserv.c
+     src/mod-memoserv.c src/mod-snoop.c src/modcmd.c src/modcmd.h
+     src/modules.c src/modules.h src/nickserv.c src/nickserv.h
+     src/nickserv.help src/opserv.c src/opserv.h src/opserv.help
+     src/policer.c src/policer.h src/proto-bahamut.c
+     src/proto-common.c src/proto-p10.c src/proto.h src/recdb.c
+     src/recdb.h src/saxdb.c src/saxdb.h src/saxdb.help
+     src/sendmail.c src/sendmail.h src/timeq.c src/timeq.h
+     src/tools.c srvx.conf.example tests/nickserv.cmd tests/p10.cmd
+     tests/test-driver.pl tests/test.cmd
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-10
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-14
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-18
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-34
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-43
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-46
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-57
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-58
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-61
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-62
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-63
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-68
+     {arch}/srvx/srvx--devo/srvx--devo--1.3/srvx@srvx.net--2004-srvx/patch-log/patch-69
+
+    modified directories:
+     languages/en_UK
+
+
 2004-06-16 12:23:32 GMT        adam <adam@gamesurge.net>       patch-69
 
     Summary:
diff --git a/patches/sethost13.diff b/patches/sethost13.diff
new file mode 100644 (file)
index 0000000..e7fc546
--- /dev/null
@@ -0,0 +1,206 @@
+diff -purN -x {arch} srvx-1.3/src/hash.h srvx-1.3~reed-sethost/src/hash.h
+--- srvx-1.3/src/hash.h        2004-05-24 16:51:58.000000000 -0600
++++ srvx-1.3~reed-sethost/src/hash.h   2004-05-22 20:01:21.000000000 -0600
+@@ -51,7 +51,11 @@
+ #define FLAGS_DEAF            0x0020 /* deaf +d */
+ #define FLAGS_SERVICE         0x0040 /* cannot be kicked, killed or deoped +k */
+ #define FLAGS_GLOBAL          0x0080 /* receives global messages +g */
+-#define FLAGS_HELPER          0x0100 /* (network?) helper +h */
++
++// sethost - reed/apples
++// #define FLAGS_HELPER               0x0100 /* (network?) helper +h */
++#define FLAGS_SETHOST         0x0100 /* sethost +h */
++
+ #define FLAGS_PERSISTENT      0x0200 /* for reserved nicks, this isn't just one-shot */
+ #define FLAGS_GAGGED          0x0400 /* for gagged users */
+ #define FLAGS_AWAY            0x0800 /* for away users */
+@@ -67,7 +71,11 @@
+ #define IsGlobal(x)             ((x)->modes & FLAGS_GLOBAL)
+ #define IsWallOp(x)             ((x)->modes & FLAGS_WALLOP)
+ #define IsServNotice(x)         ((x)->modes & FLAGS_SERVNOTICE)
+-#define IsHelperIrcu(x)         ((x)->modes & FLAGS_HELPER)
++
++// sethost - reed/apples
++// #define IsHelperIrcu(x)         ((x)->modes & FLAGS_HELPER)
++#define IsSetHost(x)          ((x)->modes & FLAGS_SETHOST)
++
+ #define IsGagged(x)             ((x)->modes & FLAGS_GAGGED)
+ #define IsPersistent(x)         ((x)->modes & FLAGS_PERSISTENT) 
+ #define IsAway(x)               ((x)->modes & FLAGS_AWAY)
+@@ -111,6 +119,9 @@ struct userNode {
+     struct in_addr ip;            /* User's IP address */
+     long modes;                   /* user flags +isw etc... */
++    // sethost - reed/apples
++    char sethost[USERLEN + HOSTLEN + 2]; /* 1 for '\0' and 1 for @ = 2 */
++
+     time_t timestamp;             /* Time of last nick change */
+     struct server *uplink;        /* Server that user is connected to */
+     struct modeList channels;     /* Vector of channels user is in */
+diff -purN -x {arch} srvx-1.3/src/opserv.c srvx-1.3~reed-sethost/src/opserv.c
+--- srvx-1.3/src/opserv.c      2004-05-24 16:51:58.000000000 -0600
++++ srvx-1.3~reed-sethost/src/opserv.c 2004-05-22 20:01:21.000000000 -0600
+@@ -1180,7 +1180,11 @@ static MODCMD_FUNC(cmd_whois)
+       if (IsOper(target)) buffer[bpos++] = 'o';
+       if (IsGlobal(target)) buffer[bpos++] = 'g';
+       if (IsServNotice(target)) buffer[bpos++] = 's';
+-      if (IsHelperIrcu(target)) buffer[bpos++] = 'h';
++
++      // sethost - reed/apples
++      // if (IsHelperIrcu(target)) buffer[bpos++] = 'h';
++      if (IsSetHost(target)) buffer[bpos++] = 'h';
++
+       if (IsService(target)) buffer[bpos++] = 'k';
+       if (IsDeaf(target)) buffer[bpos++] = 'd';
+         if (IsHiddenHost(target)) buffer[bpos++] = 'x';
+diff -purN -x {arch} srvx-1.3/src/proto-common.c srvx-1.3~reed-sethost/src/proto-common.c
+--- srvx-1.3/src/proto-common.c        2004-05-24 16:51:58.000000000 -0600
++++ srvx-1.3~reed-sethost/src/proto-common.c   2004-05-22 20:01:21.000000000 -0600
+@@ -662,14 +662,27 @@ generate_hostmask(struct userNode *user,
+     else
+         nickname = "*";
+     if (options & GENMASK_STRICT_IDENT)
++        // sethost - reed/apples
++        if (IsSetHost(user)) {
++          ident = alloca(strcspn(user->sethost, "@")+2);
++          safestrncpy(ident, user->sethost, strcspn(user->sethost, "@")+1);
++        }
++        else
+         ident = user->ident;
+     else if (options & GENMASK_ANY_IDENT)
+         ident = "*";
+     else {
++        // sethost - reed/apples
++        if (IsSetHost(user)) {
++          ident = alloca(strcspn(user->sethost, "@")+3);
++          ident[0] = '*';
++          safestrncpy(ident+1, user->sethost, strcspn(user->sethost, "@")+1);
++        } else {
+         ident = alloca(strlen(user->ident)+2);
+         ident[0] = '*';
+         strcpy(ident+1, user->ident + ((*user->ident == '~')?1:0));
+     }
++    }
+     hostname = user->hostname;
+     if (IsFakeHost(user) && IsHiddenHost(user) && !(options & GENMASK_NO_HIDING)) {
+         hostname = user->fakehost;
+@@ -727,6 +740,10 @@ generate_hostmask(struct userNode *user,
+             sprintf(hostname, "*.%s", user->hostname+ii+2);
+         }
+     }
++    // sethost - reed/apples
++    if (IsSetHost(user)) 
++      hostname = strchr(user->sethost, '@') + 1;
++
+     /* Emit hostmask */
+     len = strlen(ident) + strlen(hostname) + 2;
+     if (nickname) {
+diff -purN -x {arch} srvx-1.3/src/proto-p10.c srvx-1.3~reed-sethost/src/proto-p10.c
+--- srvx-1.3/src/proto-p10.c   2004-05-24 16:51:58.000000000 -0600
++++ srvx-1.3~reed-sethost/src/proto-p10.c      2004-05-22 20:58:36.000000000 -0600
+@@ -400,8 +400,12 @@ irc_user(struct userNode *user)
+             modes[modelen++] = 'd';
+         if (IsGlobal(user))
+             modes[modelen++] = 'g';
+-        if (IsHelperIrcu(user))
++        // sethost - reed/apples
++        // if (IsHelperIrcu(user))
++        if (IsSetHost(user))
+             modes[modelen++] = 'h';
++        if (IsFakeHost(user))
++            modes[modelen++] = 'f';
+         if (IsHiddenHost(user))
+             modes[modelen++] = 'x';
+         modes[modelen] = 0;
+@@ -1099,6 +1103,8 @@ static CMD_FUNC(cmd_mode)
+ {
+     struct chanNode *cn;
+     struct userNode *un;
++    char *sethost; // sethost - reed/apples
++    int i; // sethost - reed/apples
+     if (argc < 3)
+         return 0;
+@@ -1108,7 +1114,19 @@ static CMD_FUNC(cmd_mode)
+             log_module(MAIN_LOG, LOG_ERROR, "Unable to find user %s whose mode is changing.", argv[1]);
+             return 0;
+         }
++        // sethost - reed/apples
++        if (argc == 3)
+         mod_usermode(un, argv[2]);
++        else {
++          sethost = malloc(strlen(argv[2]) + 1 + strlen(argv[3]) + 1);
++          i = 0;
++          while((sethost[i++] = *argv[2]++));
++          i--;
++         sethost[i++] = ' ';
++          while((sethost[i++] = *argv[3]++));
++          mod_usermode(un, sethost); // sethost - reed/apples
++        }
++
+         return 1;
+     }
+@@ -2018,7 +2036,22 @@ void mod_usermode(struct userNode *user,
+       case 'd': do_user_mode(FLAGS_DEAF); break;
+       case 'k': do_user_mode(FLAGS_SERVICE); break;
+       case 'g': do_user_mode(FLAGS_GLOBAL); break;
+-      case 'h': do_user_mode(FLAGS_HELPER); break;
++      // sethost - reed/apples
++      // case 'h': do_user_mode(FLAGS_HELPER); break;
++      // I check if there's an 'h' in the first part, and if there, 
++      // then everything after the space becomes their new host.
++      case 'h': do_user_mode(FLAGS_SETHOST);
++          if (*word) {
++              char sethost[MAXLEN];
++              unsigned int ii;
++              for (ii=0; (*word != ' ') && (*word != '\0'); )
++                  sethost[ii++] = *word++;
++              sethost[ii] = 0;
++              while (*word == ' ')
++                  word++;
++              safestrncpy(user->sethost, sethost, sizeof(user->sethost));
++          }
++          break;
+         case 'x': do_user_mode(FLAGS_HIDDEN_HOST); break;
+         case 'r':
+             if (*word) {
+diff -purN -x {arch} srvx-1.3/src/tools.c srvx-1.3~reed-sethost/src/tools.c
+--- srvx-1.3/src/tools.c       2004-05-24 16:51:58.000000000 -0600
++++ srvx-1.3~reed-sethost/src/tools.c  2004-05-22 21:10:26.000000000 -0600
+@@ -311,6 +311,7 @@ int
+ user_matches_glob(struct userNode *user, const char *orig_glob, int include_nick)
+ {
+     char *glob, *marker;
++    char *setident = NULL, *sethostname = NULL; // sethost - reed/apples
+     /* Make a writable copy of the glob */
+     glob = alloca(strlen(orig_glob)+1);
+@@ -331,8 +332,16 @@ user_matches_glob(struct userNode *user,
+         return 0;
+     }
+     *marker = 0;
+-    if (!match_ircglob(user->ident, glob))
+-        return 0;
++
++    // sethost - reed/apples
++    if (IsSetHost(user)) {
++      setident = alloca(strcspn(user->sethost, "@")+2);
++      safestrncpy(setident, user->sethost, strcspn(user->sethost, "@")+1);
++      sethostname = strchr(user->sethost, '@') + 1;
++    }
++
++    if (!match_ircglob(user->ident, glob) && (IsSetHost(user) && !match_ircglob(setident, glob)))
++      return 0;
+     glob = marker + 1;
+     /* Now check the host part */
+     if (isdigit(*glob) && !glob[strspn(glob, "0123456789./*?")]) {
+@@ -340,6 +349,8 @@ user_matches_glob(struct userNode *user,
+         return match_ircglob(inet_ntoa(user->ip), glob);
+     } else {
+         /* The host part of the mask isn't IP-based */
++        if (IsSetHost(user) && match_ircglob(sethostname, glob))
++                return 1;
+         if (IsFakeHost(user) && match_ircglob(user->fakehost, glob))
+                 return 1;
+         if (hidden_host_suffix && user->handle_info) {
index 0a3ac77767078e0cf7ee0a440282b1ecc124ed00..26dab12415b486e4941e7de64899ffd4fd46fc0b 100644 (file)
@@ -1047,6 +1047,7 @@ static MODCMD_FUNC(cmd_kickbanall)
         change->args[0].hostmask = "*!*@*";
     }
     modcmd_chanmode_announce(change);
+    mod_chanmode_free(change);
     if (argc < 2) {
        reason = alloca(strlen(OSMSG_KICK_REQUESTED)+strlen(user->nick)+1);
        sprintf(reason, OSMSG_KICK_REQUESTED, user->nick);
index 35fc9bde2dbe7e5298db7dc812c8e9916625f357..1b8c2f588340c7f574e8d7af1b350d900d4c254a 100644 (file)
@@ -638,7 +638,8 @@ mod_chanmode(struct userNode *who, struct chanNode *channel, char **modes, unsig
 }
 
 int
-irc_make_chanmode(struct chanNode *chan, char *out) {
+irc_make_chanmode(struct chanNode *chan, char *out)
+{
     struct mod_chanmode change;
     mod_chanmode_init(&change);
     change.modes_set = chan->modes;
index 8e5bc3ef4a8dfd07a38c9597a887b8f038315d66..6dfe841d7bdd21548595ed60fe233f193fe75cdd 100644 (file)
@@ -782,13 +782,11 @@ static CMD_FUNC(cmd_whois)
     }
     irc_numeric(from, RPL_WHOISUSER, "%s %s %s * :%s", who->nick, who->ident, who->hostname, who->info);
     if (his_servername && his_servercomment)
-      irc_numeric(from, RPL_WHOISSERVER, "%s %s :%s", who->nick, his_servername, his_servercomment);
+        irc_numeric(from, RPL_WHOISSERVER, "%s %s :%s", who->nick, his_servername, his_servercomment);
     else
-    irc_numeric(from, RPL_WHOISSERVER, "%s %s :%s", who->nick, who->uplink->name, who->uplink->description);
-
-    if (IsOper(who)) {
+        irc_numeric(from, RPL_WHOISSERVER, "%s %s :%s", who->nick, who->uplink->name, who->uplink->description);
+    if (IsOper(who))
         irc_numeric(from, RPL_WHOISOPERATOR, "%s :is a megalomaniacal power hungry tyrant", who->nick);
-    }
     irc_numeric(from, RPL_ENDOFWHOIS, "%s :End of /WHOIS list", who->nick);
     return 1;
 }
@@ -800,7 +798,7 @@ static CMD_FUNC(cmd_server)
 
     if (argc < 8)
         return 0;
-    if (origin) {
+    if (self->uplink) {
         /* another server introduced us */
         srv = AddServer(GetServerH(origin), argv[1], atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), argv[6], argv[argc-1]);
         if (!srv)
@@ -1989,8 +1987,8 @@ void mod_usermode(struct userNode *user, const char *mode_change) {
 
     if (!user || !mode_change)
         return;
-    while (*word != ' ' && *word) word++;\
-    while (*word == ' ') word++; \
+    while (*word != ' ' && *word) word++;
+    while (*word == ' ') word++;
     while (1) {
 #define do_user_mode(FLAG) do { if (add) user->modes |= FLAG; else user->modes &= ~FLAG; } while (0)
        switch (*mode_change++) {
index 161e9d2bd9e4e2b8bbe9cded2fa7d20fdc461792..53214dc56775256348582b1548debfd660db497b 100644 (file)
@@ -341,7 +341,7 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int include_nick
     } else {
         /* The host part of the mask isn't IP-based */
         if (IsFakeHost(user) && match_ircglob(user->fakehost, glob))
-                return 1;
+            return 1;
         if (hidden_host_suffix && user->handle_info) {
             char hidden_host[HOSTLEN+1];
             snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix);
@@ -746,7 +746,7 @@ string_buffer_append_vprintf(struct string_buffer *buf, const char *fmt, va_list
         /* pre-C99 behavior; double buffer size until it is big enough */
         va_end(working);
         VA_COPY(working, args);
-        while ((ret = vsnprintf(buf->list + buf->used, buf->size, fmt, working)) == -1) {
+        while ((ret = vsnprintf(buf->list + buf->used, buf->size - buf->used, fmt, working)) <= 0) {
             buf->size += len;
             buf->list = realloc(buf->list, buf->size);
             va_end(working);
index bab5e6a19cbad5f0052cf052ee70f9e253d662e7..28b97903b92a65b6ef4881127d3c5c416d7d401a 100644 (file)
@@ -47,8 +47,9 @@
        // mind which ircd software you are using here, and that all of the
        // services need to be at least +o.
        // "modes" "+iok";
-        // If you want to by have *@* as the default hostmask, set
-        // default_hostmask.  This is discouraged for security reasons.
+        // If you want to by have *@* as the default hostmask for all
+        // new accounts, set default_hostmask.  This is discouraged
+        // for security reasons.
         // "default_hostmask" "1";
         // do we warn users when someone new auths to their account?
         "warn_clone_auth" "1";