Merge branch 'master' of git://mutabah.net/opendispense2
[tpg/opendispense2.git] / src / server / dispense.c
index 52d978c..3fb5652 100644 (file)
@@ -3,6 +3,7 @@
 #include "common.h"
 #include <stdlib.h>
 #include <limits.h>
+#include <string.h>
 
  int   _GetMinBalance(int Account);
  int   _CanTransfer(int Source, int Destination, int Ammount);
@@ -179,14 +180,27 @@ int _GetMinBalance(int Account)
 {
         int    flags = Bank_GetFlags(Account);
        
+       // Evil little piece of HACK:
+       // root's balance cannot be changed by any of the above functions
+       // - Stops dispenses as root by returning insufficent balance.
+       {
+               char    *username = Bank_GetAcctName(Account);
+               if( strcmp(username, "root") == 0 )
+               {
+                       free(username);
+                       return INT_MAX;
+               }
+               free(username);
+       }
+       
        // - Internal accounts have no lower bound
        if( flags & USER_FLAG_INTERNAL )        return INT_MIN;
        
        // Admin to -$10
-       if( flags & USER_FLAG_ADMIN )   return -1000;
+       //if( flags & USER_FLAG_ADMIN ) return -1000;
        
        // Coke to -$5
-       if( flags & USER_FLAG_COKE )    return -500;
+       //if( flags & USER_FLAG_COKE )  return -500;
        
        // Anyone else, non-negative
        return 0;

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