diff options
author | ivan <ivan> | 2004-03-24 14:28:48 +0000 |
---|---|---|
committer | ivan <ivan> | 2004-03-24 14:28:48 +0000 |
commit | dabdf357484badff95afcae50b08ec1c3bb58343 (patch) | |
tree | be9286511b919228eda79aa69efacddf449851fb /FS/FS/part_export/shellcommands.pm | |
parent | 7de51deb0e3e3fe1b0a9e06be6498256d5511bd0 (diff) |
move export info to the modules themselves
Diffstat (limited to 'FS/FS/part_export/shellcommands.pm')
-rw-r--r-- | FS/FS/part_export/shellcommands.pm | 154 |
1 files changed, 153 insertions, 1 deletions
diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index 9fad36dad..cee54b488 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -1,11 +1,161 @@ package FS::part_export::shellcommands; -use vars qw(@ISA @saltset); +use vars qw(@ISA %info @saltset); +use Tie::IxHash; use String::ShellQuote; use FS::part_export; @ISA = qw(FS::part_export); +tie my %options, 'Tie::IxHash', + 'user' => { label=>'Remote username', default=>'root' }, + 'useradd' => { label=>'Insert command', + default=>'useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username' + #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir' + }, + 'useradd_stdin' => { label=>'Insert command STDIN', + type =>'textarea', + default=>'', + }, + 'userdel' => { label=>'Delete command', + default=>'userdel -r $username', + #default=>'rm -rf $dir', + }, + 'userdel_stdin' => { label=>'Delete command STDIN', + type =>'textarea', + default=>'', + }, + 'usermod' => { label=>'Modify command', + default=>'usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username', + #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '. + # 'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '. + # 'find . -depth -print | cpio -pdm $new_dir; '. + # 'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '. + # 'rm -rf $old_dir'. + #')' + }, + 'usermod_stdin' => { label=>'Modify command STDIN', + type =>'textarea', + default=>'', + }, + 'usermod_pwonly' => { label=>'Disallow username changes', + type =>'checkbox', + }, + 'suspend' => { label=>'Suspension command', + default=>'usermod -L $username', + }, + 'suspend_stdin' => { label=>'Suspension command STDIN', + default=>'', + }, + 'unsuspend' => { label=>'Unsuspension command', + default=>'usermod -U $username', + }, + 'unsuspend_stdin' => { label=>'Unsuspension command STDIN', + default=>'', + }, +; + +%info = ( + 'svc' => 'svc_acct', + 'desc' => + 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', + 'options' => \%options, + 'nodomain' => 'Y', + 'notes' => <<'END' +Run remote commands via SSH. Usernames are considered unique (also see +shellcommands_withdomain). You probably want this if the commands you are +running will not accept a domain as a parameter. You will need to +<a href="../docs/ssh.html">setup SSH for unattended operation</a>. + +<BR><BR>Use these buttons for some useful presets: +<UL> + <LI> + <INPUT TYPE="button" VALUE="Linux" onClick=' + this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username"; + this.form.useradd_stdin.value = ""; + this.form.userdel.value = "userdel -r $username"; + this.form.userdel_stdin.value=""; + this.form.usermod.value = "usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username"; + this.form.usermod_stdin.value = ""; + this.form.suspend.value = "usermod -L $username"; + this.form.suspend_stdin.value=""; + this.form.unsuspend.value = "usermod -U $username"; + this.form.unsuspend_stdin.value=""; + '> + <LI> + <INPUT TYPE="button" VALUE="FreeBSD before 5.2.1" onClick=' + this.form.useradd.value = "lockf /etc/passwd.lock pw useradd $username -d $dir -m -s $shell -u $uid -g $gid -c $finger -h 0"; + this.form.useradd_stdin.value = "$_password\n"; + this.form.userdel.value = "lockf /etc/passwd.lock pw userdel $username -r"; this.form.userdel_stdin.value=""; + this.form.usermod.value = "lockf /etc/passwd.lock pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -c $new_finger -h 0"; + this.form.usermod_stdin.value = "$new__password\n"; this.form.suspend.value = "lockf /etc/passwd.lock pw lock $username"; + this.form.suspend_stdin.value=""; + this.form.unsuspend.value = "lockf /etc/passwd.lock pw unlock $username"; this.form.unsuspend_stdin.value=""; + '> + Note: On FreeBSD versions before 5.2.1, due to deficient locking in pw(1), + you must disable the chpass(1), chsh(1), chfn(1), passwd(1), and vipw(1) + commands, or replace them with wrappers that prepend + "lockf /etc/passwd.lock". Alternatively, apply the patch in + <A HREF="http://www.freebsd.org/cgi/query-pr.cgi?pr=23501">FreeBSD PR#23501</A> + and use the "FreeBSD 5.2.1 or later" button below. + <LI> + <INPUT TYPE="button" VALUE="FreeBSD 5.2.1 or later" onClick=' + this.form.useradd.value = "pw useradd $username -d $dir -m -s $shell -u $uid -g $gid -c $finger -h 0"; + this.form.useradd_stdin.value = "$_password\n"; + this.form.userdel.value = "pw userdel $username -r"; + this.form.userdel_stdin.value=""; + this.form.usermod.value = "pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -c $new_finger -h 0"; + this.form.usermod_stdin.value = "$new__password\n"; + this.form.suspend.value = "pw lock $username"; + this.form.suspend_stdin.value=""; + this.form.unsuspend.value = "pw unlock $username"; + this.form.unsuspend_stdin.value=""; + '> + <LI> + <INPUT TYPE="button" VALUE="NetBSD/OpenBSD" onClick=' + this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username"; + this.form.useradd_stdin.value = ""; + this.form.userdel.value = "userdel -r $username"; + this.form.userdel_stdin.value=""; + this.form.usermod.value = "usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username"; + this.form.usermod_stdin.value = ""; + this.form.suspend.value = ""; + this.form.suspend_stdin.value=""; + this.form.unsuspend.value = ""; + this.form.unsuspend_stdin.value=""; + '> + <LI> + <INPUT TYPE="button" VALUE="Just maintain directories (use with sysvshell or bsdshell)" onClick=' + this.form.useradd.value = "cp -pr /etc/skel $dir; chown -R $uid.$gid $dir"; this.form.useradd_stdin.value = ""; + this.form.usermod.value = "[ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $new_uid.$new_gid $new_dir; rm -rf $old_dir )"; + this.form.usermod_stdin.value = ""; + this.form.userdel.value = "rm -rf $dir"; + this.form.userdel_stdin.value=""; + this.form.suspend.value = ""; + this.form.suspend_stdin.value=""; + this.form.unsuspend.value = ""; + this.form.unsuspend_stdin.value=""; + '> +</UL> + +The following variables are available for interpolation (prefixed with new_ or +old_ for replace operations): +<UL> + <LI><code>$username</code> + <LI><code>$_password</code> + <LI><code>$quoted_password</code> - unencrypted password quoted for the shell + <LI><code>$crypt_password</code> - encrypted password + <LI><code>$uid</code> + <LI><code>$gid</code> + <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes) + <LI><code>$dir</code> - home directory + <LI><code>$shell</code> + <LI><code>$quota</code> + <LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available. +</UL> +END +); + @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); sub rebless { shift; } @@ -152,3 +302,5 @@ sub ssh_cmd { #subroutine, not method #sub shellcommands_delete { #subroutine, not method #} +1; + |