Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: File permissions problem (updated)

by haukex (Monsignor)
on Dec 16, 2016 at 09:01 UTC ( #1177907=note: print w/replies, xml ) Need Help??


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

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

Replies are listed 'Best First'.
Re^6: File permissions problem (updated)
by wdhammond (Novice) on Dec 16, 2016 at 15:45 UTC

    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

        Thank you for all of your help Hauke.

        The "bug report" was created by me but is not getting much attention so I am trying to correct my copy of the application to make my job easier. Mostly I have been formatting out of copyright books for Project Gutenberg. I am working on learning Perl too. Thanks too for the links.

        Regards, Wayne

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1177907]
help
Chatterbox?
[marto]: good morning all

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2017-11-22 10:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (317 votes). Check out past polls.

    Notices?