Netgroups - Uses:
vladimir:x:31415:31415:Vladimir V Egorin:/home/2/vladimir:/bin/bash
sysadmin:x:11:11:Sysadmin:/home/8/SA:/bin/csh
culler:x:30007:30007:Marc Culler:/home/4/culler:/bin/bash
burgiel:x:31887:31887:Heidi Burgiel:/home/4/burgiel:/bin/bash
irina:x:30119:30119:Irina Perepelitsa:/home/4/irina:/bin/bash
dye:x:30225:30225:Heather A. Dye:/home/4/dye:/bin/bash
wolfgang:x:1244:1244:Wolfgang McKeown:/home/6/wolfgang:/bin/bash
you could use:
+@admin:x:::::
and put us in the admin netgroup.
/etc/hosts.allow
/etc/passwd
right. In turn, labauto_master exists so
that automounter
consulted
labauto.direct
Why Net groups:
netgroups are limited to 1024 characters, insufficient
for need.
use the make netgroups stuff:
netgroups -> gen file netgroup
#include <ctype.h>
#include <strings.h>
#include <pwd.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#define NGRPDIR "/var/yp/NETGROUPS"
#define ngrptmp "/var/yp/netgroup.tmp"
#define MAXL 1019
#define DEBUG 0
#define DBG if(DEBUG) fprintf
FILE *nf; /* ngrptmp */
void make_netgroup(struct dirent *);
char *find_word(char s[255]);
int main(void) {
DIR *dirp;
struct dirent
*dp;
char *t;
char bad =
0;
if( (nf = fopen(ngrptmp,"w"))
== NULL) {
perror(ngrptmp);
exit(2);
}
if( (dirp=opendir(NGRPDIR))
== NULL) {
perror(NGRPDIR);
exit(2);
}
if(chdir(NGRPDIR)<0)
{
perror(NGRPDIR);
exit(2);
}
while( (dp
= readdir(dirp)) != NULL) {
bad = 0;
if( (!strcmp(dp->d_name,".")) || (!strcmp(dp->d_name,"..")) )
continue;
for(t=dp->d_name; *t; t++) {
if( (*t == '~') || (*t == '.') ) {
printf("\007---->BAD filename: %s. Skipping.\n", dp->d_name);
bad = 1;
break;
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;
}