~ubuntu-branches/ubuntu/karmic/cyrus-imapd-2.2/karmic

« back to all changes in this revision

Viewing changes to timsieved/actions.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-07-11 18:51:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060711185139-gl3oe4tppp7g3euf
Tags: 2.2.13-4ubuntu1
Synchronize with Debian unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* actions.c -- executes the commands for timsieved
2
2
 * Tim Martin
3
 
 * $Id: actions.c,v 1.36 2003/10/22 18:50:31 rjs3 Exp $
 
3
 * $Id: actions.c,v 1.38 2005/11/18 14:18:18 murch Exp $
4
4
 */
5
5
/*
6
6
 * Copyright (c) 1998-2003 Carnegie Mellon University.  All rights reserved.
77
77
/* after a user has authentication, our current directory is their Sieve 
78
78
   directory! */
79
79
 
 
80
extern int sieved_userisadmin;
80
81
char *sieve_dir = NULL;
81
82
 
82
83
int actions_init(void)
99
100
 
100
101
int actions_setuser(const char *userid)
101
102
{
102
 
  char hash, *domain;
103
 
  char *foo=sieve_dir;
 
103
  char userbuf[1024], *user, *domain = NULL;
 
104
  char *foo = sieve_dir;
 
105
  size_t size = 1024, len;
104
106
  int result;  
105
107
 
106
 
  sieve_dir=(char *) xmalloc(1024);
 
108
  sieve_dir = (char *) xzmalloc(size+1);
107
109
  
108
 
  if (config_virtdomains && (domain = strchr(userid, '@'))) {
109
 
      char d = (char) dir_hash_c(domain+1);
110
 
      *domain = '\0';  /* split user@domain */
111
 
      hash = (char) dir_hash_c(userid);
112
 
      snprintf(sieve_dir, 1023, "%s%s%c/%s/%c/%s",
113
 
               foo, FNAME_DOMAINDIR, d, domain+1,
114
 
               hash, userid);
115
 
      *domain = '@';  /* reassemble user@domain */
 
110
  user = (char *) userid;
 
111
  if (config_virtdomains && strchr(user, '@')) {
 
112
      /* split the user and domain */
 
113
      strlcpy(userbuf, userid, sizeof(userbuf));
 
114
      user = userbuf;
 
115
      if ((domain = strrchr(user, '@'))) *domain++ = '\0';
 
116
  }
 
117
 
 
118
  len = strlcpy(sieve_dir, foo, size);
 
119
 
 
120
  if (domain) {
 
121
      char dhash = (char) dir_hash_c(domain);
 
122
      len += snprintf(sieve_dir+len, size-len, "%s%c/%s",
 
123
                      FNAME_DOMAINDIR, dhash, domain);
 
124
  }
 
125
 
 
126
  if (sieved_userisadmin) {
 
127
      strlcat(sieve_dir, "/global", size);
116
128
  }
117
129
  else {
118
 
      hash = (char) dir_hash_c(userid);
119
 
    
120
 
      snprintf(sieve_dir, 1023, "%s/%c/%s", foo, hash,userid);
 
130
      char hash = (char) dir_hash_c(user);
 
131
      snprintf(sieve_dir+len, size-len, "/%c/%s", hash, user);
121
132
  }
122
133
 
123
134
  result = chdir(sieve_dir);
163
174
                 int starttls_done, int authenticated)
164
175
{
165
176
    const char *sasllist;
166
 
    unsigned mechcount;
 
177
    int mechcount;
167
178
 
168
179
    /* implementation */
169
180
    prot_printf(conn, "\"IMPLEMENTATION\" \"Cyrus timsieved %s\"\r\n",