Class: Yast::RemoteClass
- Inherits:
-
Module
- Object
- Module
- Yast::RemoteClass
- Defined in:
- ../../src/modules/Remote.rb
Instance Method Summary (collapse)
-
- (Object) CreateSaxAutomaticConfiguration
Function creates automatic X configuration by calling sax2 see bugs #135605, #157342.
-
- (Object) Disable
Disables remote administration.
-
- (Object) Enable
Enables remote administration.
-
- (Object) IsDisabled
Checks if remote administration is currently disallowed.
-
- (Object) IsEnabled
Checks if remote administration is currently allowed.
- - (Object) main
-
- (Object) Propose
Function proposes a configuration But only if it hasn't been proposed already.
-
- (Object) Read
Read the current status.
-
- (Object) Reset
Reset all module data.
-
- (Object) ServerArgsRemoveOpt(server_args, option, has_value)
Removes all options (and its value) from .
-
- (Object) SetSecurityType(server_args, sec_type)
Appends option for particular security type.
-
- (Object) SetServerArgsOpt(server_args, option, value)
Add given option and its value to server_args.
-
- (Object) Summary
Create summary.
-
- (Object) Write
Update the SCR according to network settings.
- - (Object) WriteXinetd
Instance Method Details
- (Object) CreateSaxAutomaticConfiguration
Function creates automatic X configuration by calling sax2 see bugs #135605, #157342
234 235 236 237 238 239 240 241 242 243 |
# File '../../src/modules/Remote.rb', line 234 def CreateSaxAutomaticConfiguration command = "TERM=dumb /usr/sbin/sax2 -r -a | /usr/bin/grep -v '\\r$'" Builtins.y2milestone("Creating automatic Xconfiguration: %1", command) Builtins.y2milestone( "SaX2 returned: %1", SCR.Execute(path(".target.bash_output"), command) ) nil end |
- (Object) Disable
Disables remote administration.
91 92 93 94 95 |
# File '../../src/modules/Remote.rb', line 91 def Disable @allow_administration = false nil end |
- (Object) Enable
Enables remote administration.
84 85 86 87 88 |
# File '../../src/modules/Remote.rb', line 84 def Enable @allow_administration = true nil end |
- (Object) IsDisabled
Checks if remote administration is currently disallowed
79 80 81 |
# File '../../src/modules/Remote.rb', line 79 def IsDisabled !IsEnabled() end |
- (Object) IsEnabled
Checks if remote administration is currently allowed
74 75 76 |
# File '../../src/modules/Remote.rb', line 74 def IsEnabled @allow_administration 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 |
# File '../../src/modules/Remote.rb', line 35 def main Yast.import "UI" textdomain "network" Yast.import "Label" Yast.import "Mode" Yast.import "Package" Yast.import "Service" Yast.import "SuSEFirewall" Yast.import "Progress" Yast.import "Linuxrc" Yast.import "String" Yast.import "FileUtils" Yast.include self, "network/routines.rb" # security types supported by Xvnc @SEC_NONE = "none" @SEC_VNCAUTH = "vncauth" @SEC_TYPES = [@SEC_NONE, @SEC_VNCAUTH] @SEC_OPT_SECURITYTYPE = "securitytypes" # Currently, all attributes (enablement of remote access) # are applied on vnc1 even vnchttpd1 configuration # Allow remote administration @allow_administration = false # Default display manager @default_dm = "xdm" # Remote administration has been already proposed # Only force-reset can change it @already_proposed = false end |
- (Object) Propose
Function proposes a configuration But only if it hasn't been proposed already
117 118 119 120 121 |
# File '../../src/modules/Remote.rb', line 117 def Propose Reset() if !@already_proposed nil end |
- (Object) Read
Read the current status
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 |
# File '../../src/modules/Remote.rb', line 197 def Read xdm = Service.Enabled("xdm") dm_ra = Convert.to_string( SCR.Read(path(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS")) ) == "yes" @default_dm = Convert.to_string( SCR.Read(path(".sysconfig.displaymanager.DISPLAYMANAGER")) ) xinetd = Service.Enabled("xinetd") # are the proper services enabled in xinetd? xinetd_conf = Convert.convert( SCR.Read(path(".etc.xinetd_conf.services")), :from => "any", :to => "list <map>" ) vnc_conf = Builtins.filter(xinetd_conf) do |m| s = Ops.get_string(m, "service", "") s == "vnc1" || s == "vnchttpd1" end vnc = Builtins.size(vnc_conf) == 2 && Ops.get_boolean(vnc_conf, [0, "enabled"], false) && Ops.get_boolean(vnc_conf, [1, "enabled"], false) Builtins.y2milestone("XDM: %1, DM_R_A: %2", xdm, dm_ra) Builtins.y2milestone("xinetd: %1, VNC: %2", xinetd, vnc) @allow_administration = xdm && dm_ra && xinetd && vnc current_progress = Progress.set(false) SuSEFirewall.Read Progress.set(current_progress) true end |
- (Object) Reset
Reset all module data.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File '../../src/modules/Remote.rb', line 98 def Reset @already_proposed = true # Bugzilla #135605 - enabling Remote Administration when installing using VNC if Linuxrc.vnc @allow_administration = true else @allow_administration = false end Builtins.y2milestone( "Remote Administration was proposed as: %1", @allow_administration ? "enabled" : "disabled" ) nil end |
- (Object) ServerArgsRemoveOpt(server_args, option, has_value)
Removes all options <option> (and its value) from <server_args>
Note: server_args has to be valid. In case of incorrect input (e.g. -opt1= -opt2) is result undefined.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File '../../src/modules/Remote.rb', line 136 def ServerArgsRemoveOpt(server_args, option, has_value) return server_args if IsEmpty(server_args) || IsEmpty(option) # Note: value (e.g. filename in -passwdfile) cannot be quoted (a bug in Xvnc ?). # valid forms are: # e.g. -file=path_to_file or # e.g. -file path_to_file value_pattern_nquote = "[=[:space:]][^[:space:]]+" pattern = Builtins.sformat( "[[:space:]]*[-]{0,2}%1%2", option, has_value ? value_pattern_nquote : "" ) # Xvnc: # - is case insensitive to option names. # - option can be prefixed by 0 or up to 2 dashes # - option and value can be separated by space or = new_server_args = Builtins.tolower(server_args) new_server_args = String.CutRegexMatch(new_server_args, pattern, true) new_server_args end |
- (Object) SetSecurityType(server_args, sec_type)
Appends option for particular security type.
188 189 190 191 192 193 |
# File '../../src/modules/Remote.rb', line 188 def SetSecurityType(server_args, sec_type) # validate sec_type return server_args if !Builtins.contains(@SEC_TYPES, sec_type) SetServerArgsOpt(server_args, @SEC_OPT_SECURITYTYPE, sec_type) end |
- (Object) SetServerArgsOpt(server_args, option, value)
Add given option and its value to server_args.
If option is present already then all occurences of option are removed. New option value pair is added subsequently.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File '../../src/modules/Remote.rb', line 165 def SetServerArgsOpt(server_args, option, value) new_server_args = ServerArgsRemoveOpt( server_args, option, IsNotEmpty(value) ) new_server_args = Builtins.sformat( "%1 -%2 %3", new_server_args, option, value ) String.CutBlanks(new_server_args) end |
- (Object) Summary
Create summary
412 413 414 415 416 417 418 419 420 |
# File '../../src/modules/Remote.rb', line 412 def Summary if @allow_administration # Label in proposal text return _("Remote administration is enabled.") else # Label in proposal text return _("Remote administration is disabled.") end end |
- (Object) Write
Update the SCR according to network settings
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 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File '../../src/modules/Remote.rb', line 283 def Write steps = [ # Progress stage 1 _("Write firewall settings"), # Progress stage 2 _("Configure display manager") ] if Mode.normal # Progress stage 3 steps = Builtins.add(steps, _("Restart the services")) end caption = _("Saving Remote Administration Configuration") sl = 0 #100; //for testing Progress.New(caption, " ", Builtins.size(steps), steps, [], "") ProgressNextStage(_("Writing firewall settings...")) current_progress = Progress.set(false) SuSEFirewall.Write Progress.set(current_progress) Builtins.sleep(sl) ProgressNextStage(_("Configuring display manager...")) if @allow_administration # Install required packages packages = ["xinetd", "tightvnc", "xorg-x11", "xorg-x11-Xvnc"] #At least one windowmanager must be installed (#427044) #If none is, there, use icewm as fallback #Package::Installed uses rpm -q --whatprovides if !Package.Installed("windowmanager") packages = Builtins.add(packages, "icewm") end if !Package.InstallAll(packages) Builtins.y2error("Installing of required packages failed") return false end # Enable xinetd if !Service.Enable("xinetd") Builtins.y2error("Enabling of xinetd failed") return false end # Enable XDM if !Service.Enable("xdm") Builtins.y2error("Enabling of xdm failed") return false end # Bugzilla #135605 - creating xorg.conf based on the sax2 automatic configuration # It is a special case when the installation runs in VNC # - Xconfiguration in the hardware proposal is disabled CreateSaxAutomaticConfiguration() if Mode.installation && Linuxrc.vnc end # Set DISPLAYMANAGER_REMOTE_ACCESS in sysconfig/displaymanager SCR.Write( path(".sysconfig.displaymanager.DISPLAYMANAGER_REMOTE_ACCESS"), @allow_administration ? "yes" : "no" ) SCR.Write( path(".sysconfig.displaymanager.DISPLAYMANAGER_ROOT_LOGIN_REMOTE"), @allow_administration ? "yes" : "no" ) SCR.Write(path(".sysconfig.displaymanager"), nil) #Query xinetd presence here (it might not have been even installed before) have_xinetd = Package.Installed("xinetd") #Do this only if package xinetd is installed (#256385) return false if have_xinetd && !WriteXinetd() Builtins.sleep(sl) if Mode.normal dm_was_running = Service.Status("xdm") == 0 ProgressNextStage(_("Restarting the service...")) if @allow_administration SCR.Write(path(".etc.inittab.id"), "5:initdefault:") SCR.Write(path(".etc.inittab"), nil) #if allow_administration is set to true, xinetd must be already installed Service.Restart("xinetd") if !dm_was_running ##41611: with Service::Start, yast hangs :-( SCR.Execute( path(".target.bash_background"), "/etc/init.d/xdm start" ) end else if have_xinetd # xinetd may be needed for other services so we never turn it # off. It will exit anyway if no services are configured. # If it is running, restart it. Service.RunInitScript("xinetd", "try-restart") end end #do not call 'rcxdm reload' for gdm - use SuSEconfig if dm_was_running && @default_dm != "gdm" Service.RunInitScript("xdm", "reload") # import "Report"; # Report::Message (sformat ( # // message popup # // %1 is a system command # // Note: it is a DISPLAY manager, not a WINDOW manager # _("For the settings to take effect, the display manager # must be restarted. Because this terminates all X Window System # sessions, do it manually from the console with # \"%1\". # Note that restarting the X server alone is not enough."), # "rcxdm restart")); end Builtins.sleep(sl) Progress.NextStage end true end |
- (Object) WriteXinetd
245 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 |
# File '../../src/modules/Remote.rb', line 245 def WriteXinetd # Enable/disable vnc1 and vnchttpd1 in xinetd.d/vnc # If the port is changed, change also the help in remote/dialogs.ycp # The agent is in yast2-inetd.rpm xinetd = Convert.convert( SCR.Read(path(".etc.xinetd_conf.services")), :from => "any", :to => "list <map>" ) xinetd = Builtins.maplist(xinetd) do |m| s = Ops.get_string(m, "service", "") next deep_copy(m) if !(s == "vnc1" || s == "vnchttpd1") Ops.set(m, "changed", true) Ops.set(m, "enabled", @allow_administration) server_args = Ops.get_string(m, "server_args", "") if @allow_administration # use none authentication, xdm will take care of it Ops.set(m, "server_args", SetSecurityType(server_args, @SEC_NONE)) else # switch back to default when remote administration is disallowed. Ops.set( m, "server_args", ServerArgsRemoveOpt(server_args, @SEC_OPT_SECURITYTYPE, true) ) end Builtins.y2milestone("Updated xinet cfg: %1", m) deep_copy(m) end SCR.Write(path(".etc.xinetd_conf.services"), xinetd) true end |