Allowed transferring to/from disabled accounts
[tpg/opendispense2.git] / src / server / server.c
index 05ee547..9780058 100644 (file)
@@ -25,6 +25,8 @@
 #define        DEBUG_TRACE_CLIENT      0
 #define HACK_NO_REFUNDS        1
 
+#define PIDFILE        "/var/run/dispsrv.pid"
+
 // Statistics
 #define MAX_CONNECTION_QUEUE   5
 #define INPUT_BUFFER_SIZE      256
@@ -215,7 +217,7 @@ void Server_Start(void)
        
        // write pidfile
        {
-               FILE *fp = fopen("/var/run/dispsrv.pid", "w");
+               FILE *fp = fopen(PIDFILE, "w");
                if( fp ) {
                        fprintf(fp, "%i", getpid());
                        fclose(fp);
@@ -307,7 +309,7 @@ void Server_Cleanup(void)
 {
        printf("\nClose(%i)\n", giServer_Socket);
        close(giServer_Socket);
-       unlink("/var/run/dispsrv.pid");
+       unlink(PIDFILE);
 }
 
 /**
@@ -597,6 +599,7 @@ void Server_Cmd_AUTHIDENT(tClient *Client, char *Args)
        // Get username via IDENT
        username = ident_id(Client->Socket, ident_timeout);
        if( !username ) {
+               perror("AUTHIDENT - IDENT timed out");
                sendf(Client->Socket, "403 Authentication failure: IDENT auth timed out\n");
                return ;
        }
@@ -682,8 +685,7 @@ void Server_Cmd_SETEUSER(tClient *Client, char *Args)
                sendf(Client->Socket, "404 User not found\n");
                return ;
        }
-       
-       // You can't be an internal account
+       // You can't be an internal account (unless you're an admin)
        if( !(userFlags & USER_FLAG_ADMIN) )
        {
                eUserFlags = Bank_GetFlags(Client->EffectiveUID);
@@ -702,7 +704,7 @@ void Server_Cmd_SETEUSER(tClient *Client, char *Args)
 
        // Disabled accounts
        if( userFlags & USER_FLAG_DISABLED ) {
-               Client->UID = -1;
+               Client->EffectiveUID = -1;
                sendf(Client->Socket, "403 Account disabled\n");
                return ;
        }
@@ -730,7 +732,7 @@ void Server_int_SendItem(tClient *Client, tItem *Item)
                }
        }
        
-       if( Item->Price == 0 )
+       if( !gbNoCostMode && Item->Price == 0 )
                status = "error";
        // KNOWN HACK: Naming a slot 'dead' disables it
        if( strcmp(Item->Name, "dead") == 0 )
@@ -810,6 +812,8 @@ tItem *_GetItemFromString(char *String)
 
 /**
  * \brief Fetch information on a specific item
+ *
+ * Usage: ITEMINFO <item ID>
  */
 void Server_Cmd_ITEMINFO(tClient *Client, char *Args)
 {
@@ -830,6 +834,11 @@ void Server_Cmd_ITEMINFO(tClient *Client, char *Args)
        Server_int_SendItem( Client, item );
 }
 
+/**
+ * \brief Dispense an item
+ *
+ * Usage: DISPENSE <Item ID>
+ */
 void Server_Cmd_DISPENSE(tClient *Client, char *Args)
 {
        tItem   *item;
@@ -871,6 +880,11 @@ void Server_Cmd_DISPENSE(tClient *Client, char *Args)
        }
 }
 
+/**
+ * \brief Refund an item to a user
+ *
+ * Usage: REFUND <user> <item id> [<price>]
+ */
 void Server_Cmd_REFUND(tClient *Client, char *Args)
 {
        tItem   *item;
@@ -919,6 +933,11 @@ void Server_Cmd_REFUND(tClient *Client, char *Args)
        }
 }
 
+/**
+ * \brief Transfer money to another account
+ *
+ * Usage: GIVE <dest> <ammount> <reason...>
+ */
 void Server_Cmd_GIVE(tClient *Client, char *Args)
 {
        char    *recipient, *ammount, *reason;

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