Bugzilla – Attachment 2213 Details for
Bug 2067
lsetstat extension to sftp-server
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to sftp to add touch [-h] command
touch.patch (text/plain), 3.31 KB, created by
Bert Haverkamp
on 2013-02-02 00:17:33 AEDT
(
hide
)
Description:
Patch to sftp to add touch [-h] command
Filename:
MIME Type:
Creator:
Bert Haverkamp
Created:
2013-02-02 00:17:33 AEDT
Size:
3.31 KB
patch
obsolete
>diff -rupN openssh-5.8p1-orig/sftp.c openssh-5.8p1/sftp.c >--- openssh-5.8p1-orig/sftp.c 2012-04-23 19:49:21.000000000 +0200 >+++ openssh-5.8p1/sftp.c 2013-01-28 20:19:58.000000000 +0100 >@@ -49,7 +51,7 @@ typedef void EditLine; > #include <string.h> > #include <unistd.h> > #include <stdarg.h> >- >+#include <time.h> > #ifdef HAVE_UTIL_H > # include <util.h> > #endif >@@ -149,6 +151,7 @@ extern char *__progname; > #define I_SYMLINK 21 > #define I_VERSION 22 > #define I_PROGRESS 23 >+#define I_TOUCH 26 > > struct CMD { > const char *c; >@@ -192,6 +195,7 @@ static const struct CMD cmds[] = { > { "rm", I_RM, REMOTE }, > { "rmdir", I_RMDIR, REMOTE }, > { "symlink", I_SYMLINK, REMOTE }, >+ { "touch", I_TOUCH, REMOTE }, > { "version", I_VERSION, NOARGS }, > { "!", I_SHELL, NOARGS }, > { "?", I_HELP, NOARGS }, >@@ -254,6 +258,7 @@ help(void) > "rm path Delete remote file\n" > "rmdir path Remove remote directory\n" > "symlink oldpath newpath Symlink remote file\n" >+ "touch [-h] path Touch remote file to create it or set timestamp (-h for symlink)\n" > "version Show SFTP version\n" > "!command Execute 'command' in local shell\n" > "! Escape to local shell\n" >@@ -482,6 +487,30 @@ parse_df_flags(const char *cmd, char **a > } > > static int >+parse_touch_flags(const char *cmd, char **argv, int argc, int *hflag) >+{ >+ extern int opterr, optind, optopt, optreset; >+ int ch; >+ >+ optind = optreset = 1; >+ opterr = 0; >+ >+ *hflag = 0; >+ while ((ch = getopt(argc, argv, "h")) != -1) { >+ switch (ch) { >+ case 'h': >+ *hflag = 1; >+ break; >+ default: >+ error("%s: Invalid flag -%c", cmd, optopt); >+ return -1; >+ } >+ } >+ >+ return optind; >+} >+ >+static int > is_dir(char *path) > { > struct stat sb; >@@ -675,6 +704,37 @@ out: > return(err); > } > >+int >+process_touch(struct sftp_conn *conn, char *path, Attrib *a, int hflag) >+{ >+ time_t t; >+ int err = 0; >+ >+ t = time(NULL); >+ a->flags |= SSH2_FILEXFER_ATTR_ACMODTIME; >+ a->atime = t; >+ a->mtime = t; >+ >+ debug3("Looking up %s", path); >+ if (hflag) { >+ err=do_lstat(conn,path,1); >+ if (err == NULL) >+ error("touch: setting times of `link3': No such file or directory",path); >+ else >+ do_lsetstat(conn, path, a); >+ } >+ else { >+ err=do_stat(conn,path,1); >+ if (err == NULL) >+ /* File not found, create it. */ >+ err=do_create(conn, path, a); >+ else >+ /* file exists, do (l)setstat to update timestamp */ >+ do_setstat(conn, path, a); >+ } >+ return(err); >+} >+ > static int > sdirent_comp(const void *aa, const void *bb) > { >@@ -1274,6 +1335,12 @@ parse_args(const char **cpp, int *pflag, > case I_VERSION: > case I_PROGRESS: > break; >+ case I_TOUCH: >+ if ((optidx = parse_touch_flags(cmd, argv, argc, hflag)) == -1) >+ return -1; >+ *path1 = xstrdup(argv[optidx]); >+ undo_glob_escape(*path1); >+ break; > default: > fatal("Command not implemented"); > } >@@ -1498,6 +1564,11 @@ parse_dispatch_command(struct sftp_conn > else > printf("Progress meter disabled\n"); > break; >+ case I_TOUCH: >+ path1 = make_absolute(path1, *pwd); >+ attrib_clear(&a); >+ process_touch(conn, path1, &a, hflag); >+ break; > default: > fatal("%d is not implemented", cmdnum); > }
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 2067
:
2212
|
2213
|
3219