Random fixes
authorJohn Hodge <[email protected]>
Tue, 22 Feb 2011 10:44:22 +0000 (18:44 +0800)
committerJohn Hodge <[email protected]>
Tue, 22 Feb 2011 10:44:22 +0000 (18:44 +0800)
src/client/main.c
src/cokebank_sqlite/main.c
src/server/server.c

index 88e82a8..5e131e8 100644 (file)
@@ -1524,7 +1524,9 @@ int Dispense_Give(int Socket, const char *Username, int Ammount, const char *Rea
        
        switch(responseCode)
        {
-       case 200:       return 0;       // OK
+       case 200:
+               printf("Give succeeded\n");
+               return 0;       // OK
        
        case 402:       
                fprintf(stderr, "Insufficient balance\n");
index 275d551..7237273 100644 (file)
@@ -102,7 +102,7 @@ int Bank_Initialise(const char *Argument)
                        return 1;
                }
                
-               Log_Info("SQLite database rebuilt");
+               Log_Info("SQLite database rebuilt (%s)", Argument);
        }
        else
        {
index 974efca..dbcc94b 100644 (file)
@@ -508,17 +508,20 @@ void Server_Cmd_SETEUSER(tClient *Client, char *Args)
        }
        
        // You can't be an internal account
-       eUserFlags = Bank_GetFlags(Client->EffectiveUID);
-       if( eUserFlags & USER_FLAG_INTERNAL ) {
-               Client->EffectiveUID = -1;
-               sendf(Client->Socket, "404 User not found\n");
-               return ;
-       }
-       // Disabled only avaliable to admins
-       if( (eUserFlags & USER_FLAG_DISABLED) && !(userFlags & USER_FLAG_ADMIN) ) {
-               Client->EffectiveUID = -1;
-               sendf(Client->Socket, "403 Account disabled\n");
-               return ;
+       if( !(userFlags & USER_FLAG_ADMIN) )
+       {
+               eUserFlags = Bank_GetFlags(Client->EffectiveUID);
+               if( eUserFlags & USER_FLAG_INTERNAL ) {
+                       Client->EffectiveUID = -1;
+                       sendf(Client->Socket, "404 User not found\n");
+                       return ;
+               }
+               // Disabled only avaliable to admins
+               if( eUserFlags & USER_FLAG_DISABLED ) {
+                       Client->EffectiveUID = -1;
+                       sendf(Client->Socket, "403 Account disabled\n");
+                       return ;
+               }
        }
        
        sendf(Client->Socket, "200 User set\n");
@@ -815,9 +818,13 @@ void Server_Cmd_ADD(tClient *Client, char *Args)
        }
        
        // You can't alter an internal account
-       if( Bank_GetFlags(uid) & USER_FLAG_INTERNAL ) {
-               sendf(Client->Socket, "404 Invalid user\n");
-               return ;
+       if( !(Bank_GetFlags(Client->UID) & USER_FLAG_ADMIN) )
+       {
+               if( Bank_GetFlags(uid) & USER_FLAG_INTERNAL ) {
+                       sendf(Client->Socket, "404 Invalid user\n");
+                       return ;
+               }
+               // TODO: Maybe disallow changes to disabled?
        }
 
        // Parse ammount
@@ -870,12 +877,6 @@ void Server_Cmd_SET(tClient *Client, char *Args)
                sendf(Client->Socket, "404 Invalid user\n");
                return ;
        }
-       
-       // You can't alter an internal account
-       if( Bank_GetFlags(uid) & USER_FLAG_INTERNAL ) {
-               sendf(Client->Socket, "404 Invalid user\n");
-               return ;
-       }
 
        // Parse ammount
        iAmmount = atoi(ammount);

UCC git Repository :: git.ucc.asn.au