This is load_eni.c in view mode; [Download] [Up]
#include <stdio.h> #include <strings.h> #include <sys/types.h> #include <sys/param.h> #define ENI "/usr/local/lib/eni" #define HLEN (MAXHOSTNAMELEN + 1) #define HOSTS "/usr/local/etc/enihosts" #define KL_UTIL "/usr/etc/kl_util" extern int execl(char *name, ...) ; extern int exit(int status) ; extern int gethostname(char *name, int namelen) ; extern int setuid(uid_t u) ; extern uid_t geteuid(void) ; extern void nuke() ; int main(void) { char h[HLEN] ; char host[HLEN] ; FILE *fp ; int full_name ; int okay = 0 ; if(setuid(geteuid()) == -1) { fprintf(stderr, "load_eni: can't change real and effective uids.\n") ; exit(1) ; } if(gethostname(host, sizeof host) == -1) { fprintf(stderr, "load_eni: can't get hostname (gethostname failed).\n") ; exit(2) ; } full_name = index(host, '.') == (char *)0 ? 0 : 1 ; if((fp = fopen(HOSTS, "r")) == (FILE *)0) { fprintf(stderr, "load_eni: can't open %s.\n", HOSTS) ; exit(3) ; } while(fgets(h, sizeof h, fp) != (char *)0) { nuke(h, '\n') ; if( ! full_name) { nuke(h, '.') ; } if(strcasecmp(h, host) == 0) { okay = 1 ; break ; } } if( ! okay) { if(feof(fp)) { fprintf(stderr, "load_eni: %s can't run eni.\n", host) ; fclose(fp) ; exit(0) ; } else { fprintf(stderr, "load_eni: error reading from %s.\n", HOSTS) ; fclose(fp) ; exit(4) ; } } fclose(fp) ; execl(KL_UTIL, KL_UTIL, "-a", ENI, (char *)0) ; perror("load_eni: exec") ; exit(5) ; return 0 ; /* a little kludge to shut up -Wall */ } void nuke(s, c) char *s ; char c ; { char *p ; if((p = index(s, c)) != (char *)0) { *p = '\0' ; } }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.