# redhat-linux-lib.pl # NIS functions for redhat linux NIS client and server $yp_makefile = "/var/yp/Makefile"; $ypserv_conf = "/etc/ypserv.conf"; $pid_file = "/var/run/ypserv.pid"; # get_nis_support() # Returns 0 for no support, 1 for client only, 2 for server and 3 for both sub get_nis_support { local $rv; $rv += 1 if (&has_command("ypbind")); $rv += 2 if (&has_command("ypserv")); return $rv; } # get_client_config() # Returns a hash ref containing details of the client's NIS settings sub get_client_config { local $nis; open(CONF, "<".$config{'client_conf'}); while(<CONF>) { s/\r|\n//g; s/#.*$//g; if (/^\s*domain\s*(\S+)\s*broadcast/i) { $nis->{'broadcast'}++; } elsif (/^\s*domain\s*(\S+)\s*server\s*(\S+)/i) { push(@{$nis->{'servers'}}, $2); } elsif (/^\s*ypserver\s*(\S+)/) { push(@{$nis->{'servers'}}, $1); } } close(CONF); local %network; &read_env_file("/etc/sysconfig/network", \%network); $nis->{'domain'} = $network{'NISDOMAIN'}; return $nis; } # save_client_config(&config) # Saves and applies the NIS client configuration in the give hash. # Returns an error message if any, or undef on success. sub save_client_config { # Save the config file &open_tempfile(CONF, ">$config{'client_conf'}"); if ($_[0]->{'domain'}) { if ($_[0]->{'broadcast'}) { &print_tempfile(CONF, "domain $_[0]->{'domain'} broadcast\n"); } else { local @s = @{$_[0]->{'servers'}}; &print_tempfile(CONF, "domain $_[0]->{'domain'} server $s[0]\n"); foreach $s (@s) { &print_tempfile(CONF, "ypserver $s\n"); } } } &close_tempfile(CONF); local %network; &read_env_file("/etc/sysconfig/network", \%network); if ($_[0]->{'domain'}) { $network{'NISDOMAIN'} = $_[0]->{'domain'}; } else { delete($network{'NISDOMAIN'}); } &write_env_file("/etc/sysconfig/network", \%network); if ($_[0]->{'domain'}) { &init::enable_at_boot("ypbind"); } else { &init::disable_at_boot("ypbind"); } # Apply by setting the domainname and running the init script &system_logged("domainname '$_[0]->{'domain'}' >/dev/null 2>&1"); local $init = &init_script("ypbind"); &system_logged("$init stop >/dev/null 2>&1"); if ($_[0]->{'domain'}) { local $out = &backquote_logged("$init start 2>&1"); if ($?) { return "<pre>$out</pre>"; } } return undef; } @nis_files = ( "passwd", "shadow", "group", "gshadow", "adjunct", "aliases", "ethers", "bootparams", "hosts", "networks", "printcap", "protocols", "publickeys", "rpc", "services", "netgroup", "netid", "amd_home", "auto_master", "auto_home", "auto_local" ); @nis_tables = ( "passwd", "group", "hosts", "rpc", "services", "netid", "protocols", "netgrp", "mail", "shadow", "publickey","networks", "ethers", "bootparams", "printcap", "amd.home", "auto.master", "auto.home", "auto.local", "passwd.adjunct" ); # show_server_config() # Display a form for editing NIS server options sub show_server_config { local ($var, $rule) = &parse_yp_makefile(); local $boot = &init::action_status("ypserv"); print "<tr> <td><b>$text{'server_boot'}</b></td>\n"; printf "<td><input type=radio name=boot value=1 %s> %s\n", $boot == 2 ? 'checked' : '', $text{'yes'}; printf "<input type=radio name=boot value=0 %s> %s</td>\n", $boot == 2 ? '' : 'checked', $text{'no'}; local $dom = $var->{'LOCALDOMAIN'}->{'value'}; print "<td><b>$text{'server_domain'}</b></td>\n"; printf "<td><input type=radio name=domain_auto value=1 %s> %s\n", $dom =~ /`.*domainname`/ ? 'checked' : '', $text{'server_domain_auto'}; printf "<input type=radio name=domain_auto value=0 %s>\n", $dom =~ /`.*domainname`/ ? '' : 'checked'; printf "<input name=domain size=20 value='%s'></td> </tr>\n", $dom =~ /`.*domainname`/ ? '' : $dom; print "<tr> <td><b>$text{'server_type'}</b></td>\n"; printf "<td colspan=3><input type=radio name=type value=1 %s> %s\n", $config{'slave'} ? '' : 'checked', $text{'server_master'}; printf "<input type=radio name=type value=0 %s> %s\n", $config{'slave'} ? 'checked' : '', $text{'server_slave'}; printf "<input name=slave size=30 value='%s'></td> </tr>\n", $config{'slave'}; print "</table></td></tr></table><p>\n"; print "<table border width=100%>\n"; print "<tr $tb> <td><b>$text{'server_mheader'}</b></td> </tr>\n"; print "<tr $cb> <td><table width=100%>\n"; print "<tr> <td><b>$text{'server_dns'}</b></td>\n"; printf "<td><input type=radio name=b value='-b' %s> %s\n", $var->{'B'}->{'value'} eq '-b' ? 'checked' : '', $text{'yes'}; printf "<input type=radio name=b value='' %s> %s</td>\n", $var->{'B'}->{'value'} eq '-b' ? '' : 'checked', $text{'no'}; print "<td><b>$text{'server_push'}</b></td>\n"; printf "<td><input type=radio name=nopush value=false %s> %s\n", $var->{'NOPUSH'}->{'value'} eq 'true' ? '' : 'checked', $text{'yes'}; printf "<input type=radio name=nopush value=true %s> %s</td> </tr>\n", $var->{'NOPUSH'}->{'value'} eq 'true' ? 'checked' : '', $text{'no'}; local %inall; map { $inall{$_}++ } split(/\s+/, $rule->{'all'}->{'value'}); print "<tr> <td rowspan=2 valign=top><b>$text{'server_tables'}</b></td>\n"; print "<td rowspan=2><select multiple size=5 name=tables>\n"; foreach $t (grep { $rule->{$_} } @nis_tables) { printf "<option value=%s %s>%s</option>\n", $t, $inall{$t} ? 'selected' : '', $t; } print "</select></td>\n"; print "<td><b>$text{'server_minuid'}</b></td>\n"; printf "<td><input name=minuid size=10 value='%s'></td> </tr>\n", $var->{'MINUID'}->{'value'}; print "<td><b>$text{'server_mingid'}</b></td>\n"; printf "<td><input name=mingid size=10 value='%s'></td> </tr>\n", $var->{'MINGID'}->{'value'}; print "<tr> <td><b>$text{'server_slaves'}</b></td>\n"; open(SLAVES, "</var/yp/ypservers"); while(<SLAVES>) { s/\s//g; push(@slaves, $_) if ($_); } close(SLAVES); printf "<td colspan=3><input name=slaves size=60 value='%s'></td> </tr>\n", join(" ", @slaves); print "</table></td></tr></table><p>\n"; print "<table border width=100%>\n"; print "<tr $tb> <td><b>$text{'server_fheader'}</b></td> </tr>\n"; print "<tr $cb> <td><table width=100%>\n"; local $i = 0; foreach $t (@nis_files) { local $f = &expand_vars($var->{uc($t)}->{'value'}, $var); next if (!$f); print "<tr>\n" if ($i%2 == 0); print "<td><b>",&text('server_file', $text{"desc_$t"} ? $text{"desc_$t"} : $t),"</b></td>\n"; print "<td><input name=$t size=30 value='$f'></td>\n"; print "</tr>\n" if ($i++%2 == 1); } } # parse_server_config() # Parse and save the NIS server options sub parse_server_config { local ($var, $rule) = &parse_yp_makefile(); $in{'minuid'} =~ /^\d+$/ || &error($text{'server_eminuid'}); $in{'mingid'} =~ /^\d+$/ || &error($text{'server_emingid'}); $in{'domain_auto'} || $in{'domain'} =~ /^[A-Za-z0-9\.\-]+$/ || &error($text{'server_edomain'}); $in{'type'} || &to_ipaddress($in{'slave'}) || &to_ip6address($in{'slave'}) || &error($text{'server_eslave'}); &update_makefile($var->{'MINUID'}, $in{'minuid'}); &update_makefile($var->{'MINGID'}, $in{'mingid'}); &update_makefile($var->{'NOPUSH'}, $in{'nopush'}); &update_makefile($var->{'B'}, $in{'b'}); &update_makefile($var->{'LOCALDOMAIN'}, $in{'domain_auto'} ? "`domainname`" : $in{'domain'}); &update_makefile($rule->{'all'}, join(" ", split(/\0/, $in{'tables'})), ""); foreach $t (@nis_files) { local $old = &expand_vars($var->{uc($t)}->{'value'}, $var); next if (!$old); if ($old ne $in{$t}) { $in{$t} =~ /\S/ || &error(&text('server_efile', $text{"desc_$t"})); &update_makefile($var->{uc($t)}, $in{$t}); } } &open_tempfile(SLAVES, ">/var/yp/ypservers"); foreach $s (split(/\s+/, $in{'slaves'})) { &print_tempfile(SLAVES, "$s\n"); } &close_tempfile(SLAVES); if ($in{'boot'}) { &init::enable_at_boot("ypserv"); &init::enable_at_boot("yppasswdd"); } else { &init::disable_at_boot("ypserv"); &init::disable_at_boot("yppasswdd"); } local $init1 = &init_script("ypserv"); local $init2 = &init_script("yppasswdd"); &system_logged("$init1 stop >/dev/null 2>&1"); &system_logged("$init2 stop >/dev/null 2>&1"); if ($in{'boot'}) { &system_logged("$init1 start >/dev/null 2>&1"); &system_logged("$init2 start >/dev/null 2>&1"); } &flush_file_lines(); if ($in{'type'}) { # Master server delete($config{'slave'}); &apply_table_changes() if ($in{'boot'}); } else { $out = &backquote_logged("/usr/lib/yp/ypinit -s $in{'slave'} 2>&1"); if ($?) { &error("<tt>$out</tt>"); } $config{'slave'} = $in{'slave'}; } &write_file("$module_config_directory/config", \%config); } # get_server_mode() # Returns 0 if the NIS server is inactive, 1 if active as a master, or 2 if # active as a slave. sub get_server_mode { if (&init::action_status("ypserv") != 2) { return 0; } elsif ($config{'slave'}) { return 2; } else { return 1; } } # list_nis_tables() # Returns a list of structures of all NIS tables sub list_nis_tables { local ($var, $rule) = &parse_yp_makefile(); local @rv; local $dom = $var->{'LOCALDOMAIN'}->{'value'}; chop($dom = `domainname`) if ($dom =~ /`.*domainname`/); local %file; map { $file{uc($_)} = &expand_vars($var->{uc($_)}->{'value'}, $var) } @nis_files; local @all = split(/\s+/, $rule->{'all'}->{'value'}); foreach $t (@all) { local $table = { 'table' => $t, 'index' => scalar(@rv), 'domain' => $dom }; if ($t eq "passwd") { if ($var->{'MERGE_PASSWD'}->{'value'} eq 'true') { $table->{'type'} = 'passwd_shadow'; $table->{'files'} = [ $file{'PASSWD'}, $file{'SHADOW'} ]; } elsif (&indexof('shadow', @all) >= 0) { # Show separate shadow and passwd tables as one table $table->{'type'} = 'passwd_shadow_full'; $table->{'files'} = [ $file{'PASSWD'}, $file{'SHADOW'} ]; @all = grep { $_ ne 'shadow' } @all; } else { $table->{'type'} = 'passwd'; $table->{'files'} = [ $file{'PASSWD'} ]; } } elsif ($t eq "group") { if ($var->{'MERGE_GROUP'}->{'value'} eq 'true') { $table->{'type'} = 'group_shadow'; $table->{'files'} = [ $file{'GROUP'}, $file{'GSHADOW'} ]; } else { $table->{'type'} = 'group'; $table->{'files'} = [ $file{'GROUP'} ]; } } elsif ($t eq "netgrp") { $table->{'type'} = "netgroup"; $table->{'files'} = [ $file{'NETGROUP'} ]; } elsif ($t eq "mail") { $table->{'type'} = "aliases"; $table->{'files'} = [ $file{'ALIASES'} ]; } else { $table->{'type'} = $t; local $fn = uc($t); $fn =~ s/\./_/g; $table->{'files'} = [ $file{$fn} || $fn ]; } push(@rv, $table); } return @rv; } # apply_table_changes() # Do whatever is necessary for the table text files to be loaded into # the NIS server sub apply_table_changes { &system_logged("(cd /var/yp ; make) >/dev/null 2>&1 </dev/null"); } sub extra_config_files { return ( "/var/yp/ypservers" ); } 1;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
images | Folder | 0755 |
|
|
lang | Folder | 0755 |
|
|
CHANGELOG | File | 308 B | 0644 |
|
aix-lib.pl | File | 9.79 KB | 0755 |
|
backup_config.pl | File | 817 B | 0755 |
|
build.cgi | File | 162 B | 0755 |
|
coherent-linux-lib.pl | File | 10.4 KB | 0755 |
|
config-aix | File | 181 B | 0644 |
|
config-coherent-linux | File | 116 B | 0644 |
|
config-debian-linux | File | 120 B | 0644 |
|
config-generic-linux | File | 116 B | 0644 |
|
config-mandrake-linux | File | 116 B | 0644 |
|
config-msc-linux | File | 116 B | 0644 |
|
config-open-linux | File | 117 B | 0644 |
|
config-openSUSE-Linux-15.0-ALL | File | 116 B | 0644 |
|
config-openmamba-linux | File | 116 B | 0644 |
|
config-redhat-linux | File | 116 B | 0644 |
|
config-slackware-linux | File | 116 B | 0644 |
|
config-solaris | File | 167 B | 0644 |
|
config-solaris-8-ALL | File | 199 B | 0644 |
|
config-suse-linux | File | 116 B | 0644 |
|
config-trustix-linux | File | 116 B | 0644 |
|
config-united-linux | File | 116 B | 0644 |
|
config.info | File | 282 B | 0644 |
|
config.info.ca | File | 320 B | 0644 |
|
config.info.cs | File | 321 B | 0644 |
|
config.info.de | File | 321 B | 0644 |
|
config.info.es | File | 277 B | 0644 |
|
config.info.fr | File | 350 B | 0644 |
|
config.info.hu | File | 0 B | 0644 |
|
config.info.nl | File | 290 B | 0644 |
|
config.info.no | File | 297 B | 0644 |
|
config.info.pl | File | 309 B | 0644 |
|
config.info.ru | File | 491 B | 0644 |
|
config.info.sv | File | 132 B | 0644 |
|
config.info.uk | File | 500 B | 0644 |
|
debian-linux-lib.pl | File | 10.19 KB | 0755 |
|
edit_aliases.cgi | File | 1.2 KB | 0755 |
|
edit_client.cgi | File | 1.41 KB | 0755 |
|
edit_ethers.cgi | File | 1.14 KB | 0755 |
|
edit_group.cgi | File | 1.81 KB | 0755 |
|
edit_group_shadow.cgi | File | 1.83 KB | 0755 |
|
edit_hosts.cgi | File | 1.31 KB | 0755 |
|
edit_netgroup.cgi | File | 2.01 KB | 0755 |
|
edit_netmasks.cgi | File | 1.16 KB | 0755 |
|
edit_networks.cgi | File | 1.35 KB | 0755 |
|
edit_passwd.cgi | File | 4.8 KB | 0755 |
|
edit_passwd_shadow.cgi | File | 4.8 KB | 0755 |
|
edit_passwd_shadow_full.cgi | File | 4.8 KB | 0755 |
|
edit_protocols.cgi | File | 1.35 KB | 0755 |
|
edit_rpc.cgi | File | 1.3 KB | 0755 |
|
edit_security.cgi | File | 1.92 KB | 0755 |
|
edit_server.cgi | File | 607 B | 0755 |
|
edit_services.cgi | File | 1.52 KB | 0755 |
|
edit_services2.cgi | File | 1.53 KB | 0755 |
|
edit_switch.cgi | File | 1.74 KB | 0755 |
|
edit_tables.cgi | File | 6.24 KB | 0755 |
|
feedback_files.pl | File | 157 B | 0755 |
|
index.cgi | File | 776 B | 0755 |
|
linux-lib.pl | File | 5.27 KB | 0755 |
|
list_switches.cgi | File | 772 B | 0755 |
|
mandrake-linux-lib.pl | File | 10.38 KB | 0755 |
|
md5-lib.pl | File | 7.58 KB | 0755 |
|
module.info | File | 346 B | 0644 |
|
module.info.af | File | 0 B | 0644 |
|
module.info.af.auto | File | 167 B | 0644 |
|
module.info.ar | File | 0 B | 0644 |
|
module.info.ar.auto | File | 195 B | 0644 |
|
module.info.be | File | 0 B | 0644 |
|
module.info.be.auto | File | 287 B | 0644 |
|
module.info.bg | File | 0 B | 0644 |
|
module.info.bg.auto | File | 250 B | 0644 |
|
module.info.ca | File | 163 B | 0644 |
|
module.info.ca.auto | File | 12 B | 0644 |
|
module.info.cs | File | 28 B | 0644 |
|
module.info.cs.auto | File | 145 B | 0644 |
|
module.info.da | File | 0 B | 0644 |
|
module.info.da.auto | File | 154 B | 0644 |
|
module.info.de | File | 136 B | 0644 |
|
module.info.de.auto | File | 12 B | 0644 |
|
module.info.el | File | 0 B | 0644 |
|
module.info.el.auto | File | 235 B | 0644 |
|
module.info.es | File | 31 B | 0644 |
|
module.info.es.auto | File | 138 B | 0644 |
|
module.info.eu | File | 0 B | 0644 |
|
module.info.eu.auto | File | 164 B | 0644 |
|
module.info.fa | File | 0 B | 0644 |
|
module.info.fa.auto | File | 248 B | 0644 |
|
module.info.fi | File | 0 B | 0644 |
|
module.info.fi.auto | File | 158 B | 0644 |
|
module.info.fr | File | 30 B | 0644 |
|
module.info.fr.auto | File | 141 B | 0644 |
|
module.info.he | File | 0 B | 0644 |
|
module.info.he.auto | File | 170 B | 0644 |
|
module.info.hr | File | 0 B | 0644 |
|
module.info.hr.auto | File | 171 B | 0644 |
|
module.info.hu | File | 34 B | 0644 |
|
module.info.hu.auto | File | 147 B | 0644 |
|
module.info.it | File | 0 B | 0644 |
|
module.info.it.auto | File | 152 B | 0644 |
|
module.info.ja | File | 49 B | 0644 |
|
module.info.ja.auto | File | 226 B | 0644 |
|
module.info.ko | File | 39 B | 0644 |
|
module.info.ko.auto | File | 154 B | 0644 |
|
module.info.lt | File | 0 B | 0644 |
|
module.info.lt.auto | File | 169 B | 0644 |
|
module.info.lv | File | 0 B | 0644 |
|
module.info.lv.auto | File | 169 B | 0644 |
|
module.info.ms | File | 149 B | 0644 |
|
module.info.ms.auto | File | 12 B | 0644 |
|
module.info.mt | File | 0 B | 0644 |
|
module.info.mt.auto | File | 144 B | 0644 |
|
module.info.nl | File | 30 B | 0644 |
|
module.info.nl.auto | File | 130 B | 0644 |
|
module.info.no | File | 29 B | 0644 |
|
module.info.no.auto | File | 117 B | 0644 |
|
module.info.pl | File | 107 B | 0644 |
|
module.info.pl.auto | File | 12 B | 0644 |
|
module.info.pt | File | 0 B | 0644 |
|
module.info.pt.auto | File | 164 B | 0644 |
|
module.info.pt_BR | File | 0 B | 0644 |
|
module.info.pt_BR.auto | File | 173 B | 0644 |
|
module.info.ro | File | 0 B | 0644 |
|
module.info.ro.auto | File | 156 B | 0644 |
|
module.info.ru | File | 41 B | 0644 |
|
module.info.ru.auto | File | 246 B | 0644 |
|
module.info.sk | File | 0 B | 0644 |
|
module.info.sk.auto | File | 165 B | 0644 |
|
module.info.sl | File | 0 B | 0644 |
|
module.info.sl.auto | File | 165 B | 0644 |
|
module.info.sv | File | 31 B | 0644 |
|
module.info.sv.auto | File | 123 B | 0644 |
|
module.info.th | File | 0 B | 0644 |
|
module.info.th.auto | File | 347 B | 0644 |
|
module.info.tr | File | 0 B | 0644 |
|
module.info.tr.auto | File | 169 B | 0644 |
|
module.info.uk | File | 0 B | 0644 |
|
module.info.uk.auto | File | 247 B | 0644 |
|
module.info.ur | File | 0 B | 0644 |
|
module.info.ur.auto | File | 244 B | 0644 |
|
module.info.vi | File | 0 B | 0644 |
|
module.info.vi.auto | File | 217 B | 0644 |
|
module.info.zh | File | 34 B | 0644 |
|
module.info.zh.auto | File | 120 B | 0644 |
|
module.info.zh_TW | File | 37 B | 0644 |
|
module.info.zh_TW.auto | File | 126 B | 0644 |
|
msc-linux-lib.pl | File | 10.38 KB | 0755 |
|
nis-lib.pl | File | 6.02 KB | 0755 |
|
nisupdate.conf | File | 1.94 KB | 0644 |
|
old_edit_passwd_shadow.cgi | File | 4.62 KB | 0755 |
|
old_edit_switch.cgi | File | 1.76 KB | 0755 |
|
old_save_switch.cgi | File | 533 B | 0755 |
|
open-linux-lib.pl | File | 7.89 KB | 0755 |
|
openmamba-linux-lib.pl | File | 10.38 KB | 0755 |
|
redhat-linux-lib.pl | File | 10.38 KB | 0755 |
|
save_aliases.cgi | File | 749 B | 0755 |
|
save_client.cgi | File | 661 B | 0755 |
|
save_ethers.cgi | File | 793 B | 0755 |
|
save_file.cgi | File | 588 B | 0755 |
|
save_group.cgi | File | 945 B | 0755 |
|
save_group_shadow.cgi | File | 1.04 KB | 0755 |
|
save_hosts.cgi | File | 758 B | 0755 |
|
save_netgroup.cgi | File | 1.04 KB | 0755 |
|
save_netmasks.cgi | File | 753 B | 0755 |
|
save_networks.cgi | File | 791 B | 0755 |
|
save_passwd_shadow.cgi | File | 2.36 KB | 0755 |
|
save_protocols.cgi | File | 806 B | 0755 |
|
save_rpc.cgi | File | 746 B | 0755 |
|
save_security.cgi | File | 996 B | 0755 |
|
save_server.cgi | File | 184 B | 0755 |
|
save_services.cgi | File | 775 B | 0755 |
|
save_services2.cgi | File | 776 B | 0755 |
|
save_switch.cgi | File | 932 B | 0755 |
|
slackware-linux-lib.pl | File | 9.91 KB | 0755 |
|
solaris-lib.pl | File | 10.45 KB | 0755 |
|
suse-linux-8.2-lib.pl | File | 11.05 KB | 0755 |
|
suse-linux-9.0-lib.pl | File | 11.05 KB | 0755 |
|
suse-linux-lib.pl | File | 11.88 KB | 0755 |
|
switch-lib.pl | File | 3.08 KB | 0755 |
|
trustix-linux-lib.pl | File | 10.38 KB | 0755 |
|
united-linux-lib.pl | File | 11.05 KB | 0755 |
|