2009/1/16 Nguyen Vu Hung <vuhung16plus at gmail.com>:
> 2009/1/16 Jean Christophe Andr? <jean-christophe.andre at auf.org>:
>> Nguyen Vu Hung a ?crit :
>>> V? sao permission m?c ??nh c?a user vuhung v?n l? 700 m? kh?ng ph?i
>>> l? 755 nh? ?? ch?nh ??nh trong /etc/adduser.conf?
>>>
>> C? l? b?i v? B?n ?? c? m?t umask ??c bi?t cho root ?
>> Hay ki?m tra v?i l?nh "umask"...
>>
>>> adduser c? ??c file /etc/adduser.conf hay kh?ng?
>>>
>> ?? bi?t chinh x?c ?i?u ?? th? d?ng c?c l?nh n?y :
>> strace -ff -o /tmp/adduser.strace adduser vuhung
>> grep open /tmp/adduser.strace*
> I did check and found that adduser doesn't read /etc/adduser.conf
>
> The permission of $HOME is hard-coded in:
> shadow-utils/src/useradd.c:function create_home()
>
I was wrong.
useradd uses its own UMASK setting which is
read from the configuration file /etc/login.defs.
"man 8 useradd" does refer to this file but I does not write
anything about UMASK setting neither in "man useradd" or login.defs
By adding a line "UMASK 0022" to the end of /etc/login.defs,
I get my problem fixed.
FYI,
lib/getdef.c
/*
* getdef_num - get numerical value from table of definitions
*
* Returns numeric value of specified item, else the "dflt" value if
* the item is not defined. Octal (leading "0") and hex (leading "0x")
* values are handled.
*/
int getdef_num (const char *item, int dflt)
{
struct itemdef *d;
if (!def_loaded)
def_load ();
if ((d = def_find (item)) == NULL || d->value == NULL)
return dflt;
return (int) strtol (d->value, (char **) NULL, 0);
}
lib/getdef.h
/* default UMASK value if not specified in /etc/login.defs */
#define GETDEF_DEFAULT_UMASK 022
useradd.c:create_home():
chmod (user_home,
0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK));
--
Best Regards,
Nguyen Hung Vu [aka: NVH] ( in Vietnamese: Nguy?n V? H?ng )
vuhung16plus{[email protected] , YIM: vuhung16 , Skype: vuhung16dg
A brief profile: http://www.hn.is.uec.ac.jp/~vuhung/Nguyen.Vu.Hung.html