Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-10

DeleteFile

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Agustìn Gregorieu

Hi! I have a CGI program that must delete files from a server and it's owned by www-data which allows me to read a file but not to delete it, even though the file has permissions 777. The folder containing the files I want to delete has permissions "drwxrwxrwx" and it's owned by "root:root" and it's files has the same characteristics. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171031/4e0657e2/attachment.html>

Reply by email

leledumbo
to Agustìn Gregorieu
Hi! I have a CGI program that must delete files from a server and it's

owned by www-data which allows me to read a file but not to delete it, even though the file has permissions 777. The folder containing the files I want to delete has permissions "drwxrwxrwx" and it's owned by "root:root" and it's files has the same characteristics.

Well, that requires a deeper inspection. Try inspecting return value of SysErrorMessage(GetLastOSError) after a failed deletion.

Reply by email

Michael Van Canneyt
to Agustìn Gregorieu: Hi! I have a CGI program that must delete files from a server and it's owned by www-data…
Agustìn Gregorieu wrote 5 lines
Hi! I have a CGI program that must delete files from a server and it's owned by www-data which allows me to read a file but not to delete it, even though the file has permissions 777. The folder containing the files I want to delete has permissions "drwxrwxrwx" and it's owned by "root:root" and it's files has the same characteristics.

You should check the return value of GetLastOSError. If that does not tell you anything, try stracing your program. For a cgi program, what I usually do is create a shell script which I place instead of the actual binary:

#!/bin/sh
exec strace -o /tmp/cgi.log /path/to/real/cgi/program.bin

Michael.

Reply by email

Agustìn Gregorieu
to Michael Van Canneyt

Thank you for your answer! I've already solved it, using the GetLastOSError I got a "permission denied" message, so after I change some group permissions on the folder I manage to delete correctly the files.

On Tue, 31 Oct 2017, Agustìn Gregorieu via Lazarus wrote:

Hi! I have a CGI program that must delete files from a server and it's owned by www-data which allows me to read a file but not to delete it, even though the file has permissions 777. The folder containing the files I want to delete has permissions "drwxrwxrwx" and it's owned by "root:root" and it's files has the same characteristics.

You should check the return value of GetLastOSError. If that does not tell you anything, try stracing your program. For a cgi program, what I usually do is create a shell script which I place instead of the actual binary:

#!/bin/sh
exec strace -o /tmp/cgi.log /path/to/real/cgi/program.bin

Michael.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171101/72368f89/attachment.html>

Reply by email