Solved ~/.login_conf ignored at login

I'm trying to change my user's default umask. To accomplish this, I've modified the .login_conf file in the user's home directory. The contents of .login_conf are:

Code:
# $FreeBSD: release/9.0.0/share/skel/dot.login_conf 77995 2001-06-10 17:08:53Z ache $
#
# see login.conf(5)
#

me:\
        :umask=027:

When I log out and back in, my umask level remains the default -- 022. The .login_conf file itself is not a symlink, and has permissions 544. Why is my .login_conf being ignored?

Thanks,
Andrew
 
See login.conf(5):

Code:
     The default /etc/login.conf shipped with FreeBSD is an out of the box
     configuration.  [b]Whenever changes to this, or the user's ~/.login_conf,
     file are made, the modifications will not be picked up until cap_mkdb(1)
     is used to compile the file into a database.[/b]  This database file will
     have a .db extension and is accessed through cgetent(3).  See getcap(3)
     for a more in-depth description of the format of a capability database.
 
Whenever changes to this, or the user's ~/.login_conf, file are made, the modifications will not be picked up until [man=]cap_mkdb[/man] is used to compile the file into a database.

I've run cap_mkdb on the file via:

[cmd=]cap_mkdb ~/.login_conf[/cmd]

Which resulted in a ~/.login_conf.db being created. The umask is still not being set correctly upon login.
 
I'm used to set umask in shell's $PROFILE; I did try to set it in ~/.login_conf for the sake of a test.

I got nothing - same as you. But when I set some other parameters (like lang) - those work. Man page does say only some of the parameters are able to be set this way; it might be that umask can't be set here. Try to set it in user's profile instead.
 
I've also tried modifying /etc/login.conf to contain:

Code:
private_users:\
        :umask=027:\
        :tc=default:

Then using chpasswd to modify my user's login class to "private_users". I performed the necessary cap_mkdb on /etc/login.conf, and did a full reboot. After logging in, my umask still hasn't changed.
 
agottem said:
I've also tried modifying /etc/login.conf to contain:

Code:
private_users:\
        :umask=027:\
        :tc=default:

I think your umask is getting overwritten in "tc" section. Try to swap those parameters, e.g.:

Code:
private_users:\
        :tc=default:\
        :umask=027:
No reboot is necessary, only cap_mkdb execution.
 
Almost forgot - chpasswd is not a FreeBSD command (chpass is, but NOTE: Class is something different there .. it's "classification"); you can use pw command to change login class:

# pw user mod <USERNAME> -L private_users
 
I gave all your commands a go and still couldn't get it to work. As a sanity check, I took a look at the default ~/.cshrc that was created by FreeBSD when I set up the user and found the following line:

Code:
# A righteous umask
umask 22

Deleting that line made the proper umask show up. Sorry to waste everyone's time with this, and thanks for sticking around to help!


If you're interested, the precedence of the login.conf file with respect to "tc":

Code:
    tc                string                A "continuation" entry, which
                                             must be the last capability pro-
                                             vided.  More capabilities are
                                             read from the named entry.  The
                                             capabilities given before tc
                                             override those in the entry
                                             invoked by tc.
 
This thread is old, but I seek help on a related problem, and for the sake of information I think some of the replies also need correction.

See login.conf(5):
Code:
     The default /etc/login.conf shipped with FreeBSD is an out of the box
     configuration.  [b]Whenever changes to this, or the user's ~/.login_conf,
     file are made, the modifications will not be picked up until cap_mkdb(1)
     is used to compile the file into a database.[/b]

This is not so, at least not for the user's ~/.login_conf (never tested if this is true for /etc/login.conf). If ~/.login_conf.db exists, then it is used, otherwise ~/.login_conf is read directly.
Personally, I find this much more convenient and I think that indexing such a usually small file is overkill anyway.

I've also tried modifying /etc/login.conf to contain:

Code:
private_users:\
        :umask=027:\
        :tc=default:

Actually, the entry which you must use in ~/.login_conf is "me". See for instance chapter 23 (Localization) section 2 of the FreeBSD handbook for an example. Confirm /usr/src/lib/libutil/login_cap.c, the user's capability database is only looked for when searching for class "me".

Finally, the "tc" entry is not relevant for the user's ~/.login_conf. The system login capabilities database is always used.

Now, my specific problem is that ~/.login_conf is being ignored for root. I have been using it for years! Or am I crazy and it never worked for root? In my version control system, I have it since 2007 for root, for the hushlogin feature.
 
I just find out why my root's ~/.login_conf was being ignored! The problem was a backslash as the last character of a commented line before the "me" entry. I had kept in a comment a line which was previously part of the entry. Like this:
Code:
# My .login_conf...
#   :setenv=ABC=1,EDITOR=vi,BCD=cde:\
me:\
    :hushlogin:\
    :setenv=CDE=2,DEF=efg:\
    :umask=022:
Problem solved!
 
Back
Top