From 90f6ab2eceada8987fc6e5017ae415eade165c00 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 5 Jun 2013 01:47:40 +0200 Subject: Use tabs for indentation, not spaces. Signed-off-by: Ralf Baechle --- ax25/access.c | 34 ++--- ax25/ax25d.c | 14 +-- ax25/axgetput/axgetput.c | 12 +- ax25/axgetput/proto_bin.c | 72 +++++------ ax25/axgetput/util.c | 66 +++++----- ax25/axparms.c | 2 +- ax25/axspawn.c | 308 +++++++++++++++++++++++----------------------- ax25/rxecho.c | 10 +- 8 files changed, 259 insertions(+), 259 deletions(-) (limited to 'ax25') diff --git a/ax25/access.c b/ax25/access.c index 6fac554..1363238 100644 --- a/ax25/access.c +++ b/ax25/access.c @@ -82,23 +82,23 @@ char *generate_rand_pw(int len) if (len > PASSSIZE) len = PASSSIZE; - for (i = 0; i < len; i++) { - j = conv_random(10+26*2, 0); - if (j < 10) { - pass[i] = j + '0'; - continue; - } - j -= 10; - if (j < 26) { - pass[i] = j + 'A'; + for (i = 0; i < len; i++) { + j = conv_random(10+26*2, 0); + if (j < 10) { + pass[i] = j + '0'; continue; - } - j -= 26; - pass[i] = j + 'a'; - } - pass[len] = 0; + } + j -= 10; + if (j < 26) { + pass[i] = j + 'A'; + continue; + } + j -= 26; + pass[i] = j + 'a'; + } + pass[len] = 0; - return pass; + return pass; } /*--------------------------------------------------------------------------*/ @@ -357,7 +357,7 @@ char *read_pwd (struct passwd *pw, int *pwtype) for (p = pass; *p && !isspace(*p & 0xff); p++) ; *p = 0; - if ( (*pwtype & PW_MD5) && !Strcasecmp(p_buf, "md5") ) { + if ( (*pwtype & PW_MD5) && !Strcasecmp(p_buf, "md5") ) { fclose(f); *pwtype = PW_MD5; goto found; @@ -391,6 +391,6 @@ found: end: *pwtype = (((*pwtype) & PW_CLEARTEXT) ? PW_CLEARTEXT : 0); - /* ^ may allow cleartext? - then cleartext, else deny */ + /* ^ may allow cleartext? - then cleartext, else deny */ return 0; } diff --git a/ax25/ax25d.c b/ax25/ax25d.c index ee921ab..472b461 100644 --- a/ax25/ax25d.c +++ b/ax25/ax25d.c @@ -535,7 +535,7 @@ int main(int argc, char *argv[]) /* debug */ syslog((LOG_DEBUG), "DEBUG: AX.25 %s (%s:%s) AX25.IP-VC host said: >%s<", User, Port, myAX25Name, buf); } - /* skip leading mess */ + /* skip leading mess */ for (p = buf; *p && (isspace(*p & 0xff) || *p == '\r'); p++) ; if (raxl->VCdiscOnLinkfailureMsg && !strncmp(p, "***", 3)) { /* format received line for debug purposes */ @@ -554,9 +554,9 @@ int main(int argc, char *argv[]) break; } /* per default, we discard all messages, - * because there's no useful combination - * using VC and pidText togegther - */ + * because there's no useful combination + * using VC and pidText togegther + */ if (raxl->VCloginEnable) goto login; } @@ -979,13 +979,13 @@ static int ReadConfig(void) reload_timer(60); continue; } - /* xlz - have to nuke this as this option is gone - * what should be here? + /* xlz - have to nuke this as this option is gone + * what should be here? if (iamdigi) { yes = 1; setsockopt(axl_port->fd, SOL_AX25, AX25_IAMDIGI, &yes, sizeof(yes)); } - */ + */ if (bind(axl_port->fd, (struct sockaddr *)&sockaddr, addrlen) < 0) { fprintf(stderr, "ax25d: bind: %s on port %s\n", strerror(errno), axl_port->port); diff --git a/ax25/axgetput/axgetput.c b/ax25/axgetput/axgetput.c index c2f4d25..595215c 100644 --- a/ax25/axgetput/axgetput.c +++ b/ax25/axgetput/axgetput.c @@ -264,17 +264,17 @@ int main(int argc, char *argv[]) #define get_filename(f) { \ if (!strcmp(f, "-")) { \ if (mode % 2) \ - fdin_is_pipe = 1; \ - else \ - fdout_is_pipe = 1; \ + fdin_is_pipe = 1; \ + else \ + fdout_is_pipe = 1; \ } else { \ - strncpy(filename, f, sizeof(filename)-1); \ - filename[sizeof(filename)-1] = 0; \ + strncpy(filename, f, sizeof(filename)-1); \ + filename[sizeof(filename)-1] = 0; \ if (mode % 2) { \ if (fdin_is_pipe) \ fdin_is_pipe = 0; \ } else { \ - if (fdout_is_pipe) \ + if (fdout_is_pipe) \ fdout_is_pipe = 0; \ } \ } \ diff --git a/ax25/axgetput/proto_bin.c b/ax25/axgetput/proto_bin.c index d02249b..9be7a58 100644 --- a/ax25/axgetput/proto_bin.c +++ b/ax25/axgetput/proto_bin.c @@ -26,7 +26,7 @@ static int init_crc(void) crctab[i] = 0; for (j = 0; j < 8; j++) { if ((bittab[j] & i) != 0) { - crctab[i] = crctab[i] ^ crcbit[j]; + crctab[i] = crctab[i] ^ crcbit[j]; } } } @@ -113,7 +113,7 @@ int bput(void) return 1; } if (buf[len-1] == '\r' && len > 5 && !memcmp(buf, "#BIN#", 5)) { - break; + break; } if (len == sizeof(buf)) { sprintf(err_msg, "line to long\n"); @@ -139,12 +139,12 @@ int bput(void) break; default: if (*p == '|') { - msg_crc = (unsigned int ) atoi(p+1); + msg_crc = (unsigned int ) atoi(p+1); } else if (*p == '$') { - file_time = parse_sfbin_date_to_unix(p+1); + file_time = parse_sfbin_date_to_unix(p+1); } else { - strncpy(filename_given, p, sizeof(filename_given)-1); - filename_given[sizeof(filename_given)-1] = 0; + strncpy(filename_given, p, sizeof(filename_given)-1); + filename_given[sizeof(filename_given)-1] = 0; } } } @@ -159,8 +159,8 @@ int bput(void) if (!stat(filename, &statbuf)) { /* file exist */ if (unlink(filename)) { - sprintf(err_msg, "error: cannot unlink %s (%s)\n", filename, strerror(errno)); - goto abort; + sprintf(err_msg, "error: cannot unlink %s (%s)\n", filename, strerror(errno)); + goto abort; } } if ((fddata = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0640)) < 0) { @@ -194,7 +194,7 @@ int bput(void) if (!len) { save_close(fddata); if (!term_line) { - sprintf(err_msg, "error: unexpected end of file during read: %s\n", strerror(errno)); + sprintf(err_msg, "error: unexpected end of file during read: %s\n", strerror(errno)); return 1; } return 0; @@ -203,14 +203,14 @@ int bput(void) if (msg_crc) { int i; for (i = 0; i < len; i++) - crc = do_crc((int ) buf[i], 1, crc); + crc = do_crc((int ) buf[i], 1, crc); } if (buf[len-1] == '\r') { if (last_line_had_CR) { if (IS_BIN_ABORT(buf, len)) { /* "\r#ABORT#\r" was sent */ - if (!fdout_is_pipe) { + if (!fdout_is_pipe) { close(fddata); /* clean up */ unlink(filename); @@ -218,8 +218,8 @@ int bput(void) return 1; } if (term_line && len == len_termline && !memcmp(buf, term_line, len_termline)) { - /* sucessfully read until termination string */ - break; + /* sucessfully read until termination string */ + break; } } last_line_had_CR = 1; @@ -241,7 +241,7 @@ int bput(void) if (is_eof) { if (!term_line && len_read_left) { save_close(fddata); - goto abort; + goto abort; } break; } @@ -304,13 +304,13 @@ int bget(void) { } #define store_line(s, len) { \ - if (!(sl = (struct strlist *) malloc(sizeof(struct strlist *) + sizeof(size_t) + len))) \ + if (!(sl = (struct strlist *) malloc(sizeof(struct strlist *) + sizeof(size_t) + len))) \ return 1; \ sl->next = 0; \ sl->len = len; \ memcpy(sl->data, s, len); \ if (!stored_file) { \ - stored_file = sl; \ + stored_file = sl; \ } else { \ sl_tail->next = sl; \ } \ @@ -336,7 +336,7 @@ int bget(void) { while ((len = read(fddata, buf, BLOCKSIZ)) > 0) { int i; for (i = 0; i < len; i++) - crc = do_crc((int ) buf[i], 1, crc); + crc = do_crc((int ) buf[i], 1, crc); file_size += len; } if (len < 0) { @@ -356,17 +356,17 @@ int bget(void) { if (!is_stream || do_crc_only) { sprintf(err_msg, "error: not enough memory\n"); while ((len = read(fddata, buf, sizeof(buf))) > 0) { - int i; - for (i = 0; i < len; i++) - crc = do_crc((int ) buf[i], 1, crc); - file_size += len; + int i; + for (i = 0; i < len; i++) + crc = do_crc((int ) buf[i], 1, crc); + file_size += len; if (!do_crc_only) store_line(buf, len); } if (len < 0) { - sprintf(err_msg, "error: read failed (%s)\n", strerror(errno)); - close(fddata); - return 1; + sprintf(err_msg, "error: read failed (%s)\n", strerror(errno)); + close(fddata); + return 1; } *err_msg = 0; sprintf(buf, "\r#BIN#%ld#|%d#$%s#%s\r", file_size, crc, unix_to_sfbin_date_string(file_time), get_fixed_filename(filename, file_size, crc, 1)); @@ -396,7 +396,7 @@ int bget(void) { /* wait for answer */ for (;;) { - /* + /* * make sure we do not read from a pipe. fdout is also * assigned to the tty */ @@ -442,26 +442,26 @@ int bget(void) { FD_SET(fdin, &readfds); if (select(fdin+1, &readfds, 0, 0, &timeout) && FD_ISSET(fdin, &readfds)) { if ((len = read(fdin, buf, sizeof(buf))) < 0) { - sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno)); - save_close(fddata); - goto abort; + sprintf(err_msg, "read from tty failed (%s)\n", strerror(errno)); + save_close(fddata); + goto abort; } if (IS_BIN_ABORT(buf, len)) { - sprintf(err_msg, "Aborted by user request\n"); - save_close(fddata); - return 1; + sprintf(err_msg, "Aborted by user request\n"); + save_close(fddata); + return 1; } } /* read data */ if (!fdin_is_pipe || is_stream) { p_buf = buf; if ((len = my_read(fddata, buf, ((len_remains > BLOCKSIZ || is_stream) ? BLOCKSIZ : len_remains), &is_eof, 0)) < 1) { - save_close(fddata); - if (len < 0) { - sprintf(err_msg, "error: read failed (%s)\n", strerror(errno)); + save_close(fddata); + if (len < 0) { + sprintf(err_msg, "error: read failed (%s)\n", strerror(errno)); goto abort; - } - break; + } + break; } len_remains -= len; } else { diff --git a/ax25/axgetput/util.c b/ax25/axgetput/util.c index 98caeeb..f20937f 100644 --- a/ax25/axgetput/util.c +++ b/ax25/axgetput/util.c @@ -54,8 +54,8 @@ int my_read(int fd, char *s, int len_max, int *eof, char *p_break) if ((len = read(fd, s_curr, (p_break ? 1 : len_max))) < 1) { if (len == -1 && errno == EAGAIN) { - sleep(10); - continue; + sleep(10); + continue; } *eof = 1; /* @@ -89,8 +89,8 @@ int secure_write(int fd, char *s, int len_write) { int len; if ((len = write(fd, s, len_write_left_curr)) < 0) { if (len == -1 && errno == EAGAIN) { - sleep(10); - continue; + sleep(10); + continue; } return -1; } @@ -162,22 +162,22 @@ char *get_fixed_filename(char *line, long size, unsigned int msg_crc, int genera /* Linear day numbers of the respective 1sts in non-leap years. */ static int day_n[] = { 0,31,59,90,120,151,181,212,243,273,304,334,0,0,0,0 }; - /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */ + /* JanFebMarApr May Jun Jul Aug Sep Oct Nov Dec */ /*---------------------------------------------------------------------------*/ long date_dos2unix(unsigned short time,unsigned short date) { - int month,year; - long secs; - - month = ((date >> 5) & 15)-1; - year = date >> 9; - secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400* - ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && - month < 2 ? 1 : 0)+3653); - /* days since 1.1.70 plus 80's leap day */ - return secs; + int month,year; + long secs; + + month = ((date >> 5) & 15)-1; + year = date >> 9; + secs = (time & 31)*2+60*((time >> 5) & 63)+(time >> 11)*3600+86400* + ((date & 31)-1+day_n[month]+(year/4)+year*365-((year & 3) == 0 && + month < 2 ? 1 : 0)+3653); + /* days since 1.1.70 plus 80's leap day */ + return secs; } /*---------------------------------------------------------------------------*/ @@ -186,22 +186,22 @@ long date_dos2unix(unsigned short time,unsigned short date) void date_unix2dos(int unix_date,unsigned short *time, unsigned short *date) { - int day,year,nl_day,month; - - *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+ - (((unix_date/3600) % 24) << 11); - day = unix_date/86400-3652; - year = day/365; - if ((year+3)/4+365*year > day) year--; - day -= (year+3)/4+365*year; - if (day == 59 && !(year & 3)) { - nl_day = day; - month = 2; - } - else { - nl_day = (year & 3) || day <= 59 ? day : day-1; - for (month = 0; month < 12; month++) - if (day_n[month] > nl_day) break; - } - *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9); + int day,year,nl_day,month; + + *time = (unix_date % 60)/2+(((unix_date/60) % 60) << 5)+ + (((unix_date/3600) % 24) << 11); + day = unix_date/86400-3652; + year = day/365; + if ((year+3)/4+365*year > day) year--; + day -= (year+3)/4+365*year; + if (day == 59 && !(year & 3)) { + nl_day = day; + month = 2; + } + else { + nl_day = (year & 3) || day <= 59 ? day : day-1; + for (month = 0; month < 12; month++) + if (day_n[month] > nl_day) break; + } + *date = nl_day-day_n[month-1]+1+(month << 5)+(year << 9); } diff --git a/ax25/axparms.c b/ax25/axparms.c index 8decf93..1f1f6ca 100644 --- a/ax25/axparms.c +++ b/ax25/axparms.c @@ -319,7 +319,7 @@ int forward(int s, int argc, char *argv[]) return 1; } #else - fprintf(stderr, "axparms: Not compiled in with forwarding option.\n"); + fprintf(stderr, "axparms: Not compiled in with forwarding option.\n"); #endif /* HAVE_AX25_FWD_STRUCT */ return 0; diff --git a/ax25/axspawn.c b/ax25/axspawn.c index e92d3ac..9e74e85 100644 --- a/ax25/axspawn.c +++ b/ax25/axspawn.c @@ -776,7 +776,7 @@ void kick_wqueue(int dummy) if (w_buf->len > curr_len) { /* rewrite current buffer, and break */ w_buf->len -= curr_len; - for (q = w_buf->data, r = w_buf->data+curr_len, i = 0; i < w_buf->len; i++) + for (q = w_buf->data, r = w_buf->data+curr_len, i = 0; i < w_buf->len; i++) *q++ = *r++; break; } @@ -910,7 +910,7 @@ int write_ax25(char *s, int len, int kick) } while (j < len) { if ((j + 1 < len) && *(p + j) == '\r' && *(p + j + 1) == '\n') { - *(p + i) = '\r'; + *(p + i) = '\r'; j++; } else @@ -1148,9 +1148,9 @@ end_mkdirs: */ opt_shell = " -s \"/bin/sh\""; } - sprintf(command,"/usr/sbin/useradd -p \"%s\" -c %s -d %s -u %d -g %d -m %s%s", + sprintf(command,"/usr/sbin/useradd -p \"%s\" -c %s -d %s -u %d -g %d -m %s%s", ((policy_add_empty_password) ? "" : "+"), - username, userdir, uid, user_gid, newuser, opt_shell); + username, userdir, uid, user_gid, newuser, opt_shell); if (system(command) != 0) goto out; } else { @@ -1202,7 +1202,7 @@ end_mkdirs: * as an optimization. * -> mark #!... as ## */ - if (buf[0] == '#' && buf[1] == '!') + if (buf[0] == '#' && buf[1] == '!') buf[1] = '#'; first = 0; } @@ -1583,7 +1583,7 @@ again: if (pwtype == PW_MD5) ask_pw_md5(prompt, pass_want, pwd); else - ask_pw_sys(prompt, pass_want, pwd); + ask_pw_sys(prompt, pass_want, pwd); cnt = read_ax25(buf, sizeof(buf)-1); if (cnt <= 0) { @@ -1643,7 +1643,7 @@ again: break; case AF_ROSE: sax25.sax25_call = sockaddr.rose.srose_call; - break; + break; } ioctl(fds, SIOCAX25ADDUID, &sax25); close(fds); @@ -1659,36 +1659,36 @@ again: struct termios termios; char *shell = "/bin/sh"; - memset((char *) &termios, 0, sizeof(termios)); + memset((char *) &termios, 0, sizeof(termios)); - ioctl(0, TIOCSCTTY, (char *) 0); + ioctl(0, TIOCSCTTY, (char *) 0); termios.c_iflag = ICRNL | IXOFF; - termios.c_oflag = OPOST | ONLCR; - termios.c_cflag = CS8 | CREAD | CLOCAL; - termios.c_lflag = ISIG | ICANON; - termios.c_cc[VINTR] = /* 127 */ 0x03; - termios.c_cc[VQUIT] = 28; - termios.c_cc[VERASE] = 8; - termios.c_cc[VKILL] = 24; - termios.c_cc[VEOF] = 4; - cfsetispeed(&termios, B19200); - cfsetospeed(&termios, B19200); - tcsetattr(0, TCSANOW, &termios); + termios.c_oflag = OPOST | ONLCR; + termios.c_cflag = CS8 | CREAD | CLOCAL; + termios.c_lflag = ISIG | ICANON; + termios.c_cc[VINTR] = /* 127 */ 0x03; + termios.c_cc[VQUIT] = 28; + termios.c_cc[VERASE] = 8; + termios.c_cc[VKILL] = 24; + termios.c_cc[VEOF] = 4; + cfsetispeed(&termios, B19200); + cfsetospeed(&termios, B19200); + tcsetattr(0, TCSANOW, &termios); setutent(); - ut_line.ut_type = LOGIN_PROCESS; - ut_line.ut_pid = getpid(); - strncpy(ut_line.ut_line, ptyslave + 5, sizeof(ut_line.ut_line)); - strncpy(ut_line.ut_id, ptyslave + 8, sizeof(ut_line.ut_id)); - strncpy(ut_line.ut_user, "LOGIN", sizeof(ut_line.ut_user)); - strncpy(ut_line.ut_host, protocol, sizeof(ut_line.ut_host)); + ut_line.ut_type = LOGIN_PROCESS; + ut_line.ut_pid = getpid(); + strncpy(ut_line.ut_line, ptyslave + 5, sizeof(ut_line.ut_line)); + strncpy(ut_line.ut_id, ptyslave + 8, sizeof(ut_line.ut_id)); + strncpy(ut_line.ut_user, "LOGIN", sizeof(ut_line.ut_user)); + strncpy(ut_line.ut_host, protocol, sizeof(ut_line.ut_host)); gettimeofday(&tv, NULL); ut_line.ut_tv.tv_sec = tv.tv_sec; ut_line.ut_tv.tv_usec = tv.tv_usec; - ut_line.ut_addr = 0; - pututline(&ut_line); - endutent(); + ut_line.ut_addr = 0; + pututline(&ut_line); + endutent(); /* become process group leader, if we not already are */ if (getpid() != getsid(0)) { @@ -1696,8 +1696,8 @@ again: exit(1); } - chargc = 0; - envc = 0; + chargc = 0; + envc = 0; if (dumb_embedded_system) { int ret = -1; @@ -1709,18 +1709,18 @@ again: ret = -1; if (pw->pw_dir && *(pw->pw_dir)) p = pw->pw_dir; - ret = chdir(p); + ret = chdir(p); if (ret != 0) { p = "/tmp"; - chdir(p); + chdir(p); } - if ((envp[envc] = (char *) malloc(strlen(p)+6))) - sprintf(envp[envc++], "HOME=%s", p); - if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+6))) - sprintf(envp[envc++], "USER=%s", pw->pw_name); - if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+9))) - sprintf(envp[envc++], "LOGNAME=%s", pw->pw_name); + if ((envp[envc] = (char *) malloc(strlen(p)+6))) + sprintf(envp[envc++], "HOME=%s", p); + if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+6))) + sprintf(envp[envc++], "USER=%s", pw->pw_name); + if ((envp[envc] = (char *) malloc(strlen(pw->pw_name)+9))) + sprintf(envp[envc++], "LOGNAME=%s", pw->pw_name); if (pw->pw_shell && *(pw->pw_shell)) { shell = pw->pw_shell; @@ -1736,56 +1736,56 @@ again: } if (!p) p = shell; - chargv[chargc++] = p; - if ((envp[envc] = (char *) malloc(strlen(shell)+7))) - sprintf(envp[envc++], "SHELL=%s", shell); + chargv[chargc++] = p; + if ((envp[envc] = (char *) malloc(strlen(shell)+7))) + sprintf(envp[envc++], "SHELL=%s", shell); if (pw->pw_uid == 0) p = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; else p = "/bin:/usr/bin:/usr/local/bin"; - if ((envp[envc] = (char *) malloc(strlen(p)+6))) - sprintf(envp[envc++], "PATH=%s", p); + if ((envp[envc] = (char *) malloc(strlen(p)+6))) + sprintf(envp[envc++], "PATH=%s", p); } else { - chargv[chargc++] = "/bin/login"; - chargv[chargc++] = "-p"; + chargv[chargc++] = "/bin/login"; + chargv[chargc++] = "-p"; /* there exist several conectps: - * Historicaly, the special character '+' in the password - * field indicated that users may login via ax25, netrom, rose, - * etc.. - but not via other protocols like telnet. - * This secures the digipeater from abuse by inet access of - * non-hams. - * On the other hand, this leads to the problem that telent - * via HF, pop3, etc.. do not work. - * The "pwcheck == 2 method means, that the password is used on - * every login mechanism other than this axspawn program; - * here we do not rely on the password - the ax25 call of - * the ham is enough. We have already checked above, that - * the call of the user is valid (and not root, httpd, etc..); - * thus this method is safe here. - * Another mechanism (pwcheck == 3) is to check if the gid - * equals to user_gid preference. I prefer this way, because - * this approach gives the chance to temporary lock a user - * out (abuse, ..) by changing his gid in passwd to for e.g. - * 65534 (nogroup). - */ + * Historicaly, the special character '+' in the password + * field indicated that users may login via ax25, netrom, rose, + * etc.. - but not via other protocols like telnet. + * This secures the digipeater from abuse by inet access of + * non-hams. + * On the other hand, this leads to the problem that telent + * via HF, pop3, etc.. do not work. + * The "pwcheck == 2 method means, that the password is used on + * every login mechanism other than this axspawn program; + * here we do not rely on the password - the ax25 call of + * the ham is enough. We have already checked above, that + * the call of the user is valid (and not root, httpd, etc..); + * thus this method is safe here. + * Another mechanism (pwcheck == 3) is to check if the gid + * equals to user_gid preference. I prefer this way, because + * this approach gives the chance to temporary lock a user + * out (abuse, ..) by changing his gid in passwd to for e.g. + * 65534 (nogroup). + */ chargv[chargc++] = "-h"; chargv[chargc++] = protocol; - if (pwtype != PW_CLEARTEXT /* PW_SYS or PW_MD5 are already authenticated */ + if (pwtype != PW_CLEARTEXT /* PW_SYS or PW_MD5 are already authenticated */ || pwcheck == 2 || (pwcheck == 3 && (pw->pw_gid == user_gid || is_guest)) || !strcmp(pw->pw_passwd, "+")) - chargv[chargc++] = "-f"; - chargv[chargc++] = as_user; + chargv[chargc++] = "-f"; + chargv[chargc++] = as_user; } - chargv[chargc] = NULL; - - if ((envp[envc] = (char *) malloc(30))) - sprintf(envp[envc++], "AXCALL=%s", call); - if ((envp[envc] = (char *) malloc(30))) - sprintf(envp[envc++], "CALL=%s", user); - if ((envp[envc] = (char *) malloc(30))) - sprintf(envp[envc++], "PROTOCOL=%s", protocol); + chargv[chargc] = NULL; + + if ((envp[envc] = (char *) malloc(30))) + sprintf(envp[envc++], "AXCALL=%s", call); + if ((envp[envc] = (char *) malloc(30))) + sprintf(envp[envc++], "CALL=%s", user); + if ((envp[envc] = (char *) malloc(30))) + sprintf(envp[envc++], "PROTOCOL=%s", protocol); if ((envp[envc] = (char *) malloc(30))) sprintf(envp[envc++], "TERM=dumb"); /* SuSE bug (dump - tsts) */ /* other useful defaults */ @@ -1800,51 +1800,51 @@ again: exit(1); if (setuid(pw->pw_uid) == -1) exit(1); - execve(shell, chargv, envp); + execve(shell, chargv, envp); /* point of no return */ exit(1); } - execve(chargv[0], chargv, envp); + execve(chargv[0], chargv, envp); /* point of no return */ exit(1); - } - else if (pid > 0) - { - child_pid = 0; - signal(SIGHUP, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGINT, signal_handler); - signal(SIGQUIT, signal_handler); - - while(1) - { - FD_ZERO(&fds_read); - FD_ZERO(&fds_err); - FD_SET(0, &fds_read); - FD_SET(0, &fds_err); - if (wqueue_length <= paclen*7) + } + else if (pid > 0) + { + child_pid = 0; + signal(SIGHUP, signal_handler); + signal(SIGTERM, signal_handler); + signal(SIGINT, signal_handler); + signal(SIGQUIT, signal_handler); + + while(1) + { + FD_ZERO(&fds_read); + FD_ZERO(&fds_err); + FD_SET(0, &fds_read); + FD_SET(0, &fds_err); + if (wqueue_length <= paclen*7) FD_SET(fdmaster, &fds_read); - FD_SET(fdmaster, &fds_err); + FD_SET(fdmaster, &fds_err); - k = select(fdmaster+1, &fds_read, NULL, &fds_err, NULL); + k = select(fdmaster+1, &fds_read, NULL, &fds_err, NULL); - if (k > 0) - { - if (FD_ISSET(0, &fds_err)) - { + if (k > 0) + { + if (FD_ISSET(0, &fds_err)) + { if (huffman) { sprintf(buf,"\r//COMP 0\r"); write_ax25(buf, strlen(buf), 1); sleep(EXITDELAY); - } - kill(pid, SIGHUP); - cleanup(ptyslave+5); - return 1; - } - - if (FD_ISSET(fdmaster, &fds_err)) - { + } + kill(pid, SIGHUP); + cleanup(ptyslave+5); + return 1; + } + + if (FD_ISSET(fdmaster, &fds_err)) + { /* give the last packet in the timer controlled sendqueue a chance.. */ if (wqueue_length) { continue; @@ -1853,28 +1853,28 @@ again: sprintf(buf,"\r//COMP 0\r"); write_ax25(buf, strlen(buf), 1); sleep(EXITDELAY); - } - cleanup(ptyslave+5); - return 1; - } - - if (FD_ISSET(0, &fds_read)) - { - cnt = read_ax25(buf, sizeof(buf)); - if (cnt < 0) /* Connection died */ - { - kill(pid, SIGHUP); - cleanup(ptyslave+5); - return 1; - } else - write(fdmaster, buf, cnt); - } - - if (FD_ISSET(fdmaster, &fds_read)) - { - cnt = read(fdmaster, buf, (huffman ? 254 : sizeof(buf))); - if (cnt < 0) - { + } + cleanup(ptyslave+5); + return 1; + } + + if (FD_ISSET(0, &fds_read)) + { + cnt = read_ax25(buf, sizeof(buf)); + if (cnt < 0) /* Connection died */ + { + kill(pid, SIGHUP); + cleanup(ptyslave+5); + return 1; + } else + write(fdmaster, buf, cnt); + } + + if (FD_ISSET(fdmaster, &fds_read)) + { + cnt = read(fdmaster, buf, (huffman ? 254 : sizeof(buf))); + if (cnt < 0) + { /* give the last packet in the timer controlled sendqueue a chance.. */ if (wqueue_length) { continue; @@ -1883,36 +1883,36 @@ again: sprintf(buf,"\r//COMP 0\r"); write_ax25(buf, strlen(buf), 1); sleep(EXITDELAY); - } - cleanup(ptyslave+5); - return 1; /* Child died */ - } - write_ax25(buf, cnt, 0); - } - } else - if (k < 0 && errno != EINTR) - { + } + cleanup(ptyslave+5); + return 1; /* Child died */ + } + write_ax25(buf, cnt, 0); + } + } else + if (k < 0 && errno != EINTR) + { if (huffman) { sprintf(buf,"\r//COMP 0\r"); write_ax25(buf, strlen(buf), 1); sleep(EXITDELAY); - } - - kill(pid, SIGHUP); /* just in case... */ - cleanup(ptyslave+5); - return 0; - } - } - } - else - { + } + + kill(pid, SIGHUP); /* just in case... */ + cleanup(ptyslave+5); + return 0; + } + } + } + else + { write_ax25_static_line(MSG_CANNOTFORK); - syslog(LOG_ERR, "cannot fork %m, closing connection to %s\n", call); - sleep(EXITDELAY); - return 1; - } + syslog(LOG_ERR, "cannot fork %m, closing connection to %s\n", call); + sleep(EXITDELAY); + return 1; + } - sleep(EXITDELAY); + sleep(EXITDELAY); return 0; } diff --git a/ax25/rxecho.c b/ax25/rxecho.c index e9c7daa..ab862bb 100644 --- a/ax25/rxecho.c +++ b/ax25/rxecho.c @@ -455,7 +455,7 @@ int main(int argc, char **argv) } for (;;) { - alen = sa_len; + alen = sa_len; if ((size = recvfrom(s, buf, 1500, 0, psa, &alen)) == -1) { if (logging) { @@ -479,11 +479,11 @@ int main(int argc, char **argv) for (p = list; p != NULL; p = p->next) #ifdef USE_SOCKADDR_SLL - if (p->from_idx == from_idx && (check_calls(p, buf, size) == 0)) { - sll.sll_ifindex = p->to_idx; + if (p->from_idx == from_idx && (check_calls(p, buf, size) == 0)) { + sll.sll_ifindex = p->to_idx; #else - if ((strcmp(p->from, from_dev_name) == 0) && (check_calls(p, buf, size) == 0)) { - strcpy(psa->sa_data, p->to); + if ((strcmp(p->from, from_dev_name) == 0) && (check_calls(p, buf, size) == 0)) { + strcpy(psa->sa_data, p->to); #endif /* * cave: alen (set by recvfrom()) may > salen -- cgit v1.2.3