~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source4/utils/net/net_join.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
   Samba Unix/Linux SMB client library 
3
 
   Distributed SMB/CIFS Server Management Utility 
4
 
 
5
 
   Copyright (C) 2004 Stefan Metzmacher <metze@samba.org>
6
 
   Copyright (C) 2005 Andrew Bartlett <abartlet@samba.org>
7
 
 
8
 
   This program is free software; you can redistribute it and/or modify
9
 
   it under the terms of the GNU General Public License as published by
10
 
   the Free Software Foundation; either version 3 of the License, or
11
 
   (at your option) any later version.
12
 
   
13
 
   This program is distributed in the hope that it will be useful,
14
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
   GNU General Public License for more details.
17
 
   
18
 
   You should have received a copy of the GNU General Public License
19
 
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
*/
21
 
 
22
 
#include "includes.h"
23
 
#include "utils/net/net.h"
24
 
#include "libnet/libnet.h"
25
 
#include "libcli/security/security.h"
26
 
#include "param/param.h"
27
 
#include "lib/events/events.h"
28
 
 
29
 
int net_join(struct net_context *ctx, int argc, const char **argv) 
30
 
{
31
 
        NTSTATUS status;
32
 
        struct libnet_context *libnetctx;
33
 
        struct libnet_Join *r;
34
 
        char *tmp;
35
 
        const char *domain_name;
36
 
        enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA;
37
 
 
38
 
        switch (argc) {
39
 
                case 0: /* no args -> fail */
40
 
                        return net_join_usage(ctx, argc, argv);
41
 
                case 1: /* only DOMAIN */
42
 
                        tmp = talloc_strdup(ctx, argv[0]);
43
 
                        break;
44
 
                case 2: /* DOMAIN and role */
45
 
                        tmp = talloc_strdup(ctx, argv[0]);
46
 
                        if (strcasecmp(argv[1], "BDC") == 0) {
47
 
                                secure_channel_type = SEC_CHAN_BDC;
48
 
                        } else if (strcasecmp(argv[1], "MEMBER") == 0) {
49
 
                                secure_channel_type = SEC_CHAN_WKSTA;
50
 
                        } else {
51
 
                                d_fprintf(stderr, "net_join: Invalid 2nd argument (%s) must be MEMBER or BDC\n", argv[1]);
52
 
                                return net_join_usage(ctx, argc, argv);
53
 
                        }
54
 
                        break;
55
 
                default: /* too many args -> fail */
56
 
                        return net_join_usage(ctx, argc, argv);
57
 
        }
58
 
 
59
 
        domain_name = tmp;
60
 
 
61
 
        libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx);
62
 
        if (!libnetctx) {
63
 
                return -1;      
64
 
        }
65
 
        libnetctx->cred = ctx->credentials;
66
 
        r = talloc(ctx, struct libnet_Join);
67
 
        if (!r) {
68
 
                return -1;
69
 
        }
70
 
        /* prepare parameters for the join */
71
 
        r->in.netbios_name              = lp_netbios_name(ctx->lp_ctx);
72
 
        r->in.domain_name               = domain_name;
73
 
        r->in.join_type                 = secure_channel_type;
74
 
        r->in.level                     = LIBNET_JOIN_AUTOMATIC;
75
 
        r->out.error_string             = NULL;
76
 
 
77
 
        /* do the domain join */
78
 
        status = libnet_Join(libnetctx, r, r);
79
 
        
80
 
        if (!NT_STATUS_IS_OK(status)) {
81
 
                d_fprintf(stderr, "Joining domain failed: %s\n",
82
 
                          r->out.error_string ? r->out.error_string : nt_errstr(status));
83
 
                talloc_free(r);
84
 
                talloc_free(libnetctx);
85
 
                return -1;
86
 
        }
87
 
        d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid));
88
 
 
89
 
        talloc_free(libnetctx);
90
 
        return 0;
91
 
}
92
 
 
93
 
int net_join_usage(struct net_context *ctx, int argc, const char **argv)
94
 
{
95
 
        d_printf("net join <domain> [BDC | MEMBER] [options]\n");
96
 
        return 0;       
97
 
}
98
 
 
99
 
int net_join_help(struct net_context *ctx, int argc, const char **argv)
100
 
{
101
 
        d_printf("Joins domain as either member or backup domain controller.\n");
102
 
        return 0;       
103
 
}
104