Module: Yast::NisServerRoutinesInclude

Defined in:
../../src/include/nis_server/routines.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) CheckForDHCPClient(domain)

Do the check if DHCP client is able to change domain name and warn user about this (see bug #28727)



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File '../../src/include/nis_server/routines.rb', line 128

def CheckForDHCPClient(domain)
  if NisServer.dhcp_changes_domain
    if NisServer.start_ypbind
      Popup.Warning(
        # warning popup
        _(
          "Your machine is set up to change the NIS domain name via DHCP.\n" +
            "This may replace the domain name just entered. Check your\n" +
            "settings and consider not running a DHCP client on a NIS server.\n"
        )
      )
    end
  end 
  # TODO: check
  # if domain from dhcp client is different then the one currently set

  nil
end

- (Object) GetFirewallWidget

Create the widget for opening firewall ports



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File '../../src/include/nis_server/routines.rb', line 149

def GetFirewallWidget
  settings = {
    "services"        => ["service:ypserv"],
    "display_details" => true,
    # firewall openning help
    "help"            => _(
      "<p><b>Firewall Settings</b><br>\n" +
        "To open the firewall to allow accessing the NIS server\n" +
        "from remote computers, set <b>Open Port in Firewall</b>.\n" +
        "To select interfaces on which to open the port, click <b>Firewall Details</b>.\n" +
        "This option is only available if the firewall is enabled.</p>\n"
    )
  }
  CWMFirewallInterfaces.CreateOpenFirewallWidget(settings)
end

- (Object) hasMasterThisSlave

unused

Returns:

  • Checks if this host is in the slaves list on master



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
# File '../../src/include/nis_server/routines.rb', line 87

def hasMasterThisSlave
  # list of maps: $["host": "foo.com", "map":"passwd.byuid"]
  running_maps = Convert.convert(
    SCR.Read(path(".run.ypwhich_m")),
    :from => "any",
    :to   => "list <map>"
  )
  if running_maps != nil
    running_maps_str = Builtins.maplist(running_maps) do |m|
      Ops.get_string(m, "map", "")
    end
    if Builtins.contains(running_maps_str, "ypservers")
      out = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), "/usr/bin/ypcat ypservers")
      )
      slaves = Ops.get_string(out, "stdout", "")
      if slaves != nil
        out = Convert.to_map(
          SCR.Execute(
            path(".target.bash_output"),
            "/usr/lib/yp/yphelper --hostname"
          )
        )
        hostname = Ops.get_string(out, "stdout", "")
        return false if hostname == ""
        hostname = Builtins.substring(
          hostname,
          0,
          Ops.subtract(Builtins.size(hostname), 1)
        )
        if Builtins.contains(Builtins.splitstring(slaves, "\n"), hostname)
          return true
        end
      end
    end
  end
  false
end

- (Object) initialize_nis_server_routines(include_target)



42
43
44
45
46
47
48
49
# File '../../src/include/nis_server/routines.rb', line 42

def initialize_nis_server_routines(include_target)
  textdomain "nis_server"

  Yast.import "CWMFirewallInterfaces"
  Yast.import "NisServer"
  Yast.import "Popup"
  Yast.import "Service"
end

- (Object) isYPServerConfigured

by reading the SCR, not the module data (not to confuse the user if he backs up to the first dialog)

Returns:

  • Checks if the YP server was already configured



74
75
76
# File '../../src/include/nis_server/routines.rb', line 74

def isYPServerConfigured
  Service.Enabled("ypserv")
end

- (Object) SlaveExists

Decides whether slave exists (according to makefile.NOPUSH)

Returns:

  • have_slave ornone_slave



81
82
83
# File '../../src/include/nis_server/routines.rb', line 81

def SlaveExists
  NisServer.nopush ? :none_slave : :have_slave
end

- (Object) toboolean(arg)

Converts from any type to boolean: true, “true” and nonzero integers are true, everything else including nil is false.

Parameters:

  • arg (Object)

    argument to convert

Returns:

  • converted value



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File '../../src/include/nis_server/routines.rb', line 56

def toboolean(arg)
  arg = deep_copy(arg)
  if arg == nil
    return false
  elsif Ops.is_boolean?(arg)
    return deep_copy(arg)
  elsif Ops.is_string?(arg)
    return arg == "true"
  elsif Ops.is_integer?(arg)
    return arg != 0
  else
    return false
  end
end