Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: howto change default permissions for new file created with dolphin

  1. #1

    Question howto change default permissions for new file created with dolphin

    When I create a new file/folder in a ext4 data partition, it has permissions:

    owner: rwx
    group: r
    other: r

    I would like to change this default to:

    owner: rwx
    group: rw
    other: -

    I tried changing fstab, but umask and guid are not supported mount options for ext4. What can I do?

    Note: I know I can do a chmod, but I don't want to do this again and again for every new file I create.

  2. #2
    Join Date
    Mar 2011
    Location
    Norway
    Posts
    77

    Default Re: howto change default permissions for new file created with dolphin

    Did a quick search, and figured this out, somebody stop me if I'm way off:

    To change default file permissions to what you're asking, this line should be added to /etc/pam.d/login
    Code:
    session optional pam_umask.so umask=0017
    If I figured this out correctly, umask's numbers works opposite of chmod, so the two first zeros keeps all permissions for root and owner, the following one subtracts execute rights from group permissions, and the last 7 takes away all rights to other users.

    Give it a go, if it doesn't work it's fairly easy to remove again.

  3. #3
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,357
    Blog Entries
    3

    Default Re: howto change default permissions for new file created with dolphin

    The tradition method would be to give a "umask" command in your ".profile" (in your home directory)
    Code:
    umask 017
    openSUSE Leap 15.1; KDE Plasma 5;

  4. #4
    Join Date
    Mar 2011
    Location
    Norway
    Posts
    77

    Default Re: howto change default permissions for new file created with dolphin

    So I tested this out, solely out of curiosity.

    Added this line to /etc/pam.d/login
    Code:
    session  optional       pam_umask.so umask=017
    Then changed the value of umask in /etc/login.defs
    Code:
    umask	017
    Rebooted, checked file permissions afterwards

    Code:
    umask -S
    u=rwx,g=rw,o=
    Seems to be granted the way OP wanted.

    Guessing this would be the way to globally change the default user permissions, the method shown in the post above would be user specific, which probably is what you're looking for.

    Going to change mine back to 022 now

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,862

    Default Re: howto change default permissions for new file created with dolphin

    Of course changing something in a system configuration (done by root and in this case within /etc) is system wide.
    Doing it in the profile of a user (can of course be done by the user) is user wide (that is not that "wide" at all ).

    It is not clear what the OP wants (he does not explicitly state he askes this as end-user (for his own security) or as system manager (as a system wide policy), but the fact that he talks about an end-user tool like Dolphin lets me think the first one is the case. Thus both answers may be valid and the OP has to chose one (or both).

    The system manager has also to be aware of the fact that a system wide policy can be overuled by the user in this case.

    (And of course, since allready more then 30 year the first thing after I got a new userid on any system was to add
    Code:
    umask 077
    to my profile).
    Henk van Velden

  6. #6

    Default Re: howto change default permissions for new file created with dolphin

    Many thanks for the replies! 4 years of running linux and still learning new stuff

  7. #7

    Default Re: howto change default permissions for new file created with dolphin

    Maybe I can teach you something as well. Looks like umask is deprecated in /etc/login.defs.
    New value is in /etc/default/useradd. Could it be that for a global change you only have to change the value in /etc/default/useradd and not change /etc/pam.d/login?

    I also wonder: if you both set a different umask in /etc and in your .profile, will it use the umask of the .profile?

  8. #8
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,862

    Default Re: howto change default permissions for new file created with dolphin

    As your .profile or .bashrc or the like files are excecuted at login, the statements there are executed. Thus when you have an umask statement there, it will be executed and thus when you get your first prompt after login that is the umask that is valid. You can of course at any moment change that by typing a different umask statement.

    Every time you give an umask statement the umask is changed (maybe to the same value it had). Thus it is easy to determine which one is valid: the last one.
    You should be aware of the fact that the umask commando is a built-in in the shell and uses the umask() function. (homework: why is it useles to have it as a separte program, I am willing to give the answer when you have realy thought about that). Also any other program can have a buit-in call to the umask() function and thus can overrule any umask you may have set.

    And because the umask itself is part of the process environment it will be inherited by all child processes. Thus when your umask is 057 and you start program a and then change your umask to 077 and then start program b, program a will use a different umask then program b when it comes to creating new files.

    Also because you have an umask immediatly after login (either some default or the one you put yourself in your .profile) in the GUI, all processes started in that session will inherit that umask, including your dolphin. That is why dolphin uses this umask when it creates a new file on your whish.


    Note that this also means that your original question (to change the umask of the dolphin processes you run as an end-user) is not realy answered as setting the wanted umask in your .profile means that it is valid for all the programs running in your session, not just dolphin. But as usual we do a lot of assumptions when answeriing questions and we assumed here that you wanted an umask for all programs in your sessions. Some even assumed that you wanted that umask for all programs, for all sessions, for all users (but you are now at the point where it is clear to you that the individual users can nullify this easily).
    Henk van Velden

  9. #9
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    24,862

    Default Re: howto change default permissions for new file created with dolphin

    And to break a long post into pieces..

    The values defined in places like /etc/default/useradd are used at the creation of a user. That means for the umask case, that the umask statement in .profiile is created with this value. When you change that value in /etc/default/useradd, it does of course not change the umask statements in the .profile of existing users. It is only for newly created users.

    Again I point to the fact that every user can of course change his .profile to his whish and thus change the umask he wants to use during his sessions. And that every user can type an umask statement or use it in his scripts at will. Thus the security officer that asks system managers to create users with a certain restrictive umask and then leans back thinking that he pluged a hole, may only do this when none of the users ever had a Unix/Linux course and is in general dumb.
    Henk van Velden

  10. #10

    Default Re: howto change default permissions for new file created with dolphin

    See here: SDB:Set UMASK - openSUSE

    The correct* way to do it system-wide is (as root): pam-config -a --umask --umask-umask=0027

    *correct as in I was told this by an opensuse developer when I filed a bug report about the setting in /etc/login.defs not working (it has indeed been deprecated).

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •