summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-04-06 23:01:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:51:08 -0500
commit1db9257c953c93c3f26596a535e4f26b609e7955 (patch)
tree6113771ac0ec30fd0cb67d243a07f5844a5c6145 /source3
parent9d458e45c8979bbfa081722b379abba9db922bba (diff)
downloadsamba-1db9257c953c93c3f26596a535e4f26b609e7955.tar.gz
samba-1db9257c953c93c3f26596a535e4f26b609e7955.tar.bz2
samba-1db9257c953c93c3f26596a535e4f26b609e7955.zip
r96: Stupid f&%'n UNIX extensions.... SETPATHINFO
normally takes as it's param entry the filename to be acted upon.... Unless it's UNIX extensions create hardlink, or UNIX extensions create symlink. Then it's param -> newfile name data -> oldfile name. This caused me to stuff them up in 3.0.2 (and the client commands link and symlink). Fixed them, everything is now called oldname and newname - thus specifying which name should already exist (hint - the old one...) and which will be created (newname). Jeremy. (This used to be commit 21cc6ab7e8a41160a3e2970623ade7445b5214d6)
Diffstat (limited to 'source3')
-rw-r--r--source3/client/client.c36
-rw-r--r--source3/libsmb/clifile.c19
-rw-r--r--source3/smbd/nttrans.c14
-rw-r--r--source3/smbd/trans2.c61
4 files changed, 67 insertions, 63 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 1da35fcc43..f2f43656cb 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1608,7 +1608,7 @@ static int cmd_rmdir(void)
static int cmd_link(void)
{
- pstring src,dest;
+ pstring oldname,newname;
pstring buf,buf2;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
@@ -1616,20 +1616,20 @@ static int cmd_link(void)
return 1;
}
- pstrcpy(src,cur_dir);
- pstrcpy(dest,cur_dir);
+ pstrcpy(oldname,cur_dir);
+ pstrcpy(newname,cur_dir);
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) ||
!next_token_nr(NULL,buf2,NULL, sizeof(buf2))) {
- d_printf("link <src> <dest>\n");
+ d_printf("link <oldname> <newname>\n");
return 1;
}
- pstrcat(src,buf);
- pstrcat(dest,buf2);
+ pstrcat(oldname,buf);
+ pstrcat(newname,buf2);
- if (!cli_unix_hardlink(cli, src, dest)) {
- d_printf("%s linking files (%s -> %s)\n", cli_errstr(cli), src, dest);
+ if (!cli_unix_hardlink(cli, oldname, newname)) {
+ d_printf("%s linking files (%s -> %s)\n", cli_errstr(cli), newname, oldname);
return 1;
}
@@ -1642,7 +1642,7 @@ static int cmd_link(void)
static int cmd_symlink(void)
{
- pstring src,dest;
+ pstring oldname,newname;
pstring buf,buf2;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
@@ -1650,21 +1650,21 @@ static int cmd_symlink(void)
return 1;
}
- pstrcpy(src,cur_dir);
- pstrcpy(dest,cur_dir);
+ pstrcpy(oldname,cur_dir);
+ pstrcpy(newname,cur_dir);
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) ||
!next_token_nr(NULL,buf2,NULL, sizeof(buf2))) {
- d_printf("symlink <src> <dest>\n");
+ d_printf("symlink <oldname> <newname>\n");
return 1;
}
- pstrcat(src,buf);
- pstrcat(dest,buf2);
+ pstrcat(oldname,buf);
+ pstrcat(newname,buf2);
- if (!cli_unix_symlink(cli, src, dest)) {
+ if (!cli_unix_symlink(cli, oldname, newname)) {
d_printf("%s symlinking files (%s -> %s)\n",
- cli_errstr(cli), src, dest);
+ cli_errstr(cli), newname, oldname);
return 1;
}
@@ -2192,7 +2192,7 @@ static struct
{"help",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
{"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
{"lcd",cmd_lcd,"[directory] change/report the local current working directory",{COMPL_LOCAL,COMPL_NONE}},
- {"link",cmd_link,"<src> <dest> create a UNIX hard link",{COMPL_REMOTE,COMPL_REMOTE}},
+ {"link",cmd_link,"<oldname> <newname> create a UNIX hard link",{COMPL_REMOTE,COMPL_REMOTE}},
{"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},
{"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
{"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}},
@@ -2219,7 +2219,7 @@ static struct
{"rm",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
{"rmdir",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
{"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
- {"symlink",cmd_symlink,"<src> <dest> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
+ {"symlink",cmd_symlink,"<oldname> <newname> create a UNIX symlink",{COMPL_REMOTE,COMPL_REMOTE}},
{"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
{"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
{"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index bf7923ec78..398c7cc4f0 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -25,9 +25,10 @@
/****************************************************************************
Hard/Symlink a file (UNIX extensions).
+ Creates new name (sym)linked to oldname.
****************************************************************************/
-static BOOL cli_link_internal(struct cli_state *cli, const char *fname_src, const char *fname_dst, BOOL hard_link)
+static BOOL cli_link_internal(struct cli_state *cli, const char *oldname, const char *newname, BOOL hard_link)
{
unsigned int data_len = 0;
unsigned int param_len = 0;
@@ -36,18 +37,18 @@ static BOOL cli_link_internal(struct cli_state *cli, const char *fname_src, cons
pstring data;
char *rparam=NULL, *rdata=NULL;
char *p;
- size_t srclen = 2*(strlen(fname_src)+1);
- size_t destlen = 2*(strlen(fname_dst) + 1);
+ size_t oldlen = 2*(strlen(oldname)+1);
+ size_t newlen = 2*(strlen(newname)+1);
memset(param, 0, sizeof(param));
SSVAL(param,0,hard_link ? SMB_SET_FILE_UNIX_HLINK : SMB_SET_FILE_UNIX_LINK);
p = &param[6];
- p += clistr_push(cli, p, fname_src, MIN(srclen, sizeof(param)-6), STR_TERMINATE);
+ p += clistr_push(cli, p, newname, MIN(newlen, sizeof(param)-6), STR_TERMINATE);
param_len = PTR_DIFF(p, param);
p = data;
- p += clistr_push(cli, p, fname_dst, MIN(destlen,sizeof(data)), STR_TERMINATE);
+ p += clistr_push(cli, p, oldname, MIN(oldlen,sizeof(data)), STR_TERMINATE);
data_len = PTR_DIFF(p, data);
if (!cli_send_trans(cli, SMBtrans2,
@@ -105,18 +106,18 @@ uint32 unix_perms_to_wire(mode_t perms)
Symlink a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_symlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_unix_symlink(struct cli_state *cli, const char *oldname, const char *newname)
{
- return cli_link_internal(cli, fname_src, fname_dst, False);
+ return cli_link_internal(cli, oldname, newname, False);
}
/****************************************************************************
Hard a file (UNIX extensions).
****************************************************************************/
-BOOL cli_unix_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst)
+BOOL cli_unix_hardlink(struct cli_state *cli, const char *oldname, const char *newname)
{
- return cli_link_internal(cli, fname_src, fname_dst, True);
+ return cli_link_internal(cli, oldname, newname, True);
}
/****************************************************************************
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index c9cc44627d..6ba74d5d50 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1500,7 +1500,7 @@ int reply_ntrename(connection_struct *conn,
char *inbuf,char *outbuf,int length,int bufsize)
{
int outsize = 0;
- pstring name;
+ pstring oldname;
pstring newname;
char *p;
NTSTATUS status;
@@ -1515,13 +1515,13 @@ int reply_ntrename(connection_struct *conn,
}
p = smb_buf(inbuf) + 1;
- p += srvstr_get_path(inbuf, name, p, sizeof(name), 0, STR_TERMINATE, &status);
+ p += srvstr_get_path(inbuf, oldname, p, sizeof(oldname), 0, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBntrename);
return ERROR_NT(status);
}
- if( strchr_m(name, ':')) {
+ if( strchr_m(oldname, ':')) {
/* Can't rename a stream. */
END_PROFILE(SMBntrename);
return ERROR_NT(NT_STATUS_ACCESS_DENIED);
@@ -1534,15 +1534,15 @@ int reply_ntrename(connection_struct *conn,
return ERROR_NT(status);
}
- RESOLVE_DFSPATH(name, conn, inbuf, outbuf);
+ RESOLVE_DFSPATH(oldname, conn, inbuf, outbuf);
RESOLVE_DFSPATH(newname, conn, inbuf, outbuf);
- DEBUG(3,("reply_ntrename : %s -> %s\n",name,newname));
+ DEBUG(3,("reply_ntrename : %s -> %s\n",oldname,newname));
if (rename_type == RENAME_FLAG_RENAME) {
- status = rename_internals(conn, name, newname, attrs, False);
+ status = rename_internals(conn, oldname, newname, attrs, False);
} else {
- status = hardlink_internals(conn, name, newname);
+ status = hardlink_internals(conn, oldname, newname);
}
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 1e7d845714..30d6845509 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2825,32 +2825,32 @@ static int ensure_link_is_safe(connection_struct *conn, const char *link_dest_in
code.
****************************************************************************/
-NTSTATUS hardlink_internals(connection_struct *conn, char *name, char *newname)
+NTSTATUS hardlink_internals(connection_struct *conn, char *oldname, char *newname)
{
- BOOL bad_path_src = False;
- BOOL bad_path_dest = False;
+ BOOL bad_path_oldname = False;
+ BOOL bad_path_newname = False;
SMB_STRUCT_STAT sbuf1, sbuf2;
BOOL rc, rcdest;
- pstring last_component_src;
- pstring last_component_dest;
+ pstring last_component_oldname;
+ pstring last_component_newname;
NTSTATUS status = NT_STATUS_OK;
ZERO_STRUCT(sbuf1);
ZERO_STRUCT(sbuf2);
/* No wildcards. */
- if (ms_has_wild(name) || ms_has_wild(newname)) {
+ if (ms_has_wild(newname) || ms_has_wild(oldname)) {
return NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
}
- rc = unix_convert(name,conn,last_component_src,&bad_path_src,&sbuf1);
- if (!rc && bad_path_src) {
+ rc = unix_convert(oldname,conn,last_component_oldname,&bad_path_oldname,&sbuf1);
+ if (!rc && bad_path_oldname) {
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
}
/* Quick check for "." and ".." */
- if (last_component_src[0] == '.') {
- if (!last_component_src[1] || (last_component_src[1] == '.' && !last_component_src[2])) {
+ if (last_component_oldname[0] == '.') {
+ if (!last_component_oldname[1] || (last_component_oldname[1] == '.' && !last_component_oldname[2])) {
return NT_STATUS_OBJECT_NAME_INVALID;
}
}
@@ -2860,19 +2860,19 @@ NTSTATUS hardlink_internals(connection_struct *conn, char *name, char *newname)
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- rcdest = unix_convert(newname,conn,last_component_dest,&bad_path_dest,&sbuf2);
- if (!rcdest && bad_path_dest) {
+ rcdest = unix_convert(newname,conn,last_component_newname,&bad_path_newname,&sbuf2);
+ if (!rcdest && bad_path_newname) {
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
}
/* Quick check for "." and ".." */
- if (last_component_dest[0] == '.') {
- if (!last_component_dest[1] || (last_component_dest[1] == '.' && !last_component_dest[2])) {
+ if (last_component_newname[0] == '.') {
+ if (!last_component_newname[1] || (last_component_newname[1] == '.' && !last_component_newname[2])) {
return NT_STATUS_OBJECT_NAME_INVALID;
}
}
- /* Disallow if already exists. */
+ /* Disallow if newname already exists. */
if (VALID_STAT(sbuf2)) {
return NT_STATUS_OBJECT_NAME_COLLISION;
}
@@ -2882,15 +2882,15 @@ NTSTATUS hardlink_internals(connection_struct *conn, char *name, char *newname)
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
- if (ensure_link_is_safe(conn, newname, newname) != 0)
+ if (ensure_link_is_safe(conn, oldname, oldname) != 0)
return NT_STATUS_ACCESS_DENIED;
- DEBUG(10,("hardlink_internals: doing hard link %s -> %s\n", name, newname ));
+ DEBUG(10,("hardlink_internals: doing hard link %s -> %s\n", newname, oldname ));
- if (SMB_VFS_LINK(conn,name,newname) != 0) {
+ if (SMB_VFS_LINK(conn,oldname,newname) != 0) {
status = map_nt_error_from_unix(errno);
- DEBUG(3,("hardlink_internals: Error %s link %s -> %s\n",
- nt_errstr(status), name,newname));
+ DEBUG(3,("hardlink_internals: Error %s hard link %s -> %s\n",
+ nt_errstr(status), newname, oldname));
}
return status;
@@ -3380,25 +3380,27 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
case SMB_SET_FILE_UNIX_LINK:
{
- pstring link_dest;
+ pstring oldname;
+ char *newname = fname;
+
/* Set a symbolic link. */
/* Don't allow this if follow links is false. */
if (!lp_symlinks(SNUM(conn)))
return(ERROR_DOS(ERRDOS,ERRnoaccess));
- srvstr_get_path(inbuf, link_dest, pdata, sizeof(link_dest), -1, STR_TERMINATE, &status);
+ srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), -1, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
- if (ensure_link_is_safe(conn, link_dest, link_dest) != 0)
+ if (ensure_link_is_safe(conn, oldname, oldname) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing symlink %s -> %s\n",
- fname, link_dest ));
+ fname, oldname ));
- if (SMB_VFS_SYMLINK(conn,link_dest,fname) != 0)
+ if (SMB_VFS_SYMLINK(conn,oldname,newname) != 0)
return(UNIXERROR(ERRDOS,ERRnoaccess));
SSVAL(params,0,0);
send_trans2_replies(outbuf, bufsize, params, 2, *ppdata, 0);
@@ -3407,18 +3409,19 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
case SMB_SET_FILE_UNIX_HLINK:
{
- pstring link_dest;
+ pstring oldname;
+ char *newname = fname;
/* Set a hard link. */
- srvstr_get_path(inbuf, link_dest, pdata, sizeof(link_dest), -1, STR_TERMINATE, &status);
+ srvstr_get_path(inbuf, oldname, pdata, sizeof(oldname), -1, STR_TERMINATE, &status);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}
DEBUG(10,("call_trans2setfilepathinfo: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
- fname, link_dest ));
+ fname, oldname));
- status = hardlink_internals(conn, fname, link_dest);
+ status = hardlink_internals(conn, oldname, newname);
if (!NT_STATUS_IS_OK(status)) {
return ERROR_NT(status);
}