]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Add some paranoia fixes for _wkssvc_NetrJoinDomain2/UnjoinDomain2.
authorGünther Deschner <gd@samba.org>
Fri, 28 Mar 2008 22:39:57 +0000 (23:39 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 28 Mar 2008 22:43:31 +0000 (23:43 +0100)
Guenther

source/rpc_server/srv_wkssvc_nt.c

index f864aad86a0b25a56ebf12565804e9040b723998..32d315f96f95a6aec234a8e7e46b36f419c57a32 100644 (file)
@@ -4,7 +4,8 @@
  *
  *  Copyright (C) Andrew Tridgell              1992-1997,
  *  Copyright (C) Gerald (Jerry) Carter                2006.
- *  
+ *  Copyright (C) Guenther Deschner            2007-2008.
+ *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  the Free Software Foundation; either version 3 of the License, or
@@ -298,6 +299,10 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p,
                return WERR_INVALID_PARAM;
        }
 
+       if (!r->in.admin_account || !r->in.encrypted_password) {
+               return WERR_INVALID_PARAM;
+       }
+
        if (!user_has_privileges(token, &se_machine_account) &&
            !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) &&
            !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) {
@@ -306,6 +311,11 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p,
                return WERR_ACCESS_DENIED;
        }
 
+       if ((r->in.join_flags & WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED) ||
+           (r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
+               return WERR_NOT_SUPPORTED;
+       }
+
        werr = decode_wkssvc_join_password_buffer(p->mem_ctx,
                                                  r->in.encrypted_password,
                                                  &p->session_key,
@@ -336,7 +346,7 @@ WERROR _wkssvc_NetrJoinDomain2(pipes_struct *p,
        unbecome_root();
 
        if (!W_ERROR_IS_OK(werr)) {
-               DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join gave %s\n",
+               DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join failed with: %s\n",
                        j->out.error_string ? j->out.error_string :
                        dos_errstr(werr)));
        }
@@ -359,6 +369,10 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p,
        WERROR werr;
        struct nt_user_token *token = p->pipe_user.nt_user_token;
 
+       if (!r->in.account || !r->in.encrypted_password) {
+               return WERR_INVALID_PARAM;
+       }
+
        if (!user_has_privileges(token, &se_machine_account) &&
            !nt_token_check_domain_rid(token, DOMAIN_GROUP_RID_ADMINS) &&
            !nt_token_check_domain_rid(token, BUILTIN_ALIAS_RID_ADMINS)) {
@@ -396,6 +410,12 @@ WERROR _wkssvc_NetrUnjoinDomain2(pipes_struct *p,
        werr = libnet_Unjoin(p->mem_ctx, u);
        unbecome_root();
 
+       if (!W_ERROR_IS_OK(werr)) {
+               DEBUG(5,("_wkssvc_NetrUnjoinDomain2: libnet_Unjoin failed with: %s\n",
+                       u->out.error_string ? u->out.error_string :
+                       dos_errstr(werr)));
+       }
+
        TALLOC_FREE(u);
        return werr;
 }