Revision: 510 http://vde.svn.sourceforge.net/vde/?rev=510&view=rev Author: rd235 Date: 2011-11-16 18:02:17 +0000 (Wed, 16 Nov 2011) Log Message: ----------- sha1passwd - openssl library function instead of fork/exec sha1sum.
Modified Paths: -------------- trunk/vdetelweb/configure.ac trunk/vdetelweb/vdetelweb.c Modified: trunk/vdetelweb/configure.ac =================================================================== --- trunk/vdetelweb/configure.ac 2011-11-07 09:29:44 UTC (rev 509) +++ trunk/vdetelweb/configure.ac 2011-11-16 18:02:17 UTC (rev 510) @@ -26,6 +26,7 @@ # Checks for libraries. AC_CHECK_LIB([lwipv6], [lwip_init],, AC_MSG_ERROR([liblwipv6 missing]), [-lpthread]) +AC_CHECK_LIB([ssl], [SHA1_Init],, AC_MSG_ERROR([libssl (openssl) missing]), [-lssl]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT Modified: trunk/vdetelweb/vdetelweb.c =================================================================== --- trunk/vdetelweb/vdetelweb.c 2011-11-07 09:29:44 UTC (rev 509) +++ trunk/vdetelweb/vdetelweb.c 2011-11-16 18:02:17 UTC (rev 510) @@ -53,6 +53,7 @@ #include "vdetelweb.h" #include <lwipv6.h> #include <limits.h> +#include <openssl/sha.h> int daemonize; int telnet; @@ -105,36 +106,21 @@ } } +static char hex[]="0123456789abcdef"; int sha1passwdok(const char *pw) { - char buf[HASH_SIZE + 1]; - int pfd_fc[2]; - int pfd_cf[2]; - pid_t pid; - - pipe(pfd_fc); - pipe(pfd_cf); - pid = fork(); - - if (!pid) { - close(pfd_fc[1]); - close(pfd_cf[0]); - dup2(pfd_fc[0], STDIN_FILENO); - dup2(pfd_cf[1], STDOUT_FILENO); - - execl("/usr/bin/sha1sum", "/usr/bin/sha1sum", NULL); - exit(1); - } else { - close(pfd_cf[1]); - close(pfd_fc[0]); - - write(pfd_fc[1], pw, strlen(pw)); - close(pfd_fc[1]); - read(pfd_cf[0], buf, sizeof(buf)); - close(pfd_cf[0]); - - waitpid(pid, NULL, 0); - return (strncmp(buf,passwd,strlen(passwd))==0); + unsigned char out[SHA_DIGEST_LENGTH]; + char outstr[SHA_DIGEST_LENGTH*2+1]; + int i; + SHA_CTX c; + SHA1_Init(&c); + SHA1_Update(&c, pw, strlen(pw)); + SHA1_Final(out, &c); + for (i=0; i<SHA_DIGEST_LENGTH; i++) { + outstr[2*i]=hex[out[i] >> 4]; + outstr[2*i+1]=hex[out[i] & 0xf]; } + outstr[2*i]=0; + return (memcmp(outstr,passwd,SHA_DIGEST_LENGTH)==0); } static void sig_handler(int sig) @@ -695,25 +681,8 @@ printlog(LOG_INFO,"VDETELWEB started"); } -#if 0 while (1) { - int n,m,i; - fd_set rds,exc; - int max=setfds(&rds,&exc); - m=lwip_select(max,&rds,NULL,&exc,NULL); - for(i=0; m>0 && i<max; i++) { - if (FD_ISSET(i,&rds) || FD_ISSET(i,&exc)) { - n=pfdsearch(i); - fpfd[n](n,i,vdefd); - m--; - } - } - } -#endif -#if 1 - while (1) - { int i; int m=lwip_poll(pfd,npfd,-1); for (i=0;i<npfd && m>0;i++) { @@ -723,6 +692,5 @@ } } } -#endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ vde-users mailing list vde-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vde-users