Class: Yast::NisServerClass
- Inherits:
-
Module
- Object
- Module
- Yast::NisServerClass
- Defined in:
- ../../src/modules/NisServer.rb
Instance Method Summary (collapse)
-
- (Object) addError(s)
Adds an error to error_msg.
-
- (Object) addErrorDetail(s)
Adds an error to error_details.
-
- (Object) CallFunction01(f)
Kind-of-compatible replacement for term evaluation.
-
- (Object) Client
Calls NIS client configuration writing.
-
- (Object) EnsureDirectory(directory)
Ensures that the domain directory exists.
-
- (Hash) Export
Dump the nisServer settings to a single map (For use by autoinstallation.).
-
- (Object) GetAllMaps
All tables that ypserv Makefile knows about.
-
- (Object) getMaster
Gets the master server (name or IP?) from any of this server's maps.
-
- (Boolean) GetModified
Functions which returns if the settings were modified.
-
- (Object) GetSaveList(workflow)
Returns a list of what to save ].
-
- (Boolean) Import(settings)
Get all nisServer settings from the first parameter (For use by autoinstallation.).
-
- (Object) isYPMaster
Determines if the current host is YP master or not.
-
- (Object) isYPServerInstalled
by querying RPM for ypserv.
- - (Object) main
-
- (Object) Read
Read all NIS server settings.
-
- (Object) Remove(file)
Removes file or directory and log errors.
-
- (Object) SaveSecurenets
Save securenets list.
-
- (Object) SaveSlaves
Save list of slaves by calling appropriate any agent.
-
- (Object) SaveVariables(which)
Saves config variables according to workflow.
- - (Object) SCRGet(p, default_val)
- - (Object) SCRGetInt(p, default_val)
-
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to “true”.
-
- (Object) Summary
Create a textual summary and a list of unconfigured cards.
-
- (Object) Write
Write all NIS server settings.
-
- (Object) YPDaemons(workflow)
Starts or stop daemons.
-
- (Object) YPGetMaps
Gets the YP maps from master for slave.
-
- (Object) YPMake
Creates initial database.
- - (Object) YPMakefileVars
- - (Object) YPSecurenets
- - (Object) YPServers
- - (Object) YPServerVars
- - (Object) YPSystemVars
Instance Method Details
- (Object) addError(s)
Adds an error to error_msg
454 455 456 457 458 |
# File '../../src/modules/NisServer.rb', line 454 def addError(s) @error_msg = Ops.add(@error_msg, s) nil end |
- (Object) addErrorDetail(s)
Adds an error to error_details
462 463 464 465 466 467 468 469 |
# File '../../src/modules/NisServer.rb', line 462 def addErrorDetail(s) @error_details = Ops.add( @error_details, Builtins.sformat("<pre>%1</pre>", s) ) nil end |
- (Object) CallFunction01(f)
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
# File '../../src/modules/NisServer.rb', line 475 def CallFunction01(f) f = deep_copy(f) fp = Ops.get(f, 0) if Ops.is(fp, "void ()") fp0 = Convert.convert(fp, :from => "any", :to => "void ()") fp0.call elsif Ops.is(fp, "void (any)") fp1 = Convert.convert(fp, :from => "any", :to => "void (any)") fp1.call(Ops.get(f, 1)) else Builtins.y2error("Bad function type: %1", fp) end nil end |
- (Object) Client
Calls NIS client configuration writing
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 |
# File '../../src/modules/NisServer.rb', line 954 def Client Yast.import "Nis" c = { "start_nis" => @start_ypbind, "nis_domain" => @domain, "nis_servers" => ["127.0.0.1"] } if @start_ypbind # static policy assures local client Ops.set(c, "netconfig_policy", "") end progress_orig = Progress.set(false) ok = Nis.Import(c) && Nis.Write Progress.set(progress_orig) if !ok # To translators: message in the popup dialog addError(_("Error while configuring the client.\n")) addErrorDetail(Nis.YpbindErrors) end nil end |
- (Object) EnsureDirectory(directory)
Ensures that the domain directory exists.
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
# File '../../src/modules/NisServer.rb', line 585 def EnsureDirectory(directory) output = {} if SCR.Read(path(".target.size"), directory) == -1 output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("/bin/mkdir %1", directory) ) ) if Ops.greater_than( Builtins.size(Ops.get_string(output, "stderr", "")), 0 ) # To translators: message in the popup dialog addError( Builtins.sformat(_("Directory %1 cannot be created.\n"), directory) ) addErrorDetail(Ops.get_string(output, "stderr", "")) return false end end true end |
- (Hash) Export
Dump the nisServer settings to a single map (For use by autoinstallation.)
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 |
# File '../../src/modules/NisServer.rb', line 1244 def Export # TODO FIXME: your code here (return the above mentioned variables)... settings = {} Ops.set(settings, "domain", @domain) type = "none" if @ui_what == :master type = "master" elsif @ui_what == :slave type = "slave" end Ops.set(settings, "server_type", type) Ops.set(settings, "minuid", @minuid) Ops.set(settings, "mingid", @mingid) Ops.set(settings, "merge_passwd", @merge_passwd) slaves = [] slaves = deep_copy(@ypservers) # FIXME: NI # global boolean start_ypbind = false; Ops.set(settings, "start_ypbind", @start_ypbind) Ops.set(settings, "start_ypxfrd", @start_ypxfrd) Ops.set(settings, "start_yppasswdd", @start_yppasswdd) Ops.set(settings, "maps_to_serve", @maps) Ops.set(settings, "pwd_srcdir", @pwd_srcdir) Ops.set(settings, "slaves", slaves) Ops.set(settings, "pwd_chsh", @pwd_chsh) Ops.set(settings, "pwd_chfn", @pwd_chfn) Ops.set(settings, "nopush", @nopush) Ops.set(settings, "securenets", @securenets) deep_copy(settings) end |
- (Object) GetAllMaps
All tables that ypserv Makefile knows about
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File '../../src/modules/NisServer.rb', line 159 def GetAllMaps [ "passwd", "group", "hosts", "rpc", "services", "netid", "protocols", "netgrp", "mail", "shadow", "publickey", "networks", "ethers", "bootparams", "printcap", "amd.home", "auto.master", "auto.home", "auto.local", "passwd.adjunct", "timezone", "locale", "netmasks" ] end |
- (Object) getMaster
Gets the master server (name or IP?) from any of this server's maps
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
# File '../../src/modules/NisServer.rb', line 407 def getMaster dn = @domain return nil if dn == "" ddir = Builtins.sformat("/var/yp/%1", dn) any_map = nil if Ops.greater_or_equal(SCR.Read(path(".target.size"), ddir), 0) dmaps = Convert.to_list(SCR.Read(path(".target.dir"), ddir)) any_map = Ops.get_string(dmaps, 0) end return nil if any_map == nil command = Builtins.sformat( "/usr/lib/yp/makedbm -u /var/yp/%1/%2 | grep ^YP_MASTER_NAME", dn, any_map ) out = Convert.to_map(SCR.Execute(path(".target.bash_output"), command)) l = Builtins.splitstring(Ops.get_string(out, "stdout", ""), " \t\n") Ops.get(l, 1) end |
- (Boolean) GetModified
Functions which returns if the settings were modified
151 152 153 |
# File '../../src/modules/NisServer.rb', line 151 def GetModified @modified end |
- (Object) GetSaveList(workflow)
Returns a list of what to save ]</pre>
987 988 989 990 991 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 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 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 1147 1148 1149 1150 1151 1152 1153 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 1184 1185 1186 1187 1188 1189 |
# File '../../src/modules/NisServer.rb', line 987 def GetSaveList(workflow) result = [] # do this remove for all workflows if @domain != "" result = [ { # To translators: progress label "save_label" => Builtins.sformat( _("Remove /var/yp/%1"), @domain ), # To translators: progress label "progress_label" => Builtins.sformat( _("Removing /var/yp/%1"), @domain ), "function" => [ fun_ref(method(:Remove), "void (any)"), Builtins.sformat("/var/yp/%1", @domain) ] } ] end # *** none YP server flow if workflow == :none result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Stop running daemons."), # To translators: progress label "progress_label" => _( "Stopping running daemons." ), "function" => [ fun_ref(method(:YPDaemons), "void (any)"), :none ] } ] ) # *** slave YP server flow elsif workflow == :slave result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Get maps from master."), # To translators: progress label "progress_label" => _( "Getting maps from master." ), "function" => [fun_ref(method(:YPGetMaps), "void ()")] }, # To translators: progress label { "save_label" => _("Save hosts allowed to query server."), # To translators: progress label "progress_label" => _( "Saving hosts allowed to query server." ), "function" => [fun_ref(method(:SaveSecurenets), "void ()")] }, # To translators: progress label { "save_label" => _("Set config variables."), # To translators: progress label "progress_label" => _( "Setting config variables." ), "function" => [ fun_ref(method(:SaveVariables), "void (any)"), :slave ] }, # To translators: progress label { "save_label" => _("Start daemon."), # To translators: progress label "progress_label" => _( "Starting daemon." ), "function" => [ fun_ref(method(:YPDaemons), "void (any)"), :slave ] } ] ) # *** master YP server flow elsif workflow == :master result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Save hosts allowed to query server."), # To translators: progress label "progress_label" => _( "Saving hosts allowed to query server." ), "function" => [fun_ref(method(:SaveSecurenets), "void ()")] } ] ) if !@nopush && Ops.greater_than(Builtins.size(@ypservers), 0) result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Save slaves."), # To translators: progress label "progress_label" => _( "Saving slaves." ), "function" => [fun_ref(method(:SaveSlaves), "void ()")] } ] ) end result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Set config variables."), # To translators: progress label "progress_label" => _( "Setting config variables." ), "function" => [ fun_ref(method(:SaveVariables), "void (any)"), :master ] }, # To translators: progress label { "save_label" => _("Start daemons."), # To translators: progress label "progress_label" => _( "Starting daemons." ), "function" => [ fun_ref(method(:YPDaemons), "void (any)"), :master ] }, # To translators: progress label { "save_label" => _("Create initial database."), # To translators: progress label "progress_label" => _( "Creating database." ), "function" => [fun_ref(method(:YPMake), "void ()")] } ] ) end # slave or master is also client ? if Builtins.contains([:slave, :master], workflow) if @start_ypbind result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Start NIS client."), # To translators: progress label "progress_label" => _( "Starting NIS client." ), "function" => [fun_ref(method(:Client), "void ()")] } ] ) elsif @nisclient_local result = Ops.add( result, [ # To translators: progress label { "save_label" => _("Stop NIS client."), # To translators: progress label "progress_label" => _( "Stopping NIS client." ), "function" => [fun_ref(method(:Client), "void ()")] } ] ) end end deep_copy(result) end |
- (Boolean) Import(settings)
Get all nisServer settings from the first parameter (For use by autoinstallation.)
1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 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 1234 1235 1236 1237 1238 1239 |
# File '../../src/modules/NisServer.rb', line 1198 def Import(settings) settings = deep_copy(settings) # Get default variables type = Ops.get_string(settings, "server_type", "none") if type == "master" @ui_what = :master elsif type == "slave" @ui_what = :slave else @ui_what = :none end @domain = Ops.get_string(settings, "domain", "") @minuid = Ops.get_integer(settings, "minuid", 0) @mingid = Ops.get_integer(settings, "mingid", 0) @merge_passwd = Ops.get_boolean(settings, "merge_passwd", false) @ypservers = Ops.get_list(settings, "slaves", []) YPServers() if @ypservers == [] @start_ypbind = Ops.get_boolean(settings, "start_ypbind", false) @start_ypxfrd = Ops.get_boolean(settings, "start_ypxfrd", false) @start_yppasswdd = Ops.get_boolean(settings, "start_yppasswdd", false) @maps = Ops.get_list(settings, "maps_to_serve", []) YPMakefileVars() if @maps == [] @pwd_srcdir = Ops.get_string(settings, "pwd_srcdir", "/etc") @pwd_chsh = Ops.get_boolean(settings, "pwd_chsh", false) @pwd_chfn = Ops.get_boolean(settings, "pwd_chfn", false) @nopush = Ops.get_boolean(settings, "nopush", false) @securenets = Ops.get_list(settings, "securenets", []) YPSecurenets() if @securenets == [] true end |
- (Object) isYPMaster
Returns Determines if the current host is YP master or not
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File '../../src/modules/NisServer.rb', line 429 def isYPMaster master = getMaster if master == nil return false # can't decide end output = Convert.to_map( SCR.Execute( path(".target.bash_output"), "/usr/lib/yp/yphelper --hostname" ) ) yphelper_hostname = Ops.get_string(output, "stdout", "") master == Builtins.deletechars(yphelper_hostname, "\n") end |
- (Object) isYPServerInstalled
by querying RPM for ypserv
448 449 450 |
# File '../../src/modules/NisServer.rb', line 448 def isYPServerInstalled SCR.Execute(path(".target.bash"), "/bin/rpm -q ypserv") == 0 end |
- (Object) main
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 |
# File '../../src/modules/NisServer.rb', line 36 def main textdomain "nis_server" Yast.import "FileUtils" Yast.import "NetworkInterfaces" Yast.import "Package" Yast.import "Progress" Yast.import "Service" Yast.import "Summary" Yast.import "SuSEFirewall" # Data was modified? @modified = false #TODO: make this work # Write only, used during autoinstallation. # Don't run services and SuSEconfig, it's all done at one place. @write_only = false # ------------------------------------------------------------ # The domain we are serving. # (for simplicity, we assume a single domain) # US ".etc.defaultdomain" @domain = "" # For warning if the domain was changed. # TODO delegate to the client module? @old_domainname = "" # What kind of server to run: `master, `slave, `none @ui_what = :none # If we are a slave, where is the master? #(it may actually be a hostname, TODO solve like in the client using nsswitch) @ui_master_ip = "" # Maps to be served @maps = [] # Minimal UID to include in the user maps @minuid = 0 # Minimal GID to include in the user maps @mingid = 0 # Merge passwd and shadow to one map? # Makefile: string true|false @merge_passwd = false # Don't push the changes to slave servers. (useful if there aren't any) # Makefile: string true|false @nopush = false # Slave servers @ypservers = [] # # **Structure:** # # securenet # network: string # netmask: string #* or # hash: "#" # (optional) comment: string @securenets = [] # Start also the client? (only when client is configured locally) @start_ypbind = false # NIS client is configured localy (with current machine as server) @nisclient_local = true # Start also the map transfer daemon? @start_ypxfrd = false # Start also the password daemon? @start_yppasswdd = false # YPPWD_SRCDIR - source directory for passwd data @pwd_srcdir = "/etc" # YPPWD_CHFN - allow changing the full name? @pwd_chfn = false # YPPWD_CHSH - allow changing the login shell? @pwd_chsh = false # If DHCP client could change domain name (#28727) @dhcp_changes_domain = false # Packages to be installed for this module to operate @required_packages = ["ypbind", "ypserv"] # ---------------------------------------- # plain text @error_msg = "" # rich text @error_details = "" end |
- (Object) Read
Read all NIS server settings.
190 191 192 193 194 195 196 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 231 232 233 234 235 236 237 238 239 240 241 242 243 244 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 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 |
# File '../../src/modules/NisServer.rb', line 190 def Read # help text 1/1 help = _("<p>Please wait while reading the configuration.</p>") # dialog heading title = _("Initializing NIS server setup") progress_title = " " files = [ "/var/yp/Makefile", "/etc/sysconfig/ypserv", "/etc/defaultdomain", "/var/yp/securenets", "/var/yp/ypservers" ] vars = [ fun_ref(method(:YPMakefileVars), "void ()"), fun_ref(method(:YPServerVars), "void ()"), fun_ref(method(:YPSystemVars), "void ()"), fun_ref(method(:YPSecurenets), "void ()"), fun_ref(method(:YPServers), "void ()") ] Progress.New( title, progress_title, Ops.add(Builtins.size(files), 3), Ops.add( # To translators: progress label %1 is filename Builtins.maplist(files) do |file| Builtins.sformat(_("Load '%1' file"), file) end, [ # Trans: progress label _("Determine running services"), # Trans: progress label _("Determine server type"), # progress stage label _("Read firewall settings") ] ), Ops.add( # To translators: progress label %1 is filename Builtins.maplist(files) do |file| Builtins.sformat(_("Loading '%1'..."), file) end, [ # Trans: progress label _("Determining running services..."), # Trans: progress label _("Determining server type..."), # progress step label _("Reading firewall settings..."), # Trans: progress label _("Done.") ] ), help ) i = 0 while Ops.less_than(i, Builtins.size(files)) Progress.NextStage varfunc = Ops.get(vars, i) varfunc.call i = Ops.add(i, 1) end Progress.NextStage # "ypserv" is handled elsewhere @start_ypbind = Service.Enabled("ypbind") # Check if nis client is configured localy or not # -> client configuration should not be touched when it uses remote server if @start_ypbind Yast.import "Nis" Yast.import "DNS" Nis.Read remote = false Builtins.foreach(Builtins.splitstring(Nis.GetServers, " ")) do |server| remote = true if !DNS.IsHostLocal(server) end if remote || Nis.policy != "" && !Builtins.issubstring(Nis.policy, "STATIC") @start_ypbind = false @nisclient_local = false end end @start_ypxfrd = Service.Enabled("ypxfrd") @start_yppasswdd = Service.Enabled("yppasswdd") # TODOm: fix like the client (?) if @domain == "" # a DHCP client may set the domainname too: # /etc/sysconfig/network/dhcp:DHCLIENT_SET_DOMAINNAME out = Convert.to_map( SCR.Execute(path(".target.bash_output"), "/bin/ypdomainname") ) @domain = Builtins.deletechars(Ops.get_string(out, "stdout", ""), "\n") end @old_domainname = @domain # Check if any device one is configured with DHCP, to know if domain name # won't be replaced by dhcp (#28727) NetworkInterfaces.Read if Ops.greater_than( Builtins.size(NetworkInterfaces.Locate("BOOTPROTO", "dhcp")), 0 ) && SCR.Read( path(".sysconfig.network.config.NETCONFIG_NIS_SETDOMAINNAME") ) != "no" @dhcp_changes_domain = true end Progress.NextStage if !isYPServerInstalled @ui_what = :none else @ui_what = isYPMaster ? :master : :slave #FIXME: this will give a hostname. the label says IP. master = getMaster @ui_master_ip = master if master != nil end Progress.NextStage progress_orig = Progress.set(false) SuSEFirewall.Read Progress.set(progress_orig) Progress.NextStage @modified = false true end |
- (Object) Remove(file)
Removes file or directory and log errors
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File '../../src/modules/NisServer.rb', line 560 def Remove(file) file = deep_copy(file) if SCR.Read(path(".target.size"), file) != -1 output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("/bin/rm -rf %1", file) ) ) if Ops.greater_than( Builtins.size(Ops.get_string(output, "stderr", "")), 0 ) # To translators: message in the popup dialog addError(Builtins.sformat(_("Error while removing %1\n"), file)) addErrorDetail(Ops.get_string(output, "stderr", "")) end end nil end |
- (Object) SaveSecurenets
Save securenets list
724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
# File '../../src/modules/NisServer.rb', line 724 def SaveSecurenets SCR.Execute( path(".target.bash"), Builtins.sformat("/bin/cp %1 %1.YaST2.save", "/var/yp/securenets") ) if !SCR.Write(path(".var.yp.securenets"), @securenets) # To translators: message in the popup dialog addError( Builtins.sformat(_("Error saving file %1\n"), "/var/yp/securenets") ) end nil end |
- (Object) SaveSlaves
Save list of slaves by calling appropriate any agent
741 742 743 744 745 746 747 748 749 750 751 752 753 754 |
# File '../../src/modules/NisServer.rb', line 741 def SaveSlaves SCR.Execute( path(".target.bash"), Builtins.sformat("/bin/cp %1 %1.YaST2.save", "/var/yp/ypservers") ) if !SCR.Write(path(".var.yp.ypservers"), @ypservers) # To translators: message in the popup dialog addError( Builtins.sformat(_("Error saving file %1\n"), "/var/yp/ypservers") ) end nil end |
- (Object) SaveVariables(which)
Saves config variables according to workflow
758 759 760 761 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 802 803 804 805 806 807 808 809 810 |
# File '../../src/modules/NisServer.rb', line 758 def SaveVariables(which) which = deep_copy(which) if !SCR.Write(path(".etc.defaultdomain"), @domain) # To translators: message in the popup dialog addError(_("Error setting up domain name\n")) end if which == :master settings = { ".sysconfig.ypserv.YPPWD_SRCDIR" => @pwd_srcdir, ".sysconfig.ypserv.YPPWD_CHFN" => @pwd_chfn ? "yes" : "no", ".sysconfig.ypserv.YPPWD_CHSH" => @pwd_chsh ? "yes" : "no", ".var.yp.makefile.maps" => @maps, ".var.yp.makefile.MINUID" => Builtins.sformat("%1", @minuid), ".var.yp.makefile.MINGID" => Builtins.sformat("%1", @mingid), ".var.yp.makefile.MERGE_PASSWD" => @merge_passwd ? "true" : "false", ".var.yp.makefile.NOPUSH" => @nopush ? "true" : "false" } Builtins.maplist(settings) do |var, value| if !SCR.Write(Builtins.topath(var), value) var_parts = Builtins.splitstring(var, ".") var_name = Ops.get_string( var_parts, Ops.subtract(Builtins.size(var_parts), 1), "" ) # To translators: message in the popup dialog addError( Builtins.sformat(_("Error setting up variable %1\n"), var_name) ) end end if !SCR.Write(path(".sysconfig.ypserv"), nil) # To translators: message in the popup dialog addError( Builtins.sformat( _("Error saving file %1\n"), "/etc/sysconfig/ypserv" ) ) end if !SCR.Write(path(".var.yp.makefile"), nil) # To translators: message in the popup dialog addError( Builtins.sformat(_("Error saving file %1\n"), "/var/yp/Makefile") ) end end nil end |
- (Object) SCRGet(p, default_val)
328 329 330 331 332 |
# File '../../src/modules/NisServer.rb', line 328 def SCRGet(p, default_val) default_val = deep_copy(default_val) v = SCR.Read(p) v != nil ? v : default_val end |
- (Object) SCRGetInt(p, default_val)
334 335 336 337 338 339 |
# File '../../src/modules/NisServer.rb', line 334 def SCRGetInt(p, default_val) v = SCR.Read(p) v != nil && v != "" && Ops.is_string?(v) ? Builtins.tointeger(Convert.to_string(v)) : default_val end |
- (Object) SetModified
Function sets internal variable, which indicates, that any settings were modified, to "true"
143 144 145 146 147 |
# File '../../src/modules/NisServer.rb', line 143 def SetModified @modified = true nil end |
- (Object) Summary
Create a textual summary and a list of unconfigured cards
1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 |
# File '../../src/modules/NisServer.rb', line 1287 def Summary summary = "" nc = Summary.NotConfigured summary = Summary.AddHeader(summary, _("NIS Domain")) summary = Summary.AddLine(summary, @domain != "" ? @domain : nc) [summary, []] end |
- (Object) Write
Write all NIS server settings
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 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
# File '../../src/modules/NisServer.rb', line 493 def Write # help text 1/1 help = _("<p>Please wait until the configuration is saved.</p>") # dialog heading title = _("Saving NIS server setup") progress_title = " " save_list = GetSaveList(@ui_what) step = 0 # To translators: dialog title Progress.New( title, progress_title, Ops.add(Builtins.size(save_list), 1), Ops.add( Builtins.maplist(save_list) { |e| Ops.get_string(e, "save_label", "") }, [ # progress bar stage _("Save firewall settings") ] ), Ops.add( Builtins.maplist(save_list) do |e| Ops.get_string(e, "progress_label", "") end, [ # progress step _("Saving firewall settings..."), # progress step _("Done.") ] ), help ) Builtins.foreach(save_list) do |save_item| Progress.NextStage fl = Ops.get_list(save_item, "function", []) Builtins.y2debug("Calling: %1", fl) if Builtins.size(fl) == 1 fp = Convert.convert(Ops.get(fl, 0), :from => "any", :to => "void ()") fp.call elsif Builtins.size(fl) == 2 fp = Convert.convert( Ops.get(fl, 0), :from => "any", :to => "void (any)" ) fp.call(Ops.get(fl, 1)) else Builtins.y2internal("Bad save list item %1", fl) end end Progress.NextStage progress_orig = Progress.set(false) SuSEFirewall.Write Progress.set(progress_orig) Progress.NextStage true end |
- (Object) YPDaemons(workflow)
Starts or stop daemons
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 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 |
# File '../../src/modules/NisServer.rb', line 814 def YPDaemons(workflow) workflow = deep_copy(workflow) output = {} to_stop = [] to_start = [] rpc_mapper = "portmap" rpc_mapper = "rpcbind" if Package.Installed("rpcbind") if workflow == :none to_stop = ["ypxfrd", "yppasswdd", "ypserv"] elsif workflow == :slave to_stop = ["ypxfrd", "yppasswdd", "ypserv"] to_start = [rpc_mapper, "ypserv"] elsif workflow == :master to_stop = ["ypxfrd", "yppasswdd", "ypserv"] to_start = [rpc_mapper, "ypserv"] to_start = Builtins.add(to_start, "yppasswdd") if @start_yppasswdd to_start = Builtins.add(to_start, "ypxfrd") if @start_ypxfrd end services = Builtins.listmap(to_stop) { |s| { s => "disable" } } Builtins.foreach(to_start) { |s| Ops.set(services, s, "enable") } Builtins.foreach(services) { |s, action| Service.Adjust(s, action) } Builtins.foreach(to_stop) do |d| Builtins.y2milestone("Stopping daemon %1", d) # $#@! broken by bug 9648 ret = Service.RunInitScript(d, "stop") if ret != 0 # To translators: message in the popup dialog addError(Builtins.sformat(_("Error while stopping %1 daemon\n"), d)) end end Builtins.foreach(to_start) do |d| Builtins.y2milestone("Starting daemon %1", d) # start only if not running. essential for portmap! (bug #9999) if Service.Status(d) != 0 ret = Service.RunInitScript(d, "start") if ret != 0 # To translators: message in the popup dialog addError(Builtins.sformat(_("Error while starting %1 daemon\n"), d)) end end end nil end |
- (Object) YPGetMaps
Gets the YP maps from master for slave
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
# File '../../src/modules/NisServer.rb', line 611 def YPGetMaps output = {} dn = @domain dndir = Builtins.sformat("/var/yp/%1", dn) # first make sure that the directory exists return if !EnsureDirectory(dndir) # and get the maps master = @ui_master_ip output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/usr/lib/yp/yphelper --maps %1 --domainname %2", master, dn ) ) ) if Ops.get_integer(output, "exit", 1) != 0 # To translators: message in the popup dialog addError(Builtins.sformat(_("Cannot get list of maps.\n"))) addErrorDetail(Ops.get_string(output, "stderr", "")) end running_maps = Builtins.splitstring( Ops.get_string(output, "stdout", ""), "\n" ) # the element after the last newline is empty, remove it if Ops.greater_than(Builtins.size(running_maps), 0) running_maps = Builtins.remove( running_maps, Ops.subtract(Builtins.size(running_maps), 1) ) end Builtins.maplist(running_maps) do |map_name| output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/usr/lib/yp/ypxfr -f -h %1 -d %2 %3", master, dn, map_name ) ) ) if Ops.get_integer(output, "exit", 1) != 0 # To translators: message in the popup dialog addError( Builtins.sformat( _("Error while retrieving %1 map from master.\n"), map_name ) ) addErrorDetail(Ops.get_string(output, "stderr", "")) end end if !Builtins.contains(running_maps, "ypservers") # To translators: message in the popup dialog addError(_("Could not get list with slaves.\n")) else output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat("/usr/lib/yp/makedbm -u %1/ypservers", dndir) ) ) slaves = Ops.get_string(output, "stdout") if slaves != nil output = Convert.to_map( SCR.Execute( path(".target.bash_output"), "/usr/lib/yp/yphelper --hostname" ) ) hostname = Builtins.deletechars( Ops.get_string(output, "stdout", ""), "\n" ) failed = true Builtins.foreach(Builtins.splitstring(slaves, "\n")) do |line| lline = Builtins.splitstring(line, " \t") if Ops.get_string(lline, 0, "") == hostname && Ops.get_string(lline, 1, "") == hostname failed = false end end if failed # To translators: message in the popup dialog, %1 is hostname addError( Builtins.sformat( _( "Hostname of this host (%1)\nis not listed in the master's list.\n" ), hostname ) ) end end end nil end |
- (Object) YPMake
Creates initial database
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 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 |
# File '../../src/modules/NisServer.rb', line 867 def YPMake output = {} # create the source directory, if it does not exist # (and passwd, shadow, group) return if !EnsureDirectory(@pwd_srcdir) create_ok = true Builtins.foreach(["passwd", "group"]) do |s| p2 = Ops.add(Ops.add(@pwd_srcdir, "/"), s) if Ops.less_than(SCR.Read(path(".target.size"), p2), 0) create_ok = create_ok && 0 == SCR.Execute( path(".target.bash"), Builtins.sformat( "/usr/bin/touch %1; /bin/chmod 0644 %1; /bin/chown root.root %1", p2 ) ) end end p = Ops.add(@pwd_srcdir, "/shadow") if Ops.less_than(SCR.Read(path(".target.size"), p), 0) create_ok = create_ok && 0 == SCR.Execute( path(".target.bash"), Builtins.sformat( "/usr/bin/touch %1; /bin/chmod 0640 %1; /bin/chown root.shadow %1", p ) ) end if !create_ok # error popup addError( Builtins.sformat(_("Error while creating an empty user database.\n")) ) end dn = @domain return if !EnsureDirectory(Builtins.sformat("/var/yp/%1", dn)) output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/usr/bin/make -C /var/yp/%1 -f ../Makefile NOPUSH=true ypservers", dn ) ) ) if Ops.greater_than( Builtins.size(Ops.get_string(output, "stderr", "")), 0 ) # To translators: message in the popup dialog addError(_("Error while creating the ypservers map.\n")) addErrorDetail(Ops.get_string(output, "stderr", "")) end output = Convert.to_map( SCR.Execute( path(".target.bash_output"), Builtins.sformat( "/usr/bin/make -C /var/yp NOPUSH=true LOCALDOMAIN=%1", dn ) ) ) if Ops.greater_than( Builtins.size(Ops.get_string(output, "stderr", "")), 0 ) # To translators: message in the popup dialog addError(_("Error while creating database.\n")) addErrorDetail(Ops.get_string(output, "stderr", "")) end nil end |
- (Object) YPMakefileVars
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File '../../src/modules/NisServer.rb', line 340 def YPMakefileVars return if !FileUtils.Exists("/var/yp/Makefile") @maps = Convert.convert( SCRGet( path(".var.yp.makefile.maps"), ["passwd", "group", "rpc", "services", "netid"] ), :from => "any", :to => "list <string>" ) @minuid = SCRGetInt(path(".var.yp.makefile.MINUID"), 100) @mingid = SCRGetInt(path(".var.yp.makefile.MINGID"), 100) @merge_passwd = Convert.to_string( SCRGet(path(".var.yp.makefile.MERGE_PASSWD"), "true") ) == "true" @nopush = Convert.to_string( SCRGet(path(".var.yp.makefile.NOPUSH"), "true") ) == "true" nil end |
- (Object) YPSecurenets
378 379 380 381 382 383 384 385 386 387 388 389 |
# File '../../src/modules/NisServer.rb', line 378 def YPSecurenets @securenets = [{ "network" => "127.0.0.0", "netmask" => "255.0.0.0" }] if FileUtils.Exists("/var/yp/securenets") @securenets = Convert.convert( SCRGet(path(".var.yp.securenets"), @securenets), :from => "any", :to => "list <map>" ) end nil end |
- (Object) YPServers
390 391 392 393 394 395 396 397 398 399 400 |
# File '../../src/modules/NisServer.rb', line 390 def YPServers if FileUtils.Exists("/var/yp/ypservers") @ypservers = Convert.convert( SCRGet(path(".var.yp.ypservers"), []), :from => "any", :to => "list <string>" ) end nil end |
- (Object) YPServerVars
362 363 364 365 366 367 368 369 370 371 372 |
# File '../../src/modules/NisServer.rb', line 362 def YPServerVars if FileUtils.Exists("/etc/sysconfig/ypserv") @pwd_srcdir = Convert.to_string( SCRGet(path(".sysconfig.ypserv.YPPWD_SRCDIR"), "/etc") ) @pwd_chfn = SCRGet(path(".sysconfig.ypserv.YPPWD_CHFN"), "no") == "yes" @pwd_chsh = SCRGet(path(".sysconfig.ypserv.YPPWD_CHSH"), "no") == "yes" end nil end |
- (Object) YPSystemVars
373 374 375 376 377 |
# File '../../src/modules/NisServer.rb', line 373 def YPSystemVars @domain = Convert.to_string(SCRGet(path(".etc.defaultdomain"), "local")) nil end |