]> jfr.im git - solanum.git/blobdiff - modules/m_privs.c
chmode: Get elevated access for op-only queries
[solanum.git] / modules / m_privs.c
index 7ff25a6b89327118d79cc0151a07e8a300397dd8..29e141ae0ced1c4e5836cea9b9c133f5d74bf9cf 100644 (file)
@@ -106,8 +106,13 @@ static void show_privs(struct Client *source_p, struct Client *target_p)
        buf[0] = '\0';
 
        if (target_p->user->privset)
-               for (const char *s = strtok(target_p->user->privset->privs, " "); s != NULL; s = strtok(NULL, " "))
+               for (char *s = target_p->user->privset->privs; s != NULL; (s = strchr(s, ' ')) && s++)
+               {
+                       char *c = strchr(s, ' ');
+                       if (c) *c = '\0';
                        append_priv(source_p, target_p, buf, s, "");
+                       if (c) *c = ' ';
+               }
 
        if (IsOper(target_p))
        {
@@ -172,6 +177,13 @@ mo_privs(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
                }
        }
 
+       if (target_p != source_p && !HasPrivilege(source_p, "oper:privs"))
+       {
+               sendto_one(source_p, form_str(ERR_NOPRIVS),
+                          me.name, source_p->name, "privs");
+               return;
+       }
+
        if (!IsServer(server_p))
                server_p = server_p->servptr;