Topic "Changing File Owner on Overwrite"

Author Message
Guest




I'm uploading files to a webserverserver with winscp. Lokal computer is windows, remote debian.

Sometimes files change the owner to the account im connecting with when overwritten. This only happens with certain files. In this case it's an .sql file.
Most files (mostly *.php) keep the owner of the previous version of the remote file.

How can I disable/prevent that ownership-change from happening?

**

Also: A setting would be nice to automatically set the owner of new files to the same owner as the director im uploading it into.


Thanks in advance!
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26553
Location: Prague, Czechia
Please read documentation:
https://winscp.net/eng/docs/resume#automatic

If that does not help, come back.
_________________
Martin Prikryl
Pascal Boulerie
[View user's profile]

Joined: 2009-07-31
Posts: 20
Location: France
Here is a workaround : the admin can set up an automatic cron task that changes the file properties and owner every 5 minutes.
Guest




thanks prikryl.

I've disabled the "temporary files"-option and this should solve my problem.


Still, please consider copying the owner/rights of the original file to the temporary before deleting it.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26553
Location: Prague, Czechia
Quote:
Still, please consider copying the owner/rights of the original file to the temporary before deleting it.

Rights are copied. And most users won't have permissions to change file ownership.
ddur

Guest


Hi, thank you for WinSCP!

I have similar case, Win->Deb.
Cannot login as www-data user, so I need to change owner for every new upload.
I there any other way to automagically change owner on new upload, except cron solution mentioned above?

Thanks.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26553
Location: Prague, Czechia
ddur wrote:
I have similar case, Win->Deb.
Cannot login as www-data user, so I need to change owner for every new upload.
I there any other way to automagically change owner on new upload, except cron solution mentioned above?

Not really.

You can of course write a WinSCP extension as a custom alternative to [i]Upload[/u] command that will upload and change ownership.
https://winscp.net/eng/docs/guide_custom_commands_automation
Pathduck
[View user's profile]
Donor
Joined: 2012-05-29
Posts: 76
Location: Oslo
You need to be root to use chown, unless you are allowed to sudo.

So unless you log in as root, you need to do sudo and since sudo requires a TTY you need to log in, since Winscp is not a tty.

If you have sudo or are root you could just open a terminal (ctrl+T) and do sudo chown. But if it prompts you for a password it will hang.

I have the same issue quite often, uploading files and then having to change their owner.

Either I just open in Putty and do it manually, but I have also made a custom command to do the same thing, it requires Cygwin+MinTTY+OpenSSH and preferably ssh-agent authentication and sudo without password.

Code:
d:\Software\cygwin\bin\mintty.exe /bin/bash -l -c "ssh -tp !# !U@!@ sudo chown -R !?OWNER:GROUP?myuser:mygroup! '!&'"


Not pretty, but it does work and you can select several files and change them. Since ssh also gives you a tty you can enter a password for sudo if required.

Doesn't seem to work on files/directories with spaces however.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26553
Location: Prague, Czechia
@Pathduck Nice solution! You should be able to the same with Plink (to reduce dependencies).
ddur

Guest


Thanks
Advertisements

You can post new topics in this forum






Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License