]> rtime.felk.cvut.cz Git - notmuch.git/blobdiff - notmuch-config.c
config: read user.name from $NAME if set
[notmuch.git] / notmuch-config.c
index 8d286538c086180ef9c88ef6a00315c95fc67fea..8f1f48d07b51301a0f08be1a39b7ab6beb3ba7f1 100644 (file)
@@ -219,7 +219,8 @@ get_username_from_passwd_file (void *ctx)
  *
  *             database_path:          $HOME/mail
  *
- *             user_name:              From /etc/passwd
+ *             user_name:              $NAME variable if set, otherwise
+ *                                     read from /etc/passwd
  *
  *             user_primary_mail:      $EMAIL variable if set, otherwise
  *                                     constructed from the username and
@@ -329,7 +330,9 @@ notmuch_config_open (void *ctx,
     }
 
     if (notmuch_config_get_user_name (config) == NULL) {
-       char *name = get_name_from_passwd_file (config);
+       char *name = getenv ("NAME");
+       if (! name)
+           name = get_name_from_passwd_file (config);
        notmuch_config_set_user_name (config, name);
        talloc_free (name);
     }
@@ -454,7 +457,7 @@ notmuch_config_save (notmuch_config_t *config)
     }
 
     /* Try not to overwrite symlinks. */
-    filename = realpath (config->filename, NULL);
+    filename = canonicalize_file_name (config->filename);
     if (! filename) {
        if (errno == ENOENT) {
            filename = strdup (config->filename);