Title: Missing SFTP file attribute constants · Issue #119 · ParallelSSH/ssh2-python · GitHub
Open Graph Title: Missing SFTP file attribute constants · Issue #119 · ParallelSSH/ssh2-python
X Title: Missing SFTP file attribute constants · Issue #119 · ParallelSSH/ssh2-python
Description: Bug reports I tried to set permission on a file on a SFTP server. I use normally use FileZilla to interact with the server, but I needed a fast way to change a lot of files, file permission. So I thought I would write a python script. I ...
Open Graph Description: Bug reports I tried to set permission on a file on a SFTP server. I use normally use FileZilla to interact with the server, but I needed a fast way to change a lot of files, file permission. So I t...
X Description: Bug reports I tried to set permission on a file on a SFTP server. I use normally use FileZilla to interact with the server, but I needed a fast way to change a lot of files, file permission. So I t...
Opengraph URL: https://github.com/ParallelSSH/ssh2-python/issues/119
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing SFTP file attribute constants","articleBody":"### Bug reports\r\nI tried to set permission on a file on a SFTP server. I use normally use FileZilla to interact with the server, but I needed a fast way to change a lot of files, file permission. So I thought I would write a python script.\r\n\r\nI noticed 2 things, if I only have read access to the file, I could not change the permission, giving me a `ssh2.exceptions.SFTPProtocolError`, I can using the same login, change the permission in FileZilla.\r\n\r\nThe second and more important issue, was that I could not change the permission at all using the code described below:\r\n__Steps to reproduce:__\r\n\r\n```py\r\ndef chmod(sftp, path, permissions):\r\n stat = sftp.stat(path)\r\n print(\"original permission\", oct(stat.permissions))\r\n \r\n stat.permissions = permissions | 0x8000 #I tried without the '|' as well, and I tried with only LIBSSH2_SFTP_S_IRWXU\r\n print(\"seting permissions to \", oct(stat.permissions))\r\n\r\n try:\r\n if sftp.setstat(path, stat) == 0:\r\n stat = sftp.stat(path)\r\n print(\"managed to set permissions to \", oct(stat.permissions))\r\n else:\r\n print(\"failed to set permissions\")\r\n\r\n except Exception:\r\n raise\r\n```\r\nThe out put is this when trying to change the permission of a file from '666' to '755'\r\n\r\n```txt\r\noriginal permission 0o100666\r\nseting permissions to 0o100755\r\nmanaged to set permissions to 0o100666\r\nsuccess\r\n```\r\n__Expected behaviour:__ \r\nI expect that I can change permission on files with only read-access, as long as the authenticated user, has privileges todo so\r\nI expected that the new file permission would be '755' after calling `setstat` with changed permissions\r\n__Actual behaviour:__ \r\nWhen I only read access has been set on a file it throws a `ssh2.exceptions.SFTPProtocolError`\r\nWhen trying to setstat it does not change, even though the `setstat()` returned a 0\r\n__Additional info:__ \r\nI am uncertain of which libssh2 I am running, as I just pip installed `ssh2-python` and it was up and running, but if I were to hazard a guess, I'd say 1.9.0","author":{"url":"https://github.com/Togtja","@type":"Person","name":"Togtja"},"datePublished":"2020-10-13T11:08:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/119/ssh2-python/issues/119"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b7fbce0f-52cf-cff7-222c-65c53b7f0351 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E358:3B507F:16BCBA2:1F5AC9A:696AA7DC |
| html-safe-nonce | f339a747f5c0e6b1fe802f2b07be2ca0dfdbd3f83207a02287650f5080cd21db |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzU4OjNCNTA3RjoxNkJDQkEyOjFGNUFDOUE6Njk2QUE3REMiLCJ2aXNpdG9yX2lkIjoiMTg2NzU0NjI3MTM0OTkwOTQ2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f4f092632ff8c34694ea141c70b35b659da7e4f39c414f0a0f85f40da03add6d |
| hovercard-subject-tag | issue:720128101 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ParallelSSH/ssh2-python/119/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a201a1f7527e4687cffd28d3812178df9e5b215fc4b83d9ee9a941937913eda4/ParallelSSH/ssh2-python/issues/119 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a201a1f7527e4687cffd28d3812178df9e5b215fc4b83d9ee9a941937913eda4/ParallelSSH/ssh2-python/issues/119 |
| og:image:alt | Bug reports I tried to set permission on a file on a SFTP server. I use normally use FileZilla to interact with the server, but I needed a fast way to change a lot of files, file permission. So I t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Togtja |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3eaf9b8cf1badcd7041a8ad480b9d9b28bea0ef1cc821ca9ff20f2cc7f4fe4b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/ParallelSSH/ssh2-python git https://github.com/ParallelSSH/ssh2-python.git |
| octolytics-dimension-user_id | 22918200 |
| octolytics-dimension-user_login | ParallelSSH |
| octolytics-dimension-repository_id | 98586974 |
| octolytics-dimension-repository_nwo | ParallelSSH/ssh2-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 98586974 |
| octolytics-dimension-repository_network_root_nwo | ParallelSSH/ssh2-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd9a979046e6382bd084e2bd873bf65f797125ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width