Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect flag defined for disabling AD computer account in win_system.py #37132

Closed
bl4ckcontact opened this issue Oct 21, 2016 · 4 comments
Closed
Assignees
Labels
Bug broken, incorrect, or confusing behavior Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged
Milestone

Comments

@bl4ckcontact
Copy link

bl4ckcontact commented Oct 21, 2016

Description of Issue/Question

The unjoin_domain function in win_system.py specifies an incorrect flag for disabling AD computer objects. The offending value is located here:
https://github.com/saltstack/salt/blob/develop/salt/modules/win_system.py#L762

According to Microsoft documentation, the NETSETUP_ACCT_DELETE flag should be 0x4, not 0x2:
https://msdn.microsoft.com/en-us/library/aa393942(v=vs.85).aspx

Setup

Running in masterless minion mode with the log level set at DEBUG

Steps to Reproduce Issue

Running the following:
c:\salt\salt-call.bat system.unjoin_domain domain='domain' username='user' password='password' disable=True restart=True

Returns the following error, twice:

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
Traceback (most recent call last):
  File "C:\salt\bin\Scripts\salt-call", line 11, in <module>
    salt_call()
  File "C:\salt\bin\lib\site-packages\salt\scripts.py", line 345, in salt_call
    client.run()
  File "C:\salt\bin\lib\site-packages\salt\cli\call.py", line 58, in run
    caller.run()
  File "C:\salt\bin\lib\site-packages\salt\cli\caller.py", line 134, in run
    ret = self.call()
  File "C:\salt\bin\lib\site-packages\salt\cli\caller.py", line 197, in call
    ret['return'] = func(*args, **kwargs)
  File "C:\salt\bin\lib\site-packages\salt\modules\win_system.py", line 688, in unjoin_domain
    log.error(_lookup_error(err[0]))
  File "C:\salt\bin\lib\site-packages\salt\modules\win_system.py", line 504, in _lookup_error
    return return_values[number]
KeyError: 1004

After looking at the C:\Windows\debug\NetSetup.log file, I found the following:

10/20/2016 23:10:26:075 -----------------------------------------------------------------
10/20/2016 23:10:26:075 NetpUnJoinDomain: unjoin from 'domain' using 'domain\user' creds, options: 0x2
10/20/2016 23:10:26:075     OS Version: 6.3
10/20/2016 23:10:26:075     Build number: 9600 (9600.winblue_gdr.131006-1505)
10/20/2016 23:10:26:075     SKU: Windows Server 2012 R2 Standard
10/20/2016 23:10:26:075     Architecture: 64-bit (AMD64)
10/20/2016 23:10:26:075 NetpUnJoinDomain: Flags are invalid: 0x2
10/20/2016 23:10:26:075 NetpUnJoinDomain: status: 0x3ec

Thus determining the 0x2 flag defined here is not correct. Changing this to 0x4 allows this to function properly.

Versions Report

Salt Version:
           Salt: 2016.3.3

Dependency Versions:
           cffi: 1.6.0
       cherrypy: 5.3.0
       dateutil: 2.5.3
          gitdb: 0.6.4
      gitpython: 2.0.2
          ioflo: 1.5.3
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: 1.4.5
       M2Crypto: Not Installed
           Mako: 1.0.4
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)]
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: 0.2.4
        Tornado: 4.3
            ZMQ: 4.1.2

System Versions:
           dist:
        machine: AMD64
        release: 8.1
         system: Windows
        version: 8.1 6.3.9600  Multiprocessor Free
@gtmanfred
Copy link
Contributor

Would you be able to submit a pull request with this explaination and fix please?

Thanks
Daniel

@gtmanfred gtmanfred added the Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged label Oct 21, 2016
@gtmanfred gtmanfred added this to the Blocked milestone Oct 21, 2016
@twangboy twangboy modified the milestones: C 2, Blocked Oct 21, 2016
@twangboy twangboy self-assigned this Oct 21, 2016
@bl4ckcontact
Copy link
Author

I'll submit the pull request shortly.

Thanks!

@bl4ckcontact
Copy link
Author

Pull request #37154 has been opened.

@gtmanfred
Copy link
Contributor

Awesome! Thanks!

On Fri, Oct 21, 2016 at 4:47 PM Alex Black notifications@github.com wrote:

Pull request #37154 #37154 has
been opened.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#37132 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAssoS2inKGHZ3Tk5H3v0FUnKTc1-ds8ks5q2TLagaJpZM4Kcurm
.

@meggiebot meggiebot added the Bug broken, incorrect, or confusing behavior label Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Pending-Discussion The issue or pull request needs more discussion before it can be closed or merged
Projects
None yet
Development

No branches or pull requests

4 participants