- if (not defined $where) { # Try NIS.
- foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
- if (-x $ypcat &&
- open(GR, "$ypcat group 2>/dev/null |") &&
- defined(<GR>)) {
- $where = "NIS group";
- undef $reason;
- last;
- }
- }
+if (not defined $where) { # Try NIS.
+ foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
+ if (-x $ypcat &&
+ open(GR, "$ypcat group 2>/dev/null |") &&
+ defined(<GR>))
+ {
+ print "# `ypcat group` worked\n";
+
+ # Check to make sure we are really using NIS.
+ if( open(NSSW, "/etc/nsswitch.conf" ) ) {
+ my($group) = grep /^\s*group:/, <NSSW>;
+
+ # If there is no group line, assume it default to compat.
+ if( !$group || $group !~ /(nis|compat)/ ) {
+ print "# Doesn't look like you're using NIS in ".
+ "/etc/nsswitch.conf\n";
+ last;
+ }
+ }
+ $where = "NIS group - $ypcat";
+ undef $reason;
+ last;
+ }