summaryrefslogtreecommitdiff
path: root/source4/smbd/rewrite.c
blob: b0ef693497dcab710eda6722886155d3b530c14e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "includes.h"

/*

 this is a set of temporary stub functions used during the core smbd rewrite.
 This file will need to go away before the rewrite is complete
*/

void mangle_reset_cache(void) 
{}

void reset_stat_cache(void)
{}


BOOL set_current_service(void *conn, BOOL x)
{ return True; }

void change_to_root_user(void)
{}

void load_printers(void)
{}

void file_init(void)
{}

BOOL init_oplocks(void)
{ return True; }

BOOL init_change_notify(void)
{ return True; }


BOOL pcap_printername_ok(const char *service, const char *foo)
{ return True; }

BOOL share_access_check(struct smbsrv_request *req, struct smbsrv_tcon *tcon, int snum, uint32_t desired_access)
{ return True; }

BOOL init_names(void)
{ return True; }

/*
 * initialize an smb process
 */
void smbd_process_init(void)
{
	TALLOC_CTX *mem_ctx;

	mem_ctx = talloc_init("smbd_process_init talloc");
	if (!mem_ctx) {
		DEBUG(0,("smbd_process_init: ERROR: No memory\n"));
		exit(1);
	}

	/* possibly reload the services file. */
	reload_services(NULL, True);

	if (*lp_rootdir()) {
		if (sys_chroot(lp_rootdir()) == 0)
			DEBUG(2,("Changed root to %s\n", lp_rootdir()));
	}

	/* Setup oplocks */
	if (!init_oplocks())
		exit(1);
	
	/* Setup change notify */
	if (!init_change_notify())
		exit(1);

	talloc_destroy(mem_ctx);
}

void init_subsystems(void)
{
	/* Setup the PROCESS_MODEL subsystem */
	if (!process_model_init())
		exit(1);

	/* Setup the AUTH subsystem */
	if (!auth_init())
		exit(1);

	/* Setup the NTVFS subsystem */
	if (!ntvfs_init())
		exit(1);

	/* Setup the DCERPC subsystem */
	if (!dcesrv_init())
		exit(1);

}

/****************************************************************************
 Reload the services file.
**************************************************************************/
BOOL reload_services(struct smbsrv_context *smb, BOOL test)
{
	BOOL ret;
	
	if (lp_loaded()) {
		pstring fname;
		pstrcpy(fname,lp_configfile());
		if (file_exist(fname, NULL) &&
		    !strcsequal(fname, dyn_CONFIGFILE)) {
			pstrcpy(dyn_CONFIGFILE, fname);
			test = False;
		}
	}

	reopen_logs();

	if (test && !lp_file_list_changed())
		return(True);

	if (smb) {
		lp_killunused(smb, conn_snum_used);
	}
	
	ret = lp_load(dyn_CONFIGFILE, False, False, True);

	load_printers();

	/* perhaps the config filename is now set */
	if (!test)
		reload_services(smb, True);

	reopen_logs();

	load_interfaces();

	mangle_reset_cache();
	reset_stat_cache();

	/* this forces service parameters to be flushed */
	set_current_service(NULL,True);

	return(ret);
}