★ wanayoo — archive 1999 https://github.com/ParallelSSH/ssh2-python/issues/103Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh2 does not set mtime/atime (scp_send64, setstat, fsetstat) #103

Open
hakaishi opened this issue Aug 13, 2020 · 7 comments
Open

ssh2 does not set mtime/atime (scp_send64, setstat, fsetstat) #103

hakaishi opened this issue Aug 13, 2020 · 7 comments

Comments

@hakaishi
Copy link

@hakaishi hakaishi commented Aug 13, 2020

Documentation says:

scp_send64(self, path, int mode, libssh2_uint64_t size, time_t mtime, time_t atime)

But mtime and atime seem to be ignored. I tried copying from the examples, but it still won't work.
My authentication method is by the way userauth_password.

It did work with paramiko, so it shouldn't be an issue with the ssh server.

By the way: I would consider to work around this using setstat(path, attrs), but I'm not sure how I would have to create the SFTPAttributes object. It would be nice to have an example or more documentation on that.

@hakaishi
Copy link
Author

@hakaishi hakaishi commented Aug 13, 2020

Btw.: Using python 3.8.2 on Ubuntu 20.04

@pkittenis
Copy link
Member

@pkittenis pkittenis commented Aug 14, 2020

Hey,

mtime and atime are passed onto libssh2 - whether they do anything depends on libssh2. SFTPAttributes is a python class typical python code to create object and set attributes.

@hakaishi
Copy link
Author

@hakaishi hakaishi commented Aug 14, 2020

I just took a peek into the source code. I didn't find anything suspicious yet.
Looking at the manpage, it should be working...
No issues reported on the GitHub project either...
It would be nice if you could confirm that it is a pure ssh2 library problem. I could open an issue over there then.

@hakaishi
Copy link
Author

@hakaishi hakaishi commented Aug 14, 2020

I've never worked with cdef and the like.
The function definitions look like I could simply do things like

fileinfo = stat(path_to_file)
attrs = SFTPAttributes()
attrs.mtime(fileinfo.st_mtime)

and so on...
It would be convenient if I could simply initialize the object using the stat result of the file 😇

@hakaishi
Copy link
Author

@hakaishi hakaishi commented Aug 17, 2020

I tried the following (with full paths though):

fifo = stat(".bashrc")
attr = SFTPAttributes()
attr.filesize = fifo.st_size
print(".bashrc", datetime.fromtimestamp(fifo.st_mtime))
attr.atime = fifo.st_atime
attr.mtime = fifo.st_mtime
attr.permissions = fifo.st_mode
attr.gid = fifo.st_gid
attr.uid = fifo.st_uid
self.connection.setstat(".bashrc", attr)
t = self.connection.stat(".bashrc")
print(datetime.fromtimestamp(t.atime),  datetime.fromtimestamp(t.mtime))

first print with local file says: ".bashrc 2019-07-08 08:10:56.616019"
second print with remote file says: "2020-08-17 22:38:00 2020-08-17 22:45:40"

EDIT: I also tried it with relative paths (hard coded) with the same negative result

@hakaishi
Copy link
Author

@hakaishi hakaishi commented Aug 18, 2020

I also tried the sftp_handle.fsetstat, but that also doesn't seem to work.
Just in case, I also used a vm with mx linux using python 3.7, but it's also not working over there (sent file from vm to local pc).

@hakaishi hakaishi changed the title scp_send64 does not set mtime/atime ssh2 does not set mtime/atime (scp_send64, setstat, fsetstat) Aug 18, 2020
@pkittenis
Copy link
Member

@pkittenis pkittenis commented Aug 18, 2020

Will try and reproduce in C when have some time, not high priority atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.