yast / yast-yast2

YaST module yast2
http://en.opensuse.org/Portal:YaST
GNU General Public License v2.0
54 stars 44 forks source link

AutoYaST: Allow blank values in SectionWithAttributes #1170

Closed joseivanlopez closed 3 years ago

joseivanlopez commented 3 years ago

Problem

Sometimes, an AutoYaST profile might contain blank values for some properties, for example:

<users config:type="list">
  <user>
    <username>tux</username>
    <password_settings>
      <expire/>
      <mx>120</max>
      <inact>5</inact>
    </password_settings>
  </user>
</user>

In the example above, expire is empty, which means that the account has no expiration. By default, the SectionWithAttributes class converts the empty values to nil, so there is no way to distinguish when a properly was set as blank or it was missing in the profile. Such a differentiation is important in some cases like the expire option, because in case of blank, an empty string should be written in the /etc/shadow file for the Expiration Date field in order to make the account to never expire. And in case of nil (missing in the profile), nothing should be explicitly written in the file, giving the default value set by commands like useradd.

Solution

Now on, the attributes definition in SectionWithAttributes allows to indicate for each attribute whether blank values are allowed or not.

coveralls commented 3 years ago

Coverage Status

Coverage increased (+0.02%) to 40.939% when pulling 81f2958fa78d0a69655b84cf01a8eb4e4cd429d5 on joseivanlopez:autoyast-allow-blank into 62965843ad892c0c49f2ff4e1aeca8d81a5cacea on yast:master.

yast-bot commented 3 years ago

:heavy_check_mark: Public Jenkins job #310 successfully finished :heavy_check_mark: Created OBS submit request #897361