Commit 23fd0592 23fd0592e1bba8ad05f44d24e08b47d77314154f by Sergey Poznyakoff

New mtstailor variable "username"

1 parent a581fd70
Showing 1 changed file with 32 additions and 2 deletions
...@@ -303,7 +303,7 @@ read_mts_profile () ...@@ -303,7 +303,7 @@ read_mts_profile ()
303 char *hostname = NULL; 303 char *hostname = NULL;
304 int rc; 304 int rc;
305 mh_context_t *local_profile; 305 mh_context_t *local_profile;
306 306
307 p = mh_expand_name (MHLIBDIR, "mtstailor", 0); 307 p = mh_expand_name (MHLIBDIR, "mtstailor", 0);
308 mts_profile = mh_context_create (p, 1); 308 mts_profile = mh_context_create (p, 1);
309 mh_context_read (mts_profile); 309 mh_context_read (mts_profile);
...@@ -321,7 +321,7 @@ read_mts_profile () ...@@ -321,7 +321,7 @@ read_mts_profile ()
321 } 321 }
322 else if ((rc = mu_get_host_name (&hostname))) 322 else if ((rc = mu_get_host_name (&hostname)))
323 mu_error (_("Cannot get system host name: %s"), mu_strerror (rc)); 323 mu_error (_("Cannot get system host name: %s"), mu_strerror (rc));
324 324
325 if ((p = mh_context_get_value (mts_profile, "localdomain", NULL))) 325 if ((p = mh_context_get_value (mts_profile, "localdomain", NULL)))
326 { 326 {
327 char *newdomain; 327 char *newdomain;
...@@ -341,6 +341,36 @@ read_mts_profile () ...@@ -341,6 +341,36 @@ read_mts_profile ()
341 exit (1); 341 exit (1);
342 } 342 }
343 } 343 }
344
345 if ((p = mh_context_get_value (mts_profile, "username", NULL)))
346 {
347 size_t len;
348 const char *domain;
349 char *newemail;
350 int rc;
351
352 rc = mu_get_user_email_domain (&domain);
353 if (rc)
354 {
355 mu_error (_("Cannot get user email: %s"), mu_strerror (rc));
356 exit (1);
357 }
358 len = strlen (p) + 1 + strlen (domain) + 1;
359 newemail = xmalloc (len);
360 strcpy (newemail, p);
361 strcat (newemail, "@");
362 strcat (newemail, domain);
363
364 rc = mu_set_user_email (newemail);
365 if (rc)
366 {
367 mu_error (_("Cannot set user email (%s): %s"),
368 newemail, mu_strerror (rc));
369 exit (1);
370 }
371
372 free (newemail);
373 }
344 } 374 }
345 375
346 376
......