/* * Select the system's default password hashing scheme and generate * a stable fake salt under it for use by a non-existent account. * Prevents jpake method being used to infer the validity of accounts. */ static void fake_salt_and_scheme(Authctxt *authctxt, char **salt, char **scheme) { char *rounds_s, *style; long long rounds; login_cap_t *lc; if ((lc = login_getclass(authctxt->pw->pw_class)) == NULL && (lc = login_getclass(NULL)) == NULL) fatal("%s: login_getclass failed", __func__); style = login_getcapstr(lc, "localcipher", NULL, NULL); if (style == NULL) style = xstrdup("blowfish,6"); login_close(lc); if ((rounds_s = strchr(style, ',')) != NULL) *rounds_s++ = '\0'; rounds = strtonum(rounds_s, 1, 1<<31, NULL); if (strcmp(style, "md5") == 0) { xasprintf(salt, "$1$%s$", makesalt(8, authctxt->user)); *scheme = xstrdup("md5"); } else if (strcmp(style, "old") == 0) { *salt = xstrdup(makesalt(2, authctxt->user)); *scheme = xstrdup("crypt"); } else if (strcmp(style, "newsalt") == 0) { rounds = MAX(rounds, 7250); rounds = MIN(rounds, (1<<24) - 1); xasprintf(salt, "_%c%c%c%c%s", pw_encode64(rounds), pw_encode64(rounds >> 6), pw_encode64(rounds >> 12), pw_encode64(rounds >> 18), makesalt(4, authctxt->user)); *scheme = xstrdup("crypt-extended"); } else {
int main() { char salt[SALTSIZE + 1]; crypt_set_format("sha512"); makesalt(salt); crypt("123456", salt); return 0; }
int main (int argc, char **argv) { int rc; char *pt; char *bversion; FILE *pidfile,*conffile; if(argc==2) { strmncpy(configfile,argv[1],sizeof(configfile)); } else { strcpy(configfile,"psybnc.conf"); /* rcsid */ } conffile=fopen(configfile,"r"); if(conffile==NULL) { printf("Configuration File %s not found, aborting\nRun 'make menuconfig' for creating a configuration or create the file manually.\n",configfile); /* rcsid */ exit (0x0); } fclose(conffile); readconfig(); rc = getini("SYSTEM","LANGUAGE",INIFILE); /* rcsid */ if(rc!=0) { rc=loadlanguage("english"); /* rcsid */ } else { rc=loadlanguage(value); if(rc<0) rc=loadlanguage("english"); /* rcsid */ } if(rc<0) { printf("Could not load language file, aborting.\n"); /* rcsid */ exit(0x0); } printbanner(); printf(lngtxt(991),configfile); printf(lngtxt(992),langname); ap_snprintf(logfile,sizeof(logfile),lngtxt(993)); rc = getini(lngtxt(994),lngtxt(995),INIFILE); if (rc != 0) { printf("%s", lngtxt(996)); exit (0x0); } listenport = atoi(value); rc = getini(lngtxt(997),"ME",INIFILE); if (rc < 0) { memset(value,0x0,sizeof(value)); } pt=strchr(value,' '); /* shortening bouncername to no spaces */ if(pt) *pt=0; ap_snprintf(me,sizeof(me),"%s",value); rc = getini(lngtxt(998),lngtxt(999),INIFILE); if (rc < 0) { printf("%s", lngtxt(1000)); ap_snprintf(value,sizeof(value),lngtxt(1001)); } ap_snprintf(logfile,sizeof(logfile),"%s",value); oldfile(logfile); /* creating the socket-root */ socketnode=(struct socketnodes *) pmalloc(sizeof(struct usernodes)); socketnode->sock=NULL; socketnode->next=NULL; #ifdef IPV6 /* set the default ipv6 preference for users without a PREFERIPV6 setting */ rc = getini("SYSTEM", "DEFAULTIPV6", INIFILE); if (rc == 0) { defaultipv6 = atoi(value); } #endif /* creating the demon socket */ rc = createlisteners(); if (rc == 0) { printf("%s", lngtxt(1002)); exit (0x0); } /* creating background */ pidfile = fopen(lngtxt(1003),"w"); if(pidfile==NULL) { printf("%s", lngtxt(1004)); exit(0x0); } if(mainlog!=NULL) { fclose(mainlog); mainlog=NULL; } fflush(stdout); pid = fork(); //pid = 0; if (pid < 0) { } if (pid == 0) { rc= errorhandling(); makesalt(); #ifdef HAVE_SSL initSSL(); pcontext; #endif U_CREATE=0; #ifdef PARTYCHANNEL /* partychannel setup */ strmncpy(partytopic,lngtxt(1005),sizeof(partytopic)); partyusers=NULL; #endif /* creating the usernode-root */ usernode=(struct usernodes *) pmalloc(sizeof(struct usernodes)); usernode->uid=0; usernode->user=NULL; usernode->next=NULL; /* creating the newpeer-root */ peernode=(struct peernodes *) pmalloc(sizeof(struct peernodes)); peernode->uid=0; peernode->peer=NULL; peernode->next=NULL; /* creating the datalink-root */ linknode=(struct linknodes *) pmalloc(sizeof(struct linknodes)); linknode->uid=0; linknode->link=NULL; linknode->next=NULL; /* loading the users */ loadusers(); loadlinks(); pcontext; /* loading the hostallows */ hostallows=loadlist(lngtxt(1006),hostallows); } pcontext; if (pid) { bversion=buildversion(); printf(lngtxt(1007),bversion,pid); p_log(LOG_INFO,-1,lngtxt(1008),bversion,pid); fprintf( pidfile,"%d\n",pid); fclose(pidfile); exit (0x0); } pcontext; //#ifndef BLOCKDNS // if(init_dns_core()==0) // { // dns_err(0,1); // } //#endif p_dns_init(); bncmain(); return 0x0; }