[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scp example: file type code instead of permission bits ?

Good Evening,

I was playing with the scp example (libssh_scp.c) and when I tried to copy a
local file to a remote location ( ie: ./libssh_scp source.txt
localhost:destination.txt  )
I got the following error: scp status code 1d not valid.

I noticed that at line 185:                            mode = s.st_mode &
"mode" is set to the* file type code
And then we use it in line 210:
size, mode);
However in the documentation of the ssh_scp_push_file
it is sais that mode is "The* UNIX permissions* for the new file, e.g.

So I replaced the line 185 with  this:         mode = s.st_mode & *~*S_IFMT;
The only difference is the tild, it inverts the value of S_IFMT so we get
the other part of s.st_mode wich is the permission bits.
It seems to work.

Anyway, I hope that I didn't waste your time with a known issue,


Baptiste Marchand - EPITA 2013

Re: scp example: file type code instead of permission bits ?Andreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org