X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/cc3456940b6b30a0fc4f83226c34e4e873336cd0..5dba54ab01bce6ca8a6f1fd64b46cd304501b596:/disobedience/login.c diff --git a/disobedience/login.c b/disobedience/login.c index a02c1c6..fb8cf71 100644 --- a/disobedience/login.c +++ b/disobedience/login.c @@ -120,11 +120,13 @@ static void set_service(struct config *c, const char *s) { } static void set_username(struct config *c, const char *s) { - c->username = s; + xfree(c->username); + c->username = xstrdup(s); } static void set_password(struct config *c, const char *s) { - c->password = s; + xfree(c->password); + c->password = xstrdup(s); } /** @brief Table used to generate the form */ @@ -154,10 +156,10 @@ static void login_update_config(struct config *c) { /** @brief Save current login details */ static void login_save_config(void) { - char *path = config_userconf(0, 0), *tmp; + char *tmp; FILE *fp; - byte_xasprintf(&tmp, "%s.tmp", path); + byte_xasprintf(&tmp, "%s.tmp", userconfigfile); /* Make sure the directory exists; don't care if it already exists. */ mkdir(d_dirname(tmp), 02700); /* Write out the file */ @@ -188,7 +190,7 @@ static void login_save_config(void) { goto done; } /* Rename into place */ - if(rename(tmp, path) < 0) { + if(rename(tmp, userconfigfile) < 0) { fpopup_msg(GTK_MESSAGE_ERROR, "error renaming %s: %s", tmp, strerror(errno)); goto done;