Bugzilla – Attachment 169 Details for
Bug 428
sftp could use a command to transfer symlinks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
implement the getlink command
22 (text/plain), 2.48 KB, created by
gfernandez
on 2002-11-07 01:38:38 AEDT
(
hide
)
Description:
implement the getlink command
Filename:
MIME Type:
Creator:
gfernandez
Created:
2002-11-07 01:38:38 AEDT
Size:
2.48 KB
patch
obsolete
>diff -u ../openssh-3.4p1/sftp-client.c . >--- ../openssh-3.4p1/sftp-client.c Sun Jun 23 17:27:19 2002 >+++ ./sftp-client.c Tue Nov 5 10:42:49 2002 >@@ -666,14 +666,14 @@ > > status = get_status(conn->fd_in, id); > if (status != SSH2_FX_OK) >- error("Couldn't rename file \"%s\" to \"%s\": %s", oldpath, >+ error("Couldn't symlink file \"%s\" to \"%s\": %s", oldpath, > newpath, fx2txt(status)); > > return(status); > } > > char * >-do_readlink(struct sftp_conn *conn, char *path) >+do_readlink(struct sftp_conn *conn, char *path, Attrib *attrib) > { > Buffer msg; > u_int type, expected_id, count, id; >@@ -712,6 +712,9 @@ > > debug3("SSH_FXP_READLINK %s -> %s", path, filename); > >+ if (attrib != NULL) >+ *attrib = *a; >+ > xfree(longname); > > buffer_free(&msg); >@@ -719,6 +722,53 @@ > return(filename); > } > >+int >+do_getlink(struct sftp_conn *conn, char *path) >+{ >+ char *dest; >+ u_int status = 0; >+ int ret; >+ struct stat statb; >+ char *filename; >+ Attrib *a; >+ Attrib attrib; >+ >+ a = do_lstat(conn, path, 0); >+ if (a == NULL || !S_ISLNK(a->perm)) { >+ if (a != NULL) >+ error("%s is not a symlink", path); >+ return(-1); >+ } >+ >+ dest = do_readlink(conn, path, &attrib); >+ if (dest == NULL) >+ return(-1); >+ filename = strrchr(path, '/'); >+ if (filename == NULL) >+ filename = path; >+ else >+ filename += 1; >+ if (lstat(filename, &statb) == 0) { >+ error("Name \"%s\" already exists", filename); >+ return(-1); >+ } >+ else { >+ ret = symlink(dest, filename); >+ status = (ret == -1) ? errno : 0; >+ if (status != 0) >+ error("Couldn't create symlink \"%s\": %s", filename, >+ strerror(status)); >+ if (getuid() == 0 || geteuid() == 0) { >+ ret = lchown(filename, attrib.uid, attrib.gid); >+ status = (ret == -1) ? errno : 0; >+ if (status != 0) >+ error("Couldn't set ownership on symlink \"%s\": > %s", filename, >+ strerror(status)); >+ } >+ } >+ return(status); >+} >+ > static void > send_read_request(int fd_out, u_int id, u_int64_t offset, u_int len, > char *handle, u_int handle_len)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 428
:
168
| 169 |
170
|
171
|
172