summaryrefslogtreecommitdiff
path: root/user-init
blob: e47ae81bd48b68e76450b2346539c75d29f2a877 (plain)
  1. #!/bin/sh
  2. set -e
  3. # reset flags
  4. apache_reload_needed=""
  5. runmode="normal"
  6. # subfolder name defaults (edit /etc/local/users.conf to override)
  7. mac="mac" # Optimized for sharing through AppleShare (netatalk)
  8. pc="pc" # Optimized for sharing though SMB/CIFS (Samba)
  9. xchange="xchange" # Readable by group
  10. # config (edit /etc/local/users.conf to override)
  11. # which are user accounts (adduser values are used if empty)
  12. first_uid=""
  13. last_uid=""
  14. do_quota="no" # Manage disk quota
  15. do_distrib="no" # Distributed shares (software archive)
  16. do_personal="no" # Personal shares (mac, pc, public_html)
  17. do_xchange="no" # Group-readable shares
  18. do_public="no" # Public share (web homepage)
  19. do_mac="no" # AppleShare-optimized share (netatalk)
  20. do_pc="no" # SMB-ptimized share (Samba)
  21. do_server="no" # Personal share on remote SMB server
  22. quota_roots="" # space-delimited list of disk devices
  23. quota_soft="100000"
  24. quota_hard="1000000"
  25. quota_newstyle="yes" # Woody used a different syntax...
  26. xchange_root="xchange"
  27. xchange_sharedroot="/home/XCHANGE"
  28. mac_root="mac"
  29. pc_root="pc"
  30. server_name="SERVER" # SMB name of remote server
  31. server_desc="remote server"
  32. server_root="server"
  33. server_conf="/etc/security/pam_mount.conf"
  34. server_userconf=".winpassword"
  35. QUOTASOFT="0"
  36. QUOTAHARD="0"
  37. # Relax permissions
  38. # Currently allows group write access to root of mac shares
  39. RELAXEDPERMS=''
  40. ### No servicable parts below this line! ###
  41. if [ -e /etc/adduser.conf ]; then
  42. . /etc/adduser.conf
  43. else
  44. echo "/etc/adduser.conf missing. Exiting..."
  45. exit 1
  46. fi
  47. [ -r /etc/local/users.conf ] && . /etc/local/users.conf
  48. #TODO: Add conversion like below, and change remaining script to new variable names
  49. #[ -n "$XDIR" ] && xchange_sharedroot="$XDIR"
  50. # exit silently if this system lacks required hints
  51. [ -r /etc/local/volumes ] && . /etc/local/volumes || exit 0
  52. XDIRREAL="$XDIR/users/root"
  53. if [ -n "$XCHANGE" ]; then
  54. if [ ! -d "$XDIR" ]; then
  55. echo "XDIR doesn't exist. Ignoring XCHANGE!"
  56. XCHANGE=""
  57. fi
  58. fi
  59. if [ $# -gt 0 ]; then
  60. USERS=$*
  61. else
  62. # USERS=`getent passwd | awk -F: '{print $1}'`
  63. echo "uid required!"
  64. exit 1
  65. fi
  66. [ -n "$NETATALK_HOME" ] && mac="$NETATALK_HOME"
  67. [ -n "$SAMBA_HOME" ] && pc="$SAMBA_HOME"
  68. [ -n "$XCHANGE_HOME" ] && xchange="$XCHANGE_HOME"
  69. echo "Setting up additional folders and permissions..."
  70. for user in $USERS; do
  71. uid="`getent passwd \"$user\" | awk -F: '{print $3}' | head -n 1`"
  72. HOME="`getent passwd \"$user\" | awk -F: '{print $6}' | head -n 1`"
  73. groups="`groups \"$user\"`"
  74. if [ -z "$HOME" ]; then
  75. echo "User $user doesn't exist. Ignoring..."
  76. continue
  77. fi
  78. # Ignore non-human accounts silently
  79. [ "$uid" -ge "$FIRST_UID" -a "$uid" -le "$LAST_UID" ] || continue
  80. [ -d "$HOME" ] || continue
  81. # [ -L "$HOME" ] && continue
  82. echo -n "$user"
  83. # if [ -x /etc/local/quota.sh ]; then
  84. # /etc/local/quota.sh "$user"
  85. # fi
  86. quotasoft="$QUOTASOFT"
  87. quotahard="$QUOTAHARD"
  88. for quotaoverride in $QUOTAOVERRIDES; do
  89. for group in $groups; do
  90. if [ "$quotaoverride" = "$group" ]; then
  91. eval quotasoft=\"\$QUOTASOFT_${quotaoverride}\"
  92. eval quotahard=\"\$QUOTAHARD_${quotaoverride}\"
  93. continue
  94. fi
  95. done
  96. done
  97. for quotahome in $QUOTAHOMES; do
  98. if [ -n "$NEW_QUOTA" ]; then
  99. setquota "$user" "$quotasoft" "$quotahard" 0 0 "$quotahome"
  100. else
  101. setquota "$user" "$quotahome" "$quotasoft" "$quotahard" 0 0
  102. fi
  103. done
  104. if [ -n "$NETATALK" ]; then
  105. mkdir -p "$HOME/$mac"
  106. fi
  107. if [ -n "$SAMBA" ]; then
  108. mkdir -p "$HOME/$pc"
  109. fi
  110. if [ -n "$XCHANGE" ]; then
  111. mkdir -p "$XDIRREAL/$user"
  112. fi
  113. if [ -n "$PUBLIC" ]; then
  114. mkdir -p "$HOME/public_html"
  115. fi
  116. #TODO: Enable this only when option implemented to do it non-interactively
  117. # echo # dirty hack: better if being able to lower verbosity of localuserconfig
  118. # su -s /bin/bash -c localuserconfig "$user"
  119. if [ "$do_server" = "yes" ] && [ -r "$server_conf" ] && [ -f "$HOME/$server_userconf" ]; then
  120. server_username="$(grep '^username' \"$HOME/$server_userconf\" | awk -F= '{print $2}' | head -n 1 | awk '{print $1}')"
  121. if [ -n "$server_username" ]; then
  122. if grep -q "^volume $user " "$server_conf"; then
  123. perl -pi -e "s|^volume $user .*|volume $user smb $server_name $server_username $HOME/$server_root uid=$user,gid=$user - -|" "$server_conf"
  124. else
  125. echo "volume $user smb $server_name $server_username $HOME/$server_root uid=$user,gid=$user - -" >> "$server_conf"
  126. fi
  127. fi
  128. fi
  129. chown "$user": "$HOME"
  130. chmod u=rwX,go=rX "$HOME"
  131. # Mail handling
  132. maildir="$MAILDIR"
  133. if [ -f "$HOME/.procmailrc" ]; then
  134. # Drop simple maildir-enabling procmail file when default
  135. if [ -n "$MAILDIR" ] && [ "`md5sum \"$HOME/.procmailrc\" | awk '{print $1}'`" = "03ea802caaa5ce6f2a9be8d56eaf8ff5" ]; then
  136. rm "$HOME/.procmailrc"
  137. else
  138. chown "$user": "$HOME/.procmailrc"
  139. chmod 0640 "$HOME/.procmailrc"
  140. # Check if this one account exceptionally uses maildir
  141. if [ -z "$maildir" ] && egrep -q '^DEFAULT=\$HOME/Maildir/$' "$HOME/.procmailrc"; then
  142. maildir="yes"
  143. fi
  144. fi
  145. fi
  146. if [ -n "$maildir" ]; then
  147. mkdir -p "$HOME/Maildir/cur" "$HOME/Maildir/new" "$HOME/Maildir/tmp"
  148. chown -R "$user": "$HOME/Maildir"
  149. chmod -R u=rw,go=,u+X "$HOME/Maildir"
  150. else
  151. mkdir -p "$HOME/mail"
  152. if [ -n "$USE_MBOX" ]; then
  153. touch "$HOME/mail/mbox"
  154. elif [ -f "$HOME/mail/mbox" ] && [ ! -s "$HOME/mail/mbox" ]; then
  155. rm -f "$HOME/mail/mbox"
  156. fi
  157. chown -R "$user": "$HOME/mail"
  158. chmod -R u=rw,go=,u+X "$HOME/mail"
  159. if [ -f "$HOME/.mailboxlist" ]; then
  160. chown "$user": "$HOME/.mailboxlist"
  161. chmod 0640 "$HOME/.mailboxlist"
  162. fi
  163. fi
  164. mailspool="/var/spool/mail"
  165. if [ -d "/var/mail" ]; then
  166. mailspool="/var/mail"
  167. fi
  168. if [ -f "$mailspool/$user" ]; then
  169. if [ -n "$maildir" ] && [ ! -s "$mailspool/$user" ]; then
  170. rm "$mailspool/$user"
  171. else
  172. chown "$user":mail "$mailspool/$user"
  173. chmod ug=rw,o= "$mailspool/$user"
  174. fi
  175. fi
  176. if [ -f "$HOME/.forward" ]; then
  177. chown "$user": "$HOME/.forward"
  178. chmod 0640 "$HOME/.forward"
  179. fi
  180. # MySQL handling
  181. if [ -f "$HOME/.my.cnf" ]; then
  182. chown "$user": "$HOME/.my.cnf"
  183. chmod 0600 "$HOME/.my.cnf"
  184. fi
  185. # Mac dir permissions
  186. if [ -d "$HOME/$mac" ]; then
  187. chown -R "$user": "$HOME/$mac"
  188. chmod -R u=rw,g=r,o=,ug+X "$HOME/$mac"
  189. rm -rf "$HOME/$mac/Network Trash Folder"
  190. mkdir "$HOME/$mac/Network Trash Folder"
  191. chown nobody: "$HOME/$mac/Network Trash Folder"
  192. chmod a= "$HOME/$mac/Network Trash Folder"
  193. fi
  194. # PC dir permissions
  195. if [ -d "$HOME/$pc" ]; then
  196. chown -R "$user": "$HOME/$pc"
  197. chmod -R u=rw,g=r,o=,ug+X "$HOME/$pc"
  198. fi
  199. #FIXME: something is wrong with prefixing "x" here...
  200. # Exchange dir permissions
  201. if [ -d "$XDIRREAL/$user" ]; then
  202. chown -R "$user":users "$XDIRREAL/$user"
  203. chmod -R g=r,g+X "$XDIRREAL/$user"
  204. if [ -e "x$HOME/$xchange" ]; then
  205. if [ -L "x$HOME/$xchange" ]; then
  206. ln -sf "$XDIRREAL/$user $HOME/$xchange"
  207. else
  208. echo "ERROR: \"$HOME/$xchange\" exists already. Leaving it as is..."
  209. fi
  210. else
  211. ln -s "$XDIRREAL/$user" "$HOME/$xchange"
  212. fi
  213. fi
  214. # Public dir permissions
  215. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./public\(_.*\)?'`; do
  216. chown -R "$user": "$HOME/$dir"
  217. chmod -R u+rX,go=r,go+X "$HOME/$dir"
  218. if [ -n "$NETATALK" ]; then
  219. rm -rf "$HOME/$dir/Network Trash Folder"
  220. mkdir "$HOME/$dir/Network Trash Folder"
  221. chown nobody: "$HOME/$dir/Network Trash Folder"
  222. chmod a= "$HOME/$dir/Network Trash Folder"
  223. fi
  224. done
  225. # Shared dirs are writable by own primary group
  226. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./shared\(_.*\)?'`; do
  227. chgrp -R "$user" "$HOME/$dir"
  228. chmod -R ug=rw,o=,ug+X,g+s "$HOME/$dir"
  229. if [ -n "$NETATALK" ]; then
  230. rm -rf "$HOME/$dir/Network Trash Folder"
  231. mkdir "$HOME/$dir/Network Trash Folder"
  232. chown nobody: "$HOME/$dir/Network Trash Folder"
  233. chmod a= "$HOME/$dir/Network Trash Folder"
  234. fi
  235. done
  236. # Private dirs are readable by own primary group
  237. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./private\(_.*\)?$'`; do
  238. chown -R "$user": "$HOME/$dir"
  239. chmod -R u+rX,g=r,g+X,o= "$HOME/$dir"
  240. done
  241. # Secret dirs are accessible only by self
  242. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./secret\(_.*\)?$'`; do
  243. chown -R "$user": "$HOME/$dir"
  244. chmod -R u+rX,go= "$HOME/$dir"
  245. done
  246. # Fileshares: <home>/shares.<sharetype>/<rogroup>/<rwgroup>/<sharename>
  247. # <sharetype>: Either mac or win depending on which of netatalk and samba provides r/w access to the shares
  248. # <rwgroup>: Group with write access to the share (usually the default group of the owner)
  249. # <rogroup>: Either rwgroup or secondary group with read-only access to the share
  250. # owner and rwgroup members must be member of both groups
  251. #FIXME: Use the below instead, and replace occurrences of "$thisdir" with "$HOME/$dir".
  252. #for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./shares\..*'`; do
  253. find "$HOME" -mindepth 1 -maxdepth 1 -type d -print | egrep "^$HOME/shares\." | (while read thisdir; do
  254. sharetype="`basename \"$thisdir\" | awk -F. '{print $2}'`"
  255. # Define dir and file exceptions
  256. case "$sharetype" in
  257. mac)
  258. dirs_world_rw_create='.AppleDB'
  259. dirs_group_rw_create='.AppleDesktop/Temporary Items/TheFindByContentFolder'
  260. dirs_group_ro_create='TheVolumeSettingsFolder'
  261. if [ -n "$RELAXEDPERMS" ]; then
  262. dirs_group_rw_update='.AppleDouble'
  263. else
  264. dirs_group_ro_update='.AppleDouble'
  265. fi
  266. dirs_group_ro_update='.AppleDouble'
  267. files_group_ro_update=':2eDS_Store'
  268. dirs_no_access_purge='Network Trash Folder'
  269. ;;
  270. win)
  271. ;;
  272. *)
  273. continue
  274. ;;
  275. esac
  276. exceptions="$dirs_world_rw_create/$dirs_group_rw_create/$dirs_group_ro_create/$dirs_group_rw_update/$dirs_group_ro_update/$files_group_ro_update/$dirs_no_access_purge"
  277. exception_dirs_create="$dirs_world_rw_create/$dirs_group_rw_create/$dirs_group_ro_create"
  278. # <home>/shares.<sharetype>
  279. chown "$user": "$thisdir"
  280. chmod a=rX "$thisdir"
  281. find "$thisdir" -mindepth 1 -maxdepth 1 -type d -print | (while read thisdir; do
  282. # <home>/shares.<sharetype>/<rogroup>
  283. rogroup="`basename \"$thisdir\"`"
  284. chown "$user":"$rogroup" "$thisdir"
  285. chmod ug=rX,o= "$thisdir"
  286. find "$thisdir" -mindepth 1 -maxdepth 1 -type d -print | (while read thisdir; do
  287. # <home>/shares.<sharetype>/<rogroup>/<rwgroup>
  288. rwgroup="`basename \"$thisdir\"`"
  289. chown "$user":"$rwgroup" "$thisdir"
  290. chmod a=rX,g+s "$thisdir"
  291. find "$thisdir" -mindepth 1 -maxdepth 1 -type d -print | (while read thisdir; do
  292. # <home>/shares.<sharetype>/<rogroup>/<rwgroup>/<sharename>
  293. sharename="`basename \"$thisdir\"`"
  294. chown "$user":"$rwgroup" "$thisdir"
  295. if [ -n "$RELAXEDPERMS" ]; then
  296. chmod ug=rw,o=r,a+X,g+s "$thisdir"
  297. else
  298. chmod u=rw,go=r,a+X,g+s "$thisdir"
  299. fi
  300. ifs="$IFS"
  301. # Set default permissions
  302. find "$thisdir" -mindepth 1 -maxdepth 1 -print | (while read thisitem; do
  303. # <home>/shares.<sharetype>/<rogroup>/<rwgroup>/<sharename>/*
  304. thisparentdir="`basename \"$thisitem\"`"
  305. IFS="/"; for exception in $exceptions; do IFS="$ifs";
  306. if [ "$thisparentdir" = "$exception" ]; then
  307. continue 2
  308. fi
  309. done
  310. chgrp -R "$rwgroup" "$thisitem"
  311. chmod -R ug=rw,o=r,a+X,g+s "$thisitem"
  312. done)
  313. # Handle exception dirs to be created if not existing
  314. IFS="/"; for dir in $exception_dirs_create; do IFS="$ifs";
  315. if [ ! -d "$thisdir/$dir" ]; then
  316. rm -f "$thisdir/$dir"
  317. fi
  318. if [ ! -e "$thisdir/$dir" ]; then
  319. mkdir "$thisdir/$dir"
  320. fi
  321. chown "$user":"$rwgroup" "$thisdir/$dir"
  322. done
  323. IFS="/"; for dir in $dirs_world_rw_create; do IFS="$ifs";
  324. if [ "$rogroup" = "$rwgroup" ]; then
  325. chmod -R ug=rw,o=r,a+X,g+s "$thisdir/$dir"
  326. else
  327. chmod -R a=rw,a+X,g+s "$thisdir/$dir"
  328. fi
  329. done
  330. IFS="/"; for dir in $dirs_group_rw_create; do IFS="$ifs";
  331. chmod -R ug=rw,o=r,a+X,g+s "$thisdir/$dir"
  332. done
  333. IFS="/"; for dir in $dirs_group_ro_create; do IFS="$ifs";
  334. chmod -R u=rw,go=r,a+X,g+s "$thisdir/$dir"
  335. done
  336. # Handle exception dirs to be updated if already there
  337. IFS="/"; for dir in $dirs_group_rw_update; do IFS="$ifs";
  338. if [ -e "$thisdir/$dir" ]; then
  339. chmod ug=rw,o=r,a+X,g+s "$thisdir/$dir"
  340. fi
  341. done
  342. IFS="/"; for dir in $dirs_group_ro_update; do IFS="$ifs";
  343. if [ -e "$thisdir/$dir" ]; then
  344. chmod u=rw,go=r,a+X,g+s "$thisdir/$dir"
  345. fi
  346. done
  347. # Handle exception files to be updated if already there
  348. IFS="/"; for file in $files_group_ro_update; do IFS="$ifs";
  349. if [ -e "$thisdir/$file" ]; then
  350. chmod u=rw,go=r,g+s "$thisdir/$file"
  351. fi
  352. done
  353. # Handle exception dirs to be purged and recreated
  354. IFS="/"; for dir in $dirs_no_access_purge; do IFS="$ifs";
  355. rm -rf "$thisdir/$dir"
  356. mkdir -m a= "$thisdir/$dir"
  357. chown nobody: "$thisdir/$dir"
  358. done
  359. IFS="$ifs"
  360. done)
  361. done)
  362. done)
  363. done)
  364. # Ftp shares permissions
  365. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex "^\./ftp_$user$"`; do
  366. chgrp -R "$user" "$HOME/$dir"
  367. chmod -R ug=rw,o=r,a+X,g+s "$HOME/$dir"
  368. rm -rf "$HOME/$dir/Network Trash Folder"
  369. mkdir "$HOME/$dir/Network Trash Folder"
  370. chown nobody: "$HOME/$dir/Network Trash Folder"
  371. chmod a= "$HOME/$dir/Network Trash Folder"
  372. done
  373. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex "^\./ftp_${user}_ro$"`; do
  374. chown -R "$user": "$HOME/$dir"
  375. chmod -R u=rw,go=r,a+X "$HOME/$dir"
  376. rm -rf "$HOME/$dir/Network Trash Folder"
  377. mkdir "$HOME/$dir/Network Trash Folder"
  378. chown nobody: "$HOME/$dir/Network Trash Folder"
  379. chmod a= "$HOME/$dir/Network Trash Folder"
  380. done
  381. # Web shares permissions
  382. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./web_.*'`; do
  383. chown -R "$user": "$HOME/$dir"
  384. # chmod -R u=rw,go=r,a+X $webdir
  385. #TODO: Only cgi scripts (.cgi and .pl) should be executable
  386. chmod -R u+rw,go+r,a+X "$HOME/$dir"
  387. # leftover from ancient times with another policy
  388. if [ $NETATALK ]; then
  389. rm -rf "$HOME/$dir/Network Trash Folder"
  390. fi
  391. done
  392. # Web shares permissions
  393. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./websites$'`; do
  394. chown root: "$HOME/$dir"
  395. chmod a=r,u+w,a+X "$HOME/$dir"
  396. done
  397. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./websites/.*'`; do
  398. chown -R "$user": "$HOME/$dir"
  399. # chmod -R u=rw,go=r,a+X $webdir
  400. #TODO: Only cgi scripts (.cgi and .pl) should be executable
  401. chmod -R u+rw,go+r,a+X "$HOME/$dir"
  402. # leftover from ancient times with another policy
  403. if [ $NETATALK ]; then
  404. rm -rf "$HOME/$dir/Network Trash Folder"
  405. fi
  406. done
  407. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webscripts$'`; do
  408. chown root: "$HOME/$dir"
  409. chmod a=r,u+w,a+X "$HOME/$dir"
  410. done
  411. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webscripts/.*'`; do
  412. chown -R $user: "$HOME/$dir"
  413. # chmod -R u=rw,go=r,a+X $webdir
  414. #TODO: Only cgi scripts (.cgi and .pl) should be executable
  415. chmod -R u+rw,go+r,a+X "$HOME/$dir"
  416. done
  417. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webdata$'`; do
  418. chown "$user": "$HOME/$dir"
  419. chmod a=r,u+w,a+X "$HOME/$dir"
  420. done
  421. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webdata/.*'`; do
  422. chown -R "$user": "$HOME/$dir"
  423. chmod -R u=rw,go=,u+X "$HOME/$dir"
  424. done
  425. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webshareddata$'`; do
  426. chown "$user": "$HOME/$dir"
  427. chmod a=r,u+w,a+X "$HOME/$dir"
  428. done
  429. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webshareddata/.*'`; do
  430. chown -R "$user:" "$HOME/$dir"
  431. chmod -R u=rw,go=r,a+X "$HOME/$dir"
  432. done
  433. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webphpsites$'`; do
  434. chown root: "$HOME/$dir"
  435. chmod u=rw,go=r,a+X "$HOME/$dir"
  436. done
  437. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webphpsites/.*'`; do
  438. chown -R "$user":www-data "$HOME/$dir"
  439. # chmod -R ug=rw,o=r,a+X $dir
  440. chmod -R ug=rw,o=,ug+X "$HOME/$dir"
  441. done
  442. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./webphpdata$'`; do
  443. chown root: "$HOME/$dir"
  444. chmod a=r,u+w,a+X "$HOME/$dir"
  445. done
  446. for dir in `cd "$HOME" && find . -mindepth 2 -maxdepth 2 -type d -regex '^\./webphpdata/.*'`; do
  447. chown -R "$user":www-data "$HOME/$dir"
  448. chmod -R ug=rw,o=,ug+X "$HOME/$dir"
  449. done
  450. for dir in `cd "$HOME" && find . -mindepth 1 -maxdepth 1 -type d -regex '^\./weblogs$'`; do
  451. chown -R "$user": "$HOME/$dir"
  452. chmod -R u=rw,g=r,o=,ug+X "$HOME/$dir"
  453. done
  454. # Dummy user restrictions
  455. if [ -n "$REALUSERS_GROUPNAME" -a -n "$DUMMYSHAREDIR" -a -n "$DUMMYSHAREOWNER" -a -n "$DUMMYSHARENAME" ]; then
  456. [ -e $DUMMYSHAREDIR/$user ] \
  457. || mkdir $DUMMYSHAREDIR/$user
  458. chown $DUMMYSHAREOWNER: $DUMMYSHAREDIR/$user
  459. chmod u=rw,go=r,a+X $DUMMYSHAREDIR/$user
  460. if [ -e $HOME/$DUMMYSHARENAME ]; then
  461. if [ -L $HOME/$DUMMYSHARENAME ]; then
  462. ln -sf $DUMMYSHAREDIR/$user $HOME/$DUMMYSHARENAME
  463. chown $user: $HOME/$DUMMYSHARENAME
  464. else
  465. echo "WARNING: $HOME/$DUMMYSHAREDIR exists already. Leaving it as is..."
  466. fi
  467. else
  468. ln -s $DUMMYSHAREDIR/$user $HOME/$DUMMYSHARENAME
  469. chown $user: $HOME/$DUMMYSHARENAME
  470. fi
  471. if [ -n "$DUMMYAPACHECFG" -a -n "$DUMMYAPACHESHAREDIR" ]; then
  472. if [ -f /etc/apache/include.d/$DUMMYAPACHECFG -a -x /etc/init.d/apache ]; then
  473. if [ -e /etc/apache/include.d/$DUMMYAPACHECFG-$user ]; then
  474. echo "/etc/apache/include.d/$DUMMYAPACHECFG-$user exists already. Ignoring..."
  475. else
  476. echo "# Created automatically by adduser.local
  477. <Location /$DUMMYAPACHESHAREDIR/$user>
  478. <Limit GET POST>
  479. require user $user
  480. </Limit>
  481. </Location>" \
  482. > /etc/apache/include.d/$DUMMYAPACHECFG-$user
  483. apache_reload_needed="1"
  484. fi
  485. fi
  486. fi
  487. fi
  488. echo "."
  489. done
  490. if [ $XCHANGE ]; then
  491. for USER in $(ls $XDIRREAL); do
  492. id $user >/dev/null 2>&1 || rm -rf $XDIRREAL/$user
  493. done
  494. fi
  495. if [ "$apache_reload_needed" ]; then
  496. apache_do_reload=""
  497. case runmode in
  498. interactive)
  499. echo -n "Apache config changed. Reload Apache now (Y/n)? "
  500. read apache_reload
  501. case $apache_reload in
  502. y|Y|"")
  503. apache_do_reload="1"
  504. ;;
  505. esac
  506. ;;
  507. force)
  508. apache_do_reload="1"
  509. ;;
  510. *)
  511. echo "Apache config has changed. Remember to reload Apache...!"
  512. ;;
  513. esac
  514. if "$apache_do_reload" ]; then
  515. /etc/init.d/apache force-reload
  516. fi
  517. fi