Skip to content

Commit

Permalink
Replace radlog(L_ERR with DEBUGE
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Apr 17, 2013
1 parent 08c5ba6 commit d31b92a
Show file tree
Hide file tree
Showing 86 changed files with 707 additions and 729 deletions.
2 changes: 1 addition & 1 deletion src/include/radiusd.h
Expand Up @@ -612,7 +612,7 @@ void rdebug_pair_list(int, REQUEST *, VALUE_PAIR *);
int log_err (char *);

/* util.c */
#define MEM(x) if (!(x)) { radlog(L_ERR, "Out of memory"); exit(1); }
#define MEM(x) if (!(x)) { DEBUGE("Out of memory"); exit(1); }
void (*reset_signal(int signo, void (*func)(int)))(int);
void request_free(REQUEST **request);
int rad_mkdir(char *directory, mode_t mode);
Expand Down
4 changes: 2 additions & 2 deletions src/main/client.c
Expand Up @@ -328,7 +328,7 @@ int client_add(RADCLIENT_LIST *clients, RADCLIENT *client)
return 1;
}

radlog(L_ERR, "Failed to add duplicate client %s",
DEBUGE("Failed to add duplicate client %s",
client->shortname);
return 0;
}
Expand Down Expand Up @@ -1206,7 +1206,7 @@ RADCLIENT *client_read(const char *filename, int in_server, int flag)

cs = cf_section_sub_find(cs, "client");
if (!cs) {
radlog(L_ERR, "No \"client\" section found in client file");
DEBUGE("No \"client\" section found in client file");
return NULL;
}

Expand Down
54 changes: 27 additions & 27 deletions src/main/command.c
Expand Up @@ -159,18 +159,18 @@ static int fr_server_domain_socket(const char *path)
struct stat buf;

if (!path) {
radlog(L_ERR, "No path provided, was NULL.");
DEBUGE("No path provided, was NULL.");
return -1;
}

len = strlen(path);
if (len >= sizeof(salocal.sun_path)) {
radlog(L_ERR, "Path too long in socket filename.");
DEBUGE("Path too long in socket filename.");
return -1;
}

if ((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
radlog(L_ERR, "Failed creating socket: %s",
DEBUGE("Failed creating socket: %s",
strerror(errno));
return -1;
}
Expand All @@ -186,7 +186,7 @@ static int fr_server_domain_socket(const char *path)
*/
if (stat(path, &buf) < 0) {
if (errno != ENOENT) {
radlog(L_ERR, "Failed to stat %s: %s",
DEBUGE("Failed to stat %s: %s",
path, strerror(errno));
close(sockfd);
return -1;
Expand All @@ -201,7 +201,7 @@ static int fr_server_domain_socket(const char *path)
&& !S_ISSOCK(buf.st_mode)
#endif
) {
radlog(L_ERR, "Cannot turn %s into socket", path);
DEBUGE("Cannot turn %s into socket", path);
close(sockfd);
return -1;
}
Expand All @@ -210,21 +210,21 @@ static int fr_server_domain_socket(const char *path)
* Refuse to open sockets not owned by us.
*/
if (buf.st_uid != geteuid()) {
radlog(L_ERR, "We do not own %s", path);
DEBUGE("We do not own %s", path);
close(sockfd);
return -1;
}

if (unlink(path) < 0) {
radlog(L_ERR, "Failed to delete %s: %s",
DEBUGE("Failed to delete %s: %s",
path, strerror(errno));
close(sockfd);
return -1;
}
}

if (bind(sockfd, (struct sockaddr *)&salocal, socklen) < 0) {
radlog(L_ERR, "Failed binding to %s: %s",
DEBUGE("Failed binding to %s: %s",
path, strerror(errno));
close(sockfd);
return -1;
Expand All @@ -235,14 +235,14 @@ static int fr_server_domain_socket(const char *path)
* doesn't seem to permit fchmod on domain sockets.
*/
if (chmod(path, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) < 0) {
radlog(L_ERR, "Failed setting permissions on %s: %s",
DEBUGE("Failed setting permissions on %s: %s",
path, strerror(errno));
close(sockfd);
return -1;
}

if (listen(sockfd, 8) < 0) {
radlog(L_ERR, "Failed listening to %s: %s",
DEBUGE("Failed listening to %s: %s",
path, strerror(errno));
close(sockfd);
return -1;
Expand All @@ -253,15 +253,15 @@ static int fr_server_domain_socket(const char *path)
int flags;

if ((flags = fcntl(sockfd, F_GETFL, NULL)) < 0) {
radlog(L_ERR, "Failure getting socket flags: %s",
DEBUGE("Failure getting socket flags: %s",
strerror(errno));
close(sockfd);
return -1;
}

flags |= O_NONBLOCK;
if( fcntl(sockfd, F_SETFL, flags) < 0) {
radlog(L_ERR, "Failure setting socket flags: %s",
DEBUGE("Failure setting socket flags: %s",
strerror(errno));
close(sockfd);
return -1;
Expand Down Expand Up @@ -1120,14 +1120,14 @@ static int null_socket_send(UNUSED rad_listen_t *listener, REQUEST *request)

output_file = request_data_reference(request, null_socket_send, 0);
if (!output_file) {
radlog(L_ERR, "WARNING: No output file for injected packet %d",
DEBUGE("WARNING: No output file for injected packet %d",
request->number);
return 0;
}

fp = fopen(output_file, "w");
if (!fp) {
radlog(L_ERR, "Failed to send injected file to %s: %s",
DEBUGE("Failed to send injected file to %s: %s",
output_file, strerror(errno));
return 0;
}
Expand Down Expand Up @@ -2136,7 +2136,7 @@ static int command_socket_parse_unix(CONF_SECTION *cs, rad_listen_t *this)

pw = getpwnam(sock->uid_name);
if (!pw) {
radlog(L_ERR, "Failed getting uid for %s: %s",
DEBUGE("Failed getting uid for %s: %s",
sock->uid_name, strerror(errno));
return -1;
}
Expand All @@ -2151,7 +2151,7 @@ static int command_socket_parse_unix(CONF_SECTION *cs, rad_listen_t *this)

gr = getgrnam(sock->gid_name);
if (!gr) {
radlog(L_ERR, "Failed getting gid for %s: %s",
DEBUGE("Failed getting gid for %s: %s",
sock->gid_name, strerror(errno));
return -1;
}
Expand All @@ -2163,7 +2163,7 @@ static int command_socket_parse_unix(CONF_SECTION *cs, rad_listen_t *this)
#else /* can't get uid or gid of connecting user */

if (sock->uid_name || sock->gid_name) {
radlog(L_ERR, "System does not support uid or gid authentication for sockets");
DEBUGE("System does not support uid or gid authentication for sockets");
return -1;
}

Expand All @@ -2174,7 +2174,7 @@ static int command_socket_parse_unix(CONF_SECTION *cs, rad_listen_t *this)
} else {
sock->co.mode = fr_str2int(mode_names, sock->mode_name, 0);
if (!sock->co.mode) {
radlog(L_ERR, "Invalid mode name \"%s\"",
DEBUGE("Invalid mode name \"%s\"",
sock->mode_name);
return -1;
}
Expand All @@ -2198,7 +2198,7 @@ static int command_socket_parse_unix(CONF_SECTION *cs, rad_listen_t *this)
if ((sock->uid != (uid_t) -1) || (sock->gid != (gid_t) -1)) {
fr_suid_up();
if (fchown(this->fd, sock->uid, sock->gid) < 0) {
radlog(L_ERR, "Failed setting ownership of %s: %s",
DEBUGE("Failed setting ownership of %s: %s",
sock->path, strerror(errno));
fr_suid_down();
return -1;
Expand Down Expand Up @@ -2413,7 +2413,7 @@ static int command_domain_recv_co(rad_listen_t *listener, fr_cs_buffer_t *co)
}

if (co->offset >= (ssize_t) (sizeof(co->buffer) - 1)) {
radlog(L_ERR, "Line too long!");
DEBUGE("Line too long!");
goto close_socket;
}

Expand Down Expand Up @@ -2537,7 +2537,7 @@ static int command_write_magic(int newfd, listen_socket_t *sock)

magic = htonl(0xf7eead15);
if (write(newfd, &magic, 4) < 0) {
radlog(L_ERR, "Failed writing initial data to socket: %s",
DEBUGE("Failed writing initial data to socket: %s",
strerror(errno));
return -1;
}
Expand All @@ -2548,7 +2548,7 @@ static int command_write_magic(int newfd, listen_socket_t *sock)
magic = htonl(1);
}
if (write(newfd, &magic, 4) < 0) {
radlog(L_ERR, "Failed writing initial data to socket: %s",
DEBUGE("Failed writing initial data to socket: %s",
strerror(errno));
return -1;
}
Expand Down Expand Up @@ -2607,7 +2607,7 @@ static int command_tcp_recv(rad_listen_t *this)
#endif
if (errno == EINTR) return 0;

radlog(L_ERR, "Failed reading from control socket; %s",
DEBUGE("Failed reading from control socket; %s",
strerror(errno));
goto close_socket;
}
Expand All @@ -2623,7 +2623,7 @@ static int command_tcp_recv(rad_listen_t *this)

if (rad_digest_cmp(expected,
(uint8_t *) co->buffer + 16, 16 != 0)) {
radlog(L_ERR, "radmin failed challenge: Closing socket");
DEBUGE("radmin failed challenge: Closing socket");
goto close_socket;
}

Expand Down Expand Up @@ -2683,7 +2683,7 @@ static int command_domain_accept(rad_listen_t *listener)
gid_t gid;

if (getpeereid(newfd, &uid, &gid) < 0) {
radlog(L_ERR, "Failed getting peer credentials for %s: %s",
DEBUGE("Failed getting peer credentials for %s: %s",
sock->path, strerror(errno));
close(newfd);
return 0;
Expand All @@ -2702,15 +2702,15 @@ static int command_domain_accept(rad_listen_t *listener)
if (sock->gid_name && (sock->gid == gid)) break;

if (sock->uid_name && (sock->uid != uid)) {
radlog(L_ERR, "Unauthorized connection to %s from uid %ld",
DEBUGE("Unauthorized connection to %s from uid %ld",

sock->path, (long int) uid);
close(newfd);
return 0;
}

if (sock->gid_name && (sock->gid != gid)) {
radlog(L_ERR, "Unauthorized connection to %s from gid %ld",
DEBUGE("Unauthorized connection to %s from gid %ld",
sock->path, (long int) gid);
close(newfd);
return 0;
Expand Down

0 comments on commit d31b92a

Please sign in to comment.