{"thread":{"id":"34997","subject":"[PATCH 00/15] Make Gnome Credential helper more Gnome-y and support ancient distros","startedAt":"2013-09-23T05:07:56Z","lastAt":"2013-09-23T17:21:28Z","messageCount":20,"participants":["Brandon Casey","Felipe Contreras","John Szakmeister"],"isPatch":true,"patchVersion":1,"patchTotal":15},"messages":[{"id":"228050","messageId":"1379912891-12277-1-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":null,"subject":"[PATCH 00/15] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:07:56Z","receivedAt":"2013-09-23T05:07:56Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"A few cleanups, followed by improved usage of the glib library (no need\nto reinvent the wheel when glib provides the necessary functionality), and\nthen the addition of support for RHEL 4.x and 5.x.\n\nBrandon Casey (15):\n  contrib/git-credential-gnome-keyring.c: remove unnecessary\n    pre-declarations\n  contrib/git-credential-gnome-keyring.c: remove unused die() function\n  contrib/git-credential-gnome-keyring.c: add static where applicable\n  contrib/git-credential-gnome-keyring.c: exit non-zero when called\n    incorrectly\n  contrib/git-credential-gnome-keyring.c: set Gnome application name\n  contrib/git-credential-gnome-keyring.c: strlen() returns size_t, not\n    ssize_t\n  contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty\n    before accessing\n  contrib/git-credential-gnome-keyring.c: use gnome helpers in\n    keyring_object()\n  contrib/git-credential-gnome-keyring.c: use secure memory functions\n    for passwds\n  contrib/git-credential-gnome-keyring.c: use secure memory for reading\n    passwords\n  contrib/git-credential-gnome-keyring.c: use glib memory allocation\n    functions\n  contrib/git-credential-gnome-keyring.c: use glib messaging functions\n  contrib/git-credential-gnome-keyring.c: report failure to store\n    password\n  contrib/git-credential-gnome-keyring.c: support ancient gnome-keyring\n  contrib/git-credential-gnome-keyring.c: support really ancient\n    gnome-keyring\n\n contrib/credential/gnome-keyring/Makefile          |   4 +-\n .../gnome-keyring/git-credential-gnome-keyring.c   | 280 ++++++++++++---------\n 2 files changed, 158 insertions(+), 126 deletions(-)\n\n-- \n1.8.4.489.g545bc72\n"},{"id":"228051","messageId":"1379912891-12277-2-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 01/15] contrib/git-credential-gnome-keyring.c: remove unnecessary pre-declarations","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:07:57Z","receivedAt":"2013-09-23T05:07:57Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"These are all defined before they are used, so it is not necessary to\npre-declare them.  Remove the pre-declarations.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../credential/gnome-keyring/git-credential-gnome-keyring.c | 13 -------------\n 1 file changed, 13 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex f2cdefe..15b0a1c 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -46,11 +46,6 @@ struct credential\n #define CREDENTIAL_INIT \\\n   { NULL,NULL,0,NULL,NULL,NULL }\n \n-void credential_init(struct credential *c);\n-void credential_clear(struct credential *c);\n-int  credential_read(struct credential *c);\n-void credential_write(const struct credential *c);\n-\n typedef int (*credential_op_cb)(struct credential*);\n \n struct credential_operation\n@@ -62,14 +57,6 @@ struct credential_operation\n #define CREDENTIAL_OP_END \\\n   { NULL,NULL }\n \n-/*\n- * Table with operation callbacks is defined in concrete\n- * credential helper implementation and contains entries\n- * like { \"get\", function_to_get_credential } terminated\n- * by CREDENTIAL_OP_END.\n- */\n-struct credential_operation const credential_helper_ops[];\n-\n /* ---------------- common helper functions ----------------- */\n \n static inline void free_password(char *password)\n-- \n1.8.4.489.g545bc72\n"},{"id":"228065","messageId":"1379912891-12277-3-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 02/15] contrib/git-credential-gnome-keyring.c: remove unused die() function","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:07:58Z","receivedAt":"2013-09-23T05:07:58Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Signed-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../credential/gnome-keyring/git-credential-gnome-keyring.c    | 10 ----------\n 1 file changed, 10 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 15b0a1c..4334f23 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -91,16 +91,6 @@ static inline void error(const char *fmt, ...)\n \tva_end(ap);\n }\n \n-static inline void die(const char *fmt, ...)\n-{\n-\tva_list ap;\n-\n-\tva_start(ap,fmt);\n-\terror(fmt, ap);\n-\tva_end(ap);\n-\texit(EXIT_FAILURE);\n-}\n-\n static inline void die_errno(int err)\n {\n \terror(\"%s\", strerror(err));\n-- \n1.8.4.489.g545bc72\n"},{"id":"228052","messageId":"1379912891-12277-4-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 03/15] contrib/git-credential-gnome-keyring.c: add static where applicable","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:07:59Z","receivedAt":"2013-09-23T05:07:59Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Mark global variable and functions as static.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c       | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 4334f23..ad23dbf 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -128,7 +128,7 @@ static char* keyring_object(struct credential *c)\n \treturn object;\n }\n \n-int keyring_get(struct credential *c)\n+static int keyring_get(struct credential *c)\n {\n \tchar* object = NULL;\n \tGList *entries;\n@@ -178,7 +178,7 @@ int keyring_get(struct credential *c)\n }\n \n \n-int keyring_store(struct credential *c)\n+static int keyring_store(struct credential *c)\n {\n \tguint32 item_id;\n \tchar  *object = NULL;\n@@ -212,7 +212,7 @@ int keyring_store(struct credential *c)\n \treturn EXIT_SUCCESS;\n }\n \n-int keyring_erase(struct credential *c)\n+static int keyring_erase(struct credential *c)\n {\n \tchar  *object = NULL;\n \tGList *entries;\n@@ -277,7 +277,7 @@ int keyring_erase(struct credential *c)\n  * Table with helper operation callbacks, used by generic\n  * credential helper main function.\n  */\n-struct credential_operation const credential_helper_ops[] =\n+static struct credential_operation const credential_helper_ops[] =\n {\n \t{ \"get\",   keyring_get   },\n \t{ \"store\", keyring_store },\n@@ -287,12 +287,12 @@ struct credential_operation const credential_helper_ops[] =\n \n /* ------------------ credential functions ------------------ */\n \n-void credential_init(struct credential *c)\n+static void credential_init(struct credential *c)\n {\n \tmemset(c, 0, sizeof(*c));\n }\n \n-void credential_clear(struct credential *c)\n+static void credential_clear(struct credential *c)\n {\n \tfree(c->protocol);\n \tfree(c->host);\n@@ -303,7 +303,7 @@ void credential_clear(struct credential *c)\n \tcredential_init(c);\n }\n \n-int credential_read(struct credential *c)\n+static int credential_read(struct credential *c)\n {\n \tchar    buf[1024];\n \tssize_t line_len = 0;\n@@ -358,14 +358,14 @@ int credential_read(struct credential *c)\n \treturn 0;\n }\n \n-void credential_write_item(FILE *fp, const char *key, const char *value)\n+static void credential_write_item(FILE *fp, const char *key, const char *value)\n {\n \tif (!value)\n \t\treturn;\n \tfprintf(fp, \"%s=%s\\n\", key, value);\n }\n \n-void credential_write(const struct credential *c)\n+static void credential_write(const struct credential *c)\n {\n \t/* only write username/password, if set */\n \tcredential_write_item(stdout, \"username\", c->username);\n-- \n1.8.4.489.g545bc72\n"},{"id":"228054","messageId":"1379912891-12277-5-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 04/15] contrib/git-credential-gnome-keyring.c: exit non-zero when called incorrectly","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:00Z","receivedAt":"2013-09-23T05:08:00Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"If the correct arguments were not specified, this program should exit\nnon-zero.  Let's do so.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex ad23dbf..5459ba7 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -396,7 +396,7 @@ int main(int argc, char *argv[])\n \n \tif (!argv[1]) {\n \t\tusage(argv[0]);\n-\t\tgoto out;\n+\t\texit(EXIT_FAILURE);\n \t}\n \n \t/* lookup operation callback */\n-- \n1.8.4.489.g545bc72\n"},{"id":"228063","messageId":"1379912891-12277-6-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 05/15] contrib/git-credential-gnome-keyring.c: set Gnome application name","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:01Z","receivedAt":"2013-09-23T05:08:01Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Since this is a Gnome application, let's set the application name to\nsomething reasonable.  This will be displayed in Gnome dialog boxes\ne.g. the one that prompts for the user's keyring password.\n\nWe add an include statement for glib.h and add the glib-2.0 cflags and\nlibs to the compilation arguments, but both of these are really noops\nsince glib is already a dependency of gnome-keyring.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n contrib/credential/gnome-keyring/Makefile                       | 4 ++--\n contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 3 +++\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/Makefile b/contrib/credential/gnome-keyring/Makefile\nindex e6561d8..c3c7c98 100644\n--- a/contrib/credential/gnome-keyring/Makefile\n+++ b/contrib/credential/gnome-keyring/Makefile\n@@ -8,8 +8,8 @@ CFLAGS = -g -O2 -Wall\n -include ../../../config.mak.autogen\n -include ../../../config.mak\n \n-INCS:=$(shell pkg-config --cflags gnome-keyring-1)\n-LIBS:=$(shell pkg-config --libs gnome-keyring-1)\n+INCS:=$(shell pkg-config --cflags gnome-keyring-1 glib-2.0)\n+LIBS:=$(shell pkg-config --libs gnome-keyring-1 glib-2.0)\n \n SRCS:=$(MAIN).c\n OBJS:=$(SRCS:.c=.o)\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 5459ba7..5779770 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -28,6 +28,7 @@\n #include <stdarg.h>\n #include <stdlib.h>\n #include <errno.h>\n+#include <glib.h>\n #include <gnome-keyring.h>\n \n /*\n@@ -399,6 +400,8 @@ int main(int argc, char *argv[])\n \t\texit(EXIT_FAILURE);\n \t}\n \n+\tg_set_application_name(\"Git Credential Helper\");\n+\n \t/* lookup operation callback */\n \twhile(try_op->name && strcmp(argv[1], try_op->name))\n \t\ttry_op++;\n-- \n1.8.4.489.g545bc72\n"},{"id":"228053","messageId":"1379912891-12277-7-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 06/15] contrib/git-credential-gnome-keyring.c: strlen() returns size_t, not ssize_t","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:02Z","receivedAt":"2013-09-23T05:08:02Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Also, initialization is not necessary since it is assigned before it is\nused.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 5779770..1081224 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -307,7 +307,7 @@ static void credential_clear(struct credential *c)\n static int credential_read(struct credential *c)\n {\n \tchar    buf[1024];\n-\tssize_t line_len = 0;\n+\tsize_t line_len;\n \tchar   *key      = buf;\n \tchar   *value;\n \n-- \n1.8.4.489.g545bc72\n"},{"id":"228064","messageId":"1379912891-12277-8-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 07/15] contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:03Z","receivedAt":"2013-09-23T05:08:03Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Ensure buffer length is non-zero before attempting to access the last\nelement.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 1081224..8ae2eab 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -315,7 +315,7 @@ static int credential_read(struct credential *c)\n \t{\n \t\tline_len = strlen(buf);\n \n-\t\tif(buf[line_len-1]=='\\n')\n+\t\tif(line_len && buf[line_len-1] == '\\n')\n \t\t\tbuf[--line_len]='\\0';\n \n \t\tif(!line_len)\n-- \n1.8.4.489.g545bc72\n"},{"id":"228056","messageId":"1379912891-12277-9-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 08/15] contrib/git-credential-gnome-keyring.c: use gnome helpers in keyring_object()","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:04Z","receivedAt":"2013-09-23T05:08:04Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Rather than carefully allocating memory for sprintf() to write into,\nlet's make use of the glib helper function g_strdup_printf(), which\nmakes things a lot easier and less error-prone.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c           | 14 +++-----------\n 1 file changed, 3 insertions(+), 11 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 8ae2eab..7565765 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -112,21 +112,13 @@ static inline char *xstrdup(const char *str)\n /* create a special keyring option string, if path is given */\n static char* keyring_object(struct credential *c)\n {\n-\tchar* object = NULL;\n-\n \tif (!c->path)\n-\t\treturn object;\n-\n-\tobject = (char*) malloc(strlen(c->host)+strlen(c->path)+8);\n-\tif(!object)\n-\t\tdie_errno(errno);\n+\t\treturn NULL;\n \n \tif(c->port)\n-\t\tsprintf(object,\"%s:%hd/%s\",c->host,c->port,c->path);\n-\telse\n-\t\tsprintf(object,\"%s/%s\",c->host,c->path);\n+\t\treturn g_strdup_printf(\"%s:%hd/%s\", c->host, c->port, c->path);\n \n-\treturn object;\n+\treturn g_strdup_printf(\"%s/%s\", c->host, c->path);\n }\n \n static int keyring_get(struct credential *c)\n-- \n1.8.4.489.g545bc72\n"},{"id":"228055","messageId":"1379912891-12277-10-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 09/15] contrib/git-credential-gnome-keyring.c: use secure memory functions for passwds","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:05Z","receivedAt":"2013-09-23T05:08:05Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"gnome-keyring provides functions for allocating non-pageable memory (if\npossible) intended to be used for storing passwords.  Let's use them.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c    | 21 ++++++---------------\n 1 file changed, 6 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 7565765..ff2f48c 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -30,6 +30,7 @@\n #include <errno.h>\n #include <glib.h>\n #include <gnome-keyring.h>\n+#include <gnome-keyring-memory.h>\n \n /*\n  * This credential struct and API is simplified from git's credential.{h,c}\n@@ -60,16 +61,6 @@ struct credential_operation\n \n /* ---------------- common helper functions ----------------- */\n \n-static inline void free_password(char *password)\n-{\n-\tchar *c = password;\n-\tif (!password)\n-\t\treturn;\n-\n-\twhile (*c) *c++ = '\\0';\n-\tfree(password);\n-}\n-\n static inline void warning(const char *fmt, ...)\n {\n \tva_list ap;\n@@ -159,8 +150,8 @@ static int keyring_get(struct credential *c)\n \t/* pick the first one from the list */\n \tpassword_data = (GnomeKeyringNetworkPasswordData *) entries->data;\n \n-\tfree_password(c->password);\n-\tc->password = xstrdup(password_data->password);\n+\tgnome_keyring_memory_free(c->password);\n+\tc->password = gnome_keyring_memory_strdup(password_data->password);\n \n \tif (!c->username)\n \t\tc->username = xstrdup(password_data->user);\n@@ -291,7 +282,7 @@ static void credential_clear(struct credential *c)\n \tfree(c->host);\n \tfree(c->path);\n \tfree(c->username);\n-\tfree_password(c->password);\n+\tgnome_keyring_memory_free(c->password);\n \n \tcredential_init(c);\n }\n@@ -338,8 +329,8 @@ static int credential_read(struct credential *c)\n \t\t\tfree(c->username);\n \t\t\tc->username = xstrdup(value);\n \t\t} else if (!strcmp(key, \"password\")) {\n-\t\t\tfree_password(c->password);\n-\t\t\tc->password = xstrdup(value);\n+\t\t\tgnome_keyring_memory_free(c->password);\n+\t\t\tc->password = gnome_keyring_memory_strdup(value);\n \t\t\twhile (*value) *value++ = '\\0';\n \t\t}\n \t\t/*\n-- \n1.8.4.489.g545bc72\n"},{"id":"228059","messageId":"1379912891-12277-11-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 10/15] contrib/git-credential-gnome-keyring.c: use secure memory for reading passwords","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:06Z","receivedAt":"2013-09-23T05:08:06Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"gnome-keyring provides functions to allocate non-pageable memory (if\npossible).  Let's use them to allocate memory that may be used to hold\nsecure data read from the keyring.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../credential/gnome-keyring/git-credential-gnome-keyring.c  | 12 +++++++++---\n 1 file changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex ff2f48c..94a65b2 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -289,12 +289,14 @@ static void credential_clear(struct credential *c)\n \n static int credential_read(struct credential *c)\n {\n-\tchar    buf[1024];\n+\tchar    *buf;\n \tsize_t line_len;\n-\tchar   *key      = buf;\n+\tchar   *key;\n \tchar   *value;\n \n-\twhile (fgets(buf, sizeof(buf), stdin))\n+\tkey = buf = gnome_keyring_memory_alloc(1024);\n+\n+\twhile (fgets(buf, 1024, stdin))\n \t{\n \t\tline_len = strlen(buf);\n \n@@ -307,6 +309,7 @@ static int credential_read(struct credential *c)\n \t\tvalue = strchr(buf,'=');\n \t\tif(!value) {\n \t\t\twarning(\"invalid credential line: %s\", key);\n+\t\t\tgnome_keyring_memory_free(buf);\n \t\t\treturn -1;\n \t\t}\n \t\t*value++ = '\\0';\n@@ -339,6 +342,9 @@ static int credential_read(struct credential *c)\n \t\t * learn new lines, and the helpers are updated to match.\n \t\t */\n \t}\n+\n+\tgnome_keyring_memory_free(buf);\n+\n \treturn 0;\n }\n \n-- \n1.8.4.489.g545bc72\n"},{"id":"228060","messageId":"1379912891-12277-12-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 11/15] contrib/git-credential-gnome-keyring.c: use glib memory allocation functions","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:07Z","receivedAt":"2013-09-23T05:08:07Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Rather than roll our own, let's use the memory allocation/free routines\nprovided by glib.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c   | 48 ++++++++--------------\n 1 file changed, 16 insertions(+), 32 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 94a65b2..5b10e3e 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -27,7 +27,6 @@\n #include <string.h>\n #include <stdarg.h>\n #include <stdlib.h>\n-#include <errno.h>\n #include <glib.h>\n #include <gnome-keyring.h>\n #include <gnome-keyring-memory.h>\n@@ -83,21 +82,6 @@ static inline void error(const char *fmt, ...)\n \tva_end(ap);\n }\n \n-static inline void die_errno(int err)\n-{\n-\terror(\"%s\", strerror(err));\n-\texit(EXIT_FAILURE);\n-}\n-\n-static inline char *xstrdup(const char *str)\n-{\n-\tchar *ret = strdup(str);\n-\tif (!ret)\n-\t\tdie_errno(errno);\n-\n-\treturn ret;\n-}\n-\n /* ----------------- GNOME Keyring functions ----------------- */\n \n /* create a special keyring option string, if path is given */\n@@ -134,7 +118,7 @@ static int keyring_get(struct credential *c)\n \t\t\t\tc->port,\n \t\t\t\t&entries);\n \n-\tfree(object);\n+\tg_free(object);\n \n \tif (result == GNOME_KEYRING_RESULT_NO_MATCH)\n \t\treturn EXIT_SUCCESS;\n@@ -154,7 +138,7 @@ static int keyring_get(struct credential *c)\n \tc->password = gnome_keyring_memory_strdup(password_data->password);\n \n \tif (!c->username)\n-\t\tc->username = xstrdup(password_data->user);\n+\t\tc->username = g_strdup(password_data->user);\n \n \tgnome_keyring_network_password_list_free(entries);\n \n@@ -192,7 +176,7 @@ static int keyring_store(struct credential *c)\n \t\t\t\tc->password,\n \t\t\t\t&item_id);\n \n-\tfree(object);\n+\tg_free(object);\n \treturn EXIT_SUCCESS;\n }\n \n@@ -226,7 +210,7 @@ static int keyring_erase(struct credential *c)\n \t\t\t\tc->port,\n \t\t\t\t&entries);\n \n-\tfree(object);\n+\tg_free(object);\n \n \tif (result == GNOME_KEYRING_RESULT_NO_MATCH)\n \t\treturn EXIT_SUCCESS;\n@@ -278,10 +262,10 @@ static void credential_init(struct credential *c)\n \n static void credential_clear(struct credential *c)\n {\n-\tfree(c->protocol);\n-\tfree(c->host);\n-\tfree(c->path);\n-\tfree(c->username);\n+\tg_free(c->protocol);\n+\tg_free(c->host);\n+\tg_free(c->path);\n+\tg_free(c->username);\n \tgnome_keyring_memory_free(c->password);\n \n \tcredential_init(c);\n@@ -315,22 +299,22 @@ static int credential_read(struct credential *c)\n \t\t*value++ = '\\0';\n \n \t\tif (!strcmp(key, \"protocol\")) {\n-\t\t\tfree(c->protocol);\n-\t\t\tc->protocol = xstrdup(value);\n+\t\t\tg_free(c->protocol);\n+\t\t\tc->protocol = g_strdup(value);\n \t\t} else if (!strcmp(key, \"host\")) {\n-\t\t\tfree(c->host);\n-\t\t\tc->host = xstrdup(value);\n+\t\t\tg_free(c->host);\n+\t\t\tc->host = g_strdup(value);\n \t\t\tvalue = strrchr(c->host,':');\n \t\t\tif (value) {\n \t\t\t\t*value++ = '\\0';\n \t\t\t\tc->port = atoi(value);\n \t\t\t}\n \t\t} else if (!strcmp(key, \"path\")) {\n-\t\t\tfree(c->path);\n-\t\t\tc->path = xstrdup(value);\n+\t\t\tg_free(c->path);\n+\t\t\tc->path = g_strdup(value);\n \t\t} else if (!strcmp(key, \"username\")) {\n-\t\t\tfree(c->username);\n-\t\t\tc->username = xstrdup(value);\n+\t\t\tg_free(c->username);\n+\t\t\tc->username = g_strdup(value);\n \t\t} else if (!strcmp(key, \"password\")) {\n \t\t\tgnome_keyring_memory_free(c->password);\n \t\t\tc->password = gnome_keyring_memory_strdup(value);\n-- \n1.8.4.489.g545bc72\n"},{"id":"228057","messageId":"1379912891-12277-13-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 12/15] contrib/git-credential-gnome-keyring.c: use glib messaging functions","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:08Z","receivedAt":"2013-09-23T05:08:08Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Rather than roll our own, let's use the messaging functions provided\nby glib.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c   | 33 +++-------------------\n 1 file changed, 4 insertions(+), 29 deletions(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 5b10e3e..a6369a3 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -25,7 +25,6 @@\n \n #include <stdio.h>\n #include <string.h>\n-#include <stdarg.h>\n #include <stdlib.h>\n #include <glib.h>\n #include <gnome-keyring.h>\n@@ -58,30 +57,6 @@ struct credential_operation\n #define CREDENTIAL_OP_END \\\n   { NULL,NULL }\n \n-/* ---------------- common helper functions ----------------- */\n-\n-static inline void warning(const char *fmt, ...)\n-{\n-\tva_list ap;\n-\n-\tva_start(ap, fmt);\n-\tfprintf(stderr, \"warning: \");\n-\tvfprintf(stderr, fmt, ap);\n-\tfprintf(stderr, \"\\n\" );\n-\tva_end(ap);\n-}\n-\n-static inline void error(const char *fmt, ...)\n-{\n-\tva_list ap;\n-\n-\tva_start(ap, fmt);\n-\tfprintf(stderr, \"error: \");\n-\tvfprintf(stderr, fmt, ap);\n-\tfprintf(stderr, \"\\n\" );\n-\tva_end(ap);\n-}\n-\n /* ----------------- GNOME Keyring functions ----------------- */\n \n /* create a special keyring option string, if path is given */\n@@ -127,7 +102,7 @@ static int keyring_get(struct credential *c)\n \t\treturn EXIT_SUCCESS;\n \n \tif (result != GNOME_KEYRING_RESULT_OK) {\n-\t\terror(\"%s\",gnome_keyring_result_to_message(result));\n+\t\tg_critical(\"%s\", gnome_keyring_result_to_message(result));\n \t\treturn EXIT_FAILURE;\n \t}\n \n@@ -220,7 +195,7 @@ static int keyring_erase(struct credential *c)\n \n \tif (result != GNOME_KEYRING_RESULT_OK)\n \t{\n-\t\terror(\"%s\",gnome_keyring_result_to_message(result));\n+\t\tg_critical(\"%s\", gnome_keyring_result_to_message(result));\n \t\treturn EXIT_FAILURE;\n \t}\n \n@@ -234,7 +209,7 @@ static int keyring_erase(struct credential *c)\n \n \tif (result != GNOME_KEYRING_RESULT_OK)\n \t{\n-\t\terror(\"%s\",gnome_keyring_result_to_message(result));\n+\t\tg_critical(\"%s\", gnome_keyring_result_to_message(result));\n \t\treturn EXIT_FAILURE;\n \t}\n \n@@ -292,7 +267,7 @@ static int credential_read(struct credential *c)\n \n \t\tvalue = strchr(buf,'=');\n \t\tif(!value) {\n-\t\t\twarning(\"invalid credential line: %s\", key);\n+\t\t\tg_warning(\"invalid credential line: %s\", key);\n \t\t\tgnome_keyring_memory_free(buf);\n \t\t\treturn -1;\n \t\t}\n-- \n1.8.4.489.g545bc72\n"},{"id":"228061","messageId":"1379912891-12277-14-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 13/15] contrib/git-credential-gnome-keyring.c: report failure to store password","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:09Z","receivedAt":"2013-09-23T05:08:09Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Produce an error message when we fail to store a password to the keyring.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 9 ++++++++-\n 1 file changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex a6369a3..6fa1278 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -125,6 +125,7 @@ static int keyring_store(struct credential *c)\n {\n \tguint32 item_id;\n \tchar  *object = NULL;\n+\tGnomeKeyringResult result;\n \n \t/*\n \t * Sanity check that what we are storing is actually sensible.\n@@ -139,7 +140,7 @@ static int keyring_store(struct credential *c)\n \n \tobject = keyring_object(c);\n \n-\tgnome_keyring_set_network_password_sync(\n+\tresult = gnome_keyring_set_network_password_sync(\n \t\t\t\tGNOME_KEYRING_DEFAULT,\n \t\t\t\tc->username,\n \t\t\t\tNULL /* domain */,\n@@ -152,6 +153,12 @@ static int keyring_store(struct credential *c)\n \t\t\t\t&item_id);\n \n \tg_free(object);\n+\n+\tif (result != GNOME_KEYRING_RESULT_OK) {\n+\t\tg_critical(\"%s\", gnome_keyring_result_to_message(result));\n+\t\treturn EXIT_FAILURE;\n+\t}\n+\n \treturn EXIT_SUCCESS;\n }\n \n-- \n1.8.4.489.g545bc72\n"},{"id":"228058","messageId":"1379912891-12277-15-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 14/15] contrib/git-credential-gnome-keyring.c: support ancient gnome-keyring","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:10Z","receivedAt":"2013-09-23T05:08:10Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The gnome-keyring lib distributed with RHEL 5.X is ancient and does\nnot provide a few of the functions/defines that more recent versions\ndo, but mostly the API is the same.  Let's provide the missing bits\nvia macro definitions and function implementation.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c   | 58 ++++++++++++++++++++++\n 1 file changed, 58 insertions(+)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex 6fa1278..f8f4df9 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -28,8 +28,66 @@\n #include <stdlib.h>\n #include <glib.h>\n #include <gnome-keyring.h>\n+\n+#ifdef GNOME_KEYRING_DEFAULT\n+\n+   /* Modern gnome-keyring */\n+\n #include <gnome-keyring-memory.h>\n \n+#else\n+\n+   /*\n+    * Support ancient gnome-keyring, circ. RHEL 5.X.\n+    * GNOME_KEYRING_DEFAULT seems to have been introduced with Gnome 2.22,\n+    * and the other features roughly around Gnome 2.20, 6 months before.\n+    * Ubuntu 8.04 used Gnome 2.22 (I think).  Not sure any distro used 2.20.\n+    * So the existence/non-existence of GNOME_KEYRING_DEFAULT seems like\n+    * a decent thing to use as an indicator.\n+    */\n+\n+#define GNOME_KEYRING_DEFAULT NULL\n+\n+/*\n+ * ancient gnome-keyring returns DENIED when an entry is not found.\n+ * Setting NO_MATCH to DENIED will prevent us from reporting denied\n+ * errors during get and erase operations, but we will still report\n+ * DENIED errors during a store.\n+ */\n+#define GNOME_KEYRING_RESULT_NO_MATCH GNOME_KEYRING_RESULT_DENIED\n+\n+#define gnome_keyring_memory_alloc g_malloc\n+#define gnome_keyring_memory_free gnome_keyring_free_password\n+#define gnome_keyring_memory_strdup g_strdup\n+\n+static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)\n+{\n+\tswitch (result) {\n+\tcase GNOME_KEYRING_RESULT_OK:\n+\t\treturn \"OK\";\n+\tcase GNOME_KEYRING_RESULT_DENIED:\n+\t\treturn \"Denied\";\n+\tcase GNOME_KEYRING_RESULT_NO_KEYRING_DAEMON:\n+\t\treturn \"No Keyring Daemon\";\n+\tcase GNOME_KEYRING_RESULT_ALREADY_UNLOCKED:\n+\t\treturn \"Already UnLocked\";\n+\tcase GNOME_KEYRING_RESULT_NO_SUCH_KEYRING:\n+\t\treturn \"No Such Keyring\";\n+\tcase GNOME_KEYRING_RESULT_BAD_ARGUMENTS:\n+\t\treturn \"Bad Arguments\";\n+\tcase GNOME_KEYRING_RESULT_IO_ERROR:\n+\t\treturn \"IO Error\";\n+\tcase GNOME_KEYRING_RESULT_CANCELLED:\n+\t\treturn \"Cancelled\";\n+\tcase GNOME_KEYRING_RESULT_ALREADY_EXISTS:\n+\t\treturn \"Already Exists\";\n+\tdefault:\n+\t\treturn \"Unknown Error\";\n+\t}\n+}\n+\n+#endif\n+\n /*\n  * This credential struct and API is simplified from git's credential.{h,c}\n  */\n-- \n1.8.4.489.g545bc72\n"},{"id":"228062","messageId":"1379912891-12277-16-git-send-email-drafnel@gmail.com","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"[PATCH 15/15] contrib/git-credential-gnome-keyring.c: support really ancient gnome-keyring","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T05:08:11Z","receivedAt":"2013-09-23T05:08:11Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The gnome-keyring lib (0.4) distributed with RHEL 4.X is really ancient\nand does not provide most of the synchronous functions that even ancient\nreleases do.  Thankfully, we're only using one function that is missing.\nLet's emulate gnome_keyring_item_delete_sync() by calling the asynchronous\nfunction and then triggering the event loop processing until our\ncallback is called.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c   | 39 ++++++++++++++++++++++\n 1 file changed, 39 insertions(+)\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex f8f4df9..ce2ddee 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -86,6 +86,45 @@ static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)\n \t}\n }\n \n+/*\n+ * Just a guess to support RHEL 4.X.\n+ * Glib 2.8 was roughly Gnome 2.12 ?\n+ * Which was released with gnome-keyring 0.4.3 ??\n+ */\n+#if GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 8\n+\n+static void gnome_keyring_done_cb(GnomeKeyringResult result, gpointer user_data)\n+{\n+\tgpointer *data = (gpointer*) user_data;\n+\tint *done = (int*) data[0];\n+\tGnomeKeyringResult *r = (GnomeKeyringResult*) data[1];\n+\n+\t*r = result;\n+\t*done = 1;\n+}\n+\n+static void wait_for_request_completion(int *done)\n+{\n+\tGMainContext *mc = g_main_context_default();\n+\twhile (!*done)\n+\t\tg_main_context_iteration(mc, TRUE);\n+}\n+\n+static GnomeKeyringResult gnome_keyring_item_delete_sync(const char *keyring, guint32 id)\n+{\n+\tint done = 0;\n+\tGnomeKeyringResult result;\n+\tgpointer data[] = { &done, &result };\n+\n+\tgnome_keyring_item_delete(keyring, id, gnome_keyring_done_cb, data,\n+\t\tNULL);\n+\n+\twait_for_request_completion(&done);\n+\n+\treturn result;\n+}\n+\n+#endif\n #endif\n \n /*\n-- \n1.8.4.489.g545bc72\n"},{"id":"228066","messageId":"523fd4f6965ad_b79d67e786506@nysa.mail","threadId":"34997","inReplyTo":"1379912891-12277-8-git-send-email-drafnel@gmail.com","subject":"RE: [PATCH 07/15] contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-09-23T05:43:18Z","receivedAt":"2013-09-23T05:43:18Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Brandon Casey wrote:\n> Ensure buffer length is non-zero before attempting to access the last\n> element.\n> \n> Signed-off-by: Brandon Casey <drafnel@gmail.com>\n> ---\n>  contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n> index 1081224..8ae2eab 100644\n> --- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n> +++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n> @@ -315,7 +315,7 @@ static int credential_read(struct credential *c)\n>  \t{\n>  \t\tline_len = strlen(buf);\n>  \n> -\t\tif(buf[line_len-1]=='\\n')\n> +\t\tif(line_len && buf[line_len-1] == '\\n')\n\nThe style is if ().\n\n-- \nFelipe Contreras\n"},{"id":"228070","messageId":"20130923102022.GA96514@yoda.local","threadId":"34997","inReplyTo":"1379912891-12277-1-git-send-email-drafnel@gmail.com","subject":"Re: [PATCH 00/15] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"John Szakmeister","fromEmail":"john@szakmeister.net","sentAt":"2013-09-23T10:20:22Z","receivedAt":"2013-09-23T10:20:22Z","isPatch":true,"sender":{"key":"john@szakmeister.net","avatar":"https://avatars.githubusercontent.com/u/448087?v=4"},"body":"On Sun, Sep 22, 2013 at 10:07:56PM -0700, Brandon Casey wrote:\n> A few cleanups, followed by improved usage of the glib library (no need\n> to reinvent the wheel when glib provides the necessary functionality), and\n> then the addition of support for RHEL 4.x and 5.x.\n> \n> Brandon Casey (15):\n>   contrib/git-credential-gnome-keyring.c: remove unnecessary\n>     pre-declarations\n>   contrib/git-credential-gnome-keyring.c: remove unused die() function\n>   contrib/git-credential-gnome-keyring.c: add static where applicable\n>   contrib/git-credential-gnome-keyring.c: exit non-zero when called\n>     incorrectly\n>   contrib/git-credential-gnome-keyring.c: set Gnome application name\n>   contrib/git-credential-gnome-keyring.c: strlen() returns size_t, not\n>     ssize_t\n>   contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty\n>     before accessing\n>   contrib/git-credential-gnome-keyring.c: use gnome helpers in\n>     keyring_object()\n>   contrib/git-credential-gnome-keyring.c: use secure memory functions\n>     for passwds\n>   contrib/git-credential-gnome-keyring.c: use secure memory for reading\n>     passwords\n>   contrib/git-credential-gnome-keyring.c: use glib memory allocation\n>     functions\n>   contrib/git-credential-gnome-keyring.c: use glib messaging functions\n>   contrib/git-credential-gnome-keyring.c: report failure to store\n>     password\n>   contrib/git-credential-gnome-keyring.c: support ancient gnome-keyring\n>   contrib/git-credential-gnome-keyring.c: support really ancient\n>     gnome-keyring\n\nI reviewed all of the commits in this series, and most are nice\ncleanups.  The only thing I'm a little shaky on is RHEL4\nsupport (patch 15).  In particular, this:\n\n    +/*\n    + * Just a guess to support RHEL 4.X.\n    + * Glib 2.8 was roughly Gnome 2.12 ?\n    + * Which was released with gnome-keyring 0.4.3 ??\n    + */\n\nHas that code been tested on RHEL4 at all?  I imagine it's hard\nto come by--it's pretty darn old--but it feels like a mistake to\ncommit untested code.\n\nOtherwise, there are a few stylistic nits that I'd like to clean\nup.  Only one was introduced by you--Felipe pointed it out--and\nI have a patch for the rest that I can submit after your series\nhas been applied.\n\nAcked-by: John Szakmeister <john@szakmeister.net>\n\n-John\n"},{"id":"228071","messageId":"CA+sFfMfhQ3ioMrppcTKaQ_0kMMjFuJ8mtv9iK+ixD8Ep0CFi4Q@mail.gmail.com","threadId":"34997","inReplyTo":"20130923102022.GA96514@yoda.local","subject":"Re: [PATCH 00/15] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T17:21:15Z","receivedAt":"2013-09-23T17:21:15Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Mon, Sep 23, 2013 at 3:20 AM, John Szakmeister <john@szakmeister.net> wrote:\n> On Sun, Sep 22, 2013 at 10:07:56PM -0700, Brandon Casey wrote:\n>> A few cleanups, followed by improved usage of the glib library (no need\n>> to reinvent the wheel when glib provides the necessary functionality), and\n>> then the addition of support for RHEL 4.x and 5.x.\n>>\n>> Brandon Casey (15):\n<snip>\n\n> I reviewed all of the commits in this series, and most are nice\n> cleanups.  The only thing I'm a little shaky on is RHEL4\n> support (patch 15).  In particular, this:\n>\n>     +/*\n>     + * Just a guess to support RHEL 4.X.\n>     + * Glib 2.8 was roughly Gnome 2.12 ?\n>     + * Which was released with gnome-keyring 0.4.3 ??\n>     + */\n>\n> Has that code been tested on RHEL4 at all?  I imagine it's hard\n> to come by--it's pretty darn old--but it feels like a mistake to\n> commit untested code.\n\nThe (poorly worded) comment is referring to the version of glib that\nis being tested by the pre-processor statements.  Since gnome-keyring\ndoesn't provide a way to test its version, and I'm not sure exactly\nwhich gnome release included gnome-keyring 0.4.3 or which glib version\nwas distributed with which gnome version, I'm just roughly guessing\nbased on dates and not-conclusive google searches that 2.8 is\nreasonable.\n\nI'll try to clarify the wording here.\n\nThe code has been tested on CentOS 4.X.\n\n> Otherwise, there are a few stylistic nits that I'd like to clean\n> up.  Only one was introduced by you--Felipe pointed it out--and\n\nWell, not exactly \"introduced\" by me, but I guess I can fix it in that\nsame patch. :)\n\n> I have a patch for the rest that I can submit after your series\n> has been applied.\n\nSounds good.\n\n> Acked-by: John Szakmeister <john@szakmeister.net>\n\n-Brandon\n"},{"id":"228072","messageId":"CA+sFfMc9xzPvR55gxriFd_dxPra4kvB6+2MRnq5haQTwPwUnLw@mail.gmail.com","threadId":"34997","inReplyTo":"523fd4f6965ad_b79d67e786506@nysa.mail","subject":"Re: [PATCH 07/15] contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2013-09-23T17:21:28Z","receivedAt":"2013-09-23T17:21:28Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Thanks.\n\nOn Sun, Sep 22, 2013 at 10:43 PM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> Brandon Casey wrote:\n>> Ensure buffer length is non-zero before attempting to access the last\n>> element.\n>>\n>> Signed-off-by: Brandon Casey <drafnel@gmail.com>\n>> ---\n>>  contrib/credential/gnome-keyring/git-credential-gnome-keyring.c | 2 +-\n>>  1 file changed, 1 insertion(+), 1 deletion(-)\n>>\n>> diff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n>> index 1081224..8ae2eab 100644\n>> --- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n>> +++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n>> @@ -315,7 +315,7 @@ static int credential_read(struct credential *c)\n>>       {\n>>               line_len = strlen(buf);\n>>\n>> -             if(buf[line_len-1]=='\\n')\n>> +             if(line_len && buf[line_len-1] == '\\n')\n>\n> The style is if ().\n>\n> --\n> Felipe Contreras\n"}]}