chiark / gitweb /
client.c remembers last response string
[disorder] / server / server.c
index a69c45194a285815a7184de59d69d5ab3739c77c..8d49193acded8acdc4c7ff8ef91fcaf40c0771c6 100644 (file)
@@ -66,7 +66,7 @@
 #include "cache.h"
 #include "unicode.h"
 #include "cookies.h"
-#include "mime.h"
+#include "base64.h"
 
 #ifndef NONCE_SIZE
 # define NONCE_SIZE 16
@@ -248,7 +248,7 @@ static int c_remove(struct conn *c, char **vec,
     r = RIGHT_REMOVE_RANDOM;
   if(!(c->rights & r)) {
     sink_writes(ev_writer_sink(c->w),
-               "550 Not authorized to remove that track\n");
+               "510 Not authorized to remove that track\n");
     return 1;
   }
   queue_remove(q, c->who);
@@ -286,7 +286,7 @@ static int c_scratch(struct conn *c,
     r = RIGHT_SCRATCH_RANDOM;
   if(!(c->rights & r)) {
     sink_writes(ev_writer_sink(c->w),
-               "550 Not authorized to scratch that track\n");
+               "510 Not authorized to scratch that track\n");
     return 1;
   }
   scratch(c->who, nvec == 1 ? vec[0] : 0);
@@ -754,7 +754,7 @@ static int c_volume(struct conn *c,
   }
   rights = set ? RIGHT_VOLUME : RIGHT_READ;
   if(!(c->rights & rights)) {
-    sink_writes(ev_writer_sink(c->w), "530 Prohibited\n");
+    sink_writes(ev_writer_sink(c->w), "510 Prohibited\n");
     return 1;
   }
   if(mixer_control(&l, &r, set))
@@ -877,7 +877,7 @@ static int c_move(struct conn *c,
   }
   if(!has_move_rights(c, &q, 1)) {
     sink_writes(ev_writer_sink(c->w),
-               "550 Not authorized to move that track\n");
+               "510 Not authorized to move that track\n");
     return 1;
   }
   n = queue_move(q, atoi(vec[1]), c->who);
@@ -911,7 +911,7 @@ static int c_moveafter(struct conn *c,
     }
   if(!has_move_rights(c, qs, nvec)) {
     sink_writes(ev_writer_sink(c->w),
-               "550 Not authorized to move those tracks\n");
+               "510 Not authorized to move those tracks\n");
     return 1;
   }
   queue_moveafter(q, nvec, qs, c->who);
@@ -1041,14 +1041,15 @@ static int c_cookie(struct conn *c,
     return 1;
   }
   /* Log in */
-  c->who = vec[0];
+  c->who = user;
   c->cookie = vec[0];
   c->rights = rights;
   if(strcmp(host, "local")) {
     info("S%x %s connected with cookie from %s", c->tag, user, host);
     c->rights |= RIGHT__LOCAL;
   }
-  sink_writes(ev_writer_sink(c->w), "230 OK\n");
+  /* Response contains username so client knows who they are acting as */
+  sink_printf(ev_writer_sink(c->w), "232 %s\n", quoteutf8(user));
   return 1;
 }
 
@@ -1120,7 +1121,7 @@ static int c_edituser(struct conn *c,
     else
       sink_writes(ev_writer_sink(c->w), "250 OK\n");
   } else
-    sink_writes(ev_writer_sink(c->w), "550 Restricted to administrators\n");
+    sink_writes(ev_writer_sink(c->w), "510 Restricted to administrators\n");
   return 1;
 }
 
@@ -1144,7 +1145,7 @@ static int c_userinfo(struct conn *c,
     else
       sink_writes(ev_writer_sink(c->w), "550 No such user\n");
   } else
-    sink_writes(ev_writer_sink(c->w), "550 Restricted to administrators\n");
+    sink_writes(ev_writer_sink(c->w), "510 Restricted to administrators\n");
   return 1;
 }
 
@@ -1308,7 +1309,7 @@ static int command(struct conn *c, char *line) {
   else {
     if(commands[n].rights
        && !(c->rights & commands[n].rights)) {
-      sink_writes(ev_writer_sink(c->w), "530 Prohibited\n");
+      sink_writes(ev_writer_sink(c->w), "510 Prohibited\n");
       return 1;
     }
     ++vec;