diff options
author | Renato Botelho <renato@netgate.com> | 2016-05-31 09:10:54 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-05-31 09:10:54 -0300 |
commit | 13a70e7d4eef151b80dcdc2567486209a6bd5312 (patch) | |
tree | cc58d866d904ac279b2d8fe1881acb78d4067a80 /src | |
parent | 3ee1e659a65f465879b3651f0bf6041ef25f0227 (diff) | |
download | pfsense-13a70e7d4eef151b80dcdc2567486209a6bd5312.zip pfsense-13a70e7d4eef151b80dcdc2567486209a6bd5312.tar.gz |
Copy users config files from skeleton dir
Every time user is added or modified, make sure all default config
files are copied over from /etc/skel to user's home. It will make sure
users will always get the last version of these files
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/inc/auth.inc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/etc/inc/auth.inc b/src/etc/inc/auth.inc index 5731c84..48d9c2e 100644 --- a/src/etc/inc/auth.inc +++ b/src/etc/inc/auth.inc @@ -548,9 +548,11 @@ function local_user_set(& $user) { pclose($fd); $userattrs = explode(":", trim($pwread)); + $skel_dir = '/etc/skel'; + /* determine add or mod */ if (($userattrs[0] != $user['name']) || (!strncmp($pwread, "pw:", 3))) { - $user_op = "useradd -m -k /etc/skel -o"; + $user_op = "useradd -m -k {$skel_dir} -o"; } else { $user_op = "usermod"; } @@ -579,6 +581,14 @@ function local_user_set(& $user) { @chown($user_home, $user_name); @chgrp($user_home, $user_group); + /* Make sure all users have last version of config files */ + foreach (glob("{$skel_dir}/dot.*") as $dot_file) { + $target = $user_home . '/' . substr(basename($dot_file), 3); + @copy($dot_file, $target); + @chown($target, $user_name); + @chgrp($target, $user_group); + } + /* write out ssh authorized key file */ if ($user['authorizedkeys']) { if (!is_dir("{$user_home}/.ssh")) { |