/usr/share/mfscgi/chart.cgi is in lizardfs-cgi 3.9.4+dfsg-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #! /usr/bin/python
import socket
import struct
import cgi
import cgitb; cgitb.enable()
PROTO_BASE = 0
CUTOAN_CHART = (PROTO_BASE+504)
ANTOCU_CHART = (PROTO_BASE+505)
fields = cgi.FieldStorage()
if fields.has_key("host"):
host = fields.getvalue("host")
else:
host = ''
if fields.has_key("port"):
try:
port = int(fields.getvalue("port"))
except ValueError:
port = 0
else:
port = 0
if fields.has_key("id"):
try:
chartid = int(fields.getvalue("id"))
except ValueError:
chartid = -1
else:
chartid = -1
def mysend(socket,msg):
totalsent = 0
while totalsent < len(msg):
sent = socket.send(msg[totalsent:])
if sent == 0:
raise RuntimeError, "socket connection broken"
totalsent = totalsent + sent
def myrecv(socket,leng):
msg = ''
while len(msg) < leng:
chunk = socket.recv(leng-len(msg))
if chunk == '':
raise RuntimeError, "socket connection broken"
msg = msg + chunk
return msg
if host=='' or port==0 or chartid<0:
print "Content-Type: image/gif"
print
f = open('err.gif')
print f.read(),
f.close()
else:
try:
s = socket.socket()
s.connect((host,port))
mysend(s,struct.pack(">LLL",CUTOAN_CHART,4,chartid))
header = myrecv(s,8)
cmd,length = struct.unpack(">LL",header)
if cmd==ANTOCU_CHART and length>0:
data = myrecv(s,length)
# data = s.recv(length)
# print len(data),length
if data[:3]=="GIF":
print "Content-Type: image/gif"
print
print data,
elif data[:8]=="\x89PNG\x0d\x0a\x1a\x0a":
print "Content-Type: image/png"
print
print data,
elif data[:9]=="timestamp":
print "Content-Type: text"
print
print data,
else:
print "Content-Type: image/gif"
f = open('err.gif')
print f.read(),
f.close()
else:
print "Content-Type: image/gif"
print
f = open('err.gif')
print f.read(),
f.close()
s.close()
except Exception:
print "Content-Type: image/gif"
print
f = open('err.gif')
print f.read(),
f.close()
|