]> jfr.im git - solanum.git/blobdiff - ircd/privilege.c
doc/reference.conf: document the auth::umodes configuration option
[solanum.git] / ircd / privilege.c
index 2f2c1cdef7b3fb1ac56a4af7c33998321133ca28..743d8f6424c4d6570debcb212897a19d5c3e7d4d 100644 (file)
@@ -19,7 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  * USA
  *
- * Copyright (c) 2008 William Pitcock <nenolod@dereferenced.org>
+ * Copyright (c) 2008 Ariadne Conill <ariadne@dereferenced.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -91,11 +91,10 @@ privilegeset_index(struct PrivilegeSet *set)
        set->privs[set->size] = NULL;
 }
 
-static void
+void
 privilegeset_add_privs(struct PrivilegeSet *dst, const char *privs)
 {
-       size_t alloc_size;
-       size_t n;
+       size_t alloc_size, old_stored_size;
 
        if (dst->priv_storage == NULL)
        {
@@ -107,6 +106,7 @@ privilegeset_add_privs(struct PrivilegeSet *dst, const char *privs)
                alloc_size = dst->allocated_size;
        }
 
+       old_stored_size = dst->stored_size;
        dst->stored_size += strlen(privs) + 1;
 
        while (alloc_size < dst->stored_size)
@@ -119,14 +119,17 @@ privilegeset_add_privs(struct PrivilegeSet *dst, const char *privs)
 
        const char *s;
        char *d;
-       for (s = privs, d = dst->priv_storage; s < privs + strlen(privs); s += n , d += n)
-       {
-               const char *e = strchr(s, ' ');
-               /* up to space if there is one, else up to end of string */
-               n = 1 + (e != NULL ? e - s : strlen(s));
-               rb_strlcpy(d, s, n);
 
-               dst->size += 1;
+       for (s = privs, d = dst->priv_storage + old_stored_size;
+                       s <= privs + strlen(privs);
+                       s++, d++)
+       {
+               *d = *s;
+               if (*d == ' ' || *d == '\0')
+               {
+                       *d = '\0';
+                       if (s > privs) dst->size += 1;
+               }
        }
 
        privilegeset_index(dst);