#include "mail-storage.h"
#include <stdlib.h>
+#include <unistd.h>
#include <syslog.h>
#define IS_STANDALONE() \
const char *user;
user = getenv("USER");
- if (user == NULL) user = "??";
+ if (user == NULL) {
+ if (!IS_STANDALONE())
+ user = getlogin();
+ if (user == NULL)
+ user = "??";
+ }
if (strlen(user) >= sizeof(log_prefix)-6) {
/* quite a long user name, cut it */
user = t_strndup(user, sizeof(log_prefix)-6-2);
{
struct client *client;
struct mail_storage *storage;
- const char *mail, *str;
+ const char *user, *mail, *str;
int hin, hout;
lib_init_signals(sig_quit);
- if (getenv("USER") == NULL)
- i_fatal("USER environment missing");
+ user = getenv("USER");
+ if (user == NULL) {
+ if (!IS_STANDALONE())
+ user = getlogin();
+ if (user == NULL)
+ i_fatal("USER environment missing");
+ }
hin = 0; hout = 1;
rawlog_open(&hin, &hout);
mail = t_strconcat("maildir:", mail, NULL);
}
- storage = mail_storage_create_with_data(mail, getenv("USER"));
+ storage = mail_storage_create_with_data(mail, user);
if (storage == NULL) {
/* failed */
if (mail != NULL && *mail != '\0')
if (IS_STANDALONE()) {
client_send_line(client, t_strconcat(
"* PREAUTH [CAPABILITY "CAPABILITY_STRING"] "
- "Logged in as ", getenv("USER"), NULL));
+ "Logged in as ", user, NULL));
}
}