1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | Samba utility functions
|
---|
4 | Copyright (C) Andrew Tridgell 1992-1998
|
---|
5 | Copyright (C) Jeremy Allison 2001-2007
|
---|
6 | Copyright (C) Simo Sorce 2001
|
---|
7 | Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
|
---|
8 | Copyright (C) James Peach 2006
|
---|
9 | Copyright (C) Andrew Bartlett 2010
|
---|
10 |
|
---|
11 | This program is free software; you can redistribute it and/or modify
|
---|
12 | it under the terms of the GNU General Public License as published by
|
---|
13 | the Free Software Foundation; either version 3 of the License, or
|
---|
14 | (at your option) any later version.
|
---|
15 |
|
---|
16 | This program is distributed in the hope that it will be useful,
|
---|
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | GNU General Public License for more details.
|
---|
20 |
|
---|
21 | You should have received a copy of the GNU General Public License
|
---|
22 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
23 | */
|
---|
24 |
|
---|
25 | #include "includes.h"
|
---|
26 |
|
---|
27 | static char *smb_myname;
|
---|
28 | static char *smb_myworkgroup;
|
---|
29 |
|
---|
30 | /***********************************************************************
|
---|
31 | Allocate and set myname. Ensure upper case.
|
---|
32 | ***********************************************************************/
|
---|
33 |
|
---|
34 | bool set_global_myname(const char *myname)
|
---|
35 | {
|
---|
36 | SAFE_FREE(smb_myname);
|
---|
37 | smb_myname = SMB_STRDUP(myname);
|
---|
38 | if (!smb_myname)
|
---|
39 | return False;
|
---|
40 | strupper_m(smb_myname);
|
---|
41 | return True;
|
---|
42 | }
|
---|
43 |
|
---|
44 | const char *global_myname(void)
|
---|
45 | {
|
---|
46 | return smb_myname;
|
---|
47 | }
|
---|
48 |
|
---|
49 | /***********************************************************************
|
---|
50 | Allocate and set myworkgroup. Ensure upper case.
|
---|
51 | ***********************************************************************/
|
---|
52 |
|
---|
53 | bool set_global_myworkgroup(const char *myworkgroup)
|
---|
54 | {
|
---|
55 | SAFE_FREE(smb_myworkgroup);
|
---|
56 | smb_myworkgroup = SMB_STRDUP(myworkgroup);
|
---|
57 | if (!smb_myworkgroup)
|
---|
58 | return False;
|
---|
59 | strupper_m(smb_myworkgroup);
|
---|
60 | return True;
|
---|
61 | }
|
---|
62 |
|
---|
63 | const char *lp_workgroup(void)
|
---|
64 | {
|
---|
65 | return smb_myworkgroup;
|
---|
66 | }
|
---|
67 |
|
---|
68 | /******************************************************************
|
---|
69 | get the default domain/netbios name to be used when dealing
|
---|
70 | with our passdb list of accounts
|
---|
71 | ******************************************************************/
|
---|
72 |
|
---|
73 | const char *get_global_sam_name(void)
|
---|
74 | {
|
---|
75 | if (IS_DC) {
|
---|
76 | return lp_workgroup();
|
---|
77 | }
|
---|
78 | return global_myname();
|
---|
79 | }
|
---|
80 |
|
---|
81 | void gfree_netbios_names(void)
|
---|
82 | {
|
---|
83 | SAFE_FREE( smb_myname );
|
---|
84 | SAFE_FREE( smb_myworkgroup );
|
---|
85 | }
|
---|