From: Martin Mares Date: Thu, 28 Jun 2007 16:01:14 +0000 (+0200) Subject: Adapted to recent libucw (log -> msg). X-Git-Tag: python-dummy-working~346 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=6324cb417d421274a384cfae916b039cbe56d6e0;p=moe.git Adapted to recent libucw (log -> msg). --- diff --git a/submit/commands.c b/submit/commands.c index 93d9ae9..9542a19 100644 --- a/submit/commands.c +++ b/submit/commands.c @@ -18,7 +18,7 @@ /*** REQUESTS AND REPLIES ***/ static void NONRET -read_error_cb(struct obj_read_state *st UNUSED, byte *msg) +read_error_cb(struct obj_read_state *st UNUSED, char *msg) { client_error("Request parse error: %s", msg); } @@ -68,13 +68,13 @@ write_reply(struct conn *c) obj_set_attr(c->reply, '+', "OK"); if (trace_commands) { - byte *msg; - if (msg = obj_find_aval(c->reply, '-')) - log(L_DEBUG, ">> -%s", msg); - else if (msg = obj_find_aval(c->reply, '+')) - log(L_DEBUG, ">> +%s", msg); + byte *m; + if (m = obj_find_aval(c->reply, '-')) + msg(L_DEBUG, ">> -%s", m); + else if (m = obj_find_aval(c->reply, '+')) + msg(L_DEBUG, ">> +%s", m); else - log(L_DEBUG, ">> ???"); + msg(L_DEBUG, ">> ???"); } obj_write(&c->tx_fb, c->reply, BUCKET_TYPE_PLAIN); bputc(&c->tx_fb, '\n'); @@ -231,7 +231,7 @@ cmd_submit(struct conn *c) obj_set_attr_num(parto, 'V', last_ver); task_unlock_status(c, 1); - log(L_INFO, "User %s submitted task %s%s (version %d%s)", + msg(L_INFO, "User %s submitted task %s%s (version %d%s)", c->user, tname, (strcmp(tname, pname) ? stk_printf("/%s", pname) : ""), last_ver, @@ -250,7 +250,7 @@ execute_command(struct conn *c) return; } if (trace_commands) - log(L_DEBUG, "<< %s", cmd); + msg(L_DEBUG, "<< %s", cmd); if (!strcasecmp(cmd, "SUBMIT")) cmd_submit(c); else if (!strcasecmp(cmd, "STATUS")) @@ -289,12 +289,12 @@ execute_init(struct conn *c) err(c, "Unknown user"); return; } - log(L_INFO, "Logged in %s", user); + msg(L_INFO, "Logged in %s", user); } else { err(c, "Permission denied"); - log(L_ERROR, "Unauthorized attempt to log in as %s", user); + msg(L_ERROR, "Unauthorized attempt to log in as %s", user); return; } c->user = xstrdup(user); diff --git a/submit/submitd.c b/submit/submitd.c index b3b5aac..e8578f6 100644 --- a/submit/submitd.c +++ b/submit/submitd.c @@ -203,7 +203,7 @@ tls_verify_cert(struct conn *c) if (err < 0) return "Cannot retrieve common name"; if (trace_tls) - log(L_INFO, "Cert CN: %s", dn); + msg(L_INFO, "Cert CN: %s", dn); c->cert_name = xstrdup(dn); /* Check certificate purpose */ @@ -236,7 +236,7 @@ tls_log_params(struct conn *c) const char *comp = gnutls_compression_get_name(gnutls_compression_get(s)); const char *cipher = gnutls_cipher_get_name(gnutls_cipher_get(s)); const char *mac = gnutls_mac_get_name(gnutls_mac_get(s)); - log(L_DEBUG, "TLS params: proto=%s kx=%s cert=%s comp=%s cipher=%s mac=%s", + msg(L_DEBUG, "TLS params: proto=%s kx=%s cert=%s comp=%s cipher=%s mac=%s", proto, kx, cert, comp, cipher, mac); } @@ -247,7 +247,7 @@ client_error(char *msg, ...) { va_list args; va_start(args, msg); - vlog_msg(L_ERROR_R, msg, args); + vmsg(L_ERROR_R, msg, args); exit(0); } @@ -377,7 +377,7 @@ client_loop(struct conn *c) alarm(session_timeout); if (!process_init(c)) - log(L_ERROR, "Protocol handshake failed"); + msg(L_ERROR, "Protocol handshake failed"); else { setproctitle("submitd: client %s (%s)", c->ip_string, c->user); @@ -407,18 +407,18 @@ sigchld_handler(int sig UNUSED) static void reap_child(pid_t pid, int status) { - byte msg[EXIT_STATUS_MSG_SIZE]; - if (format_exit_status(msg, status)) - log(L_ERROR, "Child %d %s", (int)pid, msg); + byte buf[EXIT_STATUS_MSG_SIZE]; + if (format_exit_status(buf, status)) + msg(L_ERROR, "Child %d %s", (int)pid, buf); CLIST_FOR_EACH(struct conn *, c, connections) if (c->pid == pid) { - log(L_INFO, "Connection %d closed", c->id); + msg(L_INFO, "Connection %d closed", c->id); conn_free(c); return; } - log(L_ERROR, "Cannot find connection for child process %d", (int)pid); + msg(L_ERROR, "Cannot find connection for child process %d", (int)pid); } static int listen_sk; @@ -483,7 +483,7 @@ sk_accept(void) } struct conn *c = conn_new(); - log(L_INFO, "Connection from %s:%d (id %d, %s, %s)", + msg(L_INFO, "Connection from %s:%d (id %d, %s, %s)", ipbuf, port, c->id, (rule->plain_text ? "plain-text" : "TLS"), (rule->allow_admin ? "admin" : "user")); @@ -497,7 +497,7 @@ sk_accept(void) { conn_free(c); err = "Server overloaded"; - log(L_ERROR, "Fork failed: %m"); + msg(L_ERROR, "Fork failed: %m"); goto reject2; } if (!c->pid) @@ -510,12 +510,12 @@ sk_accept(void) return; reject: - log(L_ERROR_R, "Connection from %s:%d rejected (%s)", ipbuf, port, err); + msg(L_ERROR_R, "Connection from %s:%d rejected (%s)", ipbuf, port, err); reject2: ; // Write an error message to the socket, but do not allow it to slow us down struct linger ling = { .l_onoff=0 }; if (setsockopt(sk, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling)) < 0) - log(L_ERROR, "Cannot set SO_LINGER: %m"); + msg(L_ERROR, "Cannot set SO_LINGER: %m"); write(sk, "-", 1); write(sk, err, strlen(err)); write(sk, "\n", 1); @@ -535,12 +535,12 @@ int main(int argc, char **argv) log_file(log_name); - log(L_INFO, "Initializing TLS"); + msg(L_INFO, "Initializing TLS"); tls_init(); conn_init(); sk_init(); - log(L_INFO, "Listening on port %d", port); + msg(L_INFO, "Listening on port %d", port); struct sigaction sa = { .sa_handler = sigchld_handler diff --git a/submit/tasks.c b/submit/tasks.c index 1ca515a..675f4d8 100644 --- a/submit/tasks.c +++ b/submit/tasks.c @@ -211,5 +211,5 @@ void task_delete_part(byte *user, byte *task, byte *part, byte *ext, uns version byte *dir = stk_printf("solutions/%s/%s", user, task); byte *name = stk_printf("%s/%s.%s", dir, part, ext); if (unlink(name) < 0) - log(L_ERROR, "Cannot delete %s: %m", name); + msg(L_ERROR, "Cannot delete %s: %m", name); }