#!/usr/local/bin/perl # Various directory setup At the - last Please do not attach /. $home_dir = '/home'; # home directory $bin_dir = 'bin'; # bin directory (copy target) $etc_dir = 'etc'; # etc directory (copy target) # Copy target files. $group_path = '/etc/group'; $passwd_path = '/etc/passwd'; $pwddb_path = '/etc/pwd.db'; $ls_path = '/bin/ls'; $gzip_path = '/usr/bin/gzip'; ### Process start. ### print ">> file copy process start.\n"; if (!opendir(DIR,"$home_dir/")) { &error("A home directory cannot be read. [$home_dir/]"); } @DIR = readdir(DIR); closedir(DIR); foreach (@DIR) { if ((!/^\.+$/)&&(-d "$home_dir/$_/")) { push (@USER,"$home_dir/$_"); } } foreach (@USER) { print "setting to '$_' user directory..."; mkdir "$_$etc_dir/",0755; mkdir "$_$bin_dir/",0755; `cp $passwd_path $_/$etc_dir/`; `cp $group_path $_/$etc_dir/`; `cp $pwddb_path $_/$etc_dir/`; `cp $ls_path $_/$bin_dir/`; `cp $gzip_path $_/$bin_dir/`; chmod 0111,"$_/$etc_dir/"; chmod 0111,"$_/$bin_dir/"; print "done.\n"; } print ">> all process successful.\n"; exit; sub error { print "\n[ERROR] $_[0]\n"; exit; }