Class: Yast::SquidClass
- Inherits:
-
Module
- Object
- Module
- Yast::SquidClass
- Defined in:
- ../../src/modules/Squid.rb
Instance Method Summary (collapse)
-
- (Boolean) Abort
Abort function.
-
- (Object) ACLIsUsedBy(id_item)
Returns list of options which use this ACL (identified by id_item).
- - (Object) AddACL(name, type, options)
- - (Object) AddHttpAccess(allow, acl)
- - (Object) AddHttpPort(host, port, transparent)
- - (Object) AddRefreshPattern(regexp, min, percent, max, case_sensitive)
-
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
- - (Object) DelACL(id_item)
- - (Object) DelHttpAccess(id_item)
- - (Object) DelHttpPort(id_item)
- - (Object) DelRefreshPattern(id_item)
- - (Object) DisableService
- - (Object) EnableService
-
- (Hash) Export
Dump the squid settings to a single map (For use by autoinstallation.).
- - (Object) GetACL(id_item)
-
- (Object) GetACLs
****** ACL ******.
- - (Object) GetACLType(id_item)
- - (Object) GetACLTypeByName(acl_name)
- - (Object) GetFirewallServiceName
- - (Object) GetHttpAccess(id_item)
-
- (Object) GetHttpAccesses
****** HTTP_ACCESS *****.
- - (Object) GetHttpPort(id_item)
- - (Object) GetHttpPorts
-
- (Object) GetHttpPortsOnly
* HTTP PORT **** Returns only list of configured ports (no hosts and so on).
- - (Object) GetModified
- - (Object) GetRefreshPattern(id_item)
-
- (Object) GetRefreshPatterns
* REFRESH PATTERN *.
- - (Object) GetSetting(name)
-
- (Object) GetSettings
****** SETTINGS ****.
-
- (Boolean) Import(sett)
Get all squid settings from the first parameter (For use by autoinstallation.).
-
- (Object) IsServiceEnabled
****** SERVICE ******.
-
- (Object) IsServiceRunning
Returns true if Squid service is running.
- - (Object) main
- - (Object) ModifyACL(id_item, name, type, options)
- - (Object) ModifyHttpAccess(id_item, allow, acl)
- - (Object) ModifyHttpPort(id_item, host, port, transparent)
- - (Object) ModifyRefreshPattern(id_item, regexp, min, percent, max, case_sensitive)
- - (Object) MoveHttpAccess(id_from, id_to)
- - (Object) MoveRefreshPattern(id_from, id_to)
-
- (Object) NumACLs(id_item)
Returns number of occurences of ACL (definition lines) in config file.
-
- (Object) NumACLsByName(name)
Same as NumACLs but ACL is identified by name.
-
- (Object) Read
Read all squid settings.
-
- (Object) readACLs
Read setting of parameter acl.
- - (Object) readAllSettings
-
- (Object) readHttpAccesses
Read setting of parameter http_access.
-
- (Object) readHttpPorts
Read setting of parameter http_port.
-
- (Object) readRefreshPatterns
Read setting of parameter refresh_pattern.
-
- (Object) readRestSetting
Read rest of setting.
- - (Object) readServiceStatus
- - (Object) repairTimeoutPeriodUnits(old)
- - (Object) SetDefaultValues
- - (Object) SetModified
- - (Object) SetServiceEnabled(enabled)
- - (Object) SetSetting(name, value)
-
- (Object) setWritePremissionsToCacheDir(dir)
Function which sets permissions 'chmod 750' and 'chown squid:root' to directory dir if exists.
-
- (Object) split(str, delim)
**************** HELP FUNCTIONS ************** Same as splitstring(), but returns only non-empty strings.
-
- (Object) StartService
Start Squid service if not running otherwise reload.
-
- (Object) StopService
Stop Squid service.
-
- (Object) Summary
Create a textual summary and a list of unconfigured cards.
-
- (Object) verifyACLs
Verify and repair list of ACLs if something's wrong.
-
- (Object) Write
Write all squid settings.
- - (Object) writeACLs
- - (Object) writeAllSettings
- - (Object) writeFirewallSettings
- - (Object) writeHttpAccesses
- - (Object) writeHttpPorts
- - (Object) writePermissions
- - (Object) writeRefreshPatterns
- - (Object) writeRestSetting
Instance Method Details
- (Boolean) Abort
Abort function
344 345 346 347 |
# File '../../src/modules/Squid.rb', line 344 def Abort return @AbortFunction.call == true if @AbortFunction != nil false end |
- (Object) ACLIsUsedBy(id_item)
Returns list of options which use this ACL (identified by id_item). It's necessary to run this function before deleting ACL to know if any options are not affected.
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
# File '../../src/modules/Squid.rb', line 454 def ACLIsUsedBy(id_item) acl = Ops.get_string(GetACL(id_item), "name", "") return nil if Builtins.size(acl) == 0 #invalid id_item params = [] ret = [] # options with format: # option_name something ACL ACL ACL ... format1 = [ "no_cache", "cache", "broken_vary_encoding", "follow_x_forwarded_for", #"http_access", -> cached in this module !!! "http_reply_access", "icp_access", "htcp_access", "miss_access", "ident_lookup_access", "log_access", "always_direct", "never_direct", "snmp_access", "broken_posts", "deny_info" ] # options with format: # option_name something something ACL ACL ACL ... format2 = [ "tcp_outgoing_tos", "tcp_outgoing_address", "reply_body_max_size", "header_access", "cache_peer_access", "access_log" ] = SCR.Dir(@squid_path) Builtins.foreach( Convert.convert( Builtins.merge(format1, format2), :from => "list", :to => "list <string>" ) ) do |value| if Builtins.contains(, value) Builtins.foreach( Convert.convert( SCR.Read(Builtins.add(@squid_path, value)), :from => "any", :to => "list <list <string>>" ) ) do |params2| params2 = Builtins.remove(params2, 0) # remove first param if Builtins.contains(format2, value) if Ops.greater_than(Builtins.size(params2), 1) params2 = Builtins.remove(params2, 0) else raise Break end end if Builtins.contains(params2, acl) || Builtins.contains(params2, Ops.add("!", acl)) ret = Builtins.add(ret, value) raise Break end end end end #http_access: Builtins.foreach(@http_accesses) do |value| if Builtins.contains(Ops.get_list(value, "acl", []), acl) || Builtins.contains(Ops.get_list(value, "acl", []), Ops.add("!", acl)) ret = Builtins.add(ret, "http_access") raise Break end end Builtins.y2debug("Squid::ACLIsUsedBy() - acl:%1, ret: %2", acl, ret) deep_copy(ret) end |
- (Object) AddACL(name, type, options)
387 388 389 390 391 392 393 394 395 396 |
# File '../../src/modules/Squid.rb', line 387 def AddACL(name, type, ) = deep_copy() SetModified() @acls = Builtins.add( @acls, { "name" => name, "type" => type, "options" => } ) nil end |
- (Object) AddHttpAccess(allow, acl)
550 551 552 553 554 555 556 557 558 559 |
# File '../../src/modules/Squid.rb', line 550 def AddHttpAccess(allow, acl) acl = deep_copy(acl) SetModified() @http_accesses = Builtins.add( @http_accesses, { "allow" => allow, "acl" => acl } ) nil end |
- (Object) AddHttpPort(host, port, transparent)
719 720 721 722 723 724 725 726 727 |
# File '../../src/modules/Squid.rb', line 719 def AddHttpPort(host, port, transparent) SetModified() @http_ports = Builtins.add( @http_ports, { "host" => host, "port" => port, "transparent" => transparent } ) nil end |
- (Object) AddRefreshPattern(regexp, min, percent, max, case_sensitive)
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File '../../src/modules/Squid.rb', line 634 def AddRefreshPattern(regexp, min, percent, max, case_sensitive) SetModified() @refresh_patterns = Builtins.add( @refresh_patterns, { "regexp" => regexp, "min" => min, "percent" => percent, "max" => max, "case_sensitive" => case_sensitive } ) nil end |
- (Hash) AutoPackages
Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.
1647 1648 1649 |
# File '../../src/modules/Squid.rb', line 1647 def AutoPackages { "install" => ["squid"], "remove" => [] } end |
- (Object) DelACL(id_item)
412 413 414 415 416 417 418 419 420 |
# File '../../src/modules/Squid.rb', line 412 def DelACL(id_item) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@acls)) SetModified() @acls = Builtins.remove(@acls, id_item) end nil end |
- (Object) DelHttpAccess(id_item)
576 577 578 579 580 581 582 583 584 |
# File '../../src/modules/Squid.rb', line 576 def DelHttpAccess(id_item) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@http_accesses)) SetModified() @http_accesses = Builtins.remove(@http_accesses, id_item) end nil end |
- (Object) DelHttpPort(id_item)
742 743 744 745 746 747 748 749 750 |
# File '../../src/modules/Squid.rb', line 742 def DelHttpPort(id_item) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@http_ports)) SetModified() @http_ports = Builtins.remove(@http_ports, id_item) end nil end |
- (Object) DelRefreshPattern(id_item)
669 670 671 672 673 674 675 676 677 |
# File '../../src/modules/Squid.rb', line 669 def DelRefreshPattern(id_item) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@refresh_patterns)) SetModified() @refresh_patterns = Builtins.remove(@refresh_patterns, id_item) end nil end |
- (Object) DisableService
1455 1456 1457 |
# File '../../src/modules/Squid.rb', line 1455 def DisableService Service.Disable("squid") end |
- (Object) EnableService
1451 1452 1453 |
# File '../../src/modules/Squid.rb', line 1451 def EnableService Service.Enable("squid") end |
- (Hash) Export
Dump the squid settings to a single map (For use by autoinstallation.)
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 |
# File '../../src/modules/Squid.rb', line 1565 def Export { "http_ports" => @http_ports, "acls" => @acls, "http_accesses" => @http_accesses, "refresh_patterns" => @refresh_patterns, "settings" => @settings, "service_enabled_on_startup" => @service_enabled_on_startup } end |
- (Object) GetACL(id_item)
368 369 370 |
# File '../../src/modules/Squid.rb', line 368 def GetACL(id_item) Ops.get(@acls, id_item, {}) end |
- (Object) GetACLs
****** ACL ******
364 365 366 |
# File '../../src/modules/Squid.rb', line 364 def GetACLs deep_copy(@acls) end |
- (Object) GetACLType(id_item)
372 373 374 |
# File '../../src/modules/Squid.rb', line 372 def GetACLType(id_item) Ops.get_string(Ops.get(@acls, id_item, {}), "type", "") end |
- (Object) GetACLTypeByName(acl_name)
376 377 378 379 380 381 382 383 384 385 |
# File '../../src/modules/Squid.rb', line 376 def GetACLTypeByName(acl_name) ret = nil Builtins.foreach(@acls) do |value| if Ops.get_string(value, "name", "") == acl_name ret = Ops.get_string(value, "type", "") raise Break end end ret end |
- (Object) GetFirewallServiceName
148 149 150 |
# File '../../src/modules/Squid.rb', line 148 def GetFirewallServiceName @firewall_service_name end |
- (Object) GetHttpAccess(id_item)
546 547 548 |
# File '../../src/modules/Squid.rb', line 546 def GetHttpAccess(id_item) Ops.get(@http_accesses, id_item, {}) end |
- (Object) GetHttpAccesses
****** HTTP_ACCESS *****
542 543 544 |
# File '../../src/modules/Squid.rb', line 542 def GetHttpAccesses deep_copy(@http_accesses) end |
- (Object) GetHttpPort(id_item)
715 716 717 |
# File '../../src/modules/Squid.rb', line 715 def GetHttpPort(id_item) Ops.get(@http_ports, id_item, {}) end |
- (Object) GetHttpPorts
711 712 713 |
# File '../../src/modules/Squid.rb', line 711 def GetHttpPorts deep_copy(@http_ports) end |
- (Object) GetHttpPortsOnly
* HTTP PORT **** Returns only list of configured ports (no hosts and so on)
701 702 703 704 705 706 707 708 709 |
# File '../../src/modules/Squid.rb', line 701 def GetHttpPortsOnly ret = [] Builtins.foreach(@http_ports) do |value| if Ops.greater_than(Builtins.size(Ops.get_string(value, "port", "")), 0) ret = Builtins.add(ret, Ops.get_string(value, "port", "")) end end deep_copy(ret) end |
- (Object) GetModified
331 332 333 |
# File '../../src/modules/Squid.rb', line 331 def GetModified @modified end |
- (Object) GetRefreshPattern(id_item)
630 631 632 |
# File '../../src/modules/Squid.rb', line 630 def GetRefreshPattern(id_item) Ops.get(@refresh_patterns, id_item, {}) end |
- (Object) GetRefreshPatterns
* REFRESH PATTERN *
626 627 628 |
# File '../../src/modules/Squid.rb', line 626 def GetRefreshPatterns deep_copy(@refresh_patterns) end |
- (Object) GetSetting(name)
607 608 609 |
# File '../../src/modules/Squid.rb', line 607 def GetSetting(name) Ops.get_list(@settings, name, []) end |
- (Object) GetSettings
****** SETTINGS ****
603 604 605 |
# File '../../src/modules/Squid.rb', line 603 def GetSettings deep_copy(@settings) end |
- (Boolean) Import(sett)
Get all squid settings from the first parameter (For use by autoinstallation.)
1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 |
# File '../../src/modules/Squid.rb', line 1532 def Import(sett) sett = deep_copy(sett) if sett == {} || sett == nil SetDefaultValues() SetModified() return true end if !Builtins.haskey(sett, "http_ports") || !Builtins.haskey(sett, "acls") || !Builtins.haskey(sett, "http_accesses") || !Builtins.haskey(sett, "refresh_patterns") || !Builtins.haskey(sett, "settings") || !Builtins.haskey(sett, "service_enabled_on_startup") return false end @http_ports = Ops.get_list(sett, "http_ports", []) @acls = Ops.get_list(sett, "acls", []) @http_accesses = Ops.get_list(sett, "http_accesses", []) @refresh_patterns = Ops.get_list(sett, "refresh_patterns", []) @settings = Ops.get_map(sett, "settings", {}) @service_enabled_on_startup = Ops.get_boolean( sett, "service_enabled_on_startup", false ) SetModified() true end |
- (Object) IsServiceEnabled
****** SERVICE ******
351 352 353 |
# File '../../src/modules/Squid.rb', line 351 def IsServiceEnabled @service_enabled_on_startup end |
- (Object) IsServiceRunning
Returns true if Squid service is running.
1408 1409 1410 |
# File '../../src/modules/Squid.rb', line 1408 def IsServiceRunning Service.Status("squid") == 0 end |
- (Object) main
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 |
# File '../../src/modules/Squid.rb', line 35 def main textdomain "squid" Yast.import "Progress" Yast.import "Report" Yast.import "Summary" Yast.import "Message" Yast.import "Service" Yast.import "FileUtils" Yast.import "SuSEFirewall" # Defines path used in SCR::Read/Write functions @squid_path = path(".etc.squid") # Defines location of sysconfig file @sysconfig_file = "/etc/sysconfig/SuSEfirewall2.d/services/squid" # Defines name of service which is used by firewall when it's openning ports. @firewall_service_name = "service:squid" # Data was modified? @modified = false # Is service enabled? @service_enabled_on_startup = false # Map of all configuration settings except consequential. Format: # $[ "parameter name" : [ list of options (rest of line) ] # ... # ] @settings = {} # List of http_ports. Format: # [ $["host" : "hostname", # "port" : "3128", # "transparent" : true], # ... # ] @http_ports = [] # List of acls. Format: # [ $[ "name" : "localhost", # "type" : "src", # "options" : [ non-empty list of options ]] # ... # ] @acls = [] # List of access control parameters. Format: # [ $["allow" : true, # "acl" : ["acl1", "!acl2", ...] ], # ... # ] @http_accesses = [] # List of refresh patterns. Format: # [ $["regexp" : "^ftp:", # "case_sensitive" : true, # "min" : "12", # "max" : "12", # "percent" : "12"], # ... # ] @refresh_patterns = [] # Map of all available parameters with defalut values. # $[ "parameter_name" : [ list of default options ], # ... # ] @parameters = { "cache_dir" => [ "ufs", "/var/cache/squid", "100", "16", "256" ], "cache_mem" => ["8", "MB"], "cache_swap_low" => ["90"], "cache_swap_high" => ["95"], "maximum_object_size" => ["4096", "KB"], "minimum_object_size" => ["0", "KB"], "cache_replacement_policy" => ["lru"], "memory_replacement_policy" => ["lru"], "access_log" => ["/var/log/squid/access.log"], "cache_log" => ["/var/log/squid/cache.log"], "cache_store_log" => ["/var/log/squid/store.log"], "emulate_httpd_log" => ["off"], "connect_timeout" => ["2", "minutes"], "client_lifetime" => ["1", "days"], "error_directory" => ["/usr/share/squid/errors/en"], "cache_mgr" => ["webmaster"], "ftp_passive" => ["on"] } # Write only, used during autoinstallation. # Don't run services and SuSEconfig, it's all done at one place. @write_only = false # Abort function # return boolean return true if abort #global boolean() AbortFunction = GetModified; @AbortFunction = nil end |
- (Object) ModifyACL(id_item, name, type, options)
398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File '../../src/modules/Squid.rb', line 398 def ModifyACL(id_item, name, type, ) = deep_copy() if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@acls)) tmp = { "name" => name, "type" => type, "options" => } if tmp != Ops.get(@acls, id_item, {}) SetModified() Ops.set(@acls, id_item, tmp) end end nil end |
- (Object) ModifyHttpAccess(id_item, allow, acl)
561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File '../../src/modules/Squid.rb', line 561 def ModifyHttpAccess(id_item, allow, acl) acl = deep_copy(acl) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@http_accesses)) tmp = { "allow" => allow, "acl" => acl } if tmp != Ops.get(@http_accesses, id_item, {}) SetModified() Ops.set(@http_accesses, id_item, tmp) end end nil end |
- (Object) ModifyHttpPort(id_item, host, port, transparent)
729 730 731 732 733 734 735 736 737 738 739 740 |
# File '../../src/modules/Squid.rb', line 729 def ModifyHttpPort(id_item, host, port, transparent) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@http_ports)) tmp = { "host" => host, "port" => port, "transparent" => transparent } if tmp != Ops.get(@http_ports, id_item, {}) SetModified() Ops.set(@http_ports, id_item, tmp) end end nil end |
- (Object) ModifyRefreshPattern(id_item, regexp, min, percent, max, case_sensitive)
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File '../../src/modules/Squid.rb', line 650 def ModifyRefreshPattern(id_item, regexp, min, percent, max, case_sensitive) if Ops.greater_or_equal(id_item, 0) && Ops.less_than(id_item, Builtins.size(@refresh_patterns)) tmp = { "regexp" => regexp, "min" => min, "percent" => percent, "max" => max, "case_sensitive" => case_sensitive } if tmp != Ops.get(@refresh_patterns, id_item, {}) SetModified() Ops.set(@refresh_patterns, id_item, tmp) end end nil end |
- (Object) MoveHttpAccess(id_from, id_to)
586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
# File '../../src/modules/Squid.rb', line 586 def MoveHttpAccess(id_from, id_to) if Ops.greater_or_equal(id_from, 0) && Ops.less_than(id_from, Builtins.size(@http_accesses)) && Ops.greater_or_equal(id_to, 0) && Ops.less_than(id_to, Builtins.size(@http_accesses)) && id_from != id_to SetModified() tmp = Ops.get(@http_accesses, id_from, {}) Ops.set(@http_accesses, id_from, Ops.get(@http_accesses, id_to, {})) Ops.set(@http_accesses, id_to, tmp) end nil end |
- (Object) MoveRefreshPattern(id_from, id_to)
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
# File '../../src/modules/Squid.rb', line 679 def MoveRefreshPattern(id_from, id_to) if Ops.greater_or_equal(id_from, 0) && Ops.less_than(id_from, Builtins.size(@refresh_patterns)) && Ops.greater_or_equal(id_to, 0) && Ops.less_than(id_to, Builtins.size(@refresh_patterns)) && id_from != id_to SetModified() tmp = Ops.get(@refresh_patterns, id_from, {}) Ops.set( @refresh_patterns, id_from, Ops.get(@refresh_patterns, id_to, {}) ) Ops.set(@refresh_patterns, id_to, tmp) end nil end |
- (Object) NumACLs(id_item)
Returns number of occurences of ACL (definition lines) in config file.
424 425 426 427 428 429 430 431 432 433 434 435 436 |
# File '../../src/modules/Squid.rb', line 424 def NumACLs(id_item) acl = Ops.get_string(Ops.get(@acls, id_item, {}), "name", "") #get name of acl return nil if Builtins.size(acl) == 0 #invalid id_item ret = 0 Builtins.foreach(@acls) do |value| ret = Ops.add(ret, 1) if Ops.get_string(value, "name", "") == acl end Builtins.y2debug("Squid::NumACLs() - acl: %1, num: %2", acl, ret) ret end |
- (Object) NumACLsByName(name)
Same as NumACLs but ACL is identified by name.
439 440 441 442 443 444 445 446 447 448 449 |
# File '../../src/modules/Squid.rb', line 439 def NumACLsByName(name) ret = nil i = 0 Builtins.foreach(@acls) do |value| raise Break if Ops.get_string(value, "name", "") == name i = Ops.add(i, 1) end ret = NumACLs(i) if Ops.less_than(i, Builtins.size(@acls)) ret end |
- (Object) Read
Read all squid settings
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
# File '../../src/modules/Squid.rb', line 1085 def Read ok = true Progress.New( _("Initializing Squid Configuration"), " ", 7, [ _("Read HTTP Ports from Config File."), _("Read Refresh Patterns from Config File."), _("Read ACL Groups from Config File."), _("Read Access Control Table from Config File."), _("Read Other Settings."), _("Read Service Status."), _("Read Firewall Settings.") ], [ _("Reading HTTP Ports ..."), _("Reading Refresh Patterns ..."), _("Reading ACL Groups ..."), _("Reading Access Control Table ..."), _("Reading Other Settings ..."), _("Reading Service Status ..."), _("Reading Firewall Settings ...") ], "" ) return false if Abort() Progress.NextStage if !readAllSettings ok = false Report.Error(_("Cannot read configuration file.")) end if !readServiceStatus ok = false Report.Error(_("Cannot read service status.")) end Progress.NextStage Progress.set(false) if !SuSEFirewall.Read # bnc#808722: yast2 squid fail if SuSEfirewall in not installed # other or no firewall can be installed Builtins.y2warning("Cannot read firewall settings.") end Progress.set(true) Progress.NextStage Builtins.y2milestone("================ Setting ======================") Builtins.y2debug("Squid::Read - http_ports: %1", @http_ports) Builtins.y2debug("Squid::Read - http_accesses: %1", @http_accesses) Builtins.y2debug("Squid::Read - acls: %1", @acls) Builtins.y2debug("Squid::Read - refresh_patterns: %1", @refresh_patterns) Builtins.y2debug("Squid::Read - settings: %1", @settings) Builtins.y2debug("Squid::Read - enabled: %1", @service_enabled_on_startup) Builtins.y2milestone("================ Setting END ==================") ok end |
- (Object) readACLs
Read setting of parameter acl. acl aclname acltype string1 string2 …
return true on success
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 |
# File '../../src/modules/Squid.rb', line 882 def readACLs ok = true tmp_acl = {} #list of types which contains regular expression regexps = [ "srcdom_regex", "dstdom_regex", "url_regex", "urlpath_regex", "browser" ] @acls = [] Builtins.foreach( Convert.convert( SCR.Read(Builtins.add(@squid_path, "acl")), :from => "any", :to => "list <list <string>>" ) ) do |value| tmp_acl = {} if Ops.less_than(Builtins.size(value), 3) ok = false next false end Ops.set(tmp_acl, "name", Ops.get(value, 0, "")) Ops.set(tmp_acl, "type", Ops.get(value, 1, "")) Ops.set( tmp_acl, "options", Builtins.remove(Builtins.remove(value, 0), 0) ) # Special settings: # concat list of regular expressions into one option if Builtins.contains(regexps, Ops.get_string(tmp_acl, "type", "")) if Ops.get(Ops.get_list(tmp_acl, "options", []), 0, "") == "-i" Ops.set( tmp_acl, "options", [ "-i", Builtins.mergestring( Convert.convert( Builtins.remove(Ops.get_list(tmp_acl, "options", []), 0), :from => "list", :to => "list <string>" ), " " ) ] ) else Ops.set( tmp_acl, "options", [Builtins.mergestring(Ops.get_list(tmp_acl, "options", []), " ")] ) end #format: acl aclname header_name [-i] list of regexps elsif Ops.get_string(tmp_acl, "type", "") == "req_header" || Ops.get_string(tmp_acl, "type", "") == "rep_header" if Ops.get(Ops.get_list(tmp_acl, "options", []), 1, "") == "-i" Ops.set( tmp_acl, "options", [ Ops.get(Ops.get_list(tmp_acl, "options", []), 0, ""), "-i", Builtins.mergestring( Convert.convert( Builtins.remove( Builtins.remove(Ops.get_list(tmp_acl, "options", []), 0), 0 ), :from => "list", :to => "list <string>" ), " " ) ] ) else Ops.set( tmp_acl, "options", [ Ops.get(Ops.get_list(tmp_acl, "options", []), 0, ""), Builtins.mergestring( Convert.convert( Builtins.remove(Ops.get_list(tmp_acl, "options", []), 0), :from => "list", :to => "list <string>" ), " " ) ] ) end end @acls = Builtins.add(@acls, tmp_acl) end verifyACLs ok end |
- (Object) readAllSettings
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 |
# File '../../src/modules/Squid.rb', line 1062 def readAllSettings ok = true ok = false if !readHttpPorts Progress.NextStage ok = false if !readRefreshPatterns Progress.NextStage ok = false if !readACLs Progress.NextStage ok = false if !readHttpAccesses Progress.NextStage ok = false if !readRestSetting Progress.NextStage ok end |
- (Object) readHttpAccesses
Read setting of parameter http_access. http_access allow acl1 !acl2 …
return true on success
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 |
# File '../../src/modules/Squid.rb', line 807 def readHttpAccesses ok = true tmp_http_access = {} @http_accesses = [] Builtins.foreach( Convert.convert( SCR.Read(Builtins.add(@squid_path, "http_access")), :from => "any", :to => "list <list <string>>" ) ) do |value| tmp_http_access = {} if Ops.get(value, 0, "") != "allow" && Ops.get(value, 0, "") != "deny" ok = false next false end Ops.set( tmp_http_access, "allow", Ops.get(value, 0, "") == "allow" ? true : false ) Ops.set(tmp_http_access, "acl", Builtins.remove(value, 0)) @http_accesses = Builtins.add(@http_accesses, tmp_http_access) end ok end |
- (Object) readHttpPorts
Read setting of parameter http_port. http_port [hostname:]port [transparent]
return true on success
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
# File '../../src/modules/Squid.rb', line 762 def readHttpPorts ok = true tmp = [] tmp_http_port = {} @http_ports = [] Builtins.foreach( Convert.convert( SCR.Read(Builtins.add(@squid_path, "http_port")), :from => "any", :to => "list <list <string>>" ) ) do |value| tmp_http_port = {} tmp = [] #can parse only 'http_port hostname:port [transparent]' if Ops.less_than(Builtins.size(value), 1) || Ops.greater_than(Builtins.size(value), 2) ok = false next false end # hostname and port tmp = split(Ops.get(value, 0, ""), ":") Builtins.y2debug("readHttpPorts - tmp: %1", tmp) if Builtins.size(tmp) == 1 Ops.set(tmp_http_port, "host", "") Ops.set(tmp_http_port, "port", Ops.get_string(tmp, 0, "")) else Ops.set(tmp_http_port, "host", Ops.get_string(tmp, 0, "")) Ops.set(tmp_http_port, "port", Ops.get_string(tmp, 1, "")) end #transparent option if Builtins.size(value) == 2 && Ops.get(value, 1, "") == "transparent" Ops.set(tmp_http_port, "transparent", true) end @http_ports = Builtins.add(@http_ports, tmp_http_port) end ok end |
- (Object) readRefreshPatterns
Read setting of parameter refresh_pattern. refresh_pattern [-i] regexp min percent max [options (ignored)]
return true on success
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 |
# File '../../src/modules/Squid.rb', line 840 def readRefreshPatterns ok = true tmp_refresh_pattern = {} @refresh_patterns = [] Builtins.foreach( Convert.convert( SCR.Read(Builtins.add(@squid_path, "refresh_pattern")), :from => "any", :to => "list <list <string>>" ) ) do |value| tmp_refresh_pattern = {} #case-insesitive if Ops.get(value, 0, "") == "-i" Ops.set(tmp_refresh_pattern, "case_sensitive", false) value = Builtins.remove(value, 0) else Ops.set(tmp_refresh_pattern, "case_sensitive", true) end if Ops.less_than(Builtins.size(value), 4) ok = false next false end Ops.set(tmp_refresh_pattern, "regexp", Ops.get(value, 0, "")) Ops.set(tmp_refresh_pattern, "min", Ops.get(value, 1, "")) Ops.set( tmp_refresh_pattern, "percent", Builtins.deletechars(Ops.get(value, 2, ""), "%") ) Ops.set(tmp_refresh_pattern, "max", Ops.get(value, 3, "")) @refresh_patterns = Builtins.add(@refresh_patterns, tmp_refresh_pattern) end ok end |
- (Object) readRestSetting
Read rest of setting. return true on success
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
# File '../../src/modules/Squid.rb', line 992 def readRestSetting ok = true tmp = [] @settings = {} Builtins.foreach(@parameters) do |key, value| tmp = Convert.convert( SCR.Read(Builtins.add(@squid_path, key)), :from => "any", :to => "list <list <string>>" ) #tmp = split(tmp[0]:"", " \t"); tmp = Ops.get_list(tmp, 0, []) if Ops.greater_than(Builtins.size(tmp), 0) Ops.set(@settings, key, tmp) else Ops.set(@settings, key, value) end end #special modification Ops.set( @settings, "cache_replacement_policy", [ Builtins.mergestring( Ops.get_list(@settings, "cache_replacement_policy", []), " " ) ] ) Ops.set( @settings, "memory_replacement_policy", [ Builtins.mergestring( Ops.get_list(@settings, "memory_replacement_policy", []), " " ) ] ) Ops.set( @settings, "connect_timeout", [ Ops.get(Ops.get_list(@settings, "connect_timeout", []), 0, ""), repairTimeoutPeriodUnits( Ops.get(Ops.get_list(@settings, "connect_timeout", []), 1, "") ) ] ) Ops.set( @settings, "client_lifetime", [ Ops.get(Ops.get_list(@settings, "client_lifetime", []), 0, ""), repairTimeoutPeriodUnits( Ops.get(Ops.get_list(@settings, "client_lifetime", []), 1, "") ) ] ) ok end |
- (Object) readServiceStatus
1057 1058 1059 1060 |
# File '../../src/modules/Squid.rb', line 1057 def readServiceStatus @service_enabled_on_startup = Service.Enabled("squid") true end |
- (Object) repairTimeoutPeriodUnits(old)
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File '../../src/modules/Squid.rb', line 198 def repairTimeoutPeriodUnits(old) ret = "seconds" if old == "day" ret = "days" elsif old == "hour" ret = "hours" elsif old == "minute" ret = "minutes" elsif old == "second" ret = "seconds" elsif Builtins.contains(["seconds", "minutes", "hours", "days"], old) ret = old end ret end |
- (Object) SetDefaultValues
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File '../../src/modules/Squid.rb', line 246 def SetDefaultValues @http_ports = [{ "host" => "", "port" => "3128", "transparent" => false }] @acls = [ { "name" => "QUERY", "options" => ["cgi-bin \\?"], "type" => "urlpath_regex" }, { "name" => "apache", "options" => ["Server", "^Apache"], "type" => "rep_header" }, { "name" => "all", "options" => ["0.0.0.0/0.0.0.0"], "type" => "src" }, { "name" => "manager", "options" => ["cache_object"], "type" => "proto" }, { "name" => "localhost", "options" => ["127.0.0.1/255.255.255.255"], "type" => "src" }, { "name" => "to_localhost", "options" => ["127.0.0.0/8"], "type" => "dst" }, { "name" => "SSL_ports", "options" => ["443"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["80"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["21"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["443"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["70"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["210"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["1025-65535"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["280"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["488"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["591"], "type" => "port" }, { "name" => "Safe_ports", "options" => ["777"], "type" => "port" }, { "name" => "CONNECT", "options" => ["CONNECT"], "type" => "method" } ] @http_accesses = [ { "acl" => ["manager", "localhost"], "allow" => true }, { "acl" => ["manager"], "allow" => false }, { "acl" => ["!Safe_ports"], "allow" => false }, { "acl" => ["CONNECT", "!SSL_ports"], "allow" => false }, { "acl" => ["localhost"], "allow" => true }, { "acl" => ["all"], "allow" => false } ] @refresh_patterns = [ { "case_sensitive" => true, "max" => "10080", "min" => "1440", "percent" => "20", "regexp" => "^ftp:" }, { "case_sensitive" => true, "max" => "1440", "min" => "1440", "percent" => "0", "regexp" => "^gopher:" }, { "case_sensitive" => true, "max" => "4320", "min" => "0", "percent" => "20", "regexp" => "." } ] @settings = deep_copy(@parameters) @service_enabled_on_startup = false nil end |
- (Object) SetModified
335 336 337 338 339 340 |
# File '../../src/modules/Squid.rb', line 335 def SetModified Builtins.y2debug("Squid::SetModified() - Squid modified") @modified = true nil end |
- (Object) SetServiceEnabled(enabled)
355 356 357 358 359 360 |
# File '../../src/modules/Squid.rb', line 355 def SetServiceEnabled(enabled) SetModified() @service_enabled_on_startup = enabled nil end |
- (Object) SetSetting(name, value)
611 612 613 614 615 616 617 618 619 620 621 |
# File '../../src/modules/Squid.rb', line 611 def SetSetting(name, value) value = deep_copy(value) tmp = deep_copy(value) if tmp != Ops.get_list(@settings, name, []) SetModified() Ops.set(@settings, name, value) end nil end |
- (Object) setWritePremissionsToCacheDir(dir)
Function which sets permissions 'chmod 750' and 'chown squid:root' to directory dir if exists. If dir does not exist, function returns true;
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File '../../src/modules/Squid.rb', line 219 def setWritePremissionsToCacheDir(dir) if !FileUtils.IsDirectory(dir) Builtins.y2debug( "Squid::checkWritePremissionsCacheDir() - '%1' is not directory", dir ) return true end if Convert.to_integer( SCR.Execute(path(".target.bash"), Ops.add("chown squid:root ", dir)) ) != 0 || Convert.to_integer( SCR.Execute(path(".target.bash"), Ops.add("chmod 750 ", dir)) ) != 0 return false #return (Popup::ContinueCancel(sformat(_("Unable to set correct permissions to directory %1."), dir))); end true end |
- (Object) split(str, delim)
**************** HELP FUNCTIONS ************** Same as splitstring(), but returns only non-empty strings.
156 157 158 159 160 |
# File '../../src/modules/Squid.rb', line 156 def split(str, delim) Builtins.filter(Builtins.splitstring(str, delim)) do |value| Ops.greater_than(Builtins.size(value), 0) end end |
- (Object) StartService
Start Squid service if not running otherwise reload. Returns true if squid was successfuly started
1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 |
# File '../../src/modules/Squid.rb', line 1414 def StartService ok = true #verify config file #if ((integer)SCR::Execute(.target.bash, "squid -k parse") != 0){ # y2error("Squid::Write - startService - 'squid -k parse' failed"); # return false; #} if !IsServiceRunning() if !Service.Start("squid") ok = false Report.Error(Message.CannotStartService("squid")) end else if !Service.Restart("squid") ok = false Report.Error(Message.CannotRestartService("squid")) end end ok end |
- (Object) StopService
Stop Squid service. Returns true if squid was successfuly stopped
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File '../../src/modules/Squid.rb', line 1439 def StopService ok = true if IsServiceRunning() if !Service.Stop("squid") ok = false Report.Error(Message.CannotStopService("squid")) end end ok end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 |
# File '../../src/modules/Squid.rb', line 1578 def Summary summary = "" tmp = "" if !GetModified() summary = Summary.NotConfigured else # Header summary = Summary.AddHeader("", _("Squid Cache Proxy")) # Start daemon summary = Summary.AddLine( summary, _("Start daemon: ") + "<i>" + (@service_enabled_on_startup ? _("When booting") : _("Manually")) + "</i>" ) # Http Ports summary = Summary.AddLine(summary, _("Configured ports:")) if Ops.greater_than(Builtins.size(@http_ports), 0) summary = Summary.OpenList(summary) Builtins.foreach(@http_ports) do |value| tmp = "<i>" if Ops.greater_than( Builtins.size(Ops.get_string(value, "host", "")), 0 ) tmp = Ops.add( Ops.add(tmp, Ops.get_string(value, "host", "")), ":" ) end tmp = Ops.add( Ops.add(tmp, Ops.get_string(value, "port", "")), Ops.get_boolean(value, "transparent", false) ? _(" (transparent)") : "" ) tmp = Ops.add(tmp, "</i>") summary = Summary.AddListItem(summary, tmp) end summary = Summary.CloseList(summary) end #Cache directory summary = Summary.AddLine( summary, Ops.add( Ops.add( _("Cache directory: ") + "<i>", Ops.get(Ops.get_list(@settings, "cache_dir", []), 1, "") ), "</i>" ) ) end [summary, []] end |
- (Object) verifyACLs
Verify and repair list of ACLs if something's wrong.
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 |
# File '../../src/modules/Squid.rb', line 162 def verifyACLs #verification of ACLs #There must not exist more ACLs with same name and different type i = 0 tested = [] to_remove = [] ii = 0 Builtins.foreach(@acls) do |value| if !Builtins.contains(tested, Ops.get_string(value, "name", "")) if Ops.greater_than(NumACLs(i), 0) to_remove = [] ii = 0 Builtins.foreach(@acls) do |val| if Ops.get_string(val, "name", "") == Ops.get_string(value, "name", "") && Ops.get_string(val, "type", "") != Ops.get_string(value, "type", "") to_remove = Builtins.add(to_remove, ii) end ii = Ops.add(ii, 1) end #delete all ACLs which has not type same as value["type"]:"" - # - it means type of first occurence of tested ACL Builtins.foreach(to_remove) do |val| @acls = Builtins.remove(@acls, val) end end tested = Builtins.add(tested, Ops.get_string(value, "name", "")) end i = Ops.add(i, 1) end nil end |
- (Object) Write
Write all squid settings
1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 |
# File '../../src/modules/Squid.rb', line 1461 def Write ok = true # We do not set help text here, because it was set outside Progress.New( _("Saving Squid Configuration"), " ", 3, [ # Progress stage 1/2 _("Write the settings"), # Progress stage 1/2 _("Write firewall settings"), # Progress stage 2/2 _("Start Service") ], [ # Progress step 1/2 _("Writing the settings..."), # Progress step 1/2 _("Writing firewall settings..."), # Progress step 2/2 _("Starting Service..."), # Progress finished _("Finished") ], "" ) # write settings return false if Abort() Progress.NextStage if !writeAllSettings Report.Error(_("Cannot write settings.")) ok = false end #firewall if !writeFirewallSettings Report.Error(_("Cannot write firewall settings.")) ok = false end Progress.NextStage #enabling / disabling service EnableService() if @service_enabled_on_startup == true DisableService() if @service_enabled_on_startup == false # start Service return false if Abort() Progress.NextStage ok = false if !StartService() if !@write_only return false if Abort() # Progress finished Progress.NextStage return false if Abort() ok end |
- (Object) writeACLs
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 |
# File '../../src/modules/Squid.rb', line 1185 def writeACLs ok = true scr = [] tmp = [] Builtins.foreach(@acls) do |value| tmp = [] Ops.set(tmp, 0, Ops.get_string(value, "name", "")) Ops.set(tmp, 1, Ops.get_string(value, "type", "")) tmp = Convert.convert( Builtins.merge(tmp, Ops.get_list(value, "options", [])), :from => "list", :to => "list <string>" ) scr = Builtins.add(scr, tmp) end Builtins.y2debug("Squid::Write - acl: %1", scr) ok = false if !SCR.Write(Builtins.add(@squid_path, "acl"), scr) ok end |
- (Object) writeAllSettings
1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 |
# File '../../src/modules/Squid.rb', line 1293 def writeAllSettings ok = true ok = false if !writePermissions if !GetModified() Builtins.y2debug( "Squid::Write - no setting to write, because nothing's changed" ) return ok end Builtins.y2milestone("Squid::writeAllSettings started") if !writeHttpPorts Builtins.y2error("Squid::writeAllSettings - writeHttpPorts failed") ok = false end if !writeACLs Builtins.y2error("Squid::writeAllSettings - writeACLs failed") ok = false end if !writeHttpAccesses Builtins.y2error("Squid::writeAllSettings - writeHttpAccesses failed") ok = false end if !writeRefreshPatterns Builtins.y2error( "Squid::writeAllSettings - writeRefreshPatterns failed" ) ok = false end if !writeRestSetting Builtins.y2error("Squid::writeAllSettings - writeRestSetting failed") ok = false end if ok if !SCR.Write(@squid_path, nil) Builtins.y2error( "Squid::Write - cannot write settings: `Write(%1, nil)", @squid_path ) ok = false end end Builtins.y2milestone("Squid::writeAllSettings finished") ok end |
- (Object) writeFirewallSettings
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
# File '../../src/modules/Squid.rb', line 1345 def writeFirewallSettings ok = true if !GetModified() Builtins.y2debug( "Squid::writeFirewallSettings - no setting to write, because nothing's changed" ) return ok end if !SCR.RegisterAgent( path(".firewall_service_definition"), term(:ag_ini, term(:SysConfigFile, @sysconfig_file)) ) ok = false Builtins.y2error( "Unable to register sysconfig agent for %1", @sysconfig_file ) end if !SCR.Write( path(".firewall_service_definition.TCP"), Builtins.mergestring(GetHttpPortsOnly(), " ") ) || !SCR.Write(path(".firewall_service_definition"), nil) ok = false Builtins.y2error( "Unable to write settings into sysconfig file %1", @sysconfig_file ) end if !SCR.UnregisterAgent(path(".firewall_service_definition")) ok = false Builtins.y2error( "Unable to unregister sysconfig agent for %1", @sysconfig_file ) end # write /etc/sysconfig/SuSEFirewall2.d/services/squid file: # string service_squid_file = # "## Name: Squid Service\n" + # "## Description: Opens ports for Squid\n" + # "TCP=\"" + mergestring(GetHttpPortsOnly(), " ") +"\"\n"; # if (!SCR::Write(.target.string, "/etc/sysconfig/SuSEfirewall2.d/services/squid", service_squid_file)){ # y2error("Squid::writeFirewallSettings - failed to write into /etc/sysconfig/SuSEfirewall2.d/services/squid file."); # ok = false; # } # write firewall settings SuSEFirewall.SetModified Progress.set(false) if !SuSEFirewall.Write Builtins.y2error( "Squid::writeFirewallSettings - SuSEFirewall::Write failed" ) ok = false end Progress.set(true) ok end |
- (Object) writeHttpAccesses
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 |
# File '../../src/modules/Squid.rb', line 1209 def writeHttpAccesses ok = true scr = [] tmp = [] Builtins.foreach(@http_accesses) do |value| tmp = [] if Ops.get_boolean(value, "allow", true) Ops.set(tmp, 0, "allow") else Ops.set(tmp, 0, "deny") end tmp = Convert.convert( Builtins.merge(tmp, Ops.get_list(value, "acl", [])), :from => "list", :to => "list <string>" ) scr = Builtins.add(scr, tmp) end Builtins.y2debug("Squid::Write - http_access: %1", scr) ok = false if !SCR.Write(Builtins.add(@squid_path, "http_access"), scr) ok end |
- (Object) writeHttpPorts
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 |
# File '../../src/modules/Squid.rb', line 1154 def writeHttpPorts ok = true scr = [] tmp = [] Builtins.foreach(@http_ports) do |value| tmp = [] if Ops.greater_than(Builtins.size(Ops.get_string(value, "host", "")), 0) Ops.set( tmp, 0, Ops.add( Ops.add(Ops.get_string(value, "host", ""), ":"), Ops.get_string(value, "port", "") ) ) else Ops.set(tmp, 0, Ops.get_string(value, "port", "")) end if Ops.get_boolean(value, "transparent", false) Ops.set(tmp, 1, "transparent") end scr = Builtins.add(scr, tmp) end Builtins.y2debug("Squid::Write - http_port: %1", scr) ok = false if !SCR.Write(Builtins.add(@squid_path, "http_port"), scr) ok end |
- (Object) writePermissions
1285 1286 1287 1288 1289 1290 1291 |
# File '../../src/modules/Squid.rb', line 1285 def writePermissions cache_dir = Ops.get(Ops.get_list(@settings, "cache_dir", []), 1, "") ok = true ok = false if !setWritePremissionsToCacheDir(cache_dir) ok end |
- (Object) writeRefreshPatterns
1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 |
# File '../../src/modules/Squid.rb', line 1236 def writeRefreshPatterns ok = true scr = [] tmp = [] Builtins.foreach(@refresh_patterns) do |value| tmp = [] if !Ops.get_boolean(value, "case_sensitive", false) Ops.set(tmp, 0, "-i ") end tmp = Builtins.add(tmp, Ops.get_string(value, "regexp", "")) tmp = Builtins.add(tmp, Ops.get_string(value, "min", "")) tmp = Builtins.add(tmp, Ops.get_string(value, "percent", "")) tmp = Builtins.add(tmp, Ops.get_string(value, "max", "")) scr = Builtins.add(scr, tmp) end Builtins.y2debug("Squid::Write - refresh_pattern: %1", scr) if !SCR.Write(Builtins.add(@squid_path, "refresh_pattern"), scr) ok = false end ok end |
- (Object) writeRestSetting
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 |
# File '../../src/modules/Squid.rb', line 1262 def writeRestSetting ok = true Builtins.foreach(@parameters) do |key, value| value = Ops.get_list(@settings, key, []) if Ops.greater_than(Builtins.size(value), 0) Builtins.y2debug("Squid::Write - %1: %2", key, value) if !SCR.Write(Builtins.add(@squid_path, key), [value]) Builtins.y2error("Squid::Write - cannot write %1 setting", key) ok = false end else Builtins.y2debug("Squid::Write - %1: %2", key, nil) if !SCR.Write(Builtins.add(@squid_path, key), nil) Builtins.y2error("Squid::Write - cannot write %1 setting", key) ok = false end end end ok end |