Thread: [Linux-decnet-commit] CVS: dnprogs/libdaemon dnet_daemon.c,1.8,1.9
Brought to you by:
chrissie_c,
ph3-der-loewe
From: Patrick C. <pa...@us...> - 2002-07-10 06:56:36
|
Update of /cvsroot/linux-decnet/dnprogs/libdaemon In directory usw-pr-cvs1:/tmp/cvs-serv20208 Modified Files: dnet_daemon.c Log Message: If the password fails to match then convert it to all lower-case and try again. This is for RSX's benefit as it sends all upper-cased passwords. Index: dnet_daemon.c =================================================================== RCS file: /cvsroot/linux-decnet/dnprogs/libdaemon/dnet_daemon.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** dnet_daemon.c 28 Jan 2001 17:27:36 -0000 1.8 --- dnet_daemon.c 10 Jul 2002 06:56:32 -0000 1.9 *************** *** 99,105 **** // Make sure we reap all children ! do ! { ! pid = waitpid(-1, &status, WNOHANG); if (pid > 0 && verbose) DNETLOG((LOG_INFO, "Reaped child process %d\n", pid)); } --- 99,105 ---- // Make sure we reap all children ! do ! { ! pid = waitpid(-1, &status, WNOHANG); if (pid > 0 && verbose) DNETLOG((LOG_INFO, "Reaped child process %d\n", pid)); } *************** *** 137,141 **** DNETLOG((LOG_ERR, "Can't open proxy database: %s\n", strerror(errno))); return; ! } line = 0; --- 137,141 ---- DNETLOG((LOG_ERR, "Can't open proxy database: %s\n", strerror(errno))); return; ! } line = 0; *************** *** 145,149 **** char *bufp = buf; char *colons; ! line++; if (!fgets(buf, sizeof(buf), f)) break; --- 145,149 ---- char *bufp = buf; char *colons; ! line++; if (!fgets(buf, sizeof(buf), f)) break; *************** *** 156,160 **** // Remove trailing LF if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; ! colons = strstr(bufp, "::"); if (colons) --- 156,160 ---- // Remove trailing LF if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0'; ! colons = strstr(bufp, "::"); if (colons) *************** *** 164,168 **** char *end; char *local; ! if (!space) space = strchr(colons, '\t'); if (!space) --- 164,168 ---- char *end; char *local; ! if (!space) space = strchr(colons, '\t'); if (!space) *************** *** 274,284 **** // Check the proxy database for authentication ! static bool check_proxy_database(char *nodename, ! char *remoteuser, char *localuser) { bool found = FALSE; struct proxy *p; ! // Re-read the proxy database 'cos it has changed. free_proxy(); --- 274,284 ---- // Check the proxy database for authentication ! static bool check_proxy_database(char *nodename, ! char *remoteuser, char *localuser) { bool found = FALSE; struct proxy *p; ! // Re-read the proxy database 'cos it has changed. free_proxy(); *************** *** 309,313 **** } ! // // Wait for an incoming connection // Returns a new fd or -1 --- 309,313 ---- } ! // // Wait for an incoming connection // Returns a new fd or -1 *************** *** 319,323 **** struct sockaddr_dn sockaddr; static bool listening = FALSE; ! memset(&sockaddr, 0, sizeof(sockaddr)); --- 319,323 ---- struct sockaddr_dn sockaddr; static bool listening = FALSE; ! memset(&sockaddr, 0, sizeof(sockaddr)); *************** *** 378,382 **** int have_shadow = -1; memset(&sockaddr, 0, sizeof(sockaddr)); ! // Get the name (or address if we cant find the name) of the remote system. // (a) for logging and (b) for checking in the proxy database. --- 378,382 ---- int have_shadow = -1; memset(&sockaddr, 0, sizeof(sockaddr)); ! // Get the name (or address if we cant find the name) of the remote system. // (a) for logging and (b) for checking in the proxy database. *************** *** 389,398 **** else { ! snprintf(nodename, sizeof(nodename), "%d.%d", (sockaddr.sdn_add.a_addr[1] >> 2), (((sockaddr.sdn_add.a_addr[1] & 0x03) << 8) | sockaddr.sdn_add.a_addr[0])); } ! // Only do this if we are dnetd if (object_db) --- 389,398 ---- else { ! snprintf(nodename, sizeof(nodename), "%d.%d", (sockaddr.sdn_add.a_addr[1] >> 2), (((sockaddr.sdn_add.a_addr[1] & 0x03) << 8) | sockaddr.sdn_add.a_addr[0])); } ! // Only do this if we are dnetd if (object_db) *************** *** 420,424 **** // Get the remote user spec. if (getsockopt(sockfd, DNPROTO_NSP, SO_CONACCESS, &accessdata, ! &len) < 0) { snprintf(errstring, sizeof(errstring), --- 420,424 ---- // Get the remote user spec. if (getsockopt(sockfd, DNPROTO_NSP, SO_CONACCESS, &accessdata, ! &len) < 0) { snprintf(errstring, sizeof(errstring), *************** *** 446,459 **** ! if (verbose) { if (username[0]) { ! DNETLOG((LOG_DEBUG, "Connection from: %s\"%s password\"::%s\n", nodename, username, remote_user)); } else { ! DNETLOG((LOG_DEBUG, "Connection from: %s::%s\n", nodename, remote_user)); } --- 446,459 ---- ! if (verbose) { if (username[0]) { ! DNETLOG((LOG_DEBUG, "Connection from: %s\"%s password\"::%s\n", nodename, username, remote_user)); } else { ! DNETLOG((LOG_DEBUG, "Connection from: %s::%s\n", nodename, remote_user)); } *************** *** 529,533 **** { snprintf(errstring, sizeof(errstring), ! "Error reading /etc/shadow entry for %s: %s", username, strerror(errno)); lasterror=errstring; --- 529,533 ---- { snprintf(errstring, sizeof(errstring), ! "Error reading /etc/shadow entry for %s: %s", username, strerror(errno)); lasterror=errstring; *************** *** 537,550 **** } endspent(); // prevent caching of passwords ! ! // Check the shadow password cryptpass = crypt(password, spw->sp_pwdp); if (strcmp(cryptpass, spw->sp_pwdp)) { ! snprintf(errstring, sizeof(errstring), ! "Incorrect password for %s", username); ! lasterror=errstring; ! dnet_reject(sockfd, DNSTAT_ACCCONTROL, NULL, 0); ! return -1; } } --- 537,557 ---- } endspent(); // prevent caching of passwords ! ! // Check the shadow password cryptpass = crypt(password, spw->sp_pwdp); if (strcmp(cryptpass, spw->sp_pwdp)) { ! // If that failed then lower-case the password and try again. ! // This is really for RSX which sends the password in all caps ! makelower(password); ! cryptpass = crypt(password, spw->sp_pwdp); ! if (strcmp(cryptpass, spw->sp_pwdp)) ! { ! snprintf(errstring, sizeof(errstring), ! "Incorrect password for %s", username); ! lasterror=errstring; ! dnet_reject(sockfd, DNSTAT_ACCCONTROL, NULL, 0); ! return -1; ! } } } *************** *** 552,569 **** #endif { ! // Check the (non-shadow) password cryptpass = crypt(password, pw->pw_passwd); if (strcmp(cryptpass, pw->pw_passwd)) { ! snprintf(errstring, sizeof(errstring), ! "Incorrect password for %s", username); ! lasterror=errstring; ! dnet_reject(sockfd, DNSTAT_ACCCONTROL, NULL, 0); ! return -1; } } } ! // NO_FORK is just for testing. It creates a single-shot server that is // easier to debug. #ifdef NO_FORK --- 559,582 ---- #endif { ! // Check the (non-shadow) password cryptpass = crypt(password, pw->pw_passwd); if (strcmp(cryptpass, pw->pw_passwd)) { ! // Check lower-case password as above. ! makelower(password); ! cryptpass = crypt(password, pw->pw_passwd); ! if (strcmp(cryptpass, pw->pw_passwd)) ! { ! snprintf(errstring, sizeof(errstring), ! "Incorrect password for %s", username); ! lasterror=errstring; ! dnet_reject(sockfd, DNSTAT_ACCCONTROL, NULL, 0); ! return -1; ! } } } } ! // NO_FORK is just for testing. It creates a single-shot server that is // easier to debug. #ifdef NO_FORK *************** *** 622,629 **** if (!f) { ! DNETLOG((LOG_ERR, "Can't open dnetd.conf database: %s\n", strerror(errno))); return; ! } line = 0; --- 635,642 ---- if (!f) { ! DNETLOG((LOG_ERR, "Can't open dnetd.conf database: %s\n", strerror(errno))); return; ! } line = 0; *************** *** 636,640 **** struct object *newobj; int state = 1; ! line++; if (!fgets(buf, sizeof(buf), f)) break; --- 649,653 ---- struct object *newobj; int state = 1; ! line++; if (!fgets(buf, sizeof(buf), f)) break; *************** *** 654,658 **** if (*bufp == '\0') continue; // Empty line ! // Split into fields newobj = malloc(sizeof(struct object)); --- 667,671 ---- if (*bufp == '\0') continue; // Empty line ! // Split into fields newobj = malloc(sizeof(struct object)); *************** *** 727,731 **** bind_sockaddr.sdn_objnamel = 0; ! status = bind(sockfd, (struct sockaddr *)&bind_sockaddr, sizeof(bind_sockaddr)); if (status) --- 740,744 ---- bind_sockaddr.sdn_objnamel = 0; ! status = bind(sockfd, (struct sockaddr *)&bind_sockaddr, sizeof(bind_sockaddr)); if (status) *************** *** 744,748 **** struct sockaddr_dn bind_sockaddr; int status; ! memset(&bind_sockaddr, 0, sizeof(bind_sockaddr)); bind_sockaddr.sdn_family = AF_DECnet; --- 757,761 ---- struct sockaddr_dn bind_sockaddr; int status; ! memset(&bind_sockaddr, 0, sizeof(bind_sockaddr)); bind_sockaddr.sdn_family = AF_DECnet; *************** *** 752,756 **** strcpy(bind_sockaddr.sdn_objname, object); ! status = bind(sockfd, (struct sockaddr *)&bind_sockaddr, sizeof(bind_sockaddr)); if (status) --- 765,769 ---- strcpy(bind_sockaddr.sdn_objname, object); ! status = bind(sockfd, (struct sockaddr *)&bind_sockaddr, sizeof(bind_sockaddr)); if (status) *************** *** 769,773 **** struct sockaddr_dn bind_sockaddr; int status; ! memset(&bind_sockaddr, 0, sizeof(bind_sockaddr)); bind_sockaddr.sdn_family = AF_DECnet; --- 782,786 ---- struct sockaddr_dn bind_sockaddr; int status; ! memset(&bind_sockaddr, 0, sizeof(bind_sockaddr)); bind_sockaddr.sdn_family = AF_DECnet; *************** *** 776,780 **** bind_sockaddr.sdn_objnamel = 0; ! status = bind(sockfd, (struct sockaddr *)&bind_sockaddr, sizeof(bind_sockaddr)); if (status) --- 789,793 ---- bind_sockaddr.sdn_objnamel = 0; ! status = bind(sockfd, (struct sockaddr *)&bind_sockaddr, sizeof(bind_sockaddr)); if (status) *************** *** 792,801 **** // just return 0 (stdin's file descriptor). otherwise we // bind to the object and wait. When we get a connection we fork ! // and (optionally) setuid, and return. The parent then loops back (ie it // never returns). ! // // This is the keystone of all DECnet daemons that can be called from dnetd // ! int dnet_daemon(int object, char *named_object, int verbosity, bool do_fork) { --- 805,814 ---- // just return 0 (stdin's file descriptor). otherwise we // bind to the object and wait. When we get a connection we fork ! // and (optionally) setuid, and return. The parent then loops back (ie it // never returns). ! // // This is the keystone of all DECnet daemons that can be called from dnetd // ! int dnet_daemon(int object, char *named_object, int verbosity, bool do_fork) { *************** *** 811,815 **** memset(&sa, 0, sizeof(sa)); ! // Are we the execed child of dnetd? if (getsockname(STDIN_FILENO, (struct sockaddr *)&sa, &namelen) == 0) --- 824,828 ---- memset(&sa, 0, sizeof(sa)); ! // Are we the execed child of dnetd? if (getsockname(STDIN_FILENO, (struct sockaddr *)&sa, &namelen) == 0) *************** *** 841,853 **** perror("server: can't fork"); exit(2); ! case 0: // child break; ! default: // Parent. if (verbosity > 1) printf("server: forked process %d\n", pid); ! exit(0); } ! // Detach ourself from the calling environment for (i=0; i<FD_SETSIZE; i++) --- 854,866 ---- perror("server: can't fork"); exit(2); ! case 0: // child break; ! default: // Parent. if (verbosity > 1) printf("server: forked process %d\n", pid); ! exit(0); } ! // Detach ourself from the calling environment for (i=0; i<FD_SETSIZE; i++) *************** *** 869,873 **** siga.sa_flags = 0; sigaction(SIGCHLD, &siga, NULL); ! siga.sa_handler=sigterm; sigaction(SIGTERM, &siga, NULL); --- 882,886 ---- siga.sa_flags = 0; sigaction(SIGCHLD, &siga, NULL); ! siga.sa_handler=sigterm; sigaction(SIGTERM, &siga, NULL); *************** *** 877,881 **** // Create the socket ! if ((sockfd=socket(AF_DECnet,SOCK_SEQPACKET,DNPROTO_NSP)) == -1) { snprintf(errstring, sizeof(errstring), "socket failed: %s", strerror(errno)); --- 890,894 ---- // Create the socket ! if ((sockfd=socket(AF_DECnet,SOCK_SEQPACKET,DNPROTO_NSP)) == -1) { snprintf(errstring, sizeof(errstring), "socket failed: %s", strerror(errno)); *************** *** 887,896 **** setsockopt(sockfd, DNPROTO_NSP, SO_CONDATA, &optdata, sizeof(optdata)); ! #ifdef DSO_ACCEPTMODE acceptmode = ACC_DEFER; setsockopt(sockfd, DNPROTO_NSP, DSO_ACCEPTMODE, &acceptmode, 4); #endif ! // Bind the object if (object) --- 900,909 ---- setsockopt(sockfd, DNPROTO_NSP, SO_CONDATA, &optdata, sizeof(optdata)); ! #ifdef DSO_ACCEPTMODE acceptmode = ACC_DEFER; setsockopt(sockfd, DNPROTO_NSP, DSO_ACCEPTMODE, &acceptmode, 4); #endif ! // Bind the object if (object) *************** *** 902,906 **** if (named_object) bind_status = bind_name(sockfd, named_object); ! else bind_status = bind_wild(sockfd); } --- 915,919 ---- if (named_object) bind_status = bind_name(sockfd, named_object); ! else bind_status = bind_wild(sockfd); } *************** *** 912,916 **** return -1; // Can't bind } ! if (verbose) DNETLOG((LOG_INFO, "Ready\n")); --- 925,929 ---- return -1; // Can't bind } ! if (verbose) DNETLOG((LOG_INFO, "Ready\n")); *************** *** 920,924 **** int fork_fail = 0; int newone; ! // Wait for a new connection. newone = waitfor(sockfd); --- 933,937 ---- int fork_fail = 0; int newone; ! // Wait for a new connection. newone = waitfor(sockfd); *************** *** 934,938 **** exit(100); } ! // Oh no, it all went horribly wrong. DNETLOG((LOG_ERR, "Fork_and_setuid failed: %s\n", lasterror)); --- 947,951 ---- exit(100); } ! // Oh no, it all went horribly wrong. DNETLOG((LOG_ERR, "Fork_and_setuid failed: %s\n", lasterror)); *************** *** 943,947 **** return newone; break; ! default: // parent, just tidy up and loop back fork_fail = 0; --- 956,960 ---- return newone; break; ! default: // parent, just tidy up and loop back fork_fail = 0; *************** *** 965,969 **** optdata.opt_optl=len; if (len && data) memcpy(optdata.opt_data, data, len); ! setsockopt(sockfd, DNPROTO_NSP, DSO_CONDATA, &optdata, sizeof(optdata)); --- 978,982 ---- optdata.opt_optl=len; if (len && data) memcpy(optdata.opt_data, data, len); ! setsockopt(sockfd, DNPROTO_NSP, DSO_CONDATA, &optdata, sizeof(optdata)); |