]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
Move user privileges functions to user_ops.c, room access check functions to room_ops.c
[citadel.git] / citadel / user_ops.c
index 7f72befa7f12abe00aca67c8d403d5772c4c2fcc..7c7e226a779bb26b9198ce11b030ca97df025d1d 100644 (file)
@@ -4,18 +4,12 @@
  * Copyright (c) 1987-2011 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * modify it under the terms of the GNU General Public License, version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "sysdep.h"
@@ -375,7 +369,30 @@ void MailboxName(char *buf, size_t n, const struct ctdluser *who, const char *pr
 
 
 /*
- * Is the user currently logged in an Aide?
+ * Check to see if the specified user has Internet mail permission
+ * (returns nonzero if permission is granted)
+ */
+int CtdlCheckInternetMailPermission(struct ctdluser *who) {
+
+       /* Do not allow twits to send Internet mail */
+       if (who->axlevel <= AxProbU) return(0);
+
+       /* Globally enabled? */
+       if (config.c_restrict == 0) return(1);
+
+       /* User flagged ok? */
+       if (who->flags & US_INTERNET) return(2);
+
+       /* Admin level access? */
+       if (who->axlevel >= AxAideU) return(3);
+
+       /* No mail for you! */
+       return(0);
+}
+
+
+/*
+ * Is the user currently logged in an Admin?
  */
 int is_aide(void)
 {
@@ -387,7 +404,7 @@ int is_aide(void)
 
 
 /*
- * Is the user currently logged in an Aide *or* the room aide for this room?
+ * Is the user currently logged in an Admin *or* the room Admin for this room?
  */
 int is_room_aide(void)
 {
@@ -799,13 +816,6 @@ void CtdlUserLogout(void)
                abort_upl(CCC);
        }
 
-       /*
-        * If we were talking to a network node, we're not anymore...
-        */
-       if (!IsEmptyStr(CCC->net_node)) {
-               network_talking_to(CCC->net_node, strlen(CCC->net_node), NTT_REMOVE);
-       }
-
        /* Run any hooks registered by modules... */
        PerformSessionHooks(EVT_LOGOUT);
        
@@ -952,7 +962,6 @@ int CtdlTryPassword(const char *password, long len)
                CONM_syslog(LOG_INFO, "CtdlTryPassword: NULL password string supplied\n");
                return pass_wrong_password;
        }
-       code = (-1);
 
        if (CCC->is_master) {
                code = strcmp(password, config.c_master_pass);
@@ -1011,9 +1020,11 @@ int CtdlTryPassword(const char *password, long len)
                strproc(pw);
                strproc(CCC->user.password);
                code = strcasecmp(CCC->user.password, pw);
-               strproc(pw);
-               strproc(CCC->user.password);
-               code = strcasecmp(CCC->user.password, pw);
+               if (code != 0) {
+                       strproc(pw);
+                       strproc(CCC->user.password);
+                       code = strcasecmp(CCC->user.password, pw);
+               }
                free (pw);
        }
 
@@ -1601,7 +1612,7 @@ int CtdlInvtKick(char *iuser, int op) {
 void cmd_invt_kick(char *iuser, int op) {
 
        /*
-        * These commands are only allowed by aides, room aides,
+        * These commands are only allowed by admins, room admins,
         * and room namespace owners
         */
        if (is_room_aide()) {
@@ -1644,7 +1655,7 @@ void cmd_kick(char *iuser) {cmd_invt_kick(iuser, 0);}
 int CtdlForgetThisRoom(void) {
        visit vbuf;
 
-       /* On some systems, Aides are not allowed to forget rooms */
+       /* On some systems, Admins are not allowed to forget rooms */
        if (is_aide() && (config.c_aide_zap == 0)
           && ((CC->room.QRflags & QR_MAILBOX) == 0)  ) {
                return(1);