*
* 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 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
/* This is the implementation of the srvsvc pipe. */
};
struct sess_file_count {
- pid_t pid;
+ struct server_id pid;
uid_t uid;
int count;
};
Count the entries belonging to a service in the connection db.
****************************************************************************/
-static int pipe_enum_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *p)
+static int pipe_enum_fn( struct db_record *rec, void *p)
{
struct pipe_open_rec prec;
struct file_enum_count *fenum = (struct file_enum_count *)p;
- if (dbuf.dsize != sizeof(struct pipe_open_rec))
+ if (rec->value.dsize != sizeof(struct pipe_open_rec))
return 0;
- memcpy(&prec, dbuf.dptr, sizeof(struct pipe_open_rec));
+ memcpy(&prec, rec->value.dptr, sizeof(struct pipe_open_rec));
if ( process_exists(prec.pid) ) {
struct srvsvc_NetFileInfo3 *f;
uint32 *count, uint32 *resume )
{
struct file_enum_count fenum;
- TDB_CONTEXT *conn_tdb = conn_tdb_ctx();
- if ( !conn_tdb ) {
- DEBUG(0,("net_enum_pipes: Failed to retrieve the connections tdb handle!\n"));
- return WERR_ACCESS_DENIED;
- }
-
fenum.ctx = ctx;
fenum.info = *info;
fenum.count = *count;
- if (tdb_traverse(conn_tdb, pipe_enum_fn, &fenum) == -1) {
- DEBUG(0,("net_enum_pipes: traverse of connections.tdb failed with error %s.\n",
- tdb_errorstr(conn_tdb) ));
+ if (connections_traverse(pipe_enum_fn, &fenum) == -1) {
+ DEBUG(0,("net_enum_pipes: traverse of connections.tdb "
+ "failed\n"));
return WERR_NOMEM;
}
*info = fenum.info;
*count = fenum.count;
- return WERR_OK;}
+ return WERR_OK;
+}
/*******************************************************************
********************************************************************/
-/* global needed to make use of the share_mode_forall() callback */
-static struct file_enum_count f_enum_cnt;
-
static void enum_file_fn( const struct share_mode_entry *e,
const char *sharepath, const char *fname,
- void *dummy )
+ void *private_data )
{
- struct file_enum_count *fenum = &f_enum_cnt;
+ struct file_enum_count *fenum =
+ (struct file_enum_count *)&private_data;
/* If the pid was not found delete the entry from connections.tdb */
/* need to count the number of locks on a file */
ZERO_STRUCT( fsp );
- fsp.dev = e->dev;
- fsp.inode = e->inode;
+ fsp.file_id = e->id;
if ( (brl = brl_get_locks_readonly(NULL,&fsp)) != NULL ) {
num_locks = brl->num_locks;
static WERROR net_enum_files( TALLOC_CTX *ctx, struct srvsvc_NetFileInfo3 **info,
uint32 *count, uint32 *resume )
{
+ struct file_enum_count f_enum_cnt;
+
f_enum_cnt.ctx = ctx;
f_enum_cnt.count = *count;
f_enum_cnt.info = *info;
- share_mode_forall( enum_file_fn, NULL );
+ share_mode_forall( enum_file_fn, (void *)&f_enum_cnt );
*info = f_enum_cnt.info;
*count = f_enum_cnt.count;
switch (info_level) {
case 0:
- if (!(ctr->ctr0 = talloc_zero(
+ if (!(ctr->ctr0 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr0))) {
goto done;
}
break;
case 1:
- if (!(ctr->ctr1 = talloc_zero(
+ if (!(ctr->ctr1 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr1))) {
goto done;
}
break;
case 2:
- if (!(ctr->ctr2 = talloc_zero(
+ if (!(ctr->ctr2 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr2))) {
goto done;
}
break;
case 501:
- if (!(ctr->ctr501 = talloc_zero(
+ if (!(ctr->ctr501 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr501))) {
goto done;
}
break;
case 502:
- if (!(ctr->ctr502 = talloc_zero(
+ if (!(ctr->ctr502 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr502))) {
goto done;
}
break;
case 1004:
- if (!(ctr->ctr1004 = talloc_zero(
+ if (!(ctr->ctr1004 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr1004))) {
goto done;
}
break;
case 1005:
- if (!(ctr->ctr1005 = talloc_zero(
+ if (!(ctr->ctr1005 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr1005))) {
goto done;
}
break;
case 1006:
- if (!(ctr->ctr1006 = talloc_zero(
+ if (!(ctr->ctr1006 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr1006))) {
goto done;
}
break;
case 1007:
- if (!(ctr->ctr1007 = talloc_zero(
+ if (!(ctr->ctr1007 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr1007))) {
goto done;
}
break;
case 1501:
- if (!(ctr->ctr1501 = talloc_zero(
+ if (!(ctr->ctr1501 = TALLOC_ZERO_P(
p->mem_ctx, struct srvsvc_NetShareCtr1501))) {
goto done;
}
{
struct sessionid *session_list;
uint32 num_entries = 0;
- (*stot) = list_sessions(&session_list);
+ (*stot) = list_sessions(p->mem_ctx, &session_list);
if (ss0 == NULL) {
if (snum) {
(*snum) = 0;
}
- SAFE_FREE(session_list);
return;
}
DEBUG(5,("init_srv_sess_0_ss0\n"));
- ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot);
+ ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo0, *stot);
if (snum) {
for (; (*snum) < (*stot); (*snum)++) {
ss0->array = NULL;
ss0->count = 0;
}
- SAFE_FREE(session_list);
}
/*******************************************************************
{
struct sess_file_count *sess = (struct sess_file_count *)private_data;
- if ( (procid_to_pid(&e->pid) == sess->pid) && (sess->uid == e->uid) ) {
+ if ( procid_equal(&e->pid, &sess->pid) && (sess->uid == e->uid) ) {
sess->count++;
}
/*******************************************************************
********************************************************************/
-static int net_count_files( uid_t uid, pid_t pid )
+static int net_count_files( uid_t uid, struct server_id pid )
{
struct sess_file_count s_file_cnt;
return;
}
- (*stot) = list_sessions(&session_list);
+ (*stot) = list_sessions(p->mem_ctx, &session_list);
- ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot);
+ ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetSessInfo1, *stot);
for (; (*snum) < (*stot); (*snum)++) {
uint32 num_files;
if ((*snum) >= (*stot)) {
(*snum) = 0;
}
-
- SAFE_FREE(session_list);
}
/*******************************************************************
DEBUG(5,("init_srv_conn_0_ss0\n"));
if (snum) {
- ss0->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot);
+ ss0->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo0, *stot);
for (; (*snum) < (*stot); (*snum)++) {
ss0->array[num_entries].conn_id = (*stot);
DEBUG(5,("init_srv_conn_1_ss1\n"));
if (snum) {
- ss1->array = talloc_array(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot);
+ ss1->array = TALLOC_ARRAY(p->mem_ctx, struct srvsvc_NetConnInfo1, *stot);
for (; (*snum) < (*stot); (*snum)++) {
ss1->array[num_entries].conn_id = (*stot);
ss1->array[num_entries].conn_type = 0x3;
(b) active pipes
(c) open directories and files */
- ctr->ctr3 = talloc_zero(p->mem_ctx, struct srvsvc_NetFileCtr3);
+ ctr->ctr3 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetFileCtr3);
status = net_enum_files( ctx, &ctr->ctr3->array, num_entries, resume_hnd );
if ( !W_ERROR_IS_OK(status))
here, as most of it is made up. */
case 102:
- r->out.info->info102 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo102);
+ r->out.info->info102 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo102);
r->out.info->info102->platform_id = 500;
r->out.info->info102->version_major = lp_major_announce_version();
r->out.info->info102->comment = lp_serverstring();
break;
case 101:
- r->out.info->info101 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo101);
+ r->out.info->info101 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo101);
r->out.info->info101->platform_id = 500;
r->out.info->info101->server_name = global_myname();
r->out.info->info101->version_major = lp_major_announce_version();
r->out.info->info101->comment = lp_serverstring();
break;
case 100:
- r->out.info->info100 = talloc_zero(p->mem_ctx, struct srvsvc_NetSrvInfo100);
+ r->out.info->info100 = TALLOC_ZERO_P(p->mem_ctx, struct srvsvc_NetSrvInfo100);
r->out.info->info100->platform_id = 500;
r->out.info->info100->server_name = global_myname();
break;
memmove(machine, &machine[1], strlen(machine));
}
- num_sessions = list_sessions(&session_list);
+ num_sessions = list_sessions(p->mem_ctx, &session_list);
DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__));
if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) &&
strequal(session_list[snum].remote_machine, machine)) {
+ NTSTATUS ntstat;
+
+ ntstat = messaging_send(smbd_messaging_context(),
+ session_list[snum].pid,
+ MSG_SHUTDOWN, &data_blob_null);
- if (NT_STATUS_IS_OK(message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)))
+ if (NT_STATUS_IS_OK(ntstat))
status = WERR_OK;
}
}
DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__));
-
done:
- SAFE_FREE(session_list);
-
return status;
}
if ( (ret = smbrun(command, NULL)) == 0 ) {
/* Tell everyone we updated smb.conf. */
- message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED,
- NULL, 0, False, NULL);
+ message_send_all(smbd_messaging_context(),
+ MSG_SMB_CONF_UPDATED,
+ NULL, 0, NULL);
}
if ( is_disk_op )
if ( (ret = smbrun(command, NULL)) == 0 ) {
/* Tell everyone we updated smb.conf. */
- message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED,
- NULL, 0, False, NULL);
+ message_send_all(smbd_messaging_context(),
+ MSG_SMB_CONF_UPDATED,
+ NULL, 0, NULL);
}
if ( is_disk_op )
if ( (ret = smbrun(command, NULL)) == 0 ) {
/* Tell everyone we updated smb.conf. */
- message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED,
- NULL, 0, False, NULL);
+ message_send_all(smbd_messaging_context(),
+ MSG_SMB_CONF_UPDATED,
+ NULL, 0, NULL);
}
if ( is_disk_op )
/* Null password is ok - we are already an authenticated user... */
- null_pw = data_blob(NULL, 0);
+ null_pw = data_blob_null;
become_root();
conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status);
goto error_exit;
}
- nt_status = open_file_stat(conn, r->in.file, &st, &fsp);
+ nt_status = open_file_stat(conn, NULL, r->in.file, &st, &fsp);
if (!NT_STATUS_IS_OK(nt_status)) {
/* Perhaps it is a directory */
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY))
- nt_status = open_directory(conn, r->in.file, &st,
+ nt_status = open_directory(conn, NULL, r->in.file, &st,
READ_CONTROL_ACCESS,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p, struct srvsvc_NetSetFileSecurity *r)
{
- BOOL ret;
DATA_BLOB null_pw;
files_struct *fsp = NULL;
SMB_STRUCT_STAT st;
ZERO_STRUCT(st);
/* Null password is ok - we are already an authenticated user... */
- null_pw = data_blob(NULL, 0);
+ null_pw = data_blob_null;
become_root();
conn = make_connection(r->in.share, null_pw, "A:", p->pipe_user.vuid, &nt_status);
}
- nt_status = open_file_stat(conn, r->in.file, &st, &fsp);
+ nt_status = open_file_stat(conn, NULL, r->in.file, &st, &fsp);
if (!NT_STATUS_IS_OK(nt_status)) {
/* Perhaps it is a directory */
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_FILE_IS_A_DIRECTORY))
- nt_status = open_directory(conn, r->in.file, &st,
+ nt_status = open_directory(conn, NULL, r->in.file, &st,
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ|FILE_SHARE_WRITE,
FILE_OPEN,
}
}
- ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd);
+ nt_status = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, r->in.securityinformation, r->in.sd_buf.sd);
- if (ret == False) {
+ if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", r->in.file));
status = WERR_ACCESS_DENIED;
goto error_exit;