Discussion:
sftp_mkdir() with server default permissions
Will Cosgrove
2018-11-06 17:56:11 UTC
Permalink
Hi All,
I’d like to modify sftp_mkdir() so it will optionally not use a mode for the new directory. This allows the server to create the folder with the default permissions value which some users require. Unfortunately the sftp_mkdir() function requires a mode. So I’m curious to know how you think I should proceed?

There are several possible solutions, my current super simple solution is to pass -1 as the mode which then causes sftp_mkdir to not set the permissions on the folder. That works, but it’s a bit ‘magical’ if you’re not reading the source. Another other option is to create a new API that doesn’t take a mode, but that also has its draw-backs. Any thoughts on how you all would like to see this structured?

Cheers,

Will
_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/l
Daniel Stenberg
2018-11-06 18:23:02 UTC
Permalink
Post by Will Cosgrove
There are several possible solutions, my current super simple solution is to
pass -1 as the mode which then causes sftp_mkdir to not set the permissions
on the folder. That works, but it’s a bit ‘magical’ if you’re not reading
the source.
I could imagine a LIBSSH2_MKDIR_DEFAULT_MODE (name to be bike-shedded) define
to be provided for the API, which very well could have a value of -1 if we
treat the mode signed internally or it could be some otherwise insane (large)
value that is unlikely to every actually be used as a real mode.
--
/ daniel.haxx.se
Loading...