{"thread":{"id":"34999","subject":"[PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","startedAt":"2013-09-23T18:49:01Z","lastAt":"2013-10-16T21:38:43Z","messageCount":23,"participants":["Brandon Casey","Felipe Contreras","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":16},"messages":[{"id":"228078","messageId":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":null,"subject":"[PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:01Z","receivedAt":"2013-09-23T18:49:01Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nMostly unchanged.\n\nInserts a patch to fix the style issues for block statements.\ni.e. use \"if ()\" instead of \"if()\"\n\nA couple early patches were reordered to improve logical flow.\n\nUpdated the comment in the last patch to hopefully improve clarity\nwrt RHEL 4.X\n\nThe only functional change is in 14/16 \"report failure to store\".\nWe should accept GNOME_KEYRING_RESULT_CANCELLED as a successful\nreturn and _not_ produce an error message.\n\nInterdiff follows...\n\nBrandon Casey (16):\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: *style* use \"if ()\" not \"if()\"\n    etc.\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: 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: set Gnome application name\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   | 301 ++++++++++++---------\n 2 files changed, 169 insertions(+), 136 deletions(-)\n\n---\n\ndiff --git a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\nindex ce2ddee..635c96b 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -50,7 +50,7 @@\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+ * 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@@ -87,8 +87,8 @@ static const char* gnome_keyring_result_to_message(GnomeKeyringResult result)\n }\n \n /*\n- * Just a guess to support RHEL 4.X.\n- * Glib 2.8 was roughly Gnome 2.12 ?\n+ * Support really ancient gnome-keyring, circ. RHEL 4.X.\n+ * Just a guess for the Glib version.  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@@ -162,7 +162,7 @@ static char* keyring_object(struct credential *c)\n \tif (!c->path)\n \t\treturn NULL;\n \n-\tif(c->port)\n+\tif (c->port)\n \t\treturn g_strdup_printf(\"%s:%hd/%s\", c->host, c->port, c->path);\n \n \treturn g_strdup_printf(\"%s/%s\", c->host, c->path);\n@@ -251,7 +251,8 @@ static int keyring_store(struct credential *c)\n \n \tg_free(object);\n \n-\tif (result != GNOME_KEYRING_RESULT_OK) {\n+\tif (result != GNOME_KEYRING_RESULT_OK &&\n+\t    result != GNOME_KEYRING_RESULT_CANCELLED) {\n \t\tg_critical(\"%s\", gnome_keyring_result_to_message(result));\n \t\treturn EXIT_FAILURE;\n \t}\n@@ -363,14 +364,14 @@ static int credential_read(struct credential *c)\n \t{\n \t\tline_len = strlen(buf);\n \n-\t\tif(line_len && 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+\t\tif (!line_len)\n \t\t\tbreak;\n \n \t\tvalue = strchr(buf,'=');\n-\t\tif(!value) {\n+\t\tif (!value) {\n \t\t\tg_warning(\"invalid credential line: %s\", key);\n \t\t\tgnome_keyring_memory_free(buf);\n \t\t\treturn -1;\n@@ -432,9 +433,9 @@ static void usage(const char *name)\n \n \tbasename = (basename) ? basename + 1 : name;\n \tfprintf(stderr, \"usage: %s <\", basename);\n-\twhile(try_op->name) {\n+\twhile (try_op->name) {\n \t\tfprintf(stderr,\"%s\",(try_op++)->name);\n-\t\tif(try_op->name)\n+\t\tif (try_op->name)\n \t\t\tfprintf(stderr,\"%s\",\"|\");\n \t}\n \tfprintf(stderr,\"%s\",\">\\n\");\n@@ -455,15 +456,15 @@ int main(int argc, char *argv[])\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+\twhile (try_op->name && strcmp(argv[1], try_op->name))\n \t\ttry_op++;\n \n \t/* unsupported operation given -- ignore silently */\n-\tif(!try_op->name || !try_op->op)\n+\tif (!try_op->name || !try_op->op)\n \t\tgoto out;\n \n \tret = credential_read(&cred);\n-\tif(ret)\n+\tif (ret)\n \t\tgoto out;\n \n \t/* perform credential operation */\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228088","messageId":"1379962157-1338-2-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 01/16] contrib/git-credential-gnome-keyring.c: remove unnecessary pre-declarations","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:02Z","receivedAt":"2013-09-23T18:49:02Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nThese 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228081","messageId":"1379962157-1338-3-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 02/16] contrib/git-credential-gnome-keyring.c: remove unused die() function","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:03Z","receivedAt":"2013-09-23T18:49:03Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nSigned-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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228079","messageId":"1379962157-1338-4-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 03/16] contrib/git-credential-gnome-keyring.c: *style* use \"if ()\" not \"if()\" etc.","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:04Z","receivedAt":"2013-09-23T18:49:04Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n .../gnome-keyring/git-credential-gnome-keyring.c     | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 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 4334f23..809b1b7 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -117,10 +117,10 @@ static char* keyring_object(struct credential *c)\n \t\treturn object;\n \n \tobject = (char*) malloc(strlen(c->host)+strlen(c->path)+8);\n-\tif(!object)\n+\tif (!object)\n \t\tdie_errno(errno);\n \n-\tif(c->port)\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@@ -314,14 +314,14 @@ 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 (buf[line_len-1]=='\\n')\n \t\t\tbuf[--line_len]='\\0';\n \n-\t\tif(!line_len)\n+\t\tif (!line_len)\n \t\t\tbreak;\n \n \t\tvalue = strchr(buf,'=');\n-\t\tif(!value) {\n+\t\tif (!value) {\n \t\t\twarning(\"invalid credential line: %s\", key);\n \t\t\treturn -1;\n \t\t}\n@@ -379,9 +379,9 @@ static void usage(const char *name)\n \n \tbasename = (basename) ? basename + 1 : name;\n \tfprintf(stderr, \"usage: %s <\", basename);\n-\twhile(try_op->name) {\n+\twhile (try_op->name) {\n \t\tfprintf(stderr,\"%s\",(try_op++)->name);\n-\t\tif(try_op->name)\n+\t\tif (try_op->name)\n \t\t\tfprintf(stderr,\"%s\",\"|\");\n \t}\n \tfprintf(stderr,\"%s\",\">\\n\");\n@@ -400,15 +400,15 @@ int main(int argc, char *argv[])\n \t}\n \n \t/* lookup operation callback */\n-\twhile(try_op->name && strcmp(argv[1], try_op->name))\n+\twhile (try_op->name && strcmp(argv[1], try_op->name))\n \t\ttry_op++;\n \n \t/* unsupported operation given -- ignore silently */\n-\tif(!try_op->name || !try_op->op)\n+\tif (!try_op->name || !try_op->op)\n \t\tgoto out;\n \n \tret = credential_read(&cred);\n-\tif(ret)\n+\tif (ret)\n \t\tgoto out;\n \n \t/* perform credential operation */\n-- \n1.8.4.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228084","messageId":"1379962157-1338-5-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 04/16] contrib/git-credential-gnome-keyring.c: add static where applicable","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:05Z","receivedAt":"2013-09-23T18:49:05Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nMark 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 809b1b7..3ff541c 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228083","messageId":"1379962157-1338-6-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 05/16] contrib/git-credential-gnome-keyring.c: exit non-zero when called incorrectly","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:06Z","receivedAt":"2013-09-23T18:49:06Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nIf 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 3ff541c..04852d7 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228092","messageId":"1379962157-1338-7-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 06/16] contrib/git-credential-gnome-keyring.c: strlen() returns size_t, not ssize_t","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:07Z","receivedAt":"2013-09-23T18:49:07Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nAlso, 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 04852d7..b9bb794 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -306,7 +306,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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228093","messageId":"1379962157-1338-8-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 07/16] contrib/git-credential-gnome-keyring.c: ensure buffer is non-empty before accessing","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:08Z","receivedAt":"2013-09-23T18:49:08Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nEnsure 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 b9bb794..0d2c55e 100644\n--- a/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n+++ b/contrib/credential/gnome-keyring/git-credential-gnome-keyring.c\n@@ -314,7 +314,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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228094","messageId":"1379962157-1338-9-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 08/16] contrib/git-credential-gnome-keyring.c: set Gnome application name","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:09Z","receivedAt":"2013-09-23T18:49:09Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nSince 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 0d2c55e..43b19dd 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228091","messageId":"1379962157-1338-10-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 09/16] contrib/git-credential-gnome-keyring.c: use gnome helpers in keyring_object()","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:10Z","receivedAt":"2013-09-23T18:49:10Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nRather 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 43b19dd..b692e1f 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228089","messageId":"1379962157-1338-11-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 10/16] contrib/git-credential-gnome-keyring.c: use secure memory functions for passwds","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:11Z","receivedAt":"2013-09-23T18:49:11Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\ngnome-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 b692e1f..d8a7038 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228090","messageId":"1379962157-1338-12-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 11/16] contrib/git-credential-gnome-keyring.c: use secure memory for reading passwords","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:12Z","receivedAt":"2013-09-23T18:49:12Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\ngnome-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 d8a7038..5e79669 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228080","messageId":"1379962157-1338-13-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 12/16] contrib/git-credential-gnome-keyring.c: use glib memory allocation functions","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:13Z","receivedAt":"2013-09-23T18:49:13Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nRather 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 5e79669..273c43b 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228087","messageId":"1379962157-1338-14-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 13/16] contrib/git-credential-gnome-keyring.c: use glib messaging functions","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:14Z","receivedAt":"2013-09-23T18:49:14Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nRather 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 273c43b..b70bd53 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228082","messageId":"1379962157-1338-15-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 14/16] contrib/git-credential-gnome-keyring.c: report failure to store password","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:15Z","receivedAt":"2013-09-23T18:49:15Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nProduce an error message when we fail to store a password to the keyring.\n\nSigned-off-by: Brandon Casey <drafnel@gmail.com>\n---\n\nDifference from v1:\nAdditionally interpret GNOME_KEYRING_RESULT_CANCELLED as a successful exit\nstatus, since that means that the user intentionally cancelled the\noperation from the gui.  We should not produce a warning in that case.\n\n .../credential/gnome-keyring/git-credential-gnome-keyring.c    | 10 +++++++++-\n 1 file changed, 9 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 b70bd53..447e9aa 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,13 @@ 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    result != GNOME_KEYRING_RESULT_CANCELLED) {\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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228086","messageId":"1379962157-1338-16-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 15/16] contrib/git-credential-gnome-keyring.c: support ancient gnome-keyring","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:16Z","receivedAt":"2013-09-23T18:49:16Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nThe 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 447e9aa..e1bc3fa 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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228085","messageId":"1379962157-1338-17-git-send-email-bcasey@nvidia.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"[PATCH v2 16/16] contrib/git-credential-gnome-keyring.c: support really ancient gnome-keyring","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-09-23T18:49:17Z","receivedAt":"2013-09-23T18:49:17Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"From: Brandon Casey <drafnel@gmail.com>\n\nThe 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\nClarified the comment about RHEL 4.X support.\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 e1bc3fa..635c96b 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+ * Support really ancient gnome-keyring, circ. RHEL 4.X.\n+ * Just a guess for the Glib version.  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.rc4.6.g5555d19\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"228100","messageId":"CAMP44s0AnN4t9xuWQy9e09=m1quRegyCtGtizTjP_Ovw62Lycg@mail.gmail.com","threadId":"34999","inReplyTo":"1379962157-1338-16-git-send-email-bcasey@nvidia.com","subject":"Re: [PATCH v2 15/16] contrib/git-credential-gnome-keyring.c: support ancient gnome-keyring","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-09-23T20:14:09Z","receivedAt":"2013-09-23T20:14:09Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Sep 23, 2013 at 1:49 PM, Brandon Casey <bcasey@nvidia.com> wrote:\n> From: Brandon Casey <drafnel@gmail.com>\n>\n> The gnome-keyring lib distributed with RHEL 5.X is ancient and does\n> not provide a few of the functions/defines that more recent versions\n> do, but mostly the API is the same.  Let's provide the missing bits\n> via macro definitions and function implementation.\n>\n> Signed-off-by: Brandon Casey <drafnel@gmail.com>\n> ---\n>  .../gnome-keyring/git-credential-gnome-keyring.c   | 58 ++++++++++++++++++++++\n>  1 file changed, 58 insertions(+)\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 447e9aa..e1bc3fa 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\nThe style is:\nstatic const char *gnome_keyring_result_to_message\n\nThere might not be a need to reroll, depending on what Junio says.\n\n-- \nFelipe Contreras\n"},{"id":"228101","messageId":"CAMP44s2G9=eheeyhXB06cH6mDL_nx3OkZics0bTLzRpxYiXt9Q@mail.gmail.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"Re: [PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-09-23T20:15:30Z","receivedAt":"2013-09-23T20:15:30Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Mon, Sep 23, 2013 at 1:49 PM, Brandon Casey <bcasey@nvidia.com> wrote:\n> From: Brandon Casey <drafnel@gmail.com>\n>\n> Mostly unchanged.\n>\n> Inserts a patch to fix the style issues for block statements.\n> i.e. use \"if ()\" instead of \"if()\"\n>\n> A couple early patches were reordered to improve logical flow.\n>\n> Updated the comment in the last patch to hopefully improve clarity\n> wrt RHEL 4.X\n>\n> The only functional change is in 14/16 \"report failure to store\".\n> We should accept GNOME_KEYRING_RESULT_CANCELLED as a successful\n> return and _not_ produce an error message.\n>\n> Interdiff follows...\n\nI'm familiar with GLib and I looked at the patches, they look good to me.\n\n-- \nFelipe Contreras\n"},{"id":"228115","messageId":"20130924034932.GB2766@sigill.intra.peff.net","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"Re: [PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-09-24T03:49:32Z","receivedAt":"2013-09-24T03:49:32Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Sep 23, 2013 at 11:49:01AM -0700, Brandon Casey wrote:\n\n> Brandon Casey (16):\n>   contrib/git-credential-gnome-keyring.c: remove unnecessary\n>     pre-declarations\n> [...]\n\nThanks, I think this is a good change. There were patches[1] from\nPhilipp about a year ago that went in the opposite direction, factoring\nout common credential functions to be used by several helpers. We ended\nup not merging them, because porting the wincred helper to the generic\nimplementation introduced complications.\n\nAnd that was part of the reason for splitting out the helpers in the\nfirst place: to let them worry about their own individual\nsystem-specific quirks (and take advantage of system-specific helpers).\nIOW, to make the gnome helper more gnome-y than git-y. And your patches\ngo in that direction, which I think is sane.\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/204154/focus=204157\n\n>   contrib/git-credential-gnome-keyring.c: report failure to store\n>     password\n\nYour subject lines are rather on the long side. I wonder if they would\nbe more readable as just:\n\n  gnome-keyring: report failure to store password\n\nand so forth. Anyone familiar with git.git knows that the \"contrib\"\nand \"git-credential-\" bits are implied by \"gnome-keyring\". But it's not\na huge deal either way.\n\n> Inserts a patch to fix the style issues for block statements.\n> i.e. use \"if ()\" instead of \"if()\"\n\nThere are a ton of other style issues in the existing code (lack of\nwhitespace around operators and function arguments, and \"char* foo\"\ninstead of \"char *foo\" were the two I noticed). As a separate contrib/\nproject, I'm not that concerned, and I would say it is up to whoever is\nnominally in charge of maintaining that contrib directory (Philipp or\nJohn, in this case).\n\n-Peff\n"},{"id":"229034","messageId":"xmqqppr6b1jl.fsf@gitster.dls.corp.google.com","threadId":"34999","inReplyTo":"1379962157-1338-1-git-send-email-bcasey@nvidia.com","subject":"Re: [PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-10-15T22:40:45Z","receivedAt":"2013-10-15T22:40:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This seems to post-date what Jonathan has kept in his 'pu'; is this\nthe latest (I have a huge backlog to wade through, so I'd rather\nskip it if another reroll is coming and move on to other topics).\n\nThanks.\n"},{"id":"229038","messageId":"525DC7B1.5090406@nvidia.com","threadId":"34999","inReplyTo":"xmqqppr6b1jl.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Brandon Casey","fromEmail":"bcasey@nvidia.com","sentAt":"2013-10-15T22:54:41Z","receivedAt":"2013-10-15T22:54:41Z","isPatch":true,"sender":{"key":"bcasey@nvidia.com","avatar":null},"body":"On 10/15/2013 3:40 PM, Junio C Hamano wrote:\n> This seems to post-date what Jonathan has kept in his 'pu'; is this\n> the latest (I have a huge backlog to wade through, so I'd rather\n> skip it if another reroll is coming and move on to other topics).\n> \n> Thanks.\n\nThis is the latest.\n\nI didn't have anything else planned.  I think Philipp planned to submit\nsome style cleanups on top for areas of the code I didn't touch.\n\n-Brandon\n\n\n-----------------------------------------------------------------------------------\nThis email message is for the sole use of the intended recipient(s) and may contain\nconfidential information.  Any unauthorized review, use, disclosure or distribution\nis prohibited.  If you are not the intended recipient, please contact the sender by\nreply email and destroy all copies of the original message.\n-----------------------------------------------------------------------------------\n"},{"id":"229090","messageId":"xmqqsiw06gm4.fsf@gitster.dls.corp.google.com","threadId":"34999","inReplyTo":"525DC7B1.5090406@nvidia.com","subject":"Re: [PATCH v2 00/16] Make Gnome Credential helper more Gnome-y and support ancient distros","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-10-16T21:38:43Z","receivedAt":"2013-10-16T21:38:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <bcasey@nvidia.com> writes:\n\n> On 10/15/2013 3:40 PM, Junio C Hamano wrote:\n>> This seems to post-date what Jonathan has kept in his 'pu'; is this\n>> the latest (I have a huge backlog to wade through, so I'd rather\n>> skip it if another reroll is coming and move on to other topics).\n>> \n>> Thanks.\n>\n> This is the latest.\n>\n> I didn't have anything else planned.  I think Philipp planned to submit\n> some style cleanups on top for areas of the code I didn't touch.\n\nThanks; will requeue.\n"}]}