NIS -Netgroups

 What NIS Does:
   Nis distributes information to the machines in the department. Netgroups consist of two types
 Machine groups and User groups. We use the machine groups to control ssh logins, information distribution,
 and user logins.
  The size of Netgroups is limited to only 1024 characters. Our netgroups are larger than this. We have script to set up netgroups located in  /var/yp/bin/build_netgroups, because of this size constraint.

 

Netgroups - Uses:

Netgroups - Status and Files Referenced:
  Netgroups - Adding a New Machine
 - this is used in the solaris jumpstart, each time we add a new sun machine.
  Netgroups - Adding a New Netgroup
  NETgroups referenced in files:
    /etc/dfs/dfstab on newton: in the export list for /opt and /usr/local.
                           }
                    }

                    if (bad) continue;
     
                    DBG(stderr,"dir entry: %s\n", dp->d_name);
            /*      if(isdigit(dp->d_name[strlen(dp->d_name) - 1])) {
                            printf("\007---->BAD filename: %s.  Skipping.\n", dp->d_name);
                            continue;
                    } */
                    printf("Making %s\n", dp->d_name);
                    make_netgroup(dp);
            }
            (void) closedir(dirp);
            fclose(nf);
            if(rename(ngrptmp,"/var/yp/netgroup") < 0) {
                    perror("Could not rename to /var/yp/netgroup");
                    exit(2);
            }
            printf("Now you can type /usr/ccs/bin/make.\n");
            exit(0);
    void make_netgroup(struct dirent *dp) {
            char o[2048];
            char i[255];
            int j;
            int count;
            static char *wordp;
            struct hostent *h;
            int table_type; /* 0 = hosts; 1 = users */
            FILE *fp;
            char temp[255];
            DBG(stderr,"Entered make_netgroup.\n");
            *o = 0;
            if( (fp = fopen(dp->d_name, "r")) == NULL) {
                    perror(dp->d_name);
                    return;
            }
            DBG(stderr,"Opened: %s\n", dp->d_name);
            count = 0;
            if(fgets(i,255,fp) == NULL) return;
            wordp = find_word(i);
            if(!strcmp(wordp,"USERS"))
                    table_type = 1;
     

         else if(!strcmp(wordp, "HOSTS"))
                    table_type = 0;
            else {
                    fprintf(stderr,"%s: unknows table type.  Skipped.\n", dp->d_name);
                    return;
            }
            DBG(stderr,"table type: %d\n",  table_type);

            if(fgets(i,255,fp) == NULL) return;
            wordp = find_word(i);
            if(strlen(dp->d_name) + 3 + strlen(wordp) + 6 > MAXL-1) {
                    fprintf(stderr,"%s: host name too long.\n", wordp);
                    return;
            }
            if(table_type)
                    sprintf(o,"%s%d (-,%s,) ", dp->d_name,count, wordp);
            else
                    sprintf(o,"%s%d (%s,-,) ", dp->d_name,count, wordp);
            while ( fgets(i,255,fp) != NULL) {
                    wordp = find_word(i);
                    if(!wordp) continue;
                    if(strlen(wordp) + strlen(o) + 6 > MAXL-1) {
    :
                           fprintf(nf,"%s\n",o);
                            if(strlen(dp->d_name) + 2 + strlen(wordp) + 6 > MAXL-1) {
                                    fprintf(stderr,"%s: name too long.\n", wordp);
                                    return;
                            }
                            count++;
                            if(table_type)
                                    sprintf(o,"%s%d (-,%s,) ", dp->d_name,count, wordp);
                            else
                                    sprintf(o,"%s%d (%s,-,) ", dp->d_name,count, wordp);
                            continue;
                    } else {
                            if(table_type)
                                    sprintf(temp,"(-,%s,) ", wordp);
                            else
                                    sprintf(temp,"(%s,-,) ", wordp);
                            strcat(o,temp);
                    }
            }
            fprintf(nf,"%s\n",o);

          fprintf(nf,"%s ",dp->d_name);
            for(j=0;j<=count;j++) {
                    fprintf(nf,"%s%d ", dp->d_name,j);
            }
            fprintf(nf,"\n");
            return;
    }

    char *find_word(char s[255]) {
            char *p;
            char *e;
            static char wordp[255];
            DBG(stderr,"Entered find_word.\n");
            for(p=s;!( isalpha(*p)||isdigit(*p) ); p++);
            for(e=p; isalpha(*e) || isdigit(*e) || (*e == '-') || (*e == '.'); e++);        *e = 0;
            if(p-e > 254) return 0;
            snprintf(wordp,255,p);
            DBG(stderr,"putting word: %s\n", wordp);
            return wordp;
    }