Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/networking/isrv_identd.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/networking/isrv_identd.c
r3232 r3621 19 19 20 20 #include "libbb.h" 21 #include "common_bufsiz.h" 21 22 #include <syslog.h> 22 23 #include "isrv.h" … … 26 27 typedef struct identd_buf_t { 27 28 int pos; 28 int fd_flag; 29 char buf[64 - 2*sizeof(int)]; 29 char buf[64 - sizeof(int)]; 30 30 } identd_buf_t; 31 31 … … 43 43 return peer; /* failure, unregister peer */ 44 44 45 buf->fd_flag = fcntl(fd, F_GETFL) | O_NONBLOCK;45 ndelay_on(fd); 46 46 isrv_want_rd(state, fd); 47 47 return 0; … … 52 52 identd_buf_t *buf = *paramp; 53 53 char *cur, *p; 54 int retval = 0; /* session is ok (so far) */55 54 int sz; 56 55 57 56 cur = buf->buf + buf->pos; 58 57 59 if (buf->fd_flag & O_NONBLOCK) 60 fcntl(fd, F_SETFL, buf->fd_flag); 61 sz = safe_read(fd, cur, sizeof(buf->buf) - buf->pos); 58 sz = safe_read(fd, cur, sizeof(buf->buf) - 1 - buf->pos); 62 59 63 60 if (sz < 0) { 64 61 if (errno != EAGAIN) 65 goto term; /* terminate this session if !EAGAIN */66 goto ok;62 goto term; 63 return 0; /* "session is ok" */ 67 64 } 68 65 … … 72 69 if (p) 73 70 *p = '\0'; 74 if (!p && sz && buf->pos <= (int)sizeof(buf->buf)) 75 goto ok; 71 if (!p && sz) 72 return 0; /* "session is ok" */ 73 76 74 /* Terminate session. If we are in server mode, then 77 75 * fd is still in nonblocking mode - we never block here */ 78 if (fd == 0) fd++; /* inetd mode? then write to fd 1 */ 76 if (fd == 0) 77 fd++; /* inetd mode? then write to fd 1 */ 79 78 fdprintf(fd, "%s : USERID : UNIX : %s\r\n", buf->buf, bogouser); 79 /* 80 * Why bother if we are going to close fd now anyway? 81 * if (server) 82 * ndelay_off(fd); 83 */ 80 84 term: 81 85 free(buf); 82 retval = 1; /* terminate */ 83 ok: 84 if (buf->fd_flag & O_NONBLOCK) 85 fcntl(fd, F_SETFL, buf->fd_flag & ~O_NONBLOCK); 86 return retval; 86 return 1; /* "terminate" */ 87 87 } 88 88 … … 96 96 identd_buf_t *buf = xzalloc(sizeof(*buf)); 97 97 /* buf->pos = 0; - xzalloc did it */ 98 /* We do NOT want nonblocking I/O here! */99 /* buf->fd_flag = 0; - xzalloc did it */100 98 do 101 99 alarm(TIMEOUT); 100 /* Note: we do NOT want nonblocking I/O here! */ 102 101 while (do_rd(0, (void*)&buf) == 0); 103 102 } … … 118 117 int fd; 119 118 119 setup_common_bufsiz(); 120 120 121 opt = getopt32(argv, "fiwb:", &bind_address); 121 122 strcpy(bogouser, "nobody"); 122 123 if (argv[optind]) 123 strncpy(bogouser, argv[optind], sizeof(bogouser));124 strncpy(bogouser, argv[optind], COMMON_BUFSIZE - 1); 124 125 125 126 /* Daemonize if no -f and no -i and no -w */
Note:
See TracChangeset
for help on using the changeset viewer.