Disallow op with no fingerprint.
authorAndrey Petrov <andrey.petrov@shazow.net>
Sat, 10 Jan 2015 19:31:18 +0000 (11:31 -0800)
committerAndrey Petrov <andrey.petrov@shazow.net>
Sat, 10 Jan 2015 19:31:18 +0000 (11:31 -0800)
client.go
server.go

index d29b5b67e9592547060acace521ffc4d3b269111..781b4d8db84e6a3ec241b7d1e91f16f5eb776bad 100644 (file)
--- a/client.go
+++ b/client.go
@@ -347,8 +347,12 @@ func (c *Client) handleShell(channel ssh.Channel) {
                                                c.SysMsg("No such name: %s", parts[1])
                                        } else {
                                                fingerprint := client.Fingerprint()
-                                               client.SysMsg("Made op by %s.", c.ColoredName())
-                                               c.Server.Op(fingerprint)
+                                               if fingerprint == "" {
+                                                       c.SysMsg("Cannot op user without fingerprint.")
+                                               } else {
+                                                       client.SysMsg("Made op by %s.", c.ColoredName())
+                                                       c.Server.Op(fingerprint)
+                                               }
                                        }
                                }
                        case "/kick":
index 9022f38ed8264927e5b5f74db3d68ddebbf20301..c5f4127ba3074d9ecae39c7eb4137c882f6a7fb9 100644 (file)
--- a/server.go
+++ b/server.go
@@ -363,6 +363,10 @@ func (s *Server) Uptime() string {
 
 // IsOp checks if the given client is Op
 func (s *Server) IsOp(client *Client) bool {
+       fingerprint := client.Fingerprint()
+       if fingerprint == "" {
+               return false
+       }
        _, r := s.admins[client.Fingerprint()]
        return r
 }