summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-11-12 23:15:52 +0000
committerJeremy Allison <jra@samba.org>2002-11-12 23:15:52 +0000
commit250c9801197ea1c949bd94c1c891f81ab118b130 (patch)
tree3a0ec79c71a010961d78726e223a70e1bc75c73f /source3/nsswitch
parent477025a6f628fd1a8d3bfacd30726e7a41819e50 (diff)
downloadsamba-250c9801197ea1c949bd94c1c891f81ab118b130.tar.gz
samba-250c9801197ea1c949bd94c1c891f81ab118b130.tar.bz2
samba-250c9801197ea1c949bd94c1c891f81ab118b130.zip
Removed global_myworkgroup, global_myname, global_myscope. Added liberal
dashes of const. This is a rather large check-in, some things may break. It does compile though :-). Jeremy. (This used to be commit 82b8f749a36b42e22186297482aad2abb04fab8a)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wbinfo.c25
-rw-r--r--source3/nsswitch/winbindd.c14
-rw-r--r--source3/nsswitch/winbindd_cm.c9
-rw-r--r--source3/nsswitch/winbindd_misc.c4
-rw-r--r--source3/nsswitch/winbindd_pam.c22
-rw-r--r--source3/nsswitch/winbindd_util.c9
6 files changed, 31 insertions, 52 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index ed51d852cd..f03b0493de 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -62,7 +62,7 @@ static char winbind_separator(void)
return sep;
}
-static char *get_winbind_domain(void)
+static const char *get_winbind_domain(void)
{
struct winbindd_response response;
static fstring winbind_domain;
@@ -206,7 +206,7 @@ static BOOL wbinfo_list_domains(void)
/* Display response */
if (response.extra_data) {
- char *extra_data = (char *)response.extra_data;
+ const char *extra_data = (char *)response.extra_data;
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
@@ -514,7 +514,7 @@ static BOOL wbinfo_auth_crap(char *username)
static BOOL print_domain_users(void)
{
struct winbindd_response response;
- char *extra_data;
+ const char *extra_data;
fstring name;
/* Send request to winbind daemon */
@@ -530,7 +530,7 @@ static BOOL print_domain_users(void)
if (!response.extra_data)
return False;
- extra_data = (char *)response.extra_data;
+ extra_data = (const char *)response.extra_data;
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
@@ -545,7 +545,7 @@ static BOOL print_domain_users(void)
static BOOL print_domain_groups(void)
{
struct winbindd_response response;
- char *extra_data;
+ const char *extra_data;
fstring name;
ZERO_STRUCT(response);
@@ -559,7 +559,7 @@ static BOOL print_domain_groups(void)
if (!response.extra_data)
return False;
- extra_data = (char *)response.extra_data;
+ extra_data = (const char *)response.extra_data;
while(next_token(&extra_data, name, ",", sizeof(fstring)))
d_printf("%s\n", name);
@@ -679,7 +679,6 @@ enum {
int main(int argc, char **argv)
{
- extern pstring global_myname;
int opt;
poptContext pc;
@@ -717,21 +716,15 @@ int main(int argc, char **argv)
/* Samba client initialisation */
- if (!*global_myname) {
- char *p;
-
- fstrcpy(global_myname, myhostname());
- p = strchr(global_myname, '.');
- if (p)
- *p = 0;
- }
-
if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
d_fprintf(stderr, "wbinfo: error opening config file %s. Error was %s\n",
dyn_CONFIGFILE, strerror(errno));
exit(1);
}
+ if (!init_names())
+ return 1;
+
load_interfaces();
/* Parse options */
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index 2bd6d7967c..8ec8bdced6 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -744,8 +744,6 @@ static void usage(void)
int main(int argc, char **argv)
{
extern BOOL AllowDebugChange;
- extern pstring global_myname;
- extern fstring global_myworkgroup;
pstring logfile;
BOOL interactive = False;
int opt;
@@ -826,16 +824,8 @@ static void usage(void)
/* Setup names. */
- if (!*global_myname) {
- char *p;
-
- fstrcpy(global_myname, myhostname());
- p = strchr(global_myname, '.');
- if (p)
- *p = 0;
- }
-
- fstrcpy(global_myworkgroup, lp_workgroup());
+ if (!init_names())
+ exit(1);
if (!interactive) {
become_daemon();
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index b4d5a664b2..d44219d172 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -356,7 +356,6 @@ static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
struct winbindd_cm_conn *new_conn)
{
struct failed_connection_cache *fcc;
- extern pstring global_myname;
NTSTATUS result;
char *ipc_username, *ipc_domain, *ipc_password;
struct in_addr dc_ip;
@@ -414,7 +413,7 @@ static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
cm_get_ipc_userpass(&ipc_username, &ipc_domain, &ipc_password);
DEBUG(5, ("connecting to %s from %s with username [%s]\\[%s]\n",
- new_conn->controller, global_myname, ipc_domain, ipc_username));
+ new_conn->controller, global_myname(), ipc_domain, ipc_username));
for (i = 0; retry && (i < 3); i++) {
@@ -423,7 +422,7 @@ static NTSTATUS cm_open_connection(const char *domain, const int pipe_index,
continue;
}
- result = cli_full_connection(&(new_conn->cli), global_myname, new_conn->controller,
+ result = cli_full_connection(&new_conn->cli, global_myname(), new_conn->controller,
&dc_ip, 0, "IPC$", "IPC", ipc_username, ipc_domain,
ipc_password, 0, &retry);
@@ -585,7 +584,7 @@ done:
/* Return a LSA policy handle on a domain */
-CLI_POLICY_HND *cm_get_lsa_handle(char *domain)
+CLI_POLICY_HND *cm_get_lsa_handle(const char *domain)
{
struct winbindd_cm_conn *conn;
uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
@@ -912,7 +911,7 @@ CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
/* Get a handle on a netlogon pipe. This is a bit of a hack to re-use the
netlogon pipe as no handle is returned. */
-NTSTATUS cm_get_netlogon_cli(char *domain, unsigned char *trust_passwd,
+NTSTATUS cm_get_netlogon_cli(const char *domain, const unsigned char *trust_passwd,
struct cli_state **cli)
{
NTSTATUS result = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
diff --git a/source3/nsswitch/winbindd_misc.c b/source3/nsswitch/winbindd_misc.c
index c2e744c0a7..d656c3ca4d 100644
--- a/source3/nsswitch/winbindd_misc.c
+++ b/source3/nsswitch/winbindd_misc.c
@@ -26,12 +26,10 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
-extern pstring global_myname;
-
/************************************************************************
Routine to get the trust account password for a domain
************************************************************************/
-static BOOL _get_trust_account_password(char *domain, unsigned char *ret_pwd,
+static BOOL _get_trust_account_password(const char *domain, unsigned char *ret_pwd,
time_t *pass_last_set_time)
{
if (!secrets_fetch_trust_account_password(domain, ret_pwd, pass_last_set_time)) {
diff --git a/source3/nsswitch/winbindd_pam.c b/source3/nsswitch/winbindd_pam.c
index 969cf272a3..733ccb4cd6 100644
--- a/source3/nsswitch/winbindd_pam.c
+++ b/source3/nsswitch/winbindd_pam.c
@@ -68,8 +68,6 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
DATA_BLOB lm_resp;
DATA_BLOB nt_resp;
- extern pstring global_myname;
-
/* Ensure null termination */
state->request.data.auth.user[sizeof(state->request.data.auth.user)-1]='\0';
@@ -135,7 +133,7 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
result = cli_netlogon_sam_network_logon(cli, mem_ctx,
name_user, name_domain,
- global_myname, chal,
+ global_myname(), chal,
lm_resp, nt_resp,
&info3);
@@ -169,14 +167,12 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
struct cli_state *cli = NULL;
TALLOC_CTX *mem_ctx = NULL;
char *user = NULL;
- char *domain = NULL;
- char *contact_domain;
- char *workstation;
+ const char *domain = NULL;
+ const char *contact_domain;
+ const char *workstation;
DATA_BLOB lm_resp, nt_resp;
- extern pstring global_myname;
-
/* Ensure null termination */
state->request.data.auth_crap.user[sizeof(state->request.data.auth_crap.user)-1]='\0';
@@ -194,9 +190,11 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
}
if (*state->request.data.auth_crap.domain) {
- if (pull_utf8_talloc(mem_ctx, &domain, state->request.data.auth_crap.domain) < 0) {
+ char *dom = NULL;
+ if (pull_utf8_talloc(mem_ctx, &dom, state->request.data.auth_crap.domain) < 0) {
DEBUG(0, ("winbindd_pam_auth_crap: pull_utf8_talloc failed!\n"));
}
+ domain = dom;
} else if (lp_winbind_use_default_domain()) {
domain = lp_workgroup();
} else {
@@ -216,11 +214,13 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
}
if (*state->request.data.auth_crap.workstation) {
- if (pull_utf8_talloc(mem_ctx, &workstation, state->request.data.auth_crap.workstation) < 0) {
+ char *wrk = NULL;
+ if (pull_utf8_talloc(mem_ctx, &wrk, state->request.data.auth_crap.workstation) < 0) {
DEBUG(0, ("winbindd_pam_auth_crap: pull_utf8_talloc failed!\n"));
}
+ workstation = wrk;
} else {
- workstation = global_myname;
+ workstation = global_myname();
}
if (state->request.data.auth_crap.lm_resp_len > sizeof(state->request.data.auth_crap.lm_resp)
diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c
index 1d18e8fda7..5ad4bada37 100644
--- a/source3/nsswitch/winbindd_util.c
+++ b/source3/nsswitch/winbindd_util.c
@@ -402,7 +402,7 @@ BOOL winbindd_param_init(void)
BOOL check_domain_env(char *domain_env, char *domain)
{
fstring name;
- char *tmp = domain_env;
+ const char *tmp = domain_env;
while(next_token(&tmp, name, ",", sizeof(fstring))) {
if (strequal(name, domain))
@@ -413,7 +413,6 @@ BOOL check_domain_env(char *domain_env, char *domain)
}
/* Parse a string of the form DOMAIN/user into a domain and a user */
-extern fstring global_myworkgroup;
BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
{
@@ -424,7 +423,7 @@ BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
if(!p && lp_winbind_use_default_domain()) {
fstrcpy(user, domuser);
- fstrcpy(domain, global_myworkgroup);
+ fstrcpy(domain, lp_workgroup());
} else {
fstrcpy(user, p+1);
fstrcpy(domain, domuser);
@@ -439,13 +438,13 @@ BOOL parse_domain_user(const char *domuser, fstring domain, fstring user)
'winbind separator' options.
This means:
- omit DOMAIN when 'winbind use default domain = true' and DOMAIN is
- global_myworkgroup
+ lp_workgroup
*/
void fill_domain_username(fstring name, const char *domain, const char *user)
{
if(lp_winbind_use_default_domain() &&
- !strcmp(global_myworkgroup, domain)) {
+ !strcmp(lp_workgroup(), domain)) {
strlcpy(name, user, sizeof(fstring));
} else {
slprintf(name, sizeof(fstring) - 1, "%s%s%s",