3 |
- |
1 |
#!/bin/sh -p
|
|
|
2 |
# It receives polydir path as $1, the instance path as $2,
|
|
|
3 |
# a flag whether the instance dir was newly created (0 - no, 1 - yes) in $3,
|
|
|
4 |
# and user name in $4.
|
|
|
5 |
#
|
|
|
6 |
# The following section will copy the contents of /etc/skel if this is a
|
|
|
7 |
# newly created home directory.
|
|
|
8 |
if [ "$3" = 1 ]; then
|
|
|
9 |
# This line will fix the labeling on all newly created directories
|
|
|
10 |
[ -x /sbin/restorecon ] && /sbin/restorecon "$1"
|
|
|
11 |
user="$4"
|
|
|
12 |
passwd=$(getent passwd "$user")
|
|
|
13 |
homedir=$(echo "$passwd" | cut -f6 -d":")
|
|
|
14 |
if [ "$1" = "$homedir" ]; then
|
|
|
15 |
gid=$(echo "$passwd" | cut -f4 -d":")
|
|
|
16 |
cp -rT /etc/skel "$homedir"
|
|
|
17 |
chown -R "$user":"$gid" "$homedir"
|
|
|
18 |
mask=$(awk '/^UMASK/{gsub("#.*$", "", $2); print $2; exit}' /etc/login.defs)
|
|
|
19 |
mode=$(printf "%o" $((0777 & ~$mask)))
|
|
|
20 |
chmod ${mode:-700} "$homedir"
|
|
|
21 |
[ -x /sbin/restorecon ] && /sbin/restorecon -R "$homedir"
|
|
|
22 |
fi
|
|
|
23 |
fi
|
|
|
24 |
|
|
|
25 |
exit 0
|