Skip to content

Exception when using user.present with Windows #24196

Closed

Description

@johnccfm

This seems to be a fairly newly introduced bug. Here's an example output:-

          ID: usrGhostFiles
    Function: user.present
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "C:\salt\bin\lib\site-packages\salt\state.py", line 1563, in call
                  **cdata['kwargs'])
                File "C:\salt\bin\lib\site-packages\salt\states\user.py", line 375, in present
                  expire)
                File "C:\salt\bin\lib\site-packages\salt\states\user.py", line 114, in _changes
                  if not os.path.isdir(newhome):
              TypeError: coercing to Unicode: need string or buffer, NoneType found
     Started: 19:27:49.649000
    Duration: 3.0 ms
     Changes:   

It seems to be because the "home" value for users on Windows is always none, as user.getent shows:-

      ----------
      gid:
      groups:
      home:
          None
      name:
          usrGhostFiles
      passwd:
          None
      shell:
      uid:
          S-1-5-21-2033504833-1387376432-1020295716-1002

A workaround that I found is to add createhome: False to the user state.

Activity

  1. added
    bug
    severity-medium
    help-wanted
    P1
    P2
    Platform
    and removed
    P2
    on Jun 4, 2015
  2. added this to the Approved milestone on Jun 4, 2015
  3. jfindlay commented on Jun 4, 2015

    @jfindlay
    Contributor

    @johnccfm, thanks for the report.

  4. self-assigned this
    on Jun 12, 2015
  5. twangboy commented on Jun 12, 2015

    @twangboy
    Contributor

    @johnccfm Could you please provide the OS Version you're using as well as the salt versions_report (salt '*' test.version_report)? Also a copy of your state file would be nice.

  6. twangboy commented on Jun 12, 2015

    @twangboy
    Contributor

    To reproduce this error you execute your state file with user.present twice. The first time it creates the user. The second time it throws the stack trace. It fails if the user exists.
    Windows 8.1
    Versions Report:

    salt 'g*' test.versions_report
    gringo:
                   Salt: 2014.7.6-50-gd7a9999
                 Python: 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)]
                 Jinja2: 2.7.3
               M2Crypto: 0.21.1
         msgpack-python: 0.4.6
           msgpack-pure: Not Installed
               pycrypto: 2.6.1
                libnacl: Not Installed
                 PyYAML: 3.11
                  ioflo: Not Installed
                  PyZMQ: 14.6.0
                   RAET: Not Installed
                    ZMQ: 4.0.5
                   Mako: Not Installed
    

    State File:

    testuser01:
     user.present:
       - name: testuser01
       - fullname: Test User 01
       - password: 'PassWord1!'
       - groups:
         - Administrators
    

    Result:

    salt 'g*' state.sls test.adduser
    gringo:
    ----------
              ID: testuser01
        Function: user.present
          Result: True
         Comment: New user testuser01 created
         Started: 11:50:38.932000
        Duration: 571.0 ms
         Changes:
                  ----------
                  active:
                      True
                  comment:
                  fullname:
                      Test User 01
                  gid:
                  groups:
                      - Administrators
                  home:
                      None
                  logonscript:
                  name:
                      testuser01
                  passwd:
                      PassWord1!
                  profile:
                      None
                  uid:
                      S-1-5-21-3611017389-930713959-1986937
    370-1006
    
    Summary
    ------------
    Succeeded: 1 (changed=1)
    Failed:    0
    ------------
    Total states run:     1
    

    Result when user exists:

    salt 'g*' state.sls test.adduser
    gringo:
    ----------
              ID: testuser01
        Function: user.present
          Result: False
         Comment: An exception occurred in this state: Traceback (most recent call last):
                    File "c:\salt-dev\salt\salt\state.py", line 1542, in call
                      **cdata['kwargs'])
                    File "c:\salt-dev\salt\salt\states\user.py", line 362, in present
                      expire)
                    File "c:\salt-dev\salt\salt\states\user.py", line 112, in _changes
                      if not os.path.isdir(newhome):
                  TypeError: coercing to Unicode: need string or buffer, NoneType found
         Started: 12:02:52.712000
        Duration: 117.0 ms
         Changes:
    
    Summary
    ------------
    Succeeded: 0
    Failed:    1
    ------------
    Total states run:     1
    
  7. johnccfm commented on Jun 14, 2015

    @johnccfm
    ContributorAuthor

    Thanks for looking at this @twangboy. Seems like you're way ahead there. Do you still need anything from me at this point?

  8. twangboy commented on Jun 15, 2015

    @twangboy
    Contributor

    @johnccfm No, I was just waiting for the PR to be merged. I think we can close the issue. I will do that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1PlatformWindowsbughelp-wantedseverity-medium

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions