summaryrefslogtreecommitdiff
path: root/libtac
diff options
context:
space:
mode:
Diffstat (limited to 'libtac')
-rw-r--r--libtac/lib/acct_r.c30
-rw-r--r--libtac/lib/acct_s.c16
-rw-r--r--libtac/lib/authen_r.c30
-rw-r--r--libtac/lib/authen_s.c15
-rw-r--r--libtac/lib/author_r.c29
-rw-r--r--libtac/lib/author_s.c8
-rw-r--r--libtac/lib/connect.c4
-rw-r--r--libtac/lib/cont_s.c15
-rw-r--r--libtac/lib/crypt.c2
-rw-r--r--libtac/lib/hdr_check.c8
-rw-r--r--libtac/lib/header.c2
-rw-r--r--libtac/lib/magic.c2
12 files changed, 88 insertions, 73 deletions
diff --git a/libtac/lib/acct_r.c b/libtac/lib/acct_r.c
index 0f23d04..ff651d3 100644
--- a/libtac/lib/acct_r.c
+++ b/libtac/lib/acct_r.c
@@ -48,7 +48,8 @@ int tac_account_read(int fd, struct areply *re) {
"%s: reply timeout after %d secs", __FUNCTION__, tac_timeout))
re->msg = xstrdup(acct_syserr_msg);
re->status = LIBTAC_STATUS_READ_TIMEOUT;
- goto AcctExit;
+ free(tb);
+ return re->status;
}
r=read(fd, &th, TAC_PLUS_HDR_SIZE);
@@ -58,7 +59,8 @@ int tac_account_read(int fd, struct areply *re) {
r, TAC_PLUS_HDR_SIZE))
re->msg = xstrdup(acct_syserr_msg);
re->status = LIBTAC_STATUS_SHORT_HDR;
- goto AcctExit;
+ free(tb);
+ return re->status;
}
/* check the reply fields in header */
@@ -66,7 +68,10 @@ int tac_account_read(int fd, struct areply *re) {
if(msg != NULL) {
re->msg = xstrdup(msg);
re->status = LIBTAC_STATUS_PROTOCOL_ERR;
- goto AcctExit;
+ free(tb);
+ TACDEBUG((LOG_DEBUG, "%s: exit status=%d, status message \"%s\"",\
+ __FUNCTION__, re->status, re->msg != NULL ? re->msg : ""))
+ return re->status;
}
len_from_header=ntohl(th.datalength);
@@ -79,7 +84,8 @@ int tac_account_read(int fd, struct areply *re) {
"%s: reply timeout after %d secs", __FUNCTION__, tac_timeout))
re->msg = xstrdup(acct_syserr_msg);
re->status = LIBTAC_STATUS_READ_TIMEOUT;
- goto AcctExit;
+ free(tb);
+ return re->status;
}
r=read(fd, tb, len_from_header);
@@ -90,7 +96,8 @@ int tac_account_read(int fd, struct areply *re) {
r, len_from_header))
re->msg = xstrdup(acct_syserr_msg);
re->status = LIBTAC_STATUS_SHORT_BODY;
- goto AcctExit;
+ free(tb);
+ return re->status;
}
/* decrypt the body */
@@ -110,7 +117,8 @@ int tac_account_read(int fd, struct areply *re) {
__FUNCTION__))
re->msg = xstrdup(acct_syserr_msg);
re->status = LIBTAC_STATUS_PROTOCOL_ERR;
- goto AcctExit;
+ free(tb);
+ return re->status;
}
/* save status and clean up */
@@ -125,9 +133,10 @@ int tac_account_read(int fd, struct areply *re) {
/* server logged our request successfully */
if (tb->status == TAC_PLUS_ACCT_STATUS_SUCCESS) {
TACDEBUG((LOG_DEBUG, "%s: accounted ok", __FUNCTION__))
- if (!re->msg) re->msg=xstrdup(acct_ok_msg);
+ if (!re->msg) re->msg = xstrdup(acct_ok_msg);
re->status = tb->status;
- goto AcctExit;
+ free(tb);
+ return re->status;
}
TACDEBUG((LOG_DEBUG, "%s: accounting failed, server reply status=%d",\
@@ -145,9 +154,6 @@ int tac_account_read(int fd, struct areply *re) {
break;
}
-AcctExit:
free(tb);
- TACDEBUG((LOG_DEBUG, "%s: exit status=%d, status message \"%s\"",\
- __FUNCTION__, re->status, re->msg != NULL ? re->msg : ""))
- return(re->status);
+ return re->status;
}
diff --git a/libtac/lib/acct_s.c b/libtac/lib/acct_s.c
index dd3dff9..51d2715 100644
--- a/libtac/lib/acct_s.c
+++ b/libtac/lib/acct_s.c
@@ -46,7 +46,7 @@ int tac_account_send(int fd, int type, const char *user, char *tty,
/* u_char *pktp; */ /* obsolute */
int ret = 0;
- th=_tac_req_header(TAC_PLUS_ACCT, 0);
+ th = _tac_req_header(TAC_PLUS_ACCT, 0);
/* set header options */
th->version=TAC_PLUS_VER_0;
@@ -64,7 +64,7 @@ int tac_account_send(int fd, int type, const char *user, char *tty,
tb.flags=(u_char) type;
tb.authen_method=tac_authen_method;
tb.priv_lvl=tac_priv_lvl;
- if(strcmp(tac_login,"chap") == 0) {
+ if (strcmp(tac_login,"chap") == 0) {
tb.authen_type=TAC_PLUS_AUTHEN_TYPE_CHAP;
} else if(strcmp(tac_login,"login") == 0) {
tb.authen_type=TAC_PLUS_AUTHEN_TYPE_ASCII;
@@ -82,7 +82,7 @@ int tac_account_send(int fd, int type, const char *user, char *tty,
/* fill attribute length fields */
a = attr;
- while(a) {
+ while (a) {
pktl = pkt_len;
pkt_len += sizeof(a->attr_len);
pkt = (u_char*) xrealloc(pkt, pkt_len);
@@ -132,13 +132,14 @@ int tac_account_send(int fd, int type, const char *user, char *tty,
th->datalength = htonl(pkt_len);
/* write header */
- w=write(fd, th, TAC_PLUS_HDR_SIZE);
+ w = write(fd, th, TAC_PLUS_HDR_SIZE);
if(w < TAC_PLUS_HDR_SIZE) {
TACSYSLOG((LOG_ERR, "%s: short write on header, wrote %d of %d: %m",\
__FUNCTION__, w, TAC_PLUS_HDR_SIZE))
- ret = LIBTAC_STATUS_WRITE_ERR;
- goto AcctExit;
+ free(pkt);
+ free(th);
+ return LIBTAC_STATUS_WRITE_ERR;
}
/* encrypt packet body */
@@ -152,9 +153,8 @@ int tac_account_send(int fd, int type, const char *user, char *tty,
ret = LIBTAC_STATUS_WRITE_ERR;
}
-AcctExit:
free(pkt);
free(th);
TACDEBUG((LOG_DEBUG, "%s: exit status=%d", __FUNCTION__, ret))
- return(ret);
+ return ret;
}
diff --git a/libtac/lib/authen_r.c b/libtac/lib/authen_r.c
index cd2ab2a..7d54cbc 100644
--- a/libtac/lib/authen_r.c
+++ b/libtac/lib/authen_r.c
@@ -49,7 +49,8 @@ int tac_authen_read(int fd) {
TACSYSLOG((LOG_ERR,\
"%s: reply timeout after %d secs", __FUNCTION__, tac_timeout))
status=LIBTAC_STATUS_READ_TIMEOUT;
- goto AuthenExit;
+ free(tb);
+ return status;
}
r = read(fd, &th, TAC_PLUS_HDR_SIZE);
if (r < TAC_PLUS_HDR_SIZE) {
@@ -58,14 +59,16 @@ int tac_authen_read(int fd) {
__FUNCTION__,\
r, TAC_PLUS_HDR_SIZE))
status=LIBTAC_STATUS_SHORT_HDR;
- goto AuthenExit;
+ free(tb);
+ return status;
}
/* check the reply fields in header */
msg = _tac_check_header(&th, TAC_PLUS_AUTHEN);
if(msg != NULL) {
status = LIBTAC_STATUS_PROTOCOL_ERR;
- goto AuthenExit;
+ free(tb);
+ return status;
}
len_from_header = ntohl(th.datalength);
@@ -84,8 +87,9 @@ int tac_authen_read(int fd) {
"%s: short reply body, read %d of %d: %m",\
__FUNCTION__,\
r, len_from_header))
- status=LIBTAC_STATUS_SHORT_BODY;
- goto AuthenExit;
+ status = LIBTAC_STATUS_SHORT_BODY;
+ free(tb);
+ return status;
}
/* decrypt the body */
@@ -104,8 +108,9 @@ int tac_authen_read(int fd) {
TACSYSLOG((LOG_ERR,\
"%s: inconsistent reply body, incorrect key?",\
__FUNCTION__))
- status=LIBTAC_STATUS_PROTOCOL_ERR;
- goto AuthenExit;
+ status = LIBTAC_STATUS_PROTOCOL_ERR;
+ free(tb);
+ return status;
}
/* save status and clean up */
@@ -115,21 +120,20 @@ int tac_authen_read(int fd) {
/* server authenticated username and password successfully */
if (r == TAC_PLUS_AUTHEN_STATUS_PASS) {
TACDEBUG((LOG_DEBUG, "%s: authentication ok", __FUNCTION__))
- goto AuthenExit;
+ free(tb);
+ return status;
}
/* server ask for continue packet with password */
if (r == TAC_PLUS_AUTHEN_STATUS_GETPASS) {
TACDEBUG((LOG_DEBUG, "%s: continue packet with password needed", __FUNCTION__))
- goto AuthenExit;
+ free(tb);
+ return status;
}
TACDEBUG((LOG_DEBUG, "%s: authentication failed, server reply status=%d",\
__FUNCTION__, r))
-AuthenExit:
free(tb);
- TACDEBUG((LOG_DEBUG, "%s: exit status=%d",\
- __FUNCTION__, status))
- return(status);
+ return status;
} /* tac_authen_read */
diff --git a/libtac/lib/authen_s.c b/libtac/lib/authen_s.c
index d241839..4983a01 100644
--- a/libtac/lib/authen_s.c
+++ b/libtac/lib/authen_s.c
@@ -116,8 +116,10 @@ int tac_authen_send(int fd, const char *user, char *pass, char *tty,
TACSYSLOG((LOG_ERR,\
"%s: short write on header, wrote %d of %d: %m",\
__FUNCTION__, w, TAC_PLUS_HDR_SIZE))
- ret = LIBTAC_STATUS_WRITE_ERR;
- goto AuthenExit;
+ free(token);
+ free(pkt);
+ free(th);
+ return LIBTAC_STATUS_WRITE_ERR;
}
/* build the packet */
@@ -139,8 +141,10 @@ int tac_authen_send(int fd, const char *user, char *pass, char *tty,
if (pkt_len != bodylength) {
TACSYSLOG((LOG_ERR, "%s: bodylength %d != pkt_len %d",\
__FUNCTION__, bodylength, pkt_len))
- ret = LIBTAC_STATUS_ASSEMBLY_ERR;
- goto AuthenExit;
+ free(token);
+ free(pkt);
+ free(th);
+ return LIBTAC_STATUS_ASSEMBLY_ERR;
}
/* encrypt the body */
@@ -154,10 +158,9 @@ int tac_authen_send(int fd, const char *user, char *pass, char *tty,
ret = LIBTAC_STATUS_WRITE_ERR;
}
-AuthenExit:
free(token);
free(pkt);
free(th);
TACDEBUG((LOG_DEBUG, "%s: exit status=%d", __FUNCTION__, ret))
- return(ret);
+ return ret;
} /* tac_authen_send */
diff --git a/libtac/lib/author_r.c b/libtac/lib/author_r.c
index 8d52c0a..915d7fd 100644
--- a/libtac/lib/author_r.c
+++ b/libtac/lib/author_r.c
@@ -56,7 +56,8 @@ int tac_author_read(int fd, struct areply *re) {
"%s: reply timeout after %d secs", __FUNCTION__, tac_timeout))
re->msg = xstrdup(author_syserr_msg);
re->status = LIBTAC_STATUS_READ_TIMEOUT;
- goto AuthorExit;
+ free(tb);
+ return re->status;
}
r = read(fd, &th, TAC_PLUS_HDR_SIZE);
@@ -66,7 +67,8 @@ int tac_author_read(int fd, struct areply *re) {
r, TAC_PLUS_HDR_SIZE))
re->msg = xstrdup(author_syserr_msg);
re->status = LIBTAC_STATUS_SHORT_HDR;
- goto AuthorExit;
+ free(tb);
+ return re->status;
}
/* check header consistency */
@@ -75,7 +77,8 @@ int tac_author_read(int fd, struct areply *re) {
/* no need to process body if header is broken */
re->msg = xstrdup(msg);
re->status = LIBTAC_STATUS_PROTOCOL_ERR;
- goto AuthorExit;
+ free(tb);
+ return re->status;
}
len_from_header = ntohl(th.datalength);
@@ -89,7 +92,8 @@ int tac_author_read(int fd, struct areply *re) {
"%s: reply timeout after %d secs", __FUNCTION__, tac_timeout))
re->msg = xstrdup(author_syserr_msg);
re->status = LIBTAC_STATUS_READ_TIMEOUT;
- goto AuthorExit;
+ free(tb);
+ return re->status;
}
r = read(fd, tb, len_from_header);
if (r < len_from_header) {
@@ -98,7 +102,8 @@ int tac_author_read(int fd, struct areply *re) {
r, len_from_header))
re->msg = xstrdup(author_syserr_msg);
re->status = LIBTAC_STATUS_SHORT_BODY;
- goto AuthorExit;
+ free(tb);
+ return re->status;
}
/* decrypt the body */
@@ -129,7 +134,8 @@ int tac_author_read(int fd, struct areply *re) {
__FUNCTION__))
re->msg = xstrdup(protocol_err_msg);
re->status = LIBTAC_STATUS_PROTOCOL_ERR;
- goto AuthorExit;
+ free(tb);
+ return re->status;
}
/* packet seems to be consistent, prepare return messages */
@@ -207,9 +213,9 @@ int tac_author_read(int fd, struct areply *re) {
pktp++;
}
}
-
- goto AuthorExit;
- break;
+ free(tb);
+ return re->status;
+ break;
}
TACDEBUG((LOG_DEBUG, "%s: authorization failed, server reply status=%d",\
@@ -229,9 +235,6 @@ int tac_author_read(int fd, struct areply *re) {
re->status=TAC_PLUS_AUTHOR_STATUS_ERROR;
}
-AuthorExit:
free(tb);
- TACDEBUG((LOG_DEBUG, "%s: exit status=%d, status message \"%s\"",\
- __FUNCTION__, re->status, re->msg != NULL ? re->msg : ""))
- return(re->status);
+ return re->status;
}
diff --git a/libtac/lib/author_s.c b/libtac/lib/author_s.c
index 53b7c89..c82d6e4 100644
--- a/libtac/lib/author_s.c
+++ b/libtac/lib/author_s.c
@@ -140,8 +140,9 @@ int tac_author_send(int fd, const char *user, char *tty, char *rem_addr,
TACSYSLOG((LOG_ERR,\
"%s: short write on header, wrote %d of %d: %m",\
__FUNCTION__, w, TAC_PLUS_HDR_SIZE))
- ret = LIBTAC_STATUS_WRITE_ERR;
- goto AuthorExit;
+ free(pkt);
+ free(th);
+ return LIBTAC_STATUS_WRITE_ERR;
}
/* encrypt packet body */
@@ -156,9 +157,8 @@ int tac_author_send(int fd, const char *user, char *tty, char *rem_addr,
ret = LIBTAC_STATUS_WRITE_ERR;
}
-AuthorExit:
free(pkt);
free(th);
TACDEBUG((LOG_DEBUG, "%s: exit status=%d", __FUNCTION__, ret))
- return(ret);
+ return ret;
}
diff --git a/libtac/lib/connect.c b/libtac/lib/connect.c
index bbbb270..15dc756 100644
--- a/libtac/lib/connect.c
+++ b/libtac/lib/connect.c
@@ -60,7 +60,7 @@ int tac_connect(struct addrinfo **server, char **key, int servers) {
/* all attempts failed if fd is still < 0 */
TACDEBUG((LOG_DEBUG, "%s: exit status=%d",__FUNCTION__, fd))
- return(fd);
+ return fd;
} /* tac_connect */
@@ -164,7 +164,7 @@ int tac_connect_single(struct addrinfo *server, char *key) {
TACDEBUG((LOG_DEBUG, "%s: exit status=%d (fd=%d)",\
__FUNCTION__, retval < 0 ? retval:0, fd))
- return(retval);
+ return retval;
} /* tac_connect_single */
diff --git a/libtac/lib/cont_s.c b/libtac/lib/cont_s.c
index a438a63..8382bc5 100644
--- a/libtac/lib/cont_s.c
+++ b/libtac/lib/cont_s.c
@@ -64,8 +64,9 @@ int tac_cont_send(int fd, char *pass) {
if (w < 0 || w < TAC_PLUS_HDR_SIZE) {
TACSYSLOG((LOG_ERR, "%s: short write on header, wrote %d of %d: %m",\
__FUNCTION__, w, TAC_PLUS_HDR_SIZE))
- ret=LIBTAC_STATUS_WRITE_ERR;
- goto ContExit;
+ free(pkt);
+ free(th);
+ return LIBTAC_STATUS_WRITE_ERR;
}
/* build the packet */
@@ -81,8 +82,9 @@ int tac_cont_send(int fd, char *pass) {
TACSYSLOG((LOG_ERR,\
"%s: bodylength %d != pkt_len %d",\
__FUNCTION__, bodylength, pkt_len))
- ret=LIBTAC_STATUS_ASSEMBLY_ERR;
- goto ContExit;
+ free(pkt);
+ free(th);
+ return LIBTAC_STATUS_ASSEMBLY_ERR;
}
/* encrypt the body */
@@ -96,11 +98,8 @@ int tac_cont_send(int fd, char *pass) {
ret=LIBTAC_STATUS_WRITE_ERR;
}
-ContExit:
-
free(pkt);
free(th);
-
TACDEBUG((LOG_DEBUG, "%s: exit status=%d", __FUNCTION__, ret))
- return(ret);
+ return ret;
} /* tac_cont_send */
diff --git a/libtac/lib/crypt.c b/libtac/lib/crypt.c
index 645cf8e..51ea669 100644
--- a/libtac/lib/crypt.c
+++ b/libtac/lib/crypt.c
@@ -79,7 +79,7 @@ u_char *_tac_md5_pad(int len, HDR *hdr) {
}
free(buf);
- return(pad);
+ return pad;
} /* _tac_md5_pad */
diff --git a/libtac/lib/hdr_check.c b/libtac/lib/hdr_check.c
index f0f0583..75c13d4 100644
--- a/libtac/lib/hdr_check.c
+++ b/libtac/lib/hdr_check.c
@@ -35,17 +35,17 @@ char *_tac_check_header(HDR *th, int type) {
TACSYSLOG((LOG_ERR,\
"%s: unrelated reply, type %d, expected %d",\
__FUNCTION__, th->type, type))
- return(protocol_err_msg);
+ return protocol_err_msg;
} else if((th->seq_no != 2) && (th->seq_no != 4)) {
TACSYSLOG((LOG_ERR, "%s: not a reply - seq_no %d != {2,4}",\
__FUNCTION__, th->seq_no))
- return(protocol_err_msg);
+ return protocol_err_msg;
} /* else if(ntohl(th->session_id) != session_id) {
TACSYSLOG((LOG_ERR,\
"%s: unrelated reply, received session_id %d != sent %d",\
__FUNCTION__, ntohl(th->session_id), session_id))
- return(protocol_err_msg);
+ return protocol_err_msg;
} */
- return(NULL); /* header is ok */
+ return NULL; /* header is ok */
} /* check header */
diff --git a/libtac/lib/header.c b/libtac/lib/header.c
index bb24918..1ae5c17 100644
--- a/libtac/lib/header.c
+++ b/libtac/lib/header.c
@@ -76,5 +76,5 @@ HDR *_tac_req_header(u_char type, int cont_session) {
session_id = magic();
th->session_id = htonl(session_id);
- return(th);
+ return th;
}
diff --git a/libtac/lib/magic.c b/libtac/lib/magic.c
index 3b809eb..d795088 100644
--- a/libtac/lib/magic.c
+++ b/libtac/lib/magic.c
@@ -84,7 +84,7 @@ magic()
if(rfd > -1) {
bytes = read(rfd, &ret, sizeof(ret));
- return(ret);
+ return ret;
}
else
return (u_int32_t) mrand48();