in reply to Re^3: File permissions problem (updated)
in thread File permissions problem

Thanks again Hauke.

The complete application is open source and available here: https://sourceforge.net/projects/guiguts/

I have it installed in Fedora 25 with Padre as a troubleshooting aid.

There are a couple of other problems too, but I thought this one would be the easiest one to troubleshoot.

Regards, Wayne
  • Comment on Re^4: File permissions problem (updated)

Replies are listed 'Best First'.
Re^5: File permissions problem (updated)
by haukex (Archbishop) on Dec 16, 2016 at 09:01 UTC

    Hi Wayne,

    So what's the result of running those commands to check on your umask setting? Update: Oh, I misunderstood your post because of the formatting! (missing <code> tags; I just considered the node for editing)

    Taking a look a the function SaveUTF from the source that you also posted in your other reply, it appears the module is saving files by using File::Temp to create a new file, and then replacing the old file with an unlink and a rename. File::Temp apparently sets the files it creates to mode 0600. I don't see an option to change that, so it'd probably be necessary to chmod the files after creation. You could simply set it to an explicit mode like 0640, or you could use the current umask like so: chmod(0666&~umask,$filename);

    Regards,
    -- Hauke D

      Hi Hauke,

      Sorry about the delay in responding, lost this response. I need to respond linearly to the comments.

      The response to umask command is 0002 which gives file permissions 0664. I should have looked at the permissions before responding instead of relying on my memory.:)

      There is a section that appears similar to your possible fix:

      # Custom file save routine to handle unicode files sub SaveUTF { my ( $w, $filename ) = @_; $filename = $w->FileName unless defined $filename; my $dir = dirname($filename); my $perms = ( stat($dir) )[2] & 07777; unless ( $perms & 0200 ) { $perms = $perms | 0200; chmod $perms, $dir or $w->BackTrace("Can not write to directory $dir: $!\n") and return; }
      Regards, Wayne

        Hi Wayne,

        PerlMonks is more of a place to learn Perl, and not usually a place where people do others' work for free - unless a monk happens to be interested, but that's not always the case, especially the more freebies one asks for ;-) If you're planning on fixing more bugs in the code, the best way to go would be to pick up at least a little bit of Perl yourself. perlintro is a good place to start, as well as Tutorials and learn.perl.org. Anyway, having said that...

        Disclaimer: I don't know the rest of the "guiguts" code, so I don't know if the following will fix the issue 100% or if there will be any negative side effects on other parts of the code.

        I'd try to hack the fix by adding the line chmod(0666&~umask,$filename) or warn "Couldn't chmod $filename"; after the line if ( rename( $tempfilename, $filename ) ) { (untested).

        BTW, it'd be best to mention the existing bug report: https://sourceforge.net/p/guiguts/bugs/133/

        Regards,
        -- Hauke D