Conjunto de mudanças 7251 no repositório publico


Ignorar:
Timestamp:
19/11/2013 09:14:00 (6 anos atrás)
Autor:
gustavolepri
Mensagem:

verificação no momento do login se o parlamentar está na camara

Localização:
ILSAPL/trunk
Arquivos:
3 editados

Legenda:

Não Modificado
Adicionado
Removido
  • ILSAPL/trunk/SAPLTool.py

    r7173 r7251  
    11# -*- coding: utf-8 -*-
     2
     3import re
     4import subprocess
     5
     6from lxml.builder import ElementMaker
     7from lxml import etree
    28
    39from datetime import datetime
     
    1723from Products.CMFCore.utils import SimpleItemWithProperties
    1824from Products.CMFCore.utils import UniqueObject
    19 
    20 from lxml.builder import ElementMaker
    21 from lxml import etree
    22 
    23 import re
    2425
    2526from zope.interface import Interface
     
    289290                   }
    290291
     292    def get_mac_address(self, ip_address):
     293        cmd = 'arping -c 1 ' + ip_address
     294
     295        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     296        output, errors = p.communicate()
     297        if output is not None :
     298            return re.findall(r'(\[.*\])', output)[0].replace('[', '').replace(']', '')
     299
    291300InitializeClass(SAPLTool)
    292 
  • ILSAPL/trunk/skins/sk_sapl/pysc/rede_sapl_pysc.py

    r7249 r7251  
    99##
    1010
    11 import socket
    12 import fcntl
    13 import struct
    14 import array
     11from Products.CMFCore.utils import getToolByName
    1512
    16 #TODO colocar os codigos na tool do SAPL ;-)
    17 max_possible = 128  # arbitrary. raise if needed.
    18 bytes = max_possible * 32
    19 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    20 names = array.array('B', '\0' * bytes)
    21 import pdb;pdb.set_trace()
    22 outbytes = struct.unpack('iL', fcntl.ioctl(s.fileno(), 0x8912, struct.pack('iL', bytes, names.buffer_info()[0])))[0]
    23 namestr = names.tostring()
     13sapl_tool = getToolByName(context, 'portal_sapl')
    2414
    25 addresses = context.zsql.presenca_endereco_obter_zsql()
     15enderecos = context.zsql.presenca_endereco_obter_zsql()
    2616
     17endereco_ip = context.REQUEST['REMOTE_ADDR']
    2718
    28 ifname = [namestr[i:i+32].split('\0', 1)[0] for i in range(0, outbytes, 32)]
     19endereco_mac = sapl_tool.get_mac_address(endereco_ip)
    2920
    30 ip_address = socket.inet_ntoa(fcntl.ioctl(
    31     s.fileno(),
    32     0x8915,  # SIOCGIFADDR
    33     struct.pack('256s', ifname[:15])
    34 )[20:24])
     21endereco_completo = [endereco_mac, endereco_ip]
    3522
    36 info = fcntl.ioctl(s.fileno(), 0x8927, struct.pack('256s', ifname[:15]))
    37 mac_address = ''.join(['%02x:' % ord(char) for char in info[18:24]])[:-1]
     23lista_enderecos = [[end.txt_mac_address, end.txt_ip_address] for end in enderecos]
     24
     25if endereco_completo in lista_enderecos:
     26    return True
     27else:
     28    return False
  • ILSAPL/trunk/skins/sk_sapl/pysc/rede_sapl_pysc.py.metadata

    r7249 r7251  
    1 [security]
    2 View = 0:Manager,Administrador,Operador
    3 
    41[default]
    52proxy = Manager
Note: Veja TracChangeset para ajuda no uso do visualizador de conjunto de mudanças.
 

The contents and data of this website are published under license:
Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual.