Class: Yast::NfsClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
../../src/modules/Nfs.rb

Overview

NFS client configuration data, I/O functions.

Instance Method Summary (collapse)

Instance Method Details

- (Hash) AutoPackages

Return required packages for auto-installation

Returns:

  • (Hash)

    of packages to be installed and to be removed



649
650
651
# File '../../src/modules/Nfs.rb', line 649

def AutoPackages
  { "install" => @required_packages, "remove" => [] }
end

- (Object) EscapeSpaces(entries)

Escape spaces “ ” -> “040” in all values of all entries

Parameters:

  • entries (Array<Hash{String => Object>})

    a list of maps, such as nfs_entries

Returns:

  • escaped entries



260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File '../../src/modules/Nfs.rb', line 260

def EscapeSpaces(entries)
  entries = deep_copy(entries)
  Builtins.maplist(entries) do |entry|
    Builtins.mapmap(entry) do |key, value|
      {
        key => if Ops.is_string?(value)
                 EscapeSpaces1(Convert.to_string(value))
               else
                 value
               end
      }
    end
  end
end

- (Object) EscapeSpaces1(s)

Escape spaces “ ” -> “040”.

Parameters:

  • s (String)

    a string or nil

Returns:

  • escaped string or nil



252
253
254
255
# File '../../src/modules/Nfs.rb', line 252

def EscapeSpaces1(s)
  return nil if s.nil?
  s.gsub(/ /) { "\\040" } # block prevents interpreting \ as backreference
end

- (Object) Export

Dump the NFS settings to a map, for autoinstallation use.

Returns:

  • a list of nfs entries.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File '../../src/modules/Nfs.rb', line 226

def Export
  settings = {}

  Ops.set(settings, "enable_nfs4", @nfs4_enabled)
  Ops.set(settings, "enable_nfs_gss", @nfs_gss_enabled)
  Ops.set(settings, "idmapd_domain", @idmapd_domain)

  entries = Builtins.maplist(@nfs_entries) do |entry|
    {
      "server_path" => Ops.get_string(entry, "spec", ""),
      "mount_point" => Ops.get_string(entry, "file", ""),
      "vfstype"     => Ops.get_string(entry, "vfstype", ""),
      "nfs_options" => Ops.get_string(entry, "mntops", "")
    }
  end
  Ops.set(settings, "nfs_entries", entries)
  deep_copy(settings)
end

- (Object) FillEntriesDefaults(entries)

Fill in the defaults for AY profile entries.



157
158
159
160
161
162
163
164
165
166
167
# File '../../src/modules/Nfs.rb', line 157

def FillEntriesDefaults(entries)
  entries = deep_copy(entries)
  Builtins.maplist(entries) do |e|
    # Backwards compatibility: with FaTE#302031, we support nfsv4 mounts
    # thus we need to keep info on nfs version (v3 vs. v4)
    # But older AY profiles might not contain this element
    # so let's assume nfsv3 in that case (#395850)
    Ops.set(e, "vfstype", "nfs") if !Builtins.haskey(e, "vfstype")
    deep_copy(e)
  end
end

- (Object) FindPortmapper



302
303
304
305
306
307
# File '../../src/modules/Nfs.rb', line 302

def FindPortmapper
  # testsuite is dumb - it can't distinguish between the existence
  # of two services - either both exists or both do not
  return "portmap" if Mode.testsuite
  Service.Find(["rpcbind", "portmap"])
end

- (Boolean) GetModified

Functions which returns if the settings were modified

Returns:

  • (Boolean)

    settings were modified



68
69
70
# File '../../src/modules/Nfs.rb', line 68

def GetModified             # rubocop:disable Style/TrivialAccessors
  @modified
end

- (Object) GetOptionsAndEntries(any_settings, global_options, entries)

From settings (which is a list in SLE11 but a map in oS: bnc#820989), extract the options and the NFS fstab entries.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File '../../src/modules/Nfs.rb', line 123

def GetOptionsAndEntries(any_settings, global_options, entries)
  any_settings = deep_copy(any_settings)
  # map: oS;
  if Ops.is_map?(any_settings)
    global_options_ref = arg_ref(global_options.value)
    entries_ref = arg_ref(entries.value)
    GetOptionsAndEntriesMap(
      Convert.to_map(any_settings),
      global_options_ref,
      entries_ref
    )
    global_options.value = global_options_ref.value
    entries.value = entries_ref.value
  elsif Ops.is(any_settings, "list <map>")
    global_options_ref = arg_ref(global_options.value)
    entries_ref = arg_ref(entries.value)
    GetOptionsAndEntriesSLE11(
      Convert.convert(any_settings, :from => "any", :to => "list <map>"),
      global_options_ref,
      entries_ref
    )
    global_options.value = global_options_ref.value
    entries.value = entries_ref.value
  else
    Builtins.y2internal(
      "Cannot happen, got neither a map nor a list: %1",
      any_settings
    )
  end

  nil
end

- (Object) GetOptionsAndEntriesMap(settings, global_options, entries)



113
114
115
116
117
118
119
# File '../../src/modules/Nfs.rb', line 113

def GetOptionsAndEntriesMap(settings, global_options, entries)
  settings = deep_copy(settings)
  global_options.value = Builtins.remove(settings, "nfs_entries")
  entries.value = Ops.get_list(settings, "nfs_entries", [])

  nil
end

- (Object) GetOptionsAndEntriesSLE11(settings, global_options, entries)



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File '../../src/modules/Nfs.rb', line 96

def GetOptionsAndEntriesSLE11(settings, global_options, entries)
  settings = deep_copy(settings)
  if Builtins.haskey(Ops.get(settings, 0, {}), "enable_nfs4") ||
      Builtins.haskey(Ops.get(settings, 0, {}), "idmapd_domain")
    global_options.value = Ops.get(settings, 0, {})
    settings = Builtins.remove(settings, 0)
  end

  entries.value = Convert.convert(
    settings,
    :from => "list <map>",
    :to   => "list <map <string, any>>"
  )

  nil
end

- (Object) Import(settings)

Get all NFS configuration from a map. When called by nfs_auto (preparing autoinstallation data) the map may be empty.

Parameters:

  • settings (Hash{String => Object})

    a map($) of nfs_entries

Returns:

  • success



219
220
221
222
# File '../../src/modules/Nfs.rb', line 219

def Import(settings)
  settings = deep_copy(settings)
  ImportAny(settings)
end

- (Object) ImportAny(settings)



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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File '../../src/modules/Nfs.rb', line 169

def ImportAny(settings)
  settings = deep_copy(settings)
  # ($) since oS-1x.x, settings was changed to be a map,
  # which is incompatible with the sle profiles;
  # it owuld be nice to make it compatible again
  # whjich this code is readyu to, but the Autoyast engine isn't.
  global_options = {}
  entries = []
  global_options_ref = arg_ref(global_options)
  entries_ref = arg_ref(entries)
  GetOptionsAndEntries(settings, global_options_ref, entries_ref)
  global_options = global_options_ref.value
  entries = entries_ref.value

  return false if Builtins.find(entries) { |e| !ValidateAyNfsEntry(e) }

  entries = FillEntriesDefaults(entries)

  @nfs4_enabled = Ops.get_boolean(global_options, "enable_nfs4") do
    ReadNfs4()
  end
  @nfs_gss_enabled = Ops.get_boolean(global_options, "enable_nfs_gss") do
    ReadNfsGss()
  end
  @idmapd_domain = Ops.get_string(global_options, "idmapd_domain") do
    ReadIdmapd()
  end

  # vfstype can override a missing enable_nfs4
  @nfs4_enabled = true if Builtins.find(entries) do |entry|
    Ops.get_string(entry, "vfstype", "") == "nfs4"
  end

  @nfs_entries = Builtins.maplist(entries) do |entry|
    {
      "spec"    => Ops.get_string(entry, "server_path", ""),
      "file"    => Ops.get_string(entry, "mount_point", ""),
      "vfstype" => Ops.get_string(entry, "vfstype", ""),
      "mntops"  => Ops.get_string(entry, "nfs_options", "")
    }
  end

  true
end

- (Object) main



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File '../../src/modules/Nfs.rb', line 12

def main
  textdomain "nfs"

  Yast.import "FileUtils"
  Yast.import "Mode"
  Yast.import "NfsOptions"
  Yast.import "Report"
  Yast.import "Service"
  Yast.import "Summary"
  Yast.import "SuSEFirewall"
  Yast.import "Progress"
  Yast.import "PackageSystem"
  Yast.import "PackagesProposal"
  Yast.import "Wizard"
  Yast.import "Message"

  Yast.include self, "nfs/routines.rb"

  # default value of settings modified
  @modified = false

  # Should fstab reading be skipped ? (yes if we're
  # embedded in partitioner)
  @skip_fstab = false

  # Required packages
  @required_packages = ["nfs-client"]

  # eg.: [ $["spec": "moon:/cheese", file: "/mooncheese", "mntops": "defaults"], ...]
  @nfs_entries = []

  # Read only, intended for checking mount-point uniqueness.
  @non_nfs_entries = []

  @nfs4_enabled = nil

  @nfs_gss_enabled = nil

  @idmapd_domain = ""

  @portmapper = ""

  # list of created directories
  @created_dirs = []
end

- (String) Mount(server, share, mpoint, options, type)

Mount NFS directory

Parameters:

  • server (String)

    remote server name

  • share (String)

    name of the exported directory

  • mpoint (String)

    mount point (can be empty or nil, in this case it will be mounted in a temporary directory)

  • options (String)

    mount options - e.g. “ro,hard,intr”, see man nfs

  • type (String)

    nfs type (nfs vs. nfsv4) - if empty, 'nfs' is used

Returns:

  • (String)

    directory where volume was mounted or nil if mount failed



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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# File '../../src/modules/Nfs.rb', line 531

def Mount(server, share, mpoint, options, type)
  return nil if Builtins.size(server) == 0 || Builtins.size(share) == 0

  # check if options are valid
  if Ops.greater_than(Builtins.size(options), 0)
    if NfsOptions.validate(options) != ""
      Builtins.y2warning("invalid mount options: %1", options)
      return nil
    end
  end

  # mount to temporary directory if mpoint is nil
  if mpoint.nil?
    tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir")))

    if tmpdir.nil? || tmpdir == ""
      Builtins.y2security("Warning: using /tmp directory!")
      tmpdir = "/tmp"
    end

    mpoint = Ops.add(
      Ops.add(tmpdir, "/nfs"),
      Builtins.sformat("%1", Builtins.size(@created_dirs))
    ) # use num to allow parallel mounts
  end

  # check mount point
  if CheckPath(mpoint) == false
    # mount point is not valid
    Builtins.y2warning("invalid mount point: %1", mpoint)
    return nil
  end

  portmapper = FindPortmapper()
  # check whether portmapper is installed
  if IsPortmapperInstalled(portmapper) == false
    Builtins.y2warning("Neither rpcbind nor portmap is installed")
    return nil
  end

  # start portmapper if it isn't running
  unless Service.active?(portmapper)
    unless Service.Start(portmapper)
      Builtins.y2warning("%1 cannot be started", portmapper)
      return nil
    end
  end

  # create mount point if it doesn't exist
  if SCR.Read(path(".target.dir"), mpoint).nil?
    if !Convert.to_boolean(SCR.Execute(path(".target.mkdir"), mpoint))
      Builtins.y2warning("cannot create mount point %1", mpoint)
      return nil
    end

    # remember name of created directory
    @created_dirs = Builtins.add(@created_dirs, mpoint)
  end

  # build mount command
  command = Builtins.sformat(
    "/bin/mount %1 %2 %3:%4 %5",
    options.to_s == "" ? "" : "-o #{options}",
    "-t #{type.to_s == "" ? "nfs" : type}",
    server,
    share,
    mpoint
  )

  # execute mount command
  SCR.Execute(path(".target.bash"), command) == 0 ? mpoint : nil
end

- (Object) ProbeExports(server, v4)

Probe a server for its exports.

Parameters:

  • server (String)

    IP or hostname

  • v4 (Boolean)

    Use NFSv4?

Returns:

  • a list of exported paths



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
# File '../../src/modules/Nfs.rb', line 684

def ProbeExports(server, v4)
  dirs = []

  # showmounts does not work for nfsv4 (#466454)
  if v4
    tmpdir = Mount(server, "/", nil, "ro", "nfs4")

    # This is completely stupid way how to explore what can be mounted
    # and I even don't know if it is correct. Maybe 'find tmpdir -xdev -type d'
    # should be used instead. No clue :(
    dirs = Builtins.maplist(
      Convert.convert(
        SCR.Read(path(".target.dir"), tmpdir),
        :from => "any",
        :to   => "list <string>"
      )
    ) { |dirent| Ops.add("/", dirent) }
    dirs = Builtins.prepend(dirs, "/")
    Unmount(tmpdir)
  else
    dirs = Convert.convert(
      SCR.Read(path(".net.showexports"), server),
      :from => "any",
      :to   => "list <string>"
    )
  end

  dirs = ["internal error"] if dirs.nil?
  deep_copy(dirs)
end

- (Object) ProbeServers

Probe the LAN for NFS servers. Uses RPC broadcast to mountd.

Returns:

  • a list of hostnames



656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
# File '../../src/modules/Nfs.rb', line 656

def ProbeServers
  # newer, shinier, better rpcinfo from rpcbind (#450056)
  prog_name = "/sbin/rpcinfo"
  delim = ""

  # fallback from glibc (uses different field separators, grr :( )
  if !FileUtils.Exists(prog_name)
    prog_name = "/usr/sbin/rpcinfo"
    delim = "-d ' ' "
  end

  # #71064
  # this works also if ICMP broadcasts are ignored
  cmd = Ops.add(
    Ops.add(Ops.add(prog_name, " -b mountd 1 | cut "), delim),
    "-f 2 | sort -u"
  )
  out = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
  hosts = Builtins.filter(
    Builtins.splitstring(Ops.get_string(out, "stdout", ""), "\n")
  ) { |s| s != "" }
  deep_copy(hosts)
end

- (Object) Read

Reads NFS settings from the SCR (.etc.fstab)

Returns:

  • true on success



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
# File '../../src/modules/Nfs.rb', line 313

def Read
  # Read /etc/fstab if we're running standalone (otherwise, libstorage does the job)
  if !@skip_fstab
    fstab = Convert.convert(
      SCR.Read(path(".etc.fstab")),
      :from => "any",
      :to   => "list <map <string, any>>"
    )
    fstab = UnescapeSpaces(fstab)
    Builtins.y2milestone("fstab: %1", fstab)

    # For simplicity, this leaves also the unused fileds in the maps.
    @nfs_entries = Builtins.filter(fstab) do |entry|
      Ops.get_string(entry, "vfstype", "") == "nfs" ||
        Ops.get_string(entry, "vfstype", "") == "nfs4"
    end
    @non_nfs_entries = Builtins.filter(fstab) do |entry|
      Ops.get_string(entry, "vfstype", "") != "nfs" &&
        Ops.get_string(entry, "vfstype", "") != "nfs4"
    end
  end

  @nfs4_enabled = ReadNfs4()
  @nfs_gss_enabled = ReadNfsGss()
  @idmapd_domain = ReadIdmapd()

  progress_orig = Progress.set(false)
  SuSEFirewall.Read
  Progress.set(progress_orig)

  @portmapper = FindPortmapper()
  # There is neither rpcbind  nor portmap
  if @portmapper == ""
    # so let's install rpcbind (default since #423026)
    @required_packages = Builtins.add(@required_packages, "rpcbind")
    @portmapper = "rpcbind"
  end
  if @nfs4_enabled
    @required_packages = Builtins.add(@required_packages, "nfsidmap")
  end

  if Mode.installation
    Builtins.foreach(@required_packages) do |p|
      PackagesProposal.AddResolvables("yast2-nfs-client", :package, [p])
    end
  else
    if !PackageSystem.CheckAndInstallPackagesInteractive(@required_packages)
      return false
    end
  end

  true
end

- (Object) ReadIdmapd



80
81
82
# File '../../src/modules/Nfs.rb', line 80

def ReadIdmapd
  Convert.to_string(SCR.Read(path(".etc.idmapd_conf.value.General.Domain")))
end

- (Object) ReadNfs4



72
73
74
# File '../../src/modules/Nfs.rb', line 72

def ReadNfs4
  SCR.Read(path(".sysconfig.nfs.NFS4_SUPPORT")) == "yes"
end

- (Object) ReadNfsGss



76
77
78
# File '../../src/modules/Nfs.rb', line 76

def ReadNfsGss
  SCR.Read(path(".sysconfig.nfs.NFS_SECURITY_GSS")) == "yes"
end

- (Object) SetModified

Function sets internal variable, which indicates, that any settings were modified, to “true”



60
61
62
63
64
# File '../../src/modules/Nfs.rb', line 60

def SetModified
  @modified = true

  nil
end

- (Object) Summary

Summary()

Returns:

  • Html formatted configuration summary



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File '../../src/modules/Nfs.rb', line 506

def Summary
  summary = ""
  nc = Summary.NotConfigured
  # summary header
  summary = Summary.AddHeader(summary, _("NFS Entries"))
  entries = Builtins.size(@nfs_entries)
  Builtins.y2milestone("Entries: %1", @nfs_entries)
  # summary item, %1 is a number
  configured = Builtins.sformat(_("%1 entries configured"), entries)
  summary = Summary.AddLine(
    summary,
    Ops.greater_than(entries, 0) ? configured : nc
  )
  summary
end

- (Object) UnescapeSpaces(entries)

Un-escape spaces “040” -> “ ” in all values of all entries

Parameters:

  • entries (Array<Hash{String => Object>})

    a list of maps, such as nfs_entries

Returns:

  • escaped entries



287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File '../../src/modules/Nfs.rb', line 287

def UnescapeSpaces(entries)
  entries = deep_copy(entries)
  Builtins.maplist(entries) do |entry|
    Builtins.mapmap(entry) do |key, value|
      {
        key => if Ops.is_string?(value)
                 UnescapeSpaces1(Convert.to_string(value))
               else
                 value
               end
      }
    end
  end
end

- (Object) UnescapeSpaces1(s)

Un-escape spaces “040” -> “ ”

Parameters:

  • s (String)

    string or nil

Returns:

  • escaped string or nil



278
279
280
281
282
# File '../../src/modules/Nfs.rb', line 278

def UnescapeSpaces1(s)
  return nil if s.nil?
  # escaped space, \040, is /\\040/
  s.gsub(/\\040/, " ")
end

- (Boolean) Unmount(mpoint)

Unmount NFS directory from the system

Parameters:

  • mpoint (String)

    NFS mount point to unmount

Returns:

  • (Boolean)

    true on success



607
608
609
610
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
# File '../../src/modules/Nfs.rb', line 607

def Unmount(mpoint)
  return false if Builtins.size(mpoint) == 0

  # unmount directory if it's NFS mountpoint
  mounts = Convert.convert(
    SCR.Read(path(".proc.mounts")),
    :from => "any",
    :to   => "list <map <string, any>>"
  )
  found = false

  Builtins.foreach(mounts) do |m|
    type = Ops.get_string(m, "vfstype")
    file = Ops.get_string(m, "file")
    found = true if (type == "nfs" || type == "nfs4") && file == mpoint
  end

  if found
    command = Builtins.sformat("/bin/umount %1", mpoint)

    return false if SCR.Execute(path(".target.bash"), command) != 0
  else
    Builtins.y2warning("%1 is not NFS mount point", mpoint)
    return false
  end

  # if the directory was created by Mount call and it is empty then remove it
  if Builtins.contains(@created_dirs, mpoint) &&
      SCR.Read(path(".target.dir"), mpoint) == []
    command = Builtins.sformat("/bin/rmdir %1", mpoint)

    return false if SCR.Execute(path(".target.bash"), command) != 0

    # remove directory from list
    @created_dirs = Builtins.filter(@created_dirs) { |d| d != mpoint }
  end

  true
end

- (Object) ValidateAyNfsEntry(entry)



84
85
86
87
88
89
90
91
92
93
94
# File '../../src/modules/Nfs.rb', line 84

def ValidateAyNfsEntry(entry)
  entry = deep_copy(entry)
  valid = true
  Builtins.foreach(["server_path", "mount_point", "nfs_options"]) do |k|
    if !Builtins.haskey(entry, k)
      Builtins.y2error("Missing at Import: '%1'.", k)
      valid = false
    end
  end
  valid
end

- (Object) Write

Writes the NFS client configuration and starts/stops the service. (No parameters because it is too short to abort)

Returns:

  • true on success



443
444
445
446
447
448
449
450
451
452
453
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
# File '../../src/modules/Nfs.rb', line 443

def Write
  if WriteOnly()
    # dialog label
    Progress.New(
      _("Writing NFS Configuration"),
      " ",
      2,
      [
        # progress stage label
        _("Stop services"),
        # progress stage label
        _("Start services")
      ],
      [
        # progress step label
        _("Stopping services..."),
        # progress step label
        _("Starting services..."),
        # final progress step label
        _("Finished")
      ],
      ""
    )

    # help text
    Wizard.RestoreHelp(_("Writing NFS client settings. Please wait..."))

    Progress.NextStage

    Service.Stop("nfs")

    Progress.NextStage
    if Ops.greater_than(Builtins.size(@nfs_entries), 0)
      # portmap must not be started if it is running already (see bug # 9999)
      Service.Start(@portmapper) unless Service.active?(@portmapper)

      unless Service.active?(@portmapper)
        Report.Error(Message.CannotStartService(@portmapper))
        return false
      end

      Service.Start("nfs")

      unless Service.active?("nfs")
        # error popup message
        Report.Error(_("Unable to mount the NFS entries from /etc/fstab."))
        return false
      end
    end

    progress_orig = Progress.set(false)
    SuSEFirewall.ActivateConfiguration
    Progress.set(progress_orig)

    Progress.NextStage
    return true
  else
    return false
  end
end

- (Object) WriteOnly

Writes the NFS client configuration without starting/stopping the service. Autoinstallation uses this and then calls SuSEconfig only once and starts the services together. (No parameters because it is too short to abort)

Returns:

  • true on success



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
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File '../../src/modules/Nfs.rb', line 373

def WriteOnly
  # Merge with non-nfs entries from fstab:
  fstab = SCR.Read(path(".etc.fstab"))
  # unescape deferred for optimization
  fstab.delete_if { |entry| ["nfs", "nfs4"].include?(entry["vfstype"]) }
  fstab = UnescapeSpaces(fstab)

  @nfs_entries.each do |entry|
    fstab << entry.merge("freq" => 0, "passno" => 0)
    # create mount points
    file = entry["file"] || ""
    next if SCR.Execute(path(".target.mkdir"), file)
    # error popup message
    Report.Warning(
      Builtins.sformat(_("Unable to create directory '%1'."), file)
    )
  end

  log.debug("fstab before ordering: #{fstab}")
  fstab = Fstab::TSort.sort(fstab)
  log.info("fstab: #{fstab}")

  SCR.Execute(
    path(".target.bash"),
    "/bin/cp $ORIG $BACKUP",
    "ORIG" => "/etc/fstab", "BACKUP" => "/etc/fstab.YaST2.save"
  )

  fstab = EscapeSpaces(fstab)
  if !SCR.Write(path(".etc.fstab"), fstab)
    # error popup message
    Report.Error(
      _(
        "Unable to write to /etc/fstab.\n" \
          "No changes will be made to the\n" \
          "the NFS client configuration.\n"
      )
    )
    return false
  end

  @portmapper = FindPortmapper()
  if !@nfs_entries.empty?
    Service.Enable(@portmapper)
    Service.Enable("nfs")
  end

  if @nfs4_enabled == true
    SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "yes")
    SCR.Write(path(".etc.idmapd_conf.value.General.Domain"), @idmapd_domain)
    # flush the changes
    SCR.Write(path(".etc.idmapd_conf"), nil)
  elsif @nfs4_enabled == false
    SCR.Write(path(".sysconfig.nfs.NFS4_SUPPORT"), "no")
  end
  SCR.Write(
    path(".sysconfig.nfs.NFS_SECURITY_GSS"),
    @nfs_gss_enabled ? "yes" : "no"
  )

  progress_orig = Progress.set(false)
  SuSEFirewall.WriteOnly
  Progress.set(progress_orig)

  true
end