Matias Surdi wrote: > Steve Holden escribió: > >> Matias Surdi wrote: >>> Thanks for your reply. >>> >>> This is the code that creates the file: >>> lock_file = open(".lock","w") >>> lock_file.write("test") >>> lock_file.close() >>> #Change permissions so that CGI can write lock file >>> os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO | >>> stat.S_IRWXG)) >>> >>> This script was run as root. >>> >>> Now, the code of the CGI that should delete the file: >>> >>> #As you see, I can write to the file >>> lock_file = open(".lock","w") >>> lock_file.write("") >>> lock_file.close() >>> # But the following line raises a "permission denied" OSError >>> os.remove(".lock") >>> >>> I've seen that the script is running as "nobody", but, the file is rwx by >>> everybody. I've also tryed changing the owner of the file to "nobody" >>> also, but no luck anyway. >>> >>> Thanks a lot. >>> >>> >>> Steve Holden wrote: >>> >>>> Matias Surdi wrote: >>>>> HI! >>>>> >>>>> I want to delete a file from a CGI, but I always get a Permission >>>>> denied error. >>>>> >>>>> I've tryed this after creating the file (from a normal script): >>>>> >>>>> os.chmod(".lock",stat.S_IMODE(stat.S_IRWXU | stat.S_IRWXO | >>>>> stat.S_IRWXG)) >>>>> os.chown(".lock",pwd.getpwnam("nobody")[2],pwd.getpwnam("nobody")[3]) >>>>> >>>>> but the CGI still can't delete the file. >>>>> >>>>> I will appreciate very much your help. >>>>> >>>>> Thanks a lot. >>>>> >>>>> >>>> How was the file created in the first place? If you don't have >>>> permissions to delete it you may well not have permissions to reown it >>>> or change its permissions either! >>>> >> Most likely, your problem is that to delete a file you need write >> permissions on the directory that contains it [1]. Apparently the web >> user (nobody, or apache, or whatever) doesn't have those permissions. >> >> regards >> Steve >> >> [1]: Unless the sticky bit is set on the containing directory, when >> other tests are applied instead. If this makes no sense to you, ignore it. > > > Hi! > > I feel so s**id.... it's very likely to be that the problem.... I'll try > this next week at work. > > Thanks a lot for the cold water on the face! > Hey, it's just information: no need to overreact!
regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- http://mail.python.org/mailman/listinfo/python-list