mirror of
https://github.com/samba-team/samba.git
synced 2025-02-22 05:57:43 +03:00
Fixed up the "add" command - although not SD's yet. Now for the SD db and
the "change" command. Jeremy.
This commit is contained in:
parent
2e6b1759e1
commit
bdec63bedb
@ -950,9 +950,11 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
|||||||
fstring share_name;
|
fstring share_name;
|
||||||
uint32 status = NT_STATUS_NOPROBLEMO;
|
uint32 status = NT_STATUS_NOPROBLEMO;
|
||||||
int snum;
|
int snum;
|
||||||
|
#if 0
|
||||||
fstring servicename;
|
fstring servicename;
|
||||||
fstring comment;
|
fstring comment;
|
||||||
pstring pathname;
|
pstring pathname;
|
||||||
|
#endif
|
||||||
|
|
||||||
DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__));
|
DEBUG(5,("_srv_net_share_set_info: %d\n", __LINE__));
|
||||||
|
|
||||||
@ -995,6 +997,49 @@ uint32 _srv_net_share_set_info(pipes_struct *p, SRV_Q_NET_SHARE_SET_INFO *q_u, S
|
|||||||
return r_u->status;
|
return r_u->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************
|
||||||
|
Check a given DOS pathname is valid for a share.
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
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);
|
||||||
|
unix_clean_name(dos_pathname);
|
||||||
|
|
||||||
|
/* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */
|
||||||
|
ptr = dos_pathname;
|
||||||
|
if (strlen(dos_pathname) > 2 && ptr[1] == ':' && ptr[0] != '/')
|
||||||
|
ptr += 2;
|
||||||
|
|
||||||
|
/* Only abolute paths allowed. */
|
||||||
|
if (*ptr != '/')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Can we cd to it ? */
|
||||||
|
|
||||||
|
/* First save our current directory. */
|
||||||
|
if (getcwd(saved_pathname, sizeof(saved_pathname)) == NULL)
|
||||||
|
return False;
|
||||||
|
|
||||||
|
/* Convert to UNIX charset. */
|
||||||
|
pstrcpy(unix_pathname, ptr);
|
||||||
|
dos_to_unix(unix_pathname, True);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
Net share add. Call 'add_share_command "sharename" "pathname" "comment"'
|
Net share add. Call 'add_share_command "sharename" "pathname" "comment"'
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
@ -1003,13 +1048,13 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
|||||||
{
|
{
|
||||||
struct current_user user;
|
struct current_user user;
|
||||||
pstring command;
|
pstring command;
|
||||||
uint32 status = NT_STATUS_NOPROBLEMO;
|
|
||||||
fstring share_name;
|
fstring share_name;
|
||||||
fstring comment;
|
fstring comment;
|
||||||
pstring pathname;
|
pstring pathname;
|
||||||
char *ptr;
|
|
||||||
int type;
|
int type;
|
||||||
int snum;
|
int snum;
|
||||||
|
int ret;
|
||||||
|
char *ptr;
|
||||||
|
|
||||||
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
|
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
|
||||||
|
|
||||||
@ -1026,27 +1071,26 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
|||||||
switch (q_u->info_level) {
|
switch (q_u->info_level) {
|
||||||
case 1:
|
case 1:
|
||||||
/* Not enough info in a level 1 to do anything. */
|
/* Not enough info in a level 1 to do anything. */
|
||||||
status = ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name));
|
unistr2_to_ascii(share_name, &q_u->info.share.info2.info_2_str.uni_netname, sizeof(share_name));
|
||||||
unistr2_to_ascii(comment, &q_u->info.share.info2.info_2_str.uni_remark, sizeof(share_name));
|
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(pathname, &q_u->info.share.info2.info_2_str.uni_path, sizeof(share_name));
|
||||||
|
type = q_u->info.share.info2.info_2.type;
|
||||||
break;
|
break;
|
||||||
case 502:
|
case 502:
|
||||||
/* we set sd's here. FIXME. JRA */
|
/* we set sd's here. FIXME. JRA */
|
||||||
unistr2_to_ascii(share_name, &q_u->info.share.info502.info_502_str.uni_netname, sizeof(share_name));
|
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));
|
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(pathname, &q_u->info.share.info502.info_502_str.uni_path, sizeof(share_name));
|
||||||
|
type = q_u->info.share.info502.info_502.type;
|
||||||
break;
|
break;
|
||||||
case 1005:
|
case 1005:
|
||||||
/* DFS only level. */
|
/* DFS only level. */
|
||||||
status = ERROR_ACCESS_DENIED;
|
return ERROR_ACCESS_DENIED;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level));
|
DEBUG(5,("_srv_net_share_add: unsupported switch value %d\n", q_u->info_level));
|
||||||
status = NT_STATUS_INVALID_INFO_CLASS;
|
return NT_STATUS_INVALID_INFO_CLASS;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snum = find_service(share_name);
|
snum = find_service(share_name);
|
||||||
@ -1055,25 +1099,36 @@ uint32 _srv_net_share_add(pipes_struct *p, SRV_Q_NET_SHARE_ADD *q_u, SRV_R_NET_S
|
|||||||
if (snum >= 0)
|
if (snum >= 0)
|
||||||
return NT_STATUS_BAD_NETWORK_NAME;
|
return NT_STATUS_BAD_NETWORK_NAME;
|
||||||
|
|
||||||
/* Convert any '\' paths to '/' */
|
/* We can only add disk shares. */
|
||||||
unix_format(pathname);
|
if (type != STYPE_DISKTREE)
|
||||||
unix_clean_name(pathname);
|
return ERROR_ACCESS_DENIED;
|
||||||
|
|
||||||
/* NT is braindead - it wants a C: prefix to a pathname ! */
|
/* Check if the pathname is valid. */
|
||||||
ptr = pathname;
|
if (!(ptr = valid_share_pathname( pathname )))
|
||||||
if (strlen(pathname) > 2 && ptr[1] == ':' && ptr[0] != '/')
|
return ERRbadpath;
|
||||||
ptr += 2;
|
|
||||||
|
|
||||||
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"",
|
slprintf(command, sizeof(command)-1, "%s \"%s\" \"%s\" \"%s\"",
|
||||||
lp_add_share_cmd(), share_name, ptr, comment );
|
lp_add_share_cmd(), share_name, ptr, comment );
|
||||||
|
dos_to_unix(command, True); /* Convert to unix-codepage */
|
||||||
|
|
||||||
/* HERE ! JRA */
|
DEBUG(10,("_srv_net_share_add: Running [%s]\n", command ));
|
||||||
|
if ((ret = smbrun(command, NULL, False)) != 0) {
|
||||||
|
DEBUG(0,("_srv_net_share_add: Running [%s] returned (%d)\n", command, ret ));
|
||||||
|
return ERROR_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
r_u->status = status;
|
/* Send SIGHUP to process group. */
|
||||||
|
kill(0, SIGHUP);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't call reload_services() here, the SIGHUP will
|
||||||
|
* cause this to be done before the next packet is read
|
||||||
|
* from the client. JRA.
|
||||||
|
*/
|
||||||
|
|
||||||
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
|
DEBUG(5,("_srv_net_share_add: %d\n", __LINE__));
|
||||||
|
|
||||||
return r_u->status;
|
return NT_STATUS_NOPROBLEMO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user