This file is indexed.

/usr/lib/falcon/net/smtp.fal is in libfalcon-engine1 0.9.6.9-git20120606-2.1+b1.

This file is owned by root:root, with mode 0o644.

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
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/*
    FALCON - SMTP client Module

    FILE: smtp.fal

    Send a mail!
    -------------------------------------------------------------------
    Author: Giancarlo Nicclai
    Begin: Sun, 21 Nov 2010 19:38:39 +0100

    -------------------------------------------------------------------
    (C) Copyright 2010: the FALCON developers (see list in AUTHORS file)

    See LICENSE file for licensing details.
 */

import from socket

/*# Simple Mail Transfer Protocol interface.
   @param server A remote server IP or DNS.
   @param port A port name or number, defaults to 'smtp'.
*/

class SMTP( server, port )
   //# Helo string sent at connection
   heloMsg = "Falcon_SMTP"
   timeout = 5000
   server = server
   port = port ? port : "smtp"

   _smtp = nil
   _auth = nil

   trace = {=>}

   authSchemes = [
     "PLAIN" => self._plainChech
   ]

   /*# Set authentication parameters.
       @param scheme The authentication scheme to be used.
       @param ... Authentication data (usually, a pair of userid, password parameters).
       @return self

       Available schemes are:
       - "PLAIN"
   */

   function auth( scheme )
      if not scheme in self.authSchemes
         raise ParamError(501, nil, "Unknown authorization scheme" )
      end
      sfunc = self.authSchemes[scheme]
      passvp(sfunc)
      return self
   end


   /*# Send a MIME part.
      @param part A @a mime.Part instance.
      @raise CodeError if the contents of From or To fields are invalid
      
      Sends a mail to the described recipients.
      The part must include the From and To headers.
      
      If the Date header is not included, it will be added and set
      to the current date and date.

      @see mime.Part
   */
   function send( part )
      if not part provides headers
         raise ParamError( 501, nil, "mime.Part")
      end

      headers = part.headers
      if not "From" in headers or not "To" in headers
         raise CodeError( 10000, "Missing 'From' or 'To' fields in mail" )
      end
      
      from_field = headers["From"]
      to_field = headers["To"]

      from_mail = self.extractMail( from_field )
      to_list = map( self.extractMail, to_field.split( "," ) )
      
      if "Date" notin headers
         time = CurrentTime()
         headers[ "Date" ] = time.toRFC2822()
      end

      self.sendTo( from_mail, to_list, part.toString() )
   end


   /*# Send a mail data to a remote SMTP server.
      @param sender The sender of the mail.
      @param rcpt Single or multiple mail target recipients.
      @param data A string containing the mail content, properly encoded.
   */
   function sendTo( sender, rcpt, data )
      self.connect()
      self.helo()
      if self._auth: self._auth()
      self.mailFrom( sender )
      if rcpt.typeId() != StringType
         for target in rcpt
            self.rcpt( target )
         end
      end
      self.data( data )
      self.quit()
   end


   function connect()
      //connect with server
      smtp = socket.TCPSocket()
      smtp.setTimeout(self.timeout)
      if not smtp.connect( self.server, self.port )
         raise socket.NetError( 10001, "Can't connect to required server", self.server.toString() + ":" + self.port )
      end

      self.trace( "Connected." )
      // get the hello message
      reply = ""
      smtp.recv(reply, 256)
      self.trace( reply )
      if reply[0:3] != "220"
         raise socket.NetError( 10002, "Remote server not ready", reply.trim() )
      end
      
      self._smtp = smtp
   end

   
   function helo()
      reply = ""
      smtp = self._smtp

      out = "HELO " + self.heloMsg
      self.trace( "-->" + out )
      smtp.send( out +"\r\n" )
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if reply[0] != "2"
         raise socket.NetError( 10003, "HELO refused", reply.trim() )
      end
   end


   function mailFrom( sender )
      reply = ""
      smtp = self._smtp

      out = "MAIL FROM:"+ sender
      self.trace( "-->" + out )
      smtp.send( out + "\r\n" )
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if reply[0:3] != "250"
         raise socket.NetError( 10004, "FROM refused", reply.trim() )
      end
   end
   

   function rcpt( target )
      reply = ""
      smtp = self._smtp

      out = "RCPT TO:"+ target
      self.trace( "-->" + out )
      smtp.send( out + "\r\n" )
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if reply[0:3] != "250"
         raise socket.NetError( 10005, "RCPT refused", reply.trim() )
      end
   end


   function data( content )
      reply = ""
      smtp = self._smtp

      self.trace( "-->DATA" )
      smtp.send( "DATA\r\n" )
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if reply[0:2] != "35"
         raise socket.NetError( 10006, "DATA refused", reply.trim() )
      end

      sent = 0
      blen = content.len()
      while sent < blen
         sent += smtp.send( content, blen - sent, sent )
         self.trace( "--> sent " + sent + " bytes"  )
      end
      out = "\r\n.\r\n"
      self.trace( "-->." )
      smtp.send( out )      

      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if reply[0:2] != "25"
         raise socket.NetError( 10007, "DATA not correctly closed", reply )
      end
   end


   function quit()
      reply = ""
      smtp = self._smtp
      
      self.trace( "-->QUIT" )
      smtp.send( "QUIT\r\n" )
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if reply[0:2] != "22"
         raise socket.NetError( 10008, "QUIT failed", reply )
      end      
   end


   function extractMail( field )
      p1 = field.rfind( "<" )
      p2 = field.rfind( ">" )
      if p1 < p2
         return field[p1+1:p2]
      end
      return field
   end


   // Manages the plain auth scheme
   function _plainChech(user, password)
      if user.typeId() != StringType or password.typeId() != StringType
         raise ParamError( 501, nil, "'PLAIN',S,S")
      end
      self._auth = .[self._plainDo user password]
   end

   function _plainDo( user, password )
      reply = ""
      smtp = self._smtp

      self.trace( "-->AUTH PLAIN" )
      smtp.send( "AUTH PLAIN\r\n" )
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if not reply.startsWith("334")
         raise socket.NetError( 10009, "AUTH PLAIN failed", reply )
      end
      
      // send the auth data
      data = Base64.encode( strToMemBuf( @"\x00$(user)\x00$(password)" ) )
      self.trace( "-->" + data )
      smtp.send( data + "\r\n")
      smtp.recv(reply,256)
      self.trace( "<--" + reply )
      if not reply.startsWith("2")
         raise socket.NetError( 10010, "Authorization for AUTH PLAIN failed", reply )
      end
   end
end