airpwn / sams2

Automatically exported from code.google.com/p/sams2
GNU General Public License v2.0
0 stars 0 forks source link

Sams 1.0.5 не работает запрет доступа к url. #578

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Ubuntu Server 10.04
apache 2.2.14
mysql 5.1.41
php 5.3.2
squid 3.0 Stable 19
sams-1.0.5
Используемый редиректор: samsredir
Тип авторизации пользователя ntlm

На веб-интерфейсе создал лист запрещенных 
url (vk.com, google.ru)
Создал шаблон и включил в нем этот лист.
Создал пользователей и применил к ним 
шаблон.
Реконфигурировал сквид.
Пользователи все равно могут заходить на 
запрещенные мной сайты.

В директории /etc/squid3/ создались 2 файла вида 
23d65d6s8vv5.sams, в одном из которых список 
добавленных мной пользователей, во втором - 
список запрещенных сайтов.

В конфиге /etc/squid3/squid.conf встречается 
вписанный туда самсом файл листа 
пользователей (разделы acl и http_access), файл 
листа с запрещенными url нигде не указан.

Original issue reported on code.google.com by frossen...@gmail.com on 5 Oct 2011 at 9:32

GoogleCodeExporter commented 9 years ago
В конфиге сквида также прописан редиректор:
url_rewrite_program /usr/local/bin/samsredir

Original comment by frossen...@gmail.com on 5 Oct 2011 at 10:18

GoogleCodeExporter commented 9 years ago
Возможно проблема кроется в порядке старта 
и завершения sams и mysql.

---------------
| reboot
| ...
| waiting samsdaemon [1276]: MySQL query error: MySQL server has gone away      
 [OK]
---------------

В файле /var/log/squid3/cache.log
---------------
| helperOpenServers: starting 5/5 'samsredir' processes
| mysql_real_connect() error 0, no open database squidctrl, Delay 3 sec
| mysql_real_connect() error 0, no open database squidctrl, Delay 3 sec
| mysql_real_connect() error 0, no open database squidctrl, Delay 3 sec
| mysql_real_connect() error 0, no open database squidctrl, Delay 3 sec
| mysql_real_connect() error 0, no open database squidctrl, Delay 3 sec
---------------

Пароль на базы совпадает в веб-интерфейсе и 
sams.conf, базы создавались через 
веб-интерфейс, mysql -u sams -p выполняется с 
паролем штатно.

Базы проверял через веб интерфейс - ошибок 
нет, мои записи в них присутствуют, сквид 
реконфигурируется через веб-интерфейс без 
ошибок.

Original comment by frossen...@gmail.com on 6 Oct 2011 at 8:36

GoogleCodeExporter commented 9 years ago
Пробовал прописать SLEEP=5 в начало скрипта sams 
- проблема осталась.

Original comment by frossen...@gmail.com on 6 Oct 2011 at 9:25

GoogleCodeExporter commented 9 years ago
root@sqd:/usr/local/bin# sams -d
Connected database: squidctrl:localhost user=sams
Connected database: squidlog:localhost user=sams
Starting process: pid = 2245
Cache 0
Reading file: start=15211 length=15211
disable user script = /usr/local/share/sams/src/script/none
Administrator address:
ISP Mb size=1048576, kb size=1024
Found 2 SAMS users
 0:          ivanov domen.ru 0.0.0.0.0.0./0.0.0.0.0.0. 1     590796   1048576000 4e8d617761cf3 ntlm
 1:          petrov domen.ru 0.0.0.0.0.0./0.0.0.0.0.0. 1          0   1048576000 4e8d618837052 ntlm
Found 3 localhosts
10.105.6.0/24 >> 10.105.6.0/255.255.255.0
192.168.2.0/24 >> 192.168.2.0/255.255.255.0
192.168.4.0/24 >> 192.168.4.0/255.255.255.0
2. SELECT count(*) FROM squidctrl.urlreplace
end=15211 newend=15211 clear=0 loadfile=0
No new values...

root@sqd:/usr/local/bin# samsdaemon -d
Starting process: pid = 2673
Read SAMS configuration... Ok
Connected database: squidctrl:localhost user=sams
Connected database: squidlog:localhost user=sams
Read SAMS properties...
    Cache... 0
    User autentification... NTLM
    Sleep time of samsdaemon...  1 second
    Redirector... SAMS
    SQUID log parser... diskret
    User traffic cleaner... YES
    Squidlog cache save... 12 month
    User name recode... NO
    Delay pools... ON
    Domain separators... '0'
    Log level... '0'
    Create PDF file... NO
Ok
SQUID log parser time=1 min
countdown: 20
countdown: 19
countdown: 18
countdown: 17
countdown: 16
countdown: 15
...

Original comment by frossen...@gmail.com on 6 Oct 2011 at 12:12

GoogleCodeExporter commented 9 years ago
root@sqd:/usr/local/bin# mysql -u sams -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 658
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use squidctrl;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------+
| Tables_in_squidctrl |
+---------------------+
| globalsettings      |
| groups              |
| ipreplace           |
| log                 |
| passwd              |
| proxyes             |
| reconfig            |
| redirect            |
| sams                |
| sconfig             |
| sguard              |
| shablons            |
| squidusers          |
| tree                |
| urlreplace          |
| urls                |
+---------------------+
16 rows in set (0.00 sec)

mysql> select *from squidctrl.urls;
+----------------+---------------+
| url            | type          |
+----------------+---------------+
| vk.com         | 4e8d60aeb6a6b |
| yandex         | 4e8d60bdc407f |
| mail.ru        | 4e8d60ced4097 |
| 10.105.6.0/24  | local         |
| 192.168.2.0/24 | local         |
| 192.168.4.0/24 | local         |
+----------------+---------------+
6 rows in set (0.00 sec)

mysql>

Как видно, доступ к базе есть, данные в ней 
содержатся верные (в этом примере).

Original comment by frossen...@gmail.com on 6 Oct 2011 at 1:02

GoogleCodeExporter commented 9 years ago
root@sqd:~# samsredir -d
Connected database: squidctrl:localhost user=sams
authentification: NTLM
Get SAMS users: 2 users found
  0:        ivanov domen.ru   0.  0.  0.  0  1    4e8d60fba7e26 1111111 0 - 1439 0 1 0 0
  1:        petrov domen.ru   0.  0.  0.  0  1    4e8d6120b5a29 1111111 0 - 1439 0 1 0 0

Search URL lists in the users templates: found 3 URL lists
  0:             4e8d60fba7e26             4e8d60bdc407f
  1:             4e8d60fba7e26             4e8d60aeb6a6b
  2:             4e8d6120b5a29             4e8d60ced4097

Sorting URL lists in the users templates: found 3 URL lists
  0             4e8d60fba7e26             4e8d60bdc407f line:      1 len: 1
  1             4e8d60fba7e26             4e8d60aeb6a6b line:      2 len: 1
  2             4e8d6120b5a29             4e8d60ced4097 line:      3 len: 1
Found 4 URL in the SAMS URL lists
  1             4e8d60bdc407f                    yandex           regex
  2             4e8d60aeb6a6b                    vk.com          denied
  3             4e8d60ced4097                   mail.ru           allow

Дальше молчит. Смущает последняя фраза - 
найдено 4 url, хотя я забивал 3 и на экране 
показаны 3.

Original comment by frossen...@gmail.com on 7 Oct 2011 at 4:53

GoogleCodeExporter commented 9 years ago
/etc/sams.conf

[client]
SQUID_DB=squidlog
SAMS_DB=squidctrl
MYSQLHOSTNAME=localhost
MYSQLUSER=sams
MYSQLPASSWORD=******
MYSQLVERSION=4.0
SQUIDCACHEFILE=access.log
SQUIDROOTDIR=/etc/squid3
SQUIDLOGDIR=/var/log/squid3
SQUIDCACHEDIR=/var/spool/squid3
SAMSPATH=/usr/local
SQUIDPATH=/usr/sbin
RECODECOMMAND=iconv -f KOI8-R -t 866 %finp > %fout
SHUTDOWNCOMMAND=shutdown -h now
CACHENUM=0

/etc/squid3/squid.conf

# OPTIONS FOR AUTHENTICATION
 auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp --domain=DOMEN.RU
 auth_param ntlm children 40
 auth_param ntlm keep_alive on

# ACCESS CONTROLS
#  TAG: acl
acl _sams_4e8d60fba7e26 proxy_auth "/etc/squid3/4e8d60fba7e26.sams" 
acl _sams_4e8d6120b5a29 proxy_auth "/etc/squid3/4e8d6120b5a29.sams" 
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl localnet src 192.168.0.0/16, 10.105.6.0/24
acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT
#  TAG: http_access
http_access allow _sams_4e8d60fba7e26  
http_access allow _sams_4e8d6120b5a29  
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access allow localhost
#  TAG: icp_access
icp_access deny all
#  TAG: htcp_access
htcp_access deny all

# NETWORK OPTIONS
#  TAG: http_port
http_port 3128

# OPTIONS WHICH AFFECT THE NEIGHBOR SELECTION ALGORITHM
#  TAG: hierarchy_stoplist
hierarchy_stoplist cgi-bin ?

# DISK CACHE OPTIONS
cache_dir ufs /var/spool/squid3 100 16 256

# LOGFILE OPTIONS
#  TAG: access_log
access_log /var/log/squid3/access.log squid
#  TAG: cache_log
cache_log /var/log/squid3/cache.log

# OPTIONS FOR URL REWRITING
#  TAG: url_rewrite_program
 url_rewrite_program /usr/local/bin/samsredir
#  TAG: url_rewrite_children
url_rewrite_children 5
# OPTIONS FOR TUNING THE CACHE
#  TAG: refresh_pattern
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern (cgi-bin|\?)    0   0%  0
refresh_pattern .       0   20% 4320

# DELAY POOL PARAMETERS
#  TAG: delay_class
delay_pools 2
delay_class 1 2
delay_class 2 2
delay_access 1 allow _sams_4e8d60fba7e26
delay_access 1 deny all
delay_parameters 1 64000/64000 64000/64000
delay_access 2 allow _sams_4e8d6120b5a29
delay_access 2 deny all
delay_parameters 2 64000/64000 64000/64000

# ICP OPTIONS
#  TAG: icp_port
icp_port 3130

# MISCELLANEOUS
#  TAG: coredump_dir
coredump_dir /var/spool/squid3

Original comment by frossen...@gmail.com on 7 Oct 2011 at 5:31

GoogleCodeExporter commented 9 years ago
Насколько выяснил из дока: 
http://sams.perm.ru/doc/ru/about.html
редиректор самса не должен вносить в 
конфиг сквида запреты, только разрешения. 
Как мне отследить проблемы в его работе?

Original comment by frossen...@gmail.com on 7 Oct 2011 at 6:16

GoogleCodeExporter commented 9 years ago
добрый день. подскажите пожалуйста. не 
работает редиректор sams2. при этом пропал 
/usr/local/bin/samsredir
как это можно исправить?

Original comment by renuasol...@gmail.com on 2 Dec 2014 at 6:46