* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Jeremy Allison 2001.
+ * Copyright (C) Nigel Williams 2001.
*
* 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
#include "includes.h"
-extern pstring global_myname;
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_RPC_SRV
/*******************************************************************
- Fill in a share info level 1 structure.
+ Utility function to get the 'type' of a share from an snum.
********************************************************************/
-
-static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum)
+static uint32 get_share_type(int snum)
{
- int len_net_name;
- pstring net_name;
- pstring remark;
- uint32 type;
-
- pstrcpy(net_name, lp_servicename(snum));
- pstrcpy(remark, lp_comment(snum));
- standard_sub_conn(p->conn, remark);
- len_net_name = strlen(net_name);
-
+ char *net_name = lp_servicename(snum);
+ int len_net_name = strlen(net_name);
+
/* work out the share type */
- type = STYPE_DISKTREE;
-
+ uint32 type = STYPE_DISKTREE;
+
if (lp_print_ok(snum))
type = STYPE_PRINTQ;
- if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name))
+ if (strequal(lp_fstype(snum), "IPC"))
type = STYPE_IPC;
if (net_name[len_net_name] == '$')
type |= STYPE_HIDDEN;
- init_srv_share_info1(&sh1->info_1, net_name, type, remark);
+ return type;
+}
+
+/*******************************************************************
+ Fill in a share info level 0 structure.
+ ********************************************************************/
+
+static void init_srv_share_info_0(pipes_struct *p, SRV_SHARE_INFO_0 *sh0, int snum)
+{
+ pstring net_name;
+
+ pstrcpy(net_name, lp_servicename(snum));
+
+ init_srv_share_info0(&sh0->info_0, net_name);
+ init_srv_share_info0_str(&sh0->info_0_str, net_name);
+}
+
+/*******************************************************************
+ Fill in a share info level 1 structure.
+ ********************************************************************/
+
+static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum)
+{
+ pstring remark;
+
+ char *net_name = lp_servicename(snum);
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark,sizeof(remark));
+
+ init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark);
init_srv_share_info1_str(&sh1->info_1_str, net_name, remark);
}
static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum)
{
- int len_net_name;
- pstring net_name;
pstring remark;
pstring path;
pstring passwd;
- uint32 type;
- pstrcpy(net_name, lp_servicename(snum));
+ char *net_name = lp_servicename(snum);
pstrcpy(remark, lp_comment(snum));
- standard_sub_conn(p->conn, remark);
+ standard_sub_conn(p->conn, remark,sizeof(remark));
pstrcpy(path, "C:");
pstrcat(path, lp_pathname(snum));
string_replace(path, '/', '\\');
pstrcpy(passwd, "");
- len_net_name = strlen(net_name);
-
- /* work out the share type */
- type = STYPE_DISKTREE;
-
- if (lp_print_ok(snum))
- type = STYPE_PRINTQ;
- if (strequal("IPC$", net_name) || strequal("ADMIN$", net_name))
- type = STYPE_IPC;
- if (net_name[len_net_name] == '$')
- type |= STYPE_HIDDEN;
- init_srv_share_info2(&sh2->info_2, net_name, type, remark, 0, 0xffffffff, 1, path, passwd);
+ init_srv_share_info2(&sh2->info_2, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd);
init_srv_share_info2_str(&sh2->info_2_str, net_name, remark, path, passwd);
}
BOOL share_info_db_init(void)
{
static pid_t local_pid;
- char *vstring = "INFO/version";
+ const char *vstring = "INFO/version";
int32 vers_id;
if (share_tdb && local_pid == sys_getpid())
local_pid = sys_getpid();
/* handle a Samba upgrade */
- tdb_lock_bystring(share_tdb, vstring);
+ tdb_lock_bystring(share_tdb, vstring, 0);
/* Cope with byte-reversed older versions of the db. */
vers_id = tdb_fetch_int32(share_tdb, vstring);
fstring key;
BOOL ret = False;
- mem_ctx = talloc_init();
+ mem_ctx = talloc_init("set_share_security");
if (mem_ctx == NULL)
return False;
/* Free malloc'ed memory */
- out:
+out:
prs_mem_free(&ps);
if (mem_ctx)
Can this user access with share with the required permissions ?
********************************************************************/
-BOOL share_access_check(connection_struct *conn, int snum, uint16 vuid, uint32 desired_access)
+BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, uint32 desired_access)
{
uint32 granted;
NTSTATUS status;
SEC_DESC *psd = NULL;
size_t sd_size;
NT_USER_TOKEN *token = NULL;
- user_struct *vuser = get_valid_user_struct(vuid);
BOOL ret = True;
- mem_ctx = talloc_init();
+ mem_ctx = talloc_init("share_access_check");
if (mem_ctx == NULL)
return False;
if (!psd)
goto out;
- if (vuser)
- token = vuser->nt_user_token;
- else
+ if (conn->nt_user_token)
token = conn->nt_user_token;
+ else
+ token = vuser->nt_user_token;
ret = se_access_check(psd, token, desired_access, &granted, &status);
- out:
+out:
talloc_destroy(mem_ctx);
return ret;
}
+/*******************************************************************
+ Fill in a share info level 501 structure.
+********************************************************************/
+
+static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum)
+{
+ int len_net_name;
+ pstring remark;
+
+ char *net_name = lp_servicename(snum);
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark, sizeof(remark));
+
+ len_net_name = strlen(net_name);
+
+ init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4));
+ init_srv_share_info501_str(&sh501->info_501_str, net_name, remark);
+}
+
/*******************************************************************
Fill in a share info level 502 structure.
********************************************************************/
pstring remark;
pstring path;
pstring passwd;
- uint32 type;
SEC_DESC *sd;
size_t sd_size;
TALLOC_CTX *ctx = p->mem_ctx;
pstrcpy(net_name, lp_servicename(snum));
pstrcpy(remark, lp_comment(snum));
- standard_sub_conn(p->conn, remark);
+ standard_sub_conn(p->conn, remark,sizeof(remark));
pstrcpy(path, "C:");
pstrcat(path, lp_pathname(snum));
pstrcpy(passwd, "");
len_net_name = strlen(net_name);
- /* work out the share type */
- type = STYPE_DISKTREE;
-
- if (lp_print_ok(snum))
- type = STYPE_PRINTQ;
- if (strequal("IPC$", net_name))
- type = STYPE_IPC;
- if (net_name[len_net_name] == '$')
- type |= STYPE_HIDDEN;
-
sd = get_share_security(ctx, snum, &sd_size);
- init_srv_share_info502(&sh502->info_502, net_name, type, remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size);
- init_srv_share_info502_str(&sh502->info_502_str, &sh502->info_502, net_name, remark, path, passwd, sd, sd_size);
+ init_srv_share_info502(&sh502->info_502, net_name, get_share_type(snum), remark, 0, 0xffffffff, 1, path, passwd, sd, sd_size);
+ init_srv_share_info502_str(&sh502->info_502_str, net_name, remark, path, passwd, sd, sd_size);
+}
+
+/***************************************************************************
+ Fill in a share info level 1004 structure.
+ ***************************************************************************/
+
+static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum)
+{
+ pstring remark;
+
+ pstrcpy(remark, lp_comment(snum));
+ standard_sub_conn(p->conn, remark, sizeof(remark));
+
+ ZERO_STRUCTP(sh1004);
+
+ init_srv_share_info1004(&sh1004->info_1004, remark);
+ init_srv_share_info1004_str(&sh1004->info_1004_str, remark);
}
/***************************************************************************
Fill in a share info level 1005 structure.
***************************************************************************/
-static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum)
+static void init_srv_share_info_1005(pipes_struct *p, SRV_SHARE_INFO_1005* sh1005, int snum)
{
- sh1005->dfs_root_flag = 0;
+ sh1005->share_info_flags = 0;
if(lp_host_msdfs() && lp_msdfs_root(snum))
- sh1005->dfs_root_flag = 3;
+ sh1005->share_info_flags |=
+ SHARE_1005_IN_DFS | SHARE_1005_DFS_ROOT;
+ sh1005->share_info_flags |=
+ lp_csc_policy(snum) << SHARE_1005_CSC_POLICY_SHIFT;
+}
+/***************************************************************************
+ Fill in a share info level 1006 structure.
+ ***************************************************************************/
+
+static void init_srv_share_info_1006(pipes_struct *p, SRV_SHARE_INFO_1006* sh1006, int snum)
+{
+ sh1006->max_uses = -1;
+}
+
+/***************************************************************************
+ Fill in a share info level 1007 structure.
+ ***************************************************************************/
+
+static void init_srv_share_info_1007(pipes_struct *p, SRV_SHARE_INFO_1007* sh1007, int snum)
+{
+ pstring alternate_directory_name = "";
+ uint32 flags = 0;
+
+ ZERO_STRUCTP(sh1007);
+
+ init_srv_share_info1007(&sh1007->info_1007, flags, alternate_directory_name);
+ init_srv_share_info1007_str(&sh1007->info_1007_str, alternate_directory_name);
+}
+
+/*******************************************************************
+ Fill in a share info level 1501 structure.
+ ********************************************************************/
+
+static void init_srv_share_info_1501(pipes_struct *p, SRV_SHARE_INFO_1501 *sh1501, int snum)
+{
+ SEC_DESC *sd;
+ size_t sd_size;
+ TALLOC_CTX *ctx = p->mem_ctx;
+
+ ZERO_STRUCTP(sh1501);
+
+ sd = get_share_security(ctx, snum, &sd_size);
+
+ sh1501->sdb = make_sec_desc_buf(p->mem_ctx, sd_size, sd);
}
/*******************************************************************
True if it ends in '$'.
********************************************************************/
-static BOOL is_admin_share(int snum)
+static BOOL is_hidden_share(int snum)
{
pstring net_name;
/* Count the number of entries. */
for (snum = 0; snum < num_services; snum++) {
- if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) )
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) )
num_entries++;
}
return True;
switch (info_level) {
+ case 0:
+ {
+ SRV_SHARE_INFO_0 *info0;
+ int i = 0;
+
+ info0 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_0));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_0(p, &info0[i++], snum);
+ }
+ }
+
+ ctr->share.info0 = info0;
+ break;
+
+ }
+
case 1:
{
SRV_SHARE_INFO_1 *info1;
info1 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1));
for (snum = *resume_hnd; snum < num_services; snum++) {
- if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
init_srv_share_info_1(p, &info1[i++], snum);
}
}
info2 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_2));
for (snum = *resume_hnd; snum < num_services; snum++) {
- if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
init_srv_share_info_2(p, &info2[i++], snum);
}
}
break;
}
+ case 501:
+ {
+ SRV_SHARE_INFO_501 *info501;
+ int i = 0;
+
+ info501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_501));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_501(p, &info501[i++], snum);
+ }
+ }
+
+ ctr->share.info501 = info501;
+ break;
+ }
+
case 502:
{
SRV_SHARE_INFO_502 *info502;
info502 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_502));
for (snum = *resume_hnd; snum < num_services; snum++) {
- if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_admin_share(snum)) ) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
init_srv_share_info_502(p, &info502[i++], snum);
}
}
break;
}
+ /* here for completeness but not currently used with enum (1004 - 1501)*/
+
+ case 1004:
+ {
+ SRV_SHARE_INFO_1004 *info1004;
+ int i = 0;
+
+ info1004 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1004));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1004(p, &info1004[i++], snum);
+ }
+ }
+
+ ctr->share.info1004 = info1004;
+ break;
+ }
+
+ case 1005:
+ {
+ SRV_SHARE_INFO_1005 *info1005;
+ int i = 0;
+
+ info1005 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1005));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1005(p, &info1005[i++], snum);
+ }
+ }
+
+ ctr->share.info1005 = info1005;
+ break;
+ }
+
+ case 1006:
+ {
+ SRV_SHARE_INFO_1006 *info1006;
+ int i = 0;
+
+ info1006 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1006));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1006(p, &info1006[i++], snum);
+ }
+ }
+
+ ctr->share.info1006 = info1006;
+ break;
+ }
+
+ case 1007:
+ {
+ SRV_SHARE_INFO_1007 *info1007;
+ int i = 0;
+
+ info1007 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1007));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1007(p, &info1007[i++], snum);
+ }
+ }
+
+ ctr->share.info1007 = info1007;
+ break;
+ }
+
+ case 1501:
+ {
+ SRV_SHARE_INFO_1501 *info1501;
+ int i = 0;
+
+ info1501 = talloc(ctx, num_entries * sizeof(SRV_SHARE_INFO_1501));
+
+ for (snum = *resume_hnd; snum < num_services; snum++) {
+ if (lp_browseable(snum) && lp_snum_ok(snum) && (all_shares || !is_hidden_share(snum)) ) {
+ init_srv_share_info_1501(p, &info1501[i++], snum);
+ }
+ }
+
+ ctr->share.info1501 = info1501;
+ break;
+ }
default:
DEBUG(5,("init_srv_share_info_ctr: unsupported switch value %d\n", info_level));
return False;
if (snum >= 0) {
switch (info_level) {
+ case 0:
+ init_srv_share_info_0(p, &r_n->info.share.info0, snum);
+ break;
case 1:
init_srv_share_info_1(p, &r_n->info.share.info1, snum);
break;
case 2:
init_srv_share_info_2(p, &r_n->info.share.info2, snum);
break;
+ case 501:
+ init_srv_share_info_501(p, &r_n->info.share.info501, snum);
+ break;
case 502:
init_srv_share_info_502(p, &r_n->info.share.info502, snum);
break;
+
+ /* here for completeness */
+ case 1004:
+ init_srv_share_info_1004(p, &r_n->info.share.info1004, snum);
+ break;
case 1005:
- init_srv_share_info_1005(&r_n->info.share.info1005, snum);
+ init_srv_share_info_1005(p, &r_n->info.share.info1005, snum);
+ break;
+
+ /* here for completeness 1006 - 1501 */
+ case 1006:
+ init_srv_share_info_1006(p, &r_n->info.share.info1006, snum);
+ break;
+ case 1007:
+ init_srv_share_info_1007(p, &r_n->info.share.info1007, snum);
+ break;
+ case 1501:
+ init_srv_share_info_1501(p, &r_n->info.share.info1501, snum);
break;
default:
DEBUG(5,("init_srv_net_share_get_info: unsupported switch value %d\n", info_level));
static void init_srv_sess_info_0(SRV_SESS_INFO_0 *ss0, uint32 *snum, uint32 *stot)
{
+ struct sessionid *session_list;
uint32 num_entries = 0;
- (*stot) = 1;
+ (*stot) = list_sessions(&session_list);
if (ss0 == NULL) {
(*snum) = 0;
+ SAFE_FREE(session_list);
return;
}
if (snum) {
for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
init_srv_sess_0_info(&ss0->info_0[num_entries],
- &ss0->info_0_str[num_entries], "MACHINE");
+ &ss0->info_0_str[num_entries], session_list[(*snum)].remote_machine);
/* move on to creating next session */
/* move on to creating next sess */
ss0->ptr_sess_info = 0;
ss0->num_entries_read2 = 0;
}
+ SAFE_FREE(session_list);
}
/*******************************************************************
static void init_srv_sess_info_1(SRV_SESS_INFO_1 *ss1, uint32 *snum, uint32 *stot)
{
+ struct sessionid *session_list;
uint32 num_entries = 0;
- (*stot) = 1;
+ (*stot) = list_sessions(&session_list);
if (ss1 == NULL) {
(*snum) = 0;
+ SAFE_FREE(session_list);
return;
}
if (snum) {
for (; (*snum) < (*stot) && num_entries < MAX_SESS_ENTRIES; (*snum)++) {
init_srv_sess_1_info(&ss1->info_1[num_entries],
- &ss1->info_1_str[num_entries],
- "MACHINE", "dummy_user", 1, 10, 5, 0);
+ &ss1->info_1_str[num_entries],
+ session_list[*snum].remote_machine,
+ session_list[*snum].username,
+ 1, 10, 5, 0);
/* move on to creating next session */
/* move on to creating next sess */
static void init_srv_conn_1_info(CONN_INFO_1 *se1, CONN_INFO_1_STR *str1,
uint32 id, uint32 type,
uint32 num_opens, uint32 num_users, uint32 open_time,
- char *usr_name, char *net_name)
+ const char *usr_name, const char *net_name)
{
init_srv_conn_info1(se1 , id, type, num_opens, num_users, open_time, usr_name, net_name);
init_srv_conn_info1_str(str1, usr_name, net_name);
init_enum_hnd(&r_n->enum_hnd, resume_hnd);
}
-/*******************************************************************
- fill in a file info level 3 structure.
- ********************************************************************/
-
-static void init_srv_file_3_info(FILE_INFO_3 *fl3, FILE_INFO_3_STR *str3,
- uint32 fnum, uint32 perms, uint32 num_locks,
- char *path_name, char *user_name)
-{
- init_srv_file_info3(fl3 , fnum, perms, num_locks, path_name, user_name);
- init_srv_file_info3_str(str3, path_name, user_name);
-}
-
-/*******************************************************************
- fill in a file info level 3 structure.
- ********************************************************************/
-
-static void init_srv_file_info_3(SRV_FILE_INFO_3 *fl3, uint32 *fnum, uint32 *ftot)
-{
- uint32 num_entries = 0;
- (*ftot) = 1;
-
- if (fl3 == NULL) {
- (*fnum) = 0;
- return;
- }
-
- DEBUG(5,("init_srv_file_3_fl3\n"));
-
- for (; (*fnum) < (*ftot) && num_entries < MAX_FILE_ENTRIES; (*fnum)++) {
- init_srv_file_3_info(&fl3->info_3[num_entries],
- &fl3->info_3_str[num_entries],
- (*fnum), 0x35, 0, "\\PIPE\\samr", "dummy user");
-
- /* move on to creating next file */
- num_entries++;
- }
-
- fl3->num_entries_read = num_entries;
- fl3->ptr_file_info = num_entries > 0 ? 1 : 0;
- fl3->num_entries_read2 = num_entries;
-
- if ((*fnum) >= (*ftot)) {
- (*fnum) = 0;
- }
-}
-
/*******************************************************************
makes a SRV_R_NET_FILE_ENUM structure.
********************************************************************/
-static WERROR init_srv_file_info_ctr(SRV_FILE_INFO_CTR *ctr,
- int switch_value, uint32 *resume_hnd, uint32 *total_entries)
+static WERROR init_srv_file_info_ctr(pipes_struct *p, SRV_FILE_INFO_CTR *ctr,
+ int switch_value, uint32 *resume_hnd,
+ uint32 *total_entries)
{
WERROR status = WERR_OK;
+ TALLOC_CTX *ctx = p->mem_ctx;
DEBUG(5,("init_srv_file_info_ctr: %d\n", __LINE__));
+ *total_entries = 1; /* dummy entries only, for */
ctr->switch_value = switch_value;
+ ctr->num_entries = *total_entries - *resume_hnd;
+ ctr->num_entries2 = ctr->num_entries;
switch (switch_value) {
- case 3:
- init_srv_file_info_3(&ctr->file.info3, resume_hnd, total_entries);
- ctr->ptr_file_ctr = 1;
+ case 3: {
+ int i;
+ if (*total_entries > 0) {
+ ctr->ptr_entries = 1;
+ ctr->file.info3 = talloc(ctx, ctr->num_entries *
+ sizeof(SRV_FILE_INFO_3));
+ }
+ for (i=0 ;i<ctr->num_entries;i++) {
+ init_srv_file_info3(&ctr->file.info3[i].info_3, i+*resume_hnd, 0x35, 0, "\\PIPE\\samr", "dummy user");
+ init_srv_file_info3_str(&ctr->file.info3[i].info_3_str, "\\PIPE\\samr", "dummy user");
+
+ }
+ ctr->ptr_file_info = 1;
+ *resume_hnd = 0;
break;
+ }
default:
DEBUG(5,("init_srv_file_info_ctr: unsupported switch value %d\n", switch_value));
(*resume_hnd = 0);
(*total_entries) = 0;
- ctr->ptr_file_ctr = 0;
+ ctr->ptr_entries = 0;
status = WERR_UNKNOWN_LEVEL;
break;
}
makes a SRV_R_NET_FILE_ENUM structure.
********************************************************************/
-static void init_srv_r_net_file_enum(SRV_R_NET_FILE_ENUM *r_n,
+static void init_srv_r_net_file_enum(pipes_struct *p, SRV_R_NET_FILE_ENUM *r_n,
uint32 resume_hnd, int file_level, int switch_value)
{
DEBUG(5,("init_srv_r_net_file_enum: %d\n", __LINE__));
if (file_level == 0)
r_n->status = WERR_UNKNOWN_LEVEL;
else
- r_n->status = init_srv_file_info_ctr(r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries));
+ r_n->status = init_srv_file_info_ctr(p, &r_n->ctr, switch_value, &resume_hnd, &(r_n->total_entries));
if (!W_ERROR_IS_OK(r_n->status))
resume_hnd = 0;
DEBUG(5,("srv_net_srv_get_info: %d\n", __LINE__));
+ if (!pipe_access_check(p)) {
+ DEBUG(3, ("access denied to srv_net_srv_get_info\n"));
+ return WERR_ACCESS_DENIED;
+ }
+
switch (q_u->switch_value) {
+
+ /* Technically level 102 should only be available to
+ Administrators but there isn't anything super-secret
+ here, as most of it is made up. */
+
case 102:
init_srv_info_102(&ctr->srv.sv102,
- 500, global_myname,
- string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
+ 500, global_myname(),
+ string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH),
lp_major_announce_version(), lp_minor_announce_version(),
lp_default_server_announce(),
0xffffffff, /* users */
break;
case 101:
init_srv_info_101(&ctr->srv.sv101,
- 500, global_myname,
+ 500, global_myname(),
lp_major_announce_version(), lp_minor_announce_version(),
lp_default_server_announce(),
string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH));
break;
case 100:
- init_srv_info_100(&ctr->srv.sv100, 500, global_myname);
+ init_srv_info_100(&ctr->srv.sv100, 500, global_myname());
break;
default:
status = WERR_UNKNOWN_LEVEL;
WERROR _srv_net_file_enum(pipes_struct *p, SRV_Q_NET_FILE_ENUM *q_u, SRV_R_NET_FILE_ENUM *r_u)
{
- r_u->ctr = (SRV_FILE_INFO_CTR *)talloc(p->mem_ctx, sizeof(SRV_FILE_INFO_CTR));
- if (!r_u->ctr)
- return WERR_NOMEM;
-
- ZERO_STRUCTP(r_u->ctr);
-
DEBUG(5,("srv_net_file_enum: %d\n", __LINE__));
/* set up the */
- init_srv_r_net_file_enum(r_u,
+ init_srv_r_net_file_enum(p, r_u,
get_enum_hnd(&q_u->enum_hnd),
q_u->file_level,
- q_u->ctr->switch_value);
+ q_u->ctr.switch_value);
DEBUG(5,("srv_net_file_enum: %d\n", __LINE__));
{
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
+ if (!pipe_access_check(p)) {
+ DEBUG(3, ("access denied to srv_net_share_enum_all\n"));
+ return WERR_ACCESS_DENIED;
+ }
+
/* Create the list of shares for the response. */
init_srv_r_net_share_enum(p, r_u,
q_u->ctr.info_level,
{
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
+ if (!pipe_access_check(p)) {
+ DEBUG(3, ("access denied to srv_net_share_enum\n"));
+ return WERR_ACCESS_DENIED;
+ }
+
/* Create the list of shares for the response. */
init_srv_r_net_share_enum(p, r_u,
- q_u->ctr.info_level,
- get_enum_hnd(&q_u->enum_hnd), False);
+ q_u->ctr.info_level,
+ get_enum_hnd(&q_u->enum_hnd), False);
DEBUG(5,("_srv_net_share_enum: %d\n", __LINE__));
unistr2_to_ascii(share_name, &q_u->uni_share_name, sizeof(share_name));
- r_u->switch_value = 0;
+ r_u->parm_error = 0;
if (strequal(share_name,"IPC$") || strequal(share_name,"ADMIN$") || strequal(share_name,"global"))
return WERR_ACCESS_DENIED;
get_current_user(&user,p);
- if (user.uid != 0)
+ if (user.uid != sec_initial_uid())
return WERR_ACCESS_DENIED;
switch (q_u->info_level) {
case 1:
- /* Not enough info in a level 1 to do anything. */
- return WERR_ACCESS_DENIED;
+ pstrcpy(pathname, lp_pathname(snum));
+ unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
+ type = q_u->info.share.info2.info_2.type;
+ psd = NULL;
+ break;
case 2:
- unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
- unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
+ unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(comment));
+ unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(pathname));
type = q_u->info.share.info2.info_2.type;
psd = NULL;
break;
+#if 0
+ /* not supported on set but here for completeness */
+ case 501:
+ unistr2_to_ascii(comment, &q_u->info.share.info501.info_501_str.uni_remark, sizeof(comment));
+ type = q_u->info.share.info501.info_501.type;
+ psd = NULL;
+ break;
+#endif
case 502:
- unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name));
- unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name));
+ unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(comment));
+ unistr2_to_ascii(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(pathname));
type = q_u->info.share.info502.info_502.type;
psd = q_u->info.share.info502.info_502_str.sd;
map_generic_share_sd_bits(psd);
break;
+ case 1004:
+ pstrcpy(pathname, lp_pathname(snum));
+ unistr2_to_ascii(comment, &q_u->info.share.info1004.info_1004_str.uni_remark, sizeof(comment));
+ type = STYPE_DISKTREE;
+ break;
case 1005:
+ /* XP re-sets the csc policy even if it wasn't changed by the
+ user, so we must compare it to see if it's what is set in
+ smb.conf, so that we can contine other ops like setting
+ ACLs on a share */
+ if (((q_u->info.share.info1005.share_info_flags &
+ SHARE_1005_CSC_POLICY_MASK) >>
+ SHARE_1005_CSC_POLICY_SHIFT) == lp_csc_policy(snum))
+ return WERR_OK;
+ else {
+ DEBUG(3, ("_srv_net_share_set_info: client is trying to change csc policy from the network; must be done with smb.conf\n"));
+ return WERR_ACCESS_DENIED;
+ }
+ break;
+ case 1006:
+ case 1007:
return WERR_ACCESS_DENIED;
+ break;
case 1501:
- fstrcpy(pathname, lp_pathname(snum));
+ pstrcpy(pathname, lp_pathname(snum));
fstrcpy(comment, lp_comment(snum));
psd = q_u->info.share.info1501.sdb->sec;
map_generic_share_sd_bits(psd);
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
- r_u->switch_value = 0;
+ r_u->parm_error = 0;
get_current_user(&user,p);
- if (user.uid != 0) {
- DEBUG(10,("_srv_net_share_add: uid != 0. Access denied.\n"));
+ if (user.uid != sec_initial_uid()) {
+ DEBUG(10,("_srv_net_share_add: uid != sec_initial_uid(). Access denied.\n"));
return WERR_ACCESS_DENIED;
}
}
switch (q_u->info_level) {
+ case 0:
+ /* No path. Not enough info in a level 0 to do anything. */
+ return WERR_ACCESS_DENIED;
case 1:
/* Not enough info in a level 1 to do anything. */
return WERR_ACCESS_DENIED;
unistr2_to_ascii(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
type = q_u->info.share.info2.info_2.type;
break;
+ case 501:
+ /* No path. Not enough info in a level 501 to do anything. */
+ return WERR_ACCESS_DENIED;
case 502:
unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name));
unistr2_to_ascii(comment, &q_u->info.share.info502.info_502_str.uni_remark, sizeof(share_name));
psd = q_u->info.share.info502.info_502_str.sd;
map_generic_share_sd_bits(psd);
break;
+
+ /* none of the following contain share names. NetShareAdd does not have a separate parameter for the share name */
+
+ case 1004:
case 1005:
+ case 1006:
+ case 1007:
+ return WERR_ACCESS_DENIED;
+ break;
+ case 1501:
/* DFS only level. */
return WERR_ACCESS_DENIED;
default:
get_current_user(&user,p);
- if (user.uid != 0)
+ if (user.uid != sec_initial_uid())
return WERR_ACCESS_DENIED;
if (!lp_delete_share_cmd() || !*lp_delete_share_cmd())
return WERR_OK;
}
+WERROR _srv_net_share_del_sticky(pipes_struct *p, SRV_Q_NET_SHARE_DEL *q_u, SRV_R_NET_SHARE_DEL *r_u)
+{
+ DEBUG(5,("_srv_net_share_del_stick: %d\n", __LINE__));
+
+ return _srv_net_share_del(p, q_u, r_u);
+}
+
/*******************************************************************
time of day
********************************************************************/
r_u->status = WERR_ACCESS_DENIED;
goto error_exit;
}
- became_user = True;
+ became_user = True;
unistr2_to_ascii(filename, &q_u->uni_file_name, sizeof(filename));
unix_convert(filename, conn, NULL, &bad_path, &st);
if (!fsp) {
/* Perhaps it is a directory */
if (errno == EISDIR)
- fsp = open_directory(conn, filename, &st,0,
+ fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0,
(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action);
if (!fsp) {
}
}
- sd_size = conn->vfs_ops.get_nt_acl(fsp, fsp->fsp_name, &psd);
+ sd_size = SMB_VFS_GET_NT_ACL(fsp, fsp->fsp_name, (OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION|DACL_SECURITY_INFORMATION), &psd);
if (sd_size == 0) {
DEBUG(3,("_srv_net_file_query_secdesc: Unable to get NT ACL for file %s\n", filename));
close_cnum(conn, user.vuid);
return r_u->status;
- error_exit:
+error_exit:
if(fsp) {
close_file(fsp, True);
int action;
NTSTATUS nt_status;
struct current_user user;
- fstring user_name;
connection_struct *conn = NULL;
BOOL became_user = False;
if (!fsp) {
/* Perhaps it is a directory */
if (errno == EISDIR)
- fsp = open_directory(conn, filename, &st,0,
+ fsp = open_directory(conn, filename, &st,FILE_READ_ATTRIBUTES,0,
(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), 0, &action);
if (!fsp) {
}
}
- ret = conn->vfs_ops.set_nt_acl(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc);
+ ret = SMB_VFS_SET_NT_ACL(fsp, fsp->fsp_name, q_u->sec_info, q_u->sec_desc);
if (ret == False) {
DEBUG(3,("_srv_net_file_set_secdesc: Unable to set NT ACL on file %s\n", filename));
close_cnum(conn, user.vuid);
return r_u->status;
- error_exit:
+error_exit:
if(fsp) {
close_file(fsp, True);
"Nigel Williams" <nigel@veritas.com>.
***********************************************************************************/
-const char *server_disks[] = {"C:"};
+static const char *server_disks[] = {"C:"};
static uint32 get_server_disk_count(void)
{
{
uint32 i;
const char *disk_name;
+ TALLOC_CTX *ctx = p->mem_ctx;
uint32 resume=get_enum_hnd(&q_u->enum_hnd);
r_u->status=WERR_OK;
r_u->disk_enum_ctr.unknown = 0;
+ {
+ DISK_INFO *dinfo;
+
+ int dinfo_size = MAX_SERVER_DISK_ENTRIES * sizeof(*dinfo);
+
+ if(!(dinfo = talloc(ctx, dinfo_size))) {
+ return WERR_NOMEM;
+ }
+
+ r_u->disk_enum_ctr.disk_info = dinfo;
+ }
+
r_u->disk_enum_ctr.disk_info_ptr = r_u->disk_enum_ctr.disk_info ? 1 : 0;
/*allow one DISK_INFO for null terminator*/
init_unistr3(&r_u->disk_enum_ctr.disk_info[i].disk_name, disk_name);
}
- /*add a terminating null string. Is this there if there is more data to come?*/
+ /* add a terminating null string. Is this there if there is more data to come? */
r_u->disk_enum_ctr.entries_read++;