[iwhd] maint: add comment: %{_unitdir} BuildReqires: systemd-units
by Jim Meyering
commit 5684eded2f3695f69c1bd4f6c5c7ada75f68ea64
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Nov 30 15:38:51 2011 +0100
maint: add comment: %{_unitdir} BuildReqires: systemd-units
iwhd.spec.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/iwhd.spec.in b/iwhd.spec.in
index 38ada80..bbd70a5 100644
--- a/iwhd.spec.in
+++ b/iwhd.spec.in
@@ -71,7 +71,7 @@ rm -rf %{buildroot}
%config(noreplace) %{_sysconfdir}/sysconfig/iwhd
%{_localstatedir}/lib/iwhd
-# Use _unitdir on F16+
+# Use _unitdir on F16+, and add this: BuildRequires: systemd-units
#{_unitdir}/iwhd.service
/lib/systemd/system/iwhd.service
12 years, 6 months
[iwhd] tests: use "compare exp out", not "compare out exp"
by Jim Meyering
commit 3081fe6e1ad507ff16f21d42c9b29bbf7aeb7b66
Author: Jim Meyering <meyering(a)redhat.com>
Date: Tue Nov 29 17:48:11 2011 +0100
tests: use "compare exp out", not "compare out exp"
Likewise, when an empty file is expected, use "compare /dev/null out",
not "compare out /dev/null". I.e., specify the expected/desired contents
via the first file name. Prompted by a suggestion from Bruno Haible
in http://thread.gmane.org/gmane.comp.gnu.grep.bugs/4020/focus=29154
Run this command:
git grep -l -E 'compare [^ ]+ exp' \
|xargs perl -pi -e 's/\b(compare) (\S+) (exp\S*)/$1 $3 $2/'
git grep -l -E 'compare [^ ]+ /dev/null' \
|xargs perl -pi -e 's,\b(compare) (\S+) (/dev/null),$1 $3 $2,'
t/basic | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/t/basic b/t/basic
index e4aec0a..5504712 100644
--- a/t/basic
+++ b/t/basic
@@ -162,7 +162,7 @@ curl -H 'Accept: */json' -d '$target=="mock"' \
http://localhost:$port/b99/_query > q.xml
tr -s '\t \n' ' ' < q.xml > k && mv k q.xml
printf '[ { "bucket": "b99", "key": "my_file" } ] ' > exp.xml
-compare q.xml exp.xml || fail=1
+compare exp.xml q.xml || fail=1
# Run a query that produces nontrivial output;
# First, create many objects that will match it.
@@ -203,10 +203,10 @@ cat <<EOF > exp-attr
EOF
# Print all attributes of an object:
curl $bucket/attr_post/_attrs > out-attr || fail=1
-compare out-attr exp-attr || fail=1
+compare exp-attr out-attr || fail=1
# Do the same thing using the old, deprecated mechanism:
curl -d op=parts $bucket/attr_post > out-attr-deprecated || fail=1
-compare out-attr-deprecated exp-attr || fail=1
+compare exp-attr out-attr-deprecated || fail=1
# Ensure that an attempt to add reserved object name fails.
# FIXME: keep this list in sync with the one in rest.c:
12 years, 6 months
[iwhd] iwhd: much-improved request logging
by Pete Zaitcev
commit 2772f7d8ddca299b8ed76b9a30e027ce8aea553f
Author: Pete Zaitcev <zaitcev(a)yahoo.com>
Date: Wed Nov 16 14:04:16 2011 -0700
iwhd: much-improved request logging
Before this change, iwhd's log was either silent (without -v), or
printed a message for every buffer transferred (with -v). Neither is
any good for diagnosing strange behavior that Aeolus people are seeing,
e.g. mysterious disappearance of files.
We want easy-to-understand, complete, yet laconic logging of REST HTTP
requests. Apache webserver is a good model. However, in our case we often
take too long to process a request, so for starters let's log both arrival
and completion of requests.
Logs must be:
- complete: lose no requests. If HTTP method arrived, always log it.
- sufficient: log Method, URL (including &arg and ?query -- very
important for OAuth!), requested length, if any when complete,
log the resulting data length and the HTTP result
- laconic: only 2 lines per request, no garbage
It turned out to be annoyingly involved, especially if we want
to report correct sizes.
NEWS | 6 ++-
logging.c | 6 +-
meta.cpp | 11 +--
rest.c | 207 +++++++++++++++++++++++++++++++++++++++++++++------------
state_defs.h | 8 ++-
5 files changed, 181 insertions(+), 57 deletions(-)
---
diff --git a/NEWS b/NEWS
index c31a3df..d3dfe6d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,11 +2,15 @@ iwhd NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
-* Changes in behavior
+** Changes in behavior
iwhd now rejects a --userlist file that is group- or other-readable
or -writable.
+ The request logging is reorganized. Now, 2 messages are logged for
+ every request. They report the method, path, requested and actual size,
+ and the HTTP result code.
+
* Noteworthy changes in release 1.0 (2011-10-31) [stable]
diff --git a/logging.c b/logging.c
index 7528e36..6e2a913 100644
--- a/logging.c
+++ b/logging.c
@@ -71,7 +71,7 @@ static void log_str(const char *fmt, va_list args)
assure_newline(f); /* length accounted above */
vfprintf(logstream?:stderr, f, args); /* atomic write */
- /* no fflush, setlinebuf-ed */
+ /* no fflush, setbuf-ed to _IONBF */
}
void log_msg(enum log_level level, const char *fmt, ...)
@@ -126,8 +126,8 @@ log_reset(void)
close(fd1);
return -1;
}
- setlinebuf(stdout);
- setlinebuf(stderr);
+ setbuf(stdout, NULL);
+ setbuf(stderr, NULL);
if (dup2(fd1, 1) == -1) {
error(0,errno,_("unable to dup log to stdout"));
diff --git a/meta.cpp b/meta.cpp
index c4de01d..36c082b 100644
--- a/meta.cpp
+++ b/meta.cpp
@@ -209,7 +209,7 @@ RepoMeta::DidPut (const char *bucket, const char *key, const char *loc,
gettimeofday(&now_tv,NULL);
now = (double)now_tv.tv_sec + (double)now_tv.tv_usec / 1000000.0;
dbl_to_str(&now,now_str);
- log_msg(IW_LOG_INFO,"now_str = %s", now_str);
+ log_msg(IW_LOG_DEBUG,"now_str is %s", now_str);
q = QUERY("_bucket"<<bucket<<"_key"<<key);
curs = GetCursor(q);
@@ -250,9 +250,6 @@ meta_did_put (const char *bucket, const char *key, const char *loc, size_t size)
{
char *rc;
- /* TBD: remove this or safestr */
- log_msg(IW_LOG_INFO,"meta_did_put(%s,%s,%s)",bucket,key,loc);
-
CLIENT_LOCK;
rc = it->DidPut(bucket,key,loc,size);
CLIENT_UNLOCK;
@@ -315,7 +312,7 @@ RepoMeta::HasCopy (const char *bucket, const char *key, const char *loc)
return (char *)"";
}
- log_msg(IW_LOG_INFO,"%s/%s _etag = %s", bucket, key, value);
+ log_msg(IW_LOG_DEBUG,"%s/%s _etag = %s", bucket, key, value);
return strdup(value);
}
@@ -436,11 +433,11 @@ RepoQuery::RepoQuery (const char *bucket, const char *key, const char *qstr,
auto_ptr<DBClientCursor> tmp;
if (bucket) {
- log_msg(IW_LOG_INFO, "bucket is %s", bucket);
+ log_msg(IW_LOG_DEBUG, "bucket is %s", bucket);
q = QUERY("_bucket"<<bucket);
}
else if (key) {
- log_msg(IW_LOG_INFO, "key is %s", key);
+ log_msg(IW_LOG_DEBUG, "key is %s", key);
q = QUERY("_key"<<key);
}
else {
diff --git a/rest.c b/rest.c
index ba5d9b0..22acc1e 100644
--- a/rest.c
+++ b/rest.c
@@ -19,6 +19,7 @@
#include <error.h>
#include <fcntl.h>
#include <getopt.h>
+#include <netdb.h>
#include <poll.h>
#include <pthread.h>
#include <semaphore.h>
@@ -121,6 +122,74 @@ static const char *log_name;
static char my_hostname[HOST_NAME_MAX+1];
static bool oauth = false;
+static void
+conn_to_client(struct MHD_Connection *conn, char *buf, size_t len)
+{
+ const union MHD_ConnectionInfo *info;
+ char listen_host[65], listen_serv[65];
+
+ info = MHD_get_connection_info(conn,MHD_CONNECTION_INFO_CLIENT_ADDRESS);
+ if (!info) {
+ snprintf(buf,len,"-");
+ return;
+ }
+
+ /*
+ * The cast is needed to support libmicrohttpd-0.9.6 in RHEL 6 and
+ * Fedora 15 or earlier, where client_addr is struct sockaddr_in *.
+ */
+ if (getnameinfo((struct sockaddr *)info->client_addr,
+ sizeof(*info->client_addr),
+ listen_host, sizeof(listen_host),
+ listen_serv, sizeof(listen_serv),
+ NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
+ snprintf(buf,len,"%s.%s",listen_host,listen_serv);
+ }
+ else {
+ snprintf(buf,len,"???");
+ }
+
+}
+
+static void
+log_http_request(struct MHD_Connection *conn, const char *method,
+ const char *url)
+{
+ const char *sizestr;
+ char client[100];
+
+ sizestr = MHD_lookup_connection_value(conn,MHD_HEADER_KIND,
+ "Content-Length");
+ if (!sizestr)
+ sizestr = "-";
+ conn_to_client(conn,client,sizeof(client));
+ log_msg(IW_LOG_INFO, "%s \"%s %s\" %s",client,method,url,sizestr);
+}
+
+static void
+log_http_result(struct MHD_Connection *conn, my_state *ms,unsigned int code)
+{
+ unsigned long sizecnt;
+ char client[100];
+
+ /*
+ * Apparently we never set Content-Length when replying, so
+ * don't bother looking it up in MHD_RESPONSE_HEADER_KIND.
+ */
+ conn_to_client(conn,client,sizeof(client));
+ sizecnt = ms ? ms->size : 0;
+ log_msg(IW_LOG_INFO, "%s %u %lu",client,code,sizecnt);
+}
+
+static void
+log_http_reset(struct MHD_Connection *conn)
+{
+ char client[100];
+
+ conn_to_client(conn,client,sizeof(client));
+ log_msg(IW_LOG_INFO, "%s reset",client);
+}
+
static const char *const (reserved_name[]) = {"_default", "_new", "_policy", "_query", NULL};
static const char *const (reserved_attr[]) = {"_attrs", "_bucket", "_date", "_etag", "_key", "_loc", "_size", NULL};
static const char *const (reserved_bucket_name[]) = {"_new", "_providers", NULL};
@@ -183,7 +252,13 @@ do_resp (struct MHD_Connection *conn, my_state *ms,
unsigned int status_code, const char *etag, const char *datastr)
{
struct MHD_Response *resp;
- size_t datalen = datastr? strlen(datastr): 0;
+ size_t datalen = 0;
+
+ if (datastr) {
+ datalen = strlen(datastr);
+ if (ms)
+ ms->size = datalen;
+ }
resp = MHD_create_response_from_data(datalen,(void *)datastr,
MHD_NO,MHD_NO);
@@ -197,6 +272,10 @@ do_resp (struct MHD_Connection *conn, my_state *ms,
MHD_queue_response(conn,status_code,resp);
MHD_destroy_response(resp);
+ if (ms)
+ ms->rc = status_code;
+ else
+ log_http_result(conn,NULL,status_code);
return MHD_YES;
}
@@ -209,12 +288,12 @@ do_resp_from_cb (struct MHD_Connection *conn, my_state *ms,
resp = MHD_create_response_from_callback(MHD_SIZE_UNKNOWN,
CB_BLOCK_SIZE, func, ms, simple_closer);
if (!resp) {
- log_msg(0,"MHD_crfc failed");
simple_closer(ms);
return MHD_NO;
}
MHD_queue_response(conn,MHD_HTTP_OK,resp);
MHD_destroy_response(resp);
+ ms->rc = MHD_HTTP_OK;
return MHD_YES;
}
@@ -289,6 +368,7 @@ proxy_get_cons_0 (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,(char *)(ps->data_ptr)+pp->offset,done);
pp->offset += done;
+ ms->size += done;
DPRINTF("consumer copied %zu, new offset %zu\n",
done, pp->offset);
if (pp->offset == ps->data_len) {
@@ -409,7 +489,6 @@ proxy_get_data (void *cctx, struct MHD_Connection *conn, const char *url,
resp = MHD_create_response_from_callback(MHD_SIZE_UNKNOWN,
CB_BLOCK_SIZE, proxy_get_cons, pp, child_closer);
if (!resp) {
- log_msg(0,"MHD_crfc failed");
if (pp2) {
/* TBD: terminate thread */
}
@@ -600,7 +679,6 @@ proxy_list_attrs (void *cctx, struct MHD_Connection *conn, const char *url,
* created its own response. Therefore we shouldn't.
*/
if (do_resp(conn,ms,rc,NULL,NULL) != MHD_YES) {
- log_msg(0,"MHD_crfd failed");
return MHD_NO;
}
return MHD_YES;
@@ -678,6 +756,7 @@ proxy_put_attr (void *cctx, struct MHD_Connection *conn, const char *url,
*p = '\0';
ms->pipe.data_ptr = p;
+ ms->size += *data_size;
(void)strncat(ms->pipe.data_ptr,data,*data_size);
/* TBD: check return value */
*data_size = 0;
@@ -807,6 +886,7 @@ proxy_query_func_0 (void *ctx, uint64_t pos, char *buf, size_t max)
memcpy(buf,ms->gen_ctx->buf,len);
ms->gen_ctx->buf += len;
ms->gen_ctx->len -= len;
+ ms->size += len;
return len;
}
@@ -827,6 +907,7 @@ proxy_query_func_0 (void *ctx, uint64_t pos, char *buf, size_t max)
memcpy(buf,ms->gen_ctx->buf,len);
ms->gen_ctx->buf += len;
ms->gen_ctx->len -= len;
+ ms->size += len;
return len;
}
@@ -839,6 +920,7 @@ proxy_query_func_0 (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
ms->gen_ctx = TMPL_CTX_DONE;
+ ms->size += len;
return len;
}
@@ -1033,6 +1115,7 @@ root_blob_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
len = max;
}
memcpy(buf,ms->gen_ctx->buf,len);
+ ms->size += len;
return len;
}
@@ -1050,6 +1133,7 @@ root_blob_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
len = max;
}
memcpy(buf,ms->gen_ctx->buf,len);
+ ms->size += len;
return len;
}
@@ -1062,6 +1146,7 @@ root_blob_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
len = max;
}
memcpy(buf,ms->gen_ctx->buf,len);
+ ms->size += len;
return len;
}
@@ -1074,6 +1159,7 @@ root_blob_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
ms->gen_ctx = TMPL_CTX_DONE;
+ ms->size += len;
return len;
}
@@ -1125,7 +1211,7 @@ post_iterator (void *ctx, enum MHD_ValueKind kind, const char *key,
(void)transfer_encoding;
(void)off;
- printf("adding %s, size=%zu\n",key,size);
+ DPRINTF("adding %s[%zu]=\"%.*s\"\n",key,size,(int)size,data);
// TBD: don't assume that values are null-terminated strings
old_val = kv_hash_lookup(ctx,key);
@@ -1289,7 +1375,7 @@ control_api_root (void *cctx, struct MHD_Connection *conn, const char *url,
}
MHD_queue_response(conn,rc,resp);
MHD_destroy_response(resp);
-
+ ms->rc = rc;
return MHD_YES;
}
@@ -1347,7 +1433,6 @@ proxy_bucket_post (void *cctx, struct MHD_Connection *conn, const char *url,
DPRINTF("A parameter is MISSING (fail)\n");
}
if (do_resp(conn,ms,rc,NULL,NULL) != MHD_YES) {
- log_msg(0,"MHD_crfd failed");
return MHD_NO;
}
}
@@ -1433,6 +1518,7 @@ parts_callback_0 (void *ctx, uint64_t pos, char *buf, size_t max)
len = max;
}
memcpy(buf,ms->gen_ctx->buf,len);
+ ms->size += len;
return len;
}
@@ -1456,6 +1542,7 @@ parts_callback_0 (void *ctx, uint64_t pos, char *buf, size_t max)
len = max;
}
memcpy(buf,ms->gen_ctx->buf,len);
+ ms->size += len;
return len;
}
@@ -1468,6 +1555,7 @@ parts_callback_0 (void *ctx, uint64_t pos, char *buf, size_t max)
}
memcpy(buf,ms->gen_ctx->buf,len);
ms->gen_ctx = TMPL_CTX_DONE;
+ ms->size += len;
return len;
}
@@ -1491,7 +1579,7 @@ show_parts (struct MHD_Connection *conn, my_state *ms)
}
if (do_resp_from_cb(conn,ms,parts_callback) != MHD_YES) {
- return MHD_NO;
+ return MHD_HTTP_INTERNAL_SERVER_ERROR;
}
return MHD_HTTP_PROCESSING;
}
@@ -1562,7 +1650,6 @@ proxy_object_post (void *cctx, struct MHD_Connection *conn, const char *url,
* created its own response. Therefore we shouldn't.
*/
if (do_resp(conn,ms,rc,NULL,NULL) != MHD_YES) {
- log_msg(0,"MHD_crfd failed");
return MHD_NO;
}
}
@@ -1689,6 +1776,7 @@ prov_list_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
}
assert (len <= max);
memcpy(buf,ms->gen_ctx->buf,len);
+ ms->size += len;
return len;
}
@@ -1730,6 +1818,7 @@ prov_list_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
size_t n = MIN (max, ms->buf_n_used - ms->buf_offset);
memcpy (buf, ms->buf + ms->buf_offset, n);
ms->buf_offset += n;
+ ms->size += n;
return n;
} else {
free (ms->buf);
@@ -1740,6 +1829,7 @@ prov_list_generator_0 (void *ctx, uint64_t pos, char *buf, size_t max)
assert (len <= max);
memcpy(buf,ms->gen_ctx->buf,len);
ms->gen_ctx = TMPL_CTX_DONE;
+ ms->size += len;
return len;
}
}
@@ -1963,7 +2053,6 @@ proxy_add_prov (void *cctx, struct MHD_Connection *conn, const char *url,
add_fail:
if (do_resp(conn,ms,rc,NULL,NULL) != MHD_YES) {
- log_msg(0,"MHD_crfd failed");
return MHD_NO;
}
}
@@ -1988,11 +2077,7 @@ proxy_create_bucket (void *cctx, struct MHD_Connection *conn, const char *url,
/* curl -T moo.empty http://localhost:9090/_new by accident */
int rc = create_bucket(ms->bucket,ms);
- if (do_resp(conn,ms,rc,NULL,NULL) != MHD_YES) {
- log_msg(0,"MHD_crfd failed");
- return MHD_NO;
- }
- return MHD_YES;
+ return do_resp(conn,ms,rc,NULL,NULL);
}
static const rule my_rules[] = {
@@ -2410,11 +2495,12 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
MHD_add_response_header(resp,"WWW-Authenticate",buf);
MHD_queue_response(conn,MHD_HTTP_UNAUTHORIZED,resp);
MHD_destroy_response(resp);
+ ms->rc = MHD_HTTP_UNAUTHORIZED;
return 1;
}
if (!auth_hdr_split(&argc, &argv, val)) {
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,"400\r\n");
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,"400\r\n");
return 1;
}
if (verbose >= 2) {
@@ -2427,7 +2513,7 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
x = oauth_param_find(argv,argc,"oauth_consumer_key");
if (x == -1) {
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,"400 no user\r\n");
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,"400 no user\r\n");
return 1;
}
user_name = oauth_param_val(argv[x]);
@@ -2438,25 +2524,25 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
* but never underestimate the trickery of network input.
* Also, there's a strdup() inside it.
*/
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500 null username\r\n");
return 1;
}
u = user_lookup(user_name);
if (!u) {
- do_resp(conn,NULL,MHD_HTTP_FORBIDDEN,NULL,"403 bad user\r\n");
+ do_resp(conn,ms,MHD_HTTP_FORBIDDEN,NULL,"403 bad user\r\n");
return 1;
}
x = oauth_param_find(argv,argc,"oauth_signature_method");
if (x == -1) {
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,
"400 no signature method\r\n");
return 1;
}
sig_method = oauth_param_val(argv[x]);
if (!sig_method) {
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500 null signature method\r\n");
return 1;
}
@@ -2467,7 +2553,7 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
/*
* We don't support OA_RSA for now, it needs key management.
*/
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,
"400 bad signature method (use HMAC-SHA1)\r\n");
return 1;
}
@@ -2495,13 +2581,13 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
}
if (!oargv) {
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500\r\n");
return 1;
}
oargv[0] = rebuild_url(false, conn, url); /* TBD: SSL */
if (!oargv[0]) {
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500\r\n");
return 1;
}
@@ -2513,14 +2599,14 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
x = oauth_param_find(argv,argc,"oauth_nonce");
if (x == -1) {
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,"400 no nonce\r\n");
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,"400 no nonce\r\n");
return 1;
}
oargv[oargc++] = argv[x];
x = oauth_param_find(argv,argc,"oauth_timestamp");
if (x == -1) {
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,
"400 no timestamp\r\n");
return 1;
}
@@ -2546,33 +2632,33 @@ do_oauth (struct MHD_Connection *conn, my_state *ms,
*/
x = oauth_param_find(argv,argc,"oauth_signature");
if (x == -1) {
- do_resp(conn,NULL,MHD_HTTP_BAD_REQUEST,NULL,
+ do_resp(conn,ms,MHD_HTTP_BAD_REQUEST,NULL,
"400 no signature\r\n");
return 1;
}
sig_supplied = oauth_param_val(argv[x]);
if (!sig_supplied) {
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500 null supplied\r\n");
return 1;
}
x = oauth_param_find(oargv,oargc,"oauth_signature");
if (x == -1) {
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500 no signature\r\n");
return 1;
}
sig_calculated = oauth_param_val(oargv[x]);
if (!sig_calculated) {
- do_resp(conn,NULL,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
+ do_resp(conn,ms,MHD_HTTP_INTERNAL_SERVER_ERROR,NULL,
"500 null calculated\r\n");
return 1;
}
if (strcmp(sig_supplied, sig_calculated) != 0) {
DPRINTF("OAuth signature mismatch");
- do_resp(conn,NULL,MHD_HTTP_FORBIDDEN,NULL,
+ do_resp(conn,ms,MHD_HTTP_FORBIDDEN,NULL,
"403 signature mismatch\r\n");
return 1;
}
@@ -2600,28 +2686,37 @@ access_handler_0 (void *cctx, struct MHD_Connection *conn, const char *url,
int rc;
log_check();
- if (verbose >= 2) {
- printf(">> HTTP\n");
- rc = MHD_get_connection_values(conn, MHD_HEADER_KIND,
- kv_iter_dump, NULL);
- printf(">> headers: %d\n", rc);
- }
if (ms) {
+ /* TBD: Does this ever fire? A ->handler forgets to advance? */
+ if (ms->state == MS_NEW)
+ log_http_request(conn, method, url);
+
if (oauth) {
rc = do_oauth(conn,ms,url,method);
if (rc < 0)
- return MHD_NO;
+ goto out_no;
if (rc > 0)
return MHD_YES;
}
- return ms->handler(cctx,conn,url,method,version,
+ rc = ms->handler(cctx,conn,url,method,version,
data,data_size,rctx);
+ if (rc == MHD_NO)
+ goto out_no;
+ return rc;
}
+ if (verbose >= 2) {
+ printf(">> HTTP\n");
+ rc = MHD_get_connection_values(conn, MHD_HEADER_KIND,
+ kv_iter_dump, NULL);
+ printf(">> headers: %d\n", rc);
+ }
+ log_http_request(conn, method, url);
+
ms = calloc(sizeof(*ms), 1);
if (!ms) {
- return MHD_NO;
+ goto out_no;
}
utype = parse_url(url,ms);
@@ -2648,16 +2743,27 @@ access_handler_0 (void *cctx, struct MHD_Connection *conn, const char *url,
if (oauth) {
rc = do_oauth(conn,ms,url,method);
if (rc < 0)
- return MHD_NO;
+ goto out_no;
if (rc > 0)
return MHD_YES;
}
- return ms->handler(cctx,conn,url,method,version,
+ rc = ms->handler(cctx,conn,url,method,version,
data,data_size,rctx);
+ if (rc == MHD_NO)
+ goto out_no;
+ return rc;
}
- log_msg(0,"bad request m=%s u=%s",method,url);
- return do_resp(conn,ms,MHD_HTTP_NOT_FOUND,NULL,NULL);
+ rc = do_resp(conn,ms,MHD_HTTP_NOT_FOUND,NULL,NULL);
+ if (rc == MHD_NO)
+ goto out_no;
+ /* This ms was never attached, so it does not end in complete_cb. */
+ log_http_result(conn,ms,ms->rc);
+ return rc;
+
+ out_no:
+ log_http_reset(conn);
+ return MHD_NO;
}
static int
@@ -2687,12 +2793,24 @@ static void complete_cb (void *cls, struct MHD_Connection *conn, void **rctx,
my_state *ms = *rctx;
if (!ms)
return;
+ log_http_result(conn,ms,ms->rc);
pthread_mutex_lock(&my_lock);
LIST_REMOVE(ms, gc_link);
pthread_mutex_unlock(&my_lock);
/* now that we removed it from GC list, no need for GC_FREE */
}
+static void *
+uri_logger(void *cls, const char *uri)
+{
+ /*
+ * This is used when we want to see the query string, which
+ * Microhttpd normally drops by the time access_handler is called.
+ */
+ log_msg(IW_LOG_DEBUG, "URI: %s", uri);
+ return NULL;
+}
+
/* These enum values cannot possibly conflict with the option values
ordinarily used by commands, including CHAR_MAX + 1, etc. Avoid
CHAR_MIN - 1, as it may equal -1, the getopt end-of-options value. */
@@ -2984,6 +3102,7 @@ args_done:
my_port, NULL, NULL, &access_handler, &the_sem,
MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t)1048576,
MHD_OPTION_NOTIFY_COMPLETED, complete_cb, NULL,
+ MHD_OPTION_URI_LOG_CALLBACK, uri_logger, NULL,
MHD_OPTION_END);
if (!the_daemon)
error (EXIT_FAILURE, errno, _("failed to start daemon"));
diff --git a/state_defs.h b/state_defs.h
index bce6cab..ff3e8ec 100644
--- a/state_defs.h
+++ b/state_defs.h
@@ -57,9 +57,13 @@ typedef struct _my_state {
char bucket[MAX_FIELD_LEN];
char key[MAX_FIELD_LEN];
char attr[MAX_FIELD_LEN];
- /* for proxy gets */
+ /* for proxy gets (and logging) */
+ /*
+ * TBD: weird! .rc was not used before log_http_result: backend.c
+ * set it, but nobody ever referenced it. Type long was for curl.
+ */
long rc;
- /* for proxy puts */
+ /* for proxy puts (and logging) */
size_t size;
/* for proxy puts, queries, and registrations */
struct MHD_Connection *conn;
12 years, 7 months
[iwhd] build/rpm: install iwhd.service in the right place
by Jim Meyering
commit 9bdb7d01ea61a455654f7283f771aaea8a95048d
Author: Jim Meyering <meyering(a)redhat.com>
Date: Fri Nov 11 08:46:25 2011 +0100
build/rpm: install iwhd.service in the right place
* Makefile.am (p): Define a surrogate for $(prefix) that we can nuke
when it's /usr. Use it in $(unitdir) definition so that iwhd.service
is installed under /lib/..., rather than under /usr/lib/...
[bug introduced via commit fc01ab35, "maint: improve new "unitdir"
definition and uses"] Reported by Pete Zaitcev.
Makefile.am | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 30e546e..df9d4f1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,8 +138,11 @@ iwhd-users.js: $(top_builddir)/config.status
$(AM_V_GEN)echo '[ { "name":"admin", "secret":"replaceme" } ]' \
> $@-t && chmod a-w $@-t && mv $@-t $@
+# Honor $(prefix) in the expansion of $(unitdir), except when it is "/usr".
+p = $$(echo '$(prefix)' | sed 's,^/usr$$,,')
+unitdir = $(DESTDIR)$(p)/lib/systemd/system
+
logrotate_dir = $(DESTDIR)$(sysconfdir)/logrotate.d
-unitdir = $(DESTDIR)$(prefix)/lib/systemd/system
.PHONY: install-data-local
install-data-local: iwhd.init iwhd-conf.js iwhd-users.js
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
12 years, 7 months
[iwhd] maint: improve new "unitdir" definition and uses
by Jim Meyering
commit fc01ab35813942ab2bad7db4d43a6de5e0354a7a
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Nov 10 09:11:26 2011 +0100
maint: improve new "unitdir" definition and uses
* Makefile.am (unitdir): Use $(prefix)/lib rather than
"$(sysconfdir)/..". There is no requirement that $(sysconfdir)
be a sibling of /lib. Include $(DESTDIR) in the definition, since
every use had that.
Makefile.am | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index b0b1587..30e546e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -139,7 +139,7 @@ iwhd-users.js: $(top_builddir)/config.status
> $@-t && chmod a-w $@-t && mv $@-t $@
logrotate_dir = $(DESTDIR)$(sysconfdir)/logrotate.d
-unitdir = $(sysconfdir)/../lib/systemd/system
+unitdir = $(DESTDIR)$(prefix)/lib/systemd/system
.PHONY: install-data-local
install-data-local: iwhd.init iwhd-conf.js iwhd-users.js
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
@@ -149,8 +149,8 @@ install-data-local: iwhd.init iwhd-conf.js iwhd-users.js
$(INSTALL) -m 600 iwhd-users.js $(DESTDIR)$(sysconfdir)/iwhd/users.js
mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
$(INSTALL_DATA) $(top_srcdir)/iwhd.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/iwhd
- mkdir -p $(DESTDIR)$(unitdir)
- $(INSTALL_DATA) $(top_srcdir)/iwhd.service $(DESTDIR)$(unitdir)/iwhd.service
+ mkdir -p $(unitdir)
+ $(INSTALL_DATA) $(top_srcdir)/iwhd.service $(unitdir)/iwhd.service
mkdir -p $(logrotate_dir)
$(INSTALL_DATA) $(top_srcdir)/iwhd.logrotate $(logrotate_dir)/iwhd
mkdir -p $(DESTDIR)$(DEFAULT_FS_DIR)
@@ -161,7 +161,7 @@ uninstall-local:
$(DESTDIR)$(sysconfdir)/iwhd/conf.js \
$(DESTDIR)$(sysconfdir)/iwhd/users.js \
$(DESTDIR)$(sysconfdir)/sysconfig/iwhd \
- $(DESTDIR)/$(unitdir)/iwhd.service \
+ $(unitdir)/iwhd.service \
$(logrotate_dir)/iwhd
rmdir $(DESTDIR)$(DEFAULT_FS_DIR)
12 years, 7 months
[iwhd] tests: fix failing t/oauth test, when using default umask (022)
by Jim Meyering
commit 14f76fcab7e1b4dad3a231c06bdc9e6c7bc61a83
Author: Pete Zaitcev <zaitcev(a)redhat.com>
Date: Fri Nov 11 08:18:57 2011 +0100
tests: fix failing t/oauth test, when using default umask (022)
* t/oauth: Explicitly set permissions of credentials file to 0600.
t/oauth | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/t/oauth b/t/oauth
index 01eb063..7f47414 100644
--- a/t/oauth
+++ b/t/oauth
@@ -73,6 +73,7 @@ poke -h localhost:$port -u chiaki -p badpass -b buk -k p1 -i -f p1.data && fail=
kill $iwhd_pid
sleep 3
echo '[ { "name":"chiaki", "secret":"nodame" } ]' > iwhd.users
+chmod 600 iwhd.users
iwhd -v -o -u iwhd.users -p $port -c iwhd.cfg -d localhost:$m_port &
iwhd_pid=$!
12 years, 7 months
[iwhd] iwhd: require safe permissions on the user.js credentials file
by Jim Meyering
commit b11e9429596e81c90c8ddb6f98cdedffb73d7978
Author: Jim Meyering <meyering(a)redhat.com>
Date: Thu Nov 10 11:42:51 2011 +0100
iwhd: require safe permissions on the user.js credentials file
* rest.c (safe_credential_file_permissions): New function.
(main): Exit if permissions are too lax.
(usage): Mention the 0600 permissions requirement.
* NEWS: Mention this.
NEWS | 5 +++++
rest.c | 25 ++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index afe5b7c..c31a3df 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ iwhd NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+* Changes in behavior
+
+ iwhd now rejects a --userlist file that is group- or other-readable
+ or -writable.
+
* Noteworthy changes in release 1.0 (2011-10-31) [stable]
diff --git a/rest.c b/rest.c
index 4630279..ba5d9b0 100644
--- a/rest.c
+++ b/rest.c
@@ -2741,7 +2741,7 @@ A configuration file must be specified.\n\
-m, --master=HOST_PORT master (upstream) server as ip[:port]\n\
-o, --oauth enable OAuth\n\
-p, --port=PORT alternate listen port (default 9090)\n\
- -u, --userlist=FILE list of user names, secrets\n\
+ -u, --userlist=FILE list of user names, secrets (0600 permissions)\n\
-v, --verbose verbose/debug output\n\
\n\
--help display this help and exit\n\
@@ -2799,6 +2799,26 @@ extract_host_port (char const *s, char **hostname, unsigned short *port)
*port = get_port (colon + 1);
}
+static bool
+safe_credential_file_permissions (char const *file_name)
+{
+ struct stat st;
+ if (stat (file_name, &st) != 0) {
+ error(0, errno, _("failed to stat %s"), file_name);
+ return false;
+ }
+
+ // Ensure that it's not readable or writable by group or other. */
+ if (st.st_mode & (S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) {
+ error(0, 0,
+ _("%s: credentials are group- or world-readable or writable"),
+ file_name);
+ return false;
+ }
+
+ return true;
+}
+
int
main (int argc, char **argv)
{
@@ -2888,6 +2908,9 @@ args_done:
user_add(usercred);
}
if (user_file) {
+ if (!safe_credential_file_permissions (user_file))
+ exit (EXIT_FAILURE);
+
if (!parse_users(user_file)) {
error (0, 0, _("could not parse %s"),user_file);
return !0;
12 years, 7 months
[iwhd] maint: don't distribute an empty AUTHORS file
by Jim Meyering
commit 787661cb6bdf98883ea3ec00166dc888ad4f7c8b
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Nov 9 16:30:48 2011 +0100
maint: don't distribute an empty AUTHORS file
* AUTHORS: Give it some content.
* cfg.mk (sc_check_author_list): Add a syntax-check rule (from libvirt)
to ensure that we keep the AUTHORS file up to date.
* .mailmap: New file.
.mailmap | 5 +++++
AUTHORS | 14 ++++++++++++++
cfg.mk | 14 ++++++++++++++
3 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 0000000..d06e9b2
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,5 @@
+<meyering(a)redhat.com> <jim(a)meyering.net>
+<jdarcy(a)redhat.com> <jdarcy(a)jdarcy-dt.usersys.redhat.com>
+<zaitcev(a)redhat.com> <zaitcev(a)kotori.zaitcev.us>
+<zaitcev(a)redhat.com> <zaitcev(a)yahoo.com>
+<zaitcev(a)redhat.com> <root(a)fserver-1.virtual>
diff --git a/AUTHORS b/AUTHORS
index e69de29..d43d1a5 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -0,0 +1,14 @@
+iwhd contributors:
+
+iwhd was initially created by Jeff Darcy <jdarcy(a)redhat.com>
+
+The primary maintainers and people with commit access:
+
+ Jeff Darcy <jdarcy(a)redhat.com>
+ Jim Meyering <meyering(a)redhat.com>
+ Pete Zaitcev <zaitcev(a)redhat.com>
+
+Patches have also been contributed by:
+
+ Chris Lalancette <clalance(a)redhat.com>
+ Mark McLoughlin <markmc(a)redhat.com>
diff --git a/cfg.mk b/cfg.mk
index df73c8c..66801b3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -57,6 +57,20 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
halt='use of emacs indent-tabs-mode: setting' \
$(_sc_search_regexp)
+# Give credit where due:
+# Ensure that each commit author email address (possibly mapped via
+# git log's .mailmap) appears in our AUTHORS file.
+sc_check_author_list:
+ @fail=0; \
+ for i in $$(git log --pretty=format:%aE%n|sort -u|grep -v '^$$'); do \
+ sanitized=$$(echo "$$i"|LC_ALL=C sed 's/\([^a-zA-Z0-9_@-]\)/\\\1/g'); \
+ grep -iq "<$$sanitized>" $(srcdir)/AUTHORS \
+ || { printf '%s\n' "$$i" >&2; fail=1; }; \
+ done; \
+ test $$fail = 1 \
+ && echo '$(ME): committer(s) not listed in AUTHORS' >&2; \
+ test $$fail = 0
+
odt = ^doc/image_repo\.odt$
exclude_file_name_regexp--sc_trailing_blank = $(odt)
exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = $(odt)
12 years, 7 months
[iwhd] maint: update line numbers in .po files
by Jim Meyering
commit 21c57d03967cf4129331ce16a812aa978df0c798
Author: Jim Meyering <meyering(a)redhat.com>
Date: Wed Nov 9 09:45:54 2011 +0100
maint: update line numbers in .po files
po/es.po | 42 +++++++++++++++++++++++-------------------
po/ja.po | 42 +++++++++++++++++++++++-------------------
po/ru.po | 42 +++++++++++++++++++++++-------------------
po/uk.po | 42 +++++++++++++++++++++++-------------------
4 files changed, 92 insertions(+), 76 deletions(-)
---
diff --git a/po/es.po b/po/es.po
index e2fb270..54acebd 100644
--- a/po/es.po
+++ b/po/es.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Image WareHouse Daemon\n"
"Report-Msgid-Bugs-To: iwhd-devel(a)fedorahosted.org\n"
-"POT-Creation-Date: 2011-10-31 17:30+0100\n"
+"POT-Creation-Date: 2011-11-08 22:51+0100\n"
"PO-Revision-Date: 2011-10-10 12:22+0000\n"
"Last-Translator: meyering <jim(a)meyering.net>\n"
"Language-Team: Spanish (Castilian) (http://www.transifex.net/projects/p/iwhd/"
@@ -600,7 +600,11 @@ msgstr ""
msgid "could not parse url %s"
msgstr ""
-#: replica.c:332 replica.c:339 replica.c:383
+#: replica.c:290
+msgid "no size, mongo may be dead"
+msgstr ""
+
+#: replica.c:336 replica.c:343 replica.c:387
#, c-format
msgid "could not create repl_item for %s"
msgstr ""
@@ -630,27 +634,27 @@ msgstr ""
msgid "failed to get default policy"
msgstr ""
-#: rest.c:1814 rest.c:1841 rest.c:1847
+#: rest.c:1819 rest.c:1846 rest.c:1852
#, c-format
msgid "invalid request: %s"
msgstr ""
-#: rest.c:1852
+#: rest.c:1857
#, c-format
msgid "failed to extract provider name: %s"
msgstr ""
-#: rest.c:2720
+#: rest.c:2725
#, c-format
msgid "Try `%s --help' for more information.\n"
msgstr ""
-#: rest.c:2724
+#: rest.c:2729
#, c-format
msgid "Usage: %s [OPTION]\n"
msgstr ""
-#: rest.c:2728
+#: rest.c:2733
msgid ""
"Aeolus' image-warehouse daemon.\n"
"A configuration file must be specified.\n"
@@ -669,66 +673,66 @@ msgid ""
" --version output version information and exit\n"
msgstr ""
-#: rest.c:2745
+#: rest.c:2750
#, c-format
msgid ""
"\n"
"The default RHEV-M import timeout is %d seconds.\n"
msgstr ""
-#: rest.c:2750
+#: rest.c:2755
#, c-format
msgid ""
"\n"
"Report %s bugs to %s.\n"
msgstr ""
-#: rest.c:2762
+#: rest.c:2767
#, c-format
msgid "gethostname"
msgstr ""
-#: rest.c:2774
+#: rest.c:2779
#, c-format
msgid "invalid port number: %s"
msgstr ""
-#: rest.c:2790
+#: rest.c:2795
#, c-format
msgid "invalid host name"
msgstr ""
-#: rest.c:2876
+#: rest.c:2881
#, c-format
msgid "extra operand %s"
msgstr ""
-#: rest.c:2882
+#: rest.c:2887
#, c-format
msgid "A deprecated flag -U is specified, migrate to -u"
msgstr ""
-#: rest.c:2887 rest.c:2911
+#: rest.c:2892 rest.c:2916
#, c-format
msgid "could not parse %s"
msgstr ""
-#: rest.c:2898
+#: rest.c:2903
#, c-format
msgid "do not use -c and -a simultaneously"
msgstr ""
-#: rest.c:2916
+#: rest.c:2921
#, c-format
msgid "specify at least -c or -a"
msgstr ""
-#: rest.c:2943
+#: rest.c:2948
#, c-format
msgid "write failed"
msgstr ""
-#: rest.c:2961
+#: rest.c:2966
#, c-format
msgid "failed to start daemon"
msgstr ""
diff --git a/po/ja.po b/po/ja.po
index 6ec0bad..defef9c 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Image WareHouse Daemon\n"
"Report-Msgid-Bugs-To: iwhd-devel(a)fedorahosted.org\n"
-"POT-Creation-Date: 2011-10-31 17:30+0100\n"
+"POT-Creation-Date: 2011-11-08 22:51+0100\n"
"PO-Revision-Date: 2011-10-10 12:22+0000\n"
"Last-Translator: meyering <jim(a)meyering.net>\n"
"Language-Team: Japanese (http://www.transifex.net/projects/p/iwhd/team/ja/)\n"
@@ -599,7 +599,11 @@ msgstr ""
msgid "could not parse url %s"
msgstr ""
-#: replica.c:332 replica.c:339 replica.c:383
+#: replica.c:290
+msgid "no size, mongo may be dead"
+msgstr ""
+
+#: replica.c:336 replica.c:343 replica.c:387
#, c-format
msgid "could not create repl_item for %s"
msgstr ""
@@ -629,27 +633,27 @@ msgstr ""
msgid "failed to get default policy"
msgstr ""
-#: rest.c:1814 rest.c:1841 rest.c:1847
+#: rest.c:1819 rest.c:1846 rest.c:1852
#, c-format
msgid "invalid request: %s"
msgstr ""
-#: rest.c:1852
+#: rest.c:1857
#, c-format
msgid "failed to extract provider name: %s"
msgstr ""
-#: rest.c:2720
+#: rest.c:2725
#, c-format
msgid "Try `%s --help' for more information.\n"
msgstr ""
-#: rest.c:2724
+#: rest.c:2729
#, c-format
msgid "Usage: %s [OPTION]\n"
msgstr ""
-#: rest.c:2728
+#: rest.c:2733
msgid ""
"Aeolus' image-warehouse daemon.\n"
"A configuration file must be specified.\n"
@@ -668,66 +672,66 @@ msgid ""
" --version output version information and exit\n"
msgstr ""
-#: rest.c:2745
+#: rest.c:2750
#, c-format
msgid ""
"\n"
"The default RHEV-M import timeout is %d seconds.\n"
msgstr ""
-#: rest.c:2750
+#: rest.c:2755
#, c-format
msgid ""
"\n"
"Report %s bugs to %s.\n"
msgstr ""
-#: rest.c:2762
+#: rest.c:2767
#, c-format
msgid "gethostname"
msgstr ""
-#: rest.c:2774
+#: rest.c:2779
#, c-format
msgid "invalid port number: %s"
msgstr ""
-#: rest.c:2790
+#: rest.c:2795
#, c-format
msgid "invalid host name"
msgstr ""
-#: rest.c:2876
+#: rest.c:2881
#, c-format
msgid "extra operand %s"
msgstr ""
-#: rest.c:2882
+#: rest.c:2887
#, c-format
msgid "A deprecated flag -U is specified, migrate to -u"
msgstr ""
-#: rest.c:2887 rest.c:2911
+#: rest.c:2892 rest.c:2916
#, c-format
msgid "could not parse %s"
msgstr ""
-#: rest.c:2898
+#: rest.c:2903
#, c-format
msgid "do not use -c and -a simultaneously"
msgstr ""
-#: rest.c:2916
+#: rest.c:2921
#, c-format
msgid "specify at least -c or -a"
msgstr ""
-#: rest.c:2943
+#: rest.c:2948
#, c-format
msgid "write failed"
msgstr ""
-#: rest.c:2961
+#: rest.c:2966
#, c-format
msgid "failed to start daemon"
msgstr ""
diff --git a/po/ru.po b/po/ru.po
index 0bfc0d9..7ef593d 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Image WareHouse Daemon\n"
"Report-Msgid-Bugs-To: iwhd-devel(a)fedorahosted.org\n"
-"POT-Creation-Date: 2011-10-31 17:30+0100\n"
+"POT-Creation-Date: 2011-11-08 22:51+0100\n"
"PO-Revision-Date: 2011-10-10 12:22+0000\n"
"Last-Translator: meyering <jim(a)meyering.net>\n"
"Language-Team: Russian (http://www.transifex.net/projects/p/iwhd/team/ru/)\n"
@@ -600,7 +600,11 @@ msgstr ""
msgid "could not parse url %s"
msgstr ""
-#: replica.c:332 replica.c:339 replica.c:383
+#: replica.c:290
+msgid "no size, mongo may be dead"
+msgstr ""
+
+#: replica.c:336 replica.c:343 replica.c:387
#, c-format
msgid "could not create repl_item for %s"
msgstr ""
@@ -630,27 +634,27 @@ msgstr ""
msgid "failed to get default policy"
msgstr ""
-#: rest.c:1814 rest.c:1841 rest.c:1847
+#: rest.c:1819 rest.c:1846 rest.c:1852
#, c-format
msgid "invalid request: %s"
msgstr ""
-#: rest.c:1852
+#: rest.c:1857
#, c-format
msgid "failed to extract provider name: %s"
msgstr ""
-#: rest.c:2720
+#: rest.c:2725
#, c-format
msgid "Try `%s --help' for more information.\n"
msgstr ""
-#: rest.c:2724
+#: rest.c:2729
#, c-format
msgid "Usage: %s [OPTION]\n"
msgstr ""
-#: rest.c:2728
+#: rest.c:2733
msgid ""
"Aeolus' image-warehouse daemon.\n"
"A configuration file must be specified.\n"
@@ -669,66 +673,66 @@ msgid ""
" --version output version information and exit\n"
msgstr ""
-#: rest.c:2745
+#: rest.c:2750
#, c-format
msgid ""
"\n"
"The default RHEV-M import timeout is %d seconds.\n"
msgstr ""
-#: rest.c:2750
+#: rest.c:2755
#, c-format
msgid ""
"\n"
"Report %s bugs to %s.\n"
msgstr ""
-#: rest.c:2762
+#: rest.c:2767
#, c-format
msgid "gethostname"
msgstr ""
-#: rest.c:2774
+#: rest.c:2779
#, c-format
msgid "invalid port number: %s"
msgstr ""
-#: rest.c:2790
+#: rest.c:2795
#, c-format
msgid "invalid host name"
msgstr ""
-#: rest.c:2876
+#: rest.c:2881
#, c-format
msgid "extra operand %s"
msgstr ""
-#: rest.c:2882
+#: rest.c:2887
#, c-format
msgid "A deprecated flag -U is specified, migrate to -u"
msgstr ""
-#: rest.c:2887 rest.c:2911
+#: rest.c:2892 rest.c:2916
#, c-format
msgid "could not parse %s"
msgstr ""
-#: rest.c:2898
+#: rest.c:2903
#, c-format
msgid "do not use -c and -a simultaneously"
msgstr ""
-#: rest.c:2916
+#: rest.c:2921
#, c-format
msgid "specify at least -c or -a"
msgstr ""
-#: rest.c:2943
+#: rest.c:2948
#, c-format
msgid "write failed"
msgstr ""
-#: rest.c:2961
+#: rest.c:2966
#, c-format
msgid "failed to start daemon"
msgstr ""
diff --git a/po/uk.po b/po/uk.po
index 6bd57a8..fc7febe 100644
--- a/po/uk.po
+++ b/po/uk.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Image WareHouse Daemon\n"
"Report-Msgid-Bugs-To: iwhd-devel(a)fedorahosted.org\n"
-"POT-Creation-Date: 2011-10-31 17:30+0100\n"
+"POT-Creation-Date: 2011-11-08 22:51+0100\n"
"PO-Revision-Date: 2011-10-10 15:53+0000\n"
"Last-Translator: yurchor <yurchor(a)ukr.net>\n"
"Language-Team: Ukrainian <trans-uk(a)lists.fedoraproject.org>\n"
@@ -630,7 +630,11 @@ msgstr "помилковий тип repl %d (url=%s), пропущено"
msgid "could not parse url %s"
msgstr "не вдалося обробити адресу %s"
-#: replica.c:332 replica.c:339 replica.c:383
+#: replica.c:290
+msgid "no size, mongo may be dead"
+msgstr ""
+
+#: replica.c:336 replica.c:343 replica.c:387
#, c-format
msgid "could not create repl_item for %s"
msgstr "не вдалося створити repl_item для %s"
@@ -660,27 +664,27 @@ msgstr "не вдалося визначити правила щодо %s/%s"
msgid "failed to get default policy"
msgstr "не вдалося визначити типові правила"
-#: rest.c:1814 rest.c:1841 rest.c:1847
+#: rest.c:1819 rest.c:1846 rest.c:1852
#, c-format
msgid "invalid request: %s"
msgstr "некоректний запит: %s"
-#: rest.c:1852
+#: rest.c:1857
#, c-format
msgid "failed to extract provider name: %s"
msgstr "не вдалося видобути назву надавача: %s"
-#: rest.c:2720
+#: rest.c:2725
#, c-format
msgid "Try `%s --help' for more information.\n"
msgstr "Виконайте команду «%s --help», щоб дізнатися більше.\n"
-#: rest.c:2724
+#: rest.c:2729
#, c-format
msgid "Usage: %s [OPTION]\n"
msgstr "Використання: %s [ПАРАМЕТР]\n"
-#: rest.c:2728
+#: rest.c:2733
#, fuzzy
msgid ""
"Aeolus' image-warehouse daemon.\n"
@@ -715,7 +719,7 @@ msgstr ""
" --help показати це довідкове повідомлення і завершити роботу\n"
" --version показати дані щодо версії і завершити роботу\n"
-#: rest.c:2745
+#: rest.c:2750
#, c-format
msgid ""
"\n"
@@ -724,7 +728,7 @@ msgstr ""
"\n"
"Типовим часом очікування на імпортування RHEV-M є %d секунд.\n"
-#: rest.c:2750
+#: rest.c:2755
#, c-format
msgid ""
"\n"
@@ -733,52 +737,52 @@ msgstr ""
"\n"
"Про вади у %s повідомляйте за адресою %s.\n"
-#: rest.c:2762
+#: rest.c:2767
#, c-format
msgid "gethostname"
msgstr "gethostname"
-#: rest.c:2774
+#: rest.c:2779
#, c-format
msgid "invalid port number: %s"
msgstr "некоректний номер порту: %s"
-#: rest.c:2790
+#: rest.c:2795
#, c-format
msgid "invalid host name"
msgstr "некоректна назва вузла"
-#: rest.c:2876
+#: rest.c:2881
#, c-format
msgid "extra operand %s"
msgstr "зайвий операнд %s"
-#: rest.c:2882
+#: rest.c:2887
#, c-format
msgid "A deprecated flag -U is specified, migrate to -u"
msgstr ""
-#: rest.c:2887 rest.c:2911
+#: rest.c:2892 rest.c:2916
#, c-format
msgid "could not parse %s"
msgstr "не вдалося обробити %s"
-#: rest.c:2898
+#: rest.c:2903
#, c-format
msgid "do not use -c and -a simultaneously"
msgstr "не можна використовувати -c і -a одночасно"
-#: rest.c:2916
+#: rest.c:2921
#, c-format
msgid "specify at least -c or -a"
msgstr "вкажіть принаймні -c або -a"
-#: rest.c:2943
+#: rest.c:2948
#, c-format
msgid "write failed"
msgstr "помилка під час спроби запису"
-#: rest.c:2961
+#: rest.c:2966
#, c-format
msgid "failed to start daemon"
msgstr "не вдалося запустити фонову службу"
12 years, 7 months
[iwhd] iwhd: add native systemd support
by Jim Meyering
commit 76efee8b04b9e2e7e9db9cd7952809ac2a297f36
Author: Pete Zaitcev <zaitcev(a)redhat.com>
Date: Wed Nov 2 10:33:30 2011 -0600
iwhd: add native systemd support
1. The unitdir madness. The problem here is that DESTDIR may be empty,
and in the same time the prefix set to something. Therefore, unitdir
cannot be defined as an absolute path. The _only_ way to stuff this
makefile through the "make check" is to use one of the predefined
variables that depend on prefix _and_ DESTDIR (which may be non-empty).
Ergo, the double-dot over sysconfigdir. Madness.
2. Why did we ever put -c outside of the normal configuration? It is
extremely unpleasant to explain how it works to fellow hackers and
sysadmins, and it confuses people greatly. I pulled this in.
3. The -m 600 is necessary for users.js, because the passwords are
in plaintext! They must be in plaintext for OAuth, because of the
way hashing works.
Makefile.am | 15 ++++++++++++---
iwhd.init.in | 4 ++--
iwhd.service | 14 ++++++++++++++
iwhd.spec.in | 5 +++++
iwhd.sysconfig | 3 +++
5 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 0b093d5..b0b1587 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,8 +28,10 @@ EXTRA_DIST = \
dc-register-image \
iwhd.init.in \
iwhd.logrotate \
+ iwhd.service \
iwhd.spec \
iwhd.spec.in \
+ iwhd.sysconfig \
qparser.h
BUILT_SOURCES = qparser.h qlexer.c
@@ -137,13 +139,18 @@ iwhd-users.js: $(top_builddir)/config.status
> $@-t && chmod a-w $@-t && mv $@-t $@
logrotate_dir = $(DESTDIR)$(sysconfdir)/logrotate.d
+unitdir = $(sysconfdir)/../lib/systemd/system
.PHONY: install-data-local
install-data-local: iwhd.init iwhd-conf.js iwhd-users.js
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
$(INSTALL_SCRIPT) iwhd.init $(DESTDIR)$(sysconfdir)/rc.d/init.d/iwhd
mkdir -p $(DESTDIR)$(sysconfdir)/iwhd
$(INSTALL_DATA) iwhd-conf.js $(DESTDIR)$(sysconfdir)/iwhd/conf.js
- $(INSTALL_DATA) iwhd-users.js $(DESTDIR)$(sysconfdir)/iwhd/users.js
+ $(INSTALL) -m 600 iwhd-users.js $(DESTDIR)$(sysconfdir)/iwhd/users.js
+ mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
+ $(INSTALL_DATA) $(top_srcdir)/iwhd.sysconfig $(DESTDIR)$(sysconfdir)/sysconfig/iwhd
+ mkdir -p $(DESTDIR)$(unitdir)
+ $(INSTALL_DATA) $(top_srcdir)/iwhd.service $(DESTDIR)$(unitdir)/iwhd.service
mkdir -p $(logrotate_dir)
$(INSTALL_DATA) $(top_srcdir)/iwhd.logrotate $(logrotate_dir)/iwhd
mkdir -p $(DESTDIR)$(DEFAULT_FS_DIR)
@@ -152,8 +159,10 @@ install-data-local: iwhd.init iwhd-conf.js iwhd-users.js
uninstall-local:
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/iwhd \
$(DESTDIR)$(sysconfdir)/iwhd/conf.js \
- $(logrotate_dir)/iwhd \
- $(DESTDIR)$(sysconfdir)/iwhd/users.js
+ $(DESTDIR)$(sysconfdir)/iwhd/users.js \
+ $(DESTDIR)$(sysconfdir)/sysconfig/iwhd \
+ $(DESTDIR)/$(unitdir)/iwhd.service \
+ $(logrotate_dir)/iwhd
rmdir $(DESTDIR)$(DEFAULT_FS_DIR)
AM_CPPFLAGS = $(HAIL_CFLAGS) -Ilib -I$(top_srcdir)/lib
diff --git a/iwhd.init.in b/iwhd.init.in
index ab03a26..a82622e 100644
--- a/iwhd.init.in
+++ b/iwhd.init.in
@@ -37,7 +37,7 @@ MONGOD_N_SECONDS=2
# writing in /tmp.
export TMPDIR=@localstatedir@/cache/iwhd
-IWHD_ARGS="-d $MONGOD_SERVER_SPEC -l $IWHD_LOG_FILE"
+IWHD_ARGS="-c $CONFIG_JS -d $MONGOD_SERVER_SPEC -l $IWHD_LOG_FILE"
test -r @sysconfdir@/sysconfig/iwhd && . @sysconfdir@/sysconfig/iwhd
@@ -84,7 +84,7 @@ start() {
echo
printf %s $"Starting $SERVICE daemon: "
- $PROCESS -c "$CONFIG_JS" $IWHD_ARGS &
+ $PROCESS $IWHD_ARGS &
pid=$!
RETVAL=$?
if test $RETVAL = 0; then
diff --git a/iwhd.service b/iwhd.service
new file mode 100644
index 0000000..200148b
--- /dev/null
+++ b/iwhd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Image Warehouse
+After=network.target
+
+# The "simple" type requires communication channels being established
+# by systemd with socket activation; this is not yet the case for iwhd.
+# The best bet may actually be fixing up iwhd to use sd_notify(3).
+[Service]
+EnvironmentFile=-/etc/sysconfig/iwhd
+Type=simple
+ExecStart=/usr/bin/iwhd $IWHD_ARGS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/iwhd.spec.in b/iwhd.spec.in
index c1c67bd..38ada80 100644
--- a/iwhd.spec.in
+++ b/iwhd.spec.in
@@ -68,8 +68,13 @@ rm -rf %{buildroot}
%config(noreplace) %{_sysconfdir}/iwhd/conf.js
%config(noreplace) %{_sysconfdir}/iwhd/users.js
%config(noreplace) %{_sysconfdir}/logrotate.d/iwhd
+%config(noreplace) %{_sysconfdir}/sysconfig/iwhd
%{_localstatedir}/lib/iwhd
+# Use _unitdir on F16+
+#{_unitdir}/iwhd.service
+/lib/systemd/system/iwhd.service
+
%changelog
* Wed Oct 7 2010 Jim Meyering <meyering(a)redhat.com> - 0.90-1
- Initial release.
diff --git a/iwhd.sysconfig b/iwhd.sysconfig
new file mode 100644
index 0000000..7533656
--- /dev/null
+++ b/iwhd.sysconfig
@@ -0,0 +1,3 @@
+# See iwhd(8) for the list of arguments.
+# IWHD_ARGS="-c /etc/iwhd/conf.js -d localhost:27017 -l /var/log/iwhd.log"
+IWHD_ARGS="-c /etc/iwhd/conf.js -l /var/log/iwhd.log"
12 years, 7 months