You are not logged in.

#1 2022-08-01 21:12:09

difri84
Member
Registered: 2021-12-09
Posts: 78

umask for DE apps [SOLVED]

i've spent the last 2 hours searching how to change the umask of a user and all the solutions i found were about shell only

i would like to change my user umask in a way that makes no difference if i create a file using a terminal or using nemo.
how do i do that?

i use lightdm + cinnamon

thanks!

Last edited by difri84 (2022-08-02 01:00:16)

Offline

#2 2022-08-01 21:45:22

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

https://wiki.archlinux.org/title/Umask# … mask_value
If you only want to change the umask for that one user, try ~/.profile - cinnamon is still a "shell", it just won't read your bashrc as it's not bash.

Online

#3 2022-08-02 00:59:53

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: umask for DE apps [SOLVED]

it worked
one line in .profile for cinnamon
one line .bashrc for the terminal
thank you!

Offline

#4 2022-08-02 05:21:51

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

bash is supposed to source ~/.profile and "terminal" as in "VTE in a graphical session" would also inherit the parenting umask - you should™ be able to skip the ~/.bashrc entry.

Online

#5 2022-08-02 11:10:46

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: umask for DE apps [SOLVED]

I copied the manjaro bashrc file, mainly because the color management. I don't understand it 100% it's a very long file.

It has a lot of if inside it, one if checks about interactive (don't really know what does it mean) and there are a lot of if about colors.

I copied the same file in /root too

I have a blue user@hostname with my user
And a red user@hostname if I'm root.

I really like it, however this only works with su, if I use su -  I have no colors.

The file profile didn't exist I created it just for the purpose of the umask

Anyway without the bashrc entry I get the umask change only into the graphic session

(I skipped all the dots in the post because my phone keeps correcting them)

Last edited by difri84 (2022-08-02 11:14:09)

Offline

#6 2022-08-02 11:50:54

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

I copied the manjaro bashrc file […] I don't understand it 100%

Do you seriously want a comment on that?

I have a blue user@hostname with my user
And a red user@hostname if I'm root.

If you only care about the PS1, see https://wiki.archlinux.org/title/Bash/P … tomization

"su -" is "su --login" and that will open a login shell which won't run your bashrc because

man bash wrote:

       When  bash  is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first
       reads and executes commands from the file /etc/profile, if that file exists.  After reading that file, it  looks  for
       ~/.bash_profile,  ~/.bash_login,  and  ~/.profile,  in that order, and reads and executes commands from the first one
       that exists and is readable.  The --noprofile option may be used when the shell is started to inhibit this behavior.

       When an interactive login shell exits, or a non-interactive login shell executes the exit builtin command, bash reads
       and executes commands from the file ~/.bash_logout, if it exists.

       When  an  interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if
       that file exists.  This may be inhibited by using the --norc option.  The --rcfile file option  will  force  bash  to
       read and execute commands from file instead of ~/.bashrc.

People feel tempted to therefore source bashrc from bash_profile but I'd advise against that because you can "break" the shell by screwing around in the config and this is more prone to happen in the elaborate bashrc - so having a "clean" login profile maybe isn't as fancy, but a nice failsafe.

Online

#7 2022-08-02 12:40:33

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: umask for DE apps [SOLVED]

yeah i know using the manjaro .bashrc feels a little like cheating but on my defense i only use arch since 6 montsh and there's so much i still don't know, i've read the file several times and i dont't think it's doing anything bad, just a lot of "if" checks about PS1 color, dircolors and --color flag of aliases.

i think it's ok to use and customize code already written by others. Isn't it what we already do for every package we install? I don't think there's anyone out there who knows and understand the source code of every single package installed on the system.

i understand manjaro is the most hated arch-based distro in this community but come on it's just about colors big_smile

anyway i did try to comment out the umask line in .bashrc and my terminal doesn't inherit the umask i set in .profile

seth wrote:

bash is supposed to source ~/.profile and "terminal" as in "VTE in a graphical session" would also inherit the parenting umask - you should™ be able to skip the ~/.bashrc entry.

i checked in /etc/skel nor .bashrc nor .bash_profile source .profile

Last edited by difri84 (2022-08-02 13:11:21)

Offline

#8 2022-08-02 13:29:13

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

i understand manjaro is the most hated arch-based distro in this community

No and the problem isn't hat you copied it from manjaro but that you admittedly don't understand what you copied there.

anyway i did try to comment out the umask line in .bashrc and my terminal doesn't inherit the umask i set in .profile

Since ~/.profile isn't interpreted by non-login interactive shells, you'll have to re-login to test this (ie. it's NOT sufficient to change the value in ~/.profile, start a new terminal and see whether the change got picked up)
You can check "bash --login" but that'll explicitly read ~/.profile.

Online

#9 2022-08-02 14:19:11

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: umask for DE apps [SOLVED]

No and the problem isn't hat you copied it from manjaro but that you admittedly don't understand what you copied there.

i understand mostly, anyway i think you use a lot of software whitout fully understand the source code too so i really don't undestand why you consider this a problem.

anyway back to the subject i rebooted the machine everytime i changed something to be asbsolutely sure it was a persistent change and as i said, setting umask only in .profile doens't affect terminal

Offline

#10 2022-08-02 14:35:31

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

i understand

No you don't.

i think you use a lot of software whitout fully understand the source code too

1. debatable
2. Syllogistic fallacy. Not understandig the assembler code in a video decoder isn't the same as executing random shell commands w/o understanding what they do. One might not be versed in assembler, but still understand that the code decodes a video.

setting umask only in .profile doens't affect terminal

Yes it does. Something alters the value before or when you start the shell.
Try

bash -x &| grep umask
strace bash 2>&1 | grep -i umask

Both commands should™ not print anything and at some point just hang, you can ctrl+c them after a few seconds.
If they do print something, then something sets the umask what is not supposed to happen.
If it doesn't print anything but the umask is still wrong, try a different terminal emulator.

Online

#11 2022-08-02 14:54:21

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: umask for DE apps [SOLVED]

i dont know how can you determine in what % i do understand that code, plus it's not random. I guess with the same logic every software on github is random code you shouldn't execute on your machine if you dont study first everyline of the code.
there's another way to be safe, the fact that it would be extremely rare for a bad open source code to not be noticed by anyone especially if it's very popular like the default config of a very popular distro.

I'll use an example out of computer to make this more understandable.
you probably use medicine without understanding the chemestry behind it
you probably use a car without fully understand the mechanic and the electronic behind it
you probably eat food without analyzing yourself what chemicals are inside, just trusting the label
what i did is not different.

i don't want to debate about what is right and what is wrong, i just see an illogic argument in what you say
you say i should know the code i run, should i know the kernel code too?
should i know the systemd code too?
should i know the code of every root access application?

i just know that nohing really bad can happen by code with non root access, so even if i dont understand 100% i dont see the problem

if you argument is only about shell code you should explain why is important to know only shell code and be careless about every other type of code.

i don't really want to argue about this, i just dont' like people criticism without a crystal clear explanation and a logic argumentation

the first line of your code gives this

bash: syntax error near unexpected token `|'
++ echo -ne '\033]0;dario@dario-fisso:~\007'

the second line gives this

+ grep --colour=auto -i umask
+ strace bash
++ echo -ne '\033]0;dario@dario-fisso:~\007'

Last edited by difri84 (2022-08-02 15:30:44)

Offline

#12 2022-08-02 15:28:44

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

bash -x 2>&1 | grep umask

("&|" is unfortunately a zshism, sorry) but since the strace is empty, I don't expect there to be a umask call either.
=> Try a different terminal emulator.
The umask cannot be not inherited from a parenting process, because then it would be completely useless (since most relevant processes are not shells) and also the (only) value in /etc/profile that's set by default would be irrelevant.


-----

i dont know how can you determine in what % i do understand that code

No, you don't understand the fundamental problem.
There's a difference in not knowing how something works and not knowing what something does.
You're playing bash roulette and if you don't or don't want to understand that, that's your problem.

Online

#13 2022-08-02 15:38:22

difri84
Member
Registered: 2021-12-09
Posts: 78

Re: umask for DE apps [SOLVED]

No, you don't understand the fundamental problem.
There's a difference in not knowing how something works and not knowing what something does.
You're playing bash roulette and if you don't or don't want to understand that, that's your problem.

it just makes sure that the shell support color output before setting colors. and it has different settings for PS1, aliases and dircolors depending on this conditions. I know what it does, i'm not playing "bash roulette" dont worry.

anyway i tried both alacritty and xfce4-terminal and they behave like you said they should. i've read gnome-terminal takes the umask from systemd --user (not sure i'm right) anyway i will just use the .bashrc line

tank you for all the time you took to help me smile

Last edited by difri84 (2022-08-02 16:43:38)

Offline

#14 2022-08-03 14:32:13

seth
Member
Registered: 2012-09-03
Posts: 50,015

Re: umask for DE apps [SOLVED]

Thanks for the confirmation.

According to https://bugzilla.gnome.org/show_bug.cgi?id=780622 it should™ adhere to pam_umask (and by inference /etc/login.defs)
You could try to add

session optional pam_umask.so umask=0022

to /etc/pam.d/system-login (at the very end, pick your desired umask)

WARNING: always keep a root shell open when messing with pam!!
========================================================
Try to eg. "sudo -i" after you edited the file and to ensure pam still works!
The smallest error there can lock you out of the system!

We might need a comment about that in the wiki (god, I hate gnome soooooo much…)

Online

Board footer

Powered by FluxBB