• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-users / 3649941877

pending completion
3649941877

Pull #371

github

Unknown Committer
Unknown Commit Message
Pull Request #371: Use Fallback for CHARACTER_CLASS

3294 of 5485 relevant lines covered (60.05%)

35.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.5
/src/include/users/routines.rb
1
# encoding: utf-8
2

3
# ------------------------------------------------------------------------------
4
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
5
#
6
#
7
# This program is free software; you can redistribute it and/or modify it under
8
# the terms of version 2 of the GNU General Public License as published by the
9
# Free Software Foundation.
10
#
11
# This program is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along with
16
# this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail, you may find
19
# current contact information at www.novell.com.
20
# ------------------------------------------------------------------------------
21

22
# File:        include/users/wizards.ycp
23
# Package:        Configuration of users and groups
24
# Summary:        Wizards definitions
25
# Authors:        Johannes Buchhold <jbuch@suse.de>,
26
#          Jiri Suchomel <jsuchome@suse.cz>
27
#
28

29
require "shellwords"
1✔
30

31
module Yast
1✔
32
  module UsersRoutinesInclude
1✔
33
    def initialize_users_routines(include_target)
1✔
34
      Yast.import "Mode"
38✔
35
      Yast.import "Autologin"
38✔
36

37
      textdomain "users"
38✔
38
    end
39

40
    # check if this is installation stage -
41
    # adding user during firstboot should be same as during 2nd stage
42
    def installation
1✔
43
      Stage.cont || Stage.firstboot
×
44
    end
45

46
    # helper function: return the 'any' value as integer
47
    def GetInt(value, default_value)
1✔
48
      value = deep_copy(value)
4✔
49
      return default_value if value == nil
4✔
50
      return Convert.to_integer(value) if Ops.is_integer?(value)
×
51
      if Ops.is_string?(value) && !value.empty?
×
52
        return value.to_i
×
53
      end
54
      default_value
×
55
    end
56

57
    # helper function: return the 'any' value as string
58
    def GetString(value, default_value)
1✔
59
      value = deep_copy(value)
2✔
60
      return default_value if value == nil
2✔
61
      Builtins.sformat("%1", value)
1✔
62
    end
63

64

65
    # Split cn (fullname) in forename and surname.
66
    # @param [Symbol] what `surname or `forename
67
    # @param [String] cn fullname
68
    # @return [String] selected part of user name
69
    def SplitFullName(what, cn)
1✔
70
      cn = "" if cn == nil
×
71

72
      # if cn is to be substituted, do not try to resolve givenName/sn
73
      return "" if Builtins.issubstring(cn, "%")
×
74

75
      strs = Builtins.splitstring(cn, " ")
×
76
      i = 1
×
77
      sn = ""
×
78
      givenName = ""
×
79

80
      Builtins.foreach(strs) do |str|
×
81
        if Ops.less_than(i, Builtins.size(strs))
×
82
          if givenName == ""
×
83
            givenName = str
×
84
          else
85
            givenName = Ops.add(Ops.add(givenName, " "), str)
×
86
          end
87
        else
88
          sn = str
×
89
        end
90
        i = Ops.add(i, 1)
×
91
      end
92
      return sn if what == :sn
×
93
      return givenName if what == :givenName
×
94

95
      nil
96
    end
97

98
    # if the user has log on system
99
    def UserLogged(name)
1✔
100
      out = SCR.Execute(
×
101
        path(".target.bash_output"),
102
        "/usr/bin/ps --no-headers -u #{name.shellescape}"
103
      )
104
      output = Ops.get_string(out, "stdout", "")
×
105
      Builtins.size(output) != 0 && !Mode.config
×
106
    end
107
  end
108
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc