mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
r4852: merge simo changes to srv_srvsvc_nt.c from trunk
that allows the add/change share command to create the directory
passed in as an arguement and not require that it pre-exist.
Also finish testing of SeDiskOperatorPrivilege via srvmgr.exe
(This used to be commit 9af83a7d70
)
This commit is contained in:
parent
320d765081
commit
415ea1dfd3
@ -1419,10 +1419,7 @@ WERROR _srv_net_share_get_info(pipes_struct *p, SRV_Q_NET_SHARE_GET_INFO *q_u, S
|
||||
|
||||
static char *valid_share_pathname(char *dos_pathname)
|
||||
{
|
||||
pstring saved_pathname;
|
||||
pstring unix_pathname;
|
||||
char *ptr;
|
||||
int ret;
|
||||
|
||||
/* Convert any '\' paths to '/' */
|
||||
unix_format(dos_pathname);
|
||||
@ -1437,21 +1434,7 @@ static char *valid_share_pathname(char *dos_pathname)
|
||||
if (*ptr != '/')
|
||||
return NULL;
|
||||
|
||||
/* Can we cd to it ? */
|
||||
|
||||
/* First save our current directory. */
|
||||
if (getcwd(saved_pathname, sizeof(saved_pathname)) == NULL)
|
||||
return False;
|
||||
|
||||
pstrcpy(unix_pathname, ptr);
|
||||
|
||||
ret = chdir(unix_pathname);
|
||||
|
||||
/* We *MUST* be able to chdir back. Abort if we can't. */
|
||||
if (chdir(saved_pathname) == -1)
|
||||
smb_panic("valid_share_pathname: Unable to restore current directory.\n");
|
||||
|
||||
return (ret != -1) ? ptr : NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
@ -1468,7 +1451,7 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
||||
int type;
|
||||
int snum;
|
||||
int ret;
|
||||
char *ptr;
|
||||
char *path;
|
||||
SEC_DESC *psd = NULL;
|
||||
SE_PRIV se_diskop = SE_DISK_OPERATOR;
|
||||
BOOL is_disk_op;
|
||||
@ -1569,12 +1552,12 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
||||
return WERR_ACCESS_DENIED;
|
||||
|
||||
/* Check if the pathname is valid. */
|
||||
if (!(ptr = valid_share_pathname( pathname )))
|
||||
if (!(path = valid_share_pathname( pathname )))
|
||||
return WERR_OBJECT_PATH_INVALID;
|
||||
|
||||
/* Ensure share name, pathname and comment don't contain '"' characters. */
|
||||
string_replace(share_name, '"', ' ');
|
||||
string_replace(ptr, '"', ' ');
|
||||
string_replace(path, '"', ' ');
|
||||
string_replace(comment, '"', ' ');
|
||||
|
||||
DEBUG(10,("_srv_net_share_set_info: change share command = %s\n",
|
||||
@ -1582,13 +1565,13 @@ WERROR _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
||||
|
||||
/* Only call modify function if something changed. */
|
||||
|
||||
if (strcmp(ptr, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) )
|
||||
if (strcmp(path, lp_pathname(snum)) || strcmp(comment, lp_comment(snum)) )
|
||||
{
|
||||
if (!lp_change_share_cmd() || !*lp_change_share_cmd())
|
||||
return WERR_ACCESS_DENIED;
|
||||
|
||||
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
|
||||
lp_change_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment);
|
||||
lp_change_share_cmd(), dyn_CONFIGFILE, share_name, path, comment);
|
||||
|
||||
DEBUG(10,("_srv_net_share_set_info: Running [%s]\n", command ));
|
||||
|
||||
@ -1648,7 +1631,7 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
int type;
|
||||
int snum;
|
||||
int ret;
|
||||
char *ptr;
|
||||
char *path;
|
||||
SEC_DESC *psd = NULL;
|
||||
SE_PRIV se_diskop = SE_DISK_OPERATOR;
|
||||
BOOL is_disk_op;
|
||||
@ -1724,16 +1707,16 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
return WERR_ACCESS_DENIED;
|
||||
|
||||
/* Check if the pathname is valid. */
|
||||
if (!(ptr = valid_share_pathname( pathname )))
|
||||
if (!(path = valid_share_pathname( pathname )))
|
||||
return WERR_OBJECT_PATH_INVALID;
|
||||
|
||||
/* Ensure share name, pathname and comment don't contain '"' characters. */
|
||||
string_replace(share_name, '"', ' ');
|
||||
string_replace(ptr, '"', ' ');
|
||||
string_replace(path, '"', ' ');
|
||||
string_replace(comment, '"', ' ');
|
||||
|
||||
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\" \"%s\"",
|
||||
lp_add_share_cmd(), dyn_CONFIGFILE, share_name, ptr, comment);
|
||||
lp_add_share_cmd(), dyn_CONFIGFILE, share_name, path, comment);
|
||||
|
||||
DEBUG(10,("_srv_net_share_add: Running [%s]\n", command ));
|
||||
|
||||
@ -1758,9 +1741,9 @@ WERROR _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
||||
message_send_all(conn_tdb_ctx(), MSG_SMB_CONF_UPDATED, NULL, 0, False, NULL);
|
||||
|
||||
if (psd) {
|
||||
if (!set_share_security(p->mem_ctx, share_name, psd))
|
||||
DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n",
|
||||
share_name ));
|
||||
if (!set_share_security(p->mem_ctx, share_name, psd)) {
|
||||
DEBUG(0,("_srv_net_share_add: Failed to add security info to share %s.\n", share_name ));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user